diff --git a/zone/attack.cpp b/zone/attack.cpp index 122f43d31..fee227e7c 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -2869,7 +2869,7 @@ void Mob::AddToHateList(Mob* other, uint32 hate /*= 0*/, int32 damage /*= 0*/, b } } //MERC - // then add pet owner if there's one + //if I am a pet, then add pet owner if there's one if (owner) { // Other is a pet, add him and it // EverHood 6/12/06 // Can't add a feigned owner to hate list @@ -2884,8 +2884,9 @@ void Mob::AddToHateList(Mob* other, uint32 hate /*= 0*/, int32 damage /*= 0*/, b !(this->GetSpecialAbility(IMMUNE_AGGRO_CLIENT) && owner->IsClient()) && !(this->GetSpecialAbility(IMMUNE_AGGRO_NPC) && owner->IsNPC()) ) { - if (owner->IsClient() && !CheckAggro(owner)) + if (owner->IsClient() && !CheckAggro(owner)) { owner->CastToClient()->AddAutoXTarget(this); + } hate_list.AddEntToHateList(owner, 0, 0, false, !iBuffTic); } } @@ -2912,8 +2913,9 @@ void Mob::AddToHateList(Mob* other, uint32 hate /*= 0*/, int32 damage /*= 0*/, b } } - if (other->GetTempPetCount()) { - entity_list.AddTempPetsToHateList(other, this, bFrenzy); + //I have a swarm pet, add other to it. + if (GetTempPetCount()) { + entity_list.AddTempPetsToHateList(this, other, bFrenzy); } if (!wasengaged) { @@ -3697,6 +3699,10 @@ void Mob::CommonDamage(Mob* attacker, int &damage, const uint16 spell_id, const } } + if (GetTempPetCount()) { + entity_list.AddTempPetsToHateListOnOwnerDamage(this, attacker, spell_id); + } + //see if any runes want to reduce this damage if (spell_id == SPELL_UNKNOWN) { damage = ReduceDamage(damage); diff --git a/zone/entity.cpp b/zone/entity.cpp index a5f3f96ae..860331ef0 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -4208,7 +4208,7 @@ void EntityList::AddTempPetsToHateList(Mob *owner, Mob* other, bool bFrenzy) auto it = npc_list.begin(); while (it != npc_list.end()) { NPC* n = it->second; - if (n->GetSwarmInfo()) { + if (n && n->GetSwarmInfo()) { if (n->GetSwarmInfo()->owner_id == owner->GetID()) { if ( !n->GetSpecialAbility(IMMUNE_AGGRO) && @@ -4223,6 +4223,35 @@ void EntityList::AddTempPetsToHateList(Mob *owner, Mob* other, bool bFrenzy) } } +void EntityList::AddTempPetsToHateListOnOwnerDamage(Mob *owner, Mob* attacker, int32 spell_id) +{ + if (!attacker || !owner) + return; + + auto it = npc_list.begin(); + while (it != npc_list.end()) { + NPC* n = it->second; + if (n && n->GetSwarmInfo()) { + if (n->GetSwarmInfo()->owner_id == owner->GetID()) { + if ( + attacker && + attacker != n && + !n->IsEngaged() && + !n->GetSpecialAbility(IMMUNE_AGGRO) && + !(n->GetSpecialAbility(IMMUNE_AGGRO_CLIENT) && attacker->IsClient()) && + !(n->GetSpecialAbility(IMMUNE_AGGRO_NPC) && attacker->IsNPC()) && + !attacker->IsTrap() && + !attacker->IsCorpse() + ) { + n->AddToHateList(attacker, 1, 0, true, false, false, spell_id); + n->SetTarget(attacker); + } + } + } + ++it; + } +} + bool Entity::CheckCoordLosNoZLeaps(float cur_x, float cur_y, float cur_z, float trg_x, float trg_y, float trg_z, float perwalk) { diff --git a/zone/entity.h b/zone/entity.h index 4edc63b0d..54a5a2fff 100644 --- a/zone/entity.h +++ b/zone/entity.h @@ -315,6 +315,7 @@ public: void DestroyTempPets(Mob *owner); int16 CountTempPets(Mob *owner); void AddTempPetsToHateList(Mob *owner, Mob* other, bool bFrenzy = false); + void AddTempPetsToHateListOnOwnerDamage(Mob *owner, Mob* attacker, int32 spell_id); Entity *GetEntityMob(uint16 id); Entity *GetEntityMerc(uint16 id); Entity *GetEntityDoor(uint16 id); diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 1d7d9c317..491115d3c 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -1349,7 +1349,7 @@ void Mob::AI_Process() { } // mob/npc waits until call for help complete, others can move else if (AI_movement_timer->Check() && target && - (GetOwnerID() || IsBot() || + (GetOwnerID() || IsBot() || IsTempPet() || CastToNPC()->GetCombatEvent())) { if (!IsRooted()) { LogAI("Pursuing [{}] while engaged", target->GetName());