diff options
author | Smokexyz <sagunkho@hotmail.com> | 2017-03-02 19:24:48 +0800 |
---|---|---|
committer | Smokexyz <sagunkho@hotmail.com> | 2017-04-04 13:38:16 +0800 |
commit | 974222a8d3f189083205bf5d330de04a43226ad3 (patch) | |
tree | b78280b9dad90616196ee37c3992c3e46962b906 /src/map/status.c | |
parent | 20145c61053479b9acd8ed50c75a80c2a861e349 (diff) | |
download | hercules-974222a8d3f189083205bf5d330de04a43226ad3.tar.gz hercules-974222a8d3f189083205bf5d330de04a43226ad3.tar.bz2 hercules-974222a8d3f189083205bf5d330de04a43226ad3.tar.xz hercules-974222a8d3f189083205bf5d330de04a43226ad3.zip |
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)
Diffstat (limited to 'src/map/status.c')
-rw-r--r-- | src/map/status.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/src/map/status.c b/src/map/status.c index 78c11899b..d8fb9a350 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -2400,8 +2400,8 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) bstatus->speed = pSpeed; } - //FIXME: Most of these stuff should be calculated once, but how do I fix the memset above to do that? [Skotlex] - //Give them all modes except these (useful for clones) + // FIXME: Most of these stuff should be calculated once, but how do I fix the memset above to do that? [Skotlex] + // Give them all modes except these (useful for clones) bstatus->mode = MD_MASK&~(MD_BOSS|MD_PLANT|MD_DETECTOR|MD_ANGRY|MD_TARGETWEAK); bstatus->size = ((sd->job & JOBL_BABY) != 0 || (sd->job & MAPID_BASEMASK) == MAPID_SUMMONER)?SZ_SMALL:SZ_MEDIUM; @@ -2646,6 +2646,39 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) } } } + + /* parse item options [Smokexyz] */ + for (i = 0; i < EQI_MAX; i++) { + status->current_equip_item_index = index = sd->equip_index[i]; + status->current_equip_option_index = -1; + + if (i == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == index) + continue; + else if (i == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == index) + continue; + else if (i == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == index || sd->equip_index[EQI_HEAD_LOW] == index)) + continue; + + if (index >= 0 && sd->inventory_data[index]) { + int j = 0; + for (j = 0; j < MAX_ITEM_OPTIONS; j++) { + int16 option_index = sd->status.inventory[index].option[j].index; + struct item_option *ito = NULL; + + if (option_index == 0 || (ito = itemdb->option_exists(option_index)) == NULL || ito->script == NULL) + continue; + + status->current_equip_option_index = j; + script->run(ito->script, 0, sd->bl.id, 0); + + if (calculating == 0) //Abort, script->run his function. [Skotlex] + return 1; + } + } + } + + status->current_equip_option_index = -1; + status->current_equip_item_index = -1; status->calc_pc_additional(sd, opt); |