[Spells] Swarm pet aggro logic fix (#1956)

* temp commit

* swarm pet logic fix

* [Spells] Swarm pet aggro logic fix
This commit is contained in:
KayenEQ 2022-02-03 22:00:52 -05:00 committed by GitHub
parent 4e297f3d96
commit cc0371c16e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 6 deletions

View File

@ -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);

View File

@ -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)
{

View File

@ -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);

View File

@ -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());