summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmistry Haoyan <equinox1991@gmail.com>2020-07-06 03:25:12 +0800
committerEmistry Haoyan <equinox1991@gmail.com>2020-07-19 15:12:36 +0800
commit3453cc9feb30022484c8d6d1a7731bc673a2be83 (patch)
tree10e8750f95bdbcdbbe932a5d07fdb2822ae7a68d
parent1dfebbd4966310387357cbddae600418a56df658 (diff)
downloadhercules-3453cc9feb30022484c8d6d1a7731bc673a2be83.tar.gz
hercules-3453cc9feb30022484c8d6d1a7731bc673a2be83.tar.bz2
hercules-3453cc9feb30022484c8d6d1a7731bc673a2be83.tar.xz
hercules-3453cc9feb30022484c8d6d1a7731bc673a2be83.zip
Update NPC OnSellitem Array List
- missing random item option's param array.
-rw-r--r--doc/script_commands.txt53
-rw-r--r--src/map/npc.c63
2 files changed, 61 insertions, 55 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index db37ef284..1939ae36e 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -3195,23 +3195,24 @@ This command sets a bunch of arrays with a complete list of whatever the
invoking character has in its inventory, including all the data needed to
recreate these items perfectly if they are destroyed. Here's what you get:
-@inventorylist_id[] - array of item ids.
-@inventorylist_idx[] - array of item inventory index.
-@inventorylist_amount[] - their corresponding item amounts.
-@inventorylist_equip[] - will return the slot the item is equipped on, if at all.
-@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
-@inventorylist_card2[] items. These data slots are also used to store
-@inventorylist_card3[] names inscribed on the items, so you can
-@inventorylist_card4[] explicitly check if the character owns an item
- made by a specific craftsman.
-@inventorylist_expire[] - expire time (Unix time stamp). 0 means never
- expires.
-@inventorylist_bound[] - whether it is an account bounded item or not.
-@inventorylist_favorite[] - whether it is favorite (inside favorite tab) or not.
-@inventorylist_count - the number of items in these lists.
+@inventorylist_id[] - array of item ids.
+@inventorylist_idx[] - array of item inventory index.
+@inventorylist_amount[] - their corresponding item amounts.
+@inventorylist_equip[] - will return the slot the item is equipped on, if at all.
+@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 inscribed
+@inventorylist_card3[] on the items, so you can explicitly check if the character
+@inventorylist_card4[] owns an item made by a specific craftsman.
+@inventorylist_expire[] - expire time (Unix time stamp). 0 means never expires.
+@inventorylist_bound[] - whether it is an account bounded item or not.
+@inventorylist_favorite[] - whether it is favorite (inside favorite tab) or not.
+@inventorylist_opt_id1~5[] - array of random option id.
+@inventorylist_opt_val1~5[] - array of random option val.
+@inventorylist_opt_param1~5[] - array of random option param.
+@inventorylist_count - the number of items in these lists.
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
@@ -3239,14 +3240,15 @@ recreate these items perfectly if they are destroyed. Here's what you get:
@cartinventorylist_refine[] - for how much it is refined.
@cartinventorylist_identify[] - whether it is identified.
@cartinventorylist_attribute[] - whether it is broken.
-@cartinventorylist_card1[] - These four arrays contain card data for the
-@cartinventorylist_card2[] items. These data slots are also used to store
-@cartinventorylist_card3[] names inscribed on the items, so you can
-@cartinventorylist_card4[] explicitly check if the character owns an item
- made by a specific craftsman.
-@cartinventorylist_expire[] - expire time (Unix time stamp). 0 means never
- expires.
+@cartinventorylist_card1[] - These four arrays contain card data for the items.
+@cartinventorylist_card2[] These data slots are also used to store names inscribed on the items,
+@cartinventorylist_card3[] so you can explicitly check if the character owns an item
+@cartinventorylist_card4[] made by a specific craftsman.
+@cartinventorylist_expire[] - expire time (Unix time stamp). 0 means never expires.
@cartinventorylist_bound - whether it is an account bound item or not.
+@inventorylist_opt_id1~5[] - array of random option id.
+@inventorylist_opt_val1~5[] - array of random option val.
+@inventorylist_opt_param1~5[] - array of random option param.
@cartinventorylist_count - the number of items in these lists.
This could be handy to save/restore a character's cart_inventory, since no
@@ -7656,7 +7658,8 @@ In the OnBuyItem, two arrays are filled (@bought_nameid and
and the amount sold of it. Same goes for the OnSellItem label, only the
variables are named different (@sold_nameid, @sold_quantity, @sold_refine,
@sold_attribute, @sold_identify, @sold_card1, @sold_card2, @sold_card3,
-@sold_card4). An example on a shop comes with Hercules, and can be found
+@sold_card4, @sold_opt_id1~5, @sold_opt_val1~5, @sold_opt_param1~5).
+An example on a shop comes with Hercules, and can be found
in the doc/sample/npc_dynamic_shop.txt file.
This example shows how to use the labels and their set variables to create
diff --git a/src/map/npc.c b/src/map/npc.c
index 055c1843b..1331414b6 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -2715,43 +2715,47 @@ static int npc_selllist_sub(struct map_session_data *sd, struct itemlist *item_l
char card_slot[NAME_LENGTH];
char opt_index_str[NAME_LENGTH];
char opt_value_str[NAME_LENGTH];
- int i, j;
+ char opt_param_str[NAME_LENGTH];
+ int i = 0;
+ int j = 0;
int key_nameid = 0;
int key_amount = 0;
int key_refine = 0;
- int key_attribute = 0;
+ int key_attribute = ATTR_NONE;
int key_identify = 0;
int key_card[MAX_SLOTS];
int key_opt_idx[MAX_ITEM_OPTIONS];
int key_opt_value[MAX_ITEM_OPTIONS];
+ int key_opt_param[MAX_ITEM_OPTIONS];
nullpo_ret(sd);
nullpo_ret(item_list);
nullpo_ret(nd);
// discard old contents
- script->cleararray_pc(sd, "@sold_nameid", (void*)0);
- script->cleararray_pc(sd, "@sold_quantity", (void*)0);
- script->cleararray_pc(sd, "@sold_refine", (void*)0);
- script->cleararray_pc(sd, "@sold_attribute", (void*)0);
- script->cleararray_pc(sd, "@sold_identify", (void*)0);
-
- for( j = 0; j < MAX_SLOTS; j++ )
- {// clear each of the card slot entries
+ script->cleararray_pc(sd, "@sold_nameid", (void *)0);
+ script->cleararray_pc(sd, "@sold_quantity", (void *)0);
+ script->cleararray_pc(sd, "@sold_refine", (void *)0);
+ script->cleararray_pc(sd, "@sold_attribute", (void *)0);
+ script->cleararray_pc(sd, "@sold_identify", (void *)0);
+
+ for (j = 0; j < MAX_SLOTS; j++) { // clear each of the card slot entries
key_card[j] = 0;
snprintf(card_slot, sizeof(card_slot), "@sold_card%d", j + 1);
- script->cleararray_pc(sd, card_slot, (void*)0);
+ script->cleararray_pc(sd, card_slot, (void *)0);
}
for (j = 0; j < MAX_ITEM_OPTIONS; j++) { // Clear Each item option entry
key_opt_idx[j] = 0;
key_opt_value[j] = 0;
+ key_opt_param[j] = 0;
- snprintf(opt_index_str, sizeof(opt_index_str), "@slot_opt_idx%d", j + 1);
- script->cleararray_pc(sd, opt_index_str, (void*)0);
-
- snprintf(opt_value_str, sizeof(opt_value_str), "@slot_opt_val%d", j + 1);
- script->cleararray_pc(sd, opt_value_str, (void*)0);
+ snprintf(opt_index_str, sizeof(opt_index_str), "@sold_opt_idx%d", j + 1);
+ script->cleararray_pc(sd, opt_index_str, (void *)0);
+ snprintf(opt_value_str, sizeof(opt_value_str), "@sold_opt_val%d", j + 1);
+ script->cleararray_pc(sd, opt_value_str, (void *)0);
+ snprintf(opt_param_str, sizeof(opt_param_str), "@sold_opt_param%d", j + 1);
+ script->cleararray_pc(sd, opt_param_str, (void *)0);
}
// save list of to be sold items
@@ -2764,32 +2768,31 @@ static int npc_selllist_sub(struct map_session_data *sd, struct itemlist *item_l
intptr_t attribute = item->attribute;
intptr_t identify = item->identify;
- script->setarray_pc(sd, "@sold_nameid", i, (void*)nameid, &key_nameid);
- script->setarray_pc(sd, "@sold_quantity", i, (void*)amount, &key_amount);
-
// process item based information into the arrays
- script->setarray_pc(sd, "@sold_refine", i, (void*)refine, &key_refine);
- script->setarray_pc(sd, "@sold_attribute", i, (void*)attribute, &key_attribute);
- script->setarray_pc(sd, "@sold_identify", i, (void*)identify, &key_identify);
+ script->setarray_pc(sd, "@sold_nameid", i, (void *)nameid, &key_nameid);
+ script->setarray_pc(sd, "@sold_quantity", i, (void *)amount, &key_amount);
+ script->setarray_pc(sd, "@sold_refine", i, (void *)refine, &key_refine);
+ script->setarray_pc(sd, "@sold_attribute", i, (void *)attribute, &key_attribute);
+ script->setarray_pc(sd, "@sold_identify", i, (void *)identify, &key_identify);
for (j = 0; j < MAX_SLOTS; j++) {
intptr_t card = item->card[j];
- // store each of the cards/special info from the item in the array
snprintf(card_slot, sizeof(card_slot), "@sold_card%d", j + 1);
- script->setarray_pc(sd, card_slot, i, (void*)card, &key_card[j]);
+ script->setarray_pc(sd, card_slot, i, (void *)card, &key_card[j]);
}
for (j = 0; j < MAX_ITEM_OPTIONS; j++) {
intptr_t opt_idx = item->option[j].index;
intptr_t opt_value = item->option[j].value;
+ intptr_t opt_param = item->option[j].param;
- snprintf(opt_index_str, sizeof(opt_index_str), "@slot_opt_idx%d", j + 1);
- script->setarray_pc(sd, opt_index_str, i, (void*)opt_idx, &key_opt_idx[j]);
-
- snprintf(opt_value_str, sizeof(opt_value_str), "@slot_opt_val%d", j + 1);
- script->setarray_pc(sd, opt_value_str, i, (void*)opt_value, &key_opt_value[j]);
+ snprintf(opt_index_str, sizeof(opt_index_str), "@sold_opt_idx%d", j + 1);
+ script->setarray_pc(sd, opt_index_str, i, (void *)opt_idx, &key_opt_idx[j]);
+ snprintf(opt_value_str, sizeof(opt_value_str), "@sold_opt_val%d", j + 1);
+ script->setarray_pc(sd, opt_value_str, i, (void *)opt_value, &key_opt_value[j]);
+ snprintf(opt_param_str, sizeof(opt_param_str), "@sold_opt_param%d", j + 1);
+ script->setarray_pc(sd, opt_param_str, i, (void *)opt_param, &key_opt_param[j]);
}
-
}
// invoke event