summaryrefslogtreecommitdiff
path: root/src/map/mob.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-02-18 06:10:49 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-02-18 06:10:49 +0000
commit1f94317bebf10175fb02c0f22e32a9010033a6c9 (patch)
tree293b36db504bfe3015b967a517cfea2c87ab77ac /src/map/mob.c
parent61047a615711051cd2896bec8c88816690a2bd0b (diff)
downloadhercules-1f94317bebf10175fb02c0f22e32a9010033a6c9.tar.gz
hercules-1f94317bebf10175fb02c0f22e32a9010033a6c9.tar.bz2
hercules-1f94317bebf10175fb02c0f22e32a9010033a6c9.tar.xz
hercules-1f94317bebf10175fb02c0f22e32a9010033a6c9.zip
- Added an alternate path searching method for non-stacking mode.
- Allowed pc_setpos to place players on top of cells that are stacked in CELL_NOSTACK mode. - Fixed a missing break that was making Heal, Resurrection and some others become attack skills x.x' - Fixed a logic bug in the mob-walk code that was making them get stuck and not move (triggered quite often when the cell no stack mod is enabled) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5320 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/mob.c')
-rw-r--r--src/map/mob.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/map/mob.c b/src/map/mob.c
index 5cb4e5c92..6be660c9e 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -509,7 +509,6 @@ static int mob_walktoxy_sub(struct mob_data *md);
*/
static int mob_walk(struct mob_data *md,unsigned int tick,int data)
{
- int moveblock;
int i;
static int dirx[8]={0,-1,-1,-1,0,1,1,1};
static int diry[8]={1,1,0,-1,-1,-1,0,1};
@@ -550,8 +549,6 @@ static int mob_walk(struct mob_data *md,unsigned int tick,int data)
return 0;
}
- moveblock = ( x/BLOCK_SIZE != (x+dx)/BLOCK_SIZE || y/BLOCK_SIZE != (y+dy)/BLOCK_SIZE);
-
md->state.state=MS_WALK;
map_foreachinmovearea(clif_moboutsight,md->bl.m,x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,dx,dy,BL_PC,md);
@@ -787,7 +784,7 @@ int mob_changestate(struct mob_data *md,int state,int type)
case MS_WALK:
if((i=calc_next_walk_step(md))>0){
i = i>>2;
- md->timer=add_timer(gettick()+i,mob_timer,md->bl.id,0);
+ md->timer=add_timer(gettick()+i,mob_timer,md->bl.id, md->walkpath.path_pos);
}
else
md->state.state=MS_IDLE;
@@ -890,20 +887,13 @@ static int mob_timer(int tid,unsigned int tick,int id,int data)
static int mob_walktoxy_sub(struct mob_data *md)
{
struct walkpath_data wpd;
- int x,y;
- static int dirx[8]={0,-1,-1,-1,0,1,1,1};
- static int diry[8]={1,1,0,-1,-1,-1,0,1};
-
nullpo_retr(0, md);
-
memset(&wpd, 0, sizeof(wpd));
if(path_search(&wpd,md->bl.m,md->bl.x,md->bl.y,md->to_x,md->to_y,md->state.walk_easy))
return 1;
if (wpd.path[0] >= 8)
return 1;
- x = md->bl.x+dirx[wpd.path[0]];
- y = md->bl.y+diry[wpd.path[0]];
memcpy(&md->walkpath,&wpd,sizeof(wpd));
@@ -1753,6 +1743,28 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap)
else if (dx > 0) dx--;
if (dy < 0) dy++;
else if (dy > 0) dy--;
+#ifdef CELL_NOSTACK
+ while (mob_walktoxy(md, md->bl.x + dx, md->bl.y + dy, 0))
+ { //Attempt to chase to nearby blocks
+ do {
+ if (i < 5) {
+ dx = tbl->x - md->bl.x + rand()%3 - 1;
+ dy = tbl->y - md->bl.y + rand()%3 - 1;
+ } else { //Try some more...
+ dx = tbl->x - md->bl.x + rand()%5 - 2;
+ dy = tbl->y - md->bl.y + rand()%5 - 2;
+ }
+ i++;
+ } while (i < 15 && map_getcell(md->bl.m, md->bl.x+dx, md->bl.y+dy, CELL_CHKSTACK));
+ if (i >= 15) {
+ //On stacked mode, it is much more likely that you just can't reach the target. So unlock it
+ mob_unlocktarget(md, tick);
+ //Make it give up for 1 second to avoid unnecessary server load in case the target is already mobbed to death.
+ mob_changestate(md,MS_DELAY,1000);
+ return 0;
+ }
+ }
+#else
while (i < 5 && mob_walktoxy(md, md->bl.x + dx, md->bl.y + dy, 0))
{ //Attempt to chase to nearby blocks
dx = tbl->x - md->bl.x + rand()%3 - 1;
@@ -1766,6 +1778,7 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap)
if (dy < 0) dy = 2;
else if (dy > 0) dy = -2;
}
+#endif
md->next_walktime = tick + 500;
mob_walktoxy (md, md->bl.x+dx, md->bl.y+dy, 0);
return 0;