summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-04-11 00:27:15 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-04-11 00:27:15 +0000
commit4fec7fb11ff316e837be25e07ae427d8aa7df460 (patch)
tree632fb4dd7e49d7ff2fa3ff78f45010e6db02a598 /src
parent7961554a72e475cd71bd34f65bb548c1b13dc685 (diff)
downloadhercules-4fec7fb11ff316e837be25e07ae427d8aa7df460.tar.gz
hercules-4fec7fb11ff316e837be25e07ae427d8aa7df460.tar.bz2
hercules-4fec7fb11ff316e837be25e07ae427d8aa7df460.tar.xz
hercules-4fec7fb11ff316e837be25e07ae427d8aa7df460.zip
- Fixes to the unit_data update that lets characters auto-chase while attacking.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5980 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/map/map.c2
-rw-r--r--src/map/mob.c5
-rw-r--r--src/map/pet.c1
-rw-r--r--src/map/skill.h3
-rw-r--r--src/map/unit.c41
5 files changed, 22 insertions, 30 deletions
diff --git a/src/map/map.c b/src/map/map.c
index 55b7996a4..aac3bea46 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -3659,6 +3659,7 @@ void do_final(void) {
do_final_pet();
do_final_mob();
do_final_msg();
+ do_final_unit();
if(use_irc)
do_final_irc();
@@ -3892,6 +3893,7 @@ int do_init(int argc, char *argv[]) {
do_init_skill();
do_init_pet();
do_init_npc();
+ do_init_unit();
#ifndef TXT_ONLY /* mail system [Valaris] */
if(mail_server_enable)
do_init_mail();
diff --git a/src/map/mob.c b/src/map/mob.c
index bdf2360f2..918acf6a0 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -967,6 +967,7 @@ int mob_unlocktarget(struct mob_data *md,int tick)
md->state.skillstate=MSS_IDLE;
md->next_walktime=tick+rand()%3000+3000;
mob_stop_attack(md);
+ md->ud.attacktarget = md->ud.walktarget = 0;
return 0;
}
/*==========================================
@@ -1182,8 +1183,6 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap)
mob_unlocktarget(md,tick);
return 0;
}
- if (!can_move) //Wait until you can move?
- return 0;
md->state.skillstate = md->state.aggressive?MSS_FOLLOW:MSS_RUSH;
if (md->ud.walktimer != -1 && md->ud.walktarget == tbl->id &&
(
@@ -1192,7 +1191,7 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap)
)) //Current target tile is still within attack range.
return 0;
//Target reachable. Locate suitable spot to move to.
- unit_walktobl(&md->bl, tbl, md->db->range, !battle_config.mob_ai&1);
+ unit_walktobl(&md->bl, tbl, md->db->range, 2|(!battle_config.mob_ai&1));
return 0;
}
//Target within range, engage
diff --git a/src/map/pet.c b/src/map/pet.c
index 4904d1c45..6f7819f7a 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -123,6 +123,7 @@ int pet_unlocktarget(struct pet_data *pd)
pd->target_id=0;
pet_stop_attack(pd);
+ pd->ud.attacktarget = pd->ud.walktarget = 0;
return 0;
}
diff --git a/src/map/skill.h b/src/map/skill.h
index f27a47f5a..42069c29c 100644
--- a/src/map/skill.h
+++ b/src/map/skill.h
@@ -42,8 +42,7 @@
#define INF2_GUILD_ONLY 2048
//Walk intervals at which chase-skills are attempted to be triggered.
-//Note that every 2 is an actual cell walked.
-#define WALK_SKILL_INTERVAL 6
+#define WALK_SKILL_INTERVAL 2
// スキルデ?タベ?ス
struct skill_db {
diff --git a/src/map/unit.c b/src/map/unit.c
index 6b5dd0433..fe2b51b1f 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -46,7 +46,7 @@ int unit_walktoxy_sub(struct block_list *bl)
{
int i;
struct walkpath_data wpd;
- struct unit_data *ud = NULL;
+ struct unit_data *ud = NULL;
nullpo_retr(1, bl);
ud = unit_bl2ud(bl);
@@ -56,6 +56,17 @@ int unit_walktoxy_sub(struct block_list *bl)
return 0;
memcpy(&ud->walkpath,&wpd,sizeof(wpd));
+
+ if (ud->walktarget && ud->chaserange >0) {
+ //Trim the last part of the path to account for range.
+ for (i = 1; i <= ud->chaserange && ud->walkpath.path_len>0; i++) {
+ int dir;
+ ud->walkpath.path_len--;
+ dir = ud->walkpath.path[ud->walkpath.path_len];
+ ud->to_x -= dirx[dir];
+ ud->to_y -= diry[dir];
+ }
+ }
ud->state.change_walk_target=0;
@@ -175,7 +186,7 @@ static int unit_walktoxy_timer(int tid,unsigned int tick,int id,int data)
if (
(sd->class_&MAPID_UPPERMASK) == MAPID_STAR_GLADIATOR &&
sd->sc.data[SC_MIRACLE].timer==-1 &&
- !ud->walkpath.path_pos%WALK_SKILL_INTERVAL &&
+ ud->walkpath.path_pos && ud->walkpath.path_pos%WALK_SKILL_INTERVAL == 0 &&
rand()%10000 < battle_config.sg_miracle_skill_ratio
) { //SG_MIRACLE [Komurka]
clif_displaymessage(sd->fd,"[Miracle of the Sun, Moon and Stars]");
@@ -184,7 +195,7 @@ static int unit_walktoxy_timer(int tid,unsigned int tick,int id,int data)
} else if (md) {
if (ud->attacktarget) {
if(md->min_chase > md->db->range2) md->min_chase--;
- if(!ud->walkpath.path_pos%WALK_SKILL_INTERVAL &&
+ if(ud->walkpath.path_pos && ud->walkpath.path_pos%WALK_SKILL_INTERVAL == 0 &&
mobskill_use(md, tick, -1))
return 0;
}
@@ -283,7 +294,6 @@ static int unit_walktobl_sub(int tid,unsigned int tick,int id,int data)
int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int flag) {
struct unit_data *ud = NULL;
struct status_change *sc = NULL;
- int i;
nullpo_retr(0, bl);
nullpo_retr(0, tbl);
@@ -293,8 +303,7 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int
if (!(status_get_mode(bl)&MD_CANMOVE))
return 0;
- i = distance_bl(bl, tbl)+1;
- if (!unit_can_reach_bl(bl, tbl, i, flag&1, &ud->to_x, &ud->to_y)) {
+ if (!unit_can_reach_bl(bl, tbl, distance_bl(bl, tbl)+1, flag&1, &ud->to_x, &ud->to_y)) {
ud->to_x = bl->x;
ud->to_y = bl->y;
return 0;
@@ -304,23 +313,6 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int
ud->walktarget = tbl->id;
ud->chaserange = range;
- if (range) {
- //Adjust target cell
- if (i < range) {
- //We are already within required distance!
- if (flag&2) //Attack
- unit_attack(bl, tbl->id, 1);
- return 1;
- }
- //Trim the last part of the path to account for range.
- for (i = 1; i <= range && ud->walkpath.path_len>0; i++) {
- int dir;
- ud->walkpath.path_len--;
- dir = ud->walkpath.path[ud->walkpath.path_len];
- ud->to_x -= dirx[dir];
- ud->to_y -= diry[dir];
- }
- }
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);
@@ -625,7 +617,6 @@ int unit_can_move(struct block_list *bl)
return 1;
}
-
/*==========================================
* Applies walk delay to character, considering that
* if type is 0, this is a damage induced delay: if previous delay is active, do not change it.
@@ -648,6 +639,7 @@ int unit_set_walkdelay(struct block_list *bl, unsigned int tick, int delay, int
if (ud->walktimer != -1)
{ //Stop walking, if chasing, readjust timers.
delete_timer(ud->walktimer, unit_walktoxy_timer);
+ ud->walktimer = -1;
clif_fixpos(bl);
if(ud->walktarget)
add_timer(ud->canmove_tick+1, unit_walktobl_sub, bl->id, ud->walktarget);
@@ -1055,7 +1047,6 @@ int unit_stop_attack(struct block_list *bl)
delete_timer( ud->attacktimer, unit_attack_timer );
ud->attacktimer = -1;
- ud->state.attack_continue = 0;
return 0;
}