Advertisement
Guest User

Captain_v2.0

a guest
Feb 19th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.79 KB | None | 0 0
  1. // [========================================================]
  2. // [============ Battle Arena - Captain ==========]
  3. // [========================================================]
  4. // [ Version 1 ]
  5. // [========================================================]
  6. // [ Original script by: Alayne ]
  7. // [========================================================]
  8. // [ Description: ]
  9. // [--------------------------------------------------------]
  10. // [ ]
  11. // [ - The Captain System ]
  12. // [========================================================]
  13. // [ Changelog: (5 last updates) ]
  14. // [--------------------------------------------------------]
  15. // [ ]
  16. // [ v0: Creation ]
  17. // [ ]
  18. // [ ]
  19. // [========================================================]
  20. // [ ]
  21. // [========================================================]
  22.  
  23. prontera,99,144,0 script CaptainManager::alabac HIDDEN_WARP_NPC,2,2,{
  24. end;
  25.  
  26. OnStartC:
  27. $captainon = 2;
  28. .teamRedScore = 0;
  29. .teamBlueScore = 0;
  30. .countTimer = 0;
  31. initnpctimer;
  32. callsub OnUpdateCaptainState;
  33. end;
  34.  
  35. OnEndC:
  36. if (.teamBlueScore == .teamRedScore)
  37. {
  38. announce "[Captain] It's a Draw with a score of " + .teamBlueScore + " to " + .teamRedScore + "! Congratulations everybody!",bc_all,0x0000FF;
  39.  
  40. for(.@i = 0; .@i<getarraysize($@cTeamBlue); .@i++)
  41. {
  42. if(attachrid($@cTeamBlue[.@i]))
  43. {
  44. charcommand "#fakename " + strcharinfo(0);
  45. bg_leave;
  46. .@cnt = CPOINTS / .rewardCnt[2];
  47. if(.@cnt < .rewardMin[2])
  48. .@cnt = .rewardMin[2];
  49. getitem .reward, .@cnt;
  50. Zeny = Zeny + $CEntryPrice * (maxCMemberCount - 1) / (getarraysize($@cTeamBlue) + getarraysize($@cTeamRed));
  51. }
  52. }
  53. for(.@i = 0; .@i<getarraysize($@cTeamRed); .@i++)
  54. {
  55. if(attachrid($@cTeamRed[.@i]))
  56. {
  57. charcommand "#fakename " + strcharinfo(0);
  58. bg_leave;
  59. .@cnt = CPOINTS / .rewardCnt[2];
  60. if(.@cnt < .rewardMin[2])
  61. .@cnt = .rewardMin[2];
  62. getitem .reward, .@cnt;
  63. Zeny = Zeny + $CEntryPrice * (maxCMemberCount - 1) / (getarraysize($@cTeamBlue) + getarraysize($@cTeamRed));
  64. }
  65. }
  66. }
  67. else if (.teamBlueScore > .teamRedScore)
  68. {
  69. announce "[Captain] Blue Team wins the Captain with a score of " + .teamBlueScore + " to " + .teamRedScore + "! Congratulations!",bc_all,0x0000FF;
  70. for(.@i = 0; .@i<getarraysize($@cTeamBlue); .@i++)
  71. {
  72. if(attachrid($@cTeamBlue[.@i]))
  73. {
  74. charcommand "#fakename " + strcharinfo(0);
  75. bg_leave;
  76. .@cnt = CPOINTS / .rewardCnt[0];
  77. if(.@cnt < .rewardMin[0])
  78. .@cnt = .rewardMin[0];
  79. getitem .reward, .@cnt;
  80. //share zeny price
  81. Zeny = Zeny + $CEntryPrice * (maxCMemberCount - 1) / getarraysize($@cTeamBlue);
  82. CPOINTS = CPOINTS + .pointPerVictory;
  83. Zeny = Zeny + CPOINTS * 10000;
  84. }
  85. }
  86. for(.@i = 0; .@i<getarraysize($@cTeamRed); .@i++)
  87. {
  88. if(attachrid($@cTeamRed[.@i]))
  89. {
  90. charcommand "#fakename " + strcharinfo(0);
  91. bg_leave;
  92. .@cnt = CPOINTS / .rewardCnt[1];
  93. if(.@cnt < .rewardMin[1])
  94. .@cnt = .rewardMin[1];
  95. getitem .reward, .@cnt;
  96. }
  97. }
  98. }
  99. else
  100. {
  101. announce "[Captain] Red Team wins the Captain with a score of " + .teamRedScore + " to " + .teamBlueScore + "! Congratulations!",bc_all,0x0000FF;
  102. for(.@i = 0; .@i<getarraysize($@cTeamRed); .@i++)
  103. {
  104. if(attachrid($@cTeamRed[.@i]))
  105. {
  106. charcommand "#fakename " + strcharinfo(0);
  107. bg_leave;
  108. .@cnt = CPOINTS / .rewardCnt[0];
  109. if(.@cnt < .rewardMin[0])
  110. .@cnt = .rewardMin[0];
  111. getitem .reward, .@cnt;
  112. //share zeny price
  113. Zeny = Zeny + $CEntryPrice * (maxCMemberCount - 1) / getarraysize($@cTeamRed);
  114. getitem .reward, CPOINTS / 10;
  115. CPOINTS = CPOINTS + .pointPerVictory;
  116. Zeny = Zeny + CPOINTS * 10000;
  117. }
  118. }
  119. for(.@i = 0; .@i<getarraysize($@cTeamBlue); .@i++)
  120. {
  121. if(attachrid($@cTeamBlue[.@i]))
  122. {
  123. charcommand "#fakename " + strcharinfo(0);
  124. bg_leave;
  125. .@cnt = CPOINTS / .rewardCnt[1];
  126. if(.@cnt < .rewardMin[1])
  127. .@cnt = .rewardMin[1];
  128. getitem .reward, .@cnt;
  129. }
  130. }
  131. }
  132. bg_destroy $@RedTeam_CM;
  133. bg_destroy $@blueTeam_CM;
  134. $captainon = 0;
  135. mapwarp $captainMap$,"prontera",156,191,0;
  136. end;
  137.  
  138. OnUpdateCaptainState:
  139. for(.@i = 0; .@i<getarraysize($@cTeamBlue); .@i++)
  140. {
  141. if(attachrid($@cTeamBlue[.@i]))
  142. {
  143. CAPTAIN = 1;
  144. }
  145. else
  146. {
  147. deletearray $@cTeamBlue[.@i], 1;
  148. }
  149. }
  150. for(.@i = 0; .@i<getarraysize($@cTeamRed); .@i++)
  151. {
  152. if(attachrid($@cTeamRed[.@i]))
  153. {
  154. CAPTAIN = 1;
  155. }
  156. else
  157. {
  158. deletearray $@cTeamRed[.@i], 1;
  159. }
  160. }
  161. .captainRedCount = getarraysize($@cTeamBlue);
  162. .captainBlueCount = getarraysize($@cTeamRed);
  163. return;
  164.  
  165. OnTimer10000:
  166. //every minute, check for members availability
  167. .countTimer = .countTimer + 1;
  168. if (.countTimer == $battleDuration)
  169. {
  170. goto OnEndC;
  171. }
  172. setnpctimer 0;
  173. end;
  174.  
  175. OnPCLoginEvent:
  176. CPOINTS = 0;
  177. end;
  178.  
  179. OnPCDieEvent:
  180. if (strcharinfo(3) == $captainMap$)
  181. {
  182. .@points = CAPTAIN == 0 ? 1 : 5;
  183. if (callfunc("CheckTeamRedPlayer", 1) == 1)
  184. {
  185. //killed player was in first team
  186. //increase team 2 score
  187. .teamBlueScore = .teamBlueScore + .@points;
  188. if(.@points == 5)
  189. {
  190. .captainRedCount = .captainRedCount - 1;
  191. if(.captainRedCount == 0)
  192. {
  193. mapannounce $captainMap$, "[Captain] All the Captains from Red Team died. New round start!",bc_all,0x0000FF;
  194. callsub OnUpdateCaptainState;
  195. }
  196. else
  197. {
  198. mapannounce $captainMap$, "[Captain] There's only " + .captainRedCount + " alive on Red Team!",bc_all,0x0000FF;
  199. }
  200. }
  201. addtimer 3000, strnpcinfo(3) + "::OnHealAfterDeath";
  202. }
  203. else if (callfunc("CheckTeamBluePlayer", 1) == 1)
  204. {
  205. //killed player was in second team
  206. //increase team 1 score
  207. .teamRedScore = .teamRedScore + .@points;
  208. if(.@points == 5)
  209. {
  210. .captainBlueCount = .captainBlueCount - 1;
  211. if(.captainBlueCount == 0)
  212. {
  213. mapannounce $captainMap$, "[Captain] All the Captains from Blue Team died. New round start!",bc_all,0x0000FF;
  214. callsub OnUpdateCaptainState;
  215. }
  216. else
  217. {
  218. mapannounce $captainMap$, "[Captain] There's only " + .captainBlueCount + " alive on Blue Team!",bc_all,0x0000FF;
  219. }
  220. }
  221. addtimer 3000, strnpcinfo(3) + "::OnHealAfterDeath";
  222. }
  223.  
  224. attachrid(killerrid);
  225. CPOINTS = CPOINTS + .@points;
  226. dispbottom "You've earn " + .@points + " points. Your current balance is " + CPOINTS;
  227.  
  228. bg_updatescore $captainMap$, .teamRedScore, .teamBlueScore;
  229. }
  230. end;
  231.  
  232. OnHealAfterDeath:
  233. dispbottom "[Valkyrie] You received the War Goddess benediction!";
  234. percentheal 100, 100;
  235. if(.buffs == 1)
  236. {
  237. specialeffect2 EF_INCREASEAGI; sc_start SC_INCREASEAGI,240000,10;
  238. specialeffect2 EF_BLESSING; sc_start SC_BLESSING,240000,10;
  239. }
  240. end;
  241.  
  242. OnBoardAsked:
  243. if($captainon == 2)
  244. {
  245. .@caller = getcharid(3);
  246.  
  247. .@found1 = callfunc("CheckTeamRedPlayer", 0);
  248. .@found2 = callfunc("CheckTeamBluePlayer", 0);
  249. .@found = .@found1 + .@found2;
  250. if(.@found >= 1)
  251. {
  252. .@caller = getcharid(3);
  253. dispbottom "!!Captain Points Board!!";
  254. dispbottom "";
  255. dispbottom "Team Red total Points ==> " + .teamRedScore;
  256. for(.@i = 0; .@i<getarraysize($@cTeamRed); .@i++)
  257. {
  258. .@attached = attachrid($@cTeamRed[.@i]);
  259. if (.@attached == 0)
  260. {
  261. deletearray $@cTeamRed[.@i], 1;
  262. }
  263. else
  264. {
  265. .@message$ = " ~" + strcharinfo(0) + ": " + CPOINTS;
  266. if(attachrid(.@caller))
  267. dispbottom .@message$;
  268. }
  269. }
  270.  
  271. dispbottom "";
  272. dispbottom "Team Blue total Points ==> " + .teamBlueScore;
  273. for(.@i = 0; .@i<getarraysize($@cTeamBlue); .@i++)
  274. {
  275. .@attached = attachrid($@cTeamBlue[.@i]);
  276. if (.@attached == 0)
  277. {
  278. deletearray $@cTeamBlue[.@i], 1;
  279. }
  280. else
  281. {
  282. .@message$ = " ~" + strcharinfo(0) + ": " + CPOINTS;
  283. if(attachrid(.@caller))
  284. dispbottom .@message$;
  285. }
  286. }
  287. }
  288. }
  289. end;
  290.  
  291. OnInit:
  292. // Config starts here ----------------------
  293. $maxCMemberCount = 10; // Max players to start (if 5v5, settings should be = 10)
  294. set $CEntryPrice, 0; // Zeny entry fee
  295. set .pointPerVictory, 100; // Points gained per victory
  296. .reward = 7773; // Reward ID
  297. setarray .rewardMin[0], 5, 1; // Reward amt <WIN TEA>, <LOSE TEAM>
  298. setarray .rewardCnt[0], 10, 20; // Reward count
  299. setarray $CDuration[0], 5, 10, 15; // Game time in minutes
  300. .buffs = 1; // Buff after death ( 1 = on ; 0 = off )
  301. // Config ends here --------------------------
  302.  
  303. $captainon = 0;
  304. $captainMap$ = "pvp_n_2-4";
  305. setarray $@cTeamBlue[0], 0;
  306. setarray $@cTeamRed[0], 0;
  307. setarray $warpPointRedCp[0], 163, 122;
  308. setarray $warpPointBlueCp[0], 36, 122;
  309. mapwarp $captainMap$,"prontera",156,191,0;
  310. bindatcmd "cboard", strnpcinfo(3) + "::OnBoardAsked";
  311. end;
  312. }
  313.  
  314. pvp_n_2-4 mapflag battleground 2
  315.  
  316. prontera,126,166,3 script Captain::alacent 4_M_ROKI2,{
  317. .@npcname$ = "[Leag]";
  318. mes .@npcname$;
  319. mes "Hello to you, " + strcharinfo(0);
  320. mes "I'm the Captain Manager.";
  321. mes "When you talk to me, you'll be able to setup or join an existing Captain.";
  322. next;
  323. mes .@npcname$;
  324. mes "Here's how a Captain works.";
  325. mes "First of all, this is a team match.";
  326. mes "A general party matching will be made when all players will be registered.";
  327. next;
  328. mes .@npcname$;
  329. mes "Once " + $maxCMemberCount + " will have join, the team matching will begin, and the match will start.";
  330. mes "This is not really an alone fight.";
  331. .@message$ = "";
  332. for(.@i = 0; .@i<getarraysize($CDuration); .@i++)
  333. {
  334. .@message$ = (.@i == 0 ? "" : (.@i == getarraysize($CDuration) - 1 ? ", or " : ", ")) + $CDuration[.@i];
  335. }
  336. mes "Each team will have a duration of " + .@message$ + " minutes to kill all the Captains of the other team.";
  337. mes "Normal kills gives points, but as long as a Captain is alive, the round continue.";
  338. mes "On the other hand, you're not prevented from killing or hurting your teammates.";
  339. mes "You can only differenciate them from color and name, as a fakename will be applied.";
  340. next;
  341. mes .@npcname$;
  342. if ($captainon == 2)
  343. {
  344. goto OnEnterAgain;
  345. }
  346. if ($captainon == 1)
  347. {
  348. if(callfunc("CheckCPlayers") == 1)
  349. {
  350. next;
  351. mes .@npcname$;
  352. mes "Be patient please. The Captain will start soon.";
  353. close;
  354. }
  355.  
  356. mes "So. Are you interested?";
  357. if (select("Join the currently running Captain","No, thanks") == 1)
  358. {
  359. callsub OnJoin, 1;
  360. }
  361. else
  362. {
  363. goto OnLeave;
  364. }
  365. }
  366. else if ($captainon == 0)
  367. {
  368. if (select("Start a new Captain","No, thanks") == 1)
  369. {
  370. callsub OnJoin, 0;
  371. }
  372. else
  373. {
  374. goto OnLeave;
  375. }
  376. }
  377. else
  378. {
  379. next;
  380. mes .@npcname$;
  381. mes "Sorry, it's too late for this battle. Come back later.";
  382. }
  383. close;
  384.  
  385. OnEnterAgain:
  386. .@found1 = callfunc("CheckTeamRedPlayer", 0);
  387. .@found2 = callfunc("CheckTeamBluePlayer", 0);
  388. .@found = .@found1 + .@found2;
  389. if(.@found >= 1)
  390. {
  391. mes "Get ready, I'll send you back.";
  392. if(.@found1 == 1)
  393. {
  394. warp $captainMap$, $warpPointRedCp[0], $warpPointRedCp[1];
  395. }
  396. else
  397. {
  398. warp $captainMap$, $warpPointBlueCp[0], $warpPointBlueCp[1];
  399. }
  400. }
  401. else
  402. {
  403. mes "You're not part of this Captain.";
  404. mes "Wait for another to begin, please.";
  405. }
  406. close;
  407.  
  408. OnJoin:
  409. .@mode = getarg(0);
  410. .@npcname$ = "[Leag]";
  411. next;
  412. mes .@npcname$;
  413. mes "Sure!";
  414. mes "It'll cost you " + $CEntryPrice + "z to enter.";
  415. if (Zeny < $CEntryPrice)
  416. {
  417. next;
  418. mes .@npcname$;
  419. mes "Sorry, but you lack some money...";
  420. close;
  421. }
  422. if (select("Here you are.","I'll get back") == 1)
  423. {
  424. next;
  425. mes .@npcname$;
  426. Zeny = Zeny - $CEntryPrice;
  427. mes "Allright.";
  428. if (.@mode == 0)
  429. {
  430. next;
  431. mes .@npcname$;
  432. mes "Now, choose a duration.";
  433. .@menu$ = "";
  434. for(.@i = 0; .@i<getarraysize($CDuration); .@i++)
  435. {
  436. .@menu$ = .@menu$ + (.@i == 0 ? "" : ":") + $CDuration[.@i] + " minutes";
  437. }
  438. .@choice = select(.@menu$) - 1;
  439. next;
  440. mes .@npcname$;
  441. mes "Allright, let's go for " + $CDuration[.@choice] + " minutes then.";
  442. }
  443. next;
  444. mes .@npcname$;
  445. mes "The team with the highest sum of points once the duration will be ellapsed will win.";
  446. mes "The reward will be the total amount paid by all players, divided between the team players.";
  447. mes "Also, there's an individual reward according to the number of kill a player may do.";
  448. if (.@mode == 0)
  449. {
  450. deletearray $@CMembers[0], getarraysize($@CMembers);
  451. deletearray $@cTeamRed[0], getarraysize($@cTeamRed);
  452. deletearray $@cTeamBlue[0], getarraysize($@cTeamBlue);
  453.  
  454. bg_destroy $@RedTeam_CM;
  455. bg_destroy $@blueTeam_CM;
  456.  
  457. bg_leave;
  458. bg_updatescore $captainMap$, 0, 0;
  459.  
  460. $@CMembers[0] = getcharid(3);
  461.  
  462. $captainon = 1;
  463. $battleDuration = $CDuration[.@choice];
  464. announce "[Captain] " + strcharinfo(0) + " just join the Captain. Who will come to fight him?",bc_all,0x0000FF;
  465. }
  466. else
  467. {
  468. bg_leave;
  469. $@CMembers[getarraysize($@CMembers)] = getcharid(3);
  470. if (getarraysize($@CMembers) < $maxCMemberCount)
  471. {
  472. announce "[Captain] " + strcharinfo(0) + " just join the Captain. Still " + ($maxCMemberCount - getarraysize($@CMembers)) + " fighters needed to begin!",bc_all,0x0000FF;
  473. }
  474. else
  475. {
  476. //start
  477. //build teams
  478. .@teamCount = $maxCMemberCount / 2;
  479. //warp first char
  480. announce "[Captain] The fight begins!", bc_all, 0x0000FF;
  481. .@warped = 0;
  482. $@RedTeam_CM = bg_create($captainMap$, $warpPointRedCp[0], $warpPointRedCp[1]);
  483. $@blueTeam_CM = bg_create($captainMap$, $warpPointBlueCp[0], $warpPointBlueCp[1]);
  484. for(.@i = 0; .@i<getarraysize($@CMembers); .@i++)
  485. {
  486. if (attachrid($@CMembers[.@i]) == 1)
  487. {
  488. CPOINTS = 0;
  489. getmapxy(.@map$, .@x, .@y, 0);
  490. savepoint .@map$, .@x, .@y;
  491. if (getarraysize($@cTeamRed) < .@teamCount)
  492. {
  493. $@cTeamRed[getarraysize($@cTeamRed)] = $@CMembers[.@i];
  494. bg_join($@RedTeam_CM);
  495. warp $captainMap$, $warpPointRedCp[0], $warpPointRedCp[1];
  496. }
  497. else if (getarraysize($@cTeamBlue) < .@teamCount)
  498. {
  499. $@cTeamBlue[getarraysize($@cTeamBlue)] = $@CMembers[.@i];
  500. bg_join($@blueTeam_CM);
  501. warp $captainMap$, $warpPointBlueCp[0], $warpPointBlueCp[1];
  502. }
  503. else
  504. {
  505. if(rand(0,1))
  506. {
  507. $@cTeamRed[getarraysize($@cTeamRed)] = $@CMembers[.@i];
  508. bg_join($@RedTeam_CM);
  509. warp $captainMap$, $warpPointRedCp[0], $warpPointRedCp[1];
  510. }
  511. else
  512. {
  513. $@cTeamBlue[getarraysize($@cTeamBlue)] = $@CMembers[.@i];
  514. bg_join($@blueTeam_CM);
  515. warp $captainMap$, $warpPointBlueCp[0], $warpPointBlueCp[1];
  516. }
  517. }
  518. }
  519. }
  520. donpcevent "alabac::OnStartC";
  521. }
  522. }
  523. }
  524. else
  525. {
  526. goto OnLeave;
  527. }
  528. close;
  529.  
  530. OnLeave:
  531. .@npcname$ = "[Leag]";
  532. next;
  533. mes .@npcname$;
  534. mes "Your choice!";
  535. close;
  536. }
  537.  
  538. function script CheckTeamRedPlayer {
  539. .@updateCap = getarg(0);
  540. for(.@i = 0; .@i<getarraysize($@cTeamRed) && .@found == 0; .@i++)
  541. {
  542. if($@cTeamRed[.@i] == getcharid(3))
  543. {
  544. if(.@updateCap)
  545. CAPTAIN = 0;
  546. return 1;
  547. }
  548. }
  549. return 0;
  550. }
  551.  
  552. function script CheckTeamBluePlayer {
  553. .@updateCap = getarg(0);
  554. for(.@i = 0; .@i<getarraysize($@cTeamBlue) && .@found == 0; .@i++)
  555. {
  556. if($@cTeamBlue[.@i] == getcharid(3))
  557. {
  558. if(.@updateCap)
  559. CAPTAIN = 0;
  560. return 1;
  561. }
  562. }
  563. return 0;
  564. }
  565.  
  566. function script CheckCPlayers {
  567. for(.@i = 0; .@i<getarraysize($@CMembers) && .@found == 0; .@i++)
  568. {
  569. if($@CMembers[.@i] == getcharid(3))
  570. {
  571. return 1;
  572. }
  573. }
  574. return 0;
  575. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement