diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-09-03 18:38:32 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-09-03 18:38:32 +0300 |
commit | c558e3645f5154ee001e5ba8b295556316356ab0 (patch) | |
tree | 934ddc944e4f62390b62e3136c8c84d0e1a0ce66 /src/emap/battle.c | |
parent | 211787e349e0249fc032b3b51f8649af613f5ecf (diff) | |
download | evol-hercules-c558e3645f5154ee001e5ba8b295556316356ab0.tar.gz evol-hercules-c558e3645f5154ee001e5ba8b295556316356ab0.tar.bz2 evol-hercules-c558e3645f5154ee001e5ba8b295556316356ab0.tar.xz evol-hercules-c558e3645f5154ee001e5ba8b295556316356ab0.zip |
Add support for MinRange in item_db.
If weapon used on range smaller than MinRange, weapon not attacking.
Diffstat (limited to 'src/emap/battle.c')
-rw-r--r-- | src/emap/battle.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/emap/battle.c b/src/emap/battle.c index 1404795..5a24927 100644 --- a/src/emap/battle.c +++ b/src/emap/battle.c @@ -15,6 +15,8 @@ #include "map/mob.h" #include "map/pc.h" +#include "plugins/HPMHooking.h" + #include "emap/data/itemd.h" #include "emap/data/mobd.h" #include "emap/struct/itemdext.h" @@ -61,6 +63,8 @@ bool ebattle_check_arrows_post(bool retVal, return true; const int weaponIndex = sd->equip_index[EQI_HAND_L]; + if (weaponIndex < 0) + return true; struct ItemdExt *data = itemd_get(sd->inventory_data[weaponIndex]); if (!data) @@ -119,3 +123,34 @@ struct Damage ebattle_calc_weapon_attack_post(struct Damage retVal, retVal.damage2 = apply_percentrate64(retVal.damage2, mod, 10000); return retVal; } + +enum damage_lv ebattle_weapon_attack_pre(struct block_list **srcPtr, + struct block_list **targetPtr, + int64 *tickPtr __attribute__ ((unused)), + int *flagPtr __attribute__ ((unused))) +{ + struct block_list *src = *srcPtr; + struct block_list *target = *targetPtr; + + nullpo_retr(ATK_NONE, src); + nullpo_retr(ATK_NONE, target); + + struct map_session_data *sd = BL_CAST(BL_PC, src); + if (sd == NULL) + return ATK_NONE; + + const int weaponIndex = sd->equip_index[EQI_HAND_L]; + if (weaponIndex < 0) + return ATK_NONE; + + struct ItemdExt *data = itemd_get(sd->inventory_data[weaponIndex]); + if (!data) + return ATK_NONE; + + if (distance_bl(src, target) < data->minRange) + { // if range between player and target > minRange, then dont attack + hookStop(); + return ATK_NONE; + } + return ATK_NONE; +} |