summaryrefslogtreecommitdiff
path: root/src/map/unit.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-12-06 18:21:32 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-12-06 18:21:32 +0000
commitf4edc7e4431b929acc62e4c2427e815ba9d69779 (patch)
treeac82447101de9f643bef0fa7a5b3a56bd1e37194 /src/map/unit.c
parentf7ff1f208a2ce086fe6636b8359c65cf14ab68f4 (diff)
downloadhercules-f4edc7e4431b929acc62e4c2427e815ba9d69779.tar.gz
hercules-f4edc7e4431b929acc62e4c2427e815ba9d69779.tar.bz2
hercules-f4edc7e4431b929acc62e4c2427e815ba9d69779.tar.xz
hercules-f4edc7e4431b929acc62e4c2427e815ba9d69779.zip
- Cleaned up the implementation of map_foreachinmovearea so that the number of arguments passed is less.
- Moved setting a mob's chase/attack states from the mob_ai to unit_attack and unit_walktobl. - Cleaned the change-target/cast-sensor code to account for the new mob modes. - Cleaned up a bit the mob ai sub hard function. - Made the monster_active_enable config setting take effect on mob load. - Updated the doc explaining mob modes. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9422 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/unit.c')
-rw-r--r--src/map/unit.c50
1 files changed, 31 insertions, 19 deletions
diff --git a/src/map/unit.c b/src/map/unit.c
index 9b6e4e85c..ef60579b6 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -145,9 +145,8 @@ static int unit_walktoxy_timer(int tid,unsigned int tick,int id,int data)
// バシリカ判定
- map_foreachinmovearea(clif_outsight,bl->m,
- x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,
- dx,dy,sd?BL_ALL:BL_PC,bl);
+ map_foreachinmovearea(clif_outsight,bl, AREA_SIZE,
+ dx, dy, sd?BL_ALL:BL_PC, bl);
x += dx;
y += dy;
@@ -155,9 +154,8 @@ static int unit_walktoxy_timer(int tid,unsigned int tick,int id,int data)
ud->walk_count++; //walked cell counter, to be used for walk-triggered skills. [Skotlex]
ud->walktimer = 1;
- map_foreachinmovearea(clif_insight,bl->m,
- x-AREA_SIZE,y-AREA_SIZE,x+AREA_SIZE,y+AREA_SIZE,
- -dx,-dy,sd?BL_ALL:BL_PC,bl);
+ map_foreachinmovearea(clif_insight, bl, AREA_SIZE,
+ -dx, -dy, sd?BL_ALL:BL_PC, bl);
ud->walktimer = -1;
if(sd) {
@@ -244,9 +242,10 @@ static int unit_walktoxy_timer(int tid,unsigned int tick,int id,int data)
}
if (tbl->m == bl->m && check_distance_bl(bl, tbl, ud->chaserange))
{ //Reached destination.
- if (ud->state.attack_continue) {
- clif_fixpos(bl); //Aegis uses one before every attack, we should
- //only need this one for syncing purposes. [Skotlex]
+ if (ud->state.attack_continue)
+ { //Aegis uses one before every attack, we should
+ //only need this one for syncing purposes. [Skotlex]
+ clif_fixpos(bl);
unit_attack(bl, tbl->id, ud->state.attack_continue);
}
} else { //Update chase-path
@@ -342,6 +341,10 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int
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;
return 1;
@@ -438,16 +441,14 @@ int unit_movepos(struct block_list *bl,int dst_x,int dst_y, int easy, int checkp
dx = dst_x - bl->x;
dy = dst_y - bl->y;
- map_foreachinmovearea(clif_outsight,bl->m,
- bl->x-AREA_SIZE,bl->y-AREA_SIZE,bl->x+AREA_SIZE,bl->y+AREA_SIZE,
- dx,dy,sd?BL_ALL:BL_PC,bl);
+ map_foreachinmovearea(clif_outsight, bl, AREA_SIZE,
+ dx, dy, sd?BL_ALL:BL_PC, bl);
map_moveblock(bl, dst_x, dst_y, gettick());
ud->walktimer = 1;
- map_foreachinmovearea(clif_insight,bl->m,
- bl->x-AREA_SIZE,bl->y-AREA_SIZE,bl->x+AREA_SIZE,bl->y+AREA_SIZE,
- -dx,-dy,sd?BL_ALL:BL_PC,bl);
+ map_foreachinmovearea(clif_insight, bl, AREA_SIZE,
+ -dx, -dy, sd?BL_ALL:BL_PC, bl);
ud->walktimer = -1;
if(sd) {
@@ -950,15 +951,22 @@ int unit_skilluse_id2(struct block_list *src, int target_id, int skill_num, int
TBL_MOB *md = (TBL_MOB*)target;
mobskill_event(md, src, tick, -1); //Cast targetted skill event.
//temp: used to store mob's mode now.
- if (tstatus->mode&MD_CASTSENSOR &&
+ if (tstatus->mode&(MD_CASTSENSOR_MELEE|MD_CASTSENSOR_CHASE) &&
battle_check_target(target, src, BCT_ENEMY) > 0)
{
switch (md->state.skillstate) {
- case MSS_ANGRY:
case MSS_RUSH:
case MSS_FOLLOW:
- if (!(tstatus->mode&(MD_AGGRESSIVE|MD_ANGRY)))
- break; //Only Aggressive mobs change target while chasing.
+ if (!(tstatus->mode&MD_CASTSENSOR_CHASE))
+ break;
+ md->target_id = src->id;
+ md->state.aggressive = (temp&MD_ANGRY)?1:0;
+ md->min_chase = md->db->range3;
+ break;
+ case MSS_ANGRY:
+ case MSS_BERSERK:
+ if (!(tstatus->mode&MD_CASTSENSOR_MELEE))
+ break;
case MSS_IDLE:
case MSS_WALK:
md->target_id = src->id;
@@ -1168,6 +1176,10 @@ int unit_attack(struct block_list *src,int target_id,int type)
if(ud->attacktimer != -1)
return 0;
+ //Set Mob's ANGRY/BERSERK states.
+ if(src->type == BL_MOB)
+ ((TBL_MOB*)src)->state.skillstate = ((TBL_MOB*)src)->state.aggressive?MSS_ANGRY:MSS_BERSERK;
+
if(DIFF_TICK(ud->attackabletime, gettick()) > 0)
//Do attack next time it is possible. [Skotlex]
ud->attacktimer=add_timer(ud->attackabletime,unit_attack_timer,src->id,0);