woe_controller.txt 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  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. for(set .@j,0; .@j<.@size_guild; set .@j,.@j+1) {
  262. if ((.Options&8) && !(.Options&4)) {
  263. set .@ip$, replacestr(getcharip(.@aid[.@j]),".","a");
  264. if (getd(".@ip_"+.@i+"_"+.@ip$)) continue;
  265. setd ".@ip_"+.@i+"_"+.@ip$,1;
  266. }
  267. if (.Options&2) {
  268. .@charid = .@cid[.@j];
  269. .@sender$ = "no-reply";
  270. .@title$ = "** Siege Reward: "+getcastlename(.Castles$[.@i])+" **";
  271. .@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. ]";
  272. if (.reward_id_size)
  273. mail .@charid, .@sender$, .@title$, .@body$, .reward_zeny, .reward_id, .reward_amount;
  274. else
  275. mail .@charid, .@sender$, .@title$, .@body$, .reward_zeny;
  276. if (PACKETVER < 20150513 && !getd(".@str_"+.@cid[.@j]) && isloggedin(.@aid[.@j],.@cid[.@j])) {
  277. setd ".@str_"+.@cid[.@j],1;
  278. message rid2name(.@aid[.@j]),"You've got mail!";
  279. }
  280. }
  281. else if (isloggedin(.@aid[.@j],.@cid[.@j])) {
  282. attachrid( .@aid[.@j], true );
  283. .@name$ = strcharinfo( 0 );
  284. .@castle_name$ = getcastlename(.Castles$[.@i]);
  285. for ( .@k = 0; .@k < .reward_id_size; .@k++ ) {
  286. if (checkweight(.reward_id[.@k], .reward_amount[.@k]))
  287. getitem .reward_id[.@k], .reward_amount[.@k];
  288. else
  289. dispbottom "You can't receive x" + .reward_amount[.@k] + " " + getitemname(.reward_id[.@k]) + " for conquering " + .@castle_name$ + " because you're overweight.";
  290. }
  291. Zeny += .reward_zeny;
  292. dispbottom "You have been rewarded for conquering " + .@castle_name$ + ".";
  293. detachrid;
  294. }
  295. }
  296. }
  297. }
  298. return;
  299. OnPCLoadMapEvent:
  300. .@compare_val = compare(strcharinfo(3),"g_cas");
  301. if (!.@compare_val) end;
  302. if (((.AutoKick && .Active[0]) || (.NoOwner && !getcastledata(strcharinfo(3),1))) && !(.Active[0]&(1<<getd("."+strcharinfo(3))))) {
  303. if (getcharid(2) && getcastledata(strcharinfo(3),1) == getcharid(2)) end;
  304. .@castle_name$ = getcastlename(strcharinfo(3));
  305. sleep2 1000;
  306. message strcharinfo(0), .@castle_name$ + " is currently inactive.";
  307. sleep2 5000;
  308. if (.@compare_val) warp "SavePoint",0,0;
  309. }
  310. end;
  311. OnMenu:
  312. while(1) {
  313. mes "[WOE Information]";
  314. if (agitcheck() || agitcheck2() || agitcheck3()) {
  315. if (.Active[0]) {
  316. for(set .@i,0; .@i<.Size; set .@i,.@i+4) {
  317. if (gettime(DT_DAYOFWEEK) == $WOE_CONTROL[.@i] && gettime(DT_HOUR) >= $WOE_CONTROL[.@i+1] && gettime(DT_HOUR) < $WOE_CONTROL[.@i+2]) {
  318. set .@i, $WOE_CONTROL[.@i+2];
  319. break;
  320. }
  321. }
  322. mes "The War of Emperium is ^0055FFactive^000000 until ^FF0000"+Add_Zero(.@i)+"^000000 in the following regions:";
  323. mes " ";
  324. for(set .@i,0; .@i < .total_region; set .@i,.@i+1)
  325. if (.Active[1]&(1<<.@i)) mes " > ^777777"+.Regions$[.@i]+"^000000";
  326. } else
  327. mes "The War of Emperium is ^0055FFactive^000000.";
  328. } else {
  329. for(set .@i,0; .@i<.Size; set .@i,.@i+4)
  330. if ((gettime(DT_DAYOFWEEK) == $WOE_CONTROL[.@i] && gettime(DT_HOUR) <= $WOE_CONTROL[.@i+1]) || gettime(DT_DAYOFWEEK) < $WOE_CONTROL[.@i]) {
  331. setarray .@time[0],$WOE_CONTROL[.@i],$WOE_CONTROL[.@i+1];
  332. break;
  333. }
  334. if (!getarraysize(.@time))
  335. setarray .@time[0],$WOE_CONTROL[0],$WOE_CONTROL[1];
  336. mes "The War of Emperium is ^777777inactive^000000.";
  337. if (.Size) {
  338. mes " ";
  339. mes "The next session will begin";
  340. mes "on ^0055FF"+.Days$[.@time[0]]+"^000000 at "+Add_Zero(.@time[1])+"^000000.";
  341. }
  342. }
  343. next;
  344. switch(select(""+((.CastleWarp || .Active[1])?" ~ Warp to castles...":"")+": ~ Check schedule...: ~ View castle owners...:"+((getgmlevel()<.GMAccess || !getgmlevel())?"":" ~ Manage sessions...")+": ~ ^777777Cancel^000000")) {
  345. case 1:
  346. if (.CastleWarp) set .@clr$,"^0055FF";
  347. set .@menu$,"";
  348. for(set .@i,0; .@i < .total_region; set .@i,.@i+1) {
  349. if (.CastleWarp || .Active[1]&(1<<.@i))
  350. set .@menu$, .@menu$+" ~ "+((.Active[1]&(1<<.@i))?.@clr$:"^777777")+.Regions$[.@i]+" Castles^000000";
  351. set .@menu$, .@menu$+":";
  352. }
  353. set .@i, select(.@menu$)-1;
  354. set .@menu$,"";
  355. for(set .@j,0; .@j < .size_region[.@i]; set .@j,.@j+1) {
  356. .@index = getd( ".castle_index_in_region_" + .@i + "[" + .@j + "]" );
  357. if (.CastleWarp || .Active[0]&(1<<.@index))
  358. set .@menu$, .@menu$+" ~ "+((.Active[0]&(1<<.@index))?.@clr$:"^777777")+getcastlename(.Castles$[.@index])+"^000000";
  359. set .@menu$, .@menu$+":";
  360. }
  361. set .@j, select(.@menu$)-1;
  362. .@index = getd( ".castle_index_in_region_" + .@i + "[" + .@j + "]" );
  363. warp .Map$[.@index],.MapX[.@index],.MapY[.@index];
  364. close;
  365. case 2:
  366. mes "[Schedule]";
  367. if (.Size) {
  368. freeloop(1);
  369. for(set .@i,0; .@i<.Size; set .@i,.@i+4) {
  370. mes "> ^FF0000"+.Days$[$WOE_CONTROL[.@i]]+" ("+Add_Zero($WOE_CONTROL[.@i+1])+"-"+Add_Zero($WOE_CONTROL[.@i+2])+")^000000";
  371. for(set .@j,0; .@j<.total_castle; set .@j,.@j+1)
  372. if ($WOE_CONTROL[.@i+3]&(1<<.@j)) mes " ~ "+getcastlename(.Castles$[.@j])+" ^777777("+.Castles$[.@j]+")^000000";
  373. if (.@i+4 < .Size) mes " ";
  374. }
  375. freeloop(0);
  376. } else
  377. mes "No times are configured.";
  378. next;
  379. break;
  380. case 3:
  381. mes "[Castle Ownership]";
  382. for(set .@i,0; .@i < .total_region; set .@i,.@i+1) {
  383. set .@k, .@i*5;
  384. mes "> ^FF0000"+.Regions$[.@i]+"^000000";
  385. for(set .@j,0; .@j<.size_region[.@i]; set .@j,.@j+1) {
  386. .@index = getd( ".castle_index_in_region_" + .@i + "[" + .@j + "]" );
  387. set .@t, getcastledata(.Castles$[.@index],1);
  388. mes " ~ "+getcastlename(.Castles$[.@index])+": "+((.@t)?"^0055FF"+getguildname(.@t):"^777777unoccupied")+"^000000";
  389. }
  390. if (.@i < 5) mes " ";
  391. }
  392. next;
  393. break;
  394. case 4:
  395. while(1) {
  396. mes "[Session Manager]";
  397. mes "There are ^0055FF"+(.Size/4)+" session(s)^000000 configured.";
  398. mes "What would you like to do?";
  399. next;
  400. switch(select(" ~ Add a session...: ~ Delete a session...: ~ Reload settings...:"+((agitcheck() || agitcheck2() || agitcheck3())?" ~ End WOE session...":"")+": ~ ^777777Go back^000000")) {
  401. case 1:
  402. mes "[New Session]";
  403. mes "Select a day.";
  404. next;
  405. set .@Day, select(" ~ "+implode(.Days$,": ~ "))-1;
  406. mes "[New Session]";
  407. mes "Select a start time for ^0055FF"+.Days$[.@Day]+"^000000.";
  408. next;
  409. set .@menu$,"";
  410. for(set .@i,0; .@i<23; set .@i,.@i+1)
  411. set .@menu$, .@menu$+" ~ "+Add_Zero(.@i,1)+":";
  412. set .@Start, select(.@menu$)-1;
  413. mes "[New Session]";
  414. mes "Select an end time for ^0055FF"+.Days$[.@Day]+"^000000.";
  415. next;
  416. set .@menu$,"";
  417. for(set .@i,.@Start+1; .@i<24; set.@i,.@i+1)
  418. set .@menu$, .@menu$+" ~ "+Add_Zero(.@i,1)+":";
  419. set .@End, select(.@menu$)+.@Start;
  420. for(set .@i,0; .@i<.Size; set .@i,.@i+4)
  421. if (.@Day == $WOE_CONTROL[.@i] &&
  422. ((.@Start >= $WOE_CONTROL[.@i+1] && .@Start < $WOE_CONTROL[.@i+2]) ||
  423. (.@End > $WOE_CONTROL[.@i+1] && .@End <= $WOE_CONTROL[.@i+2]) ||
  424. (.@Start <= $WOE_CONTROL[.@i+1] && .@End >= $WOE_CONTROL[.@i+2]))) {
  425. mes "[New Session]";
  426. mes "The chosen times overlap with an existing session.";
  427. next;
  428. set .@d,1;
  429. break;
  430. }
  431. if (.@d) { set .@d,0; break; }
  432. set .@Castle,0;
  433. while(1) {
  434. mes "[New Session]";
  435. mes "^0055FF"+.Days$[.@Day]+" ("+Add_Zero(.@Start)+"-"+Add_Zero(.@End)+")^000000";
  436. mes " > Castles:";
  437. if (!.@Castle)
  438. mes " ~ ^777777(none selected)^000000";
  439. else {
  440. for(set .@i,0; .@i<.total_castle; set .@i,.@i+1) {
  441. .@string$ = ( .@Castle&(1<<.@i) ) ? " ~ "+getcastlename(.Castles$[.@i])+" ("+.Castles$[.@i]+")" : "";
  442. mes .@string$;
  443. }
  444. }
  445. next;
  446. set .@menu$,((.@Castle)?" ~ ^FF0000Finished...^000000":"")+":";
  447. for(set .@i,0; .@i<.total_castle; set .@i,.@i+1)
  448. set .@menu$, .@menu$+" ~ "+((.@Castle&(1<<.@i))?"^0055FF":"")+getcastlename(.Castles$[.@i])+" ("+.Castles$[.@i]+")^000000:";
  449. set .@i, select(.@menu$)-1;
  450. if (.@i)
  451. set .@Castle, .@Castle^(1<<(.@i-1));
  452. else {
  453. mes "[New Session]";
  454. mes "Are you sure?";
  455. next;
  456. switch(select(" ~ ^0055FFAdd session...^000000: ~ Continue selecting castles...: ~ ^777777Cancel^000000")) {
  457. case 1:
  458. for(set .@i,0; .@i<.Size; set .@i,.@i+4) {
  459. if ((.@Day == $WOE_CONTROL[.@i] && .@End <= $WOE_CONTROL[.@i+1]) || .@Day < $WOE_CONTROL[.@i]) {
  460. set .@d,1;
  461. break;
  462. }
  463. }
  464. if (!.@d) { set .@d,1; set .@i,.Size; }
  465. copyarray $WOE_CONTROL[.@i+4], $WOE_CONTROL[.@i], .Size-.@i;
  466. setarray $WOE_CONTROL[.@i], .@Day, .@Start, .@End, .@Castle;
  467. set .Size, getarraysize($WOE_CONTROL);
  468. case 3:
  469. mes "[New Session]";
  470. mes ((.@d)?"Session added.":"cancelled.");
  471. next;
  472. set .@d,1;
  473. case 2:
  474. break;
  475. }
  476. if (.@d) { set .@d,0; break; }
  477. }
  478. }
  479. break;
  480. case 2:
  481. mes "[Remove Session]";
  482. if (!.Size) {
  483. mes "There are no sessions configured.";
  484. next;
  485. break;
  486. }
  487. mes "Select a session to remove.";
  488. next;
  489. set .@menu$,"";
  490. for(set .@i,0; .@i<.Size; set .@i,.@i+4)
  491. set .@menu$, .@menu$+" ~ "+.Days$[$WOE_CONTROL[.@i]]+" ("+Add_Zero($WOE_CONTROL[.@i+1],1)+"-"+Add_Zero($WOE_CONTROL[.@i+2],1)+"):";
  492. set .@menu$, .@menu$+" ~ ^777777Cancel^000000";
  493. set .@i, select(.@menu$)-1;
  494. if (.@i == (.Size/4)) break;
  495. mes "[Remove Session]";
  496. mes "Delete ^0055FF"+.Days$[$WOE_CONTROL[.@i*4]]+"'s^000000 session?";
  497. mes "This action cannot be undone.";
  498. next;
  499. set .@j, select(" ~ ^FF0000Delete session...^000000: ~ ^777777Cancel^000000");
  500. mes "[Remove Session]";
  501. if (.@j == 2)
  502. mes "cancelled.";
  503. else {
  504. deletearray $WOE_CONTROL[.@i*4],4;
  505. set .Size, getarraysize($WOE_CONTROL);
  506. mes "Session deleted.";
  507. }
  508. next;
  509. break;
  510. case 3:
  511. mes "[Reload Settings]";
  512. mes "This will trigger all events related to new session configurations, if any.";
  513. if (agitcheck() || agitcheck2() || agitcheck3()) {
  514. mes " ";
  515. mes "Be aware that this will disrupt the current WOE session.";
  516. }
  517. next;
  518. set .@i, select(" ~ ^0055FFReload settings...^000000: ~ ^777777Cancel^000000");
  519. mes "[Reload Settings]";
  520. if (.@i == 2) mes "cancelled.";
  521. else {
  522. set .Init,1;
  523. donpcevent "WOE_CONTROL::OnMinute00";
  524. mes "Variables have been re-initialized.";
  525. }
  526. next;
  527. break;
  528. case 4:
  529. mes "[Force Agit End]";
  530. if (!agitcheck() && !agitcheck2() && !agitcheck3()) {
  531. mes "WOE has already ended.";
  532. next;
  533. break;
  534. }
  535. mes "This command will safely execute all AgitEnd events.";
  536. mes " ";
  537. mes "Kill the current WOE session?";
  538. next;
  539. set .@i, select(" ~ ^FF0000End session...^000000:"+((.Options&1)?" ~ ^FF0000End session without rewards...^000000":"")+": ~ ^777777Cancel^000000");
  540. mes "[Force Agit End]";
  541. if (.@i == 3)
  542. mes "cancelled.";
  543. else {
  544. set .ForceEnd, .@i;
  545. donpcevent "WOE_CONTROL::OnWOEEnd";
  546. mes "WOE session terminated.";
  547. }
  548. next;
  549. break;
  550. case 5:
  551. set .@d,1; break;
  552. }
  553. if (.@d) { set .@d,0; break; }
  554. } break;
  555. case 5:
  556. close;
  557. } }
  558. }