Advertisement
dagiccross

Untitled

Oct 11th, 2014
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.67 KB | None | 0 0
  1. //===== rAthena Script =======================================
  2. //= Euphy's Quest Shop
  3. //===== By: ==================================================
  4. //= Euphy
  5. //===== Current Version: =====================================
  6. //= 1.6b
  7. //===== Compatible With: =====================================
  8. //= rAthena SVN r16862+
  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. //============================================================
  23.  
  24. // Shop NPCs -- supplying no argument displays entire menu.
  25. // callfunc "qshop"{,<shop ID>{,<shop ID>{,...}}};
  26. //============================================================
  27. prontera,140,169,5 script Hat Maker 1#1 503,{ callfunc "qshop"; }
  28. prontera,140,165,5 script Hat Maker 2#2 510,{ callfunc "qshop"; }
  29. prontera,140,161,5 script Hat Maker 3#3 504,{ callfunc "qshop"; }
  30.  
  31. // Script Core
  32. //============================================================
  33. - script quest_shop -1,{
  34. function Add; function Chk; function Slot; function A_An;
  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,1; // 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. setarray .Shops$[2],"Headgears","Other";
  62. setarray .Shops$[3],"Other";
  63.  
  64. // -----------------------------------------------------------
  65. // Quest items -- do NOT use a reward item more than once!
  66. // Add(<shop ID>,<reward ID>,<reward amount>,
  67. // <Zeny cost>,<point cost>,
  68. // <required item ID>,<required item amount>{,...});
  69. // -----------------------------------------------------------
  70.  
  71. Add(1,5022,1,0,0,7086,1,969,10,999,40,1003,50,984,2);
  72. Add(1,5032,1,0,0,1059,250,2221,1,2227,1,7063,600);
  73. Add(1,5027,1,0,0,2252,1,1036,400,7001,50,4052,1);
  74. Add(1,5045,1,0,0,2252,1,1054,450,943,1200);
  75.  
  76. Add(2,1224,1,0,0,7297,30,969,10,999,50,714,10);
  77. Add(2,1225,1,0,0,7292,30,969,10,999,50,714,10);
  78.  
  79. Add(3,531,1,3,0,512,1,713,1);
  80. Add(3,532,1,3,0,513,1,713,1);
  81. Add(3,533,1,3,0,514,1,713,1);
  82. Add(3,534,1,3,0,515,1,713,1);
  83.  
  84. // -----------------------------------------------------------
  85.  
  86. freeloop(0);
  87. set .menu$,"";
  88. for(set .@i,1; .@i<=getarraysize(.Shops$); set .@i,.@i+1) {
  89. set .menu$, .menu$+.Shops$[.@i]+":";
  90. npcshopdelitem "qshop"+.@i,909;
  91. }
  92. end;
  93.  
  94. OnMenu:
  95. set .@size, getarraysize(@i);
  96. if (!.@size) set .@i, select(.menu$);
  97. else if (.@size == 1) set .@i, @i[0];
  98. else {
  99. for(set .@j,0; .@j<.@size; set .@j,.@j+1)
  100. set .@menu$, .@menu$+.Shops$[@i[.@j]]+":";
  101. set .@i, @i[select(.@menu$)-1];
  102. }
  103. deletearray @i[0],getarraysize(@i);
  104. if (.Shops$[.@i] == "") {
  105. message strcharinfo(0),"An error has occurred.";
  106. end;
  107. }
  108. dispbottom "Select one item at a time.";
  109. callshop "qshop"+.@i,1;
  110. npcshopattach "qshop"+.@i;
  111. end;
  112.  
  113. OnBuyItem:
  114. // .@q[] : RewardID, BoughtAmt, RewardAmt, BaseAmt, ReqZeny, ReqPts, { ReqItem, ReqAmt, ... }
  115. setarray .@q[0],@bought_nameid[0],((@bought_quantity[0] > .MaxStack)?.MaxStack:@bought_quantity[0]);
  116. copyarray .@q[3],getd(".q_"+.@q[0]+"[0]"),getarraysize(getd(".q_"+.@q[0]));
  117. set .@q[2],.@q[1]*.@q[3];
  118. if (!.@q[2] || .@q[2] > 30000) {
  119. message strcharinfo(0),"You can't purchase that many "+getitemname(.@q[0])+".";
  120. end;
  121. }
  122. mes "[Quest Shop]";
  123. mes "Reward: ^0055FF"+((.@q[2] > 1)?.@q[2]+"x ":"")+Slot(.@q[0])+"^000000";
  124. mes "Requirements:";
  125. disable_items;
  126. if (.@q[4]) mes " > "+Chk(Zeny,.@q[4]*.@q[1])+(.@q[4]*.@q[1])+" Zeny^000000";
  127. 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";
  128. if (.@q[6]) for(set .@i,6; .@i<getarraysize(.@q); set .@i,.@i+2)
  129. 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";
  130. next;
  131. setarray @qe[1], getiteminfo(.@q[0],5), getiteminfo(.@q[0],11);
  132. if (@qe[2] > 0 && ((@qe[1] & 1) || (@qe[1] & 256) || (@qe[1] & 512) || (@qe[1] & 1024) || (@qe[1] & 2048) || (@qe[1] & 4096) || (@qe[1] & 4) || (@qe[1] & 8192)))
  133. set .@preview,1;
  134. addtimer 1000, strnpcinfo(0)+"::OnEnd";
  135. while(1) {
  136. switch(select(" ~ Purchase ^0055FF"+getitemname(.@q[0])+"^000000:"+((.@preview && !@qe[7])?" ~ Preview...":"")+": ~ ^777777Cancel^000000")) {
  137. case 1:
  138. if (@qe[0]) {
  139. mes "[Quest Shop]";
  140. mes "You're missing one or more quest requirements.";
  141. close;
  142. }
  143. if (!checkweight(.@q[0],.@q[2])) {
  144. mes "[Quest Shop]";
  145. mes "^FF0000You need "+(((.@q[2]*getiteminfo(.@q[0],6))+Weight-MaxWeight)/10)+" additional weight capacity to complete this trade.^000000";
  146. close;
  147. }
  148. if (.@q[4]) set Zeny, Zeny-(.@q[4]*.@q[1]);
  149. if (.@q[5]) setd .Points$[0], getd(.Points$[0])-(.@q[5]*.@q[1]);
  150. if (.@q[6]) for(set .@i,6; .@i<getarraysize(.@q); set .@i,.@i+2)
  151. delitem .@q[.@i],.@q[.@i+1]*.@q[1];
  152. getitem .@q[0],.@q[2];
  153. if (.Announce) announce strcharinfo(0)+" has created "+((.@q[2] > 1)?.@q[2]+"x "+getitemname(.@q[0]):A_An(getitemname(.@q[0])))+"!",0;
  154. specialeffect2 EF_FLOWERLEAF;
  155. close;
  156. case 2:
  157. setarray @qe[3], getlook(LOOK_HEAD_BOTTOM), getlook(LOOK_HEAD_TOP), getlook(LOOK_HEAD_MID), getlook(LOOK_ROBE), 1;
  158. if ((@qe[1] & 1) || (@qe[1] & 4096)) changelook LOOK_HEAD_BOTTOM, @qe[2];
  159. else if ((@qe[1] & 256) || (@qe[1] & 1024)) changelook LOOK_HEAD_TOP, @qe[2];
  160. else if ((@qe[1] & 512) || (@qe[1] & 2048)) changelook LOOK_HEAD_MID, @qe[2];
  161. else if ((@qe[1] & 4) || (@qe[1] & 8192)) changelook LOOK_ROBE, @qe[2];
  162. break;
  163. case 3:
  164. close;
  165. }
  166. }
  167.  
  168. OnEnd:
  169. if (@qe[7]) {
  170. changelook LOOK_HEAD_BOTTOM, @qe[3];
  171. changelook LOOK_HEAD_TOP, @qe[4];
  172. changelook LOOK_HEAD_MID, @qe[5];
  173. changelook LOOK_ROBE, @qe[6];
  174. }
  175. deletearray @qe[0],8;
  176. end;
  177.  
  178. function Add {
  179. if (getitemname(getarg(1)) == "null") {
  180. debugmes "Quest reward #"+getarg(1)+" invalid (skipped).";
  181. return;
  182. }
  183. setarray .@j[0],getarg(2),getarg(3),getarg(4);
  184. for(set .@i,5; .@i<getargcount(); set .@i,.@i+2) {
  185. if (getitemname(getarg(.@i)) == "null") {
  186. debugmes "Quest requirement #"+getarg(.@i)+" invalid (skipped).";
  187. return;
  188. } else
  189. setarray .@j[.@i-2],getarg(.@i),getarg(.@i+1);
  190. }
  191. copyarray getd(".q_"+getarg(1)+"[0]"),.@j[0],getarraysize(.@j);
  192. npcshopadditem "qshop"+getarg(0),getarg(1),((.ShowZeny)?getarg(3):0);
  193. return;
  194. }
  195.  
  196. function Chk {
  197. if (getarg(0) < getarg(1)) {
  198. set @qe[0],1;
  199. return "^FF0000";
  200. } else
  201. return "^00FF00";
  202. }
  203.  
  204. function Slot {
  205. set .@s$,getitemname(getarg(0));
  206. switch(.ShowSlot) {
  207. case 1: if (!getitemslots(getarg(0))) return .@s$;
  208. case 2: if (getiteminfo(getarg(0),2) == 4 || getiteminfo(getarg(0),2) == 5) return .@s$+" ["+getitemslots(getarg(0))+"]";
  209. default: return .@s$;
  210. }
  211. }
  212.  
  213. function A_An {
  214. setarray .@A$[0],"a","e","i","o","u";
  215. set .@B$, "_"+getarg(0);
  216. for(set .@i,0; .@i<5; set .@i,.@i+1)
  217. if (compare(.@B$,"_"+.@A$[.@i])) return "an "+getarg(0);
  218. return "a "+getarg(0);
  219. }
  220. }
  221.  
  222. function script qshop {
  223. deletearray @i[0],getarraysize(@i);
  224. for(set .@i,0; .@i<getargcount(); set .@i,.@i+1)
  225. set @i[.@i],getarg(.@i);
  226. doevent "quest_shop::OnMenu";
  227. end;
  228. }
  229.  
  230.  
  231. // Dummy shop data -- copy as needed.
  232. //============================================================
  233. - shop qshop1 -1,909:-1
  234. - shop qshop2 -1,909:-1
  235. - shop qshop3 -1,909:-1
  236. - shop qshop4 -1,909:-1
  237. - shop qshop5 -1,909:-1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement