Guest User

Untitled

a guest
Jul 20th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.24 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], 1;
  182. setarray .woe_0[0], 79200;
  183. setarray .woe_1[0], 82800;
  184. setarray .woe_state[0], 0;
  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],8,0,0,0,0,0,0;
  193.  
  194. //Setting for if script handles WoE controller function. Disable agit_controller.txt if you are using this.
  195. //For if you want to use something else to handle your woe stuff but only this script
  196. //to show info (1 - on, 0 - off...duh)
  197. set .active_woe, 1;
  198.  
  199.  
  200. //WoE inactive on map notifier. Basically notifies player if the castle they are entering is
  201. //WoE active or not
  202. set .notify_woe, 1;
  203.  
  204. //-----------------------------------------------------------------------------------------//
  205. //CONFIG END //
  206. //-----------------------------------------------------------------------------------------//
  207.  
  208.  
  209. //-----------------------------------------------------------------------------------------//
  210. //CONSTANTS START - Don't touch this unless you know what you are doing //
  211. //-----------------------------------------------------------------------------------------//
  212.  
  213. //castle maps by region
  214. setarray .castles_prtg$[0],"prtg_cas01","prtg_cas02","prtg_cas03","prtg_cas04","prtg_cas05";
  215. setarray .castles_payg$[0],"payg_cas01","payg_cas02","payg_cas03","payg_cas04","payg_cas05";
  216. setarray .castles_gefg$[0],"gefg_cas01","gefg_cas02","gefg_cas03","gefg_cas04","gefg_cas05";
  217. setarray .castles_aldeg$[0],"aldeg_cas01","aldeg_cas02","aldeg_cas03","aldeg_cas04","aldeg_cas05";
  218. setarray .castles_arug$[0],"arug_cas01","arug_cas02","arug_cas03","arug_cas04","arug_cas05";
  219. setarray .castles_schg$[0],"schg_cas01","schg_cas02","schg_cas03","schg_cas04","schg_cas05";
  220. setarray .castles_novi$[0],"nguild_alde","nguild_gef","nguild_pay","nguild_prt";
  221.  
  222. //woe kill functions for each castle
  223. 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";
  224. 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";
  225. 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";
  226. 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";
  227. setarray .woe_kill_arug$[0],"Manager#aru01_02::OnAgitEnd2","Manager#aru02_02::OnAgitEnd2","Manager#aru03_02::OnAgitEnd2","Manager#aru04_02::OnAgitEnd2","Manager#aru05_02::OnAgitEnd2";
  228. setarray .woe_kill_schg$[0],"Manager#sch01_02::OnAgitEnd2","Manager#sch02_02::OnAgitEnd2","Manager#sch03_02::OnAgitEnd2","Manager#sch04_02::OnAgitEnd2","Manager#sch05_02::OnAgitEnd2";
  229. setarray .woe_kill_novi$[0],"Agit_N01::OnAgitEnd","Agit_N02::OnAgitEnd","Agit_N03::OnAgitEnd","Agit_N04::OnAgitEnd";
  230.  
  231. //region prefixs
  232. setarray .regions$[0],"prtg","payg","gefg","aldeg","arug","schg","novi";
  233.  
  234. //region info
  235. setarray .region_names$[0],"Prontera", "Payon", "Geffen", "Aldebaran", "Arunafeltz", "Schwarzwald", "Novice Castles";
  236. setarray .region_maps$[0],"prt_gld", "pay_gld", "gef_fild13", "alde_gld", "aru_gld", "sch_gld", "prontera";
  237. //coords to warp player to region (0 is random)
  238. setarray .region_x[0],0, 0, 0, 0, 0, 0, 148;
  239. setarray .region_y[0],0, 0, 0, 0, 0, 0, 163;
  240.  
  241. setarray .waitMsg$[0], "WoE Starts: ", "WoE Ends: ";
  242. setarray .startMsg$[0], "WoE is Starting", "WoE is Ending";
  243.  
  244. set .ticks_in_day, 86400; //mmm...magic numbers
  245. setarray .daysOfWeek$[0], "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday";
  246.  
  247. set .timer_refresh_rate, 500; //how many ms per timer refresh...keep less than 1000 (in milliseconds)
  248. set .change_state_sleep, 3000; //how long to show "WoE is Start|End-ing" msg for in ms. (in milliseconds)
  249. //Make sure WoE sessions are longer than this xD
  250. set .banner_refresh_rate, 10; //how many seconds per banner refresh...keep 1 or above (in seconds)
  251.  
  252. //-----------------------------------------------------------------------------------------//
  253. //CONSTANTS END //
  254. //-----------------------------------------------------------------------------------------//
  255.  
  256. set .num_regions, getarraysize(.regions$);
  257. set .num_woes, getarraysize(.woe_1);
  258.  
  259. //force WoE to end if active
  260. callfunc "WoEToggler", 0;
  261.  
  262. for(set .@i, 0; .@i < .num_regions; set .@i, .@i + 1) {
  263. //count num castles per region
  264. set .num_castles[.@i], getarraysize(getd(".castles_" + .regions$[.@i] + "$"));
  265. }
  266.  
  267. //convert timestamps to readable format
  268. for(set .@i, 0; .@i < .num_woes; set .@i, .@i + 1)
  269. {
  270. set .@hrs, .woe_0[.@i] / 3600;
  271. set .@mins, .woe_0[.@i] % 3600 / 60;
  272. set .@output$, ((.@hrs % 12)?.@hrs%12:12) + ":" + ((.@mins < 10)?"0"+.@mins:.@mins) + " " + ((.@hrs > 12)?"PM":"AM");
  273.  
  274. set .woe_0_str$[.@i], .@output$;
  275.  
  276. set .@hrs, .woe_1[.@i] / 3600;
  277. set .@mins, .woe_1[.@i] % 3600 / 60;
  278. set .@output$, ((.@hrs % 12)?.@hrs%12:12) + ":" + ((.@mins < 10)?"0"+.@mins:.@mins) + " " + ((.@hrs > 12)?"PM":"AM");
  279.  
  280. set .woe_1_str$[.@i], .@output$;
  281. }
  282.  
  283. //calc number of woe states and consolidate states to create list of castles used
  284. set .num_states, 0;
  285. while(getarraysize(getd(".woe_state_" + (.num_states)))) {
  286. set .@state$, ".woe_state_" + .num_states;
  287. set .@i, 0;
  288. while(.@i < getarraysize(getd(.@state$))) {
  289. set .castleUsage[.@i], .castleUsage[.@i] | getd(.@state$ + "[" + .@i + "]");
  290. set .@i, .@i + 1;
  291. }
  292. set .num_states, .num_states + 1;
  293. }
  294.  
  295. for(set .@i, 0; .@i < .num_states; set .@i, .@i + 1) {
  296. set .@woe_state_array$, ".woe_state_" + .@i;
  297. for(set .@k, 0; .@k < .num_regions; set .@k, .@k + 1) {
  298. if(.castleUsage[.@k] > 0) {
  299. set .@castles$, ".castles_" + .regions$[.@k] + "$";
  300. set .@castle_check, getd(.@woe_state_array$ + "[" + .@k + "]");
  301. if(.@castle_check == 0) { //region not in this state
  302. //region warp menu string
  303. set .region_warp$[.@i], .region_warp$[.@i] + "^DD0000" + .region_names$[.@k] + "^000000:";
  304. continue;
  305. } else {
  306. if(.@castle_check >= ((1 << .num_castles[.@k]) - 1)) {
  307. //includes all castles...just list as region.
  308. setd(".woe_state_str_" + .@i + "$[" + .@k + "]", .region_names$[.@k]);
  309.  
  310. //region warp menu string
  311. set .region_warp$[.@i], .region_warp$[.@i] + "^00DD00" + .region_names$[.@k] + "^000000:";
  312. } else {
  313. set .@j, 0;
  314. set .@output$, "";
  315. while(.@j < .num_castles[.@k]) {
  316. if(.@castle_check & (1 << .@j)) {
  317. set .@output$, .@output$ + GetCastleName(getd(.@castles$+"["+.@j+"]"));
  318. set .@castle_check, .@castle_check - (1 << .@j);
  319. if(.@castle_check) {
  320. if(.@output$ != "")
  321. set .@output$, .@output$ + ", ";
  322. } else
  323. break;
  324. }
  325. set .@j, .@j + 1;
  326. }
  327. setd(".woe_state_str_" + .@i + "$[" + .@k + "]", .region_names$[.@k] + " ("+ .@output$ + ")");
  328.  
  329. //region warp menu string
  330. set .region_warp$[.@i], .region_warp$[.@i] + "^00DD00" + .region_names$[.@k] + " ("+ .@output$ + ")^000000:";
  331. }
  332. }
  333. } else {
  334. set .region_warp$[.@i], .region_warp$[.@i] + ":";
  335. }
  336. }
  337. }
  338.  
  339. donpcevent strnpcinfo(3)+"::OnFindCurIndex";
  340. donpcevent strnpcinfo(3)+"::OnUpdateCountTick";
  341.  
  342. if(.active_woe) {
  343. if(.notify_woe) {
  344. //set mapflag for all castle maps
  345. for(set .@i, 0; .@i < .num_regions; set .@i, .@i + 1) {
  346. set .@region_array$, ".castles_" + .regions$[.@i] + "$";
  347. for(set .@k, 0; .@k < .num_castles[.@i]; set .@k, .@k + 1) {
  348. setmapflag getd(.@region_array$ + "[" + .@k + "]"), mf_loadevent;
  349. setd(".loadmap_region_" + getd(.@region_array$ + "[" + .@k + "]"), .@i + 1);
  350. setd(".loadmap_castleIndex_" + getd(.@region_array$ + "[" + .@k + "]"), .@k);
  351. }
  352. }
  353. }
  354. //activates WoE if needed
  355. donpcevent strnpcinfo(3)+"::OnDoWoE";
  356. }
  357. //flag that init occured
  358. set .init, 1;
  359.  
  360. OnWoETimer:
  361. //timer stuff
  362. while (1) {
  363. set .remainTime, .count_tick - gettimetick(2);
  364. set .bannerTimer, .remainTime - (.remainTime % .banner_refresh_rate) + .banner_refresh_rate;
  365. set .min, .bannerTimer / 60;
  366. set .sec, .bannerTimer - .min * 60;
  367. set .hr, .min / 60;
  368. set .min, .min - .hr * 60;
  369. set .roomMsg$, .waitMsg$[.state] + .hr + ":" + ((.min < 10 )?"0":"") + .min + ":" + ((.sec < 10 )?"0":"") + .sec;
  370. sleep .timer_refresh_rate;
  371.  
  372. if(.remainTime <= 0) {
  373. if(.active_woe) {
  374. donpcevent strnpcinfo(3)+"::OnDoWoE";
  375. }
  376. set .roomMsg$, .startMsg$[.state];
  377.  
  378. set .woe_index, (.woe_index + .state) % .num_woes; //go to next index if needed
  379. set .state, (.state + 1) % 2; //flip state
  380.  
  381. donpcevent strnpcinfo(3)+"::OnUpdateCountTick";
  382. sleep .change_state_sleep;
  383. }
  384. }
  385. end; //obligatory end =D
  386.  
  387. OnUpdateCountTick:
  388. set .count_tick, getd(".woe_" + .state + "[" + .woe_index + "]");
  389. set .count_tick, gettimetick(2) + .count_tick - gettimetick(1) + (.woe_day[.woe_index] - gettime(4) + 7) % 7 * .ticks_in_day;
  390.  
  391. if(gettimetick(2) > .count_tick)
  392. set .count_tick, .count_tick + 7 * .ticks_in_day;
  393. end;
  394.  
  395. OnFindCurIndex:
  396.  
  397. set .@cur_day, gettime(4);
  398. set .@cur_tick, gettimetick(1);
  399.  
  400. set .woe_index, 0;
  401. set .state, 0;
  402.  
  403. for(set .@i, 0; .@i < .num_woes; set .@i, .@i + 1) {
  404. if(.woe_day[.@i] < .@cur_day)
  405. continue;
  406.  
  407. if(.woe_day[.@i] == .@cur_day) {
  408. if(.woe_0[.@i] >= .@cur_tick) {
  409. set .woe_index, .@i;
  410. set .state, 0;
  411. break;
  412. }
  413. if(.woe_1[.@i] >= .@cur_tick) {
  414. set .woe_index, .@i;
  415. set .state, 1;
  416. break;
  417. }
  418. }
  419. if(.woe_day[.@i] > .@cur_day) {
  420. set .woe_index, .@i;
  421. set .state, 0;
  422. break;
  423. }
  424. }
  425. end;
  426.  
  427. //On map notifier
  428. //Comment out OnPCLoadMapEvent label if .notify_woe is disabled to prevent unnecessary triggering
  429. OnPCLoadMapEvent:
  430. if(.state && .notify_woe) {
  431. getmapxy(.@map$, .@x, .@y, 0);
  432. set .@region, getd(".loadmap_region_" + .@map$) - 1;
  433. if(.@region >= 0) {
  434. set .@castleIndex, getd(".loadmap_castleIndex_" + .@map$);
  435. if(getd(".woe_state_" + .woe_state[.woe_index] + "[" + .@region + "]") & 1 << .@castleIndex)
  436. dispbottom "The [" + GetCastleName(.@map$) + "] castle is available for conquering during this WoE session";
  437. else
  438. dispbottom "The [" + GetCastleName(.@map$) + "] castle is NOT available for conquering during this WoE session";
  439. }
  440. }
  441. end;
  442.  
  443. //------------------------------------------------------------------------------
  444. // WoE Controller Stuff Here
  445. //------------------------------------------------------------------------------
  446.  
  447. OnDoWoE:
  448. if((.state == 0 && .init) || (.state == 1 && !agitcheck())) { //starting
  449. callfunc "WoEToggler", 1;
  450.  
  451. //kills WoE in all castles that shouldn't have WoE
  452. set .@woe_state_array$, ".woe_state_" + .woe_state[.woe_index];
  453. for(set .@i, 0; .@i < .num_regions; set .@i, .@i + 1) {
  454. set .@castles$, ".castles_" + .regions$[.@i] + "$";
  455. set .@castle_check, getd(.@woe_state_array$ + "[" + .@i + "]");
  456.  
  457. for(set .@k, 0; .@k < .num_castles[.@i]; set .@k, .@k + 1) {
  458. set .@map$, getd(.@castles$+"["+.@k+"]");
  459. if((.@castle_check & (1 << .@k)) == 0) {
  460. donpcevent getd(".woe_kill_" + .regions$[.@i] + "$[" + .@k + "]");
  461. }
  462. }
  463. }
  464.  
  465. announce "The War Of Emperium has begun!",bc_all;
  466. donpcevent strnpcinfo(3)+"::OnDisplayOwners";
  467. } else { //ending
  468. if(agitcheck()) {
  469. callfunc "WoEToggler", 0;
  470. announce "The War Of Emperium is over!",bc_all;
  471. donpcevent strnpcinfo(3)+"::OnDisplayOwners";
  472. }
  473. }
  474. end;
  475.  
  476. OnDisplayOwners: //displays based on current region
  477. set .@woe_state_array$, ".woe_state_" + .woe_state[.woe_index];
  478. for(set .@i, 0; .@i < .num_regions; set .@i, .@i + 1) {
  479. set .@k, 0;
  480.  
  481. set .@castle_check, getd(.@woe_state_array$ + "[" + .@i + "]");
  482. set .@castles$, ".castles_" + .regions$[.@i] + "$";
  483.  
  484. while(.@castle_check && .@k < .num_castles[.@i]) {
  485. if(.@castle_check & (1 << .@k)) {
  486. set .@map$, getd(.@castles$+"["+.@k+"]");
  487. if (GetCastleData(.@map$,1)) {
  488. announce "The [" + GetCastleName(.@map$) + "] castle of the [" + .region_names$[.@i] + "] region is currently held by the [" + GetGuildName(GetCastleData(.@map$,1)) + "] guild.",bc_all;
  489. } else {
  490. announce "The [" + GetCastleName(.@map$) + "] castle of the [" + .region_names$[.@i] + "] region is currently unoccupied.",bc_all;
  491. }
  492. set .@castle_check, .@castle_check - (1 << .@k);
  493. }
  494. set .@k, .@k + 1;
  495. }
  496. }
  497. end;
  498. }
  499. prontera,163,194,4 script WoE Info 837,{
  500. if(getwaitingroomstate(3, strnpcinfo(3)) == -1)
  501. donpcevent strnpcinfo(3)+"::OnInit";
  502.  
  503. doevent "WoEInfoBase::OnStartMenu";
  504. end;
  505.  
  506. OnInit:
  507. while (1) {
  508. //only updates if msg is different
  509. set .banner$, getwaitingroomstate(4, strnpcinfo(3));
  510. if(getvariableofnpc(.roomMsg$, "WoEInfoBase") != .banner$) {
  511. delwaitingroom;
  512. waitingroom getvariableofnpc(.roomMsg$, "WoEInfoBase"), 0;
  513. }
  514. sleep 500;
  515. }
  516. end;
  517. }
  518.  
  519. //zomg! it duplicates!!
  520. prontera,156,196,6 duplicate(WoE Info) WoE Info#2winfo 837
  521.  
  522. //---------------------------------------------------------------------------------------------------------------------
  523.  
  524. //These two functions handle WoE's activation/deactivation. Since stable does not have AgitStart2/AgitEnd2,
  525. //using the trunk version will result in catastrophic failure of the script. Double declaration of the following
  526. //functions fixes this (you will get warning messages though)
  527.  
  528. function script WoEToggler { //<state> = 0|1
  529. if(getarg(0)) {
  530. AgitStart;
  531. } else {
  532. AgitEnd;
  533. }
  534. return;
  535. }
  536.  
  537. //if stable script will fail parsing this function, but the rest of the script will still be usable
  538. function script WoEToggler { //<state> = 0|1
  539. if(getarg(0)) {
  540. AgitStart;
  541. AgitStart2;
  542. } else {
  543. AgitEnd;
  544. AgitEnd2;
  545. }
  546. return;
  547. }
Add Comment
Please, Sign In to add comment