summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-07-11 01:34:51 +0300
committerAndrei Karas <akaras@inbox.ru>2016-07-12 23:22:59 +0300
commitddca9bf6efe551a7d7dbc3d12a7d638453defcd6 (patch)
treeeef6d506215354a1d0acea0f890acb612f8a9314 /src
parent69df5ffa970dbcafde7dbb5d360c0ea28300cb50 (diff)
downloadhercules-ddca9bf6efe551a7d7dbc3d12a7d638453defcd6.tar.gz
hercules-ddca9bf6efe551a7d7dbc3d12a7d638453defcd6.tar.bz2
hercules-ddca9bf6efe551a7d7dbc3d12a7d638453defcd6.tar.xz
hercules-ddca9bf6efe551a7d7dbc3d12a7d638453defcd6.zip
Add into skill.c some handling for unknown skills/skill units.
Also improve a bit cast end functions call.
Diffstat (limited to 'src')
-rw-r--r--src/map/battle.c25
-rw-r--r--src/map/skill.c100
-rw-r--r--src/map/skill.h5
-rw-r--r--src/map/status.c12
4 files changed, 66 insertions, 76 deletions
diff --git a/src/map/battle.c b/src/map/battle.c
index 76b74a766..6e8ff3ba9 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -6269,17 +6269,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 +6315,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);
}
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);