diff options
author | Kenpachi Developer <Kenpachi.Developer@gmx.de> | 2020-02-23 06:48:30 +0100 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2021-02-15 17:22:26 -0300 |
commit | 9a9435bba174c0652d88aac7619add73ef918ac1 (patch) | |
tree | 20c3de969700cd0e2c6794a8345f0fa13a83ba98 | |
parent | 283ad82ad91a9029993e69f2e898640f647204d0 (diff) | |
download | hercules-9a9435bba174c0652d88aac7619add73ef918ac1.tar.gz hercules-9a9435bba174c0652d88aac7619add73ef918ac1.tar.bz2 hercules-9a9435bba174c0652d88aac7619add73ef918ac1.tar.xz hercules-9a9435bba174c0652d88aac7619add73ef918ac1.zip |
Add execution of unequip script when entering a zone where item is restricted
In official servers, an item's unequip script is executed when entering a zone where the item is restricted, even if the item won't be unequipped.
-rw-r--r-- | src/map/clif.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index ab8988837..721f5fc37 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -10552,6 +10552,65 @@ static void clif_parse_LoadEndAck(int fd, struct map_session_data *sd) clif->updatestatus(sd, SP_CARTINFO); } + /** + * In official servers, an item's unequip script is executed when entering a zone where the item is restricted, + * even if the item won't be unequipped. + * + **/ + if (map->list[sd->bl.m].zone != NULL && map->list[sd->bl.m].zone->disabled_items_count != 0) { + struct map_zone_data *zone = map->list[sd->bl.m].zone; + int dis_items_cnt = zone->disabled_items_count; + int handled_equip = 0x00000000; + + for (int i = 0; i < EQI_MAX; i++) { + if (sd->equip_index[i] == INDEX_NOT_FOUND) + continue; + + int inv_idx = sd->equip_index[i]; + struct item_data *equip_data = sd->inventory_data[inv_idx]; + + if (equip_data == NULL) + continue; + + if ((handled_equip & equip_data->equip) != 0) + continue; // Equipment takes multiple slots and was already handled. + + handled_equip |= equip_data->equip; + + if (equip_data->unequip_script != NULL) { + int idx; + + ARR_FIND(0, dis_items_cnt, idx, zone->disabled_items[idx] == equip_data->nameid); + + if (idx < dis_items_cnt) + script->run_item_unequip_script(sd, equip_data, npc->fake_nd->bl.id); + } + + if (inv_idx != sd->equip_index[i]) + continue; // Unequip script execution corrupted the inventory index. + + struct item *equip = &sd->status.inventory[inv_idx]; + + if (equip != NULL && !itemdb_isspecial(equip->card[0])) { + for (int slot = 0; slot < equip_data->slot; slot++) { + if (equip->card[slot] == 0) + continue; + + struct item_data *card_data = itemdb->exists(equip->card[slot]); + + if (card_data != NULL && card_data->unequip_script != NULL) { + int idx; + + ARR_FIND(0, dis_items_cnt, idx, zone->disabled_items[idx] == card_data->nameid); + + if (idx < dis_items_cnt) + script->run_item_unequip_script(sd, card_data, npc->fake_nd->bl.id); + } + } + } + } + } + // Check for and delete unavailable/disabled items. pc->checkitem(sd); |