summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-11-22 05:04:16 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-11-22 05:04:16 +0000
commitb2acf4c0b0eaeb9415bc5d82fb2df8253b599325 (patch)
tree1053c03e14e2cbd8f3d4639a9bcf2a0f137df796
parentd22ee8c44edd2ae3574cc818536ef096e9413b98 (diff)
downloadhercules-b2acf4c0b0eaeb9415bc5d82fb2df8253b599325.tar.gz
hercules-b2acf4c0b0eaeb9415bc5d82fb2df8253b599325.tar.bz2
hercules-b2acf4c0b0eaeb9415bc5d82fb2df8253b599325.tar.xz
hercules-b2acf4c0b0eaeb9415bc5d82fb2df8253b599325.zip
- Fixed the Auto-Berserk giving you back defense when it triggers during berserk's HP penalty.
- Some small changes in the pet ai to make it more responsive. - Rewrote the pet looting behaviour (taken from the mob's), pets are much more smarter now when looting from multiple possible items. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9291 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--Changelog-Trunk.txt5
-rw-r--r--src/map/pet.c28
-rw-r--r--src/map/status.c2
3 files changed, 25 insertions, 10 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index bac0dffd0..c7a0eb072 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -4,6 +4,11 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2006/11/21
+ * Fixed the Auto-Berserk giving you back defense when it triggers during
+ berserk's HP penalty. [Skotlex]
+ * Some small changes in the pet ai to make it more responsive. [Skotlex]
+ * Rewrote the pet looting behaviour (taken from the mob's), pets are much
+ more smarter now when looting from multiple possible items. [Skotlex]
* Fixed pets/homunc trying to be deleted twice when they had 0 intimacy and
their master logs out. [Skotlex]
* Added support for specifying ammo type = 99 in the skill_require_db file,
diff --git a/src/map/pet.c b/src/map/pet.c
index 12731cb34..836c9fa97 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -895,7 +895,7 @@ static int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, uns
if(pd->ud.attacktimer != -1 || pd->ud.skilltimer != -1 || pd->bl.m != sd->bl.m)
return 0;
- if(pd->ud.walktimer != -1 && pd->ud.walkpath.path_pos <= 3)
+ if(pd->ud.walktimer != -1 && pd->ud.walkpath.path_pos <= 2)
return 0; //No thinking when you just started to walk.
if(pd->pet.intimate <= 0) {
@@ -904,7 +904,7 @@ static int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, uns
return 0;
}
- if (!check_distance_bl(&sd->bl, &pd->bl, pd->db->range2)) {
+ if (!check_distance_bl(&sd->bl, &pd->bl, pd->db->range3)) {
//Master too far, chase.
if(pd->target_id)
pet_unlocktarget(pd);
@@ -939,10 +939,10 @@ static int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, uns
if(!target && pd->loot && pd->loot->count < pd->loot->max && DIFF_TICK(tick,pd->ud.canact_tick)>0) {
//Use half the pet's range of sight.
- int itc=0;
map_foreachinrange(pet_ai_sub_hard_lootsearch,&pd->bl,
- pd->db->range2/2, BL_ITEM,pd,&itc);
+ pd->db->range2/2, BL_ITEM,pd,&target);
}
+
if (!target) {
//Just walk around.
if (check_distance_bl(&sd->bl, &pd->bl, 3))
@@ -1012,18 +1012,26 @@ static int pet_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap)
{
struct pet_data* pd;
struct flooritem_data *fitem = (struct flooritem_data *)bl;
+ struct block_list **target;
int sd_id =0;
- int *itc;
pd=va_arg(ap,struct pet_data *);
- itc=va_arg(ap,int *);
+ target=va_arg(ap,struct block_list**);
sd_id = fitem->first_get_id;
- if(bl->m == pd->bl.m && (!sd_id || sd_id == pd->msd->bl.id) &&
- unit_can_reach_bl(&pd->bl,bl, pd->db->range2, 1, NULL, NULL) &&
- rand()%1000<1000/(++(*itc)))
- pd->target_id=bl->id;
+ if(sd_id && sd_id != pd->msd->bl.id)
+ return 0;
+
+ if(unit_can_reach_bl(&pd->bl,bl, pd->db->range2, 1, NULL, NULL) &&
+ ((*target) == NULL || //New target closer than previous one.
+ !check_distance_bl(&pd->bl, *target, distance_bl(&pd->bl, bl))))
+ {
+ (*target) = bl;
+ pd->target_id = bl->id;
+ return 1;
+ }
+
return 0;
}
diff --git a/src/map/status.c b/src/map/status.c
index ebab67eb1..dcc1f9e1d 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -6666,6 +6666,8 @@ int status_change_timer(int tid, unsigned int tick, int id, int data)
break;
case SC_BERSERK:
+ //The damage below should be made aware that Berserk is active.
+ sc->data[type].timer = temp_timerid;
// 5% every 10 seconds [DracoRPG]
if((--sc->data[type].val3)>0 && status_charge(bl, sc->data[type].val2, 0))
{