diff options
author | Guilherme G. Menaldo <guilherme.menaldo@outlook.com> | 2018-08-20 21:20:46 -0300 |
---|---|---|
committer | Guilherme G. Menaldo <guilherme.menaldo@outlook.com> | 2018-08-30 12:04:06 -0300 |
commit | 6a0d3d52dcb64a4e04d49336fa7bdf82874a7cc1 (patch) | |
tree | 554d7c0f25b7c44076a93da4507e74a697bcf09e | |
parent | 7f7b8060cba8f0aba60f43cf343bdf3f773f3438 (diff) | |
download | hercules-6a0d3d52dcb64a4e04d49336fa7bdf82874a7cc1.tar.gz hercules-6a0d3d52dcb64a4e04d49336fa7bdf82874a7cc1.tar.bz2 hercules-6a0d3d52dcb64a4e04d49336fa7bdf82874a7cc1.tar.xz hercules-6a0d3d52dcb64a4e04d49336fa7bdf82874a7cc1.zip |
Makes trap damage possible to be reflected
-rw-r--r-- | conf/map/battle/skill.conf | 6 | ||||
-rw-r--r-- | src/map/battle.c | 35 | ||||
-rw-r--r-- | src/map/battle.h | 3 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking.Defs.inc | 2 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc | 4 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc | 1 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.Hooks.inc | 26 |
7 files changed, 77 insertions, 0 deletions
diff --git a/conf/map/battle/skill.conf b/conf/map/battle/skill.conf index d258567a0..64bba68b5 100644 --- a/conf/map/battle/skill.conf +++ b/conf/map/battle/skill.conf @@ -307,6 +307,12 @@ dancing_weaponswitch_fix: true // 1: Traps in GvG make player stop moving right when stepping over it. skill_trap_type: 0 +// Trap Reflect +// Whether the damage from traps must be reflected (for example by Reflect Shield or High Orc Card)? +// true: Aegis - traps are reflected +// false: Athena - traps are not reflected +trap_reflect: true + // Max Possible Level of Monster skills // Note: If your MVPs are too tough, reduce it to 10. mob_max_skilllvl: 100 diff --git a/src/map/battle.c b/src/map/battle.c index fceb30be1..8707ef6ac 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -4339,6 +4339,8 @@ static struct Damage battle_calc_misc_attack(struct block_list *src, struct bloc } break; } + + battle->reflect_trap(target, src, &md, skill_id); return md; } @@ -6008,6 +6010,37 @@ static void battle_reflect_damage(struct block_list *target, struct block_list * #undef NORMALIZE_RDAMAGE } +/** + * Reflects damage from certain traps, if battle_config.trap_reflect is true. + * @param target : Player who triggered the trap + * @param src : Player who set the trap + * @param md : Trap damage structure + * @param skill_id : Trap skill ID + */ +static void battle_reflect_trap(struct block_list *target, struct block_list *src, struct Damage *md, uint16 skill_id) +{ + if (battle_config.trap_reflect == true) { + if (src != target) { // Don't reflect your own damage + switch (skill_id) { + case HT_CLAYMORETRAP: + case HT_LANDMINE: + case HT_FREEZINGTRAP: + case HT_BLASTMINE: + // Needs official info + //case RA_CLUSTERBOMB: + //case RA_FIRINGTRAP: + //case RA_ICEBOUNDTRAP: + //case GN_THORNS_TRAP: + //case KO_MAKIBISHI: + case MA_LANDMINE: + case MA_FREEZINGTRAP: + battle->reflect_damage(target, src, md, skill_id); + break; + } + } + } +} + static void battle_drain(struct map_session_data *sd, struct block_list *tbl, int64 rdamage, int64 ldamage, int race, int boss) { struct weapon_data *wd; @@ -7325,6 +7358,7 @@ static const struct battle_data { * Hercules **/ { "skill_trap_type", &battle_config.skill_trap_type, 0, 0, 1, }, + { "trap_reflect", &battle_config.trap_reflect, 1, 0, 1, }, { "item_restricted_consumption_type", &battle_config.item_restricted_consumption_type,1, 0, 1, }, { "unequip_restricted_equipment", &battle_config.unequip_restricted_equipment, 0, 0, 3, }, { "max_walk_path", &battle_config.max_walk_path, 17, 1, MAX_WALKPATH, }, @@ -7614,6 +7648,7 @@ void battle_defaults(void) battle->delay_damage = battle_delay_damage; battle->drain = battle_drain; battle->reflect_damage = battle_reflect_damage; + battle->reflect_trap = battle_reflect_trap; battle->attr_ratio = battle_attr_ratio; battle->attr_fix = battle_attr_fix; battle->calc_cardfix = battle_calc_cardfix; diff --git a/src/map/battle.h b/src/map/battle.h index 9f5207e95..c16007e16 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -506,6 +506,7 @@ struct Battle_Config { /** Hercules **/ int skill_trap_type; + int trap_reflect; int item_restricted_consumption_type; int unequip_restricted_equipment; int max_walk_path; @@ -636,6 +637,8 @@ struct battle_interface { void (*drain) (struct map_session_data *sd, struct block_list *tbl, int64 rdamage, int64 ldamage, int race, int boss); /* damage reflect */ void (*reflect_damage) (struct block_list *target, struct block_list *src, struct Damage *wd,uint16 skill_id); + /* trap reflect */ + void(*reflect_trap) (struct block_list *target, struct block_list *src, struct Damage *md, uint16 skill_id); /* attribute rate */ int (*attr_ratio) (int atk_elem, int def_type, int def_lv); /* applies attribute modifiers */ diff --git a/src/plugins/HPMHooking/HPMHooking.Defs.inc b/src/plugins/HPMHooking/HPMHooking.Defs.inc index 0c63a98b6..9261f6320 100644 --- a/src/plugins/HPMHooking/HPMHooking.Defs.inc +++ b/src/plugins/HPMHooking/HPMHooking.Defs.inc @@ -278,6 +278,8 @@ typedef void (*HPMHOOK_pre_battle_drain) (struct map_session_data **sd, struct b typedef void (*HPMHOOK_post_battle_drain) (struct map_session_data *sd, struct block_list *tbl, int64 rdamage, int64 ldamage, int race, int boss); typedef void (*HPMHOOK_pre_battle_reflect_damage) (struct block_list **target, struct block_list **src, struct Damage **wd, uint16 *skill_id); typedef void (*HPMHOOK_post_battle_reflect_damage) (struct block_list *target, struct block_list *src, struct Damage *wd, uint16 skill_id); +typedef void (*HPMHOOK_pre_battle_reflect_trap) (struct block_list **target, struct block_list **src, struct Damage **md, uint16 *skill_id); +typedef void (*HPMHOOK_post_battle_reflect_trap) (struct block_list *target, struct block_list *src, struct Damage *md, uint16 skill_id); typedef int (*HPMHOOK_pre_battle_attr_ratio) (int *atk_elem, int *def_type, int *def_lv); typedef int (*HPMHOOK_post_battle_attr_ratio) (int retVal___, int atk_elem, int def_type, int def_lv); typedef int64 (*HPMHOOK_pre_battle_attr_fix) (struct block_list **src, struct block_list **target, int64 *damage, int *atk_elem, int *def_type, int *def_lv); diff --git a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc index c4394d7f4..fdd89760e 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc @@ -232,6 +232,8 @@ struct { struct HPMHookPoint *HP_battle_drain_post; struct HPMHookPoint *HP_battle_reflect_damage_pre; struct HPMHookPoint *HP_battle_reflect_damage_post; + struct HPMHookPoint *HP_battle_reflect_trap_pre; + struct HPMHookPoint *HP_battle_reflect_trap_post; struct HPMHookPoint *HP_battle_attr_ratio_pre; struct HPMHookPoint *HP_battle_attr_ratio_post; struct HPMHookPoint *HP_battle_attr_fix_pre; @@ -6783,6 +6785,8 @@ struct { int HP_battle_drain_post; int HP_battle_reflect_damage_pre; int HP_battle_reflect_damage_post; + int HP_battle_reflect_trap_pre; + int HP_battle_reflect_trap_post; int HP_battle_attr_ratio_pre; int HP_battle_attr_ratio_post; int HP_battle_attr_fix_pre; diff --git a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc index e5584cc43..140758140 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc @@ -133,6 +133,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(battle->delay_damage, HP_battle_delay_damage) }, { HP_POP(battle->drain, HP_battle_drain) }, { HP_POP(battle->reflect_damage, HP_battle_reflect_damage) }, + { HP_POP(battle->reflect_trap, HP_battle_reflect_trap) }, { HP_POP(battle->attr_ratio, HP_battle_attr_ratio) }, { HP_POP(battle->attr_fix, HP_battle_attr_fix) }, { HP_POP(battle->calc_cardfix, HP_battle_calc_cardfix) }, diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index f2ce1505c..d220f78fd 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -2806,6 +2806,32 @@ void HP_battle_reflect_damage(struct block_list *target, struct block_list *src, } return; } +void HP_battle_reflect_trap(struct block_list *target, struct block_list *src, struct Damage *md, uint16 skill_id) { + int hIndex = 0; + if (HPMHooks.count.HP_battle_reflect_trap_pre > 0) { + void (*preHookFunc) (struct block_list **target, struct block_list **src, struct Damage **md, uint16 *skill_id); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_battle_reflect_trap_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_battle_reflect_trap_pre[hIndex].func; + preHookFunc(&target, &src, &md, &skill_id); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.battle.reflect_trap(target, src, md, skill_id); + } + if (HPMHooks.count.HP_battle_reflect_trap_post > 0) { + void (*postHookFunc) (struct block_list *target, struct block_list *src, struct Damage *md, uint16 skill_id); + for (hIndex = 0; hIndex < HPMHooks.count.HP_battle_reflect_trap_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_battle_reflect_trap_post[hIndex].func; + postHookFunc(target, src, md, skill_id); + } + } + return; +} int HP_battle_attr_ratio(int atk_elem, int def_type, int def_lv) { int hIndex = 0; int retVal___ = 0; |