1 | //===== eAthena Script ====================================== |
---|
2 | //= Hall of Fame |
---|
3 | //=========================================================== |
---|
4 | //===== By ================================================== |
---|
5 | //= [Lance] |
---|
6 | //= Idea from emilylee78 |
---|
7 | //===== Version ============================================= |
---|
8 | //= 2.4 FINAL |
---|
9 | //===== Compatible With ===================================== |
---|
10 | //= eAthena SVN and Freya SVN |
---|
11 | //===== Description ========================================= |
---|
12 | //= A Hall of Fame framework. Will update the list on every |
---|
13 | //= login and logout in a safe manner. |
---|
14 | //= |
---|
15 | //= Usage: callfunc "printHallOfFame", $; |
---|
16 | //= $ - Can be either 0 or 1. |
---|
17 | //= 0 - Display the current rankings. |
---|
18 | //= 1 - Display last week's rankings. |
---|
19 | //= Note : Remember to put a close; after calling it. |
---|
20 | //===== Comments ============================================ |
---|
21 | //= 1.0 - Initial beta release [Lance] |
---|
22 | //= 1.1 - Fixed typos. Optimized a teeny bit. [Lance] |
---|
23 | //= 1.2 - Bug fixes. [Lance] |
---|
24 | //= 1.3 - Added a more realistic shuffling. [Lance] |
---|
25 | //= 1.4 - Added Weekly Top 10 list. [Lance] |
---|
26 | //= 1.5 - Friggin typos =< + Better shuffling [Lance] |
---|
27 | //= 1.6 - Bugfixes [Lance] |
---|
28 | //= 1.7 - More bugfixes. Type mismatch =P [Lance] |
---|
29 | //= 2.0 - Exclude GMs and add recovery plan. |
---|
30 | //= Suggested by EvilPoringOfDooom. [Lance] |
---|
31 | //= 2.1 - Typo.. again.. T_T [Lance] |
---|
32 | //= 2.2 - Minor updates and added Jury [Lance] |
---|
33 | //= 2.3 - Utilizing eAthena's new scripting engine [Lance] |
---|
34 | //= 2.4 - Minor bug fix with event script label (bugport:722) [Samura22] |
---|
35 | //=========================================================== |
---|
36 | |
---|
37 | prontera,0,0,0 script OnPCLoginEvent -1,{ |
---|
38 | OnPCLoginEvent: |
---|
39 | callfunc "HallOfFameInit"; |
---|
40 | end; |
---|
41 | |
---|
42 | OnInit: |
---|
43 | // Total Number of Players in Hall of Fame |
---|
44 | // ======================================= |
---|
45 | set $HoF_totalCount, 10; |
---|
46 | // Reshuffle (Will affect perfomance) ==== |
---|
47 | set $HoF_reshuffle, 1; |
---|
48 | // Minimum GM Lvl to be excluded from HoF= |
---|
49 | set $HoF_minGMLvl, 99; |
---|
50 | // Recovery Plan to Remove GMs ============ |
---|
51 | set $@HoF_recovery, 0; |
---|
52 | // ======================================= |
---|
53 | |
---|
54 | //set $HoF_totalCount, $HoF_totalCount - 1; |
---|
55 | set $@FebruaryD, 28; |
---|
56 | if((gettime(7) % 4) == 0) { |
---|
57 | set $@FebruaryD, 29; |
---|
58 | } |
---|
59 | setarray $@MonthDayThing[1],31, $@FebruaryD,31,30,31,30,31,31,30,31,30,31; |
---|
60 | set $@HoF_TimeUpdateD, $HoF_LastUpdateD; |
---|
61 | set $@HoF_TimeUpdateM, $HoF_LastUpdateM; |
---|
62 | set $@HoF_TimeUpdateY, $HoF_LastUpdateY; |
---|
63 | // Time to do some maths |
---|
64 | set $@TimeNowD, gettime(5); |
---|
65 | set $@TimeNowM, gettime(6); |
---|
66 | set $@TimeNowY, gettime(7); |
---|
67 | // Debug Message -- |
---|
68 | debugmes "[Hall of Fame] Last Update is Year " + $@HoF_TimeUpdateY + " Month " + $@HoF_TimeUpdateM + " Day " + $@HoF_TimeUpdateD; |
---|
69 | debugmes "[Hall of Fame] Today is Year " + $@TimeNowY + " Month " + $@TimeNowM + " Day " + $@TimeNowD; |
---|
70 | if(($@TimeNowD - $@HoF_TimeUpdateD) < 0){ |
---|
71 | set $@TimeNowD, $@TimeNowD + $@MonthDayThing[$@TimeNowM]; |
---|
72 | set $@TimeNowM, $@TimeNowM - 1; |
---|
73 | } |
---|
74 | set $@GapD, $@TimeNowD - $@HoF_TimeUpdateD; |
---|
75 | if(($@TimeNowM - $@HoF_TimeUpdateM) < 0){ |
---|
76 | set $@TimeNowM, $@TimeNowM + 12; |
---|
77 | set $@TimeNowY, $@TimeNowY - 1; |
---|
78 | } |
---|
79 | set $@GapM, $@TimeNowM - $@HoF_TimeUpdateM; |
---|
80 | set $@GapY, $@TimeNowY - $@HoF_TimeUpdateY; |
---|
81 | debugmes "[Hall of Fame] Gap is " + $@GapY + " Years " + $@GapM + " Months " + $@GapD + " Days."; |
---|
82 | if($@GapY > 0 || $@GapM > 0 || $@GapD >= 7) { |
---|
83 | callfunc "hallOfFameReset"; // Phew.. |
---|
84 | } |
---|
85 | end; |
---|
86 | |
---|
87 | OnClock0000: |
---|
88 | set $HoF_UpdateCount, $HoF_UpdateCount + 1; |
---|
89 | if($HoF_UpdateCount == 7) { |
---|
90 | callfunc "hallOfFameReset"; |
---|
91 | } |
---|
92 | end; |
---|
93 | } |
---|
94 | |
---|
95 | prontera,0,0,0 script PCLogoutEvent -1,{ |
---|
96 | OnPCLogoutEvent: |
---|
97 | callfunc "HallOfFameInit"; |
---|
98 | end; |
---|
99 | } |
---|
100 | |
---|
101 | function script hallOfFameReset { |
---|
102 | copyarray $HoF_LadderNameO$[0], $HoF_LadderName$[0], $HoF_totalCount; |
---|
103 | copyarray $HoF_LadderBLevelO[0], $HoF_LadderBLevel[0], $HoF_totalCount; |
---|
104 | copyarray $HoF_LadderJLevelO[0], $HoF_LadderJLevel[0], $HoF_totalCount; |
---|
105 | copyarray $HoF_LadderZenyO[0], $HoF_LadderZeny[0], $HoF_totalCount; |
---|
106 | deletearray $HoF_LadderName$[0], $HoF_totalCount; |
---|
107 | deletearray $HoF_LadderBLevel[0], $HoF_totalCount; |
---|
108 | deletearray $HoF_LadderJLevel[0], $HoF_totalCount; |
---|
109 | deletearray $HoF_LadderZeny[0], $HoF_totalCount; |
---|
110 | set $HoF_LastUpdateD, gettime(5); |
---|
111 | set $HoF_LastUpdateM, gettime(6); |
---|
112 | set $HoF_LastUpdateY, gettime(7); |
---|
113 | set $HoF_UpdateCount, 0; |
---|
114 | debugmes "[Hall of Fame] System Reset Invoked!"; |
---|
115 | return; |
---|
116 | } |
---|
117 | |
---|
118 | function script HallOfFameInit { |
---|
119 | if(getgmlevel() >= $HoF_minGMLvl && $@HoF_recovery != 1) { |
---|
120 | set PCLogoutEvent, 0; |
---|
121 | } else { |
---|
122 | set PCLogoutEvent, 1; |
---|
123 | callfunc "updateHallofFame", $HoF_reshuffle; |
---|
124 | } |
---|
125 | return; |
---|
126 | } |
---|
127 | |
---|
128 | function script updateHallofFame { |
---|
129 | set @i, 0; |
---|
130 | if(getarg(0) == 1){ |
---|
131 | goto L_ShuffleName; |
---|
132 | } |
---|
133 | if(BaseLevel >= $HoF_LadderBLevel[$HoF_totalCount-1]){ |
---|
134 | goto L_checkBase; |
---|
135 | } |
---|
136 | goto L_End; |
---|
137 | |
---|
138 | L_ShuffleName: |
---|
139 | if($HoF_LadderName$[@i] == strcharinfo(0)) { |
---|
140 | goto L_ShuffleScore; |
---|
141 | } |
---|
142 | if(@i == $HoF_totalCount-1) { |
---|
143 | goto L_checkEntry; |
---|
144 | } |
---|
145 | set @i, @i + 1; |
---|
146 | goto L_ShuffleName; |
---|
147 | |
---|
148 | L_ShuffleScore: |
---|
149 | deletearray $HoF_LadderName$[@i],1; |
---|
150 | deletearray $HoF_LadderZeny[@i],1; |
---|
151 | deletearray $HoF_LadderJLevel[@i],1; |
---|
152 | deletearray $HoF_LadderBLevel[@i],1; |
---|
153 | goto L_ShuffleName; |
---|
154 | |
---|
155 | L_checkEntry: |
---|
156 | if(getgmlevel() >= $HoF_minGMLvl){ |
---|
157 | end; |
---|
158 | } |
---|
159 | set @i, 0; |
---|
160 | goto L_checkBase; |
---|
161 | |
---|
162 | L_checkBase: |
---|
163 | if(BaseLevel >= $HoF_LadderBLevel[@i]) { |
---|
164 | goto L_BaseOK; |
---|
165 | } else { |
---|
166 | goto L_Increment; |
---|
167 | } |
---|
168 | |
---|
169 | L_BaseOK: |
---|
170 | if(BaseLevel == $HoF_LadderBLevel[@i]){ |
---|
171 | goto L_BaseSameLoop; |
---|
172 | } else { |
---|
173 | goto L_NewEntry; |
---|
174 | } |
---|
175 | |
---|
176 | L_BaseSameLoop: |
---|
177 | if(JobLevel >= $HoF_LadderJLevel[@i]) { |
---|
178 | goto L_JobOK; |
---|
179 | } else if(Zeny >= $HoF_LadderZeny[@i]) { |
---|
180 | goto L_ZenyOK; |
---|
181 | } |
---|
182 | goto L_Increment; |
---|
183 | |
---|
184 | L_JobOK: |
---|
185 | if(JobLevel == $HoF_LadderJLevel[@i]) { |
---|
186 | goto L_JobSame; |
---|
187 | } else { |
---|
188 | goto L_NewEntry; |
---|
189 | } |
---|
190 | |
---|
191 | L_ZenyOK: |
---|
192 | if(Zeny == $HoF_LadderZeny[@i]){ |
---|
193 | goto L_Increment; |
---|
194 | } else { |
---|
195 | goto L_NewEntry; |
---|
196 | } |
---|
197 | |
---|
198 | L_JobSame: |
---|
199 | if(Zeny >= $HoF_LadderZeny[@i]) { |
---|
200 | goto L_ZenyOK; |
---|
201 | } else { |
---|
202 | goto L_Increment; |
---|
203 | } |
---|
204 | |
---|
205 | L_NewEntry: |
---|
206 | callfunc "hallOfFameNewEntry", @i, strcharinfo(0), BaseLevel, JobLevel, Zeny; |
---|
207 | end; |
---|
208 | |
---|
209 | L_Increment: |
---|
210 | if(@i == $HoF_totalCount-1) { |
---|
211 | goto L_End; |
---|
212 | } else { |
---|
213 | set @i, @i + 1; |
---|
214 | goto L_checkBase; |
---|
215 | } |
---|
216 | |
---|
217 | L_End: |
---|
218 | return; |
---|
219 | |
---|
220 | } |
---|
221 | |
---|
222 | |
---|
223 | function script hallOfFameNewEntry { |
---|
224 | if(getarg(0) == 0) goto L_New_Entry; |
---|
225 | else if(getarg(1) != $HoF_LadderName$[getarg(0) - 1]) goto L_New_Entry; |
---|
226 | return; |
---|
227 | |
---|
228 | L_New_Entry: |
---|
229 | set @startPos, getarg(0); |
---|
230 | copyarray @HoF_LadderNameB$[0], $HoF_LadderName$[@startPos], $HoF_totalCount; |
---|
231 | copyarray @HoF_LadderBLevelB[0], $HoF_LadderBLevel[@startPos], $HoF_totalCount; |
---|
232 | copyarray @HoF_LadderJLevelB[0], $HoF_LadderJLevel[@startPos], $HoF_totalCount; |
---|
233 | copyarray @HoF_LadderZenyB[0], $HoF_LadderZeny[@startPos], $HoF_totalCount; |
---|
234 | setarray $HoF_LadderName$[@startPos], getarg(1); |
---|
235 | setarray $HoF_LadderBLevel[@startPos], getarg(2); |
---|
236 | setarray $HoF_LadderJLevel[@startPos], getarg(3); |
---|
237 | setarray $HoF_LadderZeny[@startPos], getarg(4); |
---|
238 | set @startPos, @startPos + 1; |
---|
239 | set @limitPos, $HoF_totalCount - @startPos; |
---|
240 | copyarray $HoF_LadderName$[@startPos], @HoF_LadderNameB$[0], @limitPos; |
---|
241 | copyarray $HoF_LadderBLevel[@startPos], @HoF_LadderBLevelB[0], @limitPos; |
---|
242 | copyarray $HoF_LadderJLevel[@startPos], @HoF_LadderJLevelB[0], @limitPos; |
---|
243 | copyarray $HoF_LadderZeny[@startPos], @HoF_LadderZenyB[0], @limitPos; |
---|
244 | announce "[Hall of Fame] " + getarg(1) + " has made his/herself onto the No. " + @startPos + " ranking in Hall of Fame!", bc_all; |
---|
245 | return; |
---|
246 | } |
---|
247 | |
---|
248 | function script printHallOfFame { |
---|
249 | if(getarg(0) == 1) { |
---|
250 | mes "[Hall of Fame] - Last Week's Rankings"; |
---|
251 | for(set @loop, 0; @loop < $HoF_totalCount; set @loop, @loop + 1){ |
---|
252 | mes "^ff0000"; |
---|
253 | mes "Position No. " + (@loop + 1) + ":^0000ff"; |
---|
254 | mes "+================================+"; |
---|
255 | mes "^000000Name :" + $HoF_LadderNameO$[@loop]; |
---|
256 | mes "BLvl :" + $HoF_LadderBLevelO[@loop]; |
---|
257 | mes "JLvl :" + $HoF_LadderJLevelO[@loop]; |
---|
258 | mes "Zeny :" + $HoF_LadderZenyO[@loop] + "^0000ff"; |
---|
259 | mes "+================================+^000000"; |
---|
260 | } |
---|
261 | } else { |
---|
262 | mes "[Hall of Fame] - Current Rankings"; |
---|
263 | for(set @loop, 0; @loop < $HoF_totalCount; set @loop, @loop + 1){ |
---|
264 | mes "^ff0000"; |
---|
265 | mes "Position No. " + (@loop + 1) + ":^0000ff"; |
---|
266 | mes "+================================+"; |
---|
267 | mes "^000000Name :" + $HoF_LadderName$[@loop]; |
---|
268 | mes "BLvl :" + $HoF_LadderBLevel[@loop]; |
---|
269 | mes "JLvl :" + $HoF_LadderJLevel[@loop]; |
---|
270 | mes "Zeny :" + $HoF_LadderZeny[@loop] + "^0000ff"; |
---|
271 | mes "+================================+^000000"; |
---|
272 | } |
---|
273 | } |
---|
274 | return; |
---|
275 | } |
---|
276 | |
---|
277 | prontera,164,134,2 script Jury 109,{ |
---|
278 | mes "[Jury]"; |
---|
279 | mes "Good day. Would you like to view the Hall of Fame?"; |
---|
280 | next; |
---|
281 | menu "Yes",L_OK,"No",L_QUIT; |
---|
282 | |
---|
283 | L_OK: |
---|
284 | mes "[Jury]"; |
---|
285 | mes "Would you like to view the current or the past rankings?"; |
---|
286 | |
---|
287 | L_MENU: |
---|
288 | next; |
---|
289 | menu "Current", L_CUR, "Past", -,"Nevermind",L_QUIT; |
---|
290 | callfunc "printHallOfFame",1; |
---|
291 | goto L_MENU; |
---|
292 | |
---|
293 | L_CUR: |
---|
294 | callfunc "printHallOfFame",0; |
---|
295 | goto L_MENU; |
---|
296 | |
---|
297 | L_QUIT: |
---|
298 | mes "[Jury]"; |
---|
299 | mes "Have a nice day then."; |
---|
300 | close; |
---|
301 | |
---|
302 | } |
---|