diff options
author | Haru <haru@dotalux.com> | 2016-07-12 23:22:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-12 23:22:54 +0200 |
commit | 0d60f6920f388fdae86cb8fb4286d9ed1b0f94a0 (patch) | |
tree | d0731b1158ffdb12eb2db23c762576cb37251792 | |
parent | 69df5ffa970dbcafde7dbb5d360c0ea28300cb50 (diff) | |
parent | ec700e101d420286caa149bd2858c3e159e55998 (diff) | |
download | hercules-0d60f6920f388fdae86cb8fb4286d9ed1b0f94a0.tar.gz hercules-0d60f6920f388fdae86cb8fb4286d9ed1b0f94a0.tar.bz2 hercules-0d60f6920f388fdae86cb8fb4286d9ed1b0f94a0.tar.xz hercules-0d60f6920f388fdae86cb8fb4286d9ed1b0f94a0.zip |
Merge pull request #1354 from 4144/hooks
Add into skill.c some handling for unknown skills/skill units.
-rw-r--r-- | src/map/battle.c | 83 | ||||
-rw-r--r-- | src/map/battle.h | 2 | ||||
-rw-r--r-- | src/map/skill.c | 100 | ||||
-rw-r--r-- | src/map/skill.h | 5 | ||||
-rw-r--r-- | src/map/status.c | 12 |
5 files changed, 102 insertions, 100 deletions
diff --git a/src/map/battle.c b/src/map/battle.c index 76b74a766..879776871 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -3263,30 +3263,8 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam } } /* no data claims these settings affect anything other than players */ - if( damage && t_sd && bl->type == BL_PC ) { - switch( skill_id ) { - //case PA_PRESSURE: /* pressure also belongs to this list but it doesn't reach this area -- so don't worry about it */ - case HW_GRAVITATION: - case NJ_ZENYNAGE: - case KO_MUCHANAGE: - break; - default: - if (flag & BF_SKILL) { //Skills get a different reduction than non-skills. [Skotlex] - if (flag&BF_WEAPON) - damage = damage * map->list[bl->m].weapon_damage_rate / 100; - if (flag&BF_MAGIC) - damage = damage * map->list[bl->m].magic_damage_rate / 100; - if (flag&BF_MISC) - damage = damage * map->list[bl->m].misc_damage_rate / 100; - } else { //Normal attacks get reductions based on range. - if (flag & BF_SHORT) - damage = damage * map->list[bl->m].short_damage_rate / 100; - if (flag & BF_LONG) - damage = damage * map->list[bl->m].long_damage_rate / 100; - } - if(!damage) damage = 1; - break; - } + if (damage && t_sd && bl->type == BL_PC) { + damage = battle->calc_pc_damage(src, bl, d, damage, skill_id, skill_lv); } if(battle_config.skill_min_damage && damage > 0 && damage < div_) @@ -3331,6 +3309,37 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam return damage; } +int64 battle_calc_pc_damage(struct block_list *src, struct block_list *bl, struct Damage *d, int64 damage, uint16 skill_id, uint16 skill_lv) +{ + int flag = d->flag; + + switch (skill_id) { + //case PA_PRESSURE: /* pressure also belongs to this list but it doesn't reach this area -- so don't worry about it */ + case HW_GRAVITATION: + case NJ_ZENYNAGE: + case KO_MUCHANAGE: + break; + default: + if (flag & BF_SKILL) { //Skills get a different reduction than non-skills. [Skotlex] + if (flag & BF_WEAPON) + damage = damage * map->list[bl->m].weapon_damage_rate / 100; + if (flag & BF_MAGIC) + damage = damage * map->list[bl->m].magic_damage_rate / 100; + if (flag & BF_MISC) + damage = damage * map->list[bl->m].misc_damage_rate / 100; + } else { //Normal attacks get reductions based on range. + if (flag & BF_SHORT) + damage = damage * map->list[bl->m].short_damage_rate / 100; + if (flag & BF_LONG) + damage = damage * map->list[bl->m].long_damage_rate / 100; + } + if (!damage) + damage = 1; + break; + } + return damage; +} + /*========================================== * Calculates BG related damage adjustments. *------------------------------------------*/ @@ -6269,17 +6278,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t sp = skill->get_sp(skill_id,skill_lv) * 2 / 3; if (status->charge(src, 0, sp)) { - switch (skill->get_casttype(skill_id)) { - case CAST_GROUND: - skill->castend_pos2(src, target->x, target->y, skill_id, skill_lv, tick, flag); - break; - case CAST_NODAMAGE: - skill->castend_nodamage_id(src, target, skill_id, skill_lv, tick, flag); - break; - case CAST_DAMAGE: - skill->castend_damage_id(src, target, skill_id, skill_lv, tick, flag); - break; - } + skill->castend_type(skill->get_casttype(skill_id), src, target, skill_id, skill_lv, tick, flag); } } if (sd) { @@ -6325,19 +6324,8 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t sd->state.autocast = 1; skill->consume_requirement(sd,r_skill,r_lv,3); - switch( type ) { - case CAST_GROUND: - skill->castend_pos2(src, target->x, target->y, r_skill, r_lv, tick, flag); - break; - case CAST_NODAMAGE: - skill->castend_nodamage_id(src, target, r_skill, r_lv, tick, flag); - break; - case CAST_DAMAGE: - skill->castend_damage_id(src, target, r_skill, r_lv, tick, flag); - break; - } + skill->castend_type(type, src, target, r_skill, r_lv, tick, flag); sd->state.autocast = 0; - sd->ud.canact_tick = tick + skill->delay_fix(src, r_skill, r_lv); clif->status_change(src, SI_POSTDELAY, 1, skill->delay_fix(src, r_skill, r_lv), 0, 0, 1); } @@ -7611,6 +7599,7 @@ void battle_defaults(void) { battle->calc_attack = battle_calc_attack; battle->calc_damage = battle_calc_damage; + battle->calc_pc_damage = battle_calc_pc_damage; battle->calc_gvg_damage = battle_calc_gvg_damage; battle->calc_bg_damage = battle_calc_bg_damage; battle->weapon_attack = battle_weapon_attack; diff --git a/src/map/battle.h b/src/map/battle.h index 6fa600ada..cb15e3b90 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -587,6 +587,8 @@ struct battle_interface { struct Damage (*calc_attack) (int attack_type, struct block_list *bl, struct block_list *target, uint16 skill_id, uint16 skill_lv, int count); /* generic final damage calculation */ int64 (*calc_damage) (struct block_list *src, struct block_list *bl, struct Damage *d, int64 damage, uint16 skill_id, uint16 skill_lv); + /* pc special damage calculation */ + int64 (*calc_pc_damage) (struct block_list *src, struct block_list *bl, struct Damage *d, int64 damage, uint16 skill_id, uint16 skill_lv); /* gvg final damage calculation */ int64 (*calc_gvg_damage) (struct block_list *src, struct block_list *bl, int64 damage, int div_, uint16 skill_id, uint16 skill_lv, int flag); /* battlegrounds final damage calculation */ diff --git a/src/map/skill.c b/src/map/skill.c index 0b66c1ded..2962cb76e 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -581,11 +581,20 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) return 1; } break; - + default: + return skill->not_ok_unknown(skill_id, sd); } return (map->list[m].flag.noskill); } +int skill_notok_unknown(uint16 skill_id, struct map_session_data *sd) +{ + int16 m; + nullpo_retr (1, sd); + m = sd->bl.m; + return (map->list[m].flag.noskill); +} + int skillnotok_hom(uint16 skill_id, struct homun_data *hd) { uint16 idx = skill->get_index(skill_id); @@ -612,12 +621,20 @@ int skillnotok_hom(uint16 skill_id, struct homun_data *hd) if(hd->sc.data[SC_GOLDENE_FERSE]) return 1; break; + default: + return skill->not_ok_hom_unknown(skill_id, hd); } //Use master's criteria. return skill->not_ok(skill_id, hd->master); } +int skillnotok_hom_unknown(uint16 skill_id, struct homun_data *hd) +{ + //Use master's criteria. + return skill->not_ok(skill_id, hd->master); +} + int skillnotok_mercenary(uint16 skill_id, struct mercenary_data *md) { uint16 idx = skill->get_index(skill_id); @@ -1548,17 +1565,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 sd->state.autocast = 1; skill->consume_requirement(sd,temp,auto_skill_lv,1); skill->toggle_magicpower(src, temp); - switch (type) { - case CAST_GROUND: - skill->castend_pos2(src, tbl->x, tbl->y, temp, auto_skill_lv, tick, 0); - break; - case CAST_NODAMAGE: - skill->castend_nodamage_id(src, tbl, temp, auto_skill_lv, tick, 0); - break; - case CAST_DAMAGE: - skill->castend_damage_id(src, tbl, temp, auto_skill_lv, tick, 0); - break; - } + skill->castend_type(type, src, tbl, temp, auto_skill_lv, tick, 0); sd->state.autocast = 0; //Set canact delay. [Skotlex] ud = unit->bl2ud(src); @@ -1686,11 +1693,7 @@ int skill_onskillusage(struct map_session_data *sd, struct block_list *bl, uint1 sd->state.autocast = 1; sd->autospell3[i].lock = true; skill->consume_requirement(sd,temp,skill_lv,1); - switch( type ) { - case CAST_GROUND: skill->castend_pos2(&sd->bl, tbl->x, tbl->y, temp, skill_lv, tick, 0); break; - case CAST_NODAMAGE: skill->castend_nodamage_id(&sd->bl, tbl, temp, skill_lv, tick, 0); break; - case CAST_DAMAGE: skill->castend_damage_id(&sd->bl, tbl, temp, skill_lv, tick, 0); break; - } + skill->castend_type(type, &sd->bl, tbl, temp, skill_lv, tick, 0); sd->autospell3[i].lock = false; sd->state.autocast = 0; } @@ -1900,17 +1903,7 @@ int skill_counter_additional_effect(struct block_list* src, struct block_list *b dstsd->state.autocast = 1; skill->consume_requirement(dstsd,auto_skill_id,auto_skill_lv,1); - switch (type) { - case CAST_GROUND: - skill->castend_pos2(bl, tbl->x, tbl->y, auto_skill_id, auto_skill_lv, tick, 0); - break; - case CAST_NODAMAGE: - skill->castend_nodamage_id(bl, tbl, auto_skill_id, auto_skill_lv, tick, 0); - break; - case CAST_DAMAGE: - skill->castend_damage_id(bl, tbl, auto_skill_id, auto_skill_lv, tick, 0); - break; - } + skill->castend_type(type, bl, tbl, auto_skill_id, auto_skill_lv, tick, 0); dstsd->state.autocast = 0; // Set canact delay. [Skotlex] ud = unit->bl2ud(bl); @@ -3556,6 +3549,21 @@ int skill_reveal_trap(struct block_list *bl, va_list ap) return 0; } +void skill_castend_type(int type, struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag) +{ + switch (type) { + case CAST_GROUND: + skill->castend_pos2(src, bl->x, bl->y, skill_id, skill_lv, tick, flag); + break; + case CAST_NODAMAGE: + skill->castend_nodamage_id(src, bl, skill_id, skill_lv, tick, flag); + break; + case CAST_DAMAGE: + skill->castend_damage_id(src, bl, skill_id, skill_lv, tick, flag); + break; + } +} + /*========================================== * * @@ -4491,18 +4499,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 if( !skill->check_condition_castbegin(sd, spell_skill_id, spell_skill_lv) ) break; - switch( skill->get_casttype(spell_skill_id) ) { - case CAST_GROUND: - skill->castend_pos2(src, bl->x, bl->y, spell_skill_id, spell_skill_lv, tick, 0); - break; - case CAST_NODAMAGE: - skill->castend_nodamage_id(src, bl, spell_skill_id, spell_skill_lv, tick, 0); - break; - case CAST_DAMAGE: - skill->castend_damage_id(src, bl, spell_skill_id, spell_skill_lv, tick, 0); - break; - } - + skill->castend_type(skill->get_casttype(spell_skill_id), src, bl, spell_skill_id, spell_skill_lv, tick, 0); sd->ud.canact_tick = tick + skill->delay_fix(src, spell_skill_id, spell_skill_lv); clif->status_change(src, SI_POSTDELAY, 1, skill->delay_fix(src, spell_skill_id, spell_skill_lv), 0, 0, 0); @@ -11886,7 +11883,8 @@ int skill_unit_onplace(struct skill_unit *src, struct block_list *bl, int64 tick return skill_id; } -void skill_unit_onplace_unknown(struct skill_unit *src, struct block_list *bl, int64 *tick) { +void skill_unit_onplace_unknown(struct skill_unit *src, struct block_list *bl, int64 *tick) +{ } /*========================================== @@ -12649,6 +12647,9 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6 status->change_start(ss, bl, SC_BLIND, rnd() % 100 > sg->skill_lv * 10, sg->skill_lv, sg->skill_id, 0, 0, skill->get_time2(sg->skill_id, sg->skill_lv), SCFLAG_FIXEDTICK|SCFLAG_FIXEDRATE); break; + default: + skill->unit_onplace_timer_unknown(src, bl, &tick); + break; } if (bl->type == BL_MOB && ss != bl) @@ -12656,6 +12657,11 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6 return skill_id; } + +void skill_unit_onplace_timer_unknown(struct skill_unit *src, struct block_list *bl, int64 *tick) +{ +} + /*========================================== * Triggered when a char steps out of a skill cell *------------------------------------------*/ @@ -18484,7 +18490,7 @@ void skill_init_unit_layout (void) } break; default: - ShowError("unknown unit layout at skill %d\n",i); + skill->init_unit_layout_unknown(i); break; } if (!skill->dbs->unit_layout[pos].count) @@ -18585,6 +18591,11 @@ void skill_init_unit_layout (void) } +void skill_init_unit_layout_unknown(int skill_idx) +{ + ShowError("unknown unit layout at skill %d\n", skill_idx); +} + int skill_block_check(struct block_list *bl, sc_type type , uint16 skill_id) { int inf = 0; struct status_change *sc = status->get_sc(bl); @@ -20466,6 +20477,7 @@ void skill_defaults(void) { skill->is_combo = skill_is_combo; skill->name2id = skill_name2id; skill->isammotype = skill_isammotype; + skill->castend_type = skill_castend_type; skill->castend_id = skill_castend_id; skill->castend_pos = skill_castend_pos; skill->castend_map = skill_castend_map; @@ -20511,7 +20523,9 @@ void skill_defaults(void) { skill->can_cloak = skill_can_cloak; skill->enchant_elemental_end = skill_enchant_elemental_end; skill->not_ok = skillnotok; + skill->not_ok_unknown = skill_notok_unknown; skill->not_ok_hom = skillnotok_hom; + skill->not_ok_hom_unknown = skillnotok_hom_unknown; skill->not_ok_mercenary = skillnotok_mercenary; skill->chastle_mob_changetarget = skill_chastle_mob_changetarget; skill->can_produce_mix = skill_can_produce_mix; @@ -20559,6 +20573,7 @@ void skill_defaults(void) { skill->sit_out = skill_sit_out; skill->unitsetmapcell = skill_unitsetmapcell; skill->unit_onplace_timer = skill_unit_onplace_timer; + skill->unit_onplace_timer_unknown = skill_unit_onplace_timer_unknown; skill->unit_effect = skill_unit_effect; skill->unit_timer_sub_onplace = skill_unit_timer_sub_onplace; skill->unit_move_sub = skill_unit_move_sub; @@ -20569,6 +20584,7 @@ void skill_defaults(void) { skill->unit_timer = skill_unit_timer; skill->unit_timer_sub = skill_unit_timer_sub; skill->init_unit_layout = skill_init_unit_layout; + skill->init_unit_layout_unknown = skill_init_unit_layout_unknown; /* Skill DB Libconfig */ skill->validate_hittype = skill_validate_hittype; skill->validate_attacktype = skill_validate_attacktype; diff --git a/src/map/skill.h b/src/map/skill.h index dfc2ecb3c..0ad91001d 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -1976,12 +1976,15 @@ struct skill_interface { bool (*can_cloak) (struct map_session_data *sd); int (*enchant_elemental_end) (struct block_list *bl, int type); int (*not_ok) (uint16 skill_id, struct map_session_data *sd); + int (*not_ok_unknown) (uint16 skill_id, struct map_session_data *sd); int (*not_ok_hom) (uint16 skill_id, struct homun_data *hd); + int (*not_ok_hom_unknown) (uint16 skill_id, struct homun_data *hd); int (*not_ok_mercenary) (uint16 skill_id, struct mercenary_data *md); int (*chastle_mob_changetarget) (struct block_list *bl,va_list ap); int (*can_produce_mix) ( struct map_session_data *sd, int nameid, int trigger, int qty); int (*produce_mix) ( struct map_session_data *sd, uint16 skill_id, int nameid, int slot1, int slot2, int slot3, int qty ); int (*arrow_create) ( struct map_session_data *sd,int nameid); + void (*castend_type) (int type, struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag); int (*castend_nodamage_id) (struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag); int (*castend_damage_id) (struct block_list* src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick,int flag); int (*castend_pos2) (struct block_list *src, int x, int y, uint16 skill_id, uint16 skill_lv, int64 tick, int flag); @@ -2024,6 +2027,7 @@ struct skill_interface { int (*sit_out) (struct block_list *bl, va_list ap); void (*unitsetmapcell) (struct skill_unit *src, uint16 skill_id, uint16 skill_lv, cell_t cell, bool flag); int (*unit_onplace_timer) (struct skill_unit *src, struct block_list *bl, int64 tick); + void (*unit_onplace_timer_unknown) (struct skill_unit *src, struct block_list *bl, int64 *tick); int (*unit_effect) (struct block_list* bl, va_list ap); int (*unit_timer_sub_onplace) (struct block_list* bl, va_list ap); int (*unit_move_sub) (struct block_list* bl, va_list ap); @@ -2034,6 +2038,7 @@ struct skill_interface { int (*unit_timer) (int tid, int64 tick, int id, intptr_t data); int (*unit_timer_sub) (union DBKey key, struct DBData *data, va_list ap); void (*init_unit_layout) (void); + void (*init_unit_layout_unknown) (int skill_idx); void (*validate_hittype) (struct config_setting_t *conf, struct s_skill_db *sk); void (*validate_skilltype) (struct config_setting_t *conf, struct s_skill_db *sk); void (*validate_attacktype) (struct config_setting_t *conf, struct s_skill_db *sk); diff --git a/src/map/status.c b/src/map/status.c index 73b5a5123..315f6bb19 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -11402,17 +11402,7 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) { mushroom_skill_id = skill->dbs->magicmushroom_db[i].skill_id; } while (mushroom_skill_id == 0); - switch( skill->get_casttype(mushroom_skill_id) ) { // Magic Mushroom skills are buffs or area damage - case CAST_GROUND: - skill->castend_pos2(bl,bl->x,bl->y,mushroom_skill_id,1,tick,0); - break; - case CAST_NODAMAGE: - skill->castend_nodamage_id(bl,bl,mushroom_skill_id,1,tick,0); - break; - case CAST_DAMAGE: - skill->castend_damage_id(bl,bl,mushroom_skill_id,1,tick,0); - break; - } + skill->castend_type(skill->get_casttype(mushroom_skill_id), bl, bl, mushroom_skill_id, 1, tick, 0); } clif->emotion(bl,E_HEH); |