1 //===== rAthena Script =======================================
3 //===== By: ==================================================
5 //===== Current Version: =====================================
7 //===== Compatible With: =====================================
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 //============================================================
25 // Shop NPCs -- supplying no argument displays entire menu.
26 // callfunc "qshop"{,<shop ID>{,<shop ID>{,...}}};
27 //============================================================
28 prontera,164,203,6 script Quest Shop#1 998,{ callfunc "qshop"; }
32 //============================================================
33 - script quest_shop -1,{
34 function Add; function Chk; function Slot;
38 // -----------------------------------------------------------
39 // Basic shop settings.
40 // -----------------------------------------------------------
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.
48 // -----------------------------------------------------------
49 // Points variable -- optional quest requirement.
50 // setarray .Points$[0],"<variable name>","<display name>";
51 // -----------------------------------------------------------
53 setarray .Points$[0],"#CASHPOINTS","Cash Points";
55 // -----------------------------------------------------------
56 // Shop IDs -- to add shops, copy dummy data at bottom of file.
57 // setarray .Shops$[1],"<Shop 1>","<Shop 2>"{,...};
58 // -----------------------------------------------------------
60 setarray .Shops$[1],"Headgears","Weapons","Other";
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 // -----------------------------------------------------------
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);
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);
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);
82 // -----------------------------------------------------------
86 for(set .@i,1; .@i<=getarraysize(.Shops$); set .@i,.@i+1) {
87 set .menu$, .menu$+.Shops$[.@i]+":";
88 npcshopdelitem "qshop"+.@i,909;
93 set .@size, getarraysize(@i);
94 if (!.@size) set @shop_index, select(.menu$);
95 else if (.@size == 1) set @shop_index, @i[0];
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];
101 deletearray @i[0],getarraysize(@i);
102 if (.Shops$[@shop_index] == "") {
103 message strcharinfo(0),"An error has occurred.";
106 dispbottom "Select one item at a time.";
107 callshop "qshop"+@shop_index,1;
108 npcshopattach "qshop"+@shop_index;
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])+".";
121 mes "Reward: ^0055FF"+((.@q[2] > 1)?.@q[2]+"x ":"")+Slot(.@q[0])+"^000000";
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";
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)))
132 addtimer 1000, strnpcinfo(0)+"::OnEnd";
134 switch(select(" ~ Purchase ^0055FF"+getitemname(.@q[0])+"^000000:"+((.@preview && !@qe[7])?" ~ Preview...":"")+": ~ ^777777Cancel^000000")) {
138 mes "You're missing one or more quest requirements.";
141 if (!checkweight(.@q[0],.@q[2])) {
143 mes "^FF0000You need "+(((.@q[2]*getiteminfo(.@q[0],6))+Weight-MaxWeight)/10)+" additional weight capacity to complete this trade.^000000";
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;
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];
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];
173 deletearray @qe[0],8;
177 if (getitemname(getarg(1)) == "null") {
178 debugmes "Quest reward #"+getarg(1)+" invalid (skipped).";
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).";
187 setarray .@j[.@i-2],getarg(.@i),getarg(.@i+1);
189 copyarray getd(".q_"+getarg(0)+"_"+getarg(1)+"[0]"),.@j[0],getarraysize(.@j);
190 npcshopadditem "qshop"+getarg(0),getarg(1),((.ShowZeny)?getarg(3):0);
195 if (getarg(0) < getarg(1)) {
203 set .@s$,getitemname(getarg(0));
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$;
212 function script qshop {
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";
221 // Dummy shop data -- copy as needed.
222 //============================================================
223 - shop qshop1 -1,909:-1
224 - shop qshop2 -1,909:-1
225 - shop qshop3 -1,909:-1
226 - shop qshop4 -1,909:-1
227 - shop qshop5 -1,909:-1