summaryrefslogtreecommitdiff
path: root/src/map/mob.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/mob.c')
-rw-r--r--src/map/mob.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/map/mob.c b/src/map/mob.c
index d0a65315a..eea1ff18e 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -1603,8 +1603,8 @@ bool mob_ai_sub_hard(struct mob_data *md, int64 tick) {
//Attempt to attack.
//At this point we know the target is attackable, we just gotta check if the range matches.
- if (battle->check_range (&md->bl, tbl, md->status.rhw.range))
- { //Target within range, engage
+ if (battle->check_range(&md->bl, tbl, md->status.rhw.range) && !(md->sc.option&OPTION_HIDE))
+ { //Target within range and able to use normal attack, engage
if (md->ud.target != tbl->id || md->ud.attacktimer == INVALID_TIMER)
{ //Only attack if no more attack delay left
if(tbl->type == BL_PC)
@@ -1624,6 +1624,19 @@ bool mob_ai_sub_hard(struct mob_data *md, int64 tick) {
return true;
}
+ //Monsters in berserk state, unable to use normal attacks, will always attempt a skill
+ if(md->ud.walktimer == INVALID_TIMER && (md->state.skillstate == MSS_BERSERK || md->state.skillstate == MSS_ANGRY)) {
+ if (DIFF_TICK(md->ud.canmove_tick, tick) <= MIN_MOBTHINKTIME && DIFF_TICK(md->ud.canact_tick, tick) < -MIN_MOBTHINKTIME*IDLE_SKILL_INTERVAL)
+ { //Only use skill if able to walk on next tick and not used a skill the last second
+ mob->skill_use(md, tick, -1);
+ }
+ }
+
+ //Target still in attack range, no need to chase the target
+ if(battle->check_range(&md->bl, tbl, md->status.rhw.range))
+ return true;
+
+
//Out of range...
if (!(mode&MD_CANMOVE) || (!can_move && DIFF_TICK(tick, md->ud.canmove_tick) > 0))
{ //Can't chase. Immobile and trapped mobs should unlock target and use an idle skill.
@@ -1635,15 +1648,6 @@ bool mob_ai_sub_hard(struct mob_data *md, int64 tick) {
return true;
}
- //Before a monster starts to chase a target, it will check if it has a ranged "attack" skill to use on it.
- if(md->ud.walktimer == INVALID_TIMER && (md->state.skillstate == MSS_BERSERK || md->state.skillstate == MSS_ANGRY))
- {
- if (DIFF_TICK(md->ud.canmove_tick, tick) <= MIN_MOBTHINKTIME && DIFF_TICK(md->ud.canact_tick, tick) < -MIN_MOBTHINKTIME*IDLE_SKILL_INTERVAL)
- { //Only use skill if able to walk on next tick and not used a skill the last second
- mob->skill_use(md, tick, -1);
- }
- }
-
if (md->ud.walktimer != INVALID_TIMER && md->ud.target == tbl->id &&
(
!(battle_config.mob_ai&0x1) ||