Advertisement
Guest User

vote

a guest
Jul 28th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.50 KB | None | 0 0
  1. //===== Hercules Script ======================================
  2. //= Euphy's Quest Shop
  3. //===== By: ==================================================
  4. //= Euphy
  5. //===== Current Version: =====================================
  6. //= 1.6a
  7. //===== Description: =========================================
  8. //= A dynamic quest shop based on Lunar's, with easier config.
  9. //= Includes support for multiple shops & cashpoints.
  10. //= Item Preview script by ToastOfDoom.
  11. //===== Additional Comments: =================================
  12. //= 1.0 Initial script.
  13. //= 1.2 Added category support.
  14. //= 1.3 More options and fixes.
  15. //= 1.4 Added debug settings.
  16. //= 1.5 Replaced categories with shop IDs.
  17. //= 1.6 Added support for purchasing stackables.
  18. //= 1.6a Added support for previewing costumes and robes.
  19. //============================================================
  20.  
  21. // Shop NPCs -- supplying no argument displays entire menu.
  22. // callfunc "qshop"{,<shop ID>{,<shop ID>{,...}}};
  23. //============================================================
  24. prontera,164,185,4 script Vote Shop 4_M_MOCASS2,{
  25. query_sql("SELECT `points` FROM `cp_v4p_voters` WHERE account_id="+getcharid(3)+" LIMIT 1",.@points);
  26. if (!.@points) {
  27. dispbottom "Your Vote points is "+#VOTEPOINTS;
  28. callfunc "voteshop"; end;
  29. }
  30. query_sql("UPDATE `cp_v4p_voters` SET points=(points-"+.@points+") WHERE account_id='"+getcharid(3)+"'");
  31. set #VOTEPOINTS, #VOTEPOINTS+.@points;
  32. dispbottom "Vote Points updated! Total: "+#VOTEPOINTS;
  33. callfunc "voteshop";
  34. end;
  35. }
  36.  
  37.  
  38. // Script Core
  39. //============================================================
  40. - script voteshop FAKE_NPC,{
  41. function Add; function Chk; function Slot; function A_An;
  42. OnInit:
  43. freeloop(1);
  44.  
  45. // -----------------------------------------------------------
  46. // Basic shop settings.
  47. // -----------------------------------------------------------
  48.  
  49. set .Announce,1; // Announce quest completion? (1: yes / 0: no)
  50. set .ShowSlot,1; // Show item slots? (2: all equipment / 1: if slots > 0 / 0: never)
  51. set .ShowID,0; // Show item IDs? (1: yes / 0: no)
  52. set .ShowZeny,0; // Show Zeny cost, if any? (1: yes / 0: no)
  53. set .MaxStack,100; // Max number of quest items purchased at one time.
  54.  
  55. // -----------------------------------------------------------
  56. // Points variable -- optional quest requirement.
  57. // setarray .Points$[0],"<variable name>","<display name>";
  58. // -----------------------------------------------------------
  59.  
  60. setarray .Points$[0],"#VOTEPOINTS","Vote Points";
  61.  
  62. // -----------------------------------------------------------
  63. // Shop IDs -- to add shops, copy dummy data at bottom of file.
  64. // setarray .Shops$[1],"<Shop 1>","<Shop 2>"{,...};
  65. // -----------------------------------------------------------
  66.  
  67. setarray .Shops$[1],"Shop 1","Shop 2";
  68.  
  69. // -----------------------------------------------------------
  70. // Quest items -- do NOT use a reward item more than once!
  71. // Add(<shop ID>,<reward ID>,<reward amount>,
  72. // <Zeny cost>,<point cost>,
  73. // <required item ID>,<required item amount>{,...});
  74. // -----------------------------------------------------------
  75.  
  76. Add(1,512,100,2,2);
  77. Add(1,502,1,10,10);
  78.  
  79. Add(2,504,1,2,2);
  80.  
  81.  
  82.  
  83. // -----------------------------------------------------------
  84.  
  85. freeloop(0);
  86. set .menu$,"";
  87. for(set .@i,1; .@i<=getarraysize(.Shops$); set .@i,.@i+1) {
  88. set .menu$, .menu$+.Shops$[.@i]+":";
  89. npcshopdelitem "voteshop"+.@i,909;
  90. }
  91. end;
  92.  
  93. OnMenu:
  94. set .@size, getarraysize(@i);
  95. if (!.@size) set .@i, select(.menu$);
  96. else if (.@size == 1) set .@i, @i[0];
  97. else {
  98. for(set .@j,0; .@j<.@size; set .@j,.@j+1)
  99. set .@menu$, .@menu$+.Shops$[@i[.@j]]+":";
  100. set .@i, @i[select(.@menu$)-1];
  101. }
  102. deletearray @i[0],getarraysize(@i);
  103. if (.Shops$[.@i] == "") {
  104. message strcharinfo(PC_NAME),"An error has occurred.";
  105. end;
  106. }
  107. dispbottom "Select one item at a time.";
  108. callshop "voteshop"+.@i,1;
  109. npcshopattach "voteshop"+.@i;
  110. end;
  111.  
  112. OnBuyItem:
  113. // .@q[] : RewardID, BoughtAmt, RewardAmt, BaseAmt, ReqZeny, ReqPts, { ReqItem, ReqAmt, ... }
  114. setarray .@q[0],@bought_nameid[0],((@bought_quantity[0] > .MaxStack)?.MaxStack:@bought_quantity[0]);
  115. copyarray .@q[3],getd(".q_"+.@q[0]+"[0]"),getarraysize(getd(".q_"+.@q[0]));
  116. set .@q[2],.@q[1]*.@q[3];
  117. if (!.@q[2] || .@q[2] > 30000) {
  118. message strcharinfo(PC_NAME),"You can't purchase that many "+getitemname(.@q[0])+".";
  119. end;
  120. }
  121. mes "[Quest Shop]";
  122. mes "Reward: ^0055FF"+((.@q[2] > 1)?.@q[2]+"x ":"")+Slot(.@q[0])+"^000000";
  123. mes "Requirements:";
  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] & 1) || (@qe[1] & 256) || (@qe[1] & 512) || (@qe[1] & 1024) || (@qe[1] & 2048) || (@qe[1] & 4096) || (@qe[1] & 4) || (@qe[1] & 8192)))
  131. set .@preview,1;
  132. addtimer 1000, strnpcinfo(NPC_NAME)+"::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]) 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(PC_NAME)+" has created "+((.@q[2] > 1)?.@q[2]+"x "+getitemname(.@q[0]):A_An(getitemname(.@q[0])))+"!",0;
  152. specialeffect(EF_FLOWERLEAF, AREA, playerattached());
  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(1)+"[0]"),.@j[0],getarraysize(.@j);
  190. npcshopadditem "voteshop"+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. function A_An {
  212. setarray .@A$[0],"a","e","i","o","u";
  213. set .@B$, "_"+getarg(0);
  214. for(set .@i,0; .@i<5; set .@i,.@i+1)
  215. if (compare(.@B$,"_"+.@A$[.@i])) return "an "+getarg(0);
  216. return "a "+getarg(0);
  217. }
  218. }
  219.  
  220. function script voteshop {
  221. deletearray @i[0],getarraysize(@i);
  222. for(set .@i,0; .@i<getargcount(); set .@i,.@i+1)
  223. set @i[.@i],getarg(.@i);
  224. doevent "voteshop::OnMenu";
  225. end;
  226. }
  227.  
  228.  
  229. // Dummy shop data -- copy as needed.
  230. //============================================================
  231. - shop voteshop1 FAKE_NPC,909:-1
  232. - shop voteshop2 FAKE_NPC,909:-1
  233. - shop voteshop3 FAKE_NPC,909:-1
  234. - shop voteshop4 FAKE_NPC,909:-1
  235. - shop voteshop5 FAKE_NPC,909:-1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement