ManokStreZ

npc quest

Mar 7th, 2021 (edited)
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.26 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. amatsu,126,130,5 script Another Quest 848,{ callfunc "qshop"; }
  30. amatsu,126,127,5 script Upper/Middle 848,{ callfunc "qshop",2,3; }
  31. // prontera,165,203,6 script Quest Shop#2 998,{ callfunc "qshop",1,2; } // call the shop 1 and 2 defined below
  32. // etc.. Add your Shop NPCs 'Quest Shop#XXX' here
  33. //============================================================
  34.  
  35. // Dummy shop data -- copy as needed.
  36. //============================================================
  37. - shop qshop1 -1,909:-1;
  38. - shop qshop2 -1,909:-1,5137:20;
  39. - shop qshop3 -1,909:-1,5389:20;
  40. - shop qshop4 -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. "Another Quest", // Show Shop 1
  79. "Upper Quest", // Show Shop 2
  80. "Middle Quest"; // Show Shop 3
  81.  
  82. // -----------------------------------------------------------
  83. // Quest items -- do NOT use a reward item more than once!
  84. // Add(<shop ID>,<reward ID>,<reward amount>,
  85. // <Zeny cost>,<point cost>,
  86. // <required item ID>,<required item amount>{,...});
  87. // -----------------------------------------------------------
  88.  
  89. // Shop 1
  90. Add(1,5155,1,0,0,1028,900,1058,500,1040,250,948,200,7065,200,1479,1,7063,100);
  91.  
  92.  
  93. // Shop 2
  94. Add(1,5137,1,0,0,5141,5,7047,100,7166,50,7038,20,978,1);
  95.  
  96.  
  97. // Shop 3
  98. Add(1,5389,1,0,0,5043,5,7568,150,969,10);
  99.  
  100.  
  101.  
  102. // -----------------------------------------------------------
  103.  
  104. //=====================================================================================
  105. // ------------------- YOUR SHOPS AND ITEMS SHOPS HAVE BEEN ADDED ---------------------
  106. //=====================================================================================
  107.  
  108. freeloop(0);
  109. set .menu$,"";
  110. for(set .@i,1; .@i<=getarraysize(.Shops$); set .@i,.@i+1) {
  111. set .menu$, .menu$+.Shops$[.@i]+":";
  112. npcshopdelitem "qshop"+.@i,909;
  113. }
  114. end;
  115.  
  116. OnMenu:
  117. set .@size, getarraysize(@i);
  118. if (!.@size) set @shop_index, select(.menu$);
  119. else if (.@size == 1) set @shop_index, @i[0];
  120. else {
  121. for(set .@j,0; .@j<.@size; set .@j,.@j+1)
  122. set .@menu$, .@menu$+.Shops$[@i[.@j]]+":";
  123. set @shop_index, @i[select(.@menu$)-1];
  124. }
  125. deletearray @i[0],getarraysize(@i);
  126. if (.Shops$[@shop_index] == "") {
  127. message strcharinfo(0),"An error has occurred.";
  128. end;
  129. }
  130. dispbottom "Select one item at a time.";
  131. callshop "qshop"+@shop_index,1;
  132. npcshopattach "qshop"+@shop_index;
  133. end;
  134.  
  135. OnBuyItem:
  136. // .@q[] : RewardID, BoughtAmt, RewardAmt, BaseAmt, ReqZeny, ReqPts, { ReqItem, ReqAmt, ... }
  137. setarray .@q[0],@bought_nameid[0],((@bought_quantity[0] > .MaxStack)?.MaxStack:@bought_quantity[0]);
  138. copyarray .@q[3],getd(".q_"+@shop_index+"_"+.@q[0]+"[0]"),getarraysize(getd(".q_"+@shop_index+"_"+.@q[0]));
  139. set .@q[2],.@q[1]*.@q[3];
  140. if (!.@q[2] || .@q[2] > 30000) {
  141. message strcharinfo(0),"You can't purchase that many "+getitemname(.@q[0])+".";
  142. end;
  143. }
  144. mes "[Quest Shop]";
  145. mes "Reward: ^0055FF"+((.@q[2] > 1)?.@q[2]+"x ":"")+Slot(.@q[0])+"^000000";
  146. mes "Requirements:";
  147. disable_items;
  148. if (.@q[4]) mes " > "+Chk(Zeny,.@q[4]*.@q[1])+(.@q[4]*.@q[1])+" Zeny^000000";
  149. 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";
  150. if (.@q[6]) for(set .@i,6; .@i<getarraysize(.@q); set .@i,.@i+2)
  151. 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";
  152. next;
  153. setarray @qe[1], getiteminfo(.@q[0],5), getiteminfo(.@q[0],11);
  154. 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)))
  155. set .@preview,1;
  156. addtimer 1000, strnpcinfo(0)+"::OnEnd";
  157. while(1) {
  158. switch(select(" ~ Purchase ^0055FF"+getitemname(.@q[0])+"^000000:"+((.@preview && !@qe[7])?" ~ Preview...":"")+": ~ ^777777Cancel^000000")) {
  159. case 1:
  160. if (@qe[0]) {
  161. mes "[Quest Shop]";
  162. mes "You're missing one or more quest requirements.";
  163. close;
  164. }
  165. if (!checkweight(.@q[0],.@q[2])) {
  166. mes "[Quest Shop]";
  167. mes "^FF0000You need "+(((.@q[2]*getiteminfo(.@q[0],6))+Weight-MaxWeight)/10)+" additional weight capacity to complete this trade.^000000";
  168. close;
  169. }
  170. if (.@q[4]) set Zeny, Zeny-(.@q[4]*.@q[1]);
  171. if (.@q[5]) setd .Points$[0], getd(.Points$[0])-(.@q[5]*.@q[1]);
  172. if (.@q[6]) for(set .@i,6; .@i<getarraysize(.@q); set .@i,.@i+2)
  173. delitem .@q[.@i],.@q[.@i+1]*.@q[1];
  174. getitem .@q[0],.@q[2];
  175. if (.Announce) announce strcharinfo(0)+" has created "+((.@q[2] > 1)?.@q[2]+"x "+getitemname(.@q[0]):callfunc("F_InsertArticle",getitemname(.@q[0])))+"!",0;
  176. specialeffect2 EF_FLOWERLEAF;
  177. close;
  178. case 2:
  179. setarray @qe[3], getlook(LOOK_HEAD_BOTTOM), getlook(LOOK_HEAD_TOP), getlook(LOOK_HEAD_MID), getlook(LOOK_ROBE), 1;
  180. if ((@qe[1] & 1) || (@qe[1] & 4096)) changelook LOOK_HEAD_BOTTOM, @qe[2];
  181. else if ((@qe[1] & 256) || (@qe[1] & 1024)) changelook LOOK_HEAD_TOP, @qe[2];
  182. else if ((@qe[1] & 512) || (@qe[1] & 2048)) changelook LOOK_HEAD_MID, @qe[2];
  183. else if ((@qe[1] & 4) || (@qe[1] & 8192)) changelook LOOK_ROBE, @qe[2];
  184. break;
  185. case 3:
  186. close;
  187. }
  188. }
  189.  
  190. OnEnd:
  191. if (@qe[7]) {
  192. changelook LOOK_HEAD_BOTTOM, @qe[3];
  193. changelook LOOK_HEAD_TOP, @qe[4];
  194. changelook LOOK_HEAD_MID, @qe[5];
  195. changelook LOOK_ROBE, @qe[6];
  196. }
  197. deletearray @qe[0],8;
  198. end;
  199.  
  200. function Add {
  201. if (getitemname(getarg(1)) == "null") {
  202. debugmes "Quest reward #"+getarg(1)+" invalid (skipped).";
  203. return;
  204. }
  205. setarray .@j[0],getarg(2),getarg(3),getarg(4);
  206. for(set .@i,5; .@i<getargcount(); set .@i,.@i+2) {
  207. if (getitemname(getarg(.@i)) == "null") {
  208. debugmes "Quest requirement #"+getarg(.@i)+" invalid (skipped).";
  209. return;
  210. } else
  211. setarray .@j[.@i-2],getarg(.@i),getarg(.@i+1);
  212. }
  213. copyarray getd(".q_"+getarg(0)+"_"+getarg(1)+"[0]"),.@j[0],getarraysize(.@j);
  214. npcshopadditem "qshop"+getarg(0),getarg(1),((.ShowZeny)?getarg(3):0);
  215. return;
  216. }
  217.  
  218. function Chk {
  219. if (getarg(0) < getarg(1)) {
  220. set @qe[0],1;
  221. return "^FF0000";
  222. } else
  223. return "^00FF00";
  224. }
  225.  
  226. function Slot {
  227. set .@s$,getitemname(getarg(0));
  228. switch(.ShowSlot) {
  229. case 1: if (!getitemslots(getarg(0))) return .@s$;
  230. case 2: if (getiteminfo(getarg(0),2) == 4 || getiteminfo(getarg(0),2) == 5) return .@s$+" ["+getitemslots(getarg(0))+"]";
  231. default: return .@s$;
  232. }
  233. }
  234. }
  235.  
  236. function script qshop {
  237. deletearray @i[0],getarraysize(@i);
  238. for(set .@i,0; .@i<getargcount(); set .@i,.@i+1)
  239. set @i[.@i],getarg(.@i);
  240. doevent "quest_shop::OnMenu";
  241. end;
  242. }
Add Comment
Please, Sign In to add comment