Quellcode durchsuchen

- 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://svn.code.sf.net/p/rathena/svn/trunk@9291 54d463be-8e91-2dee-dedb-b68131a5f0ec

skotlex vor 18 Jahren
Ursprung
Commit
7f460dc646
3 geänderte Dateien mit 25 neuen und 10 gelöschten Zeilen
  1. 5 0
      Changelog-Trunk.txt
  2. 18 10
      src/map/pet.c
  3. 2 0
      src/map/status.c

+ 5 - 0
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,

+ 18 - 10
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;
 }
 

+ 2 - 0
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))
 		{