- 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://svn.code.sf.net/p/rathena/svn/trunk@9658 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
skotlex 2007-01-16 13:56:17 +00:00
parent 9e0791f775
commit bc9daa6048
4 changed files with 29 additions and 14 deletions

View File

@ -3,6 +3,9 @@ Date Added
AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2007/01/16
* Some cleaning on the mob_ai to enable mobs to run away from their current
target when they are rude-attacked by them.
2007/01/15
* The NPC elemental attacks will display a skill animation again.
* Mob instant cast skills will use their adelay now.

View File

@ -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.

View File

@ -413,6 +413,19 @@ int unit_run(struct block_list *bl)
return 1;
}
//Makes bl attempt to run dist cells away from target. Uses hard-paths.
int unit_escape(struct block_list *bl, struct block_list *target, int dist)
{
int dir = map_calc_dir(target, bl->x, bl->y);
while (dist > 0 && map_getcell(bl->m,
bl->x + dist*dirx[dir], bl->y + dist*diry[dir],
CELL_CHKNOREACH))
dist--;
return (dist > 0 && unit_walktoxy(bl,
bl->x + dist*dirx[dir], bl->y + dist*diry[dir],
0));
}
//Instant warp function.
int unit_movepos(struct block_list *bl,int dst_x,int dst_y, int easy, int checkpath)
{

View File

@ -24,6 +24,7 @@ int unit_can_move(struct block_list *bl);
int unit_is_walking(struct block_list *bl);
int unit_set_walkdelay(struct block_list *bl, unsigned int tick, int delay, int type);
int unit_escape(struct block_list *bl, struct block_list *target, int dist);
// 位置の強制移動(吹き飛ばしなど)
int unit_movepos(struct block_list *bl,int dst_x,int dst_y, int easy, int checkpath);
int unit_warp(struct block_list *bl, int map, short x, short y, int type);