1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
|
//===== eAthena Script =======================================
//= Kafra Express - Refining Module
//===== By: ==================================================
//= Skotlex
//===== Current Version: =====================================
//= 2.7
//===== Compatible With: =====================================
//= eAthena SVN R3424+
//===== Description: =========================================
//= Part of the Kafra Express Script Package.
//= Does item forging, ore purifying and repairing.
//= Can also sell phracon/emveretarcon
//===== Additional Comments: =================================
//= See config.txt for configuration.
//============================================================
- script keInit_refine {
OnInit: //Load Config
donpcevent "keConfig::OnLoadRefine";
end;
}
function script F_keRefine {
function SF_refine;
function SF_repair;
function SF_purify;
function SF_sellOres;
do {
set @kmenu, select(
"- Return",
"- Refine Equipment",
"- Repair Equipment",
"- Buy Ores",
"- Purify Ores",
);
switch(@kmenu) {
case 2: //Refine
SF_refine();
break;
case 3: //Repair
SF_repair();
break;
case 4: //Buy Ore
SF_sellOres();
break;
case 5: //Purify Ore
SF_purify();
break;
}
} while (@kmenu > 1);
return;
//Subfunction SF_refine, presents the refining menu.
function SF_refine {
do {
set @part, select(
"- Cancel upgrading",
"- "+getequipname(1),
"- "+getequipname(2),
"- "+getequipname(3),
"- "+getequipname(4),
"- "+getequipname(5),
"- "+getequipname(6),
"- "+getequipname(7),
"- "+getequipname(8),
"- "+getequipname(9),
"- "+getequipname(10)
);
set @part, @part-1;
if (@part == 0)
break;
if (getequipisequiped(@part) == 0) {
callfunc "F_keIntro", e_swt, "There is nothing to refine there...";
} else
if(getequipisenableref(@part) == 0 && $@kerf_refineAll == 0) {
callfunc "F_keIntro", -1, "Sorry, this item cannot be refined.";
} else
if(getequiprefinerycnt(@part) >= $@kerf_maxLv) {
callfunc "F_keIntro", -1, "This item cannot be refined further.";
break;
} else {
switch (getequipweaponlv(@part))
{
case 0: //Armor
set @mat,985;
set @cost,$@kerf_armorCost;
break;
case 1:
set @mat,1010;
set @cost,$@kerf_weaponLv1Cost;
break;
case 2:
set @mat,1011;
set @cost,$@kerf_weaponLv2Cost;
break;
case 3:
set @mat,984;
set @cost,$@kerf_weaponLv3Cost;
break;
default:
set @mat,984;
set @cost,$@kerf_weaponLv4Cost;
break;
}
set @cost, callfunc("F_keCost",@cost,$@kerf_discount);
do {
if ($@kerf_safe==0 && getequippercentrefinery(@part) < 100) {
if ($@kerf_showChance) {
if (select(
"- Return ("+(100-getequippercentrefinery(@part))+"% chance refine will fail)",
"- Refine (Need "+getitemname(@mat)+" and "+@cost+"z)") != 2)
break;
} else {
if (select(
"- Return (Upgrade not safe, item might break!)",
"- Refine (Need "+getitemname(@mat)+" and "+@cost+"z)") != 2)
break;
}
} else {
if (select(
"- Refine (Need "+getitemname(@mat)+" and "+@cost+"z)",
"- Cancel") != 1)
break;
}
if (getequiprefinerycnt(@part) >= $@kerf_maxLv) {
callfunc "F_keIntro", e_ok, "This item has reached it's maximum level.";
break;
}
if (countitem(@mat) < 1) {
callfunc "F_keIntro", e_ag, "Sorry, you don't have the materials I need.";
break;
}
if (!(callfunc("F_keCharge",@cost,$@kerf_discount,1))) {
callfunc "F_keIntro", e_ag, "Sorry, you don't have enough zeny.";
break;
}
delitem @mat,1;
if ($@kerf_safe || getequippercentrefinery(@part)>rand(100)) {
successrefitem @part;
emotion e_rock;
} else {
failedrefitem @part;
callfunc "F_keIntro", e_swt, "...sorry.";
break;
}
} while (1);
}
} while (@part > 0);
return;
}
//Subfunction: SF_repair()
function SF_repair {
set @cost,callfunc("F_keCost",$@kerf_repairCost,$@kerf_repairDiscount);
do {
set @broken1,getbrokenid(1);
if(@broken1==NULL) {
callfunc "F_keIntro", -1, "You don't need anything repaired for now.";
return;
}
set @broken2,getbrokenid(2);
set @broken3,getbrokenid(3);
set @broken4,getbrokenid(4);
set @broken5,getbrokenid(5);
set @broken6,getbrokenid(6);
set @broken7,getbrokenid(7);
set @broken8,getbrokenid(8);
set @broken9,getbrokenid(9);
set @broken10,getbrokenid(10);
if ($@kerf_repairSteel)
set @str$,"- Cancel (Repairing costs "+@cost+"z and 1 "+getitemname(999);
else
set @str$,"- Cancel (Repairing costs "+@cost+"z)";
set @idRepair, select(
@str$,
getitemname(@broken1),
getitemname(@broken2),
getitemname(@broken3),
getitemname(@broken4),
getitemname(@broken5),
getitemname(@broken6),
getitemname(@broken7),
getitemname(@broken8),
getitemname(@broken9),
getitemname(@broken10)
);
set @idRepair, @idRepair-1;
if (@idRepair == 0) break;
if ($@kerf_repairSteel && countitem(999) < 1) {
callfunc "F_keIntro", e_ag, "Sorry, you don't have the materials I need.";
return;
}
if (!(callfunc("F_keCharge", $@kerf_repairCost, $@kerf_repairDiscount,1))) {
callfunc "F_keIntro", e_ag, "Sorry, you don't have enough zeny.";
return;
}
if ($@kerf_repairSteel) delitem 999,1;
repair(@idRepair);
emotion e_lv2;
} while (@idRepair > 0);
}
//Subfunction: SF_purify()
function SF_purify {
if ($@kerf_purifyAll) {
set @submenu, select (
"- Return",
"- Purify "+getitemname(984)+" (need 5 "+getitemname(756)+")",
"- Purify "+getitemname(985)+" (need 5 "+getitemname(757)+")",
"- Purify "+getitemname(998)+" (need 2 "+getitemname(1002)+")",
"- Temper "+getitemname(999)+" (need 5 "+getitemname(998)+", 1 "+getitemname(1003)+")",
"- Temper "+getitemname(994)+" (need 10 "+getitemname(990)+")",
"- Temper "+getitemname(995)+" (need 10 "+getitemname(991)+")",
"- Temper "+getitemname(996)+" (need 10 "+getitemname(992)+")",
"- Temper "+getitemname(997)+" (need 10 "+getitemname(993)+")",
"- Temper "+getitemname(1000)+" (need 10 "+getitemname(1001)+")"
);
} else {
set @submenu, select(
"- Return",
"- Purify "+getitemname(984)+" (need 5 "+getitemname(756)+")",
"- Purify "+getitemname(985)+" (need 5 "+getitemname(757)+")"
);
}
switch (@submenu) {
case 2: //Oridecon
set @item, 984;
set @rough, 756;
set @qty, 5;
break;
case 3: //Elunium
set @item, 985;
set @rough, 757;
set @qty, 5;
break;
case 4: //Iron
set @item, 998;
set @rough, 1002;
set @qty, 2;
break;
case 5: //Steel
set @item,999;
set @rough,998;
set @qty,5;
set @rough2,1003;
set @qty2,1;
set @count,countitem(@rough1);
set @count2,countitem(@rough2);
if (@count < @qty || @count2 < @qty2) {
callfunc "F_keIntro", e_ag, "Sorry, you don't have the materials I need.";
return;
}
set @count, @count/@qty;
set @count2, @count2/@qty2;
if (@count2 < @count)
set @count,@count2;
delitem @rough2,@qty2*@count;
break;
case 6: //Fire
set @item, 994;
set @rough, 990;
set @qty, 10;
break;
case 7: //Ice
set @item, 995;
set @rough, 991;
set @qty, 10;
break;
case 8: //Wind
set @item, 996;
set @rough, 992;
set @qty, 10;
break;
case 9: //Earth
set @item, 997;
set @rough, 993;
set @qty, 10;
break;
case 10: //Star
set @item, 1000;
set @rough, 1001;
set @qty, 10;
break;
default:
return;
}
set @count,countitem(@rough);
if (@count < @qty) {
callfunc "F_keIntro", e_ag, "Sorry, you don't have the materials I need.";
return;
}
set @count, @count/@qty;
delitem @rough,@qty*@count;
getitem @item,@count;
emotion e_paper;
}
//Subfunction: SF_sellOres()
function SF_sellOres {
do {
set @submenu, select(
"- Return",
"- Buy "+getitemname(1010)+" (200z each)",
"- Buy "+getitemname(1011)+" (1000z each)"
);
switch (@submenu) {
case 2: //Phracon
set @mat, 1010;
set @cost, 200;
break;
case 3: //Emveratarcon
set @mat, 1011;
set @cost, 1000;
break;
default:
return;
}
input @qty;
set @cost,@cost*@qty;
if (@qty < 1) {
callfunc "F_keIntro", e_pif, "That is NOT a valid quantity...";
} else if (@cost > Zeny) {
callfunc "F_keIntro", e_ag, "Sorry, you don't have enough zeny.";
} else if (@cost < 0) {
callfunc "F_keIntro", e_swt2, "Sorry, that's too much! Try buying less...";
} else {
set Zeny,Zeny-@cost;
getitem @mat,@qty;
emotion e_paper;
}
} while (@submenu > 1);
}
}
|