Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes some issues with traps #2182

Merged
merged 2 commits into from
Oct 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions conf/map/battle/skill.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions db/pre-re/skill_db.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4299,6 +4299,7 @@ skill_db: (
Element: "Ele_Wind"
DamageType: {
SplashArea: true
SplitDamage: true
IgnoreFlee: true
}
SplashRange: 1
Expand Down Expand Up @@ -4350,6 +4351,7 @@ skill_db: (
Element: "Ele_Fire"
DamageType: {
SplashArea: true
SplitDamage: true
IgnoreFlee: true
}
SplashRange: 2
Expand Down
2 changes: 2 additions & 0 deletions db/re/skill_db.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4520,6 +4520,7 @@ skill_db: (
Element: "Ele_Wind"
DamageType: {
SplashArea: true
SplitDamage: true
guilherme-gm marked this conversation as resolved.
Show resolved Hide resolved
IgnoreFlee: true
}
SplashRange: 1
Expand Down Expand Up @@ -4572,6 +4573,7 @@ skill_db: (
Element: "Ele_Fire"
DamageType: {
SplashArea: true
SplitDamage: true
IgnoreFlee: true
}
SplashRange: 2
Expand Down
35 changes: 35 additions & 0 deletions src/map/battle.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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, },
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/map/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down
53 changes: 37 additions & 16 deletions src/map/skill.c
Original file line number Diff line number Diff line change
Expand Up @@ -4132,7 +4132,7 @@ static int skill_activate_reverberation(struct block_list *bl, va_list ap)
if( su->alive && (sg = su->group) != NULL && sg->skill_id == WM_REVERBERATION && sg->unit_id == UNT_REVERBERATION ) {
int64 tick = timer->gettick();
clif->changetraplook(bl,UNT_USED_TRAPS);
map->foreachinrange(skill->trap_splash, bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, bl, tick);
skill->trap_do_splash(bl, sg->skill_id, sg->skill_lv, sg->bl_flag, tick);
su->limit = DIFF_TICK32(tick,sg->tick)+1500;
sg->unit_id = UNT_USED_TRAPS;
}
Expand Down Expand Up @@ -12638,7 +12638,7 @@ static int skill_unit_onplace(struct skill_unit *src, struct block_list *bl, int
if (sg->src_id == bl->id)
break; //Does not affect the caster.
clif->changetraplook(&src->bl,UNT_USED_TRAPS);
map->foreachinrange(skill->trap_splash,&src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &src->bl,tick);
skill->trap_do_splash(&src->bl, sg->skill_id, sg->skill_lv, sg->bl_flag, tick);
sg->unit_id = UNT_USED_TRAPS;
sg->limit = DIFF_TICK32(tick,sg->tick) + 1500;
break;
Expand Down Expand Up @@ -12932,7 +12932,7 @@ static int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *b

}

map->foreachinrange(skill->trap_splash, &src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &src->bl, tick);
skill->trap_do_splash(&src->bl, sg->skill_id, sg->skill_lv, sg->bl_flag, tick);
sg->unit_id = UNT_USED_TRAPS; //Changed ID so it does not invoke a for each in area again.
}
break;
Expand Down Expand Up @@ -12963,10 +12963,10 @@ static int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *b
case UNT_FREEZINGTRAP:
case UNT_FIREPILLAR_ACTIVE:
case UNT_CLAYMORETRAP:
if( sg->unit_id == UNT_FIRINGTRAP || sg->unit_id == UNT_ICEBOUNDTRAP || sg->unit_id == UNT_CLAYMORETRAP )
map->foreachinrange(skill->trap_splash,&src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag|BL_SKILL|~BCT_SELF, &src->bl,tick);
if (sg->unit_id == UNT_FIRINGTRAP || sg->unit_id == UNT_ICEBOUNDTRAP || sg->unit_id == UNT_CLAYMORETRAP)
skill->trap_do_splash(&src->bl, sg->skill_id, sg->skill_lv, sg->bl_flag | BL_SKILL | ~BCT_SELF, tick);
else
map->foreachinrange(skill->trap_splash,&src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &src->bl,tick);
skill->trap_do_splash(&src->bl, sg->skill_id, sg->skill_lv, sg->bl_flag, tick);
if (sg->unit_id != UNT_FIREPILLAR_ACTIVE)
clif->changetraplook(&src->bl, sg->unit_id==UNT_LANDMINE?UNT_FIREPILLAR_ACTIVE:UNT_USED_TRAPS);
sg->limit=DIFF_TICK32(tick,sg->tick)+1500 +
Expand Down Expand Up @@ -13197,9 +13197,7 @@ static int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *b
case UNT_GROUNDDRIFT_POISON:
case UNT_GROUNDDRIFT_WATER:
case UNT_GROUNDDRIFT_FIRE:
map->foreachinrange(skill->trap_splash,&src->bl,
skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag,
&src->bl,tick);
skill->trap_do_splash(&src->bl, sg->skill_id, sg->skill_lv, sg->bl_flag, tick);
sg->unit_id = UNT_USED_TRAPS;
//clif->changetraplook(&src->bl, UNT_FIREPILLAR_ACTIVE);
sg->limit=DIFF_TICK32(tick,sg->tick)+1500;
Expand Down Expand Up @@ -13260,7 +13258,7 @@ static int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *b

case UNT_REVERBERATION:
clif->changetraplook(&src->bl,UNT_USED_TRAPS);
map->foreachinrange(skill->trap_splash,&src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &src->bl,tick);
skill->trap_do_splash(&src->bl, sg->skill_id, sg->skill_lv, sg->bl_flag, tick);
sg->limit = DIFF_TICK32(tick,sg->tick)+1500;
sg->unit_id = UNT_USED_TRAPS;
break;
Expand Down Expand Up @@ -16624,10 +16622,10 @@ static int skill_detonator(struct block_list *bl, va_list ap)
case UNT_CLAYMORETRAP:
case UNT_FIRINGTRAP:
case UNT_ICEBOUNDTRAP:
map->foreachinrange(skill->trap_splash,bl,skill->get_splash(su->group->skill_id,su->group->skill_lv),su->group->bl_flag|BL_SKILL|~BCT_SELF,bl,su->group->tick);
skill->trap_do_splash(bl, su->group->skill_id, su->group->skill_lv, su->group->bl_flag | BL_SKILL | ~BCT_SELF, su->group->tick);
break;
default:
map->foreachinrange(skill->trap_splash,bl,skill->get_splash(su->group->skill_id,su->group->skill_lv),su->group->bl_flag,bl,su->group->tick);
skill->trap_do_splash(bl, su->group->skill_id, su->group->skill_lv, su->group->bl_flag, su->group->tick);
}
clif->changetraplook(bl, UNT_USED_TRAPS);
su->group->limit = DIFF_TICK32(timer->gettick(),su->group->tick) +
Expand Down Expand Up @@ -16760,6 +16758,27 @@ static int skill_chastle_mob_changetarget(struct block_list *bl, va_list ap)
return 0;
}

/**
* Does final adjustments (e.g. count enemies affected by splash) then runs trap splash function (skill_trap_splash).
*
* @param bl : trap skill unit's bl
* @param skill_id : Trap Skill ID
* @param skill_lv : Trap Skill Level
* @param bl_flag : Flag representing units affected by this trap
* @param tick : tick related to this trap
*/
static void skill_trap_do_splash(struct block_list *bl, uint16 skill_id, uint16 skill_lv, int bl_flag, int64 tick)
{
int enemy_count = 0;

if (skill->get_nk(skill_id) & NK_SPLASHSPLIT) {
enemy_count = map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), BL_CHAR, bl, skill_id, skill_lv, tick, BCT_ENEMY, skill->area_sub_count);
enemy_count = max(1, enemy_count); // Don't let enemy_count be 0 when spliting trap damage
}

map->foreachinrange(skill->trap_splash, bl, skill->get_splash(skill_id, skill_lv), bl_flag, bl, tick, enemy_count);
}

/*==========================================
*
*------------------------------------------*/
Expand All @@ -16770,6 +16789,7 @@ static int skill_trap_splash(struct block_list *bl, va_list ap)
struct skill_unit *src_su = NULL;
struct skill_unit_group *sg;
struct block_list *ss;
int enemy_count = va_arg(ap, int);

nullpo_ret(bl);
nullpo_ret(src);
Expand Down Expand Up @@ -16864,7 +16884,7 @@ static int skill_trap_splash(struct block_list *bl, va_list ap)
}
/* Fall through */
default:
skill->attack(skill->get_type(sg->skill_id),ss,src,bl,sg->skill_id,sg->skill_lv,tick,0);
skill->attack(skill->get_type(sg->skill_id), ss, src, bl, sg->skill_id, sg->skill_lv, tick, enemy_count);
break;
}
return 1;
Expand Down Expand Up @@ -17579,7 +17599,7 @@ static int skill_unit_timer_sub(union DBKey key, struct DBData *data, va_list ap
break;
}
clif->changetraplook(bl,UNT_USED_TRAPS);
map->foreachinrange(skill->trap_splash, bl, skill->get_splash(group->skill_id, group->skill_lv), group->bl_flag, bl, tick);
skill->trap_do_splash(bl, group->skill_id, group->skill_lv, group->bl_flag, tick);
group->limit = DIFF_TICK32(tick,group->tick)+1500;
su->limit = DIFF_TICK32(tick,group->tick)+1500;
group->unit_id = UNT_USED_TRAPS;
Expand Down Expand Up @@ -18967,7 +18987,7 @@ static int skill_destroy_trap(struct block_list *bl, va_list ap)
case UNT_CLAYMORETRAP:
case UNT_FIRINGTRAP:
case UNT_ICEBOUNDTRAP:
map->foreachinrange(skill->trap_splash,&su->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag|BL_SKILL|~BCT_SELF, &su->bl,tick);
skill->trap_do_splash(&su->bl, sg->skill_id, sg->skill_lv, sg->bl_flag | BL_SKILL | ~BCT_SELF, tick);
break;
case UNT_LANDMINE:
case UNT_BLASTMINE:
Expand All @@ -18976,7 +18996,7 @@ static int skill_destroy_trap(struct block_list *bl, va_list ap)
case UNT_FLASHER:
case UNT_FREEZINGTRAP:
case UNT_CLUSTERBOMB:
map->foreachinrange(skill->trap_splash,&su->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &su->bl,tick);
skill->trap_do_splash(&su->bl, sg->skill_id, sg->skill_lv, sg->bl_flag, tick);
break;
}
// Traps aren't recovered.
Expand Down Expand Up @@ -21572,6 +21592,7 @@ void skill_defaults(void)
skill->onskillusage = skill_onskillusage;
skill->cell_overlap = skill_cell_overlap;
skill->timerskill = skill_timerskill;
skill->trap_do_splash = skill_trap_do_splash;
skill->trap_splash = skill_trap_splash;
skill->check_condition_mercenary = skill_check_condition_mercenary;
skill->locate_element_field = skill_locate_element_field;
Expand Down
1 change: 1 addition & 0 deletions src/map/skill.h
Original file line number Diff line number Diff line change
Expand Up @@ -2059,6 +2059,7 @@ struct skill_interface {
int (*onskillusage) (struct map_session_data *sd, struct block_list *bl, uint16 skill_id, int64 tick);
int (*cell_overlap) (struct block_list *bl, va_list ap);
int (*timerskill) (int tid, int64 tick, int id, intptr_t data);
void (*trap_do_splash) (struct block_list *bl, uint16 skill_id, uint16 skill_lv, int bl_flag, int64 tick);
int (*trap_splash) (struct block_list *bl, va_list ap);
int (*check_condition_mercenary) (struct block_list *bl, int skill_id, int lv, int type);
struct skill_unit_group *(*locate_element_field) (struct block_list *bl);
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/HPMHooking/HPMHooking.Defs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -7154,6 +7156,8 @@ typedef int (*HPMHOOK_pre_skill_cell_overlap) (struct block_list **bl, va_list a
typedef int (*HPMHOOK_post_skill_cell_overlap) (int retVal___, struct block_list *bl, va_list ap);
typedef int (*HPMHOOK_pre_skill_timerskill) (int *tid, int64 *tick, int *id, intptr_t *data);
typedef int (*HPMHOOK_post_skill_timerskill) (int retVal___, int tid, int64 tick, int id, intptr_t data);
typedef void (*HPMHOOK_pre_skill_trap_do_splash) (struct block_list **bl, uint16 *skill_id, uint16 *skill_lv, int *bl_flag, int64 *tick);
typedef void (*HPMHOOK_post_skill_trap_do_splash) (struct block_list *bl, uint16 skill_id, uint16 skill_lv, int bl_flag, int64 tick);
typedef int (*HPMHOOK_pre_skill_trap_splash) (struct block_list **bl, va_list ap);
typedef int (*HPMHOOK_post_skill_trap_splash) (int retVal___, struct block_list *bl, va_list ap);
typedef int (*HPMHOOK_pre_skill_check_condition_mercenary) (struct block_list **bl, int *skill_id, int *lv, int *type);
Expand Down
8 changes: 8 additions & 0 deletions src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -5670,6 +5672,8 @@ struct {
struct HPMHookPoint *HP_skill_cell_overlap_post;
struct HPMHookPoint *HP_skill_timerskill_pre;
struct HPMHookPoint *HP_skill_timerskill_post;
struct HPMHookPoint *HP_skill_trap_do_splash_pre;
struct HPMHookPoint *HP_skill_trap_do_splash_post;
struct HPMHookPoint *HP_skill_trap_splash_pre;
struct HPMHookPoint *HP_skill_trap_splash_post;
struct HPMHookPoint *HP_skill_check_condition_mercenary_pre;
Expand Down Expand Up @@ -6783,6 +6787,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;
Expand Down Expand Up @@ -12221,6 +12227,8 @@ struct {
int HP_skill_cell_overlap_post;
int HP_skill_timerskill_pre;
int HP_skill_timerskill_post;
int HP_skill_trap_do_splash_pre;
int HP_skill_trap_do_splash_post;
int HP_skill_trap_splash_pre;
int HP_skill_trap_splash_post;
int HP_skill_check_condition_mercenary_pre;
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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) },
Expand Down Expand Up @@ -2901,6 +2902,7 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(skill->onskillusage, HP_skill_onskillusage) },
{ HP_POP(skill->cell_overlap, HP_skill_cell_overlap) },
{ HP_POP(skill->timerskill, HP_skill_timerskill) },
{ HP_POP(skill->trap_do_splash, HP_skill_trap_do_splash) },
{ HP_POP(skill->trap_splash, HP_skill_trap_splash) },
{ HP_POP(skill->check_condition_mercenary, HP_skill_check_condition_mercenary) },
{ HP_POP(skill->locate_element_field, HP_skill_locate_element_field) },
Expand Down
Loading