diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-08-14 17:58:29 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-08-14 17:58:29 +0300 |
commit | 2ed4142dfcde097648857f41f8064b0a19c350c7 (patch) | |
tree | 5777014a74b30081ac39cda28ea9c64280cbebb5 /src/emap/pc.c | |
parent | f8b3342f690816022d26038389431002e9cf3648 (diff) | |
download | plugin-2ed4142dfcde097648857f41f8064b0a19c350c7.tar.gz plugin-2ed4142dfcde097648857f41f8064b0a19c350c7.tar.bz2 plugin-2ed4142dfcde097648857f41f8064b0a19c350c7.tar.xz plugin-2ed4142dfcde097648857f41f8064b0a19c350c7.zip |
Add basic support for charm items (If item present in inventory it give own bonuses)
For char item in items.conf need add attribute "Charm: true"
Diffstat (limited to 'src/emap/pc.c')
-rw-r--r-- | src/emap/pc.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/emap/pc.c b/src/emap/pc.c index 96bc074..c0957d9 100644 --- a/src/emap/pc.c +++ b/src/emap/pc.c @@ -361,3 +361,59 @@ int epc_setnewpc(int retVal, struct map_session_data *sd, } return retVal; } + +int epc_additem_post(int retVal, struct map_session_data *sd, + struct item *item_data, + int *amountPtr __attribute__ ((unused)), + e_log_pick_type *log_type __attribute__ ((unused))) +{ + if (!retVal) + { + struct ItemdExt *data = itemd_get_by_item(item_data); + if (data && data->charmItem) + status_calc_pc(sd, SCO_NONE); + } + return retVal; +} + +static bool calcPc = false; + +int epc_delitem_pre(struct map_session_data *sd, + int *nPtr, int *amountPtr, + int *typePtr __attribute__ ((unused)), + short *reasonPtr __attribute__ ((unused)), + e_log_pick_type *log_type __attribute__ ((unused))) +{ + if (!sd) + return 1; + const int n = *nPtr; + const int amount = *amountPtr; + + if (sd->status.inventory[n].nameid == 0 || + amount <= 0 || + sd->status.inventory[n].amount < amount || + sd->inventory_data[n] == NULL) + { + return 1; + } + + struct ItemdExt *data = itemd_get(sd->inventory_data[n]); + if (data && data->charmItem) + calcPc = true; + + return 0; +} + +int epc_delitem_post(int retVal, + struct map_session_data *sd, + int *nPtr __attribute__ ((unused)), + int *amountPtr __attribute__ ((unused)), + int *typePtr __attribute__ ((unused)), + short *reasonPtr __attribute__ ((unused)), + e_log_pick_type *log_type __attribute__ ((unused))) +{ + if (!retVal && calcPc && sd) + status_calc_pc(sd, SCO_NONE); + calcPc = false; + return retVal; +} |