Advertisement
Guest User

Untitled

a guest
Sep 14th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.43 KB | None | 0 0
  1. //======================================================================================================
  2. //= Toasty's WoE Controller (formerly WoE Info Banner)
  3. //===== By: ============================================================================================
  4. //= ToastOfDoom (aka: iHeart)
  5. //===== Current Version: ===============================================================================
  6. //= 1.22
  7. //===== Description: ===================================================================================
  8. //= A WoE Controller function which controls castle based WoE by utilising npc events.
  9. //= Includes a NPC that provides information on the next WoE session
  10. //=
  11. //= This script is kinda @reloadscript/@loadnpc safe, provided that someone clicks the NPCs afterwards
  12. //= to start the OnInit function. That said..it is recommended that you don't use @reloadscript/@loadnpc
  13. //= but reset your server.
  14. //===== Changelog: =====================================================================================
  15. //= 1.22
  16. //= - Fixed an issue regarding the controller getting confused when using @reloadscript/loadnpc while
  17. //= WoE was still active. (thanks to annie for pointing out)
  18. //= 1.21
  19. //= - Fixed a misspelt variable name (thanks to rahuldev345 for pointing out)
  20. //= 1.20
  21. //= - Project renamed to 'Toasty's WoE Controller'. The script originally was only used to display WoE
  22. //= times then I 1st wrote it 3yrs ago and I feel it's purpose is more to control WoE these days. So
  23. //= name change to better reflect purpose.
  24. //= - Added support for novice WoE. Region teleport goes to the Novice Warper NPC (default in prontera)
  25. //= Change position in .region_maps, .region_x, .region_y if needed.
  26. //= - Region warp now only displays regions that have castles used at least once. (eg. If you don't
  27. //= configure any castles for Payon region, payon will not show up)
  28. //= - Optimised WoE Active/Inactive map notifier. Old method used too many loops for something that
  29. //= can happen alot.
  30. //= - Adjusted menus to be abit more friendly. 'next's will always display before 'menu's
  31. //= - Fixed bug with WoE autostarting when only configured for 2 sessions in one day
  32. //= - Added some nifty code that prevents catastrophic failure of the script if you try to run a trunk
  33. //= version on a stable server (ie. if you do, it will show an error message, but script will still
  34. //= run perfectly fine - check out WoEToggler function for those that want to peek at it =P)
  35. //= 1.11
  36. //= - Fixed timer glitch when players only configured sessions for one day of the week
  37. //= - Adjusted timer to show remaining time more accurately
  38. //= - Modified .num_woes calculation due to bug regarding 0's being counted as unset values in arrays
  39. //= 1.10
  40. //= - Expanded script to allow castle based configuration
  41. //= - Moved away from portal based woe control. Now using donpcevents to OnAgitEnd/2 events. Provided
  42. //= castles are linked to the main agit commands in this manner, they will be controllable using this
  43. //= script.
  44. //= - Added an onLoadMap WoE available notifier. Can be disabled by setting .notify_woe to 0 in the
  45. //= CONFIG section.
  46. //= - Did some funky color coding.
  47. //= - Added Coordinate based warping per region (see .region_x & .region_y in the CONSTANTS section)
  48. //= 1.02
  49. //= - Added delwaitingroom to banner npc to prevent memory leaks from bug #2325
  50. //= - To reduce spamming of waitingroom packets to players banner NPC only now updates when the banner
  51. //= text changes. Thus min time between updates is now 1sec regardless of setting.
  52. //= - Added setting for rate which banner time is updated (.banner_refresh_rate) in the CONFIG section.
  53. //= - Added agitstart2/end2 to provide WoE2 support (Hope it works ^_^;)
  54. //= 1.01
  55. //= - Hardcoded in refresh value for banner npc instead of getting it from config from WoEInfoBase. Had
  56. //= issues starting the script after @reloadscript/@loadnpc
  57. //======================================================================================================
  58. - script WoEInfoBase -1,{
  59.  
  60. OnStartMenu:
  61. if(.init == 0)
  62. donpcevent strnpcinfo(3)+"::OnInit";
  63.  
  64. OnStartMenu2:
  65. mes "The " + ((.state)?"^00DD00current":"^DD0000next") + "^000000 WoE session is: ";
  66. mes " ";
  67. mes "Day: ^0000DD" + .daysOfWeek$[.woe_day[.woe_index]];
  68. mes "^000000Start time: ^00DD00" + .woe_0_str$[.woe_index];
  69. mes "^000000End time: ^DD0000" + .woe_1_str$[.woe_index];
  70. mes "^000000Region:";
  71.  
  72. set .@state_strs$, ".woe_state_str_" + .woe_state[.woe_index] + "$";
  73. for(set .@i, 0; .@i < .num_regions; set .@i, .@i + 1) {
  74. set .@output$, getd(.@state_strs$ + "[" + .@i + "]");
  75. if(.@output$ != "")
  76. mes "^000000- ^0000DD" + .@output$;
  77. }
  78. next;
  79.  
  80. if(getgmlevel() >= .gm_access)
  81. select(
  82. "Warp to Castle Grounds",
  83. "View Castle Owners",
  84. "View all WoE times",
  85. ((!.state)?"Start next WoE":"End current WoE"),
  86. ((.state)?"":"Skip next WoE session")
  87. );
  88. else
  89. select(
  90. "Warp to Castle Grounds",
  91. "View Castle Owners",
  92. "View all WoE times");
  93.  
  94. switch(@menu) {
  95. case 1: //warp
  96. mes "Which region would you like to warp to?";
  97. next;
  98. select(.region_warp$[.woe_state[.woe_index]]);
  99. if(@menu < 1 || @menu > .num_regions)
  100. close;
  101.  
  102. close2;
  103. warp .region_maps$[@menu - 1], .region_x[@menu - 1], .region_y[@menu - 1];
  104. end;
  105. case 2: //view
  106. set .@woe_state_array$, ".woe_state_" + .woe_state[.woe_index];
  107. for(set .@i, 0; .@i < .num_regions; set .@i, .@i + 1) {
  108. set .@k, 0;
  109. set .@castles$, ".castles_" + .regions$[.@i] + "$";
  110. set .@castle_check, getd(.@woe_state_array$ + "[" + .@i + "]");
  111. while(.@castle_check && .@k < .num_castles[.@i]) {
  112. if(.@castle_check & (1 << .@k)) {
  113. set .@map$, getd(.@castles$+"["+.@k+"]");
  114. if (GetCastleData(.@map$,1)) {
  115. dispbottom "The [" + GetCastleName(.@map$) + "] castle of the [" + .region_names$[.@i] + "] region is currently held by the [" + GetGuildName(GetCastleData(.@map$,1)) + "] guild.";
  116. } else {
  117. dispbottom "The [" + GetCastleName(.@map$) + "] castle of the [" + .region_names$[.@i] + "] region is currently unoccupied.";
  118. }
  119. set .@castle_check, .@castle_check - (1 << .@k);
  120. }
  121. set .@k, .@k + 1;
  122. }
  123. }
  124. break;
  125. case 3: //woe times
  126. for(set .@i, 0; .@i < .num_woes; set .@i, .@i + 1) {
  127. dispbottom "- " + .daysOfWeek$[.woe_day[.@i]] + " " + .woe_0_str$[.@i] + "-" + .woe_1_str$[.@i];
  128. set .@woe_state_str_array$, ".woe_state_str_" + .woe_state[.@i] + "$";
  129. for(set .@k, 0; .@k < .num_regions; set .@k, .@k + 1) {
  130. set .@output$, getd(.@woe_state_str_array$ + "[" + .@k + "]");
  131. if(.@output$ != "")
  132. dispbottom " " + .@output$;
  133. }
  134. }
  135. break;
  136. case 4: //start next;
  137. if(getgmlevel() <.gm_access) close;
  138.  
  139. mes "^FF0000Are you sure you want to " + ((!.state)?"start the next WoE session?":"end the current WoE session?");
  140. next;
  141. if(select("Yes:No") == 2) break;
  142.  
  143. set .remainTime, 0; //might not work sometimes...you have like a 500ms window out of 505ms i guess..
  144. sleep2 .timer_refresh_rate; //wait abit so the menu doesn't screw up (how long it takes for the timer to update)
  145. break;
  146. case 5: //skip next;
  147. if(getgmlevel() <.gm_access || .state) close;
  148.  
  149. mes "^FF0000Are you sure you want to skip the next WoE session^000000";
  150. next;
  151. if(select("Yes:No") == 2) break;
  152. if(.state) { //you really can't do this with woe active
  153. next;
  154. mes "Sorry, in the time you took making your decision, WoE started";
  155. mes "Please either manually end it first or wait";
  156. break;
  157. }
  158. set .woe_index, (.woe_index + 1) % .num_woes;
  159. donpcevent strnpcinfo(3)+"::OnUpdateCountTick";
  160. sleep2 .timer_refresh_rate;
  161. break;
  162. default: close;
  163. }
  164. goto OnStartMenu2;
  165.  
  166. OnInit:
  167.  
  168. //-----------------------------------------------------------------------------------------//
  169. //CONFIG START //
  170. //-----------------------------------------------------------------------------------------//
  171.  
  172. set .gm_access, 60;
  173.  
  174. //WoE timings needs to be ordered ascendingly unless you want to do weird
  175. //stuff like skip a region every other week or so...
  176. //Also times can't overlap. Uses second of day(gettimetick(1)) for timing
  177. // eg 1am -> 3600, 2:30pm -> 52200, midnight -> 86400 (anything past that doesn't work)
  178. //Note: woe_0 is start times, woe_1 is end times. Ignore how it's called but
  179. // don't change it either since it's dynamically used
  180. // Also..woe has to end on the same day it starts (it's easier that way..)
  181. setarray .woe_day[0], 0, 0, 3, 5, 6;
  182. setarray .woe_0[0], 35940,68400,21600,21600,21600;
  183. setarray .woe_1[0], 43140,72000,25200,28800,25200;
  184. setarray .woe_state[0], 0, 1, 2, 3, 4;
  185.  
  186. //WoE state settings. Every WoE session can be defined as a particular state of castle configuration.
  187. //.woe_state_#[%] = $
  188. // # - state number
  189. // % - region number
  190. // $ - binary representation of castles that are active for that region in that state (
  191. // (ie. 0 is no castles, 5 is castle 0 and 2 (2^0 + 2^2 = 5))
  192. setarray .woe_state_0[0],0,0,0,0,0,4,0;
  193. setarray .woe_state_1[0],0,0,0,4,0,0,0;
  194. setarray .woe_state_2[0],0,4,0,0,0,0,0;
  195. setarray .woe_state_3[0],0,0,0,0,4,0,0;
  196. setarray .woe_state_4[0],1,0,0,0,0,0,0;
  197.  
  198. //Setting for if script handles WoE controller function. Disable agit_controller.txt if you are using this.
  199. //For if you want to use something else to handle your woe stuff but only this script
  200. //to show info (1 - on, 0 - off...duh)
  201. set .active_woe, 1;
  202.  
  203.  
  204. //WoE inactive on map notifier. Basically notifies player if the castle they are entering is
  205. //WoE active or not
  206. set .notify_woe, 1;
  207.  
  208. //-----------------------------------------------------------------------------------------//
  209. //CONFIG END //
  210. //-----------------------------------------------------------------------------------------//
  211.  
  212.  
  213. //-----------------------------------------------------------------------------------------//
  214. //CONSTANTS START - Don't touch this unless you know what you are doing //
  215. //-----------------------------------------------------------------------------------------//
  216.  
  217. //castle maps by region
  218. setarray .castles_prtg$[0],"prtg_cas01","prtg_cas02","prtg_cas03","prtg_cas04","prtg_cas05";
  219. setarray .castles_payg$[0],"payg_cas01","payg_cas02","payg_cas03","payg_cas04","payg_cas05";
  220. setarray .castles_gefg$[0],"gefg_cas01","gefg_cas02","gefg_cas03","gefg_cas04","gefg_cas05";
  221. setarray .castles_aldeg$[0],"aldeg_cas01","aldeg_cas02","aldeg_cas03","aldeg_cas04","aldeg_cas05";
  222. setarray .castles_arug$[0],"arug_cas01","arug_cas02","arug_cas03","arug_cas04","arug_cas05";
  223. setarray .castles_schg$[0],"schg_cas01","schg_cas02","schg_cas03","schg_cas04","schg_cas05";
  224. setarray .castles_novi$[0],"nguild_alde","nguild_gef","nguild_pay","nguild_prt";
  225.  
  226. //woe kill functions for each castle
  227. setarray .woe_kill_prtg$[0],"Agit#prtg_cas01::OnAgitEnd","Agit#prtg_cas02::OnAgitEnd","Agit#prtg_cas03::OnAgitEnd","Agit#prtg_cas04::OnAgitEnd","Agit#prtg_cas05::OnAgitEnd";
  228. setarray .woe_kill_payg$[0],"Agit#payg_cas01::OnAgitEnd","Agit#payg_cas02::OnAgitEnd","Agit#payg_cas03::OnAgitEnd","Agit#payg_cas04::OnAgitEnd","Agit#payg_cas05::OnAgitEnd";
  229. setarray .woe_kill_gefg$[0],"Agit#gefg_cas01::OnAgitEnd","Agit#gefg_cas02::OnAgitEnd","Agit#gefg_cas03::OnAgitEnd","Agit#gefg_cas04::OnAgitEnd","Agit#gefg_cas05::OnAgitEnd";
  230. setarray .woe_kill_aldeg$[0],"Agit#aldeg_cas01::OnAgitEnd","Agit#aldeg_cas02::OnAgitEnd","Agit#aldeg_cas03::OnAgitEnd","Agit#aldeg_cas04::OnAgitEnd","Agit#aldeg_cas05::OnAgitEnd";
  231. setarray .woe_kill_arug$[0],"Manager#aru01_02::OnAgitEnd","Manager#aru02_02::OnAgitEnd","Manager#aru03_02::OnAgitEnd","Manager#aru04_02::OnAgitEnd","Manager#aru05_02::OnAgitEnd";
  232. setarray .woe_kill_schg$[0],"Manager#sch01_02::OnAgitEnd","Manager#sch02_02::OnAgitEnd","Manager#sch03_02::OnAgitEnd","Manager#sch04_02::OnAgitEnd","Manager#sch05_02::OnAgitEnd";
  233. setarray .woe_kill_novi$[0],"Agit_N01::OnAgitEnd","Agit_N02::OnAgitEnd","Agit_N03::OnAgitEnd","Agit_N04::OnAgitEnd";
  234.  
  235. //region prefixs
  236. setarray .regions$[0],"prtg","payg","gefg","aldeg","arug","schg","novi";
  237.  
  238. //region info
  239. setarray .region_names$[0],"Prontera", "Payon", "Geffen", "Aldebaran", "Arunafeltz", "Schwarzwald", "Novice Castles";
  240. setarray .region_maps$[0],"prt_gld", "pay_gld", "gef_fild13", "alde_gld", "aru_gld", "sch_gld", "prontera";
  241. //coords to warp player to region (0 is random)
  242. setarray .region_x[0],0, 0, 0, 0, 0, 0, 148;
  243. setarray .region_y[0],0, 0, 0, 0, 0, 0, 163;
  244.  
  245. setarray .waitMsg$[0], "WoE Starts: ", "WoE Ends: ";
  246. setarray .startMsg$[0], "WoE is Starting", "WoE is Ending";
  247.  
  248. set .ticks_in_day, 86400; //mmm...magic numbers
  249. setarray .daysOfWeek$[0], "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday";
  250.  
  251. set .timer_refresh_rate, 500; //how many ms per timer refresh...keep less than 1000 (in milliseconds)
  252. set .change_state_sleep, 3000; //how long to show "WoE is Start|End-ing" msg for in ms. (in milliseconds)
  253. //Make sure WoE sessions are longer than this xD
  254. set .banner_refresh_rate, 10; //how many seconds per banner refresh...keep 1 or above (in seconds)
  255.  
  256. //-----------------------------------------------------------------------------------------//
  257. //CONSTANTS END //
  258. //-----------------------------------------------------------------------------------------//
  259.  
  260. set .num_regions, getarraysize(.regions$);
  261. set .num_woes, getarraysize(.woe_1);
  262.  
  263. //force WoE to end if active
  264. callfunc "WoEToggler", 0;
  265.  
  266. for(set .@i, 0; .@i < .num_regions; set .@i, .@i + 1) {
  267. //count num castles per region
  268. set .num_castles[.@i], getarraysize(getd(".castles_" + .regions$[.@i] + "$"));
  269. }
  270.  
  271. //convert timestamps to readable format
  272. for(set .@i, 0; .@i < .num_woes; set .@i, .@i + 1)
  273. {
  274. set .@hrs, .woe_0[.@i] / 3600;
  275. set .@mins, .woe_0[.@i] % 3600 / 60;
  276. set .@output$, ((.@hrs % 12)?.@hrs%12:12) + ":" + ((.@mins < 10)?"0"+.@mins:.@mins) + " " + ((.@hrs > 12)?"PM":"AM");
  277.  
  278. set .woe_0_str$[.@i], .@output$;
  279.  
  280. set .@hrs, .woe_1[.@i] / 3600;
  281. set .@mins, .woe_1[.@i] % 3600 / 60;
  282. set .@output$, ((.@hrs % 12)?.@hrs%12:12) + ":" + ((.@mins < 10)?"0"+.@mins:.@mins) + " " + ((.@hrs > 12)?"PM":"AM");
  283.  
  284. set .woe_1_str$[.@i], .@output$;
  285. }
  286.  
  287. //calc number of woe states and consolidate states to create list of castles used
  288. set .num_states, 0;
  289. while(getarraysize(getd(".woe_state_" + (.num_states)))) {
  290. set .@state$, ".woe_state_" + .num_states;
  291. set .@i, 0;
  292. while(.@i < getarraysize(getd(.@state$))) {
  293. set .castleUsage[.@i], .castleUsage[.@i] | getd(.@state$ + "[" + .@i + "]");
  294. set .@i, .@i + 1;
  295. }
  296. set .num_states, .num_states + 1;
  297. }
  298.  
  299. for(set .@i, 0; .@i < .num_states; set .@i, .@i + 1) {
  300. set .@woe_state_array$, ".woe_state_" + .@i;
  301. for(set .@k, 0; .@k < .num_regions; set .@k, .@k + 1) {
  302. if(.castleUsage[.@k] > 0) {
  303. set .@castles$, ".castles_" + .regions$[.@k] + "$";
  304. set .@castle_check, getd(.@woe_state_array$ + "[" + .@k + "]");
  305. if(.@castle_check == 0) { //region not in this state
  306. //region warp menu string
  307. set .region_warp$[.@i], .region_warp$[.@i] + "^DD0000" + .region_names$[.@k] + "^000000:";
  308. continue;
  309. } else {
  310. if(.@castle_check >= ((1 << .num_castles[.@k]) - 1)) {
  311. //includes all castles...just list as region.
  312. setd(".woe_state_str_" + .@i + "$[" + .@k + "]", .region_names$[.@k]);
  313.  
  314. //region warp menu string
  315. set .region_warp$[.@i], .region_warp$[.@i] + "^00DD00" + .region_names$[.@k] + "^000000:";
  316. } else {
  317. set .@j, 0;
  318. set .@output$, "";
  319. while(.@j < .num_castles[.@k]) {
  320. if(.@castle_check & (1 << .@j)) {
  321. set .@output$, .@output$ + GetCastleName(getd(.@castles$+"["+.@j+"]"));
  322. set .@castle_check, .@castle_check - (1 << .@j);
  323. if(.@castle_check) {
  324. if(.@output$ != "")
  325. set .@output$, .@output$ + ", ";
  326. } else
  327. break;
  328. }
  329. set .@j, .@j + 1;
  330. }
  331. setd(".woe_state_str_" + .@i + "$[" + .@k + "]", .region_names$[.@k] + " ("+ .@output$ + ")");
  332.  
  333. //region warp menu string
  334. set .region_warp$[.@i], .region_warp$[.@i] + "^00DD00" + .region_names$[.@k] + " ("+ .@output$ + ")^000000:";
  335. }
  336. }
  337. } else {
  338. set .region_warp$[.@i], .region_warp$[.@i] + ":";
  339. }
  340. }
  341. }
  342.  
  343. donpcevent strnpcinfo(3)+"::OnFindCurIndex";
  344. donpcevent strnpcinfo(3)+"::OnUpdateCountTick";
  345.  
  346. if(.active_woe) {
  347. if(.notify_woe) {
  348. //set mapflag for all castle maps
  349. for(set .@i, 0; .@i < .num_regions; set .@i, .@i + 1) {
  350. set .@region_array$, ".castles_" + .regions$[.@i] + "$";
  351. for(set .@k, 0; .@k < .num_castles[.@i]; set .@k, .@k + 1) {
  352. setmapflag getd(.@region_array$ + "[" + .@k + "]"), mf_loadevent;
  353. setd(".loadmap_region_" + getd(.@region_array$ + "[" + .@k + "]"), .@i + 1);
  354. setd(".loadmap_castleIndex_" + getd(.@region_array$ + "[" + .@k + "]"), .@k);
  355. }
  356. }
  357. }
  358. //activates WoE if needed
  359. donpcevent strnpcinfo(3)+"::OnDoWoE";
  360. }
  361. //flag that init occured
  362. set .init, 1;
  363.  
  364. OnWoETimer:
  365. //timer stuff
  366. while (1) {
  367. set .remainTime, .count_tick - gettimetick(2);
  368. set .bannerTimer, .remainTime - (.remainTime % .banner_refresh_rate) + .banner_refresh_rate;
  369. set .min, .bannerTimer / 60;
  370. set .sec, .bannerTimer - .min * 60;
  371. set .hr, .min / 60;
  372. set .min, .min - .hr * 60;
  373. set .roomMsg$, .waitMsg$[.state] + .hr + ":" + ((.min < 10 )?"0":"") + .min + ":" + ((.sec < 10 )?"0":"") + .sec;
  374. sleep .timer_refresh_rate;
  375.  
  376. if(.remainTime <= 0) {
  377. if(.active_woe) {
  378. donpcevent strnpcinfo(3)+"::OnDoWoE";
  379. }
  380. set .roomMsg$, .startMsg$[.state];
  381.  
  382. set .woe_index, (.woe_index + .state) % .num_woes; //go to next index if needed
  383. set .state, (.state + 1) % 2; //flip state
  384.  
  385. donpcevent strnpcinfo(3)+"::OnUpdateCountTick";
  386. sleep .change_state_sleep;
  387. }
  388. }
  389. end; //obligatory end =D
  390.  
  391. OnUpdateCountTick:
  392. set .count_tick, getd(".woe_" + .state + "[" + .woe_index + "]");
  393. set .count_tick, gettimetick(2) + .count_tick - gettimetick(1) + (.woe_day[.woe_index] - gettime(4) + 7) % 7 * .ticks_in_day;
  394.  
  395. if(gettimetick(2) > .count_tick)
  396. set .count_tick, .count_tick + 7 * .ticks_in_day;
  397. end;
  398.  
  399. OnFindCurIndex:
  400.  
  401. set .@cur_day, gettime(4);
  402. set .@cur_tick, gettimetick(1);
  403.  
  404. set .woe_index, 0;
  405. set .state, 0;
  406.  
  407. for(set .@i, 0; .@i < .num_woes; set .@i, .@i + 1) {
  408. if(.woe_day[.@i] < .@cur_day)
  409. continue;
  410.  
  411. if(.woe_day[.@i] == .@cur_day) {
  412. if(.woe_0[.@i] >= .@cur_tick) {
  413. set .woe_index, .@i;
  414. set .state, 0;
  415. break;
  416. }
  417. if(.woe_1[.@i] >= .@cur_tick) {
  418. set .woe_index, .@i;
  419. set .state, 1;
  420. break;
  421. }
  422. }
  423. if(.woe_day[.@i] > .@cur_day) {
  424. set .woe_index, .@i;
  425. set .state, 0;
  426. break;
  427. }
  428. }
  429. end;
  430.  
  431. //On map notifier
  432. //Comment out OnPCLoadMapEvent label if .notify_woe is disabled to prevent unnecessary triggering
  433. OnPCLoadMapEvent:
  434. if(.state && .notify_woe) {
  435. getmapxy(.@map$, .@x, .@y, 0);
  436. set .@region, getd(".loadmap_region_" + .@map$) - 1;
  437. if(.@region >= 0) {
  438. set .@castleIndex, getd(".loadmap_castleIndex_" + .@map$);
  439. if(getd(".woe_state_" + .woe_state[.woe_index] + "[" + .@region + "]") & 1 << .@castleIndex)
  440. dispbottom "The [" + GetCastleName(.@map$) + "] castle is available for conquering during this WoE session";
  441. else
  442. dispbottom "The [" + GetCastleName(.@map$) + "] castle is NOT available for conquering during this WoE session";
  443. }
  444. }
  445. end;
  446.  
  447. //------------------------------------------------------------------------------
  448. // WoE Controller Stuff Here
  449. //------------------------------------------------------------------------------
  450.  
  451. OnDoWoE:
  452. if((.state == 0 && .init) || (.state == 1 && !agitcheck())) { //starting
  453. callfunc "WoEToggler", 1;
  454.  
  455. //kills WoE in all castles that shouldn't have WoE
  456. set .@woe_state_array$, ".woe_state_" + .woe_state[.woe_index];
  457. for(set .@i, 0; .@i < .num_regions; set .@i, .@i + 1) {
  458. set .@castles$, ".castles_" + .regions$[.@i] + "$";
  459. set .@castle_check, getd(.@woe_state_array$ + "[" + .@i + "]");
  460.  
  461. for(set .@k, 0; .@k < .num_castles[.@i]; set .@k, .@k + 1) {
  462. set .@map$, getd(.@castles$+"["+.@k+"]");
  463. if((.@castle_check & (1 << .@k)) == 0) {
  464. donpcevent getd(".woe_kill_" + .regions$[.@i] + "$[" + .@k + "]");
  465. }
  466. }
  467. }
  468.  
  469. announce "The War Of Emperium has begun!",bc_all;
  470. donpcevent strnpcinfo(3)+"::OnDisplayOwners";
  471. } else { //ending
  472. if(agitcheck()) {
  473. callfunc "WoEToggler", 0;
  474. announce "The War Of Emperium is over!",bc_all;
  475. donpcevent strnpcinfo(3)+"::OnDisplayOwners";
  476. }
  477. }
  478. end;
  479.  
  480. OnDisplayOwners: //displays based on current region
  481. set .@woe_state_array$, ".woe_state_" + .woe_state[.woe_index];
  482. for(set .@i, 0; .@i < .num_regions; set .@i, .@i + 1) {
  483. set .@k, 0;
  484.  
  485. set .@castle_check, getd(.@woe_state_array$ + "[" + .@i + "]");
  486. set .@castles$, ".castles_" + .regions$[.@i] + "$";
  487.  
  488. while(.@castle_check && .@k < .num_castles[.@i]) {
  489. if(.@castle_check & (1 << .@k)) {
  490. set .@map$, getd(.@castles$+"["+.@k+"]");
  491. if (GetCastleData(.@map$,1)) {
  492. announce "The [" + GetCastleName(.@map$) + "] castle of the [" + .region_names$[.@i] + "] region is currently held by the [" + GetGuildName(GetCastleData(.@map$,1)) + "] guild.",bc_all;
  493. } else {
  494. announce "The [" + GetCastleName(.@map$) + "] castle of the [" + .region_names$[.@i] + "] region is currently unoccupied.",bc_all;
  495. }
  496. set .@castle_check, .@castle_check - (1 << .@k);
  497. }
  498. set .@k, .@k + 1;
  499. }
  500. }
  501. end;
  502. }
  503. prontera,157,198,4 script WoE Info 837,{
  504. if(getwaitingroomstate(3, strnpcinfo(3)) == -1)
  505. donpcevent strnpcinfo(3)+"::OnInit";
  506.  
  507. doevent "WoEInfoBase::OnStartMenu";
  508. end;
  509.  
  510. OnInit:
  511. while (1) {
  512. //only updates if msg is different
  513. set .banner$, getwaitingroomstate(4, strnpcinfo(3));
  514. if(getvariableofnpc(.roomMsg$, "WoEInfoBase") != .banner$) {
  515. delwaitingroom;
  516. waitingroom getvariableofnpc(.roomMsg$, "WoEInfoBase"), 0;
  517. }
  518. sleep 500;
  519. }
  520. end;
  521. }
  522.  
  523. //zomg! it duplicates!!
  524. lighthalzen,153,84,6 duplicate(WoE Info) WoE Info#3winfo 835
  525. moscovia,218,199,6 duplicate(WoE Info) WoE Info#4winfo 835
  526. rachel,129,119,6 duplicate(WoE Info) WoE Info#5winfo 835
  527. ayothaya,149,102,6 duplicate(WoE Info) WoE Info#6winfo 835
  528. hugel,89,151,6 duplicate(WoE Info) WoE Info#7winfo 835
  529. splendide,200,156,6 duplicate(WoE Info) WoE Info#8winfo 835
  530. izlude,127,120,6 duplicate(WoE Info) WoE Info#9winfo 835
  531. brasilis,199,226,3 duplicate(WoE Info) WoE Info#10winfo 835
  532. gonryun,159,125,3 duplicate(WoE Info) WoE Info#11winfo 835
  533. //---------------------------------------------------------------------------------------------------------------------
  534.  
  535.  
  536. function script WoEToggler { //<state> = 0|1
  537. if(getarg(0)) {
  538. AgitStart;
  539. } else {
  540. AgitEnd;
  541. }
  542. return;
  543. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement