summaryrefslogtreecommitdiff
path: root/src/map/unit.c
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-07-05 18:07:31 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-07-05 18:07:31 +0000
commita7574756fd69e9935bbb98d0d0fe6c3d3645d71f (patch)
treedf23a8e42a8a66d8334f3408f2ac445bc782a083 /src/map/unit.c
parent888584986b05b663898726aa5bf9f4ea9f3d8495 (diff)
downloadhercules-a7574756fd69e9935bbb98d0d0fe6c3d3645d71f.tar.gz
hercules-a7574756fd69e9935bbb98d0d0fe6c3d3645d71f.tar.bz2
hercules-a7574756fd69e9935bbb98d0d0fe6c3d3645d71f.tar.xz
hercules-a7574756fd69e9935bbb98d0d0fe6c3d3645d71f.zip
* update from Skotlex
- Fixed NPC_STOP's visual effect not clearing when the status ends - Corrected @homshuffle making the skill tree be lost. - Corrected homunculus skills being unusable if the master was sitting or inflicted by a disabling status (eg: petrify, stun) - Some fixes to the cell no stacking mod (mainly mobs would just get stuck behind each other and not properly surround you) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10856 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/unit.c')
-rw-r--r--src/map/unit.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/map/unit.c b/src/map/unit.c
index c05b8e25a..f09444b4c 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -317,6 +317,11 @@ int unit_walktoxy( struct block_list *bl, int x, int y, int flag)
return unit_walktoxy_sub(bl);
}
+//To set Mob's CHASE/FOLLOW states (shouldn't be done if there's no path to reach)
+#define set_mobstate(bl, flag) \
+ if((bl)->type == BL_MOB && (flag)) \
+ ((TBL_MOB*)(bl))->state.skillstate = ((TBL_MOB*)(bl))->state.aggressive?MSS_FOLLOW:MSS_RUSH;
+
static int unit_walktobl_sub(int tid,unsigned int tick,int id,int data)
{
struct block_list *bl = map_id2bl(id);
@@ -327,7 +332,10 @@ static int unit_walktobl_sub(int tid,unsigned int tick,int id,int data)
if (DIFF_TICK(ud->canmove_tick, tick) > 0) //Keep waiting?
add_timer(ud->canmove_tick+1, unit_walktobl_sub, id, data);
else if (unit_can_move(bl))
- unit_walktoxy_sub(bl);
+ {
+ if (unit_walktoxy_sub(bl))
+ set_mobstate(bl, ud->state.attack_continue);
+ }
}
return 0;
}
@@ -361,13 +369,10 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int
sc = status_get_sc(bl);
if (sc && sc->count && sc->data[SC_CONFUSION].timer != -1) //Randomize the target position
map_random_dir(bl, &ud->to_x, &ud->to_y);
-
- //Set Mob's CHASE/FOLLOW states.
- if(bl->type == BL_MOB && flag&2)
- ((TBL_MOB*)bl)->state.skillstate = ((TBL_MOB*)bl)->state.aggressive?MSS_FOLLOW:MSS_RUSH;
if(ud->walktimer != -1) {
ud->state.change_walk_target = 1;
+ set_mobstate(bl, flag&2);
return 1;
}
@@ -385,8 +390,13 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int
ud->attacktimer = -1;
}
- return unit_walktoxy_sub(bl);
+ if (unit_walktoxy_sub(bl)) {
+ set_mobstate(bl, flag&2);
+ return 1;
+ }
+ return 0;
}
+#undef set_mobstate
int unit_run(struct block_list *bl)
{
@@ -1317,9 +1327,9 @@ int unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range, i
dx=(dx>0)?1:((dx<0)?-1:0);
dy=(dy>0)?1:((dy<0)?-1:0);
- if (map_getcell(tbl->m,tbl->x-dx,tbl->y-dy,CELL_CHKNOREACH))
+ if (map_getcell(tbl->m,tbl->x-dx,tbl->y-dy,CELL_CHKNOPASS))
{ //Look for a suitable cell to place in.
- for(i=0;i<9 && map_getcell(tbl->m,tbl->x-dirx[i],tbl->y-diry[i],CELL_CHKNOREACH);i++);
+ for(i=0;i<9 && map_getcell(tbl->m,tbl->x-dirx[i],tbl->y-diry[i],CELL_CHKNOPASS);i++);
if (i==9) return 0; //No valid cells.
dx = dirx[i];
dy = diry[i];