instancing.txt 5.5 KB

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