Advertisement
Guest User

Untitled

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