瀏覽代碼

Merge pull request #1120 from secretdataz/feature/geteqweaponlv

Made a new argument for script command getequipweaponlv
* Added -1 which will return the weapon level that the item is compounded on.
Thanks to @secretdataz!
Aleos 9 年之前
父節點
當前提交
1cd3741055
共有 2 個文件被更改,包括 13 次插入8 次删除
  1. 3 0
      doc/script_commands.txt
  2. 10 8
      src/map/script.c

+ 3 - 0
doc/script_commands.txt

@@ -2648,6 +2648,9 @@ 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 -1 is passed as the equipment slot argument then the 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
 custom items as a flag or something.

+ 10 - 8
src/map/script.c

@@ -8396,22 +8396,24 @@ BUILDIN_FUNC(getequiprefinerycnt)
  *------------------------------------------*/
 BUILDIN_FUNC(getequipweaponlv)
 {
-	int i = -1,num;
+	int i = -1, num;
 	TBL_PC *sd;
 
-	num = script_getnum(st,2);
+	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;
 }