diff options
author | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-04-10 21:38:05 +0000 |
---|---|---|
committer | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-04-10 21:38:05 +0000 |
commit | 7961554a72e475cd71bd34f65bb548c1b13dc685 (patch) | |
tree | 58bcfac64070e2d01fd499ba9bfb4a423ebeac99 /src/map/pc.c | |
parent | 20fadf45adddb27cf7e4db736614b67f7f8561f6 (diff) | |
download | hercules-7961554a72e475cd71bd34f65bb548c1b13dc685.tar.gz hercules-7961554a72e475cd71bd34f65bb548c1b13dc685.tar.bz2 hercules-7961554a72e475cd71bd34f65bb548c1b13dc685.tar.xz hercules-7961554a72e475cd71bd34f65bb548c1b13dc685.zip |
- Modified the unit_data structure to handle automatically switching between chasing and attacking a character. Note that it's a work in progress and not yet properly tested/finished...
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5979 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/pc.c')
-rw-r--r-- | src/map/pc.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/src/map/pc.c b/src/map/pc.c index 5852edc08..8502b5ce8 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -3821,26 +3821,23 @@ int pc_follow_timer(int tid,unsigned int tick,int id,int data) if (pc_isdead(sd))
return 0;
- if ((tsd = map_id2sd(sd->followtarget)) != NULL)
- {
- if (pc_isdead(tsd))
- return 0;
+ if ((tsd = map_id2sd(sd->followtarget)) == NULL || pc_isdead(tsd))
+ return 0;
- // either player or target is currently detached from map blocks (could be teleporting),
- // but still connected to this map, so we'll just increment the timer and check back later
- if (sd->bl.prev != NULL && tsd->bl.prev != NULL &&
- sd->ud.skilltimer == -1 && sd->ud.attacktimer == -1 && sd->ud.walktimer == -1)
- {
- if((sd->bl.m == tsd->bl.m) && unit_can_reach(&sd->bl,tsd->bl.x,tsd->bl.y)) {
- if (!check_distance_bl(&sd->bl, &tsd->bl, 5) && unit_can_move(&sd->bl))
- unit_walktoxy(&sd->bl,tsd->bl.x,tsd->bl.y, 0);
- } else
- pc_setpos(sd, tsd->mapindex, tsd->bl.x, tsd->bl.y, 3);
- }
- sd->followtimer = add_timer(
- tick + sd->aspd + rand() % 1000, // increase time a bit to loosen up map's load
- pc_follow_timer, sd->bl.id, 0);
+ // either player or target is currently detached from map blocks (could be teleporting),
+ // but still connected to this map, so we'll just increment the timer and check back later
+ if (sd->bl.prev != NULL && tsd->bl.prev != NULL &&
+ sd->ud.skilltimer == -1 && sd->ud.attacktimer == -1 && sd->ud.walktimer == -1)
+ {
+ if((sd->bl.m == tsd->bl.m) && unit_can_reach_bl(&sd->bl,&tsd->bl, AREA_SIZE, 0, NULL, NULL)) {
+ if (!check_distance_bl(&sd->bl, &tsd->bl, 5))
+ unit_walktobl(&sd->bl, &tsd->bl, 5, 0);
+ } else
+ pc_setpos(sd, tsd->mapindex, tsd->bl.x, tsd->bl.y, 3);
}
+ sd->followtimer = add_timer(
+ tick + sd->aspd + rand() % 1000, // increase time a bit to loosen up map's load
+ pc_follow_timer, sd->bl.id, 0);
return 0;
}
|