summaryrefslogtreecommitdiff
path: root/src/map/mob.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-01-16 13:56:17 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-01-16 13:56:17 +0000
commit8ff8d0f9ee285452ba7820c3fb333eddb042272b (patch)
tree167718cd574dbaa83ed3c4baf4ede65a0c5266f3 /src/map/mob.c
parente2d3ae9dc682afc1ac34a536006ef79370040b04 (diff)
downloadhercules-8ff8d0f9ee285452ba7820c3fb333eddb042272b.tar.gz
hercules-8ff8d0f9ee285452ba7820c3fb333eddb042272b.tar.bz2
hercules-8ff8d0f9ee285452ba7820c3fb333eddb042272b.tar.xz
hercules-8ff8d0f9ee285452ba7820c3fb333eddb042272b.zip
- Added function unit_escape to simplify the run-away code a bit in the mob ai.
- Some cleaning on the mob_ai to enable mobs to run away from their current target when they are rude-attacked by them. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9658 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/mob.c')
-rw-r--r--src/map/mob.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/map/mob.c b/src/map/mob.c
index d7e6f9592..fca96c965 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -1123,12 +1123,16 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap)
if (md->attacked_id == md->target_id)
{
if (!battle_check_range(&md->bl, tbl, md->status.rhw.range) &&
- ((!can_move && battle_config.mob_ai&0x2) ||
- (!mob_can_reach(md, tbl, md->min_chase, MSS_RUSH))))
+ (
+ (!can_move && battle_config.mob_ai&0x2) ||
+ (!mob_can_reach(md, tbl, md->min_chase, MSS_RUSH))
+ ) &&
+ DIFF_TICK(tick, md->ud.canmove_tick) > 0 &&
+ md->state.attacked_count++ >= RUDE_ATTACKED_COUNT
+ )
{ //Rude-attacked (avoid triggering due to can-walk delay).
- if (DIFF_TICK(tick, md->ud.canmove_tick) > 0 &&
- md->state.attacked_count++ >= RUDE_ATTACKED_COUNT)
- mobskill_use(md, tick, MSC_RUDEATTACKED);
+ if (!mobskill_use(md, tick, MSC_RUDEATTACKED) && can_move)
+ unit_escape(bl, tbl, rand()%10 +1);
}
} else
if ((abl= map_id2bl(md->attacked_id)) && (!tbl || mob_can_changetarget(md, abl, mode))) {
@@ -1142,15 +1146,9 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap)
((TBL_PC*)abl)->state.gangsterparadise
)
) { //Can't attack back
- if (md->state.attacked_count++ >= RUDE_ATTACKED_COUNT) {
- if (mobskill_use(md, tick, MSC_RUDEATTACKED) == 0 && can_move)
- {
- int dist = rand() % 10 + 1;//Œã‘Þ‚·‚é‹——£
- int dir = map_calc_dir(abl, bl->x, bl->y);
- int mask[8][2] = {{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1},{1,0},{1,1}};
- unit_walktoxy(&md->bl, md->bl.x + dist * mask[dir][0], md->bl.y + dist * mask[dir][1], 0);
- }
- }
+ if (md->state.attacked_count++ >= RUDE_ATTACKED_COUNT &&
+ !mobskill_use(md, tick, MSC_RUDEATTACKED) && can_move)
+ unit_escape(bl, abl, rand()%10 +1);
} else if (!(battle_config.mob_ai&0x2) && !status_check_skilluse(bl, abl, 0, 0)) {
//Can't attack back, but didn't invoke a rude attacked skill...
md->attacked_id = 0; //Simply unlock, shouldn't attempt to run away when in dumb_ai mode.