diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 2d6f8e5377..e9990ddeef 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -2642,14 +2642,14 @@ this is +10: --------------------------------------- -*getequipweaponlv({,}) +*getequipweaponlv({,}) This function returns the weapon level for the weapon equipped in the specified equipment slot on the invoking character. For a list of equipment slots see 'getequipid'. -If no arguments are provided. Weapon level for the item calling this function -assuming it is called by an item script will be returned. Otherwise, 0 will be returned. +If -1 is passed as argument. Weapon level for the item calling this function, +assuming it is called by an item script, will be returned. Otherwise, 0 will be returned. Only EQI_HAND_L and EQI_HAND_R normally make sense, since only weapons have a weapon level. You can, however, probably, use this field for other equippable diff --git a/src/map/script.c b/src/map/script.c index 675f508496..c37c171f8f 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -8392,37 +8392,28 @@ BUILDIN_FUNC(getequiprefinerycnt) * return (npc) * x : weapon level * 0 : false - * getequipweaponlv({,}) + * getequipweaponlv({,}) *------------------------------------------*/ BUILDIN_FUNC(getequipweaponlv) { - int i = -1,num; + int i = -1, num; TBL_PC *sd; - if (!script_hasdata(st, 2)) { - if ((sd = script_rid2sd(st)) != NULL && current_equip_item_index < MAX_INVENTORY && sd->inventory_data[current_equip_item_index]) - { - script_pushint(st, sd->inventory_data[current_equip_item_index]->wlv); - } - else { - script_pushint(st, 0); - } - return SCRIPT_CMD_SUCCESS; - } - num = script_getnum(st, 2); if (!script_charid2sd(3, sd)) { - script_pushint(st,0); + script_pushint(st, 0); return SCRIPT_CMD_FAILURE; } - if (num > 0 && num <= ARRAYLENGTH(equip)) - i=pc_checkequip(sd,equip[num-1]); - if(i >= 0 && sd->inventory_data[i]) - script_pushint(st,sd->inventory_data[i]->wlv); + if (num == -1) + i = current_equip_item_index; + else if (num > 0 && num <= ARRAYLENGTH(equip)) + i = pc_checkequip(sd, equip[num - 1]); + if (i >= 0 && sd->inventory_data[i]) + script_pushint(st, sd->inventory_data[i]->wlv); else - script_pushint(st,0); + script_pushint(st, 0); return SCRIPT_CMD_SUCCESS; } @@ -21450,7 +21441,7 @@ struct script_function buildin_func[] = { BUILDIN_DEF(getequipisequiped,"i?"), BUILDIN_DEF(getequipisenableref,"i?"), BUILDIN_DEF(getequiprefinerycnt,"i?"), - BUILDIN_DEF(getequipweaponlv,"??"), + BUILDIN_DEF(getequipweaponlv,"i?"), BUILDIN_DEF(getequippercentrefinery,"i?"), BUILDIN_DEF(successrefitem,"i??"), BUILDIN_DEF(failedrefitem,"i?"),