Advertisement
Guest User

template

a guest
Jul 28th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.59 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 "templateshop"{,<shop ID>{,<shop ID>{,...}}};
  27. //============================================================
  28. prontera,164,203,6 script Test 998,{ callfunc "templateshop"; }
  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,5027,1,0,0,2252,1,1036,400,7001,50,4052,1);
  72. Add(1,5045,1,0,0,2252,1,1054,450,943,1200);
  73.  
  74. Add(2,1224,1,0,0,7297,30,969,10,999,50,714,10);
  75. Add(2,1225,1,0,0,7292,30,969,10,999,50,714,10);
  76.  
  77. Add(3,531,1,3,0,512,1,713,1);
  78. Add(3,532,1,3,0,513,1,713,1);
  79. Add(3,533,1,3,0,514,1,713,1);
  80. Add(3,534,1,3,0,515,1,713,1);
  81.  
  82. // -----------------------------------------------------------
  83.  
  84. freeloop(0);
  85. set .menu$,"";
  86. for(set .@i,1; .@i<=getarraysize(.Shops$); set .@i,.@i+1) {
  87. set .menu$, .menu$+.Shops$[.@i]+":";
  88. npcshopdelitem "templateshop"+.@i,909;
  89. }
  90. end;
  91.  
  92. OnMenu:
  93. set .@size, getarraysize(@i);
  94. if (!.@size) set @shop_index, select(.menu$);
  95. else if (.@size == 1) set @shop_index, @i[0];
  96. else {
  97. for(set .@j,0; .@j<.@size; set .@j,.@j+1)
  98. set .@menu$, .@menu$+.Shops$[@i[.@j]]+":";
  99. set @shop_index, @i[select(.@menu$)-1];
  100. }
  101. deletearray @i[0],getarraysize(@i);
  102. if (.Shops$[@shop_index] == "") {
  103. message strcharinfo(0),"An error has occurred.";
  104. end;
  105. }
  106. dispbottom "Select one item at a time.";
  107. callshop "templateshop"+@shop_index,1;
  108. npcshopattach "templateshop"+@shop_index;
  109. end;
  110.  
  111. OnBuyItem:
  112. // .@q[] : RewardID, BoughtAmt, RewardAmt, BaseAmt, ReqZeny, ReqPts, { ReqItem, ReqAmt, ... }
  113. setarray .@q[0],@bought_nameid[0],((@bought_quantity[0] > .MaxStack)?.MaxStack:@bought_quantity[0]);
  114. copyarray .@q[3],getd(".q_"+@shop_index+"_"+.@q[0]+"[0]"),getarraysize(getd(".q_"+@shop_index+"_"+.@q[0]));
  115. set .@q[2],.@q[1]*.@q[3];
  116. if (!.@q[2] || .@q[2] > 30000) {
  117. message strcharinfo(0),"You can't purchase that many "+getitemname(.@q[0])+".";
  118. end;
  119. }
  120. mes "[Quest Shop]";
  121. mes "Reward: ^0055FF"+((.@q[2] > 1)?.@q[2]+"x ":"")+Slot(.@q[0])+"^000000";
  122. mes "Requirements:";
  123. disable_items;
  124. if (.@q[4]) mes " > "+Chk(Zeny,.@q[4]*.@q[1])+(.@q[4]*.@q[1])+" Zeny^000000";
  125. 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";
  126. if (.@q[6]) for(set .@i,6; .@i<getarraysize(.@q); set .@i,.@i+2)
  127. 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";
  128. next;
  129. setarray @qe[1], getiteminfo(.@q[0],5), getiteminfo(.@q[0],11);
  130. 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)))
  131. set .@preview,1;
  132. addtimer 1000, strnpcinfo(0)+"::OnEnd";
  133. while(1) {
  134. switch(select(" ~ Purchase ^0055FF"+getitemname(.@q[0])+"^000000:"+((.@preview && !@qe[7])?" ~ Preview...":"")+": ~ ^777777Cancel^000000")) {
  135. case 1:
  136. if (@qe[0]) {
  137. mes "[Quest Shop]";
  138. mes "You're missing one or more quest requirements.";
  139. close;
  140. }
  141. if (!checkweight(.@q[0],.@q[2])) {
  142. mes "[Quest Shop]";
  143. mes "^FF0000You need "+(((.@q[2]*getiteminfo(.@q[0],6))+Weight-MaxWeight)/10)+" additional weight capacity to complete this trade.^000000";
  144. close;
  145. }
  146. if (.@q[4]) set Zeny, Zeny-(.@q[4]*.@q[1]);
  147. if (.@q[5]) setd .Points$[0], getd(.Points$[0])-(.@q[5]*.@q[1]);
  148. if (.@q[6]) for(set .@i,6; .@i<getarraysize(.@q); set .@i,.@i+2)
  149. delitem .@q[.@i],.@q[.@i+1]*.@q[1];
  150. getitem .@q[0],.@q[2];
  151. if (.Announce) announce strcharinfo(0)+" has created "+((.@q[2] > 1)?.@q[2]+"x "+getitemname(.@q[0]):callfunc("F_InsertArticle",getitemname(.@q[0])))+"!",0;
  152. specialeffect2 EF_FLOWERLEAF;
  153. close;
  154. case 2:
  155. setarray @qe[3], getlook(LOOK_HEAD_BOTTOM), getlook(LOOK_HEAD_TOP), getlook(LOOK_HEAD_MID), getlook(LOOK_ROBE), 1;
  156. if ((@qe[1] & 1) || (@qe[1] & 4096)) changelook LOOK_HEAD_BOTTOM, @qe[2];
  157. else if ((@qe[1] & 256) || (@qe[1] & 1024)) changelook LOOK_HEAD_TOP, @qe[2];
  158. else if ((@qe[1] & 512) || (@qe[1] & 2048)) changelook LOOK_HEAD_MID, @qe[2];
  159. else if ((@qe[1] & 4) || (@qe[1] & 8192)) changelook LOOK_ROBE, @qe[2];
  160. break;
  161. case 3:
  162. close;
  163. }
  164. }
  165.  
  166. OnEnd:
  167. if (@qe[7]) {
  168. changelook LOOK_HEAD_BOTTOM, @qe[3];
  169. changelook LOOK_HEAD_TOP, @qe[4];
  170. changelook LOOK_HEAD_MID, @qe[5];
  171. changelook LOOK_ROBE, @qe[6];
  172. }
  173. deletearray @qe[0],8;
  174. end;
  175.  
  176. function Add {
  177. if (getitemname(getarg(1)) == "null") {
  178. debugmes "Quest reward #"+getarg(1)+" invalid (skipped).";
  179. return;
  180. }
  181. setarray .@j[0],getarg(2),getarg(3),getarg(4);
  182. for(set .@i,5; .@i<getargcount(); set .@i,.@i+2) {
  183. if (getitemname(getarg(.@i)) == "null") {
  184. debugmes "Quest requirement #"+getarg(.@i)+" invalid (skipped).";
  185. return;
  186. } else
  187. setarray .@j[.@i-2],getarg(.@i),getarg(.@i+1);
  188. }
  189. copyarray getd(".q_"+getarg(0)+"_"+getarg(1)+"[0]"),.@j[0],getarraysize(.@j);
  190. npcshopadditem "templateshop"+getarg(0),getarg(1),((.ShowZeny)?getarg(3):0);
  191. return;
  192. }
  193.  
  194. function Chk {
  195. if (getarg(0) < getarg(1)) {
  196. set @qe[0],1;
  197. return "^FF0000";
  198. } else
  199. return "^00FF00";
  200. }
  201.  
  202. function Slot {
  203. set .@s$,getitemname(getarg(0));
  204. switch(.ShowSlot) {
  205. case 1: if (!getitemslots(getarg(0))) return .@s$;
  206. case 2: if (getiteminfo(getarg(0),2) == 4 || getiteminfo(getarg(0),2) == 5) return .@s$+" ["+getitemslots(getarg(0))+"]";
  207. default: return .@s$;
  208. }
  209. }
  210. }
  211.  
  212. function script templateshop {
  213. deletearray @i[0],getarraysize(@i);
  214. for(set .@i,0; .@i<getargcount(); set .@i,.@i+1)
  215. set @i[.@i],getarg(.@i);
  216. doevent "quest_shop::OnMenu";
  217. end;
  218. }
  219.  
  220.  
  221. // Dummy shop data -- copy as needed.
  222. //============================================================
  223. - shop templateshop1 -1,909:-1
  224. - shop templateshop2 -1,909:-1
  225. - shop templateshop3 -1,909:-1
  226. - shop templateshop4 -1,909:-1
  227. - shop templateshop5 -1,909:-1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement