diff options
author | Haru <haru@dotalux.com> | 2017-11-04 20:59:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-04 20:59:36 +0100 |
commit | 94859ffd0f75163b30b883091b7c54bae30beacb (patch) | |
tree | 9a44b23b87cfb88920f690538ac59ba439fa617a | |
parent | 9519c40b00802dfb22070884820ab4a26d7c5ba5 (diff) | |
parent | e6afabe4da2fb32debc4a15ab3a67a897e1b7e77 (diff) | |
download | hercules-94859ffd0f75163b30b883091b7c54bae30beacb.tar.gz hercules-94859ffd0f75163b30b883091b7c54bae30beacb.tar.bz2 hercules-94859ffd0f75163b30b883091b7c54bae30beacb.tar.xz hercules-94859ffd0f75163b30b883091b7c54bae30beacb.zip |
Merge pull request #1865 from dastgir/2017-1_equipoption_mod
setequipoption Modification
-rw-r--r-- | doc/script_commands.txt | 1 | ||||
-rw-r--r-- | src/map/script.c | 35 |
2 files changed, 21 insertions, 15 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 5c730106b..b5718a55e 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -3232,6 +3232,7 @@ Set an equipment's option index or value for the specified option slot. <equipment_index> For a list of equipment indexes see getequipid(). <option_slot> can range from 1 to MAX_ITEM_OPTIONS <type> can be IT_OPT_INDEX (the ID of the option bonus, @see "Id" or "Name" in db/item_options.conf) + removes the equip option if type is 0. <value> The value of the type to be set. returns 0 if value couldn't be set, 1 on success. diff --git a/src/map/script.c b/src/map/script.c index 6b920514c..c218e98a6 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -14270,31 +14270,36 @@ BUILDIN(setequipoption) if (equip_index > 0 && equip_index <= ARRAYLENGTH(script->equip)) { if ((i = pc->checkequip(sd, script->equip[equip_index - 1])) == -1) { - ShowError("buildin_setequipoptioninfo: No equipment is equipped in the given index %d.\n", equip_index); + ShowError("buildin_setequipoption: No equipment is equipped in the given index %d.\n", equip_index); script_pushint(st, 0); return false; } } else { - ShowError("buildin_setequipoptioninfo: Invalid equipment index %d provided.\n", equip_index); + ShowError("buildin_setequipoption: Invalid equipment index %d provided.\n", equip_index); script_pushint(st, 0); return false; } if (sd->status.inventory[i].nameid != 0) { - - if ((ito = itemdb->option_exists(opt_index)) == NULL) { - script_pushint(st, 0); - ShowError("buildin_setequipotion: Option index %d does not exist!\n", opt_index); - return false; - } else if (value < -INT16_MAX || value > INT16_MAX) { - script_pushint(st, 0); - ShowError("buildin_setequipotion: Option value %d exceeds maximum limit (%d to %d) for type!\n", value, -INT16_MAX, INT16_MAX); - return false; + if (opt_index == 0) { + // Remove the option + sd->status.inventory[i].option[slot-1].index = 0; + sd->status.inventory[i].option[slot-1].value = 0; + } else { + if ((ito = itemdb->option_exists(opt_index)) == NULL) { + script_pushint(st, 0); + ShowError("buildin_setequipotion: Option index %d does not exist!\n", opt_index); + return false; + } else if (value < -INT16_MAX || value > INT16_MAX) { + script_pushint(st, 0); + ShowError("buildin_setequipotion: Option value %d exceeds maximum limit (%d to %d) for type!\n", value, -INT16_MAX, INT16_MAX); + return false; + } + /* Add Option Index */ + sd->status.inventory[i].option[slot-1].index = ito->index; + /* Add Option Value */ + sd->status.inventory[i].option[slot-1].value = value; } - /* Add Option Index */ - sd->status.inventory[i].option[slot-1].index = ito->index; - /* Add Option Value */ - sd->status.inventory[i].option[slot-1].value = value; /* Unequip and simulate deletion of the item. */ pc->unequipitem(sd, i, PCUNEQUIPITEM_FORCE); // status calc will happen in pc->equipitem() below |