You can clone with
HTTPS or Subversion.
TC Rev: 7-28-2012 (41da3fe)
I have 2 people in my group. I am a warlock with a voidwalker. If the voidwalker and the other member in the group are attacking the same target and the other member in the group kills the target, the voidwalker will stay and not return to me, even though he has the follow command activated. This is repeatable. if the voidwalker or myself kills the target, the voidwalker returns to me, if the other group member kills the target, the voidwalker stays next to the dead target and I have to click on the follow command to get the voidwalker following me again.
Voidwalker is set to passive and follow.
I'm looking into this. I've had a conversation with the OP and it appears it may not be related to the AI but rather to the movement code. The rev. in question modified Movement::MoveSplineInit() which may have adversely effected the pet reaction.
Looking in PetAI::KilledUnit() there is nothing that checks what killed the target so it shouldn't matter wether it was the owner, pet or a 3rd party.
I think Pet::KilledUnit() is only called when the Hunter or the Pet get the killing blow on the target.
Pet::KilledUnit() is called from Unit::Kill() regardless of who killed the creature. I think the problem is that the notification isn't broadcast to everyone involved in the fight, only the killer and his / her pet.
Perhaps it would be better if I implemented the CreatureAI::JustDied() instead.
Ok, I've got a potential fix in the works for this which in the long run is rather simple.
I'm going to post a patch and request some testers to try group related things that I can't do since I'm the only one on my server. If all goes well I'll submit the pull request.
Here's a patch that I need some help testing. If all goes well I will submit a pull request...
(patch based on revision 53bc7c2)
I need people to have a player / pet other than themselves to kill the target and see if the pet stays stuck where it was or if it behaves properly and returns / picks a new target. Try this in a group and out of a group.
Please post your results back here, thanks.
I have tested this patch with another player. I had that player not in my group and also in my group. Either way, if that player killed the target, while my pet was attacking the same target, my pet stays next to the now dead target and does not return to me.
I started playing around with the code and if i comment out these lines:
if (!me->GetCharmInfo()->IsFollowing() && !me->GetCharmInfo()->IsReturning())
// if (!me->GetCharmInfo()->IsCommandAttack())
me->GetMotionMaster()->MoveFollow(me->GetCharmerOrOwner(), PET_FOLLOW_DIST, me->GetFollowAngle());
Everything seems to work as it should (I am still testing different scenarios though). Any idea why that would seem to fix the problem?
I have an idea how to fix it.
The fix you posted will cause additional problems because you don't want the pet returning while it's chasing something after you click the attack button. Without that flag check, the AI has a tendency to send the pet back because of the target not being set until the first melee hit.
What you've described though is when the pet's target dies due to another player / pet, it isn't clearing the attack flag. That should be an easy fix.
Actually, now that I look at it, it looks like the pet's target is now set before the first melee hit so that IsCommandAttack() might not be necessary anymore.
In the past, the pet's target wasn't set until it acutally hit something so that check was needed so when you clicked attack it would follow through to chase the target.
Let me know if removing that check has any adverse effects. If not, I'll write up a patch that removes that flag completely. What you want to look for is:
1. A pet behaving wrong when you click the attack button. Does it actually chase it's target or does it come back
2. When a target flees does the pet chase it or come back to the owner
3. When a target dies does the pet select a new one (if multiple) or come back right away
The pet should chase until it is called back since the AI doesn't handle Evade properly.
In the past when you clicked "Attack" the pet would run forward a few yards and come back. This was because in PetAI::Update() there was no target since the pet hadn't hit anything so me->GetVictim() would fail causing the player to have to spam "attack" to get anywhere. That is why the IsCommandAttack() check exists.
It appears though that things have been rewritten on the Unit side so the target is set at the attack command rather than first contact. I just want you to make sure that the pet doesn't require the "attack" spam by removing the check.
Another question on this. When pet is set to aggressive and there are multiple targets within range, what is the AI of the pet in this scenario, or what happens on official?
Is it supposed to attack a target, come back to owner, then go and attack another target, or is it supposed to move from target to target killing them, then moving back to owner only when all targets within range are killed?
Can you give the revision you're having problems with? I can't reproduce the problem.
I replied to your PM but for everyone else: Yes, an aggressive pet should continue to attack targets within range and only return to the owner when its threat list is empty or the owner changes it's state / tells it to return.
Cleanup PetAI, remove unnecessary and broken JustDied(). Closes #7242
Thanks to Oiler2112 for suggestions and testing.
Just for future reference and to keep the GIT commit comment short:
In order for JustDied() to work properly, the mob that dies needs to call PetAI::JustDied() for every pet in its threat list.
I didn't feel this would be a viable method because if (for example) you had a 40 man raid, you would need to iterate through all 40 players looking for pets. Imagine doing that on "trash" packs who die quickly to AOE. Then multiply that by the number of raids open on the server who might also be quickly killing mobs.
I felt for now, this would be an unnecessary burden on CPU cycles when the AI::Update() function can check for a dead target and switch accordingly.