Advertisement
Guest User

fixed

a guest
Jan 19th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.02 KB | None | 0 0
  1. //===== rAthena Script =======================================
  2. //= Euphy's WOE Controller
  3. //===== By: ==================================================
  4. //= Euphy
  5. //===== Current Version: =====================================
  6. //= 1.5
  7. //===== Compatible With: =====================================
  8. //= rAthena Project
  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. // Information NPC
  21. //============================================================
  22. prontera,159,192,4 script WOE Information 835,{
  23. doevent "WOE_CONTROL::OnMenu";
  24. end;
  25. OnAgitStart:
  26. while(agitcheck()) {
  27. specialeffect EF_BEGINSPELL6;
  28. sleep 425;
  29. }
  30. end;
  31. }
  32.  
  33. // Script Core
  34. //============================================================
  35. - script WOE_CONTROL -1,{
  36. function Disp_Owner; function Add_Zero;
  37.  
  38. OnInit:
  39.  
  40. // -----------------------------------------------------------
  41. // Configuration settings.
  42. // -----------------------------------------------------------
  43.  
  44. set .CastleWarp,0; // 1: Always enable all castle warps. | 0: Warp only to active castles.
  45. set .AutoKick,1; // Automatically kick players from inactive castles during WOE? (1:yes / 0:no)
  46. set .NoOwner,0; // Automatically kick players from unconquered castles outside of WOE? (1:yes / 0:no)
  47. set .ExitWarp,0; // Warp all players from castles when WOE ends? (1:yes / 0:no)
  48. set .GMAccess,99; // GM level required to access Session Manager.
  49.  
  50. // -----------------------------------------------------------
  51. // Reward options.
  52. // -----------------------------------------------------------
  53. // [1] Enable rewards.
  54. // [2] Mail all rewards.
  55. // - If not set, players receive items in their inventory.
  56. // - Only ONE item can be sent via mail for PACKETVER < 20150513 while later clients are limited to MAIL_MAX_ITEM (5).
  57. // - Note that offline players do NOT receive rewards.
  58. // [4] Only reward Guild Masters.
  59. // - If not set, all guild members are rewarded.
  60. // - If mailing is enabled (option 2), offline Guild Masters WILL receive rewards.
  61. // [8] Duplicate IP check.
  62. // - Members in a guild with the same IP address are not rewarded.
  63. // - If Guild Masters is enabled (option 4), this feature is not used.
  64. // -----------------------------------------------------------
  65.  
  66. // Combine values as needed (e.g. 1|8 = 1+8 = 9).
  67. set .Options, 1|8;
  68.  
  69. // Rewards per castle.
  70. // setarray .reward_id[0], <itemID>{,<itemID>,...}
  71. // setarray .reward_amount[0], <amount>{,<amount>,...}
  72. //setarray .reward_id[0],14001;
  73. //setarray .reward_amount[0],1;
  74. setarray .Reward[0],501,1;
  75. setarray .Reward_Leader[0], 502, 1;
  76.  
  77. // Zeny reward:
  78. .reward_zeny = 0;
  79.  
  80. // -----------------------------------------------------------
  81. // Constants (leave this section alone).
  82. // -----------------------------------------------------------
  83.  
  84. setarray .Castles$[0],
  85. "prtg_cas01","prtg_cas02","prtg_cas03","prtg_cas04","prtg_cas05",
  86. "payg_cas01","payg_cas02","payg_cas03","payg_cas04","payg_cas05",
  87. "gefg_cas01","gefg_cas02","gefg_cas03","gefg_cas04","gefg_cas05",
  88. "aldeg_cas01","aldeg_cas02","aldeg_cas03","aldeg_cas04","aldeg_cas05",
  89. "arug_cas01","arug_cas02","arug_cas03","arug_cas04","arug_cas05",
  90. "schg_cas01","schg_cas02","schg_cas03","schg_cas04","schg_cas05";
  91. setarray .EndLabel$[0],"ar01","ar02","ar03","ar04","ar05","sc01","sc02","sc03","sc04","sc05";
  92. setarray .Days$[0],"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday";
  93. setarray .Regions$[0],"Prontera","Payon","Geffen","Aldebaran","Arunafeltz","Schwaltzvalt";
  94. setarray .Map$[0],"prt_gld","pay_gld","gef_fild13","alde_gld","aru_gld","sch_gld";
  95. 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;
  96. 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;
  97.  
  98. // -----------------------------------------------------------
  99.  
  100. .reward_id_size = getarraysize(.Reward);
  101. set .Size, getarraysize($WOE_CONTROL);
  102. if (.AutoKick || .NoOwner)
  103. for(set .@i,0; .@i<30; set .@i,.@i+1) {
  104. setmapflag .Castles$[.@i], mf_loadevent;
  105. setd "."+.Castles$[.@i], .@i;
  106. }
  107. if (!agitcheck() && !agitcheck2()) sleep 4000;
  108. set .Init,1;
  109.  
  110. OnMinute00:
  111. freeloop(1);
  112. if (agitcheck() || agitcheck2()) {
  113. for(set .@i,0; .@i<.Size; set .@i,.@i+4)
  114. if (gettime(DT_DAYOFWEEK) == $WOE_CONTROL[.@i] && gettime(DT_HOUR) == $WOE_CONTROL[.@i+2]) {
  115. OnWOEEnd:
  116. announce "The War Of Emperium is over!",bc_all|bc_woe;
  117. AgitEnd; AgitEnd2;
  118. sleep 1000;
  119. for(set .@j,0; .@j<30; set .@j,.@j+1) {
  120. if (.Active[0]&(1<<.@j)) Disp_Owner(.Castles$[.@j],1);
  121. if (.ExitWarp) maprespawnguildid .Castles$[.@j],0,3;
  122. }
  123. if ((.Options&1) && .Active[0] && .ForceEnd != 2) callsub OnReward, .Active[0];
  124. deletearray .Active[0],2;
  125. if (.ForceEnd) { set .ForceEnd,0; end; }
  126. break;
  127. }
  128. }
  129. if ((!agitcheck() && !agitcheck2()) || .Init) {
  130. if (!agitcheck() && !agitcheck2()) set .Init,0;
  131. for(set .@i,0; .@i<.Size; set .@i,.@i+4)
  132. if (gettime(DT_DAYOFWEEK) == $WOE_CONTROL[.@i] && gettime(DT_HOUR) >= $WOE_CONTROL[.@i+1] && gettime(DT_HOUR) < $WOE_CONTROL[.@i+2]) {
  133. deletearray .Active[0],2;
  134. set .Active[0], $WOE_CONTROL[.@i+3];
  135. if (.Init) { AgitEnd; AgitEnd2; }
  136. else announce "The War Of Emperium has begun!",bc_all|bc_woe;
  137. sleep 1000;
  138. AgitStart; AgitStart2;
  139. for(set .@j,0; .@j<30; set .@j,.@j+1) {
  140. if (.Active[0]&(1<<.@j)) {
  141. if (!.Init) Disp_Owner(.Castles$[.@j],0);
  142. set .Active[1], .Active[1] | (1<<((.@j/5)+1));
  143. } else {
  144. if (.@j<20) {
  145. donpcevent "Agit#"+.Castles$[.@j]+"::OnAgitEnd";
  146. killmonster .Castles$[.@j], "Agit#"+.Castles$[.@j]+"::OnAgitBreak";
  147. } else {
  148. donpcevent "Manager#"+.Castles$[.@j]+"::OnAgitEnd2";
  149. killmonster .Castles$[.@j], "Steward#"+.EndLabel$[.@j-20]+"::OnStartArena";
  150. }
  151. }
  152. }
  153. break;
  154. }
  155. }
  156. set .Init,0;
  157. end;
  158.  
  159. function Disp_Owner {
  160. set .@o, getcastledata(getarg(0),1);
  161. 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;
  162. else announce "The ["+getcastlename(getarg(0))+"] castle is currently unoccupied.",bc_all|bc_woe;
  163. return;
  164. }
  165. function Add_Zero {
  166. return ((getarg(0)<10)?"0":"")+getarg(0)+(getarg(1,0)?".":":")+"00";
  167. }
  168.  
  169. OnReward:
  170. if (!.reward_id_size && !.reward_zeny)
  171. return;
  172.  
  173. set .@sql$, ((.Options&4)?"position = 0":"online = 1");
  174. if (.Options&2) set .@str$,gettimestr("%B %d, %Y",21);
  175. freeloop(1);
  176. for(set .@i,0; .@i<30; set .@i,.@i+1) {
  177. if (getarg(0)&(1<<.@i)) {
  178. set .@gid, getcastledata(.Castles$[.@i],1);
  179. if (!.@gid) continue;
  180. set .@size, query_sql("SELECT account_id,char_id FROM `guild_member` WHERE guild_id = '"+.@gid+"' AND "+.@sql$,.@aid,.@cid);
  181. for(set .@j,0; .@j<.@size; set .@j,.@j+1) {
  182. if ((.Options&8) && !(.Options&4)) {
  183. set .@ip$, replacestr(getcharip(.@aid[.@j]),".","a");
  184. if (getd(".@ip_"+.@i+"_"+.@ip$)) continue;
  185. setd ".@ip_"+.@i+"_"+.@ip$,1;
  186. }
  187. if (isloggedin(.@aid[.@j])) {
  188. query_sql("SELECT `name` FROM `char` WHERE `account_id` = '"+.@aid[.@j]+"'"),$leadername$; //get the name using the account id
  189. query_sql("SELECT `master` FROM `guild` WHERE `master` = '"+$leadername$+"'"),$guildleader$; //match mastername to name
  190.  
  191. if($leadername$ != $guildleader$){ //if not match reward for member only 501 as example and 502 for guild leader if the name matched
  192. getitem 501, 1, .@aid[.@j];
  193. } else {
  194. getitem 502, 1, .@aid[.@j];
  195. }
  196. message rid2name(.@aid[.@j]),"You have been rewarded for conquering "+getcastlename(.Castles$[.@i])+".";
  197. }
  198. }
  199. }
  200. }
  201. return;
  202.  
  203. OnPCLoadMapEvent:
  204. if (!compare(strcharinfo(3),"g_cas")) end;
  205. if (((.AutoKick && .Active[0]) || (.NoOwner && !getcastledata(strcharinfo(3),1))) && !(.Active[0]&(1<<getd("."+strcharinfo(3))))) {
  206. if (getcharid(2) && getcastledata(strcharinfo(3),1) == getcharid(2)) end;
  207. sleep2 1000;
  208. message strcharinfo(0), getcastlename(strcharinfo(3))+" is currently inactive.";
  209. sleep2 5000;
  210. if (compare(strcharinfo(3),"g_cas")) warp "SavePoint",0,0;
  211. }
  212. end;
  213.  
  214. OnMenu:
  215. while(1) {
  216. mes "[WOE Information]";
  217. if (agitcheck() || agitcheck2()) {
  218. if (.Active[0]) {
  219. for(set .@i,0; .@i<.Size; set .@i,.@i+4)
  220. if (gettime(DT_DAYOFWEEK) == $WOE_CONTROL[.@i] && gettime(DT_HOUR) >= $WOE_CONTROL[.@i+1] && gettime(DT_HOUR) < $WOE_CONTROL[.@i+2]) {
  221. set .@i, $WOE_CONTROL[.@i+2];
  222. break;
  223. }
  224. mes "The War of Emperium is ^0055FFactive^000000 until ^FF0000"+Add_Zero(.@i)+"^000000 in the following regions:";
  225. mes " ";
  226. for(set .@i,0; .@i<6; set .@i,.@i+1)
  227. if (.Active[1]&(1<<(.@i+1))) mes " > ^777777"+.Regions$[.@i]+"^000000";
  228. } else
  229. mes "The War of Emperium is ^0055FFactive^000000.";
  230. } else {
  231. for(set .@i,0; .@i<.Size; set .@i,.@i+4)
  232. if ((gettime(DT_DAYOFWEEK) == $WOE_CONTROL[.@i] && gettime(DT_HOUR) <= $WOE_CONTROL[.@i+1]) || gettime(DT_DAYOFWEEK) < $WOE_CONTROL[.@i]) {
  233. setarray .@time[0],$WOE_CONTROL[.@i],$WOE_CONTROL[.@i+1];
  234. break;
  235. }
  236. if (!getarraysize(.@time))
  237. setarray .@time[0],$WOE_CONTROL[0],$WOE_CONTROL[1];
  238. mes "The War of Emperium is ^777777inactive^000000.";
  239. if (.Size) {
  240. mes " ";
  241. mes "The next session will begin";
  242. mes "on ^0055FF"+.Days$[.@time[0]]+"^000000 at "+Add_Zero(.@time[1])+"^000000.";
  243. }
  244. }
  245. next;
  246. switch(select(""+((.CastleWarp || .Active[1])?" ~ Warp to castles...":"")+": ~ Check schedule...: ~ View castle owners...:"+((getgmlevel()<.GMAccess || !getgmlevel())?"":" ~ Manage sessions...")+": ~ ^777777Cancel^000000")) {
  247. case 1:
  248. if (.CastleWarp) set .@clr$,"^0055FF";
  249. set .@menu$,"";
  250. for(set .@i,0; .@i<6; set .@i,.@i+1) {
  251. if (.CastleWarp || .Active[1]&(1<<(.@i+1)))
  252. set .@menu$, .@menu$+" ~ "+((.Active[1]&(1<<(.@i+1)))?.@clr$:"^777777")+.Regions$[.@i]+" Castles^000000";
  253. set .@menu$, .@menu$+":";
  254. }
  255. set .@i, select(.@menu$)-1;
  256. set .@menu$,"";
  257. for(set .@j,.@i*5; .@j<(.@i*5)+5; set .@j,.@j+1) {
  258. if (.CastleWarp || .Active[0]&(1<<.@j))
  259. set .@menu$, .@menu$+" ~ "+((.Active[0]&(1<<.@j))?.@clr$:"^777777")+getcastlename(.Castles$[.@j])+"^000000";
  260. set .@menu$, .@menu$+":";
  261. }
  262. set .@j, select(.@menu$)-1;
  263. warp .Map$[.@i],.MapX[(.@i*5)+.@j],.MapY[(.@i*5)+.@j];
  264. close;
  265. case 2:
  266. mes "[Schedule]";
  267. if (.Size) {
  268. freeloop(1);
  269. for(set .@i,0; .@i<.Size; set .@i,.@i+4) {
  270. mes "> ^FF0000"+.Days$[$WOE_CONTROL[.@i]]+" ("+Add_Zero($WOE_CONTROL[.@i+1])+"-"+Add_Zero($WOE_CONTROL[.@i+2])+")^000000";
  271. for(set .@j,0; .@j<30; set .@j,.@j+1)
  272. if ($WOE_CONTROL[.@i+3]&(1<<.@j)) mes " ~ "+getcastlename(.Castles$[.@j])+" ^777777("+.Castles$[.@j]+")^000000";
  273. if (.@i+4 < .Size) mes " ";
  274. }
  275. freeloop(0);
  276. } else
  277. mes "No times are configured.";
  278. next;
  279. break;
  280. case 3:
  281. mes "[Castle Ownership]";
  282. for(set .@i,0; .@i<6; set .@i,.@i+1) {
  283. set .@k, .@i*5;
  284. mes "> ^FF0000"+.Regions$[.@i]+"^000000";
  285. for(set .@j,.@k; .@j<(.@k+5); set .@j,.@j+1) {
  286. set .@t, getcastledata(.Castles$[.@j],1);
  287. mes " ~ "+getcastlename(.Castles$[.@j])+": "+((.@t)?"^0055FF"+getguildname(.@t):"^777777unoccupied")+"^000000";
  288. }
  289. if (.@i < 5) mes " ";
  290. }
  291. next;
  292. break;
  293. case 4:
  294. while(1) {
  295. mes "[Session Manager]";
  296. mes "There are ^0055FF"+(.Size/4)+" session(s)^000000 configured.";
  297. mes "What would you like to do?";
  298. next;
  299. switch(select(" ~ Add a session...: ~ Delete a session...: ~ Reload settings...:"+((agitcheck() || agitcheck2())?" ~ End WOE session...":"")+": ~ ^777777Go back^000000")) {
  300. case 1:
  301. mes "[New Session]";
  302. if (.Size > 127) {
  303. mes "You have already reached the maximum of 32 sessions.";
  304. next;
  305. break;
  306. }
  307. mes "Select a day.";
  308. next;
  309. set .@Day, select(" ~ "+implode(.Days$,": ~ "))-1;
  310. mes "[New Session]";
  311. mes "Select a start time for ^0055FF"+.Days$[.@Day]+"^000000.";
  312. next;
  313. set .@menu$,"";
  314. for(set .@i,0; .@i<23; set .@i,.@i+1)
  315. set .@menu$, .@menu$+" ~ "+Add_Zero(.@i,1)+":";
  316. set .@Start, select(.@menu$)-1;
  317. mes "[New Session]";
  318. mes "Select an end time for ^0055FF"+.Days$[.@Day]+"^000000.";
  319. next;
  320. set .@menu$,"";
  321. for(set .@i,.@Start+1; .@i<24; set.@i,.@i+1)
  322. set .@menu$, .@menu$+" ~ "+Add_Zero(.@i,1)+":";
  323. set .@End, select(.@menu$)+.@Start;
  324. for(set .@i,0; .@i<.Size; set .@i,.@i+4)
  325. if (.@Day == $WOE_CONTROL[.@i] &&
  326. ((.@Start >= $WOE_CONTROL[.@i+1] && .@Start < $WOE_CONTROL[.@i+2]) ||
  327. (.@End > $WOE_CONTROL[.@i+1] && .@End <= $WOE_CONTROL[.@i+2]) ||
  328. (.@Start <= $WOE_CONTROL[.@i+1] && .@End >= $WOE_CONTROL[.@i+2]))) {
  329. mes "[New Session]";
  330. mes "The chosen times overlap with an existing session.";
  331. next;
  332. set .@d,1;
  333. break;
  334. }
  335. if (.@d) { set .@d,0; break; }
  336. set .@Castle,0;
  337. while(1) {
  338. mes "[New Session]";
  339. mes "^0055FF"+.Days$[.@Day]+" ("+Add_Zero(.@Start)+"-"+Add_Zero(.@End)+")^000000";
  340. mes " > Castles:";
  341. if (!.@Castle)
  342. mes " ~ ^777777(none selected)^000000";
  343. else for(set .@i,0; .@i<30; set .@i,.@i+1)
  344. if (.@Castle&(1<<.@i)) mes " ~ "+getcastlename(.Castles$[.@i])+" ("+.Castles$[.@i]+")";
  345. next;
  346. set .@menu$,((.@Castle)?" ~ ^FF0000Finished...^000000":"")+":";
  347. for(set .@i,0; .@i<30; set .@i,.@i+1)
  348. set .@menu$, .@menu$+" ~ "+((.@Castle&(1<<.@i))?"^0055FF":"")+getcastlename(.Castles$[.@i])+" ("+.Castles$[.@i]+")^000000:";
  349. set .@i, select(.@menu$)-1;
  350. if (.@i)
  351. set .@Castle, .@Castle^(1<<(.@i-1));
  352. else {
  353. mes "[New Session]";
  354. mes "Are you sure?";
  355. next;
  356. switch(select(" ~ ^0055FFAdd session...^000000: ~ Continue selecting castles...: ~ ^777777Cancel^000000")) {
  357. case 1:
  358. for(set .@i,0; .@i<.Size; set .@i,.@i+4)
  359. if ((.@Day == $WOE_CONTROL[.@i] && .@End <= $WOE_CONTROL[.@i+1]) || .@Day < $WOE_CONTROL[.@i]) {
  360. set .@d,1;
  361. break;
  362. }
  363. if (!.@d) { set .@d,1; set .@i,.Size; }
  364. copyarray $WOE_CONTROL[.@i+4], $WOE_CONTROL[.@i], .Size-.@i;
  365. setarray $WOE_CONTROL[.@i], .@Day, .@Start, .@End, .@Castle;
  366. set .Size, getarraysize($WOE_CONTROL);
  367. case 3:
  368. mes "[New Session]";
  369. mes ((.@d)?"Session added.":"cancelled.");
  370. next;
  371. set .@d,1;
  372. case 2:
  373. break;
  374. }
  375. if (.@d) { set .@d,0; break; }
  376. }
  377. }
  378. break;
  379. case 2:
  380. mes "[Remove Session]";
  381. if (!.Size) {
  382. mes "There are no sessions configured.";
  383. next;
  384. break;
  385. }
  386. mes "Select a session to remove.";
  387. next;
  388. set .@menu$,"";
  389. for(set .@i,0; .@i<.Size; set .@i,.@i+4)
  390. set .@menu$, .@menu$+" ~ "+.Days$[$WOE_CONTROL[.@i]]+" ("+Add_Zero($WOE_CONTROL[.@i+1],1)+"-"+Add_Zero($WOE_CONTROL[.@i+2],1)+"):";
  391. set .@menu$, .@menu$+" ~ ^777777Cancel^000000";
  392. set .@i, select(.@menu$)-1;
  393. if (.@i == (.Size/4)) break;
  394. mes "[Remove Session]";
  395. mes "Delete ^0055FF"+.Days$[$WOE_CONTROL[.@i*4]]+"'s^000000 session?";
  396. mes "This action cannot be undone.";
  397. next;
  398. set .@j, select(" ~ ^FF0000Delete session...^000000: ~ ^777777Cancel^000000");
  399. mes "[Remove Session]";
  400. if (.@j == 2)
  401. mes "cancelled.";
  402. else {
  403. deletearray $WOE_CONTROL[.@i*4],4;
  404. set .Size, getarraysize($WOE_CONTROL);
  405. mes "Session deleted.";
  406. }
  407. next;
  408. break;
  409. case 3:
  410. mes "[Reload Settings]";
  411. mes "This will trigger all events related to new session configurations, if any.";
  412. if (agitcheck() || agitcheck2()) {
  413. mes " ";
  414. mes "Be aware that this will disrupt the current WOE session.";
  415. }
  416. next;
  417. set .@i, select(" ~ ^0055FFReload settings...^000000: ~ ^777777Cancel^000000");
  418. mes "[Reload Settings]";
  419. if (.@i == 2) mes "cancelled.";
  420. else {
  421. set .Init,1;
  422. donpcevent "WOE_CONTROL::OnMinute00";
  423. mes "Variables have been re-initialized.";
  424. }
  425. next;
  426. break;
  427. case 4:
  428. mes "[Force Agit End]";
  429. if (!agitcheck() && !agitcheck2()) {
  430. mes "WOE has already ended.";
  431. next;
  432. break;
  433. }
  434. mes "This command will safely execute all AgitEnd events.";
  435. mes " ";
  436. mes "Kill the current WOE session?";
  437. next;
  438. set .@i, select(" ~ ^FF0000End session...^000000:"+((.Options&1)?" ~ ^FF0000End session without rewards...^000000":"")+": ~ ^777777Cancel^000000");
  439. mes "[Force Agit End]";
  440. if (.@i == 3)
  441. mes "cancelled.";
  442. else {
  443. set .ForceEnd, .@i;
  444. donpcevent "WOE_CONTROL::OnWOEEnd";
  445. mes "WOE session terminated.";
  446. }
  447. next;
  448. break;
  449. case 5:
  450. set .@d,1; break;
  451. }
  452. if (.@d) { set .@d,0; break; }
  453. } break;
  454. case 5:
  455. close;
  456. } }
  457. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement