Advertisement
akbare

Euphy's WOE Controller

Dec 9th, 2012
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.76 KB | None | 0 0
  1. //===== rAthena Script =======================================
  2. //= Euphy's WOE Controller
  3. //===== By: ==================================================
  4. //= Euphy
  5. //===== Current Version: =====================================
  6. //= 1.4
  7. //===== Compatible With: =====================================
  8. //= rAthena SVN r16571+
  9. //===== Description: =========================================
  10. //= A controller for War of Emperium designed for
  11. //= simplicity and ease of use.
  12. //= Many concepts taken from ToastOfDoom's script,
  13. //= and "rewards" function originally by Goddameit.
  14. //===== Additional Comments: =================================
  15. //= Be sure to disable the default agit controllers!
  16. //== npc\guild\agit_controller.txt
  17. //== npc\guild2\agit_start_se.txt
  18. //============================================================
  19.  
  20. prontera,137,222,4 script WOE Information 835,{ doevent "WOE_CONTROL::OnMenu"; end; OnAgitStart: while(agitcheck()) { misceffect 58; sleep 425; } end; }
  21.  
  22. - script WOE_CONTROL -1,{
  23. function Disp_Owner; function Add_Zero;
  24.  
  25. OnInit:
  26. // --------------------------------------------------------------------------------------------------------------------------
  27.  
  28. set .CastleWarp,0; // 1: Always enable all castle warps. | 0: Warp only to active castles.
  29. set .AutoKick,1; // Automatically kick players from inactive castles during WOE? (1:yes / 0:no)
  30. set .NoOwner,0; // Automatically kick players from unconquered castles outside of WOE? (1:yes / 0:no)
  31. set .ExitWarp,0; // Warp all players from castles when WOE ends? (1:yes / 0:no)
  32. set .GMAccess,99; // GM level required to access Session Manager.
  33. setarray .Reward[0],14001,1; // Reward for all members of conquering guilds, per castle: <ID>,<Count>{,...} (0 to disable)
  34.  
  35. // --------------------------------------------------------------------------------------------------------------------------
  36. set .Size, getarraysize($WOE_CONTROL);
  37. setarray .Castles$[0],
  38. "prtg_cas01","prtg_cas02","prtg_cas03","prtg_cas04","prtg_cas05",
  39. "payg_cas01","payg_cas02","payg_cas03","payg_cas04","payg_cas05",
  40. "gefg_cas01","gefg_cas02","gefg_cas03","gefg_cas04","gefg_cas05",
  41. "aldeg_cas01","aldeg_cas02","aldeg_cas03","aldeg_cas04","aldeg_cas05",
  42. "arug_cas01","arug_cas02","arug_cas03","arug_cas04","arug_cas05",
  43. "schg_cas01","schg_cas02","schg_cas03","schg_cas04","schg_cas05";
  44. setarray .EndLabel$[0],"ar01","ar02","ar03","ar04","ar05","sc01","sc02","sc03","sc04","sc05";
  45. setarray .Days$[0],"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday";
  46. setarray .Regions$[0],"Prontera","Payon","Geffen","Aldebaran","Arunafeltz","Schwaltzvalt";
  47. setarray .Map$[0],"prt_gld","pay_gld","gef_fild13","alde_gld","aru_gld","sch_gld";
  48. setarray .MapX[0],134,240,153,111,208,121,295,317,140,204,214,308,143,193,305,48, 95,142,239,264,158,83, 68,299,292,293,288, 97,137, 71;
  49. setarray .MapY[0], 65,128,137,240,240,233,116,293,160,266, 75,240,240,278, 87,83,249, 85,242, 90,272,47,155,345,107,100,252,196, 90,315;
  50. if (.AutoKick || .NoOwner) for(set .@i,0; .@i<30; set .@i,.@i+1) {
  51. setmapflag .Castles$[.@i], mf_loadevent;
  52. setd "."+.Castles$[.@i], .@i;
  53. }
  54. if (!agitcheck() && !agitcheck2()) sleep 4000;
  55. set .Init,1;
  56. OnMinute00:
  57. freeloop(1);
  58. if (agitcheck() || agitcheck2()) {
  59. for(set .@i,0; .@i<.Size; set .@i,.@i+4)
  60. if (gettime(4) == $WOE_CONTROL[.@i] && gettime(3) == $WOE_CONTROL[.@i+2]) {
  61. OnWOEEnd:
  62. announce "The War Of Emperium is over!",bc_all|bc_woe;
  63. AgitEnd; AgitEnd2;
  64. sleep 1000;
  65. for(set .@j,0; .@j<30; set .@j,.@j+1) {
  66. if (.Active[0]&(1<<.@j)) Disp_Owner(.Castles$[.@j],1);
  67. if (.ExitWarp) maprespawnguildid .Castles$[.@j],0,3;
  68. }
  69. if (.Reward[0] && .Active[0] && .ForceEnd != 2) callsub OnReward, .Active[0];
  70. deletearray .Active[0],2;
  71. if (.ForceEnd) { set .ForceEnd,0; end; }
  72. break;
  73. }
  74. }
  75. if ((!agitcheck() && !agitcheck2()) || .Init) {
  76. if (!agitcheck() && !agitcheck2()) set .Init,0;
  77. for(set .@i,0; .@i<.Size; set .@i,.@i+4)
  78. if (gettime(4) == $WOE_CONTROL[.@i] && gettime(3) >= $WOE_CONTROL[.@i+1] && gettime(3) < $WOE_CONTROL[.@i+2]) {
  79. deletearray .Active[0],2;
  80. set .Active[0], $WOE_CONTROL[.@i+3];
  81. if (.Init) { AgitEnd; AgitEnd2; }
  82. else announce "The War Of Emperium has begun!",bc_all|bc_woe;
  83. sleep 1000;
  84. AgitStart; AgitStart2;
  85. for(set .@j,0; .@j<30; set .@j,.@j+1) {
  86. if (.Active[0]&(1<<.@j)) {
  87. if (!.Init) Disp_Owner(.Castles$[.@j],0);
  88. set .Active[1], .Active[1] | (1<<((.@j/5)+1));
  89. } else {
  90. if (.@j<20) {
  91. donpcevent "Agit#"+.Castles$[.@j]+"::OnAgitEnd";
  92. killmonster .Castles$[.@j], "Agit#"+.Castles$[.@j]+"::OnAgitBreak";
  93. } else {
  94. donpcevent "Manager#"+.Castles$[.@j]+"::OnAgitEnd2";
  95. killmonster .Castles$[.@j], "Steward#"+.EndLabel$[.@j-20]+"::OnStartArena";
  96. }
  97. }
  98. }
  99. break;
  100. }
  101. }
  102. set .Init,0;
  103. freeloop(0);
  104. end;
  105.  
  106. function Disp_Owner {
  107. set .@o, getcastledata(getarg(0),1);
  108. if (.@o) announce "The ["+getcastlename(getarg(0))+"] castle "+((getarg(1))?"has been conquered":"is currently held")+" by the ["+getguildname(.@o)+"] guild.",bc_all|bc_woe;
  109. else announce "The ["+getcastlename(getarg(0))+"] castle is currently unoccupied.",bc_all|bc_woe;
  110. return;
  111. }
  112. function Add_Zero {
  113. return ((getarg(0)<10)?"0":"")+getarg(0)+(getarg(1,0)?".":":")+"00";
  114. }
  115.  
  116. OnReward:
  117. for(set .@i,0; .@i<30; set .@i,.@i+1)
  118. if (getarg(0)&(1<<.@i)) {
  119. set .@guild, getcastledata(.Castles$[.@i],1);
  120. if (.@guild) {
  121. deletearray .@acc[0], getarraysize(.@acc); deletearray .@char[0], getarraysize(.@char);
  122. query_sql("SELECT account_id,char_id FROM `guild_member` WHERE guild_id = '"+.@guild+"'", .@acc, .@char);
  123. for(set .@j,0; .@j<getarraysize(.@acc); set .@j,.@j+1)
  124. if (isloggedin(.@acc[.@j],.@char[.@j])) {
  125. for(set .@k,0; .@k<getarraysize(.Reward); set .@k,.@k+2)
  126. getitem .Reward[.@k], .Reward[.@k+1], .@acc[.@j];
  127. message rid2name(.@acc[.@j]),"You have been rewarded for conquering "+getcastlename(.Castles$[.@i])+".";
  128. }
  129. }
  130. }
  131. return;
  132.  
  133. OnPCLoadMapEvent:
  134. if (!compare(strcharinfo(3),"g_cas")) end;
  135. if (((.AutoKick && .Active[0]) || (.NoOwner && !getcastledata(strcharinfo(3),1))) && !(.Active[0]&(1<<getd("."+strcharinfo(3))))) {
  136. if (getcharid(2) && getcastledata(strcharinfo(3),1) == getcharid(2)) end;
  137. sleep2 1000;
  138. message strcharinfo(0), getcastlename(strcharinfo(3))+" is currently inactive.";
  139. sleep2 5000;
  140. if (compare(strcharinfo(3),"g_cas")) warp "SavePoint",0,0;
  141. }
  142. end;
  143.  
  144. OnMenu:
  145. while(1) {
  146. mes "[WOE Information]";
  147. if (agitcheck() || agitcheck2()) {
  148. if (!.Size) mes "The War of Emperium is ^0055FFactive^000000.";
  149. else {
  150. for(set .@i,0; .@i<.Size; set .@i,.@i+4)
  151. if (gettime(4) == $WOE_CONTROL[.@i] && gettime(3) >= $WOE_CONTROL[.@i+1] && gettime(3) < $WOE_CONTROL[.@i+2]) {
  152. set .@i, $WOE_CONTROL[.@i+2];
  153. break;
  154. }
  155. mes "The War of Emperium is ^0055FFactive^000000 until ^FF0000"+Add_Zero(.@i)+"^000000 in the following regions:";
  156. mes " ";
  157. for(set .@i,0; .@i<6; set .@i,.@i+1)
  158. if (.Active[1]&(1<<(.@i+1))) mes " > ^777777"+.Regions$[.@i]+"^000000";
  159. }
  160. } else {
  161. set .@j,0; set .@k,0;
  162. for(set .@i,0; .@i<.Size; set .@i,.@i+4)
  163. if ((gettime(4) == $WOE_CONTROL[.@i] && gettime(3) <= $WOE_CONTROL[.@i+1]) || gettime(4) < $WOE_CONTROL[.@i]) {
  164. set .@j, $WOE_CONTROL[.@i]; set .@k, $WOE_CONTROL[.@i+1];
  165. break;
  166. }
  167. if (!.@j && !.@k) {
  168. set .@j, $WOE_CONTROL[0];
  169. set .@k, $WOE_CONTROL[1];
  170. }
  171. mes "The War of Emperium is ^777777inactive^000000.";
  172. if (.Size) {
  173. mes " ";
  174. mes "The next session will begin";
  175. mes "on ^0055FF"+.Days$[.@j]+"^000000 at "+Add_Zero(.@k)+"^000000.";
  176. }
  177. }
  178. next;
  179. switch(select(""+((.CastleWarp || .Active[1])?" ~ Warp to castles...":"")+": ~ Check schedule...: ~ View castle owners...:"+((getgmlevel()<.GMAccess || !getgmlevel())?"":" ~ Manage sessions...")+": ~ ^777777Cancel^000000")) {
  180. case 1:
  181. set .@menu$,"";
  182. for(set .@i,0; .@i<6; set .@i,.@i+1) {
  183. if (.CastleWarp || .Active[1]&(1<<(.@i+1)))
  184. set .@menu$, .@menu$+" ~ "+((.Active[1]&(1<<(.@i+1)))?"^0055FF":"^777777")+.Regions$[.@i]+" Castles^000000";
  185. set .@menu$, .@menu$+":";
  186. }
  187. set .@i, select(.@menu$)-1;
  188. set .@menu$,"";
  189. for(set .@j,.@i*5; .@j<(.@i*5)+5; set .@j,.@j+1) {
  190. if (.CastleWarp || .Active[0]&(1<<.@j))
  191. set .@menu$, .@menu$+" ~ "+((.Active[0]&(1<<.@j))?"^0055FF":"^777777")+getcastlename(.Castles$[.@j])+"^000000";
  192. set .@menu$, .@menu$+":";
  193. }
  194. set .@j, select(.@menu$)-1;
  195. warp .Map$[.@i],.MapX[(.@i*5)+.@j],.MapY[(.@i*5)+.@j];
  196. close;
  197. case 2:
  198. mes "[Schedule]";
  199. if (.Size) {
  200. freeloop(1);
  201. for(set .@i,0; .@i<.Size; set .@i,.@i+4) {
  202. mes "> ^FF0000"+.Days$[$WOE_CONTROL[.@i]]+" ("+Add_Zero($WOE_CONTROL[.@i+1])+"-"+Add_Zero($WOE_CONTROL[.@i+2])+")^000000";
  203. for(set .@j,0; .@j<30; set .@j,.@j+1)
  204. if ($WOE_CONTROL[.@i+3]&(1<<.@j)) mes " ~ "+getcastlename(.Castles$[.@j])+" ^777777("+.Castles$[.@j]+")^000000";
  205. if (.@i+4 < .Size) mes " ";
  206. }
  207. freeloop(0);
  208. }
  209. else mes "No times are configured.";
  210. next;
  211. break;
  212. case 3:
  213. mes "[Castle Ownership]";
  214. for(set .@i,0; .@i<6; set .@i,.@i+1) {
  215. set .@k, .@i*5;
  216. mes "> ^FF0000"+.Regions$[.@i]+"^000000";
  217. for(set .@j,.@k; .@j<(.@k+5); set .@j,.@j+1) {
  218. set .@t, getcastledata(.Castles$[.@j],1);
  219. mes " ~ "+getcastlename(.Castles$[.@j])+": "+((.@t)?"^0055FF"+getguildname(.@t):"^777777unoccupied")+"^000000";
  220. }
  221. if (.@i < 5) mes " ";
  222. }
  223. next;
  224. break;
  225. case 4:
  226. while(1) {
  227. mes "[Session Manager]";
  228. mes "There are ^0055FF"+(.Size/4)+" session(s)^000000 configured.";
  229. mes "What would you like to do?";
  230. next;
  231. switch(select(" ~ Add a session...: ~ Delete a session...: ~ Reload settings...:"+((agitcheck() || agitcheck2())?" ~ End WOE session...":"")+": ~ ^777777Go back^000000")) {
  232. case 1:
  233. mes "[New Session]";
  234. if (.Size > 127) {
  235. mes "You have already reached the maximum of 32 sessions.";
  236. next;
  237. break;
  238. }
  239. mes "Select a day.";
  240. next;
  241. set .@Day, select(" ~ "+implode(.Days$,": ~ "))-1;
  242. mes "[New Session]";
  243. mes "Select a start time for ^0055FF"+.Days$[.@Day]+"^000000.";
  244. next;
  245. set .@menu$,"";
  246. for(set .@i,0; .@i<23; set .@i,.@i+1)
  247. set .@menu$, .@menu$+" ~ "+Add_Zero(.@i,1)+":";
  248. set .@Start, select(.@menu$)-1;
  249. mes "[New Session]";
  250. mes "Select an end time for ^0055FF"+.Days$[.@Day]+"^000000.";
  251. next;
  252. set .@menu$,"";
  253. for(set .@i,.@Start+1; .@i<24; set.@i,.@i+1)
  254. set .@menu$, .@menu$+" ~ "+Add_Zero(.@i,1)+":";
  255. set .@End, select(.@menu$)+.@Start;
  256. for(set .@i,0; .@i<.Size; set .@i,.@i+4)
  257. if (.@Day == $WOE_CONTROL[.@i] &&
  258. ((.@Start >= $WOE_CONTROL[.@i+1] && .@Start < $WOE_CONTROL[.@i+2]) ||
  259. (.@End > $WOE_CONTROL[.@i+1] && .@End <= $WOE_CONTROL[.@i+2]) ||
  260. (.@Start <= $WOE_CONTROL[.@i+1] && .@End >= $WOE_CONTROL[.@i+2]))) {
  261. mes "[New Session]";
  262. mes "The chosen times overlap with an existing session.";
  263. next;
  264. set .@d,1;
  265. break;
  266. }
  267. if (.@d) { set .@d,0; break; }
  268. set .@Castle,0;
  269. while(1) {
  270. mes "[New Session]";
  271. mes "^0055FF"+.Days$[.@Day]+" ("+Add_Zero(.@Start)+"-"+Add_Zero(.@End)+")^000000";
  272. mes " > Castles:";
  273. if (!.@Castle) mes " ~ ^777777(none selected)^000000";
  274. else for(set .@i,0; .@i<30; set .@i,.@i+1)
  275. if (.@Castle&(1<<.@i)) mes " ~ "+getcastlename(.Castles$[.@i])+" ("+.Castles$[.@i]+")";
  276. next;
  277. set .@menu$,((.@Castle)?" ~ ^FF0000Finished...^000000":"")+":";
  278. for(set .@i,0; .@i<30; set .@i,.@i+1)
  279. set .@menu$, .@menu$+" ~ "+((.@Castle&(1<<.@i))?"^0055FF":"")+getcastlename(.Castles$[.@i])+" ("+.Castles$[.@i]+")^000000:";
  280. set .@i, select(.@menu$)-1;
  281. if (.@i) set .@Castle, .@Castle^(1<<(.@i-1));
  282. else {
  283. mes "[New Session]";
  284. mes "Are you sure?";
  285. next;
  286. switch(select(" ~ ^0055FFAdd session...^000000: ~ Continue selecting castles...: ~ ^777777Cancel^000000")) {
  287. case 1:
  288. for(set .@i,0; .@i<.Size; set .@i,.@i+4)
  289. if ((.@Day == $WOE_CONTROL[.@i] && .@End <= $WOE_CONTROL[.@i+1]) || .@Day < $WOE_CONTROL[.@i]) {
  290. set .@d,1;
  291. break;
  292. }
  293. if (!.@d) { set .@d,1; set .@i,.Size; }
  294. copyarray $WOE_CONTROL[.@i+4], $WOE_CONTROL[.@i], .Size-.@i;
  295. setarray $WOE_CONTROL[.@i], .@Day, .@Start, .@End, .@Castle;
  296. set .Size, getarraysize($WOE_CONTROL);
  297. case 3:
  298. mes "[New Session]";
  299. mes ((.@d)?"Session added.":"Cancelled.");
  300. next;
  301. set .@d,1;
  302. case 2:
  303. break;
  304. }
  305. if (.@d) { set .@d,0; break; }
  306. }
  307. }
  308. break;
  309. case 2:
  310. mes "[Remove Session]";
  311. if (!.Size) {
  312. mes "There are no sessions configured.";
  313. next;
  314. break;
  315. }
  316. mes "Select a session to remove.";
  317. next;
  318. set .@menu$,"";
  319. for(set .@i,0; .@i<.Size; set .@i,.@i+4)
  320. set .@menu$, .@menu$+" ~ "+.Days$[$WOE_CONTROL[.@i]]+" ("+Add_Zero($WOE_CONTROL[.@i+1],1)+"-"+Add_Zero($WOE_CONTROL[.@i+2],1)+"):";
  321. set .@menu$, .@menu$+" ~ ^777777Cancel^000000";
  322. set .@i, select(.@menu$)-1;
  323. if (.@i == (.Size/4)) break;
  324. mes "[Remove Session]";
  325. mes "Delete ^0055FF"+.Days$[$WOE_CONTROL[.@i*4]]+"'s^000000 session?";
  326. mes "This action cannot be undone.";
  327. next;
  328. set .@j, select(" ~ ^FF0000Delete session...^000000: ~ ^777777Cancel^000000");
  329. mes "[Remove Session]";
  330. if (.@j == 2) mes "Cancelled.";
  331. else {
  332. deletearray $WOE_CONTROL[.@i*4],4;
  333. set .Size, getarraysize($WOE_CONTROL);
  334. mes "Session deleted.";
  335. }
  336. next;
  337. break;
  338. case 3:
  339. mes "[Reload Settings]";
  340. mes "This will trigger all events related to new session configurations, if any.";
  341. if (agitcheck() || agitcheck2()) {
  342. mes " ";
  343. mes "Be aware that this will disrupt the current WOE session.";
  344. }
  345. next;
  346. set .@i, select(" ~ ^0055FFReload settings...^000000: ~ ^777777Cancel^000000");
  347. mes "[Reload Settings]";
  348. if (.@i == 2) mes "Cancelled.";
  349. else {
  350. set .Init,1;
  351. donpcevent "WOE_CONTROL::OnMinute00";
  352. mes "Variables have been re-initialized.";
  353. }
  354. next;
  355. break;
  356. case 4:
  357. mes "[Force Agit End]";
  358. if (!agitcheck() && !agitcheck2()) {
  359. mes "WOE has already ended.";
  360. next;
  361. break;
  362. }
  363. mes "This command will safely execute all AgitEnd events.";
  364. mes " ";
  365. mes "Kill the current WOE session?";
  366. next;
  367. set .@i, select(" ~ ^FF0000End session...^000000:"+((.Reward[0])?" ~ ^FF0000End session without rewards...^000000":"")+": ~ ^777777Cancel^000000");
  368. mes "[Force Agit End]";
  369. if (.@i == 3) mes "Cancelled.";
  370. else {
  371. set .ForceEnd, .@i;
  372. donpcevent "WOE_CONTROL::OnWOEEnd";
  373. mes "WOE session terminated.";
  374. }
  375. next;
  376. break;
  377. case 5:
  378. set .@d,1; break;
  379. }
  380. if (.@d) { set .@d,0; break; }
  381. } break;
  382. case 5:
  383. close;
  384. } }
  385. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement