1 | //===== eAthena Script ======================================= |
---|
2 | //= Kafra Express - Uncarder Module |
---|
3 | //===== By: ================================================== |
---|
4 | //= Skotlex |
---|
5 | //===== Current Version: ===================================== |
---|
6 | //= 1.6 |
---|
7 | //===== Compatible With: ===================================== |
---|
8 | //= eAthena SVN R3424+ |
---|
9 | //===== Description: ========================================= |
---|
10 | //= Part of the Kafra Express Script Package. |
---|
11 | //= Offers uncarding services. |
---|
12 | //===== Additional Comments: ================================= |
---|
13 | //= See config.txt for configuration. |
---|
14 | //============================================================ |
---|
15 | |
---|
16 | - script keInit_uncard -1,{ |
---|
17 | OnInit: //Load Config |
---|
18 | donpcevent "keConfig::OnLoadUncard"; |
---|
19 | end; |
---|
20 | } |
---|
21 | |
---|
22 | function script F_keUncard { |
---|
23 | |
---|
24 | function SF_uncard; |
---|
25 | |
---|
26 | do { |
---|
27 | set @kmenu, select( |
---|
28 | "- Return", |
---|
29 | "- See Price Specifics", |
---|
30 | "- "+getequipname(1), |
---|
31 | "- "+getequipname(2), |
---|
32 | "- "+getequipname(3), |
---|
33 | "- "+getequipname(4), |
---|
34 | "- "+getequipname(5), |
---|
35 | "- "+getequipname(6), |
---|
36 | "- "+getequipname(7), |
---|
37 | "- "+getequipname(8), |
---|
38 | "- "+getequipname(9), |
---|
39 | "- "+getequipname(10) |
---|
40 | ); |
---|
41 | if (@kmenu == 1) |
---|
42 | return; |
---|
43 | if (@kmenu == 2) { //Details |
---|
44 | mes "Okay, listen up..."; |
---|
45 | next; |
---|
46 | mes "["+@name$+"]"; |
---|
47 | if ($@keuc_BaseCost) |
---|
48 | mes "The base cost is of "+$@keuc_BaseCost+"z."; |
---|
49 | mes "Each card to be removed incurs a cost of +"+$@keuc_CardCost+"z."; |
---|
50 | mes "The refine level of the compounded equipment can incur an additional cost:"; |
---|
51 | mes "Armors: "+$@keuc_UpgradeCostA+"z per level."; |
---|
52 | mes "Lv1 Weapons: "+$@keuc_UpgradeCostW1+"z per level."; |
---|
53 | mes "Lv2 Weapons: "+$@keuc_UpgradeCostW2+"z per level."; |
---|
54 | mes "Lv3 Weapons: "+$@keuc_UpgradeCostW3+"z per level."; |
---|
55 | mes "Lv4 Weapons: "+$@keuc_UpgradeCostW4+"z per level."; |
---|
56 | |
---|
57 | if ($@keuc_Mat1 && $@keuc_Qty1) { |
---|
58 | mes "The materials needed are:"; |
---|
59 | mes "- "+$@keuc_Qty1+" "+getitemname($@keuc_Mat1)+"."; |
---|
60 | } |
---|
61 | if ($@keuc_Mat2 && $@keuc_Qty2) |
---|
62 | mes "- "+$@keuc_Qty2+" "+getitemname($@keuc_Mat2)+"."; |
---|
63 | |
---|
64 | if ($@keuc_Fail1Chance || $@keuc_Fail2Chance) |
---|
65 | mes "There is a chance the process might fail and you'll lose your items."; |
---|
66 | |
---|
67 | next; |
---|
68 | callfunc "F_keIntro", -1, ""; |
---|
69 | } else { |
---|
70 | if (SF_uncard(@kmenu-2)) |
---|
71 | return; |
---|
72 | } |
---|
73 | } while (@kmenu >1); |
---|
74 | return; |
---|
75 | |
---|
76 | //Subfunction SF_uncard (equipment-position) |
---|
77 | //Attempts to uncard the equipment. |
---|
78 | function SF_uncard { |
---|
79 | set @part, getarg(0); |
---|
80 | if(getequipcardcnt(@part) == 0) { |
---|
81 | callfunc "F_keIntro", e_ag, "There are no cards to remove there!"; |
---|
82 | return 0; |
---|
83 | } |
---|
84 | set @cost, $@keuc_BaseCost; |
---|
85 | set @cost, @cost + $@keuc_CardCost*getequipcardcnt(@part); |
---|
86 | |
---|
87 | switch (getequipweaponlv(@part)) { |
---|
88 | case 0: //Armor |
---|
89 | set @upgradeCost, $@keuc_UpgradeCostA; |
---|
90 | break; |
---|
91 | case 1: //Lv1 Weapons |
---|
92 | set @upgradeCost, $@keuc_UpgradeCostW1; |
---|
93 | break; |
---|
94 | case 2: //Lv2 Weapons |
---|
95 | set @upgradeCost, $@keuc_UpgradeCostW2; |
---|
96 | break; |
---|
97 | case 3: //Lv3 Weapons |
---|
98 | set @upgradeCost, $@keuc_UpgradeCostW3; |
---|
99 | break; |
---|
100 | default: //Lv4 Weapons |
---|
101 | set @upgradeCost, $@keuc_UpgradeCostW4; |
---|
102 | } |
---|
103 | |
---|
104 | set @cost, @cost + @upgradeCost*getequiprefinerycnt(@part); |
---|
105 | |
---|
106 | set @price, callfunc("F_keCost",@cost,$@keuc_discount); |
---|
107 | |
---|
108 | if ($@keuc_Fail1Chance) { |
---|
109 | set @failsave, select( |
---|
110 | "- Cancel", |
---|
111 | "- Remove cards ("+@price+"z, item gets priority)", |
---|
112 | "- Remove cards ("+@price+"z, cards get priority)" |
---|
113 | ); |
---|
114 | } else { |
---|
115 | set @failsave, select( |
---|
116 | "- Cancel", |
---|
117 | "- Remove cards ("+@price+"z)" |
---|
118 | ); |
---|
119 | } |
---|
120 | if (@failsave == 1) |
---|
121 | return 0; |
---|
122 | set @failsave, @failsave-1; //1: Save item, 2: Save Card |
---|
123 | |
---|
124 | if (($@keuc_Mat1 && countitem($@keuc_Mat1) < $@keuc_Qty1) |
---|
125 | || ($@keuc_Mat2 && countitem($@keuc_Mat2) < $@keuc_Qty2)) { |
---|
126 | callfunc "F_keIntro", e_pif, "You do not have all the materials I need..."; |
---|
127 | return 0; |
---|
128 | } |
---|
129 | |
---|
130 | if (!(callfunc("F_keCharge",@cost,$@keuc_discount,1))) { |
---|
131 | callfunc "F_keIntro", e_ag, "Sorry, you don't have enough zeny."; |
---|
132 | return 0; |
---|
133 | } |
---|
134 | |
---|
135 | if ($@keuc_Mat1 && $@keuc_Qty1) |
---|
136 | delitem $@keuc_Mat1, $@keuc_Qty1; |
---|
137 | if ($@keuc_Mat2 && $@keuc_Qty2) |
---|
138 | delitem $@keuc_Mat2, $@keuc_Qty2; |
---|
139 | |
---|
140 | set @failtype,-1; |
---|
141 | //Recycling cost... |
---|
142 | set @cost, rand(1000); |
---|
143 | if (@cost < $@keuc_Fail2Chance) //Total Failure |
---|
144 | set @failtype, 0; |
---|
145 | else if (@cost < $@keuc_Fail1Chance) //Partial Failure |
---|
146 | set @failtype, @failsave; |
---|
147 | else if (@cost < $@keuc_Fail0Chance) //Harmless Failure |
---|
148 | set @failtype, 3; |
---|
149 | else { //Success |
---|
150 | successremovecards @part; |
---|
151 | emotion e_ho; |
---|
152 | return 1; |
---|
153 | } |
---|
154 | failedremovecards @part,@failtype; |
---|
155 | if (@failtype == 1) |
---|
156 | mes "The cards were lost..."; |
---|
157 | if (@failtype == 2) |
---|
158 | mes "The item was lost..."; |
---|
159 | if (@failtype == 0) |
---|
160 | mes "Lost the cards and item..."; |
---|
161 | callfunc "F_keIntro", e_swt, "...oops."; |
---|
162 | return 1; |
---|
163 | } |
---|
164 | |
---|
165 | } |
---|