1 | //===== eAthena Script ======================================= |
---|
2 | //= Kafra Expres - Stat/Skill Market Module |
---|
3 | //===== By: ================================================== |
---|
4 | //= Skotlex |
---|
5 | //===== Current Version: ===================================== |
---|
6 | //= 2.0 |
---|
7 | //===== Compatible With: ===================================== |
---|
8 | //= eAthena SVN R3579+ |
---|
9 | //===== Description: ========================================= |
---|
10 | //= Part of the Kafra Express Script Package. |
---|
11 | //= Lets players buy/sell skill points/stat points |
---|
12 | //===== Additional Comments: ================================= |
---|
13 | //= See config.txt for configuration. |
---|
14 | //============================================================ |
---|
15 | |
---|
16 | - script keInit_statmarket -1,{ |
---|
17 | OnInit: //Load Config |
---|
18 | donpcevent "keConfig::OnLoadStatMarket"; |
---|
19 | end; |
---|
20 | } |
---|
21 | |
---|
22 | function script F_keStatMarket { |
---|
23 | set @discount,callfunc("F_keCost",100,$@kesm_discount); |
---|
24 | do { |
---|
25 | set @kmenu, select ( |
---|
26 | "- Return", |
---|
27 | "- Buy Stat points ("+($@kesm_stBuyPrice*@discount/100)+"z each)", |
---|
28 | "- Sell Stat points (up to "+StatusPoint+"/"+$@kesm_stSellPrice+"z each)", |
---|
29 | "- Buy Skill points ("+($@kesm_skBuyPrice*@discount/100)+"z each)", |
---|
30 | "- Sell Skill points (up to "+SkillPoint+"/"+$@kesm_skSellPrice+"z each)", |
---|
31 | "- Trade Stats -> Skill ("+$@kesm_skTradePrice+" stats/skill)", |
---|
32 | "- Trade Skills -> Stats ("+$@kesm_stTradePrice+" stats/skill)" |
---|
33 | ); |
---|
34 | if (@kmenu > 1) |
---|
35 | input @qty; |
---|
36 | switch (@kmenu) { |
---|
37 | case 2: //Buy Stat |
---|
38 | set @min, 1; |
---|
39 | set @max, 9999; |
---|
40 | set @cost, @qty*$@kesm_stBuyPrice; |
---|
41 | break; |
---|
42 | case 3: //Sell Stat |
---|
43 | input @qty; |
---|
44 | set @min, 1; |
---|
45 | set @max, StatusPoint; |
---|
46 | set @cost, @qty*$@kesm_stSellPrice; |
---|
47 | break; |
---|
48 | case 4: //Buy Skill |
---|
49 | set @min, 1; |
---|
50 | set @max, 9999; |
---|
51 | set @cost, @qty*$@kesm_skBuyPrice; |
---|
52 | break; |
---|
53 | case 5: //Sell Skill |
---|
54 | set @min, 1; |
---|
55 | set @max, SkillPoint; |
---|
56 | set @cost, @qty*$@kesm_skSellPrice; |
---|
57 | break; |
---|
58 | case 6: //Convert stats -> skills |
---|
59 | set @min, $@kesm_skTradePrice; |
---|
60 | set @max, StatusPoint; |
---|
61 | set @cost, @qty/$@kesm_skTradePrice; |
---|
62 | break; |
---|
63 | case 7: //Convert skills -> stats |
---|
64 | set @min, 1; |
---|
65 | set @max, SkillPoint; |
---|
66 | set @cost, @qty*$@kesm_stTradePrice; |
---|
67 | break; |
---|
68 | default: |
---|
69 | return; |
---|
70 | } |
---|
71 | if (@qty < @min) { |
---|
72 | if (@min == 1) |
---|
73 | callfunc "F_keIntro", e_dots, "Was that supposed to be funny?"; |
---|
74 | else |
---|
75 | callfunc "F_keIntro", e_dots, "That is not enough to buy a single skill..."; |
---|
76 | } else |
---|
77 | if (@qty > @max) { |
---|
78 | if (@max == 9999) |
---|
79 | callfunc "F_keIntro", e_X, "You can't buy that many!"; |
---|
80 | else |
---|
81 | callfunc "F_keIntro", e_X, "You don't have that many to sell..."; |
---|
82 | } else |
---|
83 | if (@cost < 0) { |
---|
84 | callfunc "F_keIntro", e_swt2, "That is too much for a single transaction! Try a smaller quantity... please?"; |
---|
85 | } else { |
---|
86 | switch(@kmenu) { |
---|
87 | case 2: //Buy Stat |
---|
88 | if (!(callfunc("F_keCharge",@cost,$@kesm_discount,1))) { |
---|
89 | callfunc "F_keIntro", e_X, "You do not have enough zeny to buy that many."; |
---|
90 | break; |
---|
91 | } |
---|
92 | set StatusPoint,StatusPoint+@qty; |
---|
93 | emotion e_oh; |
---|
94 | break; |
---|
95 | case 3: //Sell Stat |
---|
96 | set StatusPoint,StatusPoint-@qty; |
---|
97 | set Zeny,Zeny+@cost; |
---|
98 | emotion e_oh; |
---|
99 | break; |
---|
100 | case 4: //Buy Skill |
---|
101 | if (!(callfunc("F_keCharge",@cost,$@kesm_discount,1))) { |
---|
102 | callfunc "F_keIntro", e_X, "You do not have enough zeny to buy that many."; |
---|
103 | break; |
---|
104 | } |
---|
105 | set SkillPoint,SkillPoint+@qty; |
---|
106 | emotion e_oh; |
---|
107 | break; |
---|
108 | case 5: //Sell Skill |
---|
109 | set SkillPoint,SkillPoint-@qty; |
---|
110 | set Zeny,Zeny+@cost; |
---|
111 | emotion e_oh; |
---|
112 | break; |
---|
113 | case 6: //Convert stats -> skills |
---|
114 | set @qty, @cost*$@kesm_skTradePrice; |
---|
115 | set StatusPoint,StatusPoint-@qty; |
---|
116 | set SkillPoint,SkillPoint+@cost; |
---|
117 | emotion e_oh; |
---|
118 | break; |
---|
119 | case 7: //Convert skills -> stats |
---|
120 | set SkillPoint,SkillPoint-@qty; |
---|
121 | set StatusPoint,StatusPoint+@cost; |
---|
122 | emotion e_oh; |
---|
123 | break; |
---|
124 | } |
---|
125 | } |
---|
126 | } while (@kmenu > 1); |
---|
127 | return; |
---|
128 | } |
---|