From 8cd6008ba67ce0c3c9068b644705c2f65b81123d Mon Sep 17 00:00:00 2001 From: Emagi Date: Sat, 31 May 2025 10:22:34 -0400 Subject: [PATCH] Fix #20 Pet back off now immediate, attacks despite pet behavior of protection --- source/WorldServer/Combat.cpp | 4 ++-- source/WorldServer/Commands/Commands.cpp | 20 ++++++++++++++++---- source/WorldServer/Entity.h | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/source/WorldServer/Combat.cpp b/source/WorldServer/Combat.cpp index 0380e93..7e6bc9b 100644 --- a/source/WorldServer/Combat.cpp +++ b/source/WorldServer/Combat.cpp @@ -1324,7 +1324,7 @@ float Entity::CalculateMitigation(int8 type, int8 damage_type, int16 effective_l return mit_percentage; } -void Entity::AddHate(Entity* attacker, sint32 hate) { +void Entity::AddHate(Entity* attacker, sint32 hate, bool ignore_pet_behavior) { if(!attacker || GetHP() <= 0 || attacker->GetHP() <= 0) return; @@ -1332,7 +1332,7 @@ void Entity::AddHate(Entity* attacker, sint32 hate) { return; // can't aggro your own members // If a players pet and protect self is off - if (IsPet() && ((NPC*)this)->GetOwner() && ((NPC*)this)->GetOwner()->IsPlayer() && ((((Player*)((NPC*)this)->GetOwner())->GetInfoStruct()->get_pet_behavior() & 2) == 0)) + if (!ignore_pet_behavior && IsPet() && ((NPC*)this)->GetOwner() && ((NPC*)this)->GetOwner()->IsPlayer() && ((((Player*)((NPC*)this)->GetOwner())->GetInfoStruct()->get_pet_behavior() & 2) == 0)) return; hate = attacker->CalculateHateAmount(this, hate); diff --git a/source/WorldServer/Commands/Commands.cpp b/source/WorldServer/Commands/Commands.cpp index 671d9fc..0808451 100644 --- a/source/WorldServer/Commands/Commands.cpp +++ b/source/WorldServer/Commands/Commands.cpp @@ -8445,10 +8445,22 @@ void Commands::Command_Pet(Client* client, Seperator* sep) } else if (strcmp(sep->arg[0], "backoff") == 0) { client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to back down."); - if (client->GetPlayer()->GetPet()) + if (client->GetPlayer()->GetPet()) { ((NPC*)client->GetPlayer()->GetPet())->Brain()->ClearHate(); - if (client->GetPlayer()->GetCharmedPet()) + + client->GetPlayer()->GetPet()->SetFollowTarget(nullptr); + client->GetPlayer()->GetZone()->movementMgr->StopNavigation(client->GetPlayer()->GetPet()); + client->GetPlayer()->GetPet()->ClearRunningLocations(); + client->GetPlayer()->GetPet()->StopMovement(); + } + if (client->GetPlayer()->GetCharmedPet()) { ((NPC*)client->GetPlayer()->GetCharmedPet())->Brain()->ClearHate(); + + client->GetPlayer()->GetCharmedPet()->SetFollowTarget(nullptr); + client->GetPlayer()->GetZone()->movementMgr->StopNavigation(client->GetPlayer()->GetCharmedPet()); + client->GetPlayer()->GetCharmedPet()->ClearRunningLocations(); + client->GetPlayer()->GetCharmedPet()->StopMovement(); + } client->GetPlayer()->GetInfoStruct()->set_pet_behavior(0); client->GetPlayer()->SetCharSheetChanged(true); } @@ -8457,9 +8469,9 @@ void Commands::Command_Pet(Client* client, Seperator* sep) if (client->GetPlayer()->AttackAllowed((Entity*)client->GetPlayer()->GetTarget())){ client->Message(CHANNEL_COLOR_YELLOW, "You command your pet to attack your target."); if (client->GetPlayer()->GetPet()) - client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1); + client->GetPlayer()->GetPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1, true); if (client->GetPlayer()->GetCharmedPet()) - client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1); + client->GetPlayer()->GetCharmedPet()->AddHate((Entity*)client->GetPlayer()->GetTarget(), 1, true); } else client->Message(CHANNEL_COLOR_YELLOW, "You can not attack that."); diff --git a/source/WorldServer/Entity.h b/source/WorldServer/Entity.h index d66552c..61a6ef6 100644 --- a/source/WorldServer/Entity.h +++ b/source/WorldServer/Entity.h @@ -1544,7 +1544,7 @@ public: Skill* GetSkillByWeaponType(int8 type, int8 damage_type, bool update); bool DamageSpawn(Entity* victim, int8 type, int8 damage_type, int32 low_damage, int32 high_damage, const char* spell_name, int8 crit_mod = 0, bool is_tick = false, bool no_damage_calcs = false, bool ignore_attacker = false, bool take_power = false, LuaSpell* spell = 0); float CalculateMitigation(int8 type = DAMAGE_PACKET_TYPE_SIMPLE_DAMAGE, int8 damage_type = 0, int16 attacker_level = 0, bool for_pvp = false); - void AddHate(Entity* attacker, sint32 hate); + void AddHate(Entity* attacker, sint32 hate, bool ignore_pet_behavior = false); bool CheckInterruptSpell(Entity* attacker); bool CheckFizzleSpell(LuaSpell* spell); void KillSpawn(Spawn* dead, int8 type = 0, int8 damage_type = 0, int16 kill_blow_type = 0);