Shadow Refiner and getequiprefinecost (#2447)
* 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!
This commit is contained in:
parent
052b9bc819
commit
cd43f32ffb
@ -2760,6 +2760,9 @@ Valid information types are:
|
|||||||
REFINE_ZENY_COST - Zeny
|
REFINE_ZENY_COST - Zeny
|
||||||
REFINE_MATERIAL_ID - Material Item ID
|
REFINE_MATERIAL_ID - Material Item ID
|
||||||
|
|
||||||
|
This function will return -1 on failure. The function fails if the cost type
|
||||||
|
is invalid or if there is no item in the equipment slot.
|
||||||
|
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
*getareadropitem("<map name>",<x1>,<y1>,<x2>,<y2>,<item>)
|
*getareadropitem("<map name>",<x1>,<y1>,<x2>,<y2>,<item>)
|
||||||
|
@ -15,12 +15,12 @@
|
|||||||
mes "Do you want to refine a shadow item? Pick yer poison!";
|
mes "Do you want to refine a shadow item? Pick yer poison!";
|
||||||
next;
|
next;
|
||||||
setarray .@indices[1], EQI_SHADOW_ARMOR, EQI_SHADOW_WEAPON, EQI_SHADOW_SHIELD, EQI_SHADOW_SHOES, EQI_SHADOW_ACC_R, EQI_SHADOW_ACC_L;
|
setarray .@indices[1], EQI_SHADOW_ARMOR, EQI_SHADOW_WEAPON, EQI_SHADOW_SHIELD, EQI_SHADOW_SHOES, EQI_SHADOW_ACC_R, EQI_SHADOW_ACC_L;
|
||||||
for(.@i = 1; .@i <= EQI_SHADOW_ACC_L; .@i++)
|
.@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$ + (getequipisequiped(.@indices[.@i]) ? getequipname(.@indices[.@i]) : F_getpositionname(.@indices[.@i]) +"-[Not equipped]") +":";
|
||||||
.@menu$ = .@menu$ + "Refine info";
|
.@menu$ = .@menu$ + "Refine info";
|
||||||
.@part = .@indices[select(.@menu$)];
|
.@choice = select(.@menu$);
|
||||||
|
if (.@choice == .@indlen + 1) { // Refine info
|
||||||
if (.@part == EQI_SHADOW_ACC_L + 1) { // Refine info
|
|
||||||
mes "[Shadow Blacksmith]";
|
mes "[Shadow Blacksmith]";
|
||||||
mes "When a shadow item is refined, it gains extra bonuses very much like normal items.";
|
mes "When a shadow item is refined, it gains extra bonuses very much like normal items.";
|
||||||
next;
|
next;
|
||||||
@ -35,6 +35,15 @@
|
|||||||
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.";
|
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;
|
close;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.@part = .@indices[.@choice];
|
||||||
|
|
||||||
|
if (!getequipisequiped(.@part)) {
|
||||||
|
mes "[Shadow Blacksmith]";
|
||||||
|
mes "There's nothing here!";
|
||||||
|
close;
|
||||||
|
}
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
mes "[Shadow Blacksmith]";
|
mes "[Shadow Blacksmith]";
|
||||||
mes "I require " + callfunc("F_InsertComma", .@zeny_cost) + " zeny as a fee for EACH refine attempt.";
|
mes "I require " + callfunc("F_InsertComma", .@zeny_cost) + " zeny as a fee for EACH refine attempt.";
|
||||||
@ -84,7 +93,7 @@
|
|||||||
.@choose = .@material[.@option-1];
|
.@choose = .@material[.@option-1];
|
||||||
if (!countitem(.@choose)) {
|
if (!countitem(.@choose)) {
|
||||||
mes "[Shadow Blacksmith]";
|
mes "[Shadow Blacksmith]";
|
||||||
mes "You do not have enough "+ getitemname(.@choose) +" / "+ getitemname(.@choose) +".";
|
mes "You do not have enough "+ getitemname(.@choose) +".";
|
||||||
close;
|
close;
|
||||||
}
|
}
|
||||||
if (Zeny < .@zeny_cost) {
|
if (Zeny < .@zeny_cost) {
|
||||||
|
@ -23565,6 +23565,7 @@ BUILDIN_FUNC(achievementupdate) {
|
|||||||
/**
|
/**
|
||||||
* Get an equipment's refine cost
|
* Get an equipment's refine cost
|
||||||
* getequiprefinecost(<equipment slot>,<type>,<information>{,<char id>})
|
* getequiprefinecost(<equipment slot>,<type>,<information>{,<char id>})
|
||||||
|
* returns -1 on fail
|
||||||
*/
|
*/
|
||||||
BUILDIN_FUNC(getequiprefinecost) {
|
BUILDIN_FUNC(getequiprefinecost) {
|
||||||
int i = -1, slot, type, info;
|
int i = -1, slot, type, info;
|
||||||
@ -23579,9 +23580,19 @@ BUILDIN_FUNC(getequiprefinecost) {
|
|||||||
return SCRIPT_CMD_FAILURE;
|
return SCRIPT_CMD_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type < 0 || type >= REFINE_COST_MAX) {
|
||||||
|
script_pushint(st, -1);
|
||||||
|
return SCRIPT_CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
if (equip_index_check(slot))
|
if (equip_index_check(slot))
|
||||||
i = pc_checkequip(sd, equip_bitmask[slot]);
|
i = pc_checkequip(sd, equip_bitmask[slot]);
|
||||||
|
|
||||||
|
if (i < 0) {
|
||||||
|
script_pushint(st, -1);
|
||||||
|
return SCRIPT_CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
int weapon_lv = sd->inventory_data[i]->wlv;
|
int weapon_lv = sd->inventory_data[i]->wlv;
|
||||||
if (sd->inventory_data[i]->type == IT_SHADOWGEAR) {
|
if (sd->inventory_data[i]->type == IT_SHADOWGEAR) {
|
||||||
if (sd->inventory_data[i]->equip == EQP_SHADOW_WEAPON)
|
if (sd->inventory_data[i]->equip == EQP_SHADOW_WEAPON)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user