instancing.txt 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. //===== rAthena Script =======================================
  2. //= Sample: Instancing
  3. //===== By: ==================================================
  4. //= Euphy
  5. //===== Last Updated: ========================================
  6. //= 20140129
  7. //===== Description: =========================================
  8. //= Contains elements of a basic instance script.
  9. //============================================================
  10. // Before running this script, add the entry below to
  11. // 'db/(pre-)re/instance_db.txt':
  12. // 100,Abyss Lake Instance,3600,300,abyss_03,160,155
  13. // Instance Creation
  14. //============================================================
  15. prontera,151,190,6 script Sample Instance 101,{
  16. .@instance$ = "Abyss Lake Instance";
  17. if (instance_live_info(ILI_NAME, instance_id(IM_PARTY)) == .@instance$) { // the instance "Abyss Lake Instance" is running
  18. mes "[Sample Instance]";
  19. mes "You are already part of an instance.";
  20. next;
  21. switch(select("Enter Instance.:Cancel.")) {
  22. case 1:
  23. break;
  24. case 2:
  25. mes "[Sample Instance]";
  26. mes "You don't want to try again?";
  27. emotion ET_CRY;
  28. close;
  29. }
  30. }
  31. else if (instance_id(IM_PARTY)) { // another instance is running
  32. mes "[Sample Instance]";
  33. mes "You are part of the instance " + instance_live_info(ILI_NAME, instance_id(IM_PARTY)) + ".";
  34. close;
  35. }
  36. else {
  37. mes "[Sample Instance]";
  38. mes "Would you like to try the sample instance in Abyss Lake 3?";
  39. next;
  40. switch(select("Create Instance.:Cancel.")) {
  41. case 1:
  42. .@create = instance_create(.@instance$);
  43. if (.@create < 0) {
  44. mes "[Sample Instance]";
  45. switch (.@create) {
  46. case -1: mes "ERROR: Invalid type."; break;
  47. case -2: mes "ERROR: Party not found."; break;
  48. case -3: mes "ERROR: Instance already exists."; break;
  49. case -4: mes "ERROR: No free instances."; break;
  50. }
  51. mes " ";
  52. mes "Instance creation ^FF0000failed^000000.";
  53. emotion ET_HUK;
  54. close;
  55. }
  56. mes "[Sample Instance]";
  57. mes "Instance created.";
  58. mes " ";
  59. mes "Now entering the instance...";
  60. next;
  61. break;
  62. case 2:
  63. mes "[Sample Instance]";
  64. mes "Okay. Maybe next time!";
  65. close;
  66. }
  67. }
  68. .@enter = instance_enter(.@instance$);
  69. if (.@enter != 0) {
  70. mes "[Sample Instance]";
  71. switch (.@enter) {
  72. case 1: mes "ERROR: Party not found."; break;
  73. case 2: mes "ERROR: Party does not have an instance."; break;
  74. case 3: mes "ERROR: Unknown error."; break;
  75. }
  76. mes " ";
  77. mes "Instance entry ^FF0000failed^000000.";
  78. emotion ET_HUK;
  79. close;
  80. }
  81. close;
  82. }
  83. // Instance Scripts
  84. //============================================================
  85. abyss_03,154,159,6 script Instance NPC#start 101,{
  86. mes "[Instance NPC]";
  87. mes "Are you ready to begin?";
  88. next;
  89. switch(select("Yes.:No.")) {
  90. case 1:
  91. mes "[Instance NPC]";
  92. mes "Good luck.";
  93. close2;
  94. donpcevent instance_npcname("#ins_abyss03_mobs")+"::OnEnable";
  95. delwaitingroom;
  96. disablenpc instance_npcname(strnpcinfo(0));
  97. end;
  98. case 2:
  99. mes "[Instance NPC]";
  100. mes "Take your time.";
  101. close;
  102. }
  103. end;
  104. OnInit: // hide the NPC on the normal map
  105. disablenpc strnpcinfo(0);
  106. end;
  107. OnInstanceInit: // initialize the NPC when the instance is created
  108. disablenpc instance_npcname("abysslakedunwarp004"); // disable original warp portal (currently buggy)
  109. waitingroom "Click here to start!",0;
  110. end;
  111. }
  112. abyss_03,0,0,0 script #ins_abyss03_mobs -1,{
  113. end;
  114. OnEnable:
  115. initnpctimer;
  116. end;
  117. OnTimer1000: //strnpcinfo(4) will retrieve the instanced map name
  118. mapannounce strnpcinfo(4),"Instance NPC: The Abyss Lake instance has begun.",bc_all;
  119. end;
  120. OnTimer4000:
  121. mapannounce strnpcinfo(4),"Instance NPC: Smash the Treasure Chest in the center of the map for a prize.",bc_all;
  122. end;
  123. OnTimer5000:
  124. stopnpctimer;
  125. // spawn mobs
  126. .@map$ = instance_mapname("abyss_03");
  127. .@label$ = instance_npcname(strnpcinfo(0))+"::OnMyMobDead";
  128. .@label_boss$ = instance_npcname(strnpcinfo(0))+"::OnMyBossDead";
  129. monster .@map$,0,0,"Huge Poring",1002,20,.@label$,2;
  130. monster .@map$,0,0,"Huge Drops",1113,15,.@label$,2;
  131. monster .@map$,0,0,"Huge Poporing",1031,10,.@label$,2;
  132. monster .@map$,0,0,"Huge Marin",1242,10,.@label$,2;
  133. monster .@map$,0,0,"Tiny Zombie",1015,30,.@label$,1;
  134. monster .@map$,0,0,"Huge Mime Monkey",1585,2,.@label$,2;
  135. monster .@map$,97,102,"Treasure Chest",1732,1,.@label_boss$,2;
  136. end;
  137. OnMyMobDead: // normal mobs
  138. dispbottom "What am I doing? I should be attacking the Treasure Chest!";
  139. viewpoint 0,97,102,0,0xFF0000;
  140. switch (rand(6)) { // for fun (:
  141. case 0: sc_start SC_STONE,5000,0; break;
  142. case 1: sc_start SC_FREEZE,5000,0; break;
  143. case 2: sc_start SC_STUN,5000,0; break;
  144. case 3: sc_start SC_SLEEP,5000,0; break;
  145. case 4: sc_start SC_CONFUSION,5000,0; break;
  146. case 5: sc_start SC_BLIND,5000,0; break;
  147. }
  148. end;
  149. OnMyBossDead: // treasure chest
  150. specialeffect2 EF_MVP;
  151. getitem 512,1; //Apple
  152. // trigger other events
  153. .@map$ = instance_mapname("abyss_03");
  154. .@label$ = instance_npcname(strnpcinfo(0))+"::OnMyMobDead";
  155. killmonster .@map$,.@label$;
  156. mapannounce .@map$,"Instance NPC: Good work! Please speak to me as soon as possible.",bc_all;
  157. donpcevent instance_npcname("Instance NPC#finish")+"::OnEnable";
  158. end;
  159. }
  160. abyss_03,97,102,4 script Instance NPC#finish 101,{
  161. mes "[Instance NPC]";
  162. mes "Congratulations! You've finished the instance.";
  163. mes "I'll send you back to town now.";
  164. emotion ET_BEST;
  165. close2;
  166. warp "prontera",156,191;
  167. instance_destroy();
  168. end;
  169. OnInit:
  170. disablenpc strnpcinfo(0);
  171. end;
  172. OnInstanceInit:
  173. disablenpc instance_npcname(strnpcinfo(0));
  174. end;
  175. OnEnable:
  176. enablenpc instance_npcname(strnpcinfo(0));
  177. specialeffect EF_HIDING;
  178. end;
  179. }
  180. abyss_03,115,26,0 script #ins_abyss03_warp 45,5,5,{
  181. end;
  182. OnTouch:
  183. mes "Are you sure you want to leave?";
  184. next;
  185. switch(select("Leave.:Stay.")) {
  186. case 1:
  187. warp "prontera",156,191;
  188. break;
  189. case 2:
  190. warp strnpcinfo(4),160,155;
  191. break;
  192. }
  193. close;
  194. OnInit:
  195. disablenpc strnpcinfo(0);
  196. end;
  197. }