Advertisement
Guest User

Untitled

a guest
Jan 10th, 2014
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.56 KB | None | 0 0
  1. //===== rAthena Script =======================================
  2. //= Euphy's Quest Shop
  3. //===== By: ==================================================
  4. //= Euphy
  5. //===== Current Version: =====================================
  6. //= 1.6
  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. //============================================================
  14.  
  15. // Shop NPCs -- supplying no argument displays entire menu.
  16. // callfunc "qshop"{,<shop ID>{,<shop ID>{,...}}};
  17. //============================================================
  18. poring_w02,112,91,6 script thisissample 475,{ callfunc "qshop"; }
  19.  
  20.  
  21. // Script Core
  22. //============================================================
  23. - script quest_shop -1,{
  24. function Add; function Chk; function Slot; function A_An;
  25. OnInit:
  26. freeloop(1);
  27.  
  28. // -----------------------------------------------------------
  29. // Basic shop settings.
  30. // -----------------------------------------------------------
  31.  
  32. set .Announce,1; // Announce quest completion? (1: yes / 0: no)
  33. set .ShowSlot,1; // Show item slots? (2: all equipment / 1: if slots > 0 / 0: never)
  34. set .ShowID,0; // Show item IDs? (1: yes / 0: no)
  35. set .ShowZeny,0; // Show Zeny cost, if any? (1: yes / 0: no)
  36. set .MaxStack,100; // Max number of quest items purchased at one time.
  37.  
  38. // -----------------------------------------------------------
  39. // Points variable -- optional quest requirement.
  40. // setarray .Points$[0],"<variable name>","<display name>";
  41. // -----------------------------------------------------------
  42.  
  43. setarray .Points$[0],"#CASHPOINTS","Cash Points";
  44.  
  45. // -----------------------------------------------------------
  46. // Shop IDs -- to add shops, copy dummy data at bottom of file.
  47. // setarray .Shops$[1],"<Shop 1>","<Shop 2>"{,...};
  48. // -----------------------------------------------------------
  49.  
  50. setarray .Shops$[1],"Upper Gear","Mid Gear","Lower Gear";
  51.  
  52. // -----------------------------------------------------------
  53. // Quest items -- do NOT use a reward item more than once!
  54. // Add(<shop ID>,<reward ID>,<reward amount>,
  55. // <Zeny cost>,<point cost>,
  56. // <required item ID>,<required item amount>{,...});
  57. // -----------------------------------------------------------
  58.  
  59. Add(1,2236,1,0,0,671,2,7151,200,7112,180,7111,200,4033,15);
  60.  
  61. Add(2,2251,1,0,0,671,2,1039,200,1058,150,7101,180,4178,15);
  62.  
  63. Add(3,2220,1,0,0,671,2,7445,200,574,150,7189,180,4009,15);
  64.  
  65.  
  66.  
  67.  
  68. // -----------------------------------------------------------
  69.  
  70. freeloop(0);
  71. set .menu$,"";
  72. for(set .@i,1; .@i<=getarraysize(.Shops$); set .@i,.@i+1) {
  73. set .menu$, .menu$+.Shops$[.@i]+":";
  74. npcshopdelitem "qshop"+.@i,909;
  75. }
  76. end;
  77.  
  78. OnMenu:
  79. set .@size, getarraysize(@i);
  80. if (!.@size) set .@i, select(.menu$);
  81. else if (.@size == 1) set .@i, @i[0];
  82. else {
  83. for(set .@j,0; .@j<.@size; set .@j,.@j+1)
  84. set .@menu$, .@menu$+.Shops$[@i[.@j]]+":";
  85. set .@i, @i[select(.@menu$)-1];
  86. }
  87. deletearray @i[0],getarraysize(@i);
  88. if (.Shops$[.@i] == "") {
  89. message strcharinfo(0),"An error has occurred.";
  90. end;
  91. }
  92. dispbottom "Select one item at a time.";
  93. callshop "qshop"+.@i,1;
  94. npcshopattach "qshop"+.@i;
  95. end;
  96.  
  97. OnBuyItem:
  98. // .@q[] : RewardID, BoughtAmt, RewardAmt, BaseAmt, ReqZeny, ReqPts, { ReqItem, ReqAmt, ... }
  99. setarray .@q[0],@bought_nameid[0],((@bought_quantity[0] > .MaxStack)?.MaxStack:@bought_quantity[0]);
  100. copyarray .@q[3],getd(".q_"+.@q[0]+"[0]"),getarraysize(getd(".q_"+.@q[0]));
  101. set .@q[2],.@q[1]*.@q[3];
  102. if (!.@q[2] || .@q[2] > 30000) {
  103. message strcharinfo(0),"You can't purchase that many "+getitemname(.@q[0])+".";
  104. end;
  105. }
  106. mes "[Quest Shop]";
  107. mes "Reward: ^0055FF"+((.@q[2] > 1)?.@q[2]+"x ":"")+Slot(.@q[0])+"^000000";
  108. mes "Requirements:";
  109. if (.@q[4]) mes " > "+Chk(Zeny,.@q[4]*.@q[1])+(.@q[4]*.@q[1])+" Zeny^000000";
  110. 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";
  111. if (.@q[6]) for(set .@i,6; .@i<getarraysize(.@q); set .@i,.@i+2)
  112. 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";
  113. next;
  114. setarray @qe[1], getiteminfo(.@q[0],5), getiteminfo(.@q[0],11);
  115. if (((@qe[1] & 1) || (@qe[1] & 256) || (@qe[1] & 512)) && @qe[2] > 0)
  116. set .@preview,1;
  117. addtimer 1000, strnpcinfo(0)+"::OnEnd";
  118. while(1) {
  119. switch(select(" ~ Purchase ^0055FF"+getitemname(.@q[0])+"^000000:"+((.@preview && !@qe[6])?" ~ Preview...":"")+": ~ ^777777Cancel^000000")) {
  120. case 1:
  121. if (@qe[0]) {
  122. mes "[Quest Shop]";
  123. mes "You're missing one or more quest requirements.";
  124. close;
  125. }
  126. if (!checkweight(.@q[0],.@q[2])) {
  127. mes "[Quest Shop]";
  128. mes "^FF0000You need "+(((.@q[2]*getiteminfo(.@q[0],6))+Weight-MaxWeight)/10)+" additional weight capacity to complete this trade.^000000";
  129. close;
  130. }
  131. if (.@q[4]) set Zeny, Zeny-(.@q[4]*.@q[1]);
  132. if (.@q[5]) setd .Points$[0], getd(.Points$[0])-(.@q[5]*.@q[1]);
  133. if (.@q[6]) for(set .@i,6; .@i<getarraysize(.@q); set .@i,.@i+2)
  134. delitem .@q[.@i],.@q[.@i+1]*.@q[1];
  135. getitem .@q[0],.@q[2];
  136. if (.Announce) announce strcharinfo(0)+" has created "+((.@q[2] > 1)?.@q[2]+"x "+getitemname(.@q[0]):A_An(getitemname(.@q[0])))+"!",0;
  137. specialeffect2 699;
  138. close;
  139. case 2:
  140. setarray @qe[3], getlook(LOOK_HEAD_BOTTOM), getlook(LOOK_HEAD_TOP), getlook(LOOK_HEAD_MID), 1;
  141. if (@qe[1] & 1) changelook LOOK_HEAD_BOTTOM, @qe[2];
  142. if (@qe[1] & 256) changelook LOOK_HEAD_TOP, @qe[2];
  143. if (@qe[1] & 512) changelook LOOK_HEAD_MID, @qe[2];
  144. break;
  145. case 3:
  146. close;
  147. }
  148. }
  149.  
  150. OnEnd:
  151. if (@qe[6]) {
  152. changelook LOOK_HEAD_BOTTOM, @qe[3];
  153. changelook LOOK_HEAD_TOP, @qe[4];
  154. changelook LOOK_HEAD_MID, @qe[5];
  155. }
  156. deletearray @qe[0],7;
  157. end;
  158.  
  159. function Add {
  160. if (getitemname(getarg(1)) == "null") {
  161. debugmes "Quest reward #"+getarg(1)+" invalid (skipped).";
  162. return;
  163. }
  164. setarray .@j[0],getarg(2),getarg(3),getarg(4);
  165. for(set .@i,5; .@i<getargcount(); set .@i,.@i+2) {
  166. if (getitemname(getarg(.@i)) == "null") {
  167. debugmes "Quest requirement #"+getarg(.@i)+" invalid (skipped).";
  168. return;
  169. } else
  170. setarray .@j[.@i-2],getarg(.@i),getarg(.@i+1);
  171. }
  172. copyarray getd(".q_"+getarg(1)+"[0]"),.@j[0],getarraysize(.@j);
  173. npcshopadditem "qshop"+getarg(0),getarg(1),((.ShowZeny)?getarg(3):0);
  174. return;
  175. }
  176.  
  177. function Chk {
  178. if (getarg(0) < getarg(1)) {
  179. set @qe[0],1;
  180. return "^FF0000";
  181. } else
  182. return "^00FF00";
  183. }
  184.  
  185. function Slot {
  186. set .@s$,getitemname(getarg(0));
  187. switch(.ShowSlot) {
  188. case 1: if (!getitemslots(getarg(0))) return .@s$;
  189. case 2: if (getiteminfo(getarg(0),2) == 4 || getiteminfo(getarg(0),2) == 5) return .@s$+" ["+getitemslots(getarg(0))+"]";
  190. default: return .@s$;
  191. }
  192. }
  193.  
  194. function A_An {
  195. setarray .@A$[0],"a","e","i","o","u";
  196. set .@B$, "_"+getarg(0);
  197. for(set .@i,0; .@i<5; set .@i,.@i+1)
  198. if (compare(.@B$,"_"+.@A$[.@i])) return "an "+getarg(0);
  199. return "a "+getarg(0);
  200. }
  201. }
  202.  
  203. function script qshop {
  204. deletearray @i[0],getarraysize(@i);
  205. for(set .@i,0; .@i<getargcount(); set .@i,.@i+1)
  206. set @i[.@i],getarg(.@i);
  207. doevent "quest_shop::OnMenu";
  208. end;
  209. }
  210.  
  211.  
  212. // Dummy shop data -- copy as needed.
  213. //============================================================
  214. - shop qshop1 -1,909:-1
  215. - shop qshop2 -1,909:-1
  216. - shop qshop3 -1,909:-1
  217. - shop qshop4 -1,909:-1
  218. - shop qshop5 -1,909:-1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement