Advertisement
Guest User

Untitled

a guest
Jul 28th, 2013
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.78 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 "A " + ((.state)?"^00DD00guerra atual":"^DD0000próxima guerra") + "^000000 será: ";
  66. mes " ";
  67. mes "Dia: ^0000DD" + .daysOfWeek$[.woe_day[.woe_index]];
  68. mes "^000000Começa às: ^00DD00" + .woe_0_str$[.woe_index];
  69. mes "^000000Termina às: ^DD0000" + .woe_1_str$[.woe_index];
  70. mes "^000000Castelo(s):";
  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. "- Teleportar para o feudo do castelo",
  83. "- Ver os donos dos castelos",
  84. "- Ver todos horários de guerra",
  85. ((!.state)?"- Começar a Guerra Autal":"- Terminar a Guerra Atual"),
  86. ((.state)?"":"- Pular para próxima Guerra")
  87. );
  88. else
  89. select(
  90. "- Teleportar para o feudo do castelo",
  91. "- Ver os donos dos castelos",
  92. "- Ver todos horários de guerra");
  93.  
  94. switch(@menu) {
  95. case 1: //warp
  96. mes "Qual local que você gostaria de ir?";
  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 "O castelo [" + GetCastleName(.@map$) + "] do feudo de [" + .region_names$[.@i] + "] é do clã [" + GetGuildName(GetCastleData(.@map$,1)) + "].";
  116. } else {
  117. dispbottom "O castelo [" + GetCastleName(.@map$) + "] do feudo de [" + .region_names$[.@i] + "] está desocupado.";
  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 "^FF0000Você tem certeza que quer " + ((!.state)?"iniciar a guerra atual?":"terminar a guerra autal?");
  140. next;
  141. if(select("- Sim:- Não") == 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 "^FF0000Você tem certeza que quer pular para próxima guerra?^000000";
  150. next;
  151. if(select("- Sim:- Não") == 2) break;
  152. if(.state) { //you really can't do this with woe active
  153. next;
  154. mes "Desculpe, no momento que você teve de fazer sua decisão, a guerra atual começou.";
  155. mes "Por favor, faça o processo manualmente ou espere o final da guerra.";
  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, 4;
  182. setarray .woe_0[0], 64800,68400;
  183. setarray .woe_1[0], 72000,75600;
  184. setarray .woe_state[0], 0, 1;
  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,1,0;
  193. setarray .woe_state_1[0],1,0,0,0,0,0,0;
  194.  
  195. //Setting for if script handles WoE controller function. Disable agit_controller.txt if you are using this.
  196. //For if you want to use something else to handle your woe stuff but only this script
  197. //to show info (1 - on, 0 - off...duh)
  198. set .active_woe, 1;
  199.  
  200.  
  201. //WoE inactive on map notifier. Basically notifies player if the castle they are entering is
  202. //WoE active or not
  203. set .notify_woe, 1;
  204.  
  205. //-----------------------------------------------------------------------------------------//
  206. //CONFIG END //
  207. //-----------------------------------------------------------------------------------------//
  208.  
  209.  
  210. //-----------------------------------------------------------------------------------------//
  211. //CONSTANTS START - Don't touch this unless you know what you are doing //
  212. //-----------------------------------------------------------------------------------------//
  213.  
  214. //castle maps by region
  215. setarray .castles_prtg$[0],"prtg_cas01","prtg_cas02","prtg_cas03","prtg_cas04","prtg_cas05";
  216. setarray .castles_payg$[0],"payg_cas01","payg_cas02","payg_cas03","payg_cas04","payg_cas05";
  217. setarray .castles_gefg$[0],"gefg_cas01","gefg_cas02","gefg_cas03","gefg_cas04","gefg_cas05";
  218. setarray .castles_aldeg$[0],"aldeg_cas01","aldeg_cas02","aldeg_cas03","aldeg_cas04","aldeg_cas05";
  219. setarray .castles_arug$[0],"arug_cas01","arug_cas02","arug_cas03","arug_cas04","arug_cas05";
  220. setarray .castles_schg$[0],"schg_cas01","schg_cas02","schg_cas03","schg_cas04","schg_cas05";
  221. //setarray .castles_novi$[0],"nguild_alde","nguild_gef","nguild_pay","nguild_prt";
  222.  
  223. //woe kill functions for each castle
  224. 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";
  225. 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";
  226. 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";
  227. 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";
  228. 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";
  229. 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";
  230. //setarray .woe_kill_novi$[0],"Agit_N01::OnAgitEnd","Agit_N02::OnAgitEnd","Agit_N03::OnAgitEnd","Agit_N04::OnAgitEnd";
  231.  
  232. //region prefixs
  233. setarray .regions$[0],"prtg","payg","gefg","aldeg","arug","schg","novi";
  234.  
  235. //region info
  236. setarray .region_names$[0],"Prontera", "Payon", "Geffen", "Aldebaran", "Arunafeltz", "Schwarzwald"; //"Novice Castles";
  237. setarray .region_maps$[0],"prt_gld", "pay_gld", "gef_fild13", "alde_gld", "aru_gld", "sch_gld"; //"prontera";
  238. //coords to warp player to region (0 is random)
  239. setarray .region_x[0],0, 0, 0, 0, 0, 0, 148;
  240. setarray .region_y[0],0, 0, 0, 0, 0, 0, 163;
  241.  
  242. setarray .waitMsg$[0], "Início da Guerra: ", "Final da Guerra: ";
  243. setarray .startMsg$[0], "A Guerra Atual está começando!", "A Guerra Atual está acabando!";
  244.  
  245. set .ticks_in_day, 86400; //mmm...magic numbers
  246. setarray .daysOfWeek$[0], "Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado";
  247.  
  248. set .timer_refresh_rate, 500; //how many ms per timer refresh...keep less than 1000 (in milliseconds)
  249. set .change_state_sleep, 3000; //how long to show "WoE is Start|End-ing" msg for in ms. (in milliseconds)
  250. //Make sure WoE sessions are longer than this xD
  251. set .banner_refresh_rate, 10; //how many seconds per banner refresh...keep 1 or above (in seconds)
  252.  
  253. //-----------------------------------------------------------------------------------------//
  254. //CONSTANTS END //
  255. //-----------------------------------------------------------------------------------------//
  256.  
  257. set .num_regions, getarraysize(.regions$);
  258. set .num_woes, getarraysize(.woe_1);
  259.  
  260. //force WoE to end if active
  261. callfunc "WoEToggler", 0;
  262.  
  263. for(set .@i, 0; .@i < .num_regions; set .@i, .@i + 1) {
  264. //count num castles per region
  265. set .num_castles[.@i], getarraysize(getd(".castles_" + .regions$[.@i] + "$"));
  266. }
  267.  
  268. //convert timestamps to readable format
  269. for(set .@i, 0; .@i < .num_woes; set .@i, .@i + 1)
  270. {
  271. set .@hrs, .woe_0[.@i] / 3600;
  272. set .@mins, .woe_0[.@i] % 3600 / 60;
  273. set .@output$, ((.@hrs % 12)?.@hrs%12:12) + ":" + ((.@mins < 10)?"0"+.@mins:.@mins) + " " + ((.@hrs > 12)?"PM":"AM");
  274.  
  275. set .woe_0_str$[.@i], .@output$;
  276.  
  277. set .@hrs, .woe_1[.@i] / 3600;
  278. set .@mins, .woe_1[.@i] % 3600 / 60;
  279. set .@output$, ((.@hrs % 12)?.@hrs%12:12) + ":" + ((.@mins < 10)?"0"+.@mins:.@mins) + " " + ((.@hrs > 12)?"PM":"AM");
  280.  
  281. set .woe_1_str$[.@i], .@output$;
  282. }
  283.  
  284. //calc number of woe states and consolidate states to create list of castles used
  285. set .num_states, 0;
  286. while(getarraysize(getd(".woe_state_" + (.num_states)))) {
  287. set .@state$, ".woe_state_" + .num_states;
  288. set .@i, 0;
  289. while(.@i < getarraysize(getd(.@state$))) {
  290. set .castleUsage[.@i], .castleUsage[.@i] | getd(.@state$ + "[" + .@i + "]");
  291. set .@i, .@i + 1;
  292. }
  293. set .num_states, .num_states + 1;
  294. }
  295.  
  296. for(set .@i, 0; .@i < .num_states; set .@i, .@i + 1) {
  297. set .@woe_state_array$, ".woe_state_" + .@i;
  298. for(set .@k, 0; .@k < .num_regions; set .@k, .@k + 1) {
  299. if(.castleUsage[.@k] > 0) {
  300. set .@castles$, ".castles_" + .regions$[.@k] + "$";
  301. set .@castle_check, getd(.@woe_state_array$ + "[" + .@k + "]");
  302. if(.@castle_check == 0) { //region not in this state
  303. //region warp menu string
  304. set .region_warp$[.@i], .region_warp$[.@i] + "^DD0000" + .region_names$[.@k] + "^000000:";
  305. continue;
  306. } else {
  307. if(.@castle_check >= ((1 << .num_castles[.@k]) - 1)) {
  308. //includes all castles...just list as region.
  309. setd(".woe_state_str_" + .@i + "$[" + .@k + "]", .region_names$[.@k]);
  310.  
  311. //region warp menu string
  312. set .region_warp$[.@i], .region_warp$[.@i] + "^00DD00" + .region_names$[.@k] + "^000000:";
  313. } else {
  314. set .@j, 0;
  315. set .@output$, "";
  316. while(.@j < .num_castles[.@k]) {
  317. if(.@castle_check & (1 << .@j)) {
  318. set .@output$, .@output$ + GetCastleName(getd(.@castles$+"["+.@j+"]"));
  319. set .@castle_check, .@castle_check - (1 << .@j);
  320. if(.@castle_check) {
  321. if(.@output$ != "")
  322. set .@output$, .@output$ + ", ";
  323. } else
  324. break;
  325. }
  326. set .@j, .@j + 1;
  327. }
  328. setd(".woe_state_str_" + .@i + "$[" + .@k + "]", .region_names$[.@k] + " ("+ .@output$ + ")");
  329.  
  330. //region warp menu string
  331. set .region_warp$[.@i], .region_warp$[.@i] + "^00DD00" + .region_names$[.@k] + " ("+ .@output$ + ")^000000:";
  332. }
  333. }
  334. } else {
  335. set .region_warp$[.@i], .region_warp$[.@i] + ":";
  336. }
  337. }
  338. }
  339.  
  340. donpcevent strnpcinfo(3)+"::OnFindCurIndex";
  341. donpcevent strnpcinfo(3)+"::OnUpdateCountTick";
  342.  
  343. if(.active_woe) {
  344. if(.notify_woe) {
  345. //set mapflag for all castle maps
  346. for(set .@i, 0; .@i < .num_regions; set .@i, .@i + 1) {
  347. set .@region_array$, ".castles_" + .regions$[.@i] + "$";
  348. for(set .@k, 0; .@k < .num_castles[.@i]; set .@k, .@k + 1) {
  349. setmapflag getd(.@region_array$ + "[" + .@k + "]"), mf_loadevent;
  350. setd(".loadmap_region_" + getd(.@region_array$ + "[" + .@k + "]"), .@i + 1);
  351. setd(".loadmap_castleIndex_" + getd(.@region_array$ + "[" + .@k + "]"), .@k);
  352. }
  353. }
  354. }
  355. //activates WoE if needed
  356. donpcevent strnpcinfo(3)+"::OnDoWoE";
  357. }
  358. //flag that init occured
  359. set .init, 1;
  360.  
  361. OnWoETimer:
  362. //timer stuff
  363. while (1) {
  364. set .remainTime, .count_tick - gettimetick(2);
  365. set .bannerTimer, .remainTime - (.remainTime % .banner_refresh_rate) + .banner_refresh_rate;
  366. set .min, .bannerTimer / 60;
  367. set .sec, .bannerTimer - .min * 60;
  368. set .hr, .min / 60;
  369. set .min, .min - .hr * 60;
  370. set .roomMsg$, .waitMsg$[.state] + .hr + ":" + ((.min < 10 )?"0":"") + .min + ":" + ((.sec < 10 )?"0":"") + .sec;
  371. sleep .timer_refresh_rate;
  372.  
  373. if(.remainTime <= 0) {
  374. if(.active_woe) {
  375. donpcevent strnpcinfo(3)+"::OnDoWoE";
  376. }
  377. set .roomMsg$, .startMsg$[.state];
  378.  
  379. set .woe_index, (.woe_index + .state) % .num_woes; //go to next index if needed
  380. set .state, (.state + 1) % 2; //flip state
  381.  
  382. donpcevent strnpcinfo(3)+"::OnUpdateCountTick";
  383. sleep .change_state_sleep;
  384. }
  385. }
  386. end; //obligatory end =D
  387.  
  388. OnUpdateCountTick:
  389. set .count_tick, getd(".woe_" + .state + "[" + .woe_index + "]");
  390. set .count_tick, gettimetick(2) + .count_tick - gettimetick(1) + (.woe_day[.woe_index] - gettime(4) + 7) % 7 * .ticks_in_day;
  391.  
  392. if(gettimetick(2) > .count_tick)
  393. set .count_tick, .count_tick + 7 * .ticks_in_day;
  394. end;
  395.  
  396. OnFindCurIndex:
  397.  
  398. set .@cur_day, gettime(4);
  399. set .@cur_tick, gettimetick(1);
  400.  
  401. set .woe_index, 0;
  402. set .state, 0;
  403.  
  404. for(set .@i, 0; .@i < .num_woes; set .@i, .@i + 1) {
  405. if(.woe_day[.@i] < .@cur_day)
  406. continue;
  407.  
  408. if(.woe_day[.@i] == .@cur_day) {
  409. if(.woe_0[.@i] >= .@cur_tick) {
  410. set .woe_index, .@i;
  411. set .state, 0;
  412. break;
  413. }
  414. if(.woe_1[.@i] >= .@cur_tick) {
  415. set .woe_index, .@i;
  416. set .state, 1;
  417. break;
  418. }
  419. }
  420. if(.woe_day[.@i] > .@cur_day) {
  421. set .woe_index, .@i;
  422. set .state, 0;
  423. break;
  424. }
  425. }
  426. end;
  427.  
  428. //On map notifier
  429. //Comment out OnPCLoadMapEvent label if .notify_woe is disabled to prevent unnecessary triggering
  430. OnPCLoadMapEvent:
  431. if(.state && .notify_woe) {
  432. getmapxy(.@map$, .@x, .@y, 0);
  433. set .@region, getd(".loadmap_region_" + .@map$) - 1;
  434. if(.@region >= 0) {
  435. set .@castleIndex, getd(".loadmap_castleIndex_" + .@map$);
  436. if(getd(".woe_state_" + .woe_state[.woe_index] + "[" + .@region + "]") & 1 << .@castleIndex)
  437. dispbottom "O castelo [" + GetCastleName(.@map$) + "] está disponível para conquista durante esta guerra.";
  438. else {
  439. dispbottom "O castelo [" + GetCastleName(.@map$) + "] NÃO está disponível para conquista durante esta guerra.";
  440. warp "prontera", 150, 150;
  441. }
  442. }
  443. }
  444. end;
  445.  
  446. //------------------------------------------------------------------------------
  447. // WoE Controller Stuff Here
  448. //------------------------------------------------------------------------------
  449.  
  450. OnDoWoE:
  451. if((.state == 0 && .init) || (.state == 1 && !agitcheck())) { //starting
  452. callfunc "WoEToggler", 1;
  453.  
  454. //kills WoE in all castles that shouldn't have WoE
  455. set .@woe_state_array$, ".woe_state_" + .woe_state[.woe_index];
  456. for(set .@i, 0; .@i < .num_regions; set .@i, .@i + 1) {
  457. set .@castles$, ".castles_" + .regions$[.@i] + "$";
  458. set .@castle_check, getd(.@woe_state_array$ + "[" + .@i + "]");
  459.  
  460. for(set .@k, 0; .@k < .num_castles[.@i]; set .@k, .@k + 1) {
  461. set .@map$, getd(.@castles$+"["+.@k+"]");
  462. if((.@castle_check & (1 << .@k)) == 0) {
  463. donpcevent getd(".woe_kill_" + .regions$[.@i] + "$[" + .@k + "]");
  464. }
  465. }
  466. }
  467.  
  468. announce "A Guerra do Emperium COMEÇOU!",8;
  469. donpcevent strnpcinfo(3)+"::OnDisplayOwners";
  470. } else { //ending
  471. if(agitcheck()) {
  472. callfunc "WoEToggler", 0;
  473. announce "A Guerra do Emperium TERMINOU!",8;
  474. donpcevent strnpcinfo(3)+"::OnDisplayOwners";
  475. }
  476. }
  477. end;
  478.  
  479. OnDisplayOwners: //displays based on current region
  480. set .@woe_state_array$, ".woe_state_" + .woe_state[.woe_index];
  481. for(set .@i, 0; .@i < .num_regions; set .@i, .@i + 1) {
  482. set .@k, 0;
  483.  
  484. set .@castle_check, getd(.@woe_state_array$ + "[" + .@i + "]");
  485. set .@castles$, ".castles_" + .regions$[.@i] + "$";
  486.  
  487. while(.@castle_check && .@k < .num_castles[.@i]) {
  488. if(.@castle_check & (1 << .@k)) {
  489. set .@map$, getd(.@castles$+"["+.@k+"]");
  490. if (GetCastleData(.@map$,1)) {
  491. announce "O castelo [" + GetCastleName(.@map$) + "] foi conquistado pelo clã [" + GetGuildName(GetCastleData(.@map$,1)) + "].",8;
  492. } else {
  493. announce "O castelo [" + GetCastleName(.@map$) + "] do feudo de [" + .region_names$[.@i] + "] está desocupado.",8;
  494. }
  495. set .@castle_check, .@castle_check - (1 << .@k);
  496. }
  497. set .@k, .@k + 1;
  498. }
  499. }
  500. end;
  501. }
  502. prontera,148,174,5 script WoE Info 837,{
  503. if(getwaitingroomstate(3, strnpcinfo(3)) == -1)
  504. donpcevent strnpcinfo(3)+"::OnInit";
  505.  
  506. doevent "WoEInfoBase::OnStartMenu";
  507. end;
  508.  
  509. OnInit:
  510. while (1) {
  511. //only updates if msg is different
  512. set .banner$, getwaitingroomstate(4, strnpcinfo(3));
  513. if(getvariableofnpc(.roomMsg$, "WoEInfoBase") != .banner$) {
  514. delwaitingroom;
  515. waitingroom getvariableofnpc(.roomMsg$, "WoEInfoBase"), 0;
  516. }
  517. sleep 500;
  518. }
  519. end;
  520. }
  521.  
  522. //zomg! it duplicates!!
  523. que_temsky,37,139,5 duplicate(WoE Info) WoE Info#2winfo 837
  524.  
  525. //---------------------------------------------------------------------------------------------------------------------
  526.  
  527. //These two functions handle WoE's activation/deactivation. Since stable does not have AgitStart2/AgitEnd2,
  528. //using the trunk version will result in catastrophic failure of the script. Double declaration of the following
  529. //functions fixes this (you will get warning messages though)
  530.  
  531. function script WoEToggler { //<state> = 0|1
  532. if(getarg(0)) {
  533. AgitStart;
  534. AgitStart2;
  535. } else {
  536. AgitEnd;
  537. AgitEnd2;
  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