Browse Source

Make arguments in getequipweaponlv command optional

Jittapan Pluemsumran 9 years ago
parent
commit
5e9489bbf2
2 changed files with 18 additions and 4 deletions
  1. 4 1
      doc/script_commands.txt
  2. 14 3
      src/map/script.c

+ 4 - 1
doc/script_commands.txt

@@ -2642,12 +2642,15 @@ this is +10:
 
 
 ---------------------------------------
 ---------------------------------------
 
 
-*getequipweaponlv(<equipment slot>{,<char_id>})
+*getequipweaponlv({<equipment slot>,<char_id>})
 
 
 This function returns the weapon level for the weapon equipped in the specified 
 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 
 equipment slot on the invoking character. For a list of equipment slots see 
 'getequipid'.
 'getequipid'.
 
 
+If no arguments are provided. Weapon level for the item calling this function
+assuming it is called by an item script. Otherwise, 0 will be returned.
+
 Only EQI_HAND_L and EQI_HAND_R normally make sense, since only weapons have
 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
 a weapon level. You can, however, probably, use this field for other equippable
 custom items as a flag or something.
 custom items as a flag or something.

+ 14 - 3
src/map/script.c

@@ -8392,14 +8392,25 @@ BUILDIN_FUNC(getequiprefinerycnt)
  * return (npc)
  * return (npc)
  *	x : weapon level
  *	x : weapon level
  *	0 : false
  *	0 : false
- * getequipweaponlv(<equipment slot>{,<char_id>})
+ * getequipweaponlv({<equipment slot>,<char_id>})
  *------------------------------------------*/
  *------------------------------------------*/
 BUILDIN_FUNC(getequipweaponlv)
 BUILDIN_FUNC(getequipweaponlv)
 {
 {
 	int i = -1,num;
 	int i = -1,num;
 	TBL_PC *sd;
 	TBL_PC *sd;
 
 
-	num = script_getnum(st,2);
+	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)) {
 	if (!script_charid2sd(3, sd)) {
 		script_pushint(st,0);
 		script_pushint(st,0);
@@ -21439,7 +21450,7 @@ struct script_function buildin_func[] = {
 	BUILDIN_DEF(getequipisequiped,"i?"),
 	BUILDIN_DEF(getequipisequiped,"i?"),
 	BUILDIN_DEF(getequipisenableref,"i?"),
 	BUILDIN_DEF(getequipisenableref,"i?"),
 	BUILDIN_DEF(getequiprefinerycnt,"i?"),
 	BUILDIN_DEF(getequiprefinerycnt,"i?"),
-	BUILDIN_DEF(getequipweaponlv,"i?"),
+	BUILDIN_DEF(getequipweaponlv,"??"),
 	BUILDIN_DEF(getequippercentrefinery,"i?"),
 	BUILDIN_DEF(getequippercentrefinery,"i?"),
 	BUILDIN_DEF(successrefitem,"i??"),
 	BUILDIN_DEF(successrefitem,"i??"),
 	BUILDIN_DEF(failedrefitem,"i?"),
 	BUILDIN_DEF(failedrefitem,"i?"),