Advertisement
Guest User

Untitled

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