diff options
author | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-04-11 04:10:41 +0000 |
---|---|---|
committer | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-04-11 04:10:41 +0000 |
commit | 96145e78a56a090e60a77c09147d2cb0991fda2d (patch) | |
tree | 174455953b53d4e37c4e26ef8ada4989659c6f8d /src/map/pet.c | |
parent | c31d5fe703c5ab30a398ef7da9059f4e20b7891d (diff) | |
download | hercules-96145e78a56a090e60a77c09147d2cb0991fda2d.tar.gz hercules-96145e78a56a090e60a77c09147d2cb0991fda2d.tar.bz2 hercules-96145e78a56a090e60a77c09147d2cb0991fda2d.tar.xz hercules-96145e78a56a090e60a77c09147d2cb0991fda2d.zip |
- Multiple optimizations to the unit_data auto-chase upgrade, also simplified the mob and pet ai routines.
- Simplified the walk routines to half the number of timers required for walking.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5982 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/pet.c')
-rw-r--r-- | src/map/pet.c | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/src/map/pet.c b/src/map/pet.c index 6f7819f7a..b11ee0e15 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -123,7 +123,7 @@ int pet_unlocktarget(struct pet_data *pd) pd->target_id=0;
pet_stop_attack(pd);
- pd->ud.attacktarget = pd->ud.walktarget = 0;
+ pet_stop_walking(pd,1);
return 0;
}
@@ -960,7 +960,7 @@ static int pet_ai_sub_hard(struct pet_data *pd,unsigned int tick) //Master too far, chase.
if(pd->target_id)
pet_unlocktarget(pd);
- if(pd->ud.walktimer != -1 && pd->ud.walktarget == sd->bl.id)
+ if(pd->ud.walktimer != -1 && pd->ud.target == sd->bl.id)
return 0; //Already walking to him
pd->speed = (sd->speed>>1);
@@ -1007,36 +1007,28 @@ static int pet_ai_sub_hard(struct pet_data *pd,unsigned int tick) return 0;
}
+ if(pd->ud.target == target->id &&
+ (pd->ud.attacktimer != -1 || pd->ud.walktimer != -1))
+ return 0; //Target already locked.
+
if (target->type != BL_ITEM)
{ //enemy targetted
if(!battle_check_range(&pd->bl,target,pd->db->range))
{ //Chase
- if(pd->ud.walktimer != -1 && check_distance_blxy(target, pd->ud.to_x,pd->ud.to_y, pd->db->range))
- return 0;
-
if(!unit_walktobl(&pd->bl, target, pd->db->range, 2))
- { //Unreachable target.
- pet_unlocktarget(pd);
- }
+ pet_unlocktarget(pd); //Unreachable target.
return 0;
- } //End Chase
- pet_stop_walking(pd,1);
- if (pd->ud.attacktimer != -1 && pd->ud.attacktarget == pd->target_id)
- return 0; //Already attacking.
+ }
//Continuous attack.
unit_attack(&pd->bl, pd->target_id, 1);
} else { //Item Targeted, attempt loot
if (!check_distance_bl(&pd->bl, target, 1))
{ //Out of range
- if(pd->ud.walktimer != -1 && pd->ud.walktarget == pd->target_id)
- return 0;
-
if(!unit_walktobl(&pd->bl, target, 0, 1)) //Unreachable target.
pet_unlocktarget(pd);
return 0;
- } else{ // アイテムまでたどり着いた
+ } else{
struct flooritem_data *fitem = (struct flooritem_data *)target;
- pet_stop_walking(pd,1);
if(pd->loot->count < pd->loot->max){
memcpy(&pd->loot->item[pd->loot->count++],&fitem->item_data,sizeof(pd->loot->item[0]));
pd->loot->weight += itemdb_search(fitem->item_data.nameid)->weight*fitem->item_data.amount;
|