summaryrefslogtreecommitdiff
path: root/src/map/mob.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-03-29 14:53:22 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-03-29 14:53:22 +0000
commit5498a520d7b5bc65d8b8c2ab949cf2986848c104 (patch)
tree344e3e2fc87dc5bc3a515730da90423ee3074dc1 /src/map/mob.c
parent008f7c84a7220474b1c6a8a0463dc72d3e3364d5 (diff)
downloadhercules-5498a520d7b5bc65d8b8c2ab949cf2986848c104.tar.gz
hercules-5498a520d7b5bc65d8b8c2ab949cf2986848c104.tar.bz2
hercules-5498a520d7b5bc65d8b8c2ab949cf2986848c104.tar.xz
hercules-5498a520d7b5bc65d8b8c2ab949cf2986848c104.zip
- Some cleaning of the mob_ai. Mobs should stop chasing once you are beyond their min_chase range. Improved rude-attacked checking when mobs can't move.
- range3 is now used as min-chase value of mobs. - Added a debug message when status_change_timer fails. - Fixed tick direct modifications increasing duration instead of decreasing it. - Fixed inf2 of Jump-Kick to make it a "combo-skill" so that it may do a BCT_ENEMY check. - When sd->state.skill_flag is set, auto-targetting through combo-skills is disabled. - You can't SG_FEEL maps already memorized. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5796 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/mob.c')
-rw-r--r--src/map/mob.c72
1 files changed, 40 insertions, 32 deletions
diff --git a/src/map/mob.c b/src/map/mob.c
index a344375b1..e42df3412 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -800,7 +800,7 @@ int mob_target(struct mob_data *md,struct block_list *bl,int dist)
md->target_id = bl->id; // Since there was no disturbance, it locks on to target.
if (md->state.provoke_flag && bl->id != md->state.provoke_flag)
md->state.provoke_flag = 0;
- md->min_chase=dist+md->db->range2;
+ md->min_chase=dist+md->db->range3;
if(md->min_chase>MAX_MINCHASE)
md->min_chase=MAX_MINCHASE;
return 0;
@@ -839,7 +839,9 @@ static int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap)
(*target) = bl;
md->target_id=bl->id;
md->state.aggressive = (status_get_mode(&md->bl)&MD_ANGRY)?1:0;
- md->min_chase= md->db->range3;
+ md->min_chase= dist + md->db->range3;
+ if(md->min_chase>MAX_MINCHASE)
+ md->min_chase=MAX_MINCHASE;
return 1;
}
break;
@@ -1001,7 +1003,7 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick)
if (tbl && status_check_skilluse(&md->bl, tbl, 0, 0)) {
md->target_id=tbl->id;
md->state.aggressive = (status_get_mode(&md->bl)&MD_ANGRY)?1:0;
- md->min_chase=md->db->range2+distance_bl(&md->bl, tbl);
+ md->min_chase=md->db->range3+distance_bl(&md->bl, tbl);
if(md->min_chase>MAX_MINCHASE)
md->min_chase=MAX_MINCHASE;
}
@@ -1130,10 +1132,17 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap)
}
// Check for target change.
- if (md->attacked_id && mode&MD_CANATTACK && md->attacked_id != md->target_id)
+ if (md->attacked_id && mode&MD_CANATTACK)
{
- abl = map_id2bl(md->attacked_id);
- if (abl && (!tbl || mob_can_changetarget(md, abl, mode))) {
+ if (md->attacked_id == md->target_id)
+ {
+ if (!can_move && !battle_check_range (&md->bl, tbl, md->db->range))
+ { //Rude-attacked.
+ if (md->attacked_count++ > 3)
+ mobskill_use(md, tick, MSC_RUDEATTACKED);
+ }
+ } else
+ if ((abl= map_id2bl(md->attacked_id)) && (!tbl || mob_can_changetarget(md, abl, mode))) {
if (md->bl.m != abl->m || abl->prev == NULL ||
(dist = distance_bl(&md->bl, abl)) >= 32 ||
battle_check_target(bl, abl, BCT_ENEMY) <= 0 ||
@@ -1141,7 +1150,7 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap)
!mob_can_reach(md, abl, dist+2, MSS_RUSH) ||
( //Gangster Paradise check
abl->type == BL_PC && !(mode&MD_BOSS) &&
- ((struct map_session_data*)abl)->state.gangsterparadise
+ ((TBL_PC*)abl)->state.gangsterparadise
)
) { //Can't attack back
if (md->attacked_count++ > 3) {
@@ -1178,15 +1187,13 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap)
}
}
}
- }
-
- if (md->attacked_id) {
if (md->state.aggressive && md->attacked_id == md->target_id)
md->state.aggressive = 0; //No longer aggressive, change to retaliate AI.
+ //Clear it since it's been checked for already.
md->attacked_players = 0;
- md->attacked_id = 0; //Clear it since it's been checked for already.
+ md->attacked_id = 0;
}
-
+
if (md->ud.attacktimer != -1 && tbl && md->ud.attacktarget == tbl->id)
return 0; //Already attacking the current target.
@@ -1217,43 +1224,44 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap)
if (tbl->type != BL_ITEM)
{ //Attempt to attack.
//At this point we know the target is attackable, we just gotta check if the range matches.
- if (!check_distance_bl(&md->bl, tbl, view_range))
- { //Run towards the enemy when out of range?
- if (!can_move) {
- mob_unlocktarget(md, tick);
- return 0;
- }
- dx = tbl->x - md->bl.x -1;
- dy = tbl->y - md->bl.y -1;
- unit_walktoxy(&md->bl, md->bl.x+dx, md->bl.y+dy, 0);
- return 0;
- }
+
if (!battle_check_range (&md->bl, tbl, md->db->range))
{ //Out of range...
mob_stop_attack(md);
if (!(mode&MD_CANMOVE))
{ //Can't chase. Attempt to use a ranged skill at least?
- if (mobskill_use(md, tick, MSC_LONGRANGEATTACKED) == 0)
- md->attacked_count++; //Increase rude-attacked count as it can't attack back.
+ mobskill_use(md, tick, MSC_LONGRANGEATTACKED);
mob_unlocktarget(md,tick);
return 0;
}
- if (!can_move) //Wait until you can move?
- return 0;
//Follow up
+ if (!mob_can_reach(md, tbl, md->min_chase, MSS_RUSH))
+ { //Give up.
+ mob_unlocktarget(md,tick);
+ return 0;
+ }
+ if (!check_distance_bl(&md->bl, tbl, view_range))
+ { //Run towards the enemy when out of range?
+ if (!can_move)
+ { //Give it up.
+ mob_unlocktarget(md,tick);
+ return 0;
+ }
+ dx = tbl->x - md->bl.x -1;
+ dy = tbl->y - md->bl.y -1;
+ unit_walktoxy(&md->bl, md->bl.x+dx, md->bl.y+dy, 0);
+ return 0;
+ }
md->state.skillstate = md->state.aggressive?MSS_FOLLOW:MSS_RUSH;
mobskill_use (md, tick, -1);
+ if (!can_move) //Wait until you can move?
+ return 0;
if (md->ud.walktimer != -1 &&
(!battle_config.mob_ai&1 ||
check_distance_blxy(tbl, md->ud.to_x, md->ud.to_y, md->db->range)) //Current target tile is still within attack range.
) {
return 0; //No need to follow, already doing it?
}
- if (!mob_can_reach(md, tbl, md->min_chase, MSS_RUSH))
- { //Can't reach
- mob_unlocktarget(md,tick);
- return 0;
- }
//Target reachable. Locate suitable spot to move to.
i = j = 0;
dx = tbl->x - md->bl.x;