From 29f7bc7a9c60aee06d5d871addda69dc72681279 Mon Sep 17 00:00:00 2001 From: Noudess Date: Mon, 31 Aug 2020 13:39:42 -0400 Subject: [PATCH] Fix bugged pet window sit button and pet sit based regen. --- zone/attack.cpp | 28 ++++++++++++++++++++++++++++ zone/client_packet.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/zone/attack.cpp b/zone/attack.cpp index 86c326e53..951d922ed 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -3445,6 +3445,22 @@ void Mob::CommonDamage(Mob* attacker, int &damage, const uint16 spell_id, const // emote goes with every one ... even npcs entity_list.MessageClose(this, true, RuleI(Range, SpellMessages), Chat::Emote, "%s beams a smile at %s", attacker->GetCleanName(), this->GetCleanName()); } + + // If a client pet is damaged while sitting, stand, fix sit button, + // and remove sitting regen. Removes bug where client clicks sit + // during battle and gains pet hp-regen and bugs the sit button. + if (IsPet()) { + Mob *owner = this->GetOwner(); + if (owner && owner->IsClient()) { + if (GetPetOrder() == SPO_Sit) { + SetPetOrder(SPO_Follow); + } + // fix GUI sit button to be unpressed and stop sitting regen + owner->CastToClient()->SetPetCommandState(PET_BUTTON_SIT, 0); + SetAppearance(eaStanding); + } + } + } //end `if there is some damage being done and theres anattacker person involved` Mob *pet = GetPet(); @@ -3455,6 +3471,18 @@ void Mob::CommonDamage(Mob* attacker, int &damage, const uint16 spell_id, const { if (!pet->IsHeld()) { LogAggro("Sending pet [{}] into battle due to attack", pet->GetName()); + if (IsClient()) { + // if pet was sitting his new mode is follow + // following after the battle (live verified) + if (pet->GetPetOrder() == SPO_Sit) { + pet->SetPetOrder(SPO_Follow); + } + + // fix GUI sit button to be unpressed and stop sitting regen + this->CastToClient()->SetPetCommandState(PET_BUTTON_SIT, 0); + pet->SetAppearance(eaStanding); + } + pet->AddToHateList(attacker, 1, 0, true, false, false, spell_id); pet->SetTarget(attacker); MessageString(Chat::NPCQuestSay, PET_ATTACKING, pet->GetCleanName(), attacker->GetCleanName()); diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 47066a5aa..33a47c3a4 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -10069,6 +10069,11 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) mypet->SetPetRegroup(false); SetPetCommandState(PET_BUTTON_REGROUP, 0); } + + // fix GUI sit button to be unpressed and stop sitting regen + SetPetCommandState(PET_BUTTON_SIT, 0); + mypet->SetAppearance(eaStanding); + zone->AddAggroMob(); // classic acts like qattack int hate = 1; @@ -10110,6 +10115,11 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) mypet->SetPetRegroup(false); SetPetCommandState(PET_BUTTON_REGROUP, 0); } + + // fix GUI sit button to be unpressed and stop sitting regen + SetPetCommandState(PET_BUTTON_SIT, 0); + mypet->SetAppearance(eaStanding); + zone->AddAggroMob(); mypet->AddToHateList(GetTarget(), 1, 0, true, false, false, SPELL_UNKNOWN, true); MessageString(Chat::PetResponse, PET_ATTACKING, mypet->GetCleanName(), GetTarget()->GetCleanName()); @@ -10170,6 +10180,11 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) if ((mypet->GetPetType() == petAnimation && aabonuses.PetCommands[PetCommand]) || mypet->GetPetType() != petAnimation) { if (mypet->IsNPC()) { + + // Set Sit button to unpressed - send stand anim/end hpregen + SetPetCommandState(PET_BUTTON_SIT, 0); + mypet->SendAppearancePacket(AT_Anim, ANIM_STAND); + mypet->SayString(this, Chat::PetResponse, PET_GUARDINGLIFE); mypet->SetPetOrder(SPO_Guard); mypet->CastToNPC()->SaveGuardSpot(mypet->GetPosition()); @@ -10189,7 +10204,11 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) if ((mypet->GetPetType() == petAnimation && aabonuses.PetCommands[PetCommand]) || mypet->GetPetType() != petAnimation) { mypet->SayString(this, Chat::PetResponse, PET_FOLLOWING); mypet->SetPetOrder(SPO_Follow); + + // fix GUI sit button to be unpressed - send stand anim/end hpregen + SetPetCommandState(PET_BUTTON_SIT, 0); mypet->SendAppearancePacket(AT_Anim, ANIM_STAND); + if (mypet->IsPetStop()) { mypet->SetPetStop(false); SetPetCommandState(PET_BUTTON_STOP, 0); @@ -10232,7 +10251,11 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) if ((mypet->GetPetType() == petAnimation && aabonuses.PetCommands[PetCommand]) || mypet->GetPetType() != petAnimation) { mypet->SayString(this, Chat::PetResponse, PET_GUARDME_STRING); mypet->SetPetOrder(SPO_Follow); + + // Set Sit button to unpressed - send stand anim/end hpregen + SetPetCommandState(PET_BUTTON_SIT, 0); mypet->SendAppearancePacket(AT_Anim, ANIM_STAND); + if (mypet->IsPetStop()) { mypet->SetPetStop(false); SetPetCommandState(PET_BUTTON_STOP, 0); @@ -10267,6 +10290,7 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) if ((mypet->GetPetType() == petAnimation && aabonuses.PetCommands[PetCommand]) || mypet->GetPetType() != petAnimation) { mypet->SayString(this, Chat::PetResponse, PET_SIT_STRING); + SetPetCommandState(PET_BUTTON_SIT, 0); mypet->SetPetOrder(SPO_Follow); mypet->SendAppearancePacket(AT_Anim, ANIM_STAND); } @@ -10277,6 +10301,7 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) if ((mypet->GetPetType() == petAnimation && aabonuses.PetCommands[PetCommand]) || mypet->GetPetType() != petAnimation) { mypet->SayString(this, Chat::PetResponse, PET_SIT_STRING); + SetPetCommandState(PET_BUTTON_SIT, 1); mypet->SetPetOrder(SPO_Sit); mypet->SetRunAnimSpeed(0); if (!mypet->UseBardSpellLogic()) //maybe we can have a bard pet