Advertisement
Guest User

Untitled

a guest
Dec 19th, 2011
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.73 KB | None | 0 0
  1. //===== eAthena Unofficial Script ===========================================
  2. //= WoE Time Setter v3
  3. //===== By: =================================================================
  4. //= [GM]Xeon
  5. //===== Current Version: ====================================================
  6. //= 3.4.3
  7. //===== Compatible With: ====================================================
  8. //= Trunk, SVN 13202+
  9. //===== Description: ========================================================
  10. //= Manages and adds WoE times for every town
  11. //===== Additional Comments: ================================================
  12. //= For revisions, see the change log!
  13. //= 3.0 Script created ;D [[GM]Xeon]
  14. //= 3.1 Added castle ownership view, manual WoE start/end [[GM]Xeon]
  15. //= 3.2 Added castle ownership change function [[GM]Xeon]
  16. //= 3.3 Added treasure spawn function [[GM]Xeon]
  17. //= 3.4 Implimented plug-in system, converted features to plug-ins,
  18. //= added whisperglobal system [[GM]Xeon]
  19. //===========================================================================
  20.  
  21. prontera,136,178,1 script WoE Information 806,{ //If you wish to change the name, search for all 'WoE Information' and replace them with the desired name.
  22. //To do:
  23. //GM:
  24. //Player: Warp to treasury when WoE isn't active?
  25.  
  26. if (getgmlevel()>=$woe_mingmlv) goto L_Main;
  27. L_View:
  28. mes "[WoE Information]";
  29. mes "Welcome to the WoE Information NPC, the current WoE times are as follows:";
  30. callsub S_Listing2;
  31. set @temp$, "";
  32. for (set @i, 0; @i < getarraysize($@woes3_pl_player$); set @i, @i+1) {
  33. set @temp$, @temp$+":"+$@woes3_pl_playermenu$[@i];
  34. }
  35. menu @temp$,-,"Exit",L_Exit;
  36. next;
  37. if (getmapxy(@ignore$,@ignore,@ignore,1,"WoES3Pl_R"+$@woes3_pl_player$[@menu-2]) != -1) { callfunc("WoES3Pl_"+$@woes3_pl_player$[@menu-2]); } else { mes "Critical error. Please report this to a GM!"; }
  38. next; goto L_View;
  39. L_Exit:
  40. close;
  41. S_Listing:
  42. deletearray @ar_id[0], 128; deletearray @ar_town[0], 128; deletearray @ar_castle[0], 128; deletearray @ar_sday[0], 128; deletearray @ar_shour[0], 128;
  43. deletearray @ar_smin[0], 128; deletearray @ar_stick[0], 128; deletearray @ar_svar[0], 128; deletearray @ar_eday[0], 128; deletearray @ar_ehour[0], 128;
  44. deletearray @ar_emin[0], 128; deletearray @ar_etick[0], 128; deletearray @ar_evar[0], 128;
  45. set @results, query_sql("select * from `woe_times` order by `st` ASC",@ar_id,@ar_town,@ar_castle,@ar_sday,@ar_shour,@ar_smin,@ar_stick,@ar_svar,@ar_eday,@ar_ehour,@ar_emin,@ar_etick,@ar_evar,@ignore);
  46. for (set @temp,0; @temp<@results; set @temp, @temp+1) {
  47. set @temp$, "";
  48. if (gettimetick(2) >= @ar_stick[@temp] && gettimetick(2) < @ar_etick[@temp]) { set @temp$, @temp$+"^339900+"; } else { set @temp$, @temp$+"^FF0000-"; }
  49. if (@ar_town[@temp]==127) { set @temp$, @temp$+"^000000All"; } else {
  50. set @temp_, @ar_town[@temp];
  51. if (@temp_>=64) { set @temp$, @temp$+"^FFFF00Ar"; set @temp_, @temp_-64; }
  52. if (@temp_>=32) { set @temp$, @temp$+"^FF0000Sc"; set @temp_, @temp_-32; }
  53. if (@temp_>=16) { set @temp$, @temp$+"^9900CCNo"; set @temp_, @temp_-16; }
  54. if (@temp_>=8) { set @temp$, @temp$+"^808080Pr"; set @temp_, @temp_-8; }
  55. if (@temp_>=4) { set @temp$, @temp$+"^339900Pa"; set @temp_, @temp_-4; }
  56. if (@temp_>=2) { set @temp$, @temp$+"^0066FFGe"; set @temp_, @temp_-2; }
  57. if (@temp_==1) set @temp$, @temp$+"^FF9900Al";
  58. set @temp$, @temp$+"^000000";
  59. }
  60. set @temp$, @temp$+" ";
  61. if (@ar_castle[@temp]==31) { set @temp$, @temp$+"All"; } else {
  62. set @temp_, @ar_castle[@temp];
  63. set @tmp, 16;
  64. for (set .@i, 5; .@i>0; set .@i,.@i-1) { if (@temp_>=@tmp) { set @temp$, @temp$+.@i; set @temp_,@temp-@tmp; } set @tmp, @tmp/2; }
  65. }
  66. set @temp$, @temp$+" ";
  67. for (set .@i, 1; .@i<3; set .@i, .@i+1) {
  68. set @temp$, @temp$+callfunc("daytostr",0,getd("@ar_"+((.@i==1)?"s":"e")+"day["+@temp+"]"));
  69. if (.@i==1) { set @temp$, @temp$+((@ar_shour[@temp]<10)?"0":"")+@ar_shour[@temp]+";"+((@ar_smin[@temp]<10)?"0":"")+@ar_smin[@temp]+"-"; } else { set @temp$, @temp$+((@ar_ehour[@temp]<10)?"0":"")+@ar_ehour[@temp]+";"+((@ar_emin[@temp]<10)?"0":"")+@ar_emin[@temp]; }
  70. }
  71. set @results$,@results$+@temp$+":";
  72. }
  73. return;
  74. S_Listing2:
  75. deletearray @ar_id[0], 128; deletearray @ar_town[0], 128; deletearray @ar_castle[0], 128; deletearray @ar_sday[0], 128; deletearray @ar_shour[0], 128;
  76. deletearray @ar_smin[0], 128; deletearray @ar_stick[0], 128; deletearray @ar_svar[0], 128; deletearray @ar_eday[0], 128; deletearray @ar_ehour[0], 128;
  77. deletearray @ar_emin[0], 128; deletearray @ar_etick[0], 128; deletearray @ar_evar[0], 128;
  78. set @results, query_sql("select * from `woe_times` order by `st` ASC",@ar_id,@ar_town,@ar_castle,@ar_sday,@ar_shour,@ar_smin,@ar_stick,@ar_svar,@ar_eday,@ar_ehour,@ar_emin,@ar_etick,@ar_evar,@ignore);
  79. if (!@results) { mes "There are no current WoE times!"; return; }
  80. for (set @temp,0; @temp<@results; set @temp, @temp+1) {
  81. mes "--";
  82. set @temp$, "";
  83. if (gettimetick(2) >= @ar_stick[@temp] && gettimetick(2) < @ar_etick[@temp]) { set @temp$, @temp$+"^339900Active: ^000000Towns-"; } else { set @temp$, @temp$+"^FF0000Unactive: ^000000Towns-"; }
  84. if (@ar_town[@temp]==127) { set @temp$, @temp$+"^000000All "; } else {
  85. set @temp_, @ar_town[@temp];
  86. if (@temp_>=64) { set @temp$, @temp$+"^FFFF00Arunafeltz "; set @temp_, @temp_-64; }
  87. if (@temp_>=32) { set @temp$, @temp$+"^FF0000Schwartzvelt "; set @temp_, @temp_-32; }
  88. if (@temp_>=16) { set @temp$, @temp$+"^9900CCNovice "; set @temp_, @temp_-16; }
  89. if (@temp_>=8) { set @temp$, @temp$+"^808080Prontera "; set @temp_, @temp_-8; }
  90. if (@temp_>=4) { set @temp$, @temp$+"^339900Payon "; set @temp_, @temp_-4; }
  91. if (@temp_>=2) { set @temp$, @temp$+"^0066FFGeffen "; set @temp_, @temp_-2; }
  92. if (@temp_==1) set @temp$, @temp$+"^FF9900Aldebaran ";
  93. set @temp$, @temp$+"^000000";
  94. }
  95. mes @temp$;
  96. set @temp$, "";
  97. if (@ar_castle[@temp]==31) { set @temp$, @temp$+"All Castles "; } else {
  98. set @temp_, @ar_castle[@temp];
  99. set @tmp, 16;
  100. mes "Castles-";
  101. for (set .@i, 5; .@i>0; set .@i,.@i-1) { if (@temp_>=@tmp) { set @temp$, @temp$+.@i; set @temp_,@temp-@tmp; } set @tmp, @tmp/2; }
  102. }
  103. mes @temp$;
  104. set @temp$, "";
  105. for (set .@i, 1; .@i<3; set .@i, .@i+1) {
  106. set @temp$, @temp$+callfunc("daytostr",1,getd("@ar_"+((.@i==1)?"s":"e")+"day["+@temp+"]"));
  107. if (.@i==1) { set @temp$, @temp$+" "+((@ar_shour[@temp]<10)?"0":"")+@ar_shour[@temp]+":"+((@ar_smin[@temp]<10)?"0":"")+@ar_smin[@temp]+"-"; } else { set @temp$, @temp$+" "+((@ar_ehour[@temp]<10)?"0":"")+@ar_ehour[@temp]+":"+((@ar_emin[@temp]<10)?"0":"")+@ar_emin[@temp]; }
  108. }
  109. mes @temp$;
  110. }
  111. return;
  112. L_Main:
  113. mes "[WoE Time Setter]";
  114. mes "Hello there, how can I help you GM?";
  115. next;
  116. menu "Manage WoE Times",L_ModifyListing,"Start/Stop WoE",L_ManualWoE,"Plug-ins",L_Plugins,"Settings",L_Settings,"Test Player View",L_View,"Exit",-;
  117. close;
  118. L_Plugins:
  119. set @temp$, "";
  120. for (set @i, 0; @i < getarraysize($@woes3_pl_gm$); set @i, @i+1) {
  121. set @temp$, @temp$+":"+$@woes3_pl_gmmenu$[@i];
  122. }
  123. menu @temp$,-,"Reinitialize Plugins",L_Reinit,"Back",L_Main;
  124. if (getmapxy(@ignore$,@ignore,@ignore,1,"WoES3Pl_R"+$@woes3_pl_gm$[@menu-2]) != -1) { callfunc("WoES3Pl_"+$@woes3_pl_gm$[@menu-2]); } else { mes "Error loading function. Please make sure the plugin is named properly!"; }
  125. next; goto L_Plugins;
  126. L_Reinit:
  127. deletearray $@woes3_pl_playermenu$[0], 128;
  128. deletearray $@woes3_pl_player$[0], 128;
  129. deletearray $@woes3_pl_gmmenu$[0], 128;
  130. deletearray $@woes3_pl_gm$[0], 128;
  131. donpcevent "::OnLoadPlugins";
  132. dispbottom "Plugins initialized";
  133. sleep2 500;
  134. goto L_Plugins;
  135. L_ModifyListing:
  136. set @results$, "";
  137. callsub S_Listing;
  138. menu @results$,-,"Add new time",L_ModifyAdd,"Back",L_Main;
  139. set @sel_modify, @menu-1;
  140. set @adding, 0;
  141. menu "Modify time",L_ModifyTown_Main,"Delete time",-,"Back",L_ModifyListing;
  142. if (gettimetick(2)>=@ar_stick[@sel_modify]&&gettimetick(2)<@ar_etick[@sel_modify]) {
  143. dispbottom "The selected WoE is currently active, if you delete it it will automatically stop! Proceed?";
  144. menu "Yes",-,"No",L_ModifyAdd;
  145. callfunc("WoE_Status",0,@ar_town[@sel_modify],@ar_castle[@sel_modify]);
  146. }
  147. query_sql("delete from `woe_times` where `id` = '"+@ar_id[@sel_modify]+"'");
  148. dispbottom "WoE time deleted!";
  149. set $woe_chatinfo, 0;
  150. goto L_ModifyListing;
  151. L_ModifyAdd:
  152. set @adding, 1;
  153. L_ModifyTown_Main: //@sel_modify is passed from the selection of what exisitng time to modify...
  154. if (@adding) {
  155. set @sel, 0;
  156. setarray @sel_town[1], 0, 0, 0, 0, 0, 0, 0;
  157. set @set_castle, 0;
  158. set @set_time, 0;
  159. } else {
  160. set @set_castle, 1;
  161. set @set_time, 1;
  162. set @temp__, 7;
  163. set @temp_, @ar_town[@sel_modify];
  164. set @temp, 64;
  165. set @sel, 0;
  166. for (set .@i, 7; .@i>0; set .@i, .@i-1) { if (@temp_>=@temp) { set @sel_town[.@i], 1; set @temp_, @temp_-@temp; set @sel, @sel+1; } else { set @sel_town[.@i], 0; } set @temp, @temp/2; }
  167. set @temp_, @ar_castle[@sel_modify];
  168. set @temp, 16;
  169. set @sel2, 0;
  170. for (set .@i, 5; .@i>0; set .@i, .@i-1) { if (@temp_>=@temp) { set @sel_castle[.@i], 1; set @temp_, @temp_-@temp; set @sel2, @sel2+1; } else { set @sel_castle[.@i], 0; } set @temp, @temp/2; }
  171. set @sday, @ar_sday[@sel_modify];
  172. set @shour, @ar_shour[@sel_modify];
  173. set @smin, @ar_smin[@sel_modify];
  174. set @svar, @ar_svar[@sel_modify];
  175. set @eday, @ar_eday[@sel_modify];
  176. set @ehour, @ar_ehour[@sel_modify];
  177. set @emin, @ar_emin[@sel_modify];
  178. set @evar, @ar_evar[@sel_modify];
  179. }
  180. dispbottom "Select the town(s) you wish this WoE time to apply to. If the name is green it means it's enabled, red means disabled.";
  181. L_ModifyTown_Sub:
  182. menu ((@sel_town[1])?"^339900":"^FF0000")+$woe_towns$[1]+":"+((@sel_town[2])?"^339900":"^FF0000")+$woe_towns$[2]+":"+((@sel_town[3])?"^339900":"^FF0000")+$woe_towns$[3]+":"+((@sel_town[4])?"^339900":"^FF0000")+$woe_towns$[4]+":"+((@sel_town[5])?"^339900":"^FF0000")+$woe_towns$[5]+":"+((@sel_town[6])?"^339900":"^FF0000")+$woe_towns$[6]+":"+((@sel_town[7])?"^339900":"^FF0000")+$woe_towns$[7]+":"+((@sel==7)?"^339900":"^FF0000")+$woe_towns$[8],-,"^000000Proceed",L_ModifyCastle_Main,"Back",L_ModifyListing;
  183. if (@menu==8) if (@sel<7) { setarray @sel_town[1], 1, 1, 1, 1, 1, 1, 1; set @sel, 7; goto L_ModifyTown_Sub; } else { setarray @sel_town[1], 0, 0, 0, 0, 0, 0, 0; set @sel, 0; goto L_ModifyTown_Sub; }
  184. if (!@sel_town[@menu]) { set @sel_town[@menu], 1; set @sel, @sel+1; goto L_ModifyTown_Sub; } else { set @sel_town[@menu], 0; set @sel, @sel-1; goto L_ModifyTown_Sub; }
  185. L_ModifyCastle_Main:
  186. if (!@sel) { dispbottom "You must first select at least one town!"; goto L_ModifyTown_Sub; }
  187. set @town_code, 0;
  188. set @set_town, 0;
  189. if (@sel_town[1]) { set @town_code, @town_code+1; if (@sel==1) set @set_town, 1; }
  190. set @temp, 2;
  191. for (set .@i, 2; .@i<8; set .@i, .@i+1) { if (@sel_town[.@i]) { set @town_code, @town_code+@temp; if (@sel==1) set @set_town, .@i; } set @temp, @temp*2; }
  192. if (!@set_castle) { set @sel2, 5; setarray @sel_castle[1], 1, 1, 1, 1, 1; if (@sel==1 && @sel_town[5]) { set @sel2, 4; set @sel_castle[5], 0; } }
  193. set @set_castle, 1;
  194. L_ModifyCastle_Sub:
  195. if (@sel>1) {
  196. menu ((@sel_castle[1])?"^339900":"^FF0000")+"Castle 1:"+((@sel_castle[2])?"^339900":"^FF0000")+"Castle 2:"+((@sel_castle[3])?"^339900":"^FF0000")+"Castle 3:"+((@sel_castle[4])?"^339900":"^FF0000")+"Castle 4:"+((@sel_castle[5])?"^339900":"^FF0000")+"Castle 5",-,"^000000Proceed",L_ModifyTime_Main,"Back",L_ModifyTown_Sub;
  197. if (!@sel_castle[@menu]) { set @sel_castle[@menu], 1; set @sel2, @sel2+1; } else { set @sel_castle[@menu], 0; set @sel2, @sel2-1; }
  198. goto L_ModifyCastle_Sub;
  199. } else {
  200. menu ((@sel_castle[1])?"^339900":"^FF0000")+getd("$woe_cas"+@set_town+"_1$[1]")+":"+((@sel_castle[2])?"^339900":"^FF0000")+getd("$woe_cas"+@set_town+"_1$[2]")+":"+((@sel_castle[3])?"^339900":"^FF0000")+getd("$woe_cas"+@set_town+"_1$[3]")+":"+((@sel_castle[4])?"^339900":"^FF0000")+getd("$woe_cas"+@set_town+"_1$[4]")+((@set_town!=5)?":"+((@sel_castle[5])?"^339900":"^FF0000")+getd("$woe_cas"+@set_town+"_1$[5]"):""),-,"^000000Proceed",L_ModifyTime_Main,"Back",L_ModifyTown_Sub;
  201. if (!@sel_castle[@menu]) { set @sel_castle[@menu], 1; set @sel2, @sel2+1; } else { set @sel_castle[@menu], 0; set @sel2, @sel2-1; }
  202. goto L_ModifyCastle_Sub;
  203. }
  204. dispbottom "Select the castle(s) within the previously selected town(s) you wish this WoE time to apply to. If the name is green it means it's enabled, red means disabled.";
  205. L_ModifyTime_Main:
  206. if (!@sel2) { dispbottom "You must first select at least one castle!"; goto L_ModifyCastle_Sub; }
  207. set @cas_code, 0;
  208. if (@sel_castle[1]) set @cas_code, @cas_code+1;
  209. set @temp, 2;
  210. for (set .@i, 2; .@i<6; set .@i, .@i+1) { if (@sel_castle[.@i]) set @cas_code, @cas_code+@temp; set @temp, @temp*2; }
  211. if (!@set_time) {
  212. set @sday, 0; set @shour, 0; set @smin, 0; set @svar, 0; set @eday, 0; set @ehour, 0; set @emin, 0; set @evar, 0;
  213. }
  214. dispbottom "Select the starting and ending time for the WoE, note the hour is in military time, i.e. 0=12AM, 10=10AM, 22=10PM. Variance is the total amount in seconds to make the time be randomized, ex: setting start to 60 would make the start time either start up to 30 seconds earlier, or start up to 30 seconds later.";
  215. L_ModifyTime_Sub:
  216. for (set .@i, 1; .@i<3; set .@i, .@i+1) setd("@temp"+.@i+"$", callfunc("daytostr",1,getd(((.@i==1)?"@sday":"@eday"))));
  217. menu "Start Day [^0066FF"+@temp1$+"^000000]:Start Hour [^0066FF"+@shour+"^000000]:Start Minute [^0066FF"+@smin+"^000000]:End Day [^0066FF"+@temp2$+"^000000]:End Hour [^0066FF"+@ehour+"^000000]:End Minute [^0066FF"+@emin+"^000000]:Start Variance [^0066FF"+@svar+"^000000]:End Variance [^0066FF"+@evar+"^000000]",-,"Proceed",L_ModifyFinish,"Back",L_ModifyCastle_Sub;
  218. switch(@menu) {
  219. case 1: menu "Sunday:Monday:Tuesday:Wednesday:Thursday:Friday:Saturday",-,"Cancel",L_ModifyTime_Sub; set @sday, @menu-1; break;
  220. case 2: input @shour; if (@shour>23) set @shour, 0; break;
  221. case 3: input @smin; if (@smin>59) set @smin, 0; break;
  222. case 4: menu "Sunday:Monday:Tuesday:Wednesday:Thursday:Friday:Saturday",-,"Cancel",L_ModifyTime_Sub; set @eday, @menu-1; break;
  223. case 5: input @ehour; if (@ehour>23) set @ehour, 0; break;
  224. case 6: input @emin; if (@emin>59) set @emin, 0; break;
  225. case 7: input @svar; break;
  226. case 8: input @evar; break;
  227. }
  228. goto L_ModifyTime_Sub;
  229. L_ModifyFinish:
  230. if (@sday==@eday) if (@shour==@ehour) if (@smin==@emin) { dispbottom "Your start time cannot be your end time!"; goto L_ModifyTime_Sub; }
  231. set $woe_chatinfo, 0;
  232. set @temp1, callfunc("WoE_TickCounter",@sday,@shour,@smin,@svar);
  233. set @temp2, callfunc("WoE_TickCounter",@eday,@ehour,@emin,@evar);
  234. if (@temp1>@temp2) set @temp2,@temp2+604800;
  235. if (@adding) {
  236. query_sql("insert into `woe_times` (town,castle,sd,sh,sm,st,sv,ed,eh,em,et,ev,active) values ('"+@town_code+"', '"+@cas_code+"', '"+@sday+"', '"+@shour+"', '"+@smin+"', '"+@temp1+"','"+@svar+"','"+@eday+"', '"+@ehour+"', '"+@emin+"', '"+@temp2+"','"+@evar+"','0')");
  237. } else {
  238. query_sql("update `woe_times` set town='"+@town_code+"', castle='"+@cas_code+"', sd='"+@sday+"', sh='"+@shour+"', sm='"+@smin+"',st='"+@temp1+"',sv='"+@svar+"',ed='"+@eday+"',eh='"+@ehour+"',em='"+@emin+"',et='"+@temp2+"',ev='"+@evar+"', active='0' where `id` = '"+@ar_id[@sel_modify]+"'");
  239. }
  240. dispbottom "WoE time "+((@adding)?"added!":"modified!");
  241. goto L_ModifyListing;
  242. L_ManualWoE:
  243. dispbottom "Select the castle(s) to start or stop WoE for.";
  244. menu (($woe_cas1_2[1]||$woe_cas1_2[2]||$woe_cas1_2[3]||$woe_cas1_2[4]||$woe_cas1_2[5])?"^339900":"^FF0000")+$woe_towns$[1]+":"+(($woe_cas2_2[1]||$woe_cas2_2[2]||$woe_cas2_2[3]||$woe_cas2_2[4]||$woe_cas2_2[5])?"^339900":"^FF0000")+$woe_towns$[2]+":"+(($woe_cas3_2[1]||$woe_cas3_2[2]||$woe_cas3_2[3]||$woe_cas3_2[4]||$woe_cas3_2[5])?"^339900":"^FF0000")+$woe_towns$[3]+":"+(($woe_cas4_2[1]||$woe_cas4_2[2]||$woe_cas4_2[3]||$woe_cas4_2[4]||$woe_cas4_2[5])?"^339900":"^FF0000")+$woe_towns$[4]+":"+(($woe_cas5_2[1]||$woe_cas5_2[2]||$woe_cas5_2[3]||$woe_cas5_2[4]||$woe_cas5_2[5])?"^339900":"^FF0000")+$woe_towns$[5]+":"+(($woe_cas6_2[1]||$woe_cas6_2[2]||$woe_cas6_2[3]||$woe_cas6_2[4]||$woe_cas6_2[5])?"^339900":"^FF0000")+$woe_towns$[6]+":"+(($woe_cas7_2[1]||$woe_cas7_2[2]||$woe_cas7_2[3]||$woe_cas7_2[4])?"^339900":"^FF0000")+$woe_towns$[7],-,"^339900Enable all",-,"^FF0000Disable all",-,"^000000Back",L_Main;
  245. if (@menu==8) { set $woe_manual, 0; callfunc("WoE_Status",1,127,31); set $woe_manual, 1; goto L_ManualWoE; }
  246. if (@menu==9) { set $woe_manual, 0; callfunc("WoE_Status",0,127,31); set $woe_manual, 1; goto L_ManualWoE; }
  247. set @temp, 64;
  248. for (set .@i, 7; .@i>0; set .@i,.@i-1) { if (.@i==@menu) { set @town, @temp; set @town_, .@i; } set @temp, @temp/2; }
  249. L_ManualCastles:
  250. menu ((getd("$woe_cas"+@town_+"_2[1]"))?"^339900":"^FF0000")+getd("$woe_cas"+@town_+"_1$[1]")+":"+((getd("$woe_cas"+@town_+"_2[2]"))?"^339900":"^FF0000")+getd("$woe_cas"+@town_+"_1$[2]")+":"+((getd("$woe_cas"+@town_+"_2[3]"))?"^339900":"^FF0000")+getd("$woe_cas"+@town_+"_1$[3]")+":"+((getd("$woe_cas"+@town_+"_2[4]"))?"^339900":"^FF0000")+getd("$woe_cas"+@town_+"_1$[4]")+((@set_town!=5)?":"+((getd("$woe_cas"+@town_+"_2[5]"))?"^339900":"^FF0000")+getd("$woe_cas"+@town_+"_1$[5]"):""),-,"^339900Enable all",-,"^FF0000Disable all",-,"^000000Back",L_ManualWoE;
  251. if (@menu==6) { set $woe_manual, 0; callfunc("WoE_Status",1,@town,31); set $woe_manual, 1; goto L_ManualCastles; }
  252. if (@menu==7) { set $woe_manual, 0; callfunc("WoE_Status",0,@town,31); set $woe_manual, 1; goto L_ManualCastles; }
  253. set @temp, 16;
  254. for (set .@i, 5; .@i>0; set .@i,.@i-1) { if (.@i==@menu) { set @cas, @temp; set @cas_,.@i; } set @temp, @temp/2; }
  255. set $woe_manual, 0; callfunc("WoE_Status",((getd("$woe_cas"+@town_+"_2["+@cas_+"]"))?0:1),@town,@cas); set $woe_manual, 1;
  256. goto L_ManualCastles;
  257. L_Settings:
  258. menu (($woe_mobspawn)?"^339900":"^FF0000")+"Monster Spawns",-,(($woe_timerdisp)?"^339900":"^FF0000")+"Chatroom Timer Display",-,(($woe_tannounce)?"^339900":"^FF0000")+"Announce Treasure Spawns [Plug-in]",-,(($woe_announcebreaker)?"^339900":"^FF0000")+"Announce Emperium Breaker",-,"^000000Back",L_Main;
  259. switch(@menu) {
  260. case 1: if ($woe_mobspawn) { set $woe_mobspawn, 0; } else { set $woe_mobspawn, 1; } break;
  261. case 2: if ($woe_timerdisp) { set $woe_timerdisp, 0; } else { set $woe_timerdisp, 1; set $woe_chatinfo, 0; donpcevent "WoE Information::OnChatInfo"; } break;
  262. case 3: if ($woe_tannounce) { set $woe_tannounce, 0; } else { set $woe_tannounce, 1; } break;
  263. case 4: if ($woe_announcebreaker) { set $woe_announcebreaker, 0; } else { set $woe_announcebreaker, 1; } break;
  264. }
  265. goto L_Settings;
  266. OnInit:
  267. query_sql("CREATE TABLE IF NOT EXISTS `woe_times` ( `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, `town` TINYINT UNSIGNED NOT NULL, `castle` TINYINT UNSIGNED NOT NULL, `sd` TINYINT UNSIGNED NOT NULL, `sh` TINYINT UNSIGNED NOT NULL, `sm` TINYINT UNSIGNED NOT NULL, `st` BIGINT UNSIGNED NOT NULL, `sv` INTEGER UNSIGNED NOT NULL, `ed` TINYINT UNSIGNED NOT NULL, `eh` TINYINT UNSIGNED NOT NULL, `em` TINYINT UNSIGNED NOT NULL, `et` BIGINT UNSIGNED NOT NULL, `ev` INTEGER UNSIGNED NOT NULL, `active` TINYINT UNSIGNED NOT NULL, PRIMARY KEY (`id`) ) ENGINE = MyISAM;");
  268. set $woe_manual, 1; //Variable to know whether WoE was started by atcommand/manually through NPC, or through automatic timer.
  269. set $woe_mingmlv, 80; //The minimum GM level able to use the NPC
  270. setarray $woe_towns$[1], "Aldebaran", "Geffen", "Payon", "Prontera", "Novice Castles", "Schwartzvalt", "Arunafeltz", "All Castles"; //These are the town names, mostly for announcements
  271. setarray $woe_cas1_1$[1], getcastlename("aldeg_cas01"), getcastlename("aldeg_cas02"), getcastlename("aldeg_cas03"), getcastlename("aldeg_cas04"), getcastlename("aldeg_cas05"); //These are the castle names
  272. setarray $woe_cas1_2[1], 0, 0, 0, 0, 0; //Aldebaran's agit status
  273. setarray $woe_cas1_3$[1], "aldeg_cas01", "aldeg_cas02", "aldeg_cas03", "aldeg_cas04", "aldeg_cas05";
  274. setarray $woe_cas2_1$[1], getcastlename("gefg_cas01"), getcastlename("gefg_cas02"), getcastlename("gefg_cas03"), getcastlename("gefg_cas04"), getcastlename("gefg_cas05"); //These are the castle names
  275. setarray $woe_cas2_2[1], 0, 0, 0, 0, 0; //Geffen's agit status
  276. setarray $woe_cas2_3$[1], "gefg_cas01", "gefg_cas02", "gefg_cas03", "gefg_cas04", "gefg_cas05";
  277. setarray $woe_cas3_1$[1], getcastlename("payg_cas01"), getcastlename("payg_cas02"), getcastlename("payg_cas03"), getcastlename("payg_cas04"), getcastlename("payg_cas05"); //These are the castle names
  278. setarray $woe_cas3_2[1], 0, 0, 0, 0, 0; //Payon's agit status
  279. setarray $woe_cas3_3$[1], "payg_cas01", "payg_cas02", "payg_cas03", "payg_cas04", "payg_cas05";
  280. setarray $woe_cas4_1$[1], getcastlename("prtg_cas01"), getcastlename("prtg_cas02"), getcastlename("prtg_cas03"), getcastlename("prtg_cas04"), getcastlename("prtg_cas05"); //These are the castle names
  281. setarray $woe_cas4_2[1], 0, 0, 0, 0, 0; //Prontera's agit status
  282. setarray $woe_cas4_3$[1], "prtg_cas01", "prtg_cas02", "prtg_cas03", "prtg_cas04", "prtg_cas05";
  283. setarray $woe_cas5_1$[1], "Aldebaran Castle", "Geffen Castle", "Payon Castle", "Prontera Castle", "-"; //These are the castle names
  284. setarray $woe_cas5_2[1], 0, 0, 0, 0, 0; //Novice's agit status
  285. setarray $woe_cas6_1$[1], getcastlename("schg_cas01"), getcastlename("schg_cas02"), getcastlename("schg_cas03"), getcastlename("schg_cas04"), getcastlename("schg_cas05"); //These are the castle names
  286. setarray $woe_cas6_2[1], 0, 0, 0, 0, 0; //Schwartzvalt's agit status
  287. setarray $woe_cas6_3$[1], "schg_cas01", "schg_cas02", "schg_cas03", "schg_cas04", "schg_cas05";
  288. setarray $woe_cas7_1$[1], getcastlename("arug_cas01"), getcastlename("arug_cas02"), getcastlename("arug_cas03"), getcastlename("arug_cas04"), getcastlename("arug_cas05"); //These are the castle names
  289. setarray $woe_cas7_2[1], 0, 0, 0, 0, 0; //Arunafeltz's agit status
  290. setarray $woe_cas7_3$[1], "arug_cas01", "arug_cas02", "arug_cas03", "arug_cas04", "arug_cas05";
  291. agitend; agitend2;
  292. query_sql "update `woe_times` set `active` = '0' where `active` = '1'";
  293. callfunc("WoE_Update");
  294. donpcevent "WoE Information::OnChatInfo";
  295. deletearray $@woes3_pl_playermenu$[0], 128;
  296. deletearray $@woes3_pl_player$[0], 128;
  297. deletearray $@woes3_pl_gmmenu$[0], 128;
  298. deletearray $@woes3_pl_gm$[0], 128;
  299. donpcevent "::OnLoadPlugins";
  300. while(1) callfunc("WoE_Init");
  301. end;
  302. OnChatInfo:
  303. while (1) {
  304. delwaitingroom; //Memory vortex restraining bolt, please don't remove it for the sake of humanity.
  305. if (!$woe_timerdisp) end;
  306. if (.@woe_e-gettimetick(2) <= 0 || !$woe_chatinfo) { set .@timeset, query_sql("select st,et from `woe_times` order by `st` ASC",.@woe_s,.@woe_e); set $woe_chatinfo, 1; }
  307. if (.@timeset) {
  308. if (gettimetick(2)>.@woe_s) {
  309. set .@sec, .@woe_e-gettimetick(2);
  310. set .@day, .@sec / 86400;
  311. set .@hr, .@sec % 86400 / 3600;
  312. set .@min, .@sec % 3600 / 60;
  313. set .@sec, .@sec % 60;
  314. waitingroom "Ends: "+.@day+"d "+((.@hr<10)?"0":"")+.@hr+":"+((.@min<10)?"0":"")+.@min+((!.@hr&&!.@min&&.@sec<60)?":"+((.@sec<10)?"0":"")+.@sec:""),0;
  315. } else {
  316. set .@sec, .@woe_s-gettimetick(2);
  317. set .@day, .@sec / 86400;
  318. set .@hr, .@sec % 86400 / 3600;
  319. set .@min, .@sec % 3600 / 60;
  320. set .@sec, .@sec % 60;
  321. waitingroom "Next: "+.@day+"d "+((.@hr<10)?"0":"")+.@hr+":"+((.@min<10)?"0":"")+.@min+((!.@hr&&!.@min&&.@sec<60)?":"+((.@sec<10)?"0":"")+.@sec:""),0;
  322. }
  323. if (.@hr||.@min>1) { sleep 60000-(gettime(1)*1000); } else { sleep 1000; }
  324. } else { waitingroom "Next: N/A, none set!",0; sleep 60000-(gettime(1)*1000); }
  325. }
  326. end;
  327. OnAgitStart:
  328. if ($woe_manual) { callfunc("WoE_Status",1,31,31); }
  329. end;
  330. OnAgitStart2:
  331. if ($woe_manual) { callfunc("WoE_Status",1,96,31); }
  332. end;
  333. OnAgitEnd:
  334. if ($woe_manual) { callfunc("WoE_Status",0,31,31); }
  335. end;
  336. OnAgitEnd2:
  337. if ($woe_manual) { callfunc("WoE_Status",0,96,31); }
  338. end;
  339. OnWhisperGlobal:
  340. if (getgmlevel() < $woe_mingmlv) end;
  341. if (@whispervar0$ == "start") {
  342. if (@whispervar1$ == "" && @whispervar2$ == "") dispbottom "Invalid syntax, type 'start#help' for assistance.";
  343. else if (@whispervar1$ == "help") dispbottom "start#town_code#castle_code - Starts WoE for the specified town(s) and castle(s).";
  344. else callfunc("WoE_Status",1,@whispervar1$,@whispervar2$);
  345. } else if (@whispervar0$ == "stop") {
  346. if (@whispervar1$ == "" && @whispervar2$ == "") dispbottom "Invalid syntax, type 'stop#help' for assistance.";
  347. else if (@whispervar1$ == "help") dispbottom "stop#town_code#castle_code - Stops WoE for the specified town(s) and castle(s).";
  348. else callfunc("WoE_Status",0,@whispervar1$,@whispervar2$);
  349. } else if (@whispervar0$ == "talk") goto L_Main;
  350. else if (@whispervar0$ == "help") {
  351. dispbottom "Welcome to the War of Emperium Setter 3 whisper help system.";
  352. dispbottom "The following are commands that you can whisper to the NPC...";
  353. dispbottom " start#town_code#castle_code - Starts WoE for the specified town(s) and castle(s).";
  354. dispbottom " stop#town_code#castle_code - Stops WoE for the specified town(s) and castle(s).";
  355. dispbottom " talk - Opens dialog with the WoE Setter 3 NPC.";
  356. dispbottom " help - Displays this help information.";
  357. dispbottom "Town code: A bitmask (Add them together to use multiple towns) code to specify what towns the command affects.";
  358. dispbottom "Aldebaran=1, Geffen=2, Payon=4, Prontera=8, Novice=16, Schwartvalt=32, Arunafeltz=64, All=127.";
  359. dispbottom "Castle code: A bitmask code to specify what castles the command affects.";
  360. dispbottom "Castle 1=1, Castle 2=2, Castle 3=4, Castle 4=8, Castle 5=16, All=31.";
  361. } else dispbottom "Invalid syntax, type 'help' for assistance.";
  362. end;
  363. }
  364.  
  365. //Returns the day name from a day #
  366. //arg0=Mode, 0=short, 1=full
  367. //arg1=Day #
  368. function script daytostr {
  369. switch(getarg(1)) {
  370. case 0: return ((getarg(0))?"Sunday":"Sun");
  371. case 1: return ((getarg(0))?"Monday":"Mon");
  372. case 2: return ((getarg(0))?"Tuesday":"Tue");
  373. case 3: return ((getarg(0))?"Wednesday":"Wed");
  374. case 4: return ((getarg(0))?"Thursday":"Thu");
  375. case 5: return ((getarg(0))?"Friday":"Fri");
  376. case 6: return ((getarg(0))?"Saturday":"Sat");
  377. }
  378. return;
  379. }
  380.  
  381. //Function to acquire the time difference between now and the arguments in seconds
  382. //arg0=Start/end day
  383. //arg1=Start/end hour
  384. //arg2=Start/end minute
  385. //arg3=Random time variance
  386. function script WoE_TickCounter {
  387. if ((getarg(0)>gettime(4))||(getarg(0)==gettime(4)&&getarg(1)>gettime(3))||(getarg(0)==gettime(4)&&getarg(1)==gettime(3)&&getarg(2)>gettime(2))) { set .@day, getarg(0)-gettime(4); } else { set .@day, 7-(gettime(4)-getarg(0)); }
  388. set .@hour, getarg(1)-gettime(3);
  389. set .@minute, getarg(2)-gettime(2);
  390. return gettimetick(2)+(.@day*86400)+(.@hour*3600)+(.@minute*60)+rand(-getarg(3)/2,getarg(3)/2)-gettime(1);
  391. }
  392.  
  393. //Function to update the tick columns of past WoE times so that they may occur again!
  394. function script WoE_Update {
  395. deletearray .@id[0], 128; deletearray .@sd[0], 128; deletearray .@sh[0], 128; deletearray .@sm[0], 128; deletearray .@st[0], 128; deletearray .@sv[0], 128;
  396. deletearray .@ed[0], 128; deletearray .@eh[0], 128; deletearray .@em[0], 128; deletearray .@et[0], 128; deletearray .@ev[0], 128;
  397. set .@results, query_sql("select id,sd,sh,sm,st,sv,ed,eh,em,et,ev from `woe_times` where `et` <= '"+gettimetick(2)+"'",.@id,.@sd,.@sh,.@sm,.@st,.@sv,.@ed,.@eh,.@em,.@et,.@ev);
  398. set .@i, 0;
  399. for (set .@i,0; .@i<.@results; set .@i,.@i+1) { query_sql("update `woe_times` set `st` = '"+callfunc("WoE_TickCounter",.@sd[.@i],.@sh[.@i],.@sm[.@i],.@sv[.@i])+"', `et` = '"+callfunc("WoE_TickCounter",.@ed[.@i],.@eh[.@i],.@em[.@i],.@ev[.@i])+"', `active` = '0' where `id` = '"+.@id[.@i]+"'"); }
  400. return;
  401. }
  402.  
  403. //Function to either start WoE or end it, depending on if the current time tick fits a valid time frame found in the SQL table
  404. function script WoE_Init {
  405. deletearray .@stown[0], 128; deletearray .@scastle[0], 128; deletearray .@etown[0], 128; deletearray .@ecastle[0], 128;
  406. set .@ends, query_sql("select town,castle from `woe_times` where `et` <= '"+gettimetick(2)+"' and `active` = '1'",.@etown,.@ecastle);
  407. if (.@ends) { set $woe_chatinfo, 0; query_sql("update `woe_times` set `active` = '0' where `et` <= '"+gettimetick(2)+"'"); callfunc("WoE_Update"); }
  408. set .@starts, query_sql("select town,castle from `woe_times` where `st` <= '"+gettimetick(2)+"' and `et` > '"+gettimetick(2)+"' and `active` = '0'",.@stown,.@scastle);
  409. if (.@starts) query_sql("update `woe_times` set `active` = '1' where `st` <= '"+gettimetick(2)+"' and `et` > '"+gettimetick(2)+"'");
  410. set $woe_manual, 0;
  411. for (set .@i1, 0; .@i1<.@ends; set .@i1,.@i1+1 ) { //WOE END STUFF
  412. callfunc("WoE_Status",0,.@etown[.@i1],.@ecastle[.@i1]);
  413. }
  414. for (set .@i1, 0; .@i1<.@starts; set .@i1,.@i1+1 ) { //WOE START STUFF
  415. callfunc("WoE_Status",1,.@stown[.@i1],.@scastle[.@i1]);
  416. }
  417. set $woe_manual, 1;
  418. sleep 60000-(1000*gettime(1));
  419. return;
  420. }
  421.  
  422. //The actual function that starts/stops WoE, called by other NPCs/Functions
  423. //arg0=Stop(0) or start(1)?
  424. //arg1=Town(s) bitmask, 127=All
  425. //arg2=Castle(s) bitmask, 31=All
  426. function script WoE_Status {
  427. set .@tcode, getarg(1); set .@tcurrent, 64;
  428. for (set .@i_, 7; .@i_>0; set .@i_,.@i_-1) {
  429. if (.@tcode>=.@tcurrent) {
  430. if (.@i_>5) { if (!agitcheck2()&&getarg(0)) { agitstart2; } } else { if (!agitcheck()&&getarg(0)) { agitstart; } }
  431. set .@temp$, ""; set .@ccode, getarg(2); set .@ccurrent, 16;
  432. for (set .@i, 5; .@i>0; set .@i,.@i-1) { if (.@ccode>=.@ccurrent) { if (getarg(0)) { if (.@i_!=6&&.@i_!=7) { if(.@tcurrent!=16) donpcevent "Agit#"+getd("$woe_cas"+.@i_+"_3$["+.@i+"]")+"::OnAgitStart_"; } else if (.@i_==7) { donpcevent "Manager#aru0"+.@i+"_02::OnAgitStart2_"; } else { donpcevent "Manager#sch0"+.@i+"_02::OnAgitStart2_"; } } else { if (.@i_!=6&&.@i_!=7) { if (.@tcurrent!=16) donpcevent "Agit#"+getd("$woe_cas"+.@i_+"_3$["+.@i+"]")+"::OnAgitEnd_"; } else if (.@i_==7) {donpcevent "Manager#aru0"+.@i+"_02::OnAgitEnd2_"; } else { donpcevent "Manager#sch0"+.@i+"_02::OnAgitEnd2_"; } } setd "$woe_cas"+.@i_+"_2["+.@i+"]", getarg(0); set .@temp$, .@temp$+getd("$woe_cas"+.@i_+"_1$["+.@i+"]")+((.@ccode>.@ccurrent)?", ":" "); set .@ccode, .@ccode-.@ccurrent; } set .@ccurrent, .@ccurrent/2; }
  433. if (getarg(1)!=127&&.@tcurrent!=16) announce "WoE has "+((getarg(0))?"begun":"ended")+" for "+$woe_towns$[.@i_]+" ( Castle(s): "+((getarg(2)==31)?"All":.@temp$)+" )!",bc_all|bc_yellow;
  434. set .@tcode, .@tcode-.@tcurrent;
  435. }
  436. set .@tcurrent,.@tcurrent/2;
  437. }
  438. if (getarg(1)==127) {
  439. set .@temp$, ""; set .@ccode, getarg(2); set .@ccurrent, 16;
  440. for (set .@i, 5; .@i>0; set .@i,.@i-1) { if (.@ccode>=.@ccurrent) set .@temp$, .@temp$+.@i+((.@ccode>.@ccurrent)?", ":" "); set .@ccode, .@ccode-.@ccurrent; set .@ccurrent, .@ccurrent/2; }
  441. announce "WoE has "+((getarg(0))?"begun":"ended")+" for All Towns ( Castle(s): "+((getarg(2)==31)?"All":.@temp$)+" )!",bc_all|bc_yellow;
  442. }
  443. if (!getarg(0)) {
  444. set .@agit1, 0; set .@agit2, 0;
  445. for (set .@i_, 7; .@i_>0; set .@i_,.@i_-1) { for (set .@i, 5; .@i>0; set .@i, .@i-1) { if (getd("$woe_cas"+.@i_+"_2["+.@i+"]")==1) setd(".@agit"+((.@i_>5)?"2":"1"),1); } }
  446. if (!.@agit1&&agitcheck()) agitend;
  447. if (!.@agit2&&agitcheck2()) agitend2;
  448. }
  449. return;
  450. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement