Advertisement
Capuche

instance_time_round

May 8th, 2013
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.63 KB | None | 0 0
  1. //===== rAthena Script =======================================
  2. //= Instance
  3. //===== By: ==================================================
  4. //= Capuche
  5. //===== Current Version: =====================================
  6. //= 1.0
  7. //===== Compatible With: =====================================
  8. //= rAthena SVN
  9. //===== Description: =========================================
  10. //= Base on this request :
  11. //= http://rathena.org/board/topic/78529-instance-script/?hl=instance
  12. //----------------------------------------------------
  13. //= An instance on 1@guild (just make a map).
  14. //= Players must be in party.
  15. //= Spawn amount and ID of mob/difficulty/number of player in
  16. //= the party.
  17. //= Players have some time to kill the mobs each round. If
  18. //= they fail => end.
  19. //= Each round, they gain #hero_points.
  20. //============================================================
  21.  
  22. // ~~~~~ show time left in days, hours, minutes and seconds ~~~~~
  23. function script timeleft__ {
  24. if ( ( .@left = getarg(0) ) <= 0 ) return getarg(0);
  25. .@day = .@left / 86400;
  26. .@hour = .@left % 86400 / 3600;
  27. .@min = .@left % 3600 / 60;
  28. .@sec = .@left % 60;
  29. if ( .@day )
  30. return .@day +" day "+ .@hour +" hour";
  31. else if ( .@hour )
  32. return .@hour +" hour "+ .@min +" min";
  33. else if ( .@min )
  34. return .@min +" min "+ .@sec +" sec";
  35. else
  36. return .@sec +" sec";
  37. }
  38.  
  39.  
  40. prontera,152,178,3 script szfjkii 406,{
  41.  
  42. mes "- each difficulty have 10 levels",
  43. "- each difficulty have given time to finish the instance",
  44. "- for Normal: 30 minutes",
  45. "- for Hard: 45 minutes",
  46. "- for Nightmare: 60 minutes",
  47. "- for Hardcore: 90 minutes";
  48. next;
  49. // can re-enter if already generated
  50. if( instance_id(1) && getcharid(1) ) {
  51. if ( select( "Enter", "Cancel" ) -1 ) {
  52. mes "See ya.";
  53. close;
  54. }
  55. if ( has_instance( .map_inst$ ) == "" ) {
  56. mes "Your group is already registered at an other instance.";
  57. close;
  58. }
  59. getpartymember getcharid(1), 1;
  60. if ( $@partymembercount > .max_players ) {
  61. mes "Maximum of "+ .max_players +" members in the party";
  62. close;
  63. }
  64. // check job if a player is invited
  65. if( .same_job ) {
  66. .@self = getcharid(3);
  67. for( .@i = 0; .@i < $@partymembercount; .@i++ ) {
  68. if( isloggedin( $@partymemberaid[ .@i ], $@partymembercid[ .@i ] ) ) {
  69. attachrid( $@partymemberaid[ .@i ] );
  70. .@job_name$ = .@job_name$ + jobname(Class) +"|";
  71. }
  72. }
  73. attachrid( .@self );
  74. if( countstr( .@job_name$, jobname(Class) ) > 1 ) {
  75. mes "sorry there is 2 same job in the party, you can't enter.";
  76. close;
  77. }
  78. }
  79. // check delay if a player is invited
  80. for( .@i = 0; .@i < getarraysize( getd( ".char_id"+ getcharid(1) ) ); .@i++ )
  81. if( getd( ".char_id"+ getcharid(1) +"["+ .@i +"]" ) == getcharid(0) ) {
  82. .@pass = 1;
  83. break;
  84. }
  85. if( !.@pass ) {
  86. if( gettimetick(2) < Delay_instance ) {
  87. mes "sorry you must wait "+ callfunc( "timeleft__", Delay_instance - gettimetick(2) ) +" before enter";
  88. close;
  89. }
  90. .@size = getarraysize( getd( ".char_id"+ getcharid(1) ) );
  91. setd( ".char_id"+ getcharid(1) +"[ "+ .@size +" ]", getcharid(0) );
  92. Delay_instance = gettimetick(2) + 3600 * 3;
  93. }
  94. instance_announce instance_id(1), strcharinfo(0)+" of the party "+ getpartyname( getcharid(1) ) +" is entering in the instance.",bc_map;
  95. warp has_instance( .map_inst$ ),50,50;
  96. end;
  97. }
  98. if ( select ( "Normal", "Hard", "Hardcore", "Nightmare", "Leave" ) == 5 ) {// using @menu for instancing
  99. mes "See ya.";
  100. close;
  101. }
  102. else if( !getcharid(1) ) {
  103. mes "You need to be in party ( Maximum of "+ .max_players +" members ).";
  104. close;
  105. }
  106. // check delay of players in the party
  107. getpartymember getcharid(1), 1;
  108. getpartymember getcharid(1), 2;
  109. .@self = getcharid(3);
  110. for( .@i = 0; .@i < $@partymembercount; .@i++ ) {
  111. if( isloggedin( $@partymemberaid[ .@i ], $@partymembercid[ .@i ] ) ) {
  112. attachrid( $@partymemberaid[ .@i ] );
  113. if( gettimetick(2) < Delay_instance ) {
  114. .@name$ = strcharinfo(0);
  115. .@time = Delay_instance - gettimetick(2);
  116. attachrid( .@self );
  117. mes "sorry "+ .@name$ +" must wait "+ callfunc( "timeleft__", .@time ) +" before enter";
  118. close;
  119. }
  120. else if( compare( .@job_name$, jobname(Class) ) && .same_job ) {
  121. .@name$ = strcharinfo(0);
  122. .@job$ = jobname(Class);
  123. attachrid( .@self );
  124. mes "sorry, "+ .@name$ +" is "+ .@job$ +" and there is already a "+ .@job$ +" in the party";
  125. close;
  126. }
  127. .@job_name$ = .@job_name$ + jobname(Class) +"|";
  128. }
  129. }
  130. attachrid( .@self );
  131. if ( $@partymembercount > .max_players ) {
  132. mes "Maximum of "+ .max_players +" members in the party";
  133. close;
  134. }
  135. else if( getpartyleader( getcharid(1),2 ) != getcharid(0) ) {
  136. mes "I only talk to your leader.";
  137. close;
  138. }
  139. mes "If the instance is successfully generated all your party will be warp inside. Get ready";
  140. next;
  141.  
  142. .@inst_id = instance_create( .name_inst$,getcharid(1) );
  143. if( .@inst_id < 0 ){
  144. mes "Failed. Contact a GM.";
  145. close;
  146. }
  147. instance_attachmap( .map_inst$,.@inst_id );
  148. instance_set_timeout .timelimit[ @menu ], .timeidle, .@inst_id;
  149. instance_init .@inst_id;
  150. instance_attach .@inst_id;
  151. 'diff$ = .diff$[ @menu ];
  152. 'party_id = getcharid(1);
  153. 'time_inst = gettimetick(2) + .timelimit[ @menu ];
  154. 'inst_id = .@inst_id;
  155. 'max_players = .max_players;
  156. donpcevent instance_npcname( "Inst_cust" ) +"::Oninstancing";
  157. sleep2 50;
  158. getpartymember getcharid(1), 1;
  159. getpartymember getcharid(1), 2;
  160. .@self = getcharid(3);
  161. if( .same_job ) {
  162. .@job_name$ = "";
  163. for( .@i = 0; .@i < $@partymembercount; .@i++ ) {
  164. if( isloggedin( $@partymemberaid[ .@i ], $@partymembercid[ .@i ] ) ) {
  165. attachrid( $@partymemberaid[ .@i ] );
  166. .@job_name$ = .@job_name$ + jobname(Class) +"|";
  167. }
  168. }
  169. }
  170. // dispbottom .@job_name$;
  171. for( .@i = 0; .@i < $@partymembercount; .@i++ ) {
  172. if( isloggedin( $@partymemberaid[ .@i ], $@partymembercid[ .@i ] ) ) {
  173. attachrid( $@partymemberaid[ .@i ] );
  174. if( gettimetick(2) >= Delay_instance && countstr( .@job_name$, jobname(Class) ) <= 1 ) {
  175. Delay_instance = gettimetick(2) + 3600 * 3;
  176. .@size = getarraysize( getd( ".char_id"+ getcharid(1) ) );
  177. setd( ".char_id"+ getcharid(1) +"[ "+ .@size +" ]", getcharid(0) );
  178. warp has_instance( .map_inst$ ),50,50;
  179. }
  180. }
  181. }
  182. // warpparty has_instance( .map_inst$ ),50,50, getcharid(1);
  183. close;
  184. OnDelete:
  185. deletearray getd( ".char_id"+ getvariableofnpc( .party_id, "Inst_cust") );
  186. end;
  187. OnInit:
  188. .same_job = 1; // DON'T allow 2 same job to enter in the instance
  189. .map_inst$ = "1@guild"; // instance map's name
  190. .name_inst$ = "Custom instance"; // instance name display
  191. .timeidle = 300; // time (sec) to re-enter in the instance when all players outside
  192. .max_players = 4; // max players in the party
  193.  
  194. // time limit (sec) of the instance per level - Normal, Hard, Hardcore, Nightmare
  195. setarray .timelimit[ 1 ], 1800, 2700, 3600, 4500;
  196.  
  197. // Difficulty's names - Don't touch
  198. setarray .diff$[ 1 ], "Normal", "Hard", "Hardcore", "Nightmare";
  199. end;
  200. }
  201.  
  202. 1@guild,0,0,0 script Inst_cust -1,{
  203. function Countpartyonline;
  204. function Reward;
  205.  
  206. OnInit:
  207. .npc_enter$ = "szfjkii"; // name of the NPC to enter in the instance
  208. // Number ( monsters / round / difficulty ) initialized
  209. setarray .mob_init_Normal[ 1 ], 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;
  210. setarray .mob_init_Hard[ 1 ], 2, 3, 4, 5, 6, 7, 8, 9, 10, 12;
  211. setarray .mob_init_Hardcore[ 1 ], 3, 4, 5, 6, 7, 8, 9, 10, 11, 13;
  212. setarray .mob_init_Nightmare[ 1 ], 5, 6, 7, 8, 9, 10, 12, 14, 16, 20;
  213.  
  214. // Hero ( points / round / difficulty ) - using #hero_points variable
  215. setarray .hero_points_Normal[ 1 ], 100,110,120,130,140,150,160,170,180,200;
  216. setarray .hero_points_Hard[ 1 ], 120,140,160,180,200,220,240,260,280,300;
  217. setarray .hero_points_Hardcore[ 1 ], 150,180,210,240,270,300,330,360,390,420;
  218. setarray .hero_points_Nightmare[ 1 ], 200,250,300,350,400,450,500,550,600,700;
  219.  
  220. // Time (min) / round / difficulty
  221. setarray .time_Normal[ 1 ], 1,2,3,4,5,6,7,8,9,10;
  222. setarray .time_Hard[ 1 ], 2,4,6,8,10,12,14,16,18,20;
  223. setarray .time_Hardcore[ 1 ], 3,6,9,12,15,18,21,24,27,30;
  224. setarray .time_Nightmare[ 1 ], 4,8,12,16,20,24,28,32,36,40;
  225.  
  226. // Mob ID / round
  227. // Level : Normal
  228. setarray .mob_ID_Normal_round1[ 0 ], 1002,1005,1004;// poring, hornet, familiar
  229. setarray .mob_ID_Normal_round2[ 0 ], 1002,1005;
  230. setarray .mob_ID_Normal_round3[ 0 ], 1002,1005,1004;
  231. setarray .mob_ID_Normal_round4[ 0 ], 1002,1005,1004;
  232. setarray .mob_ID_Normal_round5[ 0 ], 1002,1005,1004,1005;
  233. setarray .mob_ID_Normal_round6[ 0 ], 1002,1005,1004;
  234. setarray .mob_ID_Normal_round7[ 0 ], 1002,1005,1004;
  235. setarray .mob_ID_Normal_round8[ 0 ], 1002,1005,1004;
  236. setarray .mob_ID_Normal_round9[ 0 ], 1002,1005,1004;
  237. setarray .mob_ID_Normal_round10[ 0 ], 1002,1005,1004;
  238. // Level : Hard
  239. setarray .mob_ID_Hard_round1[ 0 ], 1002,1005,1004;
  240. setarray .mob_ID_Hard_round2[ 0 ], 1002,1005,1004;
  241. setarray .mob_ID_Hard_round3[ 0 ], 1002,1005,1004;
  242. setarray .mob_ID_Hard_round4[ 0 ], 1002,1005,1004;
  243. setarray .mob_ID_Hard_round5[ 0 ], 1002,1005,1004;
  244. setarray .mob_ID_Hard_round6[ 0 ], 1002,1005,1004;
  245. setarray .mob_ID_Hard_round7[ 0 ], 1002,1005,1004;
  246. setarray .mob_ID_Hard_round8[ 0 ], 1002,1005,1004;
  247. setarray .mob_ID_Hard_round9[ 0 ], 1002,1005,1004;
  248. setarray .mob_ID_Hard_round10[ 0 ], 1002,1005,1004;
  249. // Level : Hardcore
  250. setarray .mob_ID_Hardcore_round1[ 0 ], 1002,1005,1004;
  251. setarray .mob_ID_Hardcore_round2[ 0 ], 1002,1005,1004;
  252. setarray .mob_ID_Hardcore_round3[ 0 ], 1002,1005,1004;
  253. setarray .mob_ID_Hardcore_round4[ 0 ], 1002,1005,1004;
  254. setarray .mob_ID_Hardcore_round5[ 0 ], 1002,1005,1004;
  255. setarray .mob_ID_Hardcore_round6[ 0 ], 1002,1005,1004;
  256. setarray .mob_ID_Hardcore_round7[ 0 ], 1002,1005,1004;
  257. setarray .mob_ID_Hardcore_round8[ 0 ], 1002,1005,1004;
  258. setarray .mob_ID_Hardcore_round9[ 0 ], 1002,1005,1004;
  259. setarray .mob_ID_Hardcore_round10[ 0 ], 1002,1005,1004;
  260. // Level : Nightmare
  261. setarray .mob_ID_Nightmare_round1[ 0 ], 1002,1005,1004;
  262. setarray .mob_ID_Nightmare_round2[ 0 ], 1002,1005,1004;
  263. setarray .mob_ID_Nightmare_round3[ 0 ], 1002,1005,1004;
  264. setarray .mob_ID_Nightmare_round4[ 0 ], 1002,1005,1004;
  265. setarray .mob_ID_Nightmare_round5[ 0 ], 1002,1005,1004;
  266. setarray .mob_ID_Nightmare_round6[ 0 ], 1002,1005,1004;
  267. setarray .mob_ID_Nightmare_round7[ 0 ], 1002,1005,1004;
  268. setarray .mob_ID_Nightmare_round8[ 0 ], 1002,1005,1004;
  269. setarray .mob_ID_Nightmare_round9[ 0 ], 1002,1005,1004;
  270. setarray .mob_ID_Nightmare_round10[ 0 ], 1002,1005,1004;
  271. .round_max = 10; // round max
  272. end;
  273.  
  274. // Instance start
  275. // --------------
  276. Oninstancing:
  277. sleep 10000;
  278. // New round
  279. // ---------
  280. LStart:
  281. 'round++;
  282. instance_announce 'inst_id, 'round + ( 'round % 10 == 1 ? "st" : ( 'round % 10 == 2 ? "nd" : ( 'round % 10 == 3 ? "rd" : "th" ) ) ) +" round in :", bc_map;
  283. for( .@i = 5; .@i > 0; .@i-- ) {
  284. instance_announce 'inst_id, .@i +"" ,bc_map;
  285. sleep 1000;
  286. }
  287. donpcevent instance_npcname( "Inst_cust" ) +"::OnTimevent";// initialize time limit for the round
  288. goto OnRound;
  289.  
  290. // Monster is dead : check player on map + reward if 0 mob
  291. // -------------------------------------------------------
  292. OnMobDead:
  293. if( instance_check_party( 'party_id,'max_players +1 ) ) {// check if there are more than 4 players in the party instance
  294. instance_announce 'inst_id, "To much players. End of instance.", bc_map;
  295. 'round = .round_max + 1;
  296. goto L_pr;
  297. }
  298. 'count = mobcount( strnpcinfo(4), instance_npcname( "Inst_cust", 'inst_id ) +"::OnMobDead" );
  299. instance_announce instance_id(0), 'count +" monsters left" ,bc_map;
  300. if( !'count ) {
  301. instance_announce 'inst_id, "All monsters on the "+ 'round + ( 'round % 10 == 1 ? "st" : ( 'round % 10 == 2 ? "nd" : ( 'round % 10 == 3 ? "rd" : "th" ) ) ) +" level have been defeated.", bc_map;
  302. Reward();// hero points / round / difficulty
  303. if( 'round == .round_max ) {
  304. 'round = .round_max + 1;
  305. goto L_end;
  306. }
  307. goto LStart;
  308. }
  309. end;
  310.  
  311. // Random (spawn / round / difficulty)
  312. // -----------------------------------
  313. OnRound:
  314. .@spawn = 'count = Countpartyonline() + getd( ".mob_init_"+ 'diff$ +"[ "+ 'round +" ]" );// spawn count = ( monster initialized / round / difficulty ) + number players online in party
  315. instance_announce 'inst_id, "you have "+ getd( ".time_"+ 'diff$ +"[ "+ 'round +" ]" ) +" min to finish this round in "+ 'diff$ +" mode. "+ .@spawn +" mobs are spawned",bc_map;
  316. while( .@spawn ) {// spawned ( monster / round / difficulty ) randomly
  317. .@rand = rand( 1,.@spawn );// number mobs
  318. .@spawn = .@spawn - .@rand;
  319. .@i = rand( getarraysize( getd( ".mob_ID_"+ 'diff$ +"_round"+ 'round ) ) );// ID mob
  320. monster "1@guild",0,0,"--ja--", getd( ".mob_ID_"+ 'diff$ +"_round"+ 'round +"[ "+ .@i +" ]" ), .@rand, instance_npcname( strnpcinfo(0),'inst_id )+"::OnMobDead";
  321. }
  322. end;
  323.  
  324. // End of instance
  325. // ---------------
  326. L_end:
  327. instance_announce 'inst_id, "Congratulation you have finished the instance in "+ callfunc( "timeleft__", 'time_inst - gettimetick(2) ), bc_map;
  328. OnTimevent:// time limit / round / difficulty
  329. awake instance_npcname( "Inst_cust" );
  330. if( 'round <= .round_max ) {
  331. sleep 1;
  332. 'tmp = 'round;
  333. sleep 1000 * 60 * getd( ".time_"+ 'diff$ +"[ "+ 'round +" ]" );
  334. if( 'round != 'tmp ) end;
  335. instance_announce 'inst_id, "you take to much time.", bc_map;
  336. }
  337. L_pr:
  338. instance_warpall "prontera", 152,178, 'inst_id;
  339. .party_id = 'party_id;
  340. donpcevent .npc_enter$ +"::OnDelete";
  341. sleep 500;
  342. instance_destroy 'inst_id;
  343. end;
  344.  
  345.  
  346. // Functions
  347. // ---------
  348. function Countpartyonline {
  349. getpartymember 'party_id, 1;
  350. getpartymember 'party_id, 2;
  351. for( .@i = 0; .@i < $@partymembercount; .@i++ ) {
  352. if( isloggedin( $@partymemberaid[ .@i ], $@partymembercid[ .@i ] ) && getarg( 0,1 ) ) .@j++;
  353. // else if( isloggedin( $@partymemberaid[ .@i ], $@partymembercid[ .@i ] ) && !getarg( 0,1 ) ) {
  354. // attachrid( $@partymemberaid[ .@i ] );
  355. // Delay_instance = gettimetick(2) + 3600 * 3;
  356. // }
  357. }
  358. return .@j;
  359. }
  360.  
  361. function Reward {
  362. getpartymember 'party_id, 1;
  363. getpartymember 'party_id, 2;
  364. .@tmp$ = strcharinfo(3);
  365. for( .@i = 0; .@i < $@partymembercount; .@i++ )
  366. if( isloggedin( $@partymemberaid[ .@i ], $@partymembercid[ .@i ] ) ) {
  367. attachrid( $@partymemberaid[ .@i ] );
  368. if( strcharinfo(3) == .@tmp$ ) {
  369. #hero_points = #hero_points + getd( ".hero_points_"+ 'diff$ +"[ "+ 'round +" ]" );
  370. dispbottom "Gained : "+ getd( ".hero_points_"+ 'diff$ +"[ "+ 'round +" ]" ) +" Hero Points. Total : "+ #hero_points;
  371. }
  372. }
  373. return;
  374. }
  375.  
  376. // function Delayparty {
  377. // Countpartyonline( 0 );
  378. // return;
  379. // }
  380.  
  381. }
  382.  
  383. 1@guild mapflag nowarp
  384. 1@guild mapflag partylock
  385. 1@guild mapflag nowarpto
  386. 1@guild mapflag noteleport
  387. 1@guild mapflag nosave SavePoint
  388. 1@guild mapflag nomemo
  389. 1@guild mapflag nobranch
  390. 1@guild mapflag monster_noteleport
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement