FR_HallOfFame.c 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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. prontera,0,0,0 script OnPCLoginEvent -1,{
  37. OnPCLoginEvent:
  38. callfunc "HallOfFameInit";
  39. end;
  40. OnInit:
  41. // Total Number of Players in Hall of Fame
  42. // =======================================
  43. set $HoF_totalCount, 10;
  44. // Reshuffle (Will affect perfomance) ====
  45. set $HoF_reshuffle, 1;
  46. // Minimum GM Lvl to be excluded from HoF=
  47. set $HoF_minGMLvl, 99;
  48. // Recovery Plan to Remove GMs ============
  49. set $@HoF_recovery, 0;
  50. // =======================================
  51. set $HoF_totalCount, $HoF_totalCount - 1;
  52. set $@FebruaryD, 28;
  53. if((gettime(7) % 4) == 0) {
  54. set $@FebruaryD, 29;
  55. }
  56. setarray $@MonthDayThing[1],31, $@FebruaryD,31,30,31,30,31,31,30,31,30,31;
  57. set $@HoF_TimeUpdateD, $HoF_LastUpdateD;
  58. set $@HoF_TimeUpdateM, $HoF_LastUpdateM;
  59. set $@HoF_TimeUpdateY, $HoF_LastUpdateY;
  60. // Time to do some maths
  61. set $@TimeNowD, gettime(5);
  62. set $@TimeNowM, gettime(6);
  63. set $@TimeNowY, gettime(7);
  64. // Debug Message --
  65. debugmes "[Hall of Fame] Last Update is Year " + $@HoF_TimeUpdateY + " Month " + $@HoF_TimeUpdateM + " Day " + $@HoF_TimeUpdateD;
  66. debugmes "[Hall of Fame] Today is Year " + $@TimeNowY + " Month " + $@TimeNowM + " Day " + $@TimeNowD;
  67. if(($@TimeNowD - $@HoF_TimeUpdateD) < 0){
  68. set $@TimeNowD, $@TimeNowD + $@MonthDayThing[$@TimeNowM];
  69. set $@TimeNowM, $@TimeNowM - 1;
  70. }
  71. set $@GapD, $@TimeNowD - $@HoF_TimeUpdateD;
  72. if(($@TimeNowM - $@HoF_TimeUpdateM) < 0){
  73. set $@TimeNowM, $@TimeNowM + 12;
  74. set $@TimeNowY, $@TimeNowY - 1;
  75. }
  76. set $@GapM, $@TimeNowM - $@HoF_TimeUpdateM;
  77. set $@GapY, $@TimeNowY - $@HoF_TimeUpdateY;
  78. debugmes "[Hall of Fame] Gap is " + $@GapY + " Years " + $@GapM + " Months " + $@GapD + " Days.";
  79. if($@GapY > 0 || $@GapM > 0 || $@GapD >= 7) {
  80. callfunc "hallOfFameReset"; // Phew..
  81. }
  82. end;
  83. OnClock0000:
  84. set $HoF_UpdateCount, $HoF_UpdateCount + 1;
  85. if($HoF_UpdateCount == 7) {
  86. callfunc "hallOfFameReset";
  87. }
  88. end;
  89. }
  90. prontera,0,0,0 script PCLogoutEvent -1,{
  91. OnPCLogoutEvent:
  92. callfunc "HallOfFameInit";
  93. end;
  94. }
  95. function script hallOfFameReset {
  96. copyarray $HoF_LadderNameO$[0], $HoF_LadderName$[0], $HoF_totalCount;
  97. copyarray $HoF_LadderBLevelO[0], $HoF_LadderBLevel[0], $HoF_totalCount;
  98. copyarray $HoF_LadderJLevelO[0], $HoF_LadderJLevel[0], $HoF_totalCount;
  99. copyarray $HoF_LadderZenyO[0], $HoF_LadderZeny[0], $HoF_totalCount;
  100. set $@number, $HoF_totalCount + 1;
  101. deletearray $HoF_LadderName$[0], $@number;
  102. deletearray $HoF_LadderBLevel[0], $@number;
  103. deletearray $HoF_LadderJLevel[0], $@number;
  104. deletearray $HoF_LadderZeny[0], $@number;
  105. set $HoF_LastUpdateD, gettime(5);
  106. set $HoF_LastUpdateM, gettime(6);
  107. set $HoF_LastUpdateY, gettime(7);
  108. set $HoF_UpdateCount, 0;
  109. debugmes "[Hall of Fame] System Reset Invoked!";
  110. return;
  111. }
  112. function script HallOfFameInit {
  113. if(getgmlevel() >= $HoF_minGMLvl && $@HoF_recovery != 1) {
  114. set PCLogoutEvent, 0;
  115. } else {
  116. set PCLogoutEvent, 1;
  117. callfunc "updateHallofFame", $HoF_reshuffle;
  118. }
  119. return;
  120. }
  121. function script updateHallofFame {
  122. set @i, 0;
  123. if(getarg(0) == 1){
  124. goto L_ShuffleName;
  125. }
  126. if(BaseLevel >= $HoF_LadderBLevel[$HoF_totalCount]){
  127. goto L_checkBase;
  128. }
  129. goto L_End;
  130. L_ShuffleName:
  131. if($HoF_LadderName$[@i] == strcharinfo(0)) {
  132. goto L_ShuffleScore;
  133. }
  134. if(@i == $HoF_totalCount) {
  135. goto L_checkEntry;
  136. }
  137. set @i, @i + 1;
  138. goto L_ShuffleName;
  139. L_ShuffleScore:
  140. deletearray $HoF_LadderName$[@i],1;
  141. deletearray $HoF_LadderZeny[@i],1;
  142. deletearray $HoF_LadderJLevel[@i],1;
  143. deletearray $HoF_LadderBLevel[@i],1;
  144. goto L_ShuffleName;
  145. L_checkEntry:
  146. if(getgmlevel() >= $HoF_minGMLvl){
  147. end;
  148. }
  149. set @i, 0;
  150. goto L_checkBase;
  151. L_checkBase:
  152. if(BaseLevel >= $HoF_LadderBLevel[@i]) {
  153. goto L_BaseOK;
  154. } else {
  155. goto L_Increment;
  156. }
  157. L_BaseOK:
  158. if(BaseLevel == $HoF_LadderBLevel[@i]){
  159. goto L_BaseSameLoop;
  160. } else {
  161. goto L_NewEntry;
  162. }
  163. L_BaseSameLoop:
  164. if(JobLevel >= $HoF_LadderJLevel[@i]) {
  165. goto L_JobOK;
  166. } else if(Zeny >= $HoF_LadderZeny[@i]) {
  167. goto L_ZenyOK;
  168. }
  169. goto L_Increment;
  170. L_JobOK:
  171. if(JobLevel == $HoF_LadderJLevel[@i]) {
  172. goto L_JobSame;
  173. } else {
  174. goto L_NewEntry;
  175. }
  176. L_ZenyOK:
  177. if(Zeny == $HoF_LadderZeny[@i]){
  178. goto L_Increment;
  179. } else {
  180. goto L_NewEntry;
  181. }
  182. L_JobSame:
  183. if(Zeny >= $HoF_LadderZeny[@i]) {
  184. goto L_ZenyOK;
  185. } else {
  186. goto L_Increment;
  187. }
  188. L_NewEntry:
  189. callfunc "hallOfFameNewEntry", @i, strcharinfo(0), BaseLevel, JobLevel, Zeny;
  190. end;
  191. L_Increment:
  192. if(@i == $HoF_totalCount) {
  193. goto L_End;
  194. } else {
  195. set @i, @i + 1;
  196. goto L_checkBase;
  197. }
  198. L_End:
  199. return;
  200. }
  201. function script hallOfFameNewEntry {
  202. if(getarg(0) == 0) goto L_New_Entry;
  203. else if(getarg(1) != $HoF_LadderName$[getarg(0) - 1]) goto L_New_Entry;
  204. return;
  205. L_New_Entry:
  206. set @startPos, getarg(0);
  207. copyarray @HoF_LadderNameB$[0], $HoF_LadderName$[@startPos], $HoF_totalCount;
  208. copyarray @HoF_LadderBLevelB[0], $HoF_LadderBLevel[@startPos], $HoF_totalCount;
  209. copyarray @HoF_LadderJLevelB[0], $HoF_LadderJLevel[@startPos], $HoF_totalCount;
  210. copyarray @HoF_LadderZenyB[0], $HoF_LadderZeny[@startPos], $HoF_totalCount;
  211. setarray $HoF_LadderName$[@startPos], getarg(1);
  212. setarray $HoF_LadderBLevel[@startPos], getarg(2);
  213. setarray $HoF_LadderJLevel[@startPos], getarg(3);
  214. setarray $HoF_LadderZeny[@startPos], getarg(4);
  215. set @startPos, @startPos + 1;
  216. set @limitPos, $HoF_totalCount - @startPos + 1;
  217. copyarray $HoF_LadderName$[@startPos], @HoF_LadderNameB$[0], @limitPos;
  218. copyarray $HoF_LadderBLevel[@startPos], @HoF_LadderBLevelB[0], @limitPos;
  219. copyarray $HoF_LadderJLevel[@startPos], @HoF_LadderJLevelB[0], @limitPos;
  220. copyarray $HoF_LadderZeny[@startPos], @HoF_LadderZenyB[0], @limitPos;
  221. announce "[Hall of Fame] " + getarg(1) + " has made his/herself onto the No. " + @startPos + " ranking in Hall of Fame!", bc_all;
  222. return;
  223. }
  224. function script printHallOfFame {
  225. if(getarg(0) == 1) {
  226. mes "[Hall of Fame] - Last Week's Rankings";
  227. for(set @loop, 0; @loop <= $HoF_totalCount; set @loop, @loop + 1){
  228. mes "^ff0000";
  229. mes "Position No. " + (@loop + 1) + ":^0000ff";
  230. mes "+================================+";
  231. mes "^000000Name :" + $HoF_LadderNameO$[@loop];
  232. mes "BLvl :" + $HoF_LadderBLevelO[@loop];
  233. mes "JLvl :" + $HoF_LadderJLevelO[@loop];
  234. mes "Zeny :" + $HoF_LadderZenyO[@loop] + "^0000ff";
  235. mes "+================================+^000000";
  236. }
  237. } else {
  238. mes "[Hall of Fame] - Current Rankings";
  239. for(set @loop, 0; @loop <= $HoF_totalCount; set @loop, @loop + 1){
  240. mes "^ff0000";
  241. mes "Position No. " + (@loop + 1) + ":^0000ff";
  242. mes "+================================+";
  243. mes "^000000Name :" + $HoF_LadderName$[@loop];
  244. mes "BLvl :" + $HoF_LadderBLevel[@loop];
  245. mes "JLvl :" + $HoF_LadderJLevel[@loop];
  246. mes "Zeny :" + $HoF_LadderZeny[@loop] + "^0000ff";
  247. mes "+================================+^000000";
  248. }
  249. }
  250. return;
  251. }
  252. prontera,164,134,2 script Jury 109,{
  253. mes "[Jury]";
  254. mes "Good day. Would you like to view the Hall of Fame?";
  255. next;
  256. menu "Yes",L_OK,"No",L_QUIT;
  257. L_OK:
  258. mes "[Jury]";
  259. mes "Would you like to view the current or the past rankings?";
  260. L_MENU:
  261. next;
  262. menu "Current", L_CUR, "Past", -,"Nevermind",L_QUIT;
  263. callfunc "printHallOfFame",1;
  264. goto L_MENU;
  265. L_CUR:
  266. callfunc "printHallOfFame",0;
  267. goto L_MENU;
  268. L_QUIT:
  269. mes "[Jury]";
  270. mes "Have a nice day then.";
  271. close;
  272. }