From d6b61b91638d80bb49987c78aee3466ea5062802 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Thu, 4 May 2017 23:48:47 -0400 Subject: [PATCH] Implement pet regroup Tweaks to stop as well --- zone/attack.cpp | 5 +--- zone/client_packet.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++ zone/common.h | 6 ++--- zone/mob.cpp | 1 + zone/mob.h | 3 +++ zone/mob_ai.cpp | 6 +++-- zone/string_ids.h | 2 ++ 7 files changed, 72 insertions(+), 9 deletions(-) diff --git a/zone/attack.cpp b/zone/attack.cpp index 7ffbc07bf..144578561 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -2516,9 +2516,6 @@ void Mob::AddToHateList(Mob* other, uint32 hate /*= 0*/, int32 damage /*= 0*/, b } } - if (IsPetStop()) - return; - // Pet that is /pet hold on will not add to their hate list if they're not engaged // Pet that is /pet hold on and /pet focus on will not add others to their hate list // Pet that is /pet ghold on will never add to their hate list unless /pet attack or /pet qattack @@ -2528,7 +2525,7 @@ void Mob::AddToHateList(Mob* other, uint32 hate /*= 0*/, int32 damage /*= 0*/, b if (IsPet()) { if ((IsGHeld() || (IsHeld() && IsFocused())) && !on_hatelist) // we want them to be able to climb the hate list return; - if (IsHeld() && !wasengaged) + if ((IsHeld() || IsPetStop() || IsPetRegroup()) && !wasengaged) // not 100% sure on stop/regroup kind of hard to test, but regroup is like "classic hold" return; } } diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 15c5e8301..090f92816 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -10017,6 +10017,10 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) mypet->SetPetStop(false); SetPetCommandState(PET_BUTTON_STOP, 0); } + if (mypet->IsPetRegroup()) { + mypet->SetPetRegroup(false); + SetPetCommandState(PET_BUTTON_REGROUP, 0); + } zone->AddAggroMob(); // classic acts like qattack int hate = 1; @@ -10054,6 +10058,10 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) mypet->SetPetStop(false); SetPetCommandState(PET_BUTTON_STOP, 0); } + if (mypet->IsPetRegroup()) { + mypet->SetPetRegroup(false); + SetPetCommandState(PET_BUTTON_REGROUP, 0); + } zone->AddAggroMob(); mypet->AddToHateList(GetTarget(), 1, 0, true, false, false, SPELL_UNKNOWN, true); Message_StringID(MT_PetResponse, PET_ATTACKING, mypet->GetCleanName(), GetTarget()->GetCleanName()); @@ -10422,6 +10430,10 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) mypet->SetPetStop(true); mypet->SetCurrentSpeed(0); mypet->SetTarget(nullptr); + if (mypet->IsPetRegroup()) { + mypet->SetPetRegroup(false); + SetPetCommandState(PET_BUTTON_REGROUP, 0); + } } mypet->Say_StringID(MT_PetResponse, PET_GETLOST_STRING); } @@ -10435,6 +10447,10 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) mypet->SetCurrentSpeed(0); mypet->SetTarget(nullptr); mypet->Say_StringID(MT_PetResponse, PET_GETLOST_STRING); + if (mypet->IsPetRegroup()) { + mypet->SetPetRegroup(false); + SetPetCommandState(PET_BUTTON_REGROUP, 0); + } } break; } @@ -10447,6 +10463,48 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) } break; } + case PET_REGROUP: { + if (mypet->IsFeared()) break; //could be exploited like PET_BACKOFF + + if (aabonuses.PetCommands[PetCommand]) { + if (mypet->IsPetRegroup()) { + mypet->SetPetRegroup(false); + mypet->Say_StringID(MT_PetResponse, PET_OFF_REGROUPING); + } else { + mypet->SetPetRegroup(true); + mypet->SetTarget(nullptr); + mypet->Say_StringID(MT_PetResponse, PET_ON_REGROUPING); + if (mypet->IsPetStop()) { + mypet->SetPetStop(false); + SetPetCommandState(PET_BUTTON_STOP, 0); + } + } + } + break; + } + case PET_REGROUP_ON: { + if (mypet->IsFeared()) break; //could be exploited like PET_BACKOFF + + if (aabonuses.PetCommands[PetCommand]) { + mypet->SetPetRegroup(true); + mypet->SetTarget(nullptr); + mypet->Say_StringID(MT_PetResponse, PET_ON_REGROUPING); + if (mypet->IsPetStop()) { + mypet->SetPetStop(false); + SetPetCommandState(PET_BUTTON_STOP, 0); + } + } + break; + } + case PET_REGROUP_OFF: { + if (mypet->IsFeared()) break; //could be exploited like PET_BACKOFF + + if (aabonuses.PetCommands[PetCommand]) { + mypet->SetPetRegroup(false); + mypet->Say_StringID(MT_PetResponse, PET_OFF_REGROUPING); + } + break; + } default: printf("Client attempted to use a unknown pet command:\n"); break; diff --git a/zone/common.h b/zone/common.h index dad32925e..7b63174d4 100644 --- a/zone/common.h +++ b/zone/common.h @@ -89,9 +89,9 @@ #define PET_GETLOST 29 // 0x1d - /pet get lost #define PET_GUARDME 30 // 0x1e - Same as /pet follow, but different message in older clients - define not from client /pet target in modern clients but doesn't send packet #define PET_REGROUP 31 // 0x1f - /pet regroup, acts like classic hold. Stops attack and moves back to guard/you but doesn't clear hate list -#define PET_REGROUPON 32 // 0x20 - /pet regroup on, turns on regroup -#define PET_REGROUPOFF 33 // 0x21 - /pet regroup off, turns off regroup -#define PET_MAXCOMMANDS PET_REGROUPOFF + 1 +#define PET_REGROUP_ON 32 // 0x20 - /pet regroup on, turns on regroup +#define PET_REGROUP_OFF 33 // 0x21 - /pet regroup off, turns off regroup +#define PET_MAXCOMMANDS PET_REGROUP_OFF + 1 // can change the state of these buttons with a packet #define PET_BUTTON_SIT 0 diff --git a/zone/mob.cpp b/zone/mob.cpp index 7f1adedc3..b9cb0ddaf 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -348,6 +348,7 @@ Mob::Mob(const char* in_name, nocast = false; focused = false; pet_stop = false; + pet_regroup = false; _IsTempPet = false; pet_owner_client = false; pet_targetlock_id = 0; diff --git a/zone/mob.h b/zone/mob.h index 53a890132..cd17067d6 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -877,6 +877,8 @@ public: inline const bool IsFocused() const { return focused; } inline void SetPetStop(bool nState) { pet_stop = nState; } inline const bool IsPetStop() const { return pet_stop; } + inline void SetPetRegroup(bool nState) { pet_regroup = nState; } + inline const bool IsPetRegroup() const { return pet_regroup; } inline const bool IsRoamer() const { return roamer; } inline const int GetWanderType() const { return wandertype; } inline const bool IsRooted() const { return rooted || permarooted; } @@ -1187,6 +1189,7 @@ protected: bool nocast; bool focused; bool pet_stop; + bool pet_regroup; bool spawned; void CalcSpellBonuses(StatBonuses* newbon); virtual void CalcBonuses(); diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 47cd0b1d4..fd0ec5d81 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -935,7 +935,7 @@ void Mob::AI_Process() { bool engaged = IsEngaged(); bool doranged = false; - if (!zone->CanDoCombat() || IsPetStop()) { + if (!zone->CanDoCombat() || IsPetStop() || IsPetRegroup()) { engaged = false; } @@ -943,7 +943,7 @@ void Mob::AI_Process() { // if(RuleB(Combat, EnableFearPathing)){ if(currently_fleeing) { - if((IsRooted() || (IsBlind() && CombatRange(hate_list.GetClosestEntOnHateList(this)))) && !IsPetStop()) { + if((IsRooted() || (IsBlind() && CombatRange(hate_list.GetClosestEntOnHateList(this)))) && !IsPetStop() && !IsPetRegroup()) { //make sure everybody knows were not moving, for appearance sake if(IsMoving()) { @@ -1411,6 +1411,8 @@ void Mob::AI_Process() { break; } } + if (IsPetRegroup()) + return; } /* Entity has been assigned another entity to follow */ else if (GetFollowID()) diff --git a/zone/string_ids.h b/zone/string_ids.h index ee4203a0e..65810d576 100644 --- a/zone/string_ids.h +++ b/zone/string_ids.h @@ -332,6 +332,8 @@ #define PET_ON_GHOLD 6843 //Pet greater hold has been set to on. #define PET_OFF_GHOLD 6846 //Pet greater hold has been set to off. #define PET_GHOLD_ON_MSG 6847 //Now greater holding master. I will only attack something new if ordered. +#define PET_ON_REGROUPING 6854 //Now regrouping, master. +#define PET_OFF_REGROUPING 6855 //No longer regrouping, master. #define BUFF_NOT_BLOCKABLE 7608 //You cannot block this effect. #define LDON_DONT_KNOW_TRAPPED 7552 //You do not know if this object is trapped. #define LDON_HAVE_DISARMED 7553 //You have disarmed %1!