ManokStreZ

npc quest

Mar 5th, 2021
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.16 KB | None | 0 0
  1. //===== rAthena Script =======================================
  2. //= Euphy's Quest Shop
  3. //===== By: ==================================================
  4. //= Euphy
  5. //===== Current Version: =====================================
  6. //= 1.6c
  7. //===== Compatible With: =====================================
  8. //= rAthena Project
  9. //===== Description: =========================================
  10. //= A dynamic quest shop based on Lunar's, with easier config.
  11. //= Includes support for multiple shops & cashpoints.
  12. //= Item Preview script by ToastOfDoom.
  13. //===== Additional Comments: =================================
  14. //= 1.0 Initial script.
  15. //= 1.2 Added category support.
  16. //= 1.3 More options and fixes.
  17. //= 1.4 Added debug settings.
  18. //= 1.5 Replaced categories with shop IDs.
  19. //= 1.6 Added support for purchasing stackables.
  20. //= 1.6a Added support for previewing costumes and robes.
  21. //= 1.6b Added 'disable_items' command.
  22. //= 1.6c Replaced function 'A_An' with "F_InsertArticle".
  23. //============================================================
  24.  
  25. // Shop NPCs -- supplying no argument displays entire menu.
  26. // callfunc "qshop"{,<shop ID>{,<shop ID>{,...}}};
  27. // ADD YOUR NPC HERE
  28. //============================================================
  29. ra_temsky,102,147,5 script Misc 848,{ callfunc "qshop"; }
  30. // prontera,165,203,6 script Quest Shop#2 998,{ callfunc "qshop",1,2; } // call the shop 1 and 2 defined below
  31. // etc.. Add your Shop NPCs 'Quest Shop#XXX' here
  32. //============================================================
  33.  
  34. // Dummy shop data -- copy as needed.
  35. //============================================================
  36. - shop qshop1 -1,909:-1
  37. - shop qshop2 -1,909:-1
  38. - shop qshop3 -1,909:-1
  39. - shop qshop4 -1,909:-1
  40. - shop qshop5 -1,909:-1
  41.  
  42. // Script Core - DO NOT DUPLICATE THIS NPC !!!!!!!!!!!!!
  43. //============================================================
  44. - script quest_shop -1,{
  45. function Add; function Chk; function Slot;
  46. OnInit:
  47. freeloop(1);
  48.  
  49. // -----------------------------------------------------------
  50. // Basic shop settings.
  51. // -----------------------------------------------------------
  52.  
  53. set .Announce,1; // Announce quest completion? (1: yes / 0: no)
  54. set .ShowSlot,1; // Show item slots? (2: all equipment / 1: if slots > 0 / 0: never)
  55. set .ShowID,0; // Show item IDs? (1: yes / 0: no)
  56. set .ShowZeny,0; // Show Zeny cost, if any? (1: yes / 0: no)
  57. set .MaxStack,100; // Max number of quest items purchased at one time.
  58.  
  59. // -----------------------------------------------------------
  60. // Points variable -- optional quest requirement.
  61. // setarray .Points$[0],"<variable name>","<display name>";
  62. // -----------------------------------------------------------
  63.  
  64. setarray .Points$[0],
  65. "#CASHPOINTS", "Cash Points";
  66.  
  67.  
  68. //=====================================================================================
  69. // ------------------- ADD YOUR SHOPS NAME AND ITEMS SHOPS STARTING HERE --------------
  70. //=====================================================================================
  71.  
  72. // -----------------------------------------------------------
  73. // Shop IDs -- to add shops, copy dummy data at bottom of file.
  74. // setarray .Shops$[1],"<Shop 1>","<Shop 2>"{,...};
  75. // -----------------------------------------------------------
  76.  
  77. setarray .Shops$[1],
  78. "Eden Weapons", // Shop Named 1
  79.  
  80. // -----------------------------------------------------------
  81. // Quest items -- do NOT use a reward item more than once!
  82. // Add(<shop ID>,<reward ID>,<reward amount>,
  83. // <Zeny cost>,<point cost>,
  84. // <required item ID>,<required item amount>{,...});
  85. // -----------------------------------------------------------
  86.  
  87. // Shop 1
  88. Add(1,5022,1,0,0,7086,1,969,10,999,40,1003,50,984,2);
  89. Add(1,5032,1,0,0,1059,250,2221,1,2227,1,7063,600);
  90. Add(1,5027,1,0,0,2252,1,1036,400,7001,50,4052,1);
  91. Add(1,5045,1,0,0,2252,1,1054,450,943,1200);
  92.  
  93.  
  94. // -----------------------------------------------------------
  95.  
  96. //=====================================================================================
  97. // ------------------- YOUR SHOPS AND ITEMS SHOPS HAVE BEEN ADDED ---------------------
  98. //=====================================================================================
  99.  
  100. freeloop(0);
  101. set .menu$,"";
  102. for(set .@i,1; .@i<=getarraysize(.Shops$); set .@i,.@i+1) {
  103. set .menu$, .menu$+.Shops$[.@i]+":";
  104. npcshopdelitem "qshop"+.@i,4320,4285,40190,40191,40192,40193,40194,40195,2629;
  105. }
  106. end;
  107.  
  108. OnMenu:
  109. set .@size, getarraysize(@i);
  110. if (!.@size) set @shop_index, select(.menu$);
  111. else if (.@size == 1) set @shop_index, @i[0];
  112. else {
  113. for(set .@j,0; .@j<.@size; set .@j,.@j+1)
  114. set .@menu$, .@menu$+.Shops$[@i[.@j]]+":";
  115. set @shop_index, @i[select(.@menu$)-1];
  116. }
  117. deletearray @i[0],getarraysize(@i);
  118. if (.Shops$[@shop_index] == "") {
  119. message strcharinfo(0),"An error has occurred.";
  120. end;
  121. }
  122. dispbottom "Select one item at a time.";
  123. callshop "qshop"+@shop_index,1;
  124. npcshopattach "qshop"+@shop_index;
  125. end;
  126.  
  127. OnBuyItem:
  128. // .@q[] : RewardID, BoughtAmt, RewardAmt, BaseAmt, ReqZeny, ReqPts, { ReqItem, ReqAmt, ... }
  129. setarray .@q[0],@bought_nameid[0],((@bought_quantity[0] > .MaxStack)?.MaxStack:@bought_quantity[0]);
  130. copyarray .@q[3],getd(".q_"+@shop_index+"_"+.@q[0]+"[0]"),getarraysize(getd(".q_"+@shop_index+"_"+.@q[0]));
  131. set .@q[2],.@q[1]*.@q[3];
  132. if (!.@q[2] || .@q[2] > 30000) {
  133. message strcharinfo(0),"You can't purchase that many "+getitemname(.@q[0])+".";
  134. end;
  135. }
  136. mes "[Quest Shop]";
  137. mes "Reward: ^0055FF"+((.@q[2] > 1)?.@q[2]+"x ":"")+Slot(.@q[0])+"^000000";
  138. mes "Requirements:";
  139. disable_items;
  140. if (.@q[4]) mes " > "+Chk(Zeny,.@q[4]*.@q[1])+(.@q[4]*.@q[1])+" Zeny^000000";
  141. if (.@q[5]) mes " > "+Chk(getd(.Points$[0]),.@q[5]*.@q[1])+(.@q[5]*.@q[1])+" "+.Points$[1]+" ("+getd(.Points$[0])+"/"+(.@q[5]*.@q[1])+")^000000";
  142. if (.@q[6]) for(set .@i,6; .@i<getarraysize(.@q); set .@i,.@i+2)
  143. mes " > "+Chk(countitem(.@q[.@i]),.@q[.@i+1]*.@q[1])+((.ShowID)?"{"+.@q[.@i]+"} ":"")+Slot(.@q[.@i])+" ("+countitem(.@q[.@i])+"/"+(.@q[.@i+1]*.@q[1])+")^000000";
  144. next;
  145. setarray @qe[1], getiteminfo(.@q[0],5), getiteminfo(.@q[0],11);
  146. if (@qe[2] > 0 && ((@qe[1] & EQP_HEAD_LOW) || (@qe[1] & EQP_HEAD_TOP) || (@qe[1] & EQP_HEAD_MID) || (@qe[1] & EQP_COSTUME_HEAD_TOP) || (@qe[1] & EQP_COSTUME_HEAD_MID) || (@qe[1] & EQP_COSTUME_HEAD_LOW) || (@qe[1] & EQP_GARMENT) || (@qe[1] & EQP_COSTUME_GARMENT)))
  147. set .@preview,1;
  148. addtimer 1000, strnpcinfo(0)+"::OnEnd";
  149. while(1) {
  150. switch(select(" ~ Purchase ^0055FF"+getitemname(.@q[0])+"^000000:"+((.@preview && !@qe[7])?" ~ Preview...":"")+": ~ ^777777Cancel^000000")) {
  151. case 1:
  152. if (@qe[0]) {
  153. mes "[Quest Shop]";
  154. mes "You're missing one or more quest requirements.";
  155. close;
  156. }
  157. if (!checkweight(.@q[0],.@q[2])) {
  158. mes "[Quest Shop]";
  159. mes "^FF0000You need "+(((.@q[2]*getiteminfo(.@q[0],6))+Weight-MaxWeight)/10)+" additional weight capacity to complete this trade.^000000";
  160. close;
  161. }
  162. if (.@q[4]) set Zeny, Zeny-(.@q[4]*.@q[1]);
  163. if (.@q[5]) setd .Points$[0], getd(.Points$[0])-(.@q[5]*.@q[1]);
  164. if (.@q[6]) for(set .@i,6; .@i<getarraysize(.@q); set .@i,.@i+2)
  165. delitem .@q[.@i],.@q[.@i+1]*.@q[1];
  166. getitem .@q[0],.@q[2];
  167. if (.Announce) announce strcharinfo(0)+" has created "+((.@q[2] > 1)?.@q[2]+"x "+getitemname(.@q[0]):callfunc("F_InsertArticle",getitemname(.@q[0])))+"!",0;
  168. specialeffect2 EF_FLOWERLEAF;
  169. close;
  170. case 2:
  171. setarray @qe[3], getlook(LOOK_HEAD_BOTTOM), getlook(LOOK_HEAD_TOP), getlook(LOOK_HEAD_MID), getlook(LOOK_ROBE), 1;
  172. if ((@qe[1] & 1) || (@qe[1] & 4096)) changelook LOOK_HEAD_BOTTOM, @qe[2];
  173. else if ((@qe[1] & 256) || (@qe[1] & 1024)) changelook LOOK_HEAD_TOP, @qe[2];
  174. else if ((@qe[1] & 512) || (@qe[1] & 2048)) changelook LOOK_HEAD_MID, @qe[2];
  175. else if ((@qe[1] & 4) || (@qe[1] & 8192)) changelook LOOK_ROBE, @qe[2];
  176. break;
  177. case 3:
  178. close;
  179. }
  180. }
  181.  
  182. OnEnd:
  183. if (@qe[7]) {
  184. changelook LOOK_HEAD_BOTTOM, @qe[3];
  185. changelook LOOK_HEAD_TOP, @qe[4];
  186. changelook LOOK_HEAD_MID, @qe[5];
  187. changelook LOOK_ROBE, @qe[6];
  188. }
  189. deletearray @qe[0],8;
  190. end;
  191.  
  192. function Add {
  193. if (getitemname(getarg(1)) == "null") {
  194. debugmes "Quest reward #"+getarg(1)+" invalid (skipped).";
  195. return;
  196. }
  197. setarray .@j[0],getarg(2),getarg(3),getarg(4);
  198. for(set .@i,5; .@i<getargcount(); set .@i,.@i+2) {
  199. if (getitemname(getarg(.@i)) == "null") {
  200. debugmes "Quest requirement #"+getarg(.@i)+" invalid (skipped).";
  201. return;
  202. } else
  203. setarray .@j[.@i-2],getarg(.@i),getarg(.@i+1);
  204. }
  205. copyarray getd(".q_"+getarg(0)+"_"+getarg(1)+"[0]"),.@j[0],getarraysize(.@j);
  206. npcshopadditem "qshop"+getarg(0),getarg(1),((.ShowZeny)?getarg(3):0);
  207. return;
  208. }
  209.  
  210. function Chk {
  211. if (getarg(0) < getarg(1)) {
  212. set @qe[0],1;
  213. return "^FF0000";
  214. } else
  215. return "^00FF00";
  216. }
  217.  
  218. function Slot {
  219. set .@s$,getitemname(getarg(0));
  220. switch(.ShowSlot) {
  221. case 1: if (!getitemslots(getarg(0))) return .@s$;
  222. case 2: if (getiteminfo(getarg(0),2) == 4 || getiteminfo(getarg(0),2) == 5) return .@s$+" ["+getitemslots(getarg(0))+"]";
  223. default: return .@s$;
  224. }
  225. }
  226. }
  227.  
  228. function script qshop {
  229. deletearray @i[0],getarraysize(@i);
  230. for(set .@i,0; .@i<getargcount(); set .@i,.@i+1)
  231. set @i[.@i],getarg(.@i);
  232. doevent "quest_shop::OnMenu";
  233. end;
  234. }
Add Comment
Please, Sign In to add comment