Advertisement
Guest User

CTF Script

a guest
Jan 25th, 2013
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.08 KB | None | 0 0
  1. //===== eAthena Script =======================================
  2. //= Capture the Flag
  3. //===== By: ==================================================
  4. //= mathio
  5. //===== Current Version: =====================================
  6. //= 1.1
  7. //===== Description: =========================================
  8. //= The players are divided up into two teams, Red Team and Blue Team.
  9. //= Players subscribe into teams - each subscriber needs a party with 5
  10. //= (or other set amount) players in it. Whole party is signed up.
  11. //= There are two flags, each team must capture the other team's flag and return
  12. //= it to their own. They cannot score if their flag is taken. First team to
  13. //= score 3 (or other set amount) captures wins!
  14. //===== Additional Comments: =================================
  15. //= Technically, there are 4 Flags, 2 for the starting base. 2 for dropped flags
  16. //= Beware of issues via player logout, the bug should be fixed though
  17. //= Starter NPC is located at "bat_b01,389,8". Careful not to touch the flags
  18. //= Clothes color change when joining teams and when picking up the flag to add
  19. //= some coolness! =)
  20. //= Players should use the Starter NPC in jupe_ele. GMs should use the one in
  21. //= bat_b01
  22. //= GM can configure CTF settings with the CTF NPC
  23. //============================================================
  24.  
  25. bat_b01 mapflag pvp
  26. bat_b01 mapflag pvp_noguild
  27. bat_b01 mapflag nobranch
  28. bat_b01 mapflag nomemo
  29. bat_b01 mapflag nopenalty
  30. bat_b01 mapflag noreturn
  31. bat_b01 mapflag noteleport
  32. bat_b01 mapflag nowarp
  33. bat_b01 mapflag nowarpto
  34. bat_b01 mapflag noicewall
  35.  
  36. jupe_ele mapflag nomemo
  37. jupe_ele mapflag noreturn
  38. jupe_ele mapflag nowarp
  39. jupe_ele mapflag nowarpto
  40. jupe_ele mapflag noicewall
  41.  
  42. bat_b01,0,0,0 script ctf_sys -1,{
  43. end;
  44.  
  45. OnPCLogoutEvent:
  46. //do this only when logged out from game
  47. if (BlueTeam == 1 || RedTeam == 1) {
  48. //Clearing all variables, restoring original look, and saving in prontera
  49. setlook 7,"normallook"+strcharinfo(0);
  50. if (getsavepoint(0) == "bat_b01" || getsavepoint(0) == "jupe_ele")
  51. savepoint "prontera",116,73;
  52. if( RedFlagTaken == 1 ){ //If PC has the red flag, drops on logout
  53. mapannounce "bat_b01","The Red Flag has been dropped",bc_map,0xFF0000;
  54. getmapxy (mapname$,.@mapx,.@mapy,0,strcharinfo(0));
  55. movenpc "Red Flag 1",.@mapx,.@mapy;
  56. }
  57. if( BlueFlagTaken == 1 ){ //If PC has the blue flag, drops on logout
  58. mapannounce "bat_b01","The Blue Flag has been dropped",bc_map,0x0000FF;
  59. getmapxy (mapname$,.@mapx,.@mapy,0,strcharinfo(0));
  60. movenpc "Blue Flag 1",.@mapx,.@mapy;
  61. }
  62. set BlueTeam, 0;
  63. set RedTeam, 0;
  64. set RedFlagTaken, 0;
  65. set BlueFlagTaken, 0;
  66. set Blue_Flag_Carrier$,0;
  67. set Red_Flag_Carrier$,0;
  68. if (getmapusers("bat_b01.gat") == 1) {
  69. goto OnCTFEndGame;
  70. }
  71. }
  72.  
  73. if (getsavepoint(0) == "bat_b01" || getsavepoint(0) == "jupe_ele") //restore savepoint to prontera
  74. savepoint "prontera",116,73;
  75. end;
  76.  
  77. OnPCDieEvent:
  78. if( BlueFlagTaken == 1 ){
  79. mapannounce "bat_b01", "The Blue Flag has been dropped",bc_map,0x0000FF;
  80. setlook 7, 79;
  81. getmapxy (mapname$,.@mapx,.@mapy,0,strcharinfo(0));
  82. movenpc "Blue Flag 1",.@mapx,.@mapy;
  83. set BlueFlagTaken, 0;
  84. set Blue_Flag_Carrier$,0;
  85. end;
  86. }
  87.  
  88. if( RedFlagTaken == 1 ){
  89. mapannounce "bat_b01", "The Red Flag has been dropped",bc_map,0xFF0000;
  90. setlook 7, 78;
  91. getmapxy (mapname$,.@mapx,.@mapy,0,strcharinfo(0));
  92. movenpc "Red Flag 1",.@mapx,.@mapy;
  93. set RedFlagTaken, 0;
  94. set Red_Flag_Carrier$,0;
  95. end;
  96. }
  97. end;
  98.  
  99. OnCTFEndGame:
  100. //Incase flags come back, move them to a remote location [Safety Precaution]
  101. movenpc "Red Flag",391,15;
  102. movenpc "Blue Flag",391,14;
  103. movenpc "Red Flag 1",392,15;
  104. movenpc "Blue Flag 1",392,14;
  105. //announce
  106. mapannounce "bat_b01", "The CTF game ended! You will be warped out in few seconds.",0;
  107. mapannounce "jupe_ele", "The CTF game ended",0;
  108. mapannounce "jupe_ele", getpartyname($BlueParty)+" (blue) "+$@bluescore+" : "+$@bluescore+" "+getpartyname($RedParty)+" (red)",0;
  109. //reset parties
  110. set $BlueParty,0;
  111. set $RedParty,0;
  112. //disable entrance warp
  113. disablenpc "CtfEntrance";
  114. //warp all players
  115. sleep 3000;
  116. mapwarp "bat_b01","jupe_ele",44,46;
  117. end;
  118. }
  119.  
  120. prontera,169,71,3 script CTF Warper#prt 874,{
  121.  
  122. mes "[CTF Warper]";
  123. mes "Welcome, do you want to play ^0000ffCapture the Flag^000000?";
  124.  
  125. //check if game in progress
  126. if ($BlueParty > 0 && $RedParty > 0) {
  127. mes "^ff0000There is a game in progress.^000000";
  128. } else {
  129. mes "^008800There is no game in progress.^000000";
  130. }
  131. mes "There are "+getmapusers("jupe_ele.gat")+" players in waiting room.";
  132. next;
  133. menu "I want to play!",warpme,
  134. "No thank you...",-;
  135. close;
  136.  
  137. warpme:
  138. warp "jupe_ele",44,46;
  139. close;
  140.  
  141. }
  142.  
  143. // This is the NPC players will use to join the game. GMs can join the game, configure CTF or force current game to end
  144. jupe_ele,37,36,7 script CTF Warper#game 874,{
  145.  
  146. set @pid, getcharid(1);
  147.  
  148. mes "[CTF Warper]";
  149. mes "Do you really want to leave?";
  150. mes "If your party is signed up for CTF it will be ^0000ffcanceled if you leave^000000!";
  151.  
  152. if (select("I will stay:I want to go back") == 1)
  153. close;
  154.  
  155. setlook 7,"normallook"+strcharinfo(0);
  156. if (getsavepoint(0) == "bat_b01" || getsavepoint(0) == "jupe_ele")
  157. savepoint "prontera",116,73;
  158.  
  159. if (@pid == $BlueParty)
  160. set $BlueParty, 0;
  161. if (@pid == $RedParty)
  162. set $RedParty, 0;
  163.  
  164. warp "prontera",116,73;
  165. close;
  166.  
  167. }
  168.  
  169. jupe_ele,46,55,5 script Capture The Flag 873,{
  170. if($Cap_Limit == 0 || $Play_Limit == 0) {
  171. set $Cap_Limit, 3;
  172. set $Play_Limit, 5;
  173. }
  174.  
  175. //check nonexistent parties
  176. getpartymember($BlueParty);
  177. set @bluecount,$@partymembercount;
  178. getpartymember($RedParty);
  179. set @redcount,$@partymembercount;
  180.  
  181. if (getpartyname($BlueParty) == "null" || @bluecount != $Play_Limit)
  182. set $BlueParty,0;
  183. if (getpartyname($RedParty) == "null" || @redcount != $Play_Limit)
  184. set $RedParty,0;
  185.  
  186. if(getgmlevel() >= 60) {
  187.  
  188. gmmenu:
  189. mes "[CTF]";
  190. mes "Want do you want to do?";
  191. next;
  192. menu "Join the fight",jtf,
  193. "Configure CTF",CTFConfig,
  194. "Force the end of current game",ForceEnd,
  195. "Cancel",-;
  196. close;
  197.  
  198. CTFConfig:
  199. mes "[CTF]";
  200. mes "What setting do you wish to change?";
  201. next;
  202. menu "Max Capture Limit ("+$Cap_Limit+")",CTFcapL,
  203. "Players Limit For Each Team ("+$Play_Limit+")",CTFplayL;
  204.  
  205. CTFcapL:
  206. mes "How many flag captures until the match is over? (3 recommended, maximum 10)";
  207. input $Cap_Limit;
  208. if($Cap_Limit > 10 || $Cap_Limit <= 0){
  209. mes "Sorry, you can only have a range or 1-10 captures";
  210. goto gmmenu;
  211. }
  212. mes "The Cap Limit is now "+$Cap_Limit;
  213. goto gmmenu;
  214.  
  215. CTFplayL:
  216. mes "How many players are required for each team?";
  217. input $Play_Limit;
  218. if($Cap_Limit > 10 || $Cap_Limit <= 0){
  219. mes "Sorry, you can only have only 1-10 players limit";
  220. goto gmmenu;
  221. }
  222. mes "The Player Limit is now "+$Play_Limit;
  223. goto gmmenu;
  224.  
  225. ForceEnd:
  226. mes "Really force the current game to end?";
  227.  
  228. if (select("No:Yes") == 1)
  229. goto gmmenu;
  230.  
  231. mes "The current game was ended!";
  232. close2;
  233.  
  234. //Incase flags come back, move them to a remote location [Safety Precaution]
  235. movenpc "Red Flag",391,15;
  236. movenpc "Blue Flag",391,14;
  237. movenpc "Red Flag 1",392,15;
  238. movenpc "Blue Flag 1",392,14;
  239. //announce
  240. mapannounce "bat_b01", "The CTF game ended by a GM! You will be warped out in few seconds.",0;
  241. mapannounce "jupe_ele", "The CTF game ended by a GM",0;
  242. mapannounce "jupe_ele", getpartyname($BlueParty)+" (blue) "+$@bluescore+" : "+$@bluescore+" "+getpartyname($RedParty)+" (red)",0;
  243. //reset parties
  244. set $BlueParty,0;
  245. set $RedParty,0;
  246. //disable entrance warp
  247. disablenpc "CtfEntrance";
  248. //warp all players
  249. sleep 3000;
  250. mapwarp "bat_b01","jupe_ele",44,46;
  251. end;
  252.  
  253. }
  254.  
  255. jtf:
  256. mes "[CTF]";
  257.  
  258. //check base level
  259. if(BaseLevel < 40){
  260. mes "I'm afraid your Baselevel is not high enough to join the event! You need to be at least ^0000ffBaselevel 40^000000.";
  261. close;
  262. }
  263.  
  264. //check if game in progress
  265. if ($BlueParty > 0 && $RedParty > 0) {
  266. mes "There is already a game in progress. Please wait untill the game is over.";
  267. mes "Do you need some help?";
  268. next;
  269. if (select("Yes, what is CTF?:No, thanks") == 1)
  270. goto explain;
  271. close;
  272. }
  273.  
  274. set @pid, getcharid(1);
  275. getpartymember(@pid);
  276. set @partymembercount,$@partymembercount;
  277. if (@pid == 0 || @partymembercount != $Play_Limit) {
  278. mes "You need a ^0000ffparty of "+$Play_Limit+" people^000000 to participate!";
  279. mes "Do you need some help?";
  280. next;
  281. if (select("Yes, what is CTF?:No, thanks") == 1)
  282. goto explain;
  283. close;
  284. }
  285.  
  286. if (@pid == $BlueParty) {
  287. mes "Your party is already signed up as ^0000ffBlue Team^000000.";
  288. mes "Please note that if someone from your party leaves this map your subscription will be cancelled.";
  289. next;
  290. if (select("Okay!:Sign out") == 1)
  291. close;
  292. set $BlueParty,0;
  293. mes "Your party signed out.";
  294. close;
  295. }
  296.  
  297. if (@pid == $RedParty) {
  298. mes "Your party is already signed up as ^ff0000Red Team^000000.";
  299. next;
  300. if (select("Okay!:Sign out") == 1)
  301. close;
  302. set $RedParty,0;
  303. mes "Your party signed out.";
  304. close;
  305. }
  306.  
  307.  
  308. mes "Which team do you want to join with your party?";
  309. mes "Or do you need some help?";
  310. next;
  311.  
  312. pickteam:
  313. menu "^0000ffBlue Team^000000",joinblueteam,
  314. "^ff0000Red Team^000000",joinredteam,
  315. "What is CTF?",-;
  316. explain:
  317. mes "[CTF]";
  318. mes "CTF stands for ^0000ffCapture the Flag^000000. This is a game where ^0000fftwo parties of "+$Play_Limit+" people^000000 compete against each other";
  319. next;
  320. mes "[CTF]";
  321. mes "You can score by taking your enemy's flag and bring it to yours. You pick up a flag by aproaching it. When you die you respawn at the map but you drop the flag (if you caried it). Than the flag can be picked up by other players.";
  322. next;
  323. mes "[CTF]";
  324. mes "If you kill enemy player carying a flag (and pick it up) it will be recovered. Please note that you cannot score if your flag is not recovered.";
  325. next;
  326. mes "[CTF]";
  327. mes "A team that scores "+$Cap_Limit+" times wins the game.";
  328. mes "Currently there are no prizes for this game.";
  329. close;
  330.  
  331. joinblueteam:
  332. if ($BlueParty > 0) {
  333. mes "Sorry ^0000ffBlue Team^000000 is already taken.";
  334. goto pickteam;
  335. }
  336.  
  337. mes "[CTF]";
  338. mes "Your party is now subscribed as ^0000ffBlue Team^000000.";
  339. mes "Please note that if someone from your party leaves this map your subscription will be cancelled.";
  340.  
  341. set $BlueParty,@pid;
  342.  
  343. if ($RedParty > 0 && $BlueParty > 0)
  344. goto start_ctf;
  345. close;
  346.  
  347. joinredteam:
  348. if ($RedParty > 0) {
  349. mes "Sorry ^ff0000Red Team^000000 is already taken.";
  350. goto pickteam;
  351. }
  352.  
  353. mes "[CTF]";
  354. mes "Your party is now subscribed as ^ff0000Red Team^000000.";
  355. mes "Please note that if someone from your party leaves this map your subscription will be cancelled.";
  356.  
  357. set $RedParty,@pid;
  358.  
  359. if ($RedParty > 0 && $BlueParty > 0)
  360. goto start_ctf;
  361. close;
  362.  
  363. start_ctf:
  364. //Moving flags to original startpoint just incase
  365. movenpc "Blue Flag",329,149;
  366. movenpc "Red Flag",62,149;
  367. movenpc "Red Flag 1",319,14;
  368. movenpc "Blue Flag 1",319,15;
  369. close2;
  370. //announce the begining
  371. mapannounce "jupe_ele", "The CTF game will start in few moments!",0;
  372. sleep2 2000;
  373. mapannounce "jupe_ele", getpartyname($BlueParty)+" (blue) vs. "+getpartyname($RedParty)+" (red)",0;
  374. sleep 3000;
  375. mapannounce "jupe_ele", "Please use the nearby warp to enter the game!",0;
  376. //show warp to game
  377. enablenpc "CtfEntrance";
  378. end;
  379.  
  380. OnInit:
  381. disablenpc "CtfEntrance";
  382. }
  383.  
  384. //warp to enter CTF map
  385. jupe_ele,39,57,0 script CtfEntrance 45,1,2,{
  386. set @pid, getcharid(1);
  387. if (@pid == $BlueParty) {
  388. set BlueTeam, 1;
  389. set RedTeam, 0;
  390. set RedFlagTaken, 0;
  391. set BlueFlagTaken, 0;
  392. set normallook,(getlook(7));
  393. setlook 7, 78;
  394. savepoint "bat_b01",312,223;
  395. warp "bat_b01",312,223;
  396. close;
  397. }
  398. if (@pid == $RedParty) {
  399. set RedTeam, 1;
  400. set BlueTeam, 0;
  401. set RedFlagTaken, 0;
  402. set BlueFlagTaken, 0;
  403. set normallook,(getlook(7));
  404. setlook 7, 79;
  405. savepoint "bat_b01",87,74;
  406. warp "bat_b01",87,74;
  407. close;
  408. }
  409. mes "Sorry but you havent signed up for CTF!";
  410. close;
  411. }
  412.  
  413. // Base Flags
  414. bat_b01,62,149,5 script Red Flag 722,2,2,{
  415. end;
  416. OnTouch:
  417. if( BlueTeam == 1 ){ //Blue Team takes the Red Flag and disables and moves the flag
  418. set RedFlagTaken, 1;
  419. set Red_Flag_Carrier$,strcharinfo(0);
  420. mapannounce "bat_b01", strcharinfo(0) + " has taken the Red Flag",bc_map,0x0000FF;
  421. announce "Take the flag back to yours!",3,0x0000FF;
  422. setlook 7, 44;
  423. movenpc "Red Flag",391,15;
  424. disablenpc "Red Flag";
  425. }
  426.  
  427. if( BlueFlagTaken == 1 ){ //Red Team scores if PC has the variable "BlueFlagTaken"
  428. percentheal 100,0;
  429. mapannounce "bat_b01", "Red Team Scores!",bc_map,0xFF0000;
  430. set BlueFlagTaken, 0;
  431. set Blue_Flag_Carrier$,0;
  432. setlook 7, 79;
  433. enablenpc "Blue Flag";
  434. movenpc "Blue Flag",329,149;
  435. setd "$@redscore"+strcharinfo(1), getd("$@redscore"+strcharinfo(1))+1;
  436. if(getd("$@redscore"+strcharinfo(1)) >= $Cap_Limit){
  437. mapannounce "bat_b01","Red team has won the match!",bc_map,0xFF0000;
  438. setd "CTF_Winner"+strcharinfo(1),1;
  439. donpcevent "ctf_sys::OnCTFEndGame";
  440. }
  441. mapannounce "bat_b01","Red Score:" + getd("$@redscore"+strcharinfo(1)),bc_map,0xFF0000;
  442. }
  443. end;
  444. }
  445.  
  446.  
  447. bat_b01,329,149,5 script Blue Flag 722,2,2,{
  448. end;
  449. OnTouch:
  450. if( RedTeam == 1 ){ //Red Team takes the Blue Flag and disables and moves the flag
  451. mapannounce "bat_b01", strcharinfo(0) + " has taken the Blue Flag",bc_map,0xFF0000;
  452. announce "Take the flag back to yours!",3,0xFF0000;
  453. set BlueFlagTaken, 1;
  454. set Blue_Flag_Carrier$,strcharinfo(0);
  455. setlook 7, 44;
  456. movenpc "Blue Flag",391,14;
  457. disablenpc "Blue Flag";
  458. }
  459.  
  460. if( RedFlagTaken == 1){ //Blue Team scores if PC has the variable "RedFlagTaken"
  461. percentheal 100,0;
  462. mapannounce "bat_b01", "Blue Team Scores!",bc_map,0x0000FF;
  463. set RedFlagTaken, 0;
  464. set Red_Flag_Carrier$,0;
  465. setlook 7, 78;
  466. enablenpc "Red Flag";
  467. movenpc "Red Flag",62,149;
  468. setd "$@bluescore"+strcharinfo(1), getd("$@bluescore"+strcharinfo(1))+1;
  469. if(getd("$@bluescore"+strcharinfo(1)) >= $Cap_Limit){
  470. mapannounce "bat_b01","Blue team has won the match!",bc_map,0x0000FF;
  471. setd "CTF_Winner"+strcharinfo(1),1;
  472. donpcevent "ctf_sys::OnCTFEndGame";
  473. }
  474. mapannounce "bat_b01","Blue Score:" + getd("$@bluescore"+strcharinfo(1)),bc_map,0x0000FF;
  475. }
  476. end;
  477. }
  478.  
  479. //Non-Base Flags. Flags that appear when the Flag is dropped
  480. bat_b01,390,13,5 script Blue Flag 1 722,2,2,{
  481. end;
  482. OnTouch:
  483. if( RedTeam == 1 ){
  484. mapannounce "bat_b01",strcharinfo(0)+" has taken the Blue Flag",bc_map,0xFF0000;
  485. set BlueFlagTaken, 1;
  486. set Blue_Flag_Carrier$,strcharinfo(0);
  487. setlook 7, 44;
  488. movenpc "Blue Flag 1",390,13;
  489. disablenpc "Blue Flag";
  490. end;
  491. }
  492. if( BlueTeam == 1 ){
  493. mapannounce "bat_b01", strcharinfo(0)+" has returned the Blue Flag",bc_map,0x0000FF;
  494. enablenpc "Blue Flag";
  495. movenpc "Blue Flag",329,149;
  496. movenpc "Blue Flag 1",390,13;
  497. end;
  498. }
  499. end;
  500. }
  501.  
  502.  
  503. bat_b01,390,14,5 script Red Flag 1 722,2,2,{
  504. end;
  505. OnTouch:
  506. if( BlueTeam == 1 ){
  507. mapannounce "bat_b01", strcharinfo(0) + " has picked up the Red Flag",bc_map,0x0000FF;
  508. set RedFlagTaken, 1;
  509. set Red_Flag_Carrier$,strcharinfo(0);
  510. setlook 7, 44;
  511. movenpc "Red Flag 1",390,13;
  512. disablenpc "Red Flag";
  513. end;
  514. }
  515. if( RedTeam == 1 ){
  516. mapannounce "bat_b01",strcharinfo(0)+" has returned the Red Flag",bc_map,0xFF0000;
  517. enablenpc "Red Flag";
  518. movenpc "Red Flag",62,149;
  519. movenpc "Red Flag 1",390,14;
  520. end;
  521. }
  522. end;
  523. }
  524.  
  525.  
  526. //Precaution incase team variables reset upon respawn
  527. bat_b01,312,223,5 script Spawn#blue -111,7,7,{
  528. end;
  529. OnTouch:
  530. if( RedTeam == 1){
  531. end;
  532. }
  533. if( BlueFlagTaken == 1 ){
  534. end;
  535. }
  536. if( RedFlagTaken == 1 ){
  537. end;
  538. }
  539. if( BlueTeam <= 0 ){
  540. set BlueTeam, 1;
  541. end;
  542. }
  543. }
  544.  
  545. bat_b01,87,74,5 script Spawn#red -111,7,7,{
  546. end;
  547. OnTouch:
  548. if( BlueTeam == 1 ){
  549. end;
  550. }
  551. if( RedFlagTaken == 1 ){
  552. end;
  553. }
  554. if( BlueFlagTaken == 1 ){
  555. end;
  556. }
  557. if( RedTeam <= 1 ){
  558. set RedTeam, 1;
  559. end;
  560. }
  561. }
  562.  
  563. //Healers
  564.  
  565. //Red Healer
  566. bat_b01,93,82,5 script Red Healer 935,{
  567. if(RedTeam == 1){
  568. mes "[Red Healer]";
  569. mes "You look weak..want a heal?";
  570. mes "You look like a person who needs it";
  571. mes "Want it?";
  572. next;
  573. menu "Heal",-,"No thanks",CANCEL;
  574. percentheal 100,0;
  575. mes "[Healer]";
  576. mes "Ok, Here you go.";
  577. mes "Now get out there and kill!!";
  578. close;
  579. CANCEL:
  580. mes "[Red Healer]";
  581. mes "Allright, come back if you need a heal.";
  582. close;
  583. }
  584. end;
  585. }
  586.  
  587. //Blue Healer
  588. bat_b01,316,232,5 script Blue Healer 932,{
  589. if(BlueTeam == 1){
  590. mes "[Blue Healer]";
  591. mes "You look weak..want a heal?";
  592. mes "You look like a person who needs it";
  593. mes "Want it?";
  594. next;
  595. menu "Heal",-,"No thanks",CANCEL;
  596. percentheal 100,0;
  597. mes "[Healer]";
  598. mes "Ok, here you go.";
  599. mes "Now get out there and kill!!";
  600. close;
  601. CANCEL:
  602. mes "[Healer]";
  603. mes "Allright, come back if you need a heal.";
  604. close;
  605. }
  606. end;
  607. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement