diff options
-rw-r--r-- | doc/script_commands.txt | 5 | ||||
-rw-r--r-- | src/map/npc.c | 29 |
2 files changed, 31 insertions, 3 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 6f7a213c1..254350904 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -5678,8 +5678,9 @@ is bought or sold by a player. In the OnBuyItem, two arrays are set (@bought_nameid and @bought_quantity), which hold information about the name id (item id) sold and the amount sold of it. Same goes for the OnSellItem label, only the variables are named different -(@sold_nameid and @sold_quantity). An example on a shop comes with eAthena, and -can be found in the doc/sample/npc_dynamic_shop.txt file. +(@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 eAthena, 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 a dynamic shop. diff --git a/src/map/npc.c b/src/map/npc.c index 1762bc73b..5869c6daa 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1424,14 +1424,28 @@ int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list) static int npc_selllist_sub(struct map_session_data* sd, int n, unsigned short* item_list, struct npc_data* nd) { char npc_ev[EVENT_NAME_LENGTH]; - int i, idx; + char card_slot[NAME_LENGTH]; + int i, j, idx; int key_nameid = 0; int key_amount = 0; + int key_refine = 0; + int key_attribute = 0; + int key_identify = 0; + int key_card = 0; // 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; MAX_SLOTS > j; j++ ) + {// clear each of the card slot entries + sprintf_s(card_slot, sizeof(card_slot), "@sold_card%d", j + 1); + script_cleararray_pc(sd, card_slot, (void*)0); + } + // save list of to be sold items for( i = 0; i < n; i++ ) { @@ -1439,6 +1453,19 @@ static int npc_selllist_sub(struct map_session_data* sd, int n, unsigned short* script_setarray_pc(sd, "@sold_nameid", i, (void*)(intptr_t)sd->status.inventory[idx].nameid, &key_nameid); script_setarray_pc(sd, "@sold_quantity", i, (void*)(intptr_t)item_list[i*2+1], &key_amount); + + if( itemdb_isequip(sd->status.inventory[idx].nameid) ) + {// process equipment based information into the arrays + script_setarray_pc(sd, "@sold_refine", i, (void*)(intptr_t)sd->status.inventory[idx].refine, &key_refine); + script_setarray_pc(sd, "@sold_attribute", i, (void*)(intptr_t)sd->status.inventory[idx].attribute, &key_attribute); + script_setarray_pc(sd, "@sold_identify", i, (void*)(intptr_t)sd->status.inventory[idx].identify, &key_identify); + + for( j = 0; MAX_SLOTS > j; j++ ) + {// store each of the cards from the equipment in the array + sprintf_s(card_slot, sizeof(card_slot), "@sold_card%d", j + 1); + script_setarray_pc(sd, card_slot, i, (void*)(intptr_t)sd->status.inventory[idx].card[j], &key_card); + } + } } // invoke event |