
* Fixes #2445 and fixes #2446. * Fixed shadow refiner. — The script uses the values of the array instead of the indexes to loop through it. * Fixed segfault in getequiprefinecost. — No checks in getequiprefinecost meant there were possibilities using negative indexes in arrays. * Added to the script documentation what happens on failure when calling getequiprefinecost (it returns -1). Thanks to @vstmpf, @crazystorm2017, and @hendra814!
153 lines
5.0 KiB
Plaintext
153 lines
5.0 KiB
Plaintext
//===== rAthena Script =======================================
|
|
//= Shadow Blacksmith
|
|
//===== Description: =========================================
|
|
//= [Official Conversion]
|
|
//= Shadow equipments refining NPC.
|
|
//===== Changelog: ===========================================
|
|
//= 1.0 First version [Aleos]
|
|
//= 1.1 Removed re-roll behavior and fetch materials from db
|
|
//= [Secret]
|
|
//============================================================
|
|
- script ::ShadowBlacksmith -1,{
|
|
.@zeny_cost = 200000; // Zeny cost is 200,000 according to official script [Secret]
|
|
disable_items;
|
|
mes "[Shadow Blacksmith]";
|
|
mes "Do you want to refine a shadow item? Pick yer poison!";
|
|
next;
|
|
setarray .@indices[1], EQI_SHADOW_ARMOR, EQI_SHADOW_WEAPON, EQI_SHADOW_SHIELD, EQI_SHADOW_SHOES, EQI_SHADOW_ACC_R, EQI_SHADOW_ACC_L;
|
|
.@indlen = getarraysize(.@indices) - 1;
|
|
for(.@i = 1; .@i <= .@indlen; .@i++)
|
|
.@menu$ = .@menu$ + (getequipisequiped(.@indices[.@i]) ? getequipname(.@indices[.@i]) : F_getpositionname(.@indices[.@i]) +"-[Not equipped]") +":";
|
|
.@menu$ = .@menu$ + "Refine info";
|
|
.@choice = select(.@menu$);
|
|
if (.@choice == .@indlen + 1) { // Refine info
|
|
mes "[Shadow Blacksmith]";
|
|
mes "When a shadow item is refined, it gains extra bonuses very much like normal items.";
|
|
next;
|
|
mes "[Shadow Blacksmith]";
|
|
mes "Weapon: ATK, MATK + 1 increase for each +1 refine success.";
|
|
mes "Etc: HP + 10 increase for each +1 refine success.";
|
|
next;
|
|
mes "[Shadow Blacksmith]";
|
|
mes "All types of Oridecon and Elunium can be used to refine shadow items. Each attempt will also cost 20,000 zeny.";
|
|
next;
|
|
mes "[Shadow Blacksmith]";
|
|
mes "HD ores can be used for gear that is at least refine level +7 and will prevent breaking as long as you stay talking to me.";
|
|
close;
|
|
}
|
|
|
|
.@part = .@indices[.@choice];
|
|
|
|
if (!getequipisequiped(.@part)) {
|
|
mes "[Shadow Blacksmith]";
|
|
mes "There's nothing here!";
|
|
close;
|
|
}
|
|
|
|
while(1) {
|
|
mes "[Shadow Blacksmith]";
|
|
mes "I require " + callfunc("F_InsertComma", .@zeny_cost) + " zeny as a fee for EACH refine attempt.";
|
|
mes "Choose your Ore and start refining.";
|
|
next;
|
|
.@isNormalEqp = 0;
|
|
if (.@part != EQI_SHADOW_WEAPON)
|
|
.@isNormalEqp = 1;
|
|
|
|
.@material[0] = getequiprefinecost(.@part, REFINE_COST_NORMAL, REFINE_MATERIAL_ID);
|
|
.@material[1] = getequiprefinecost(.@part, REFINE_COST_ENRICHED, REFINE_MATERIAL_ID);
|
|
.@material[2] = getequiprefinecost(.@part, REFINE_COST_HD, REFINE_MATERIAL_ID);
|
|
|
|
if (countitem(.@material[0]))
|
|
.@mate$[0] = getitemname(.@material[0]);
|
|
else {
|
|
.@mate$[0] = "^8C8C8C"+ getitemname(.@material[0]) +"^000000";
|
|
.@miss[0] = 1;
|
|
}
|
|
if (countitem(.@material[1]))
|
|
.@mate$[1] = getitemname(.@material[1]);
|
|
else {
|
|
.@mate$[1] = "^8C8C8C"+ getitemname(.@material[1]) +"^000000";
|
|
.@miss[1] = 1;
|
|
}
|
|
if (getequiprefinerycnt(.@part) > 6 && countitem(.@material[2]))
|
|
.@mate$[2] = getitemname(.@material[2]);
|
|
else {
|
|
.@mate$[2] = "^8C8C8C"+ getitemname(.@material[2]) +"^000000";
|
|
.@miss[2] = 1;
|
|
}
|
|
|
|
.@option = select(.@mate$[0],.@mate$[1],.@mate$[2],"Cancel");
|
|
if (.@option == 4) {
|
|
mes "[Shadow Blacksmith]";
|
|
mes "You've cancelled refining.";
|
|
close;
|
|
}
|
|
else if (.@option == 3) { // HD
|
|
if (getequiprefinerycnt(.@part) < 7) {
|
|
mes "[Shadow Blacksmith]";
|
|
mes "HD Ore can only used for +7 or higher refine level items.";
|
|
close;
|
|
}
|
|
.@hoihoi = 1;
|
|
}
|
|
.@choose = .@material[.@option-1];
|
|
if (!countitem(.@choose)) {
|
|
mes "[Shadow Blacksmith]";
|
|
mes "You do not have enough "+ getitemname(.@choose) +".";
|
|
close;
|
|
}
|
|
if (Zeny < .@zeny_cost) {
|
|
mes "[Shadow Blacksmith]";
|
|
mes "You do not have enough zeny.";
|
|
close;
|
|
}
|
|
if (getequiprefinerycnt(.@part) > 9) {
|
|
mes "[Shadow Blacksmith]";
|
|
mes "Shadow Equipment can be refined to the maximum of 10...";
|
|
close;
|
|
}
|
|
if (!getequipisenableref(.@part)) {
|
|
mes "[Shadow Blacksmith]";
|
|
mes "This item cannot be refined.";
|
|
close;
|
|
}
|
|
if (getequippercentrefinery(.@part) < 100) {
|
|
mes "[Shadow Blacksmith]";
|
|
mes "The safety refine level for Shadow Equipment is +4.";
|
|
if (!.@hoihoi)
|
|
mes "Shadow equipment may be destroyed in subsequent refinements. Want to get started?";
|
|
else
|
|
mes "The next refinement, if it fails, will degrade the refinement. Do you want to refine?";
|
|
next;
|
|
if (select("Proceed","Cancel") == 2) {
|
|
mes "[Shadow Blacksmith]";
|
|
mes "Heh, I knew it!";
|
|
close;
|
|
}
|
|
}
|
|
|
|
mes "[Shadow Blacksmith]";
|
|
mes "Well then.. here goes nothing!";
|
|
next;
|
|
delitem .@choose,1;
|
|
Zeny -= .@zeny_cost;
|
|
if (getequippercentrefinery(.@part, .@option > 1) > rand(100)) {
|
|
successrefitem .@part;
|
|
mes "[Shadow Blacksmith]";
|
|
mes "It worked! It worked!";
|
|
next;
|
|
} else {
|
|
if (.@hoihoi)
|
|
downrefitem .@part;
|
|
else
|
|
failedrefitem .@part;
|
|
mes "[Shadow Blacksmith]";
|
|
mes "Oh Odin No!";
|
|
close;
|
|
}
|
|
}
|
|
}
|
|
|
|
//moc_paraup,45,185,5 duplicate(ShadowBlacksmith) Shadow Blacksmith#eden1 4_F_JOB_BLACKSMITH // Commented out until it's added to the map index
|
|
prt_in,61,54,3 duplicate(ShadowBlacksmith) Shadow Blacksmith#itemmall 4_F_JOB_BLACKSMITH
|