[Pets] Fix errors in sync with client of sit/stand (#4245)

* [Pets] Fix errors in sync with client of sit/stand

* Forgot bot.h
This commit is contained in:
Paul Coene 2024-04-15 05:59:36 -04:00 committed by GitHub
parent d6b5a9d343
commit 41c5369c18
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 37 additions and 19 deletions

View File

@ -4058,7 +4058,7 @@ void Mob::CommonDamage(Mob* attacker, int64 &damage, const uint16 spell_id, cons
Mob *owner = GetOwner();
if (owner && owner->IsClient()) {
if (GetPetOrder() == SPO_Sit) {
SetPetOrder(SPO_Follow);
SetPetOrder(GetPreviousPetOrder());
}
// fix GUI sit button to be unpressed and stop sitting regen
owner->CastToClient()->SetPetCommandState(PET_BUTTON_SIT, 0);
@ -4088,11 +4088,11 @@ void Mob::CommonDamage(Mob* attacker, int64 &damage, const uint16 spell_id, cons
!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 (IsClient() && !pet->IsPetStop()) {
// if pet was sitting his new mode is previous setting of
// follow or guard after the battle (live verified)
if (pet->GetPetOrder() == SPO_Sit) {
pet->SetPetOrder(SPO_Follow);
pet->SetPetOrder(pet->GetPreviousPetOrder());
}
// fix GUI sit button to be unpressed and stop sitting regen

View File

@ -893,7 +893,6 @@ private:
bool m_pulling_flag;
bool m_returning_flag;
bool is_using_item_click;
eStandingPetOrder m_previous_pet_order;
uint32 m_bot_caster_range;
BotCastingRoles m_CastingRoles;

View File

@ -11034,7 +11034,10 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app)
// fix GUI sit button to be unpressed and stop sitting regen
SetPetCommandState(PET_BUTTON_SIT, 0);
mypet->SetAppearance(eaStanding);
if (mypet->GetPetOrder() == SPO_Sit || mypet->GetPetOrder() == SPO_FeignDeath) {
mypet->SetPetOrder(mypet->GetPreviousPetOrder());
mypet->SetAppearance(eaStanding);
}
zone->AddAggroMob();
// classic acts like qattack
@ -11081,7 +11084,10 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app)
// fix GUI sit button to be unpressed and stop sitting regen
SetPetCommandState(PET_BUTTON_SIT, 0);
mypet->SetAppearance(eaStanding);
if (mypet->GetPetOrder() == SPO_Sit || mypet->GetPetOrder() == SPO_FeignDeath) {
mypet->SetPetOrder(mypet->GetPreviousPetOrder());
mypet->SetAppearance(eaStanding);
}
zone->AddAggroMob();
mypet->AddToHateList(GetTarget(), 1, 0, true, false, false, SPELL_UNKNOWN, true);
@ -11147,7 +11153,7 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app)
// Set Sit button to unpressed - send stand anim/end hpregen
mypet->SetFeigned(false);
SetPetCommandState(PET_BUTTON_SIT, 0);
mypet->SendAppearancePacket(AppearanceType::Animation, Animation::Standing);
mypet->SetAppearance(eaStanding);
mypet->SayString(this, Chat::PetResponse, PET_GUARDINGLIFE);
mypet->SetPetOrder(SPO_Guard);
@ -11172,7 +11178,7 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app)
// fix GUI sit button to be unpressed - send stand anim/end hpregen
SetPetCommandState(PET_BUTTON_SIT, 0);
mypet->SendAppearancePacket(AppearanceType::Animation, Animation::Standing);
mypet->SetAppearance(eaStanding);
if (mypet->IsPetStop()) {
mypet->SetPetStop(false);
@ -11220,7 +11226,7 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app)
// Set Sit button to unpressed - send stand anim/end hpregen
SetPetCommandState(PET_BUTTON_SIT, 0);
mypet->SendAppearancePacket(AppearanceType::Animation, Animation::Standing);
mypet->SetAppearance(eaStanding);
if (mypet->IsPetStop()) {
mypet->SetPetStop(false);
@ -11237,8 +11243,8 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app)
{
mypet->SetFeigned(false);
mypet->SayString(this, Chat::PetResponse, PET_SIT_STRING);
mypet->SetPetOrder(SPO_Follow);
mypet->SendAppearancePacket(AppearanceType::Animation, Animation::Standing);
mypet->SetPetOrder(mypet->GetPreviousPetOrder());
mypet->SetAppearance(eaStanding);
}
else
{
@ -11248,7 +11254,7 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app)
mypet->SetRunAnimSpeed(0);
if (!mypet->UseBardSpellLogic()) //maybe we can have a bard pet
mypet->InterruptSpell(); //No cast 4 u. //i guess the pet should start casting
mypet->SendAppearancePacket(AppearanceType::Animation, Animation::Sitting);
mypet->SetAppearance(eaSitting);
}
}
break;
@ -11260,8 +11266,8 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app)
mypet->SetFeigned(false);
mypet->SayString(this, Chat::PetResponse, PET_SIT_STRING);
SetPetCommandState(PET_BUTTON_SIT, 0);
mypet->SetPetOrder(SPO_Follow);
mypet->SendAppearancePacket(AppearanceType::Animation, Animation::Standing);
mypet->SetPetOrder(mypet->GetPreviousPetOrder());
mypet->SetAppearance(eaStanding);
}
break;
}
@ -11276,7 +11282,7 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app)
mypet->SetRunAnimSpeed(0);
if (!mypet->UseBardSpellLogic()) //maybe we can have a bard pet
mypet->InterruptSpell(); //No cast 4 u. //i guess the pet should start casting
mypet->SendAppearancePacket(AppearanceType::Animation, Animation::Sitting);
mypet->SetAppearance(eaSitting);
}
break;
}
@ -11481,7 +11487,7 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app)
mypet->SetPetOrder(SPO_FeignDeath);
mypet->SetRunAnimSpeed(0);
mypet->StopNavigation();
mypet->SendAppearancePacket(AppearanceType::Animation, Animation::Lying);
mypet->SetAppearance(eaDead);
mypet->SetFeigned(true);
mypet->SetTarget(nullptr);
if (!mypet->UseBardSpellLogic()) {

View File

@ -442,6 +442,7 @@ Mob::Mob(
weaponstance.aabonus_buff_spell_id = 0;
pStandingPetOrder = SPO_Follow;
m_previous_pet_order = SPO_Follow;
pseudo_rooted = false;
nobuff_invisible = 0;
@ -635,6 +636,16 @@ void Mob::CalcInvisibleLevel()
BreakCharmPetIfConditionsMet();
}
void Mob::SetPetOrder(eStandingPetOrder i) {
if (i == SPO_Sit || i == SPO_FeignDeath) {
if (pStandingPetOrder == SPO_Follow || pStandingPetOrder == SPO_Guard) {
m_previous_pet_order = pStandingPetOrder;
}
}
pStandingPetOrder = i;
}
void Mob::SetInvisible(uint8 state, bool set_on_bonus_calc) {
if (state == Invisibility::Visible) {
SendAppearancePacket(AppearanceType::Invisibility, Invisibility::Visible);

View File

@ -589,6 +589,7 @@ public:
inline const char* GetName() const { return name; }
inline const char* GetOrigName() const { return orig_name; }
inline const char* GetLastName() const { return lastname; }
inline const eStandingPetOrder GetPreviousPetOrder() const { return m_previous_pet_order; }
const char *GetCleanName();
virtual void SetName(const char *new_name = nullptr) { new_name ? strn0cpy(name, new_name, 64) :
strn0cpy(name, GetName(), 64); return; };
@ -1179,7 +1180,7 @@ public:
inline const float GetAssistRange() const { return (spellbonuses.AssistRange == -1) ? pAssistRange : spellbonuses.AssistRange; }
inline void SetPetOrder(eStandingPetOrder i) { pStandingPetOrder = i; }
void SetPetOrder(eStandingPetOrder i);
inline const eStandingPetOrder GetPetOrder() const { return pStandingPetOrder; }
inline void SetHeld(bool nState) { held = nState; }
inline const bool IsHeld() const { return held; }
@ -1773,6 +1774,7 @@ protected:
// MobAI stuff
eStandingPetOrder pStandingPetOrder;
eStandingPetOrder m_previous_pet_order;
uint32 minLastFightingDelayMoving;
uint32 maxLastFightingDelayMoving;
float pAggroRange = 0;