瀏覽代碼

Added Random Option item data to getinventorylist (#3030)

* Closes #3021.
* Added Random Option item data to script command getinventorylist return values.
Thanks to @Yuchinin!
Aleos 7 年之前
父節點
當前提交
f07a1c4b4d
共有 2 個文件被更改,包括 40 次插入16 次删除
  1. 30 15
      doc/script_commands.txt
  2. 10 1
      src/map/script.cpp

+ 30 - 15
doc/script_commands.txt

@@ -2809,21 +2809,36 @@ This command sets a bunch of arrays with a complete list of whatever the
 invoking character has in their inventory, including all the data needed to
 invoking character has in their inventory, including all the data needed to
 recreate these items perfectly if they are destroyed. Here's what you get:
 recreate these items perfectly if they are destroyed. Here's what you get:
 
 
-@inventorylist_id[]        - array of item ids.
-@inventorylist_amount[]    - their corresponding item amounts.
-@inventorylist_equip[]     - on which position the item is equipped (see EQP_* constants)
-                             It will contain 0 if the item is not equipped.
-@inventorylist_refine[]    - for how much it is refined.
-@inventorylist_identify[]  - whether it is identified.
-@inventorylist_attribute[] - whether it is broken.
-@inventorylist_card1[]     - These four arrays contain card data for the items.
-@inventorylist_card2[]       These data slots are also used to store names
-@inventorylist_card3[]       inscribed on the items, so you can explicitly check
-@inventorylist_card4[]       if the character owns an item made by a specific
-                             craftsman.
-@inventorylist_expire[]    - expire time (Unix time stamp). 0 means never expires.
-@inventorylist_bound[]     - the bound type of the items (see BOUND_* constants)
-@inventorylist_count       - the number of items in these lists.
+@inventorylist_id[]                - array of item ids.
+@inventorylist_amount[]            - their corresponding item amounts.
+@inventorylist_equip[]             - on which position the item is equipped (see EQP_* constants)
+                                     It will contain 0 if the item is not equipped.
+@inventorylist_refine[]            - for how much it is refined.
+@inventorylist_identify[]          - whether it is identified.
+@inventorylist_attribute[]         - whether it is broken.
+@inventorylist_card1[]             - These four arrays contain card data for the items.
+@inventorylist_card2[]               These data slots are also used to store names
+@inventorylist_card3[]               inscribed on the items, so you can explicitly check
+@inventorylist_card4[]               if the character owns an item made by a specific
+                                     craftsman.
+@inventorylist_expire[]            - expire time (Unix time stamp). 0 means never expires.
+@inventorylist_bound[]             - the bound type of the items (see BOUND_* constants)
+@inventorylist_count               - the number of items in these lists.
+@inventorylist_option_id1[]        - first array of random option IDs
+@inventorylist_option_value1[]     - first array of random option values
+@inventorylist_option_parameter1[] - first array of random option parameters
+@inventorylist_option_id2[]        - second array of random option IDs
+@inventorylist_option_value2[]     - second array of random option values
+@inventorylist_option_parameter2[] - second array of random option parameters
+@inventorylist_option_id3[]        - third array of random option IDs
+@inventorylist_option_value3[]     - third array of random option values
+@inventorylist_option_parameter3[] - third array of random option parameters
+@inventorylist_option_id4[]        - fourth array of random option IDs
+@inventorylist_option_value4[]     - fourth array of random option values
+@inventorylist_option_parameter4[] - fourth array of random option parameters
+@inventorylist_option_id5[]        - fifth array of random option IDs
+@inventorylist_option_value5[]     - fifth array of random option values
+@inventorylist_option_parameter5[] - fifth array of random option parameters
 
 
 This could be handy to save/restore a character's inventory, since no other
 This could be handy to save/restore a character's inventory, since no other
 command returns such a complete set of data, and could also be the only way to
 command returns such a complete set of data, and could also be the only way to

+ 10 - 1
src/map/script.cpp

@@ -13880,7 +13880,7 @@ BUILDIN_FUNC(petloot)
 BUILDIN_FUNC(getinventorylist)
 BUILDIN_FUNC(getinventorylist)
 {
 {
 	TBL_PC *sd;
 	TBL_PC *sd;
-	char card_var[NAME_LENGTH];
+	char card_var[NAME_LENGTH], randopt_var[NAME_LENGTH];
 	int i,j=0,k;
 	int i,j=0,k;
 
 
 	if (!script_charid2sd(2,sd))
 	if (!script_charid2sd(2,sd))
@@ -13900,6 +13900,15 @@ BUILDIN_FUNC(getinventorylist)
 			}
 			}
 			pc_setreg(sd,reference_uid(add_str("@inventorylist_expire"), j),sd->inventory.u.items_inventory[i].expire_time);
 			pc_setreg(sd,reference_uid(add_str("@inventorylist_expire"), j),sd->inventory.u.items_inventory[i].expire_time);
 			pc_setreg(sd,reference_uid(add_str("@inventorylist_bound"), j),sd->inventory.u.items_inventory[i].bound);
 			pc_setreg(sd,reference_uid(add_str("@inventorylist_bound"), j),sd->inventory.u.items_inventory[i].bound);
+			for (k = 0; k < MAX_ITEM_RDM_OPT; k++)
+			{
+				sprintf(randopt_var, "@inventorylist_option_id%d",k+1);
+				pc_setreg(sd,reference_uid(add_str(randopt_var), j),sd->inventory.u.items_inventory[i].option[k].id);
+				sprintf(randopt_var, "@inventorylist_option_value%d",k+1);
+				pc_setreg(sd,reference_uid(add_str(randopt_var), j),sd->inventory.u.items_inventory[i].option[k].value);
+				sprintf(randopt_var, "@inventorylist_option_parameter%d",k+1);
+				pc_setreg(sd,reference_uid(add_str(randopt_var), j),sd->inventory.u.items_inventory[i].option[k].param);
+			}
 			j++;
 			j++;
 		}
 		}
 	}
 	}