woe_controller.txt 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. //===== rAthena Script =======================================
  2. //= Euphy's WOE Controller
  3. //===== Changelogs: ==========================================
  4. //= 1.3a Initial SVN release [Euphy]
  5. //= 1.3b Fixed WoE SE end labels [Euphy]
  6. //= 1.4 Added auto kick config [Euphy]
  7. //= 1.5 Added additional reward configs [Euphy]
  8. //= 1.5a Fixed hardcoded date constants [Lemongrass]
  9. //= 1.6 Replaced SQL insert for mail with script command [Capuche]
  10. //= 1.6a Fixed invalid name Schwaltzvalt [Daegaladh]
  11. //= 1.6b Fixed hardcoded castle numbers [Lemongrass]
  12. //= 1.7 Removed direct SQL access [Lemongrass]
  13. //= 1.8 Fixed invalid checkweight usage [Lemongrass]
  14. //= 1.9 Fixed reward handout for multiple characters on the same account [Lemongrass]
  15. //===== Description: =========================================
  16. //= A controller for War of Emperium designed for
  17. //= simplicity and ease of use.
  18. //= Many concepts taken from ToastOfDoom's script,
  19. //= and "rewards" function originally by Goddameit.
  20. //=
  21. //= Be sure to disable the default agit controllers!
  22. //= npc\guild\agit_controller.txt
  23. //= npc\guild2\agit_start_se.txt
  24. //= npc\re\guild3\agit_start_te.txt
  25. //============================================================
  26. // Information NPC
  27. //============================================================
  28. prontera,149,193,4 script WOE Information 835,{
  29. doevent "WOE_CONTROL::OnMenu";
  30. end;
  31. OnAgitStart:
  32. while(agitcheck() || agitcheck2() || agitcheck3()) {
  33. sleep 425;
  34. specialeffect EF_BEGINSPELL6;
  35. }
  36. end;
  37. }
  38. // Script Core
  39. //============================================================
  40. - script WOE_CONTROL -1,{
  41. function Disp_Owner; function Add_Zero;
  42. function Region;
  43. function Castle;
  44. OnInit:
  45. // -----------------------------------------------------------
  46. // Configuration settings.
  47. // -----------------------------------------------------------
  48. set .CastleWarp,0; // 1: Always enable all castle warps. | 0: Warp only to active castles.
  49. set .AutoKick,1; // Automatically kick players from inactive castles during WOE? (1:yes / 0:no)
  50. set .NoOwner,0; // Automatically kick players from unconquered castles outside of WOE? (1:yes / 0:no)
  51. set .ExitWarp,0; // Warp all players from castles when WOE ends? (1:yes / 0:no)
  52. set .GMAccess,99; // GM level required to access Session Manager.
  53. // -----------------------------------------------------------
  54. // Reward options.
  55. // -----------------------------------------------------------
  56. // [1] Enable rewards.
  57. // [2] Mail all rewards.
  58. // - If not set, players receive items in their inventory.
  59. // - Only ONE item can be sent via mail for PACKETVER < 20150513 while later clients are limited to MAIL_MAX_ITEM (5).
  60. // - Note that offline players do NOT receive rewards.
  61. // [4] Only reward Guild Masters.
  62. // - If not set, all guild members are rewarded.
  63. // - If mailing is enabled (option 2), offline Guild Masters WILL receive rewards.
  64. // [8] Duplicate IP check.
  65. // - Members in a guild with the same IP address are not rewarded.
  66. // - If Guild Masters is enabled (option 4), this feature is not used.
  67. // -----------------------------------------------------------
  68. // Combine values as needed (e.g. 1|8 = 1+8 = 9).
  69. set .Options, 1|8;
  70. // Rewards per castle.
  71. // setarray .reward_id[0], <itemID>{,<itemID>,...}
  72. // setarray .reward_amount[0], <amount>{,<amount>,...}
  73. setarray .reward_id[0],14001;
  74. setarray .reward_amount[0],1;
  75. // Zeny reward:
  76. .reward_zeny = 0;
  77. // -----------------------------------------------------------
  78. // Castles datas.
  79. // -----------------------------------------------------------
  80. // Region function defines the region of the castle defined by Castle function.
  81. // Region("<region name>");
  82. // Castle("<castle map name>", "<event name when woe end>", "<event killmonster name>", "<map name special warp>",<x>,<y>)
  83. Region("Prontera");
  84. Castle("prtg_cas01", "Agit#prtg_cas01::OnAgitEnd", "Agit#prtg_cas01::OnAgitBreak", "prt_gld",134,65);
  85. Castle("prtg_cas02", "Agit#prtg_cas02::OnAgitEnd", "Agit#prtg_cas02::OnAgitBreak", "prt_gld",240,128);
  86. Castle("prtg_cas03", "Agit#prtg_cas03::OnAgitEnd", "Agit#prtg_cas03::OnAgitBreak", "prt_gld",153,137);
  87. Castle("prtg_cas04", "Agit#prtg_cas04::OnAgitEnd", "Agit#prtg_cas04::OnAgitBreak", "prt_gld",111,240);
  88. Castle("prtg_cas05", "Agit#prtg_cas05::OnAgitEnd", "Agit#prtg_cas05::OnAgitBreak", "prt_gld",208,240);
  89. Region("Payon");
  90. Castle("payg_cas01", "Agit#payg_cas01::OnAgitEnd", "Agit#payg_cas01::OnAgitBreak", "pay_gld",121,233);
  91. Castle("payg_cas02", "Agit#payg_cas02::OnAgitEnd", "Agit#payg_cas02::OnAgitBreak", "pay_gld",295,116);
  92. Castle("payg_cas03", "Agit#payg_cas03::OnAgitEnd", "Agit#payg_cas03::OnAgitBreak", "pay_gld",317,293);
  93. Castle("payg_cas04", "Agit#payg_cas04::OnAgitEnd", "Agit#payg_cas04::OnAgitBreak", "pay_gld",140,160);
  94. Castle("payg_cas05", "Agit#payg_cas05::OnAgitEnd", "Agit#payg_cas05::OnAgitBreak", "pay_gld",204,266);
  95. Region("Geffen");
  96. Castle("gefg_cas01", "Agit#gefg_cas01::OnAgitEnd", "Agit#gefg_cas01::OnAgitBreak", "gef_fild13",214,75);
  97. Castle("gefg_cas02", "Agit#gefg_cas02::OnAgitEnd", "Agit#gefg_cas02::OnAgitBreak", "gef_fild13",308,240);
  98. Castle("gefg_cas03", "Agit#gefg_cas03::OnAgitEnd", "Agit#gefg_cas03::OnAgitBreak", "gef_fild13",143,240);
  99. Castle("gefg_cas04", "Agit#gefg_cas04::OnAgitEnd", "Agit#gefg_cas04::OnAgitBreak", "gef_fild13",193,278);
  100. Castle("gefg_cas05", "Agit#gefg_cas05::OnAgitEnd", "Agit#gefg_cas05::OnAgitBreak", "gef_fild13",305,87);
  101. Region("Aldebaran");
  102. Castle("aldeg_cas01", "Agit#aldeg_cas01::OnAgitEnd", "Agit#aldeg_cas01::OnAgitBreak", "alde_gld",48,83);
  103. Castle("aldeg_cas02", "Agit#aldeg_cas02::OnAgitEnd", "Agit#aldeg_cas02::OnAgitBreak", "alde_gld",95,249);
  104. Castle("aldeg_cas03", "Agit#aldeg_cas03::OnAgitEnd", "Agit#aldeg_cas03::OnAgitBreak", "alde_gld",142,85);
  105. Castle("aldeg_cas04", "Agit#aldeg_cas04::OnAgitEnd", "Agit#aldeg_cas04::OnAgitBreak", "alde_gld",239,242);
  106. Castle("aldeg_cas05", "Agit#aldeg_cas05::OnAgitEnd", "Agit#aldeg_cas05::OnAgitBreak", "alde_gld",264,90);
  107. Region("Arunafeltz");
  108. Castle("arug_cas01", "Manager#arug_cas01::OnAgitEnd2", "Steward#ar01::OnStartArena", "aru_gld",158,272);
  109. Castle("arug_cas02", "Manager#arug_cas02::OnAgitEnd2", "Steward#ar02::OnStartArena", "aru_gld",83,47);
  110. Castle("arug_cas03", "Manager#arug_cas03::OnAgitEnd2", "Steward#ar03::OnStartArena", "aru_gld",68,155);
  111. Castle("arug_cas04", "Manager#arug_cas04::OnAgitEnd2", "Steward#ar04::OnStartArena", "aru_gld",299,345);
  112. Castle("arug_cas05", "Manager#arug_cas05::OnAgitEnd2", "Steward#ar05::OnStartArena", "aru_gld",292,107);
  113. Region("Schwarzwald");
  114. Castle("schg_cas01", "Manager#schg_cas01::OnAgitEnd2", "Steward#sc01::OnStartArena", "sch_gld",293,100);
  115. Castle("schg_cas02", "Manager#schg_cas02::OnAgitEnd2", "Steward#sc02::OnStartArena", "sch_gld",288,252);
  116. Castle("schg_cas03", "Manager#schg_cas03::OnAgitEnd2", "Steward#sc03::OnStartArena", "sch_gld",97,196);
  117. Castle("schg_cas04", "Manager#schg_cas04::OnAgitEnd2", "Steward#sc04::OnStartArena", "sch_gld",137,90);
  118. Castle("schg_cas05", "Manager#schg_cas05::OnAgitEnd2", "Steward#sc05::OnStartArena", "sch_gld",71,315);
  119. Region("Prontera (TE)");
  120. Castle("te_prtcas01", "Manager_TE#Gaebolg::OnAgitEnd3", "Manager_TE#Gaebolg::OnAgitBreak", "te_prt_gld",134,65);
  121. Castle("te_prtcas02", "Manager_TE#Richard::OnAgitEnd3", "Manager_TE#Richard::OnAgitBreak", "te_prt_gld",240,128);
  122. Castle("te_prtcas03", "Manager_TE#Wigner::OnAgitEnd3", "Manager_TE#Wigner::OnAgitBreak", "te_prt_gld",153,137);
  123. Castle("te_prtcas04", "Manager_TE#Heine::OnAgitEnd3", "Manager_TE#Heine::OnAgitBreak", "te_prt_gld",111,240);
  124. Castle("te_prtcas05", "Manager_TE#Nerious::OnAgitEnd3", "Manager_TE#Nerious::OnAgitBreak", "te_prt_gld",208,240);
  125. Region("Aldebaran (TE)");
  126. Castle("te_aldecas1", "Manager_TE#Glaris::OnAgitEnd3", "Manager_TE#Glaris::OnAgitBreak", "te_alde_gld",48,83);
  127. Castle("te_aldecas2", "Manager_TE#Defolty::OnAgitEnd3", "Manager_TE#Defolty::OnAgitBreak", "te_alde_gld",95,249);
  128. Castle("te_aldecas3", "Manager_TE#Sorin::OnAgitEnd3", "Manager_TE#Sorin::OnAgitBreak", "te_alde_gld",142,85);
  129. Castle("te_aldecas4", "Manager_TE#Bennit::OnAgitEnd3", "Manager_TE#Bennit::OnAgitBreak", "te_alde_gld",239,242);
  130. Castle("te_aldecas5", "Manager_TE#W::OnAgitEnd3", "Manager_TE#W::OnAgitBreak", "te_alde_gld",264,90);
  131. setarray .Days$[0],"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday";
  132. // -----------------------------------------------------------
  133. .reward_id_size = getarraysize(.reward_id);
  134. set .Size, getarraysize($WOE_CONTROL);
  135. if (.AutoKick || .NoOwner) {
  136. for(set .@i,0; .@i<.total_castle; set .@i,.@i+1) {
  137. setmapflag .Castles$[.@i], mf_loadevent;
  138. setd "."+.Castles$[.@i], .@i;
  139. }
  140. }
  141. else {
  142. for(set .@i,0; .@i<.total_castle; set .@i,.@i+1)
  143. setd "."+.Castles$[.@i], 0;
  144. }
  145. if (!agitcheck() && !agitcheck2() && !agitcheck3()) sleep 4000;
  146. set .Init,1;
  147. .current_region = 0;
  148. OnMinute00:
  149. freeloop(1);
  150. if (agitcheck() || agitcheck2() || agitcheck3()) {
  151. for(set .@i,0; .@i<.Size; set .@i,.@i+4) {
  152. if (gettime(DT_DAYOFWEEK) == $WOE_CONTROL[.@i] && gettime(DT_HOUR) == $WOE_CONTROL[.@i+2]) {
  153. OnWOEEnd:
  154. announce "The War Of Emperium is over!",bc_all|bc_woe;
  155. AgitEnd; AgitEnd2; AgitEnd3;
  156. sleep 1000;
  157. for(set .@j,0; .@j<.total_castle; set .@j,.@j+1) {
  158. if (.Active[0]&(1<<.@j)) Disp_Owner(.Castles$[.@j],1);
  159. if (.ExitWarp) maprespawnguildid .Castles$[.@j],0,3;
  160. }
  161. if ((.Options&1) && .Active[0] && .ForceEnd != 2) callsub OnReward, .Active[0];
  162. deletearray .Active[0],2;
  163. if (.ForceEnd) { set .ForceEnd,0; end; }
  164. break;
  165. }
  166. }
  167. }
  168. .@agit_check = (!agitcheck() && !agitcheck2() && !agitcheck3());
  169. if (.@agit_check || .Init) {
  170. if (.@agit_check) set .Init,0;
  171. for(set .@i,0; .@i<.Size; set .@i,.@i+4) {
  172. if (gettime(DT_DAYOFWEEK) == $WOE_CONTROL[.@i] && gettime(DT_HOUR) >= $WOE_CONTROL[.@i+1] && gettime(DT_HOUR) < $WOE_CONTROL[.@i+2]) {
  173. deletearray .Active[0],2;
  174. set .Active[0], $WOE_CONTROL[.@i+3];
  175. if (.Init) { AgitEnd; AgitEnd2; AgitEnd3; }
  176. else announce "The War Of Emperium has begun!",bc_all|bc_woe;
  177. sleep 1000;
  178. AgitStart; AgitStart2; AgitStart3;
  179. for(set .@j,0; .@j<.total_castle; set .@j,.@j+1) {
  180. if (.Active[0]&(1<<.@j)) {
  181. if (!.Init) Disp_Owner(.Castles$[.@j],0);
  182. set .Active[1], .Active[1] | (1<<.castle_region[.@j]);
  183. } else {
  184. donpcevent .event_name_agitend$[.@j];
  185. killmonster .Castles$[.@j], .event_name_killmob$[.@j];
  186. }
  187. }
  188. break;
  189. }
  190. }
  191. }
  192. set .Init,0;
  193. end;
  194. function Disp_Owner {
  195. set .@o, getcastledata(getarg(0),1);
  196. if (.@o) announce "The ["+getcastlename(getarg(0))+"] castle "+((getarg(1))?"has been conquered":"is currently held")+" by the ["+getguildname(.@o)+"] guild.",bc_all|bc_woe;
  197. else announce "The ["+getcastlename(getarg(0))+"] castle is currently unoccupied.",bc_all|bc_woe;
  198. return;
  199. }
  200. function Add_Zero {
  201. return ((getarg(0)<10)?"0":"")+getarg(0)+(getarg(1,0)?".":":")+"00";
  202. }
  203. function Castle {
  204. .@map$ = getarg(0);
  205. if (getd( "." + .@map$ ) > 0) {
  206. debugmes sprintf("WOE_CONTROL: map %s already defined.", .@map$);
  207. return;
  208. }
  209. if (.total_castle > 61) {
  210. debugmes sprintf("WOE_CONTROL: Maximum of 62 castles defined, %s skipped.", .@map$);
  211. return;
  212. }
  213. .Castles$[.total_castle] = .@map$;
  214. .event_name_agitend$[.total_castle] = getarg(1);
  215. .event_name_killmob$[.total_castle] = getarg(2);
  216. .Map$[.total_castle] = getarg(3);
  217. .MapX[.total_castle] = getarg(4);
  218. .MapY[.total_castle] = getarg(5);
  219. .castle_region[.total_castle] = .current_region;
  220. setd ".castle_index_in_region_" + .current_region + "[" + .size_region[.current_region] + "]", .total_castle;
  221. .total_castle++;
  222. .size_region[.current_region]++;
  223. setd "." + .Castles$[.total_castle-1], .total_castle;
  224. return;
  225. }
  226. function Region {
  227. .@zone$ = getarg(0);
  228. for ( .@i = 0; .@i < .total_region; ++.@i ) {
  229. if (.Regions$[.@i] == .@zone$) {
  230. .current_region = .@index;
  231. return;
  232. }
  233. }
  234. .Regions$[.total_region] = .@zone$;
  235. .current_region = .total_region;
  236. .total_region++;
  237. return;
  238. }
  239. OnReward:
  240. if (!.reward_id_size && !.reward_zeny)
  241. return;
  242. if (.Options&2) set .@str$,gettimestr("%B %d, %Y",21);
  243. freeloop(1);
  244. for(set .@i,0; .@i<.total_castle; set .@i,.@i+1) {
  245. if (getarg(0)&(1<<.@i)) {
  246. set .@gid, getcastledata(.Castles$[.@i],1);
  247. if (!.@gid)
  248. continue;
  249. getguildmember( .@gid, 1, .@cid );
  250. .@size_guild = getguildmember( .@gid, 2, .@aid );
  251. if( .Options&4 ){
  252. .@master_cid = getguildmasterid( .@gid );
  253. .@index = inarray(.@cid, .@master_cid);
  254. .@master_aid = .@aid[.@index];
  255. cleararray( .@cid, 0, .@size_guild );
  256. cleararray( .@aid, 0, .@size_guild );
  257. .@size_guild = 1;
  258. .@cid[0] = .@master_cid;
  259. .@aid[0] = .@master_aid;
  260. }
  261. else if (.Options&8) {
  262. for ( .@j = 0; .@j < .@size_guild; ++.@j ) {
  263. .@is_online[.@j] = isloggedin( .@aid[.@j], .@cid[.@j] );
  264. if (.@is_online[.@j])
  265. .@ip$ = replacestr(getcharip(.@aid[.@j]),".","a");
  266. else {
  267. if (query_sql("SELECT `last_ip` FROM `login` WHERE `account_id` = '" + .@aid[.@j] + "'", .@last_ip$) < 1)
  268. continue;
  269. .@ip$ = replacestr(.@last_ip$, ".", "a");
  270. }
  271. .@variable$ = ".@ip_" + .@i + "_" + .@ip$;
  272. .@index = getd(.@variable$) - 1;
  273. if (.@index >= 0) {
  274. if (.@is_online[.@j]) {
  275. .@tmp_account_id[.@index] = .@aid[.@j];
  276. .@tmp_char_id[.@index] = .@cid[.@j];
  277. }
  278. continue;
  279. }
  280. setd .@variable$, .@j+1;
  281. .@tmp_account_id[.@k] = .@aid[.@j];
  282. .@tmp_char_id[.@k] = .@cid[.@j];
  283. .@k++;
  284. }
  285. copyarray .@aid[0], .@tmp_account_id[0], .@k;
  286. copyarray .@cid[0], .@tmp_char_id[0], .@k;
  287. .@size_guild = .@k;
  288. }
  289. for(set .@j,0; .@j<.@size_guild; set .@j,.@j+1) {
  290. if (.Options&2) {
  291. .@charid = .@cid[.@j];
  292. .@sender$ = "no-reply";
  293. .@title$ = "** Siege Reward: "+getcastlename(.Castles$[.@i])+" **";
  294. .@body$ = "Brave one,\r\n \r\n Congratulations!\r\n Your guild has successfully occupied\r\n territory in the War of Emperium on\r\n "+.@str$+".\r\n \r\n \r\n \r\n \r\n [ Your reward is attached. ]";
  295. if (.reward_id_size)
  296. mail .@charid, .@sender$, .@title$, .@body$, .reward_zeny, .reward_id, .reward_amount;
  297. else
  298. mail .@charid, .@sender$, .@title$, .@body$, .reward_zeny;
  299. if (PACKETVER < 20150513 && !getd(".@str_"+.@cid[.@j]) && isloggedin(.@aid[.@j],.@cid[.@j])) {
  300. setd ".@str_"+.@cid[.@j],1;
  301. message rid2name(.@aid[.@j]),"You've got mail!";
  302. }
  303. }
  304. else if (isloggedin(.@aid[.@j],.@cid[.@j])) {
  305. attachrid( .@aid[.@j], true );
  306. .@name$ = strcharinfo( 0 );
  307. .@castle_name$ = getcastlename(.Castles$[.@i]);
  308. for ( .@k = 0; .@k < .reward_id_size; .@k++ ) {
  309. if (checkweight(.reward_id[.@k], .reward_amount[.@k]))
  310. getitem .reward_id[.@k], .reward_amount[.@k];
  311. else
  312. dispbottom "You can't receive x" + .reward_amount[.@k] + " " + getitemname(.reward_id[.@k]) + " for conquering " + .@castle_name$ + " because you're overweight.";
  313. }
  314. Zeny += .reward_zeny;
  315. dispbottom "You have been rewarded for conquering " + .@castle_name$ + ".";
  316. }
  317. }
  318. }
  319. }
  320. return;
  321. OnPCLoadMapEvent:
  322. if (!compare(strcharinfo(3),"g_cas")) end;
  323. if (((.AutoKick && .Active[0]) || (.NoOwner && !getcastledata(strcharinfo(3),1))) && !(.Active[0]&(1<<getd("."+strcharinfo(3))))) {
  324. if (getcharid(2) && getcastledata(strcharinfo(3),1) == getcharid(2)) end;
  325. .@castle_name$ = getcastlename(strcharinfo(3));
  326. sleep2 1000;
  327. message strcharinfo(0), .@castle_name$ + " is currently inactive.";
  328. sleep2 5000;
  329. if (compare(strcharinfo(3),"g_cas")) warp "SavePoint",0,0;
  330. }
  331. end;
  332. OnMenu:
  333. while(1) {
  334. mes "[WOE Information]";
  335. if (agitcheck() || agitcheck2() || agitcheck3()) {
  336. if (.Active[0]) {
  337. for(set .@i,0; .@i<.Size; set .@i,.@i+4) {
  338. if (gettime(DT_DAYOFWEEK) == $WOE_CONTROL[.@i] && gettime(DT_HOUR) >= $WOE_CONTROL[.@i+1] && gettime(DT_HOUR) < $WOE_CONTROL[.@i+2]) {
  339. set .@i, $WOE_CONTROL[.@i+2];
  340. break;
  341. }
  342. }
  343. mes "The War of Emperium is ^0055FFactive^000000 until ^FF0000"+Add_Zero(.@i)+"^000000 in the following regions:";
  344. mes " ";
  345. for(set .@i,0; .@i < .total_region; set .@i,.@i+1)
  346. if (.Active[1]&(1<<.@i)) mes " > ^777777"+.Regions$[.@i]+"^000000";
  347. } else
  348. mes "The War of Emperium is ^0055FFactive^000000.";
  349. } else {
  350. for(set .@i,0; .@i<.Size; set .@i,.@i+4)
  351. if ((gettime(DT_DAYOFWEEK) == $WOE_CONTROL[.@i] && gettime(DT_HOUR) <= $WOE_CONTROL[.@i+1]) || gettime(DT_DAYOFWEEK) < $WOE_CONTROL[.@i]) {
  352. setarray .@time[0],$WOE_CONTROL[.@i],$WOE_CONTROL[.@i+1];
  353. break;
  354. }
  355. if (!getarraysize(.@time))
  356. setarray .@time[0],$WOE_CONTROL[0],$WOE_CONTROL[1];
  357. mes "The War of Emperium is ^777777inactive^000000.";
  358. if (.Size) {
  359. mes " ";
  360. mes "The next session will begin";
  361. mes "on ^0055FF"+.Days$[.@time[0]]+"^000000 at "+Add_Zero(.@time[1])+"^000000.";
  362. }
  363. }
  364. next;
  365. switch(select(""+((.CastleWarp || .Active[1])?" ~ Warp to castles...":"")+": ~ Check schedule...: ~ View castle owners...:"+((getgmlevel()<.GMAccess || !getgmlevel())?"":" ~ Manage sessions...")+": ~ ^777777Cancel^000000")) {
  366. case 1:
  367. if (.CastleWarp) set .@clr$,"^0055FF";
  368. set .@menu$,"";
  369. for(set .@i,0; .@i < .total_region; set .@i,.@i+1) {
  370. if (.CastleWarp || .Active[1]&(1<<.@i))
  371. set .@menu$, .@menu$+" ~ "+((.Active[1]&(1<<.@i))?.@clr$:"^777777")+.Regions$[.@i]+" Castles^000000";
  372. set .@menu$, .@menu$+":";
  373. }
  374. set .@i, select(.@menu$)-1;
  375. set .@menu$,"";
  376. for(set .@j,0; .@j < .size_region[.@i]; set .@j,.@j+1) {
  377. .@index = getd( ".castle_index_in_region_" + .@i + "[" + .@j + "]" );
  378. if (.CastleWarp || .Active[0]&(1<<.@index))
  379. set .@menu$, .@menu$+" ~ "+((.Active[0]&(1<<.@index))?.@clr$:"^777777")+getcastlename(.Castles$[.@index])+"^000000";
  380. set .@menu$, .@menu$+":";
  381. }
  382. set .@j, select(.@menu$)-1;
  383. .@index = getd( ".castle_index_in_region_" + .@i + "[" + .@j + "]" );
  384. warp .Map$[.@index],.MapX[.@index],.MapY[.@index];
  385. close;
  386. case 2:
  387. mes "[Schedule]";
  388. if (.Size) {
  389. freeloop(1);
  390. for(set .@i,0; .@i<.Size; set .@i,.@i+4) {
  391. mes "> ^FF0000"+.Days$[$WOE_CONTROL[.@i]]+" ("+Add_Zero($WOE_CONTROL[.@i+1])+"-"+Add_Zero($WOE_CONTROL[.@i+2])+")^000000";
  392. for(set .@j,0; .@j<.total_castle; set .@j,.@j+1)
  393. if ($WOE_CONTROL[.@i+3]&(1<<.@j)) mes " ~ "+getcastlename(.Castles$[.@j])+" ^777777("+.Castles$[.@j]+")^000000";
  394. if (.@i+4 < .Size) mes " ";
  395. }
  396. freeloop(0);
  397. } else
  398. mes "No times are configured.";
  399. next;
  400. break;
  401. case 3:
  402. mes "[Castle Ownership]";
  403. for(set .@i,0; .@i < .total_region; set .@i,.@i+1) {
  404. set .@k, .@i*5;
  405. mes "> ^FF0000"+.Regions$[.@i]+"^000000";
  406. for(set .@j,0; .@j<.size_region[.@i]; set .@j,.@j+1) {
  407. .@index = getd( ".castle_index_in_region_" + .@i + "[" + .@j + "]" );
  408. set .@t, getcastledata(.Castles$[.@index],1);
  409. mes " ~ "+getcastlename(.Castles$[.@index])+": "+((.@t)?"^0055FF"+getguildname(.@t):"^777777unoccupied")+"^000000";
  410. }
  411. if (.@i < 5) mes " ";
  412. }
  413. next;
  414. break;
  415. case 4:
  416. while(1) {
  417. mes "[Session Manager]";
  418. mes "There are ^0055FF"+(.Size/4)+" session(s)^000000 configured.";
  419. mes "What would you like to do?";
  420. next;
  421. switch(select(" ~ Add a session...: ~ Delete a session...: ~ Reload settings...:"+((agitcheck() || agitcheck2() || agitcheck3())?" ~ End WOE session...":"")+": ~ ^777777Go back^000000")) {
  422. case 1:
  423. mes "[New Session]";
  424. mes "Select a day.";
  425. next;
  426. set .@Day, select(" ~ "+implode(.Days$,": ~ "))-1;
  427. mes "[New Session]";
  428. mes "Select a start time for ^0055FF"+.Days$[.@Day]+"^000000.";
  429. next;
  430. set .@menu$,"";
  431. for(set .@i,0; .@i<23; set .@i,.@i+1)
  432. set .@menu$, .@menu$+" ~ "+Add_Zero(.@i,1)+":";
  433. set .@Start, select(.@menu$)-1;
  434. mes "[New Session]";
  435. mes "Select an end time for ^0055FF"+.Days$[.@Day]+"^000000.";
  436. next;
  437. set .@menu$,"";
  438. for(set .@i,.@Start+1; .@i<24; set.@i,.@i+1)
  439. set .@menu$, .@menu$+" ~ "+Add_Zero(.@i,1)+":";
  440. set .@End, select(.@menu$)+.@Start;
  441. for(set .@i,0; .@i<.Size; set .@i,.@i+4)
  442. if (.@Day == $WOE_CONTROL[.@i] &&
  443. ((.@Start >= $WOE_CONTROL[.@i+1] && .@Start < $WOE_CONTROL[.@i+2]) ||
  444. (.@End > $WOE_CONTROL[.@i+1] && .@End <= $WOE_CONTROL[.@i+2]) ||
  445. (.@Start <= $WOE_CONTROL[.@i+1] && .@End >= $WOE_CONTROL[.@i+2]))) {
  446. mes "[New Session]";
  447. mes "The chosen times overlap with an existing session.";
  448. next;
  449. set .@d,1;
  450. break;
  451. }
  452. if (.@d) { set .@d,0; break; }
  453. set .@Castle,0;
  454. while(1) {
  455. mes "[New Session]";
  456. mes "^0055FF"+.Days$[.@Day]+" ("+Add_Zero(.@Start)+"-"+Add_Zero(.@End)+")^000000";
  457. mes " > Castles:";
  458. if (!.@Castle)
  459. mes " ~ ^777777(none selected)^000000";
  460. else {
  461. for(set .@i,0; .@i<.total_castle; set .@i,.@i+1) {
  462. .@string$ = ( .@Castle&(1<<.@i) ) ? " ~ "+getcastlename(.Castles$[.@i])+" ("+.Castles$[.@i]+")" : "";
  463. mes .@string$;
  464. }
  465. }
  466. next;
  467. set .@menu$,((.@Castle)?" ~ ^FF0000Finished...^000000":"")+":";
  468. for(set .@i,0; .@i<.total_castle; set .@i,.@i+1)
  469. set .@menu$, .@menu$+" ~ "+((.@Castle&(1<<.@i))?"^0055FF":"")+getcastlename(.Castles$[.@i])+" ("+.Castles$[.@i]+")^000000:";
  470. set .@i, select(.@menu$)-1;
  471. if (.@i)
  472. set .@Castle, .@Castle^(1<<(.@i-1));
  473. else {
  474. mes "[New Session]";
  475. mes "Are you sure?";
  476. next;
  477. switch(select(" ~ ^0055FFAdd session...^000000: ~ Continue selecting castles...: ~ ^777777Cancel^000000")) {
  478. case 1:
  479. for(set .@i,0; .@i<.Size; set .@i,.@i+4) {
  480. if ((.@Day == $WOE_CONTROL[.@i] && .@End <= $WOE_CONTROL[.@i+1]) || .@Day < $WOE_CONTROL[.@i]) {
  481. set .@d,1;
  482. break;
  483. }
  484. }
  485. if (!.@d) { set .@d,1; set .@i,.Size; }
  486. copyarray $WOE_CONTROL[.@i+4], $WOE_CONTROL[.@i], .Size-.@i;
  487. setarray $WOE_CONTROL[.@i], .@Day, .@Start, .@End, .@Castle;
  488. set .Size, getarraysize($WOE_CONTROL);
  489. case 3:
  490. mes "[New Session]";
  491. mes ((.@d)?"Session added.":"cancelled.");
  492. next;
  493. set .@d,1;
  494. case 2:
  495. break;
  496. }
  497. if (.@d) { set .@d,0; break; }
  498. }
  499. }
  500. break;
  501. case 2:
  502. mes "[Remove Session]";
  503. if (!.Size) {
  504. mes "There are no sessions configured.";
  505. next;
  506. break;
  507. }
  508. mes "Select a session to remove.";
  509. next;
  510. set .@menu$,"";
  511. for(set .@i,0; .@i<.Size; set .@i,.@i+4)
  512. set .@menu$, .@menu$+" ~ "+.Days$[$WOE_CONTROL[.@i]]+" ("+Add_Zero($WOE_CONTROL[.@i+1],1)+"-"+Add_Zero($WOE_CONTROL[.@i+2],1)+"):";
  513. set .@menu$, .@menu$+" ~ ^777777Cancel^000000";
  514. set .@i, select(.@menu$)-1;
  515. if (.@i == (.Size/4)) break;
  516. mes "[Remove Session]";
  517. mes "Delete ^0055FF"+.Days$[$WOE_CONTROL[.@i*4]]+"'s^000000 session?";
  518. mes "This action cannot be undone.";
  519. next;
  520. set .@j, select(" ~ ^FF0000Delete session...^000000: ~ ^777777Cancel^000000");
  521. mes "[Remove Session]";
  522. if (.@j == 2)
  523. mes "cancelled.";
  524. else {
  525. deletearray $WOE_CONTROL[.@i*4],4;
  526. set .Size, getarraysize($WOE_CONTROL);
  527. mes "Session deleted.";
  528. }
  529. next;
  530. break;
  531. case 3:
  532. mes "[Reload Settings]";
  533. mes "This will trigger all events related to new session configurations, if any.";
  534. if (agitcheck() || agitcheck2() || agitcheck3()) {
  535. mes " ";
  536. mes "Be aware that this will disrupt the current WOE session.";
  537. }
  538. next;
  539. set .@i, select(" ~ ^0055FFReload settings...^000000: ~ ^777777Cancel^000000");
  540. mes "[Reload Settings]";
  541. if (.@i == 2) mes "cancelled.";
  542. else {
  543. set .Init,1;
  544. donpcevent "WOE_CONTROL::OnMinute00";
  545. mes "Variables have been re-initialized.";
  546. }
  547. next;
  548. break;
  549. case 4:
  550. mes "[Force Agit End]";
  551. if (!agitcheck() && !agitcheck2() && !agitcheck3()) {
  552. mes "WOE has already ended.";
  553. next;
  554. break;
  555. }
  556. mes "This command will safely execute all AgitEnd events.";
  557. mes " ";
  558. mes "Kill the current WOE session?";
  559. next;
  560. set .@i, select(" ~ ^FF0000End session...^000000:"+((.Options&1)?" ~ ^FF0000End session without rewards...^000000":"")+": ~ ^777777Cancel^000000");
  561. mes "[Force Agit End]";
  562. if (.@i == 3)
  563. mes "cancelled.";
  564. else {
  565. set .ForceEnd, .@i;
  566. donpcevent "WOE_CONTROL::OnWOEEnd";
  567. mes "WOE session terminated.";
  568. }
  569. next;
  570. break;
  571. case 5:
  572. set .@d,1; break;
  573. }
  574. if (.@d) { set .@d,0; break; }
  575. } break;
  576. case 5:
  577. close;
  578. } }
  579. }