Advertisement
Sehrentos

rAthena npc script instance test

Apr 15th, 2015
524
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.53 KB | None | 0 0
  1. // ------------------------------------------
  2. // Testing Instance
  3. // ------------------------------------------
  4. // Made by: Sehrentos
  5. // ------------------------------------------
  6. // Date: 08-04-2015
  7. // ------------------------------------------
  8. // - 24 hours instance reset (todo)
  9. // - Kill monsters to spawn the boss
  10. // - Party shared loot
  11. //
  12. // Example how it works: https://youtu.be/iR4gO-TXJII
  13. //
  14. // Edit 'db/(pre-)re/instance_db.txt' to enable this custom instance.
  15. // 12,Testing instance,3600,prt_are01,149,121,prt_are01
  16. // ------------------------------------------
  17. prontera,155,163,4 script Instance Stone#1_test 406,{
  18. set .@party_id, getcharid(1);
  19. set .@party_name$, getpartyname(.@party_id);
  20. set .@instance_name$, "Testing instance";
  21.  
  22. // Check party
  23. if (!instance_check_party(.@party_id,1)) {
  24. mes "["+strnpcinfo(1)+"]";
  25. mes "Make or join a party with more than 1 member and try again.";
  26. mes "Instance: ^0000ff"+.@instance_name$+"^000000";
  27. close;
  28. }
  29.  
  30. // Create instance (party leader)
  31. if (getcharid(0) == getpartyleader(.@party_id,2)) {
  32. mes "["+strnpcinfo(1)+"]";
  33. mes "Confirmed the party has been made. Would you like to reserve entrance to the instance?";
  34. mes "Instance: ^0000ff"+.@instance_name$+"^000000";
  35. next;
  36. switch(select("Generate instance:Enter the instance:Cancel")) {
  37. case 1:
  38. // Check the instance timer(1 day)
  39. if (gettime(4) < test_timer) {//TODO -fix this
  40. mes "This instance has a 1 day expiration time (in server time).";
  41. mes "You still have to wait till tomorrow reset.";
  42. close;
  43. }
  44. mes "^0000ff"+.@instance_name$+"^000000 - Reserved";
  45. mes "Party Name: "+.@party_name$;
  46. mes "Party Leader: "+strcharinfo(0);
  47. mes "After making a reservation, you can enter the instance.";
  48. next;
  49. .@create = instance_create(.@instance_name$);
  50. if (.@create < 0) {
  51. mes "[Instance]";
  52. switch (.@create) {
  53. case -1: mes "ERROR: Invalid type."; break;
  54. case -2: mes "ERROR: Party not found."; break;
  55. case -3: mes "ERROR: Instance already exists."; break;
  56. case -4: mes "ERROR: No free instances."; break;
  57. }
  58. mes " ";
  59. mes "Instance creation ^FF0000failed^000000.";
  60. emotion e_omg;
  61. }
  62. close;
  63. case 2:
  64. callsub L_Enter,0,1;
  65. case 3:
  66. mes "["+strnpcinfo(1)+"]";
  67. mes "Instance ^0000ff"+.@instance_name$+"^000000 - Removed!";
  68. instance_destroy();
  69. close;
  70. }
  71. }
  72.  
  73. // Party members
  74. mes "["+strnpcinfo(1)+"]";
  75. mes "^0000ff"+.@instance_name$+"^000000 - Reserved";
  76. switch(select("Enter the instance:Cancel")) {
  77. case 1:
  78. // Check the instance timer(1 day)
  79. if (gettime(4) < test_timer) {//TODO -fix this
  80. mes "This instance has a 1 day expiration time (in server time).";
  81. mes "You still have to wait till tomorrow reset.";
  82. close;
  83. }
  84. callsub L_Enter,1,1;
  85. case 2:
  86. break;
  87. }
  88. close;
  89.  
  90. L_Enter:
  91. set test_timer, gettime(4); //Week day (0 for Sunday, 6 is Saturday)
  92. // Enter instance
  93. .@enter = instance_enter("Testing instance");
  94. if (.@enter != 0) {
  95. mes "["+strnpcinfo(1)+"]";
  96. switch (.@enter) {
  97. case 1: mes "ERROR: Party not found."; break;
  98. case 2: mes "ERROR: Party does not have an instance."; break;
  99. case 3: mes "ERROR: Unknown error."; break;
  100. }
  101. mes " ";
  102. mes "Instance entry ^FF0000failed^000000.";
  103. emotion e_omg;
  104. close;
  105. }
  106. if (getarg(0) == 0) close;
  107. else end;
  108.  
  109. P_Enter:
  110. //TODO -test these
  111. //warpparty instance_mapname("prt_are01"), 149, 121, getcharid(1);
  112. if (getcharid(1)) {
  113. getpartymember(getcharid(1),2);
  114. set .@partymembercount, $@partymembercount;
  115. copyarray .@partymemberaid[0], $@partymemberaid[0], .@partymembercount;
  116. for (set .@i, 0; .@i < .@partymembercount; set .@i, .@i + 1) {
  117. // Attach party member
  118. if (attachrid(.@partymemberaid[.@i])) {
  119. // Check if player is logged in, not vending or chatting (AFK)
  120. if (isloggedin(getcharid(3),getcharid(0)) && !checkvending() && !checkchatting()) {
  121. // Enter instance
  122. instance_enter("Testing instance");
  123. }
  124. }
  125. }
  126. }
  127. end;
  128.  
  129. }
  130.  
  131. // Instance start event NPC
  132. // - Add job-sprite based sprite id in 'db/mob_avail.txt' with this.
  133. //============================================================
  134. prt_are01,150,150,4 script TestEvent#start 106,{
  135. end;
  136. mes "["+strnpcinfo(1)+"]";
  137. mes "Hello, do you wan't to start the event?";
  138. if (select("Start the event")) {
  139. donpcevent instance_npcname("TestTimer#1_1")+"::OnEnable";
  140. message strcharinfo(0),"Event start!";
  141. close2;
  142. disablenpc instance_npcname(strnpcinfo(0));
  143. end;
  144. }
  145. close;
  146.  
  147. OnInit: // disable NPC on normal map
  148. disablenpc strnpcinfo(0);
  149. end;
  150.  
  151. OnDisable:
  152. disablenpc instance_npcname(strnpcinfo(0)); //Disable it self.
  153. end;
  154.  
  155. OnInstanceInit:
  156. enablenpc instance_npcname(strnpcinfo(0));
  157. waitingroom "Party - Waiting Room",(1 + 1),instance_npcname(strnpcinfo(0))+"::OnStart",1,0,10,99;
  158. end;
  159.  
  160. OnStart:
  161. .@speed = 100;
  162. .@distance = distance(150,150,150,124);
  163. .@sleep = (.@distance * .@speed); //.@distance * .@time_per_square_in_miliseconds
  164. kickwaitingroomall instance_npcname(strnpcinfo(0));
  165. delwaitingroom instance_npcname(strnpcinfo(0));
  166. mapannounce instance_mapname("prt_are01"),"Event will start. Get ready!",bc_map,"0x7799ff";
  167. npcspeed .@speed;
  168. npcwalkto 150,124; //NPC will move to a new position(beware of the blocks in the way)
  169. sleep .@sleep;
  170. donpcevent instance_npcname("TestTimer#1_1")+"::OnEnable";
  171. donpcevent instance_npcname(strnpcinfo(0))+"::OnDisable"; //Disable it self.
  172. end;
  173. }
  174.  
  175. // Set timers
  176. prt_are01,0,0,-1 script TestTimer#1_1 -1,{
  177. end;
  178.  
  179. OnInit: // disable NPC on normal map
  180. disablenpc strnpcinfo(0);
  181. end;
  182.  
  183. OnDisable:
  184. stopnpctimer;
  185. disablenpc instance_npcname(strnpcinfo(0)); //Disable it self.
  186. end;
  187.  
  188. OnEnable:
  189. enablenpc instance_npcname(strnpcinfo(0));
  190. mapannounce instance_mapname("prt_are01"),"[Event] Starting in 5 seconds.",bc_map,"0x7DCBF0";
  191. initnpctimer;
  192. end;
  193.  
  194. OnTimer1000:
  195. mapannounce instance_mapname("prt_are01"),"[Event] 5.",bc_map,"0x7DCBF0";
  196. end;
  197.  
  198. OnTimer2000:
  199. mapannounce instance_mapname("prt_are01"),"[Event] 4.",bc_map,"0x7DCBF0";
  200. end;
  201.  
  202. OnTimer3000:
  203. mapannounce instance_mapname("prt_are01"),"[Event] 3.",bc_map,"0x7DCBF0";
  204. end;
  205.  
  206. OnTimer4000:
  207. mapannounce instance_mapname("prt_are01"),"[Event] 2.",bc_map,"0x7DCBF0";
  208. end;
  209.  
  210. OnTimer5000:
  211. mapannounce instance_mapname("prt_are01"),"[Event] 1.",bc_map,"0x7DCBF0";
  212. end;
  213.  
  214. OnTimer6000:
  215. mapannounce instance_mapname("prt_are01"),"[Event] Start!",bc_map,"0x7DCBF0";
  216. donpcevent instance_npcname("TestSummonMonsters#1_1")+"::OnEnable";
  217. donpcevent instance_npcname(strnpcinfo(0))+"::OnDisable"; //Disable it self.
  218. end;
  219. }
  220.  
  221. // Summon normal monsters
  222. prt_are01,0,0,-1 script TestSummonMonsters#1_1 -1,{
  223. end;
  224.  
  225. OnInit: // disable NPC on normal map
  226. disablenpc strnpcinfo(0);
  227. end;
  228.  
  229. OnDisable:
  230. disablenpc instance_npcname(strnpcinfo(0)); //Disable it self.
  231. end;
  232.  
  233. OnEnable:
  234. enablenpc instance_npcname(strnpcinfo(0));
  235. .@map$ = instance_mapname("prt_are01");
  236. .@label$ = instance_npcname(strnpcinfo(0))+"::OnMobDead";
  237. // Summons
  238. areamonster .@map$,131,168,144,155,"Marin",1242,5,.@label$; //top-left
  239. areamonster .@map$,155,167,168,155,"Metaling",1613,5,.@label$; //top-right
  240. areamonster .@map$,144,155,144,131,"Poporing",1031,5,.@label$; //bottom-left
  241. areamonster .@map$,155,144,168,131,"Drops",1113,5,.@label$; //bottom-right
  242. end;
  243.  
  244. OnMobDead:
  245. if (mobcount(instance_mapname("prt_are01"), instance_npcname(strnpcinfo(0))+"::OnMobDead") < 1) {
  246. mapannounce instance_mapname("prt_are01"),"Boss incomming.....",bc_map,"0xFD3B02";
  247. donpcevent instance_npcname("TestSummonBoss#1_1")+"::OnEnable";
  248. donpcevent instance_npcname(strnpcinfo(0))+"::OnDisable"; //Disable it self.
  249. }
  250. end;
  251. }
  252.  
  253. // Summon boss
  254. prt_are01,150,150,-1 script TestSummonBoss#1_1 -1,{
  255. end;
  256.  
  257. OnInit: // disable NPC on normal map
  258. disablenpc strnpcinfo(0);
  259. end;
  260.  
  261. OnEnable:
  262. enablenpc instance_npcname(strnpcinfo(0));
  263. .@map$ = instance_mapname("prt_are01");
  264. .@label$ = instance_npcname(strnpcinfo(0))+"::OnBossDead";
  265. specialeffect EF_SUI_EXPLOSION;
  266. // Summons
  267. monster .@map$,150,150,"The Boss",1090,1,.@label$; //1502, Pori Pori, Bring it on!
  268. end;
  269.  
  270. OnDisable:
  271. disablenpc instance_npcname(strnpcinfo(0)); //Disable it self.
  272. end;
  273.  
  274. OnBossDead:
  275. //specialeffect2 EF_MVP; //This effect will be triggered on the player who dealt the killing blow.
  276. mapannounce instance_mapname("prt_are01"),"Boss is dead!",bc_map,"0xFD3B02";
  277. killmonster instance_mapname("prt_are01"),instance_npcname(strnpcinfo(0))+"::OnBossDead"; //Clean up
  278.  
  279. // Make party rewarding loop here and disable npc after it.
  280. if (getcharid(1)) {
  281. getpartymember(getcharid(1),2);
  282. set .@partymembercount, $@partymembercount;
  283. copyarray .@partymemberaid[0], $@partymemberaid[0], .@partymembercount;
  284. for (set .@i, 0; .@i < .@partymembercount; set .@i, .@i + 1) {
  285. // Attach party member
  286. if (attachrid(.@partymemberaid[.@i])) {
  287. // Check if player is logged in, not vending or chatting
  288. if (isloggedin(getcharid(3),getcharid(0)) && !checkvending() && !checkchatting()) {
  289.  
  290. // Effects
  291. specialeffect2 EF_MVP;
  292. // Rewards:
  293. set #CASHPOINTS, #CASHPOINTS + 5;
  294. message strcharinfo(0), "+5 Cash Point!";
  295. // 50% change to get a Carrot! Yumy... For the Powaa!!
  296. if (rand(100) >= 50) {
  297. getitem 515,1;
  298. }
  299.  
  300. }
  301. }
  302. }
  303. } else {
  304. // Solo reward...
  305. // This is a group event but hey, if party gets removed
  306. // And yeah you don't get the Carrot this time!
  307. specialeffect2 EF_MVP;
  308. set #CASHPOINTS, #CASHPOINTS + 5;
  309. message strcharinfo(0), "+5 Cash Point!";
  310. }
  311.  
  312. // Enable portal npc at the center of the room.
  313. donpcevent instance_npcname("#TestPortalOut")+"::OnEnable";
  314.  
  315. // Disable it self.
  316. donpcevent instance_npcname(strnpcinfo(0))+"::OnDisable";
  317. end;
  318. }
  319.  
  320. // Warp portal out side
  321. prt_are01,150,150,0 script #TestPortalOut WARPNPC,2,2,{
  322. end;
  323.  
  324. OnInit: // disable NPC on normal map
  325. disablenpc strnpcinfo(0);
  326. end;
  327.  
  328. OnInstanceInit:
  329. disablenpc instance_npcname(strnpcinfo(0));
  330. end;
  331.  
  332. OnEnable:
  333. mapannounce instance_mapname("prt_are01"),"[Portal] The portal to out side will be opening at the center of the room.",bc_map,"0x7799ff";
  334. initnpctimer;
  335. end;
  336.  
  337. OnDisable:
  338. stopnpctimer;
  339. disablenpc instance_npcname(strnpcinfo(0));
  340. end;
  341.  
  342. OnTimer10000:
  343. mapannounce instance_mapname("prt_are01"),"[Portal] The portal to out side is now open.",bc_map,"0x7799ff";
  344. enablenpc instance_npcname(strnpcinfo(0));
  345. stopnpctimer;
  346. end;
  347.  
  348. OnTouch:
  349. //warp "Save", 0, 0;
  350. warp "prontera", 156, 167;
  351. end;
  352. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement