From 974222a8d3f189083205bf5d330de04a43226ad3 Mon Sep 17 00:00:00 2001 From: Smokexyz Date: Thu, 2 Mar 2017 19:24:48 +0800 Subject: Implementation of Item Options System. Allows the infusing of equipments with bonus item options. This feature is constrained to clients of packet versions greater than or equal to `20150226`. Item Options and their effects are defined server-side in `db/item_options.conf` and client side in `data/luafiles514/lua files/datainfo/addrandomoptionnametable.lub` The ID of the option must tally with the correct index of the description provided in the client side lua file to avoid bugs. IT_OPT_* keys and MAX_ITEM_OPTIONS macro are also exported from the source as constants. An additional flag `disable_options` has been added to sql, and as `DisableOptions: true/false (boolean, defaults to false !!for equipments only!!)` to item_db.conf files. Script commands documentation is also included. SQL file updates are included. Credits: [Smokexyz](https://github.com/Smokexyz) Style and Script Fixes by [Asheraf](https://github.com/Asheraf) Initial design Idea by [secretdataz](https://github.com/secretdataz) --- src/map/npc.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/map/npc.c') diff --git a/src/map/npc.c b/src/map/npc.c index a824d4216..2876ea595 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2089,6 +2089,8 @@ int npc_selllist_sub(struct map_session_data *sd, struct itemlist *item_list, st { char npc_ev[EVENT_NAME_LENGTH]; char card_slot[NAME_LENGTH]; + char opt_index_str[NAME_LENGTH]; + char opt_value_str[NAME_LENGTH]; int i, j; int key_nameid = 0; int key_amount = 0; @@ -2096,6 +2098,8 @@ int npc_selllist_sub(struct map_session_data *sd, struct itemlist *item_list, st int key_attribute = 0; int key_identify = 0; int key_card[MAX_SLOTS]; + int key_opt_idx[MAX_ITEM_OPTIONS]; + int key_opt_value[MAX_ITEM_OPTIONS]; nullpo_ret(sd); nullpo_ret(item_list); @@ -2140,6 +2144,17 @@ int npc_selllist_sub(struct map_session_data *sd, struct itemlist *item_list, st 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; + + 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]); + } + } // invoke event -- cgit v1.2.3-60-g2f50