Advertisement
Guest User

Untitled

a guest
Jun 5th, 2017
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.75 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. //============================================================
  28. prontera,147,158,5 script One Hour Shop 998,{ callfunc "qshop"; }
  29.  
  30.  
  31. // Script Core
  32. //============================================================
  33. - script quest_shop -1,{
  34. function Add; function Chk; function Slot;
  35. OnInit:
  36. freeloop(1);
  37.  
  38. // -----------------------------------------------------------
  39. // Basic shop settings.
  40. // -----------------------------------------------------------
  41.  
  42. set .Announce,1; // Announce quest completion? (1: yes / 0: no)
  43. set .ShowSlot,1; // Show item slots? (2: all equipment / 1: if slots > 0 / 0: never)
  44. set .ShowID,0; // Show item IDs? (1: yes / 0: no)
  45. set .ShowZeny,0; // Show Zeny cost, if any? (1: yes / 0: no)
  46. set .MaxStack,100; // Max number of quest items purchased at one time.
  47.  
  48. // -----------------------------------------------------------
  49. // Points variable -- optional quest requirement.
  50. // setarray .Points$[0],"<variable name>","<display name>";
  51. // -----------------------------------------------------------
  52.  
  53. setarray .Points$[0],"#CASHPOINTS","Cash Points";
  54.  
  55. // -----------------------------------------------------------
  56. // Shop IDs -- to add shops, copy dummy data at bottom of file.
  57. // setarray .Shops$[1],"<Shop 1>","<Shop 2>"{,...};
  58. // -----------------------------------------------------------
  59.  
  60. setarray .Shops$[1],"Headgears","Weapons","Other";
  61.  
  62. // -----------------------------------------------------------
  63. // Quest items -- do NOT use a reward item more than once!
  64. // Add(<shop ID>,<reward ID>,<reward amount>,
  65. // <Zeny cost>,<point cost>,
  66. // <required item ID>,<required item amount>{,...});
  67. // -----------------------------------------------------------
  68.  
  69. Add(1,5022,1,0,0,7086,1,969,10,999,40,1003,50,984,2);
  70. Add(1,5032,1,0,0,1059,250,2221,1,2227,1,7063,600);
  71. Add(1,606,1,3,0,6153,1);
  72. Add(1,605,1,3,0,6153,2);
  73. Add(1,609,1,3,0,6153,3);
  74. Add(1,662,1,3,0,6153,4);
  75. Add(1,678,1,3,0,6153,5);
  76. Add(1,645,1,3,0,6153,6);
  77. Add(1,656,1,3,0,6153,7);
  78. Add(1,657,1,3,0,6153,8);
  79. Add(1,14509,1,3,0,6153,9);
  80. Add(1,5027,1,0,0,2252,1,1036,400,7001,50,4052,1);
  81. Add(1,5045,1,0,0,2252,1,1054,450,943,1200);
  82. Add(2,1224,1,0,0,7297,30,969,10,999,50,714,10);
  83. Add(2,1225,1,0,0,7292,30,969,10,999,50,714,10);
  84. Add(3,531,1,3,0,512,1,713,1);
  85. Add(3,532,1,3,0,513,1,713,1);
  86. Add(3,533,1,3,0,514,1,713,1);
  87. Add(3,534,1,3,0,515,1,713,1);
  88.  
  89. // -----------------------------------------------------------
  90.  
  91. freeloop(0);
  92. set .menu$,"";
  93. for(set .@i,1; .@i<=getarraysize(.Shops$); set .@i,.@i+1) {
  94. set .menu$, .menu$+.Shops$[.@i]+":";
  95. npcshopdelitem "qshop"+.@i,909;
  96. }
  97. end;
  98.  
  99. OnMenu:
  100. set .@size, getarraysize(@i);
  101. if (!.@size) set @shop_index, select(.menu$);
  102. else if (.@size == 1) set @shop_index, @i[0];
  103. else {
  104. for(set .@j,0; .@j<.@size; set .@j,.@j+1)
  105. set .@menu$, .@menu$+.Shops$[@i[.@j]]+":";
  106. set @shop_index, @i[select(.@menu$)-1];
  107. }
  108. deletearray @i[0],getarraysize(@i);
  109. if (.Shops$[@shop_index] == "") {
  110. message strcharinfo(0),"An error has occurred.";
  111. end;
  112. }
  113. dispbottom "Select one item at a time.";
  114. callshop "qshop"+@shop_index,1;
  115. npcshopattach "qshop"+@shop_index;
  116. end;
  117.  
  118. OnBuyItem:
  119. // .@q[] : RewardID, BoughtAmt, RewardAmt, BaseAmt, ReqZeny, ReqPts, { ReqItem, ReqAmt, ... }
  120. setarray .@q[0],@bought_nameid[0],((@bought_quantity[0] > .MaxStack)?.MaxStack:@bought_quantity[0]);
  121. copyarray .@q[3],getd(".q_"+@shop_index+"_"+.@q[0]+"[0]"),getarraysize(getd(".q_"+@shop_index+"_"+.@q[0]));
  122. set .@q[2],.@q[1]*.@q[3];
  123. if (!.@q[2] || .@q[2] > 30000) {
  124. message strcharinfo(0),"You can't purchase that many "+getitemname(.@q[0])+".";
  125. end;
  126. }
  127. mes "[Quest Shop]";
  128. mes "Reward: ^0055FF"+((.@q[2] > 1)?.@q[2]+"x ":"")+Slot(.@q[0])+"^000000";
  129. mes "Requirements:";
  130. disable_items;
  131. if (.@q[4]) mes " > "+Chk(Zeny,.@q[4]*.@q[1])+(.@q[4]*.@q[1])+" Zeny^000000";
  132. 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";
  133. if (.@q[6]) for(set .@i,6; .@i<getarraysize(.@q); set .@i,.@i+2)
  134. 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";
  135. next;
  136. setarray @qe[1], getiteminfo(.@q[0],5), getiteminfo(.@q[0],11);
  137. 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)))
  138. set .@preview,1;
  139. addtimer 1000, strnpcinfo(0)+"::OnEnd";
  140. while(1) {
  141. switch(select(" ~ Purchase ^0055FF"+getitemname(.@q[0])+"^000000:"+((.@preview && !@qe[7])?" ~ Preview...":"")+": ~ ^777777Cancel^000000")) {
  142. case 1:
  143. if (@qe[0]) {
  144. mes "[Quest Shop]";
  145. mes "You're missing one or more quest requirements.";
  146. close;
  147. }
  148. if (!checkweight(.@q[0],.@q[2])) {
  149. mes "[Quest Shop]";
  150. mes "^FF0000You need "+(((.@q[2]*getiteminfo(.@q[0],6))+Weight-MaxWeight)/10)+" additional weight capacity to complete this trade.^000000";
  151. close;
  152. }
  153. if (.@q[4]) set Zeny, Zeny-(.@q[4]*.@q[1]);
  154. if (.@q[5]) setd .Points$[0], getd(.Points$[0])-(.@q[5]*.@q[1]);
  155. if (.@q[6]) for(set .@i,6; .@i<getarraysize(.@q); set .@i,.@i+2)
  156. delitem .@q[.@i],.@q[.@i+1]*.@q[1];
  157. getitem .@q[0],.@q[2];
  158. if (.Announce) announce strcharinfo(0)+" has created "+((.@q[2] > 1)?.@q[2]+"x "+getitemname(.@q[0]):callfunc("F_InsertArticle",getitemname(.@q[0])))+"!",0;
  159. specialeffect2 EF_FLOWERLEAF;
  160. close;
  161. case 2:
  162. setarray @qe[3], getlook(LOOK_HEAD_BOTTOM), getlook(LOOK_HEAD_TOP), getlook(LOOK_HEAD_MID), getlook(LOOK_ROBE), 1;
  163. if ((@qe[1] & 1) || (@qe[1] & 4096)) changelook LOOK_HEAD_BOTTOM, @qe[2];
  164. else if ((@qe[1] & 256) || (@qe[1] & 1024)) changelook LOOK_HEAD_TOP, @qe[2];
  165. else if ((@qe[1] & 512) || (@qe[1] & 2048)) changelook LOOK_HEAD_MID, @qe[2];
  166. else if ((@qe[1] & 4) || (@qe[1] & 8192)) changelook LOOK_ROBE, @qe[2];
  167. break;
  168. case 3:
  169. close;
  170. }
  171. }
  172.  
  173. OnEnd:
  174. if (@qe[7]) {
  175. changelook LOOK_HEAD_BOTTOM, @qe[3];
  176. changelook LOOK_HEAD_TOP, @qe[4];
  177. changelook LOOK_HEAD_MID, @qe[5];
  178. changelook LOOK_ROBE, @qe[6];
  179. }
  180. deletearray @qe[0],8;
  181. end;
  182.  
  183. function Add {
  184. if (getitemname(getarg(1)) == "null") {
  185. debugmes "Quest reward #"+getarg(1)+" invalid (skipped).";
  186. return;
  187. }
  188. setarray .@j[0],getarg(2),getarg(3),getarg(4);
  189. for(set .@i,5; .@i<getargcount(); set .@i,.@i+2) {
  190. if (getitemname(getarg(.@i)) == "null") {
  191. debugmes "Quest requirement #"+getarg(.@i)+" invalid (skipped).";
  192. return;
  193. } else
  194. setarray .@j[.@i-2],getarg(.@i),getarg(.@i+1);
  195. }
  196. copyarray getd(".q_"+getarg(0)+"_"+getarg(1)+"[0]"),.@j[0],getarraysize(.@j);
  197. npcshopadditem "qshop"+getarg(0),getarg(1),((.ShowZeny)?getarg(3):0);
  198. return;
  199. }
  200.  
  201. function Chk {
  202. if (getarg(0) < getarg(1)) {
  203. set @qe[0],1;
  204. return "^FF0000";
  205. } else
  206. return "^00FF00";
  207. }
  208.  
  209. function Slot {
  210. set .@s$,getitemname(getarg(0));
  211. switch(.ShowSlot) {
  212. case 1: if (!getitemslots(getarg(0))) return .@s$;
  213. case 2: if (getiteminfo(getarg(0),2) == 4 || getiteminfo(getarg(0),2) == 5) return .@s$+" ["+getitemslots(getarg(0))+"]";
  214. default: return .@s$;
  215. }
  216. }
  217. }
  218.  
  219. function script qshop {
  220. deletearray @i[0],getarraysize(@i);
  221. for(set .@i,0; .@i<getargcount(); set .@i,.@i+1)
  222. set @i[.@i],getarg(.@i);
  223. doevent "quest_shop::OnMenu";
  224. end;
  225. }
  226.  
  227.  
  228. // Dummy shop data -- copy as needed.
  229. //============================================================
  230. - shop qshop1 -1,909:-1
  231. - shop qshop2 -1,909:-1
  232. - shop qshop3 -1,909:-1
  233. - shop qshop4 -1,909:-1
  234. - shop qshop5 -1,909:-1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement