check if you have other items equip with endure bonus.

1 hour ago, Dduwsmitt said:
additional info.
After successfully removing the card, the script command 'successremovecards' fails to re-equip the item.
View attachment 6656
it seems pc->equipitem(sd, i, sd->status.inventory.equip); is not working properly.
pc->unequipitem(sd, i, PCUNEQUIPITEM_FORCE); does not recalculate stats so we rely on the pc->equipitem(sd, i, sd->status.inventory.equip); to recalculate the stats thus not triggering the OnUnequipScript.
i dont know how to fix it tho.![]()
/// Removes all cards from the item found in the specified equipment slot of the invoking character,
/// and give them to the character. If any cards were removed in this manner, it will also show a success effect.
/// successremovecards(<slot>
static BUILDIN(successremovecards)
{
int i = -1, c, cardflag = 0;
struct map_session_data *sd = script->rid2sd(st);
int num = script_getnum(st, 2);
if (sd == NULL)
return true;
if (num > 0 && num <= ARRAYLENGTH(script->equip))
i = pc->checkequip(sd,script->equip[num - 1]);
if (i < 0 || sd->inventory_data == NULL)
return true;
if (itemdb_isspecial(sd->status.inventory.card[0]))
return true;
for (c = sd->inventory_data->slot - 1; c >= 0; --c) {
if (sd->status.inventory.card[c] > 0 && itemdb_type(sd->status.inventory.card[c]) == IT_CARD) {
int flag;
struct item item_tmp;
memset(&item_tmp, 0, sizeof(item_tmp));
cardflag = 1;
item_tmp.nameid = sd->status.inventory.card[c];
item_tmp.identify = 1;
sd->status.inventory.card[c] = 0;
if ((flag = pc->additem(sd, &item_tmp, 1, LOG_TYPE_SCRIPT))) {
clif->additem(sd, 0, 0, flag);
map->addflooritem(&sd->bl, &item_tmp, 1, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 0, false);
}
}
}
if (cardflag == 1) {
pc->unequipitem(sd, i, PCUNEQUIPITEM_FORCE);
clif->delitem(sd, i, 1, DELITEM_MATERIALCHANGE);
clif->additem(sd, i, 1, 0);
pc->equipitem(sd, i, sd->status.inventory.equip); //THIS LINE HERE FAILS TO WORK
clif->misceffect(&sd->bl,3);
}
return true;
}
/// Removes all cards from the item found in the specified equipment slot of the invoking character,
/// and give them to the character. If any cards were removed in this manner, it will also show a success effect.
/// successremovecards(<slot>
static BUILDIN(successremovecards)
{
int i = -1, c, cardflag = 0;
struct map_session_data *sd = script->rid2sd(st);
int num = script_getnum(st, 2);
if (sd == NULL)
return true;
if (num > 0 && num <= ARRAYLENGTH(script->equip))
i = pc->checkequip(sd,script->equip[num - 1]);
if (i < 0 || sd->inventory_data == NULL)
return true;
if (itemdb_isspecial(sd->status.inventory.card[0]))
return true;
for (c = sd->inventory_data->slot - 1; c >= 0; --c) {
if (sd->status.inventory.card[c] > 0 && itemdb_type(sd->status.inventory.card[c]) == IT_CARD) {
int flag;
struct item item_tmp;
memset(&item_tmp, 0, sizeof(item_tmp));
cardflag = 1;
item_tmp.nameid = sd->status.inventory.card[c];
item_tmp.identify = 1;
sd->status.inventory.card[c] = 0;
if ((flag = pc->additem(sd, &item_tmp, 1, LOG_TYPE_SCRIPT))) {
clif->additem(sd, 0, 0, flag);
map->addflooritem(&sd->bl, &item_tmp, 1, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 0, false);
}
}
}
if (cardflag == 1) {
pc->unequipitem(sd, i, PCUNEQUIPITEM_FORCE);
clif->delitem(sd, i, 1, DELITEM_MATERIALCHANGE);
clif->additem(sd, i, 1, 0);
pc->equipitem(sd, i, sd->status.inventory.equip); //THIS LINE HERE FAILS TO WORK
clif->misceffect(&sd->bl,3);
}
return true;
}
We use essential cookies to make this site work, and optional cookies to enhance your experience.