47 TC_LOG_DEBUG(
"entities.pet",
"Critter ({}) does not exist - player '{}' ({} / account: {}) attempted to dismiss it (possibly lagged out)",
85 if (pet !=
GetPlayer()->GetFirstControlled())
104 if (
GetPlayer()->m_Controlled.size() == 1)
109 std::vector<Unit*> controlled;
111 if ((*itr)->GetEntry() == pet->
GetEntry() && (*itr)->IsAlive())
112 controlled.push_back(*itr);
113 for (std::vector<Unit*>::iterator itr = controlled.begin(); itr != controlled.end(); ++itr)
130 TC_LOG_ERROR(
"entities.pet",
"HandlePetStopAttack: {} isn't a pet or charmed creature of player {}",
146 TC_LOG_DEBUG(
"entities.pet",
"WorldSession::HandlePetAction(petGuid: {}, tagGuid: {}, spellId: {}, flag: {}): object {} is considered pet-like but doesn't have a charminfo!",
198 if (!owner->IsValidAttackTarget(TargetUnit))
217 petAI->_AttackStart(TargetUnit);
238 pet->
Attack(TargetUnit,
true);
259 ((
Minion*)pet)->UnSummon();
276 TC_LOG_ERROR(
"entities.pet",
"WORLD: unknown PET flag Action {} and spellid {}.",
uint32(flag), spellid);
296 Unit* unit_target =
nullptr;
305 TC_LOG_ERROR(
"spells.pet",
"WORLD: unknown PET spell id {}", spellid);
379 petAI->_AttackStart(unit_target);
381 AI->AttackStart(unit_target);
408 TC_LOG_ERROR(
"entities.pet",
"WORLD: unknown PET flag Action {} and spellid {}.",
uint32(flag), spellid);
425 response.
Allow =
true;
426 response.
Timestamp = *unit->m_unitData->PetNameTimestamp;
427 response.
Name = unit->GetName();
431 if (
DeclinedName const* names = pet->GetDeclinedNames())
449 TC_LOG_DEBUG(
"entities.player.cheat",
"{} attempt open stable in cheating way.", guid.
ToString());
458 TC_LOG_DEBUG(
"entities.player",
"Stablemaster {} not found or you can't interact with him.", guid.
ToString());
479 TC_LOG_ERROR(
"entities.pet",
"WorldSession::HandlePetSetAction: object {} is considered pet-like but doesn't have a charminfo!", pet->
GetGUID().
ToString());
483 std::vector<Unit*> pets;
485 if (controlled->GetEntry() == pet->
GetEntry() && controlled->IsAlive())
486 pets.push_back(controlled);
494 TC_LOG_DEBUG(
"entities.pet",
"Player {} has changed pet spell action. Position: {}, Spell: {}, State: 0x{:X}",
497 for (
Unit* petControlled : pets)
502 if (
SpellInfo const* spellInfo =
sSpellMgr->GetSpellInfo(spell_id, petControlled->GetMap()->GetDifficultyID()))
507 if (petControlled->GetTypeId() ==
TYPEID_UNIT && petControlled->IsPet())
508 ((
Pet*)petControlled)->ToggleAutocast(spellInfo,
true);
511 if ((*itr)->GetEntry() == petControlled->GetEntry())
512 (*itr)->GetCharmInfo()->ToggleCreatureAutocast(spellInfo,
true);
517 if (petControlled->GetTypeId() ==
TYPEID_UNIT && petControlled->IsPet())
518 ((
Pet*)petControlled)->ToggleAutocast(spellInfo,
false);
521 if ((*itr)->GetEntry() == petControlled->GetEntry())
522 (*itr)->GetCharmInfo()->ToggleCreatureAutocast(spellInfo,
false);
593 for (
uint8 i = 0; i < 5; i++)
594 stmt->
setString(i + 2, declinedname->name[i]);
624 if (pet->IsHunterPet() && pet->m_unitData->PetNumber == petAbandonByNumber.
PetNumber)
644 TC_LOG_ERROR(
"entities.pet",
"WorldSession::HandlePetSpellAutocastOpcode: {} isn't pet of player {} ({}).",
656 std::vector<Unit*> pets;
658 if (controlled->GetEntry() == pet->
GetEntry() && controlled->IsAlive())
659 pets.push_back(controlled);
661 for (
Unit* petControlled : pets)
667 CharmInfo* charmInfo = petControlled->GetCharmInfo();
670 TC_LOG_ERROR(
"entities.pet",
"WorldSession::HandlePetSpellAutocastOpcode: object {} is considered pet-like but doesn't have a charminfo!", petControlled->GetGUID().ToString());
674 if (petControlled->IsPet())
675 petControlled->ToPet()->ToggleAutocast(spellInfo, packet.
AutocastEnabled);
695 TC_LOG_ERROR(
"spells.pet",
"WorldSession::HandlePetCastSpellOpcode: unknown spell id {} tried to cast by {}",
730 Spell* spell =
new Spell(caster, spellInfo, triggerCastFlags);
748 pet->SendPetAIReaction(petCastSpell.
PetGUID);
774 petNameInvalid.
Result = error;
@ CHAR_INS_CHAR_PET_DECLINEDNAME
@ CHAR_DEL_CHAR_PET_DECLINEDNAME
#define UNIT_ACTION_BUTTON_ACTION(X)
#define UNIT_ACTION_BUTTON_TYPE(X)
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
@ GROUP_UPDATE_FLAG_PET_NAME
#define TC_LOG_DEBUG(filterType__, message__,...)
#define TC_LOG_ERROR(filterType__, message__,...)
std::optional< T > Optional
Optional helper class to wrap optional values within.
uint32 urand(uint32 min, uint32 max)
@ SPELL_ATTR9_CHANNEL_PERSISTS_ON_PET_FOLLOW
@ TARGET_DEST_DYNOBJ_ENEMY
@ TARGET_UNIT_DEST_AREA_ENEMY
@ TARGET_UNIT_SRC_AREA_ENEMY
@ SPELL_ATTR0_ALLOW_CAST_WHILE_DEAD
@ SPELL_FAILED_UNIT_NOT_INFRONT
@ PET_NAME_DECLENSION_DOESNT_MATCH_BASE_NAME
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL_FROM_CLIENT
@ TRIGGERED_FULL_MASK
Used when doing CastSpell with triggered == true.
@ TRIGGERED_NONE
Not triggered.
@ UNIT_PET_FLAG_CAN_BE_RENAMED
@ UNIT_NPC_FLAG_STABLEMASTER
@ UNIT_FLAG_PLAYER_CONTROLLED
@ CURRENT_CHANNELED_SPELL
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
ObjectGuid const & GetGUID() const
void SendUpdateToPlayer(Player *player) const
void AttackStart(Unit *victim) override
== Triggered Actions Requested ==================
void SetReactState(ReactStates st)
Difficulty GetDifficultyID() const
void MoveFollow(Unit *target, float dist, Optional< ChaseAngle > angle={}, Optional< Milliseconds > duration={}, bool ignoreTargetWalk=false, MovementSlot slot=MOTION_SLOT_ACTIVE, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={}, Optional< MovementFadeObject > fadeObject={}, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
LowType GetCounter() const
std::string ToString() const
static bool CheckDeclinedNames(const std::wstring &w_ownname, DeclinedName const &names)
static PetNameInvalidReason CheckPetName(std::string_view name)
PetInfo * GetCurrentPet()
void SetGroupUpdateFlag(uint32 flag)
PetType getPetType() const
ObjectGuid GetSummonedBattlePetGUID() const
void SendDirectMessage(WorldPacket const *data) const
void CharmSpellInitialize()
void DeletePetFromDB(uint32 petNumber)
PetStable * GetPetStable()
void PetSpellInitialize()
void RemovePet(Pet *pet, PetSaveMode mode, bool returnreagent=false)
void SetBattlePetData(BattlePets::BattlePet const *pet=nullptr)
void PossessSpellInitialize()
void VehicleSpellInitialize()
void setString(uint8 index, std::string &&value)
void setUInt32(uint8 index, uint32 value)
void setUInt64(uint8 index, uint64 value)
Unit * GetUnitTarget() const
void ResetCooldown(uint32 spellId, bool update=false)
bool HasCooldown(SpellInfo const *spellInfo, uint32 itemId=0) const
bool IsAutocastable() const
bool HasAttribute(SpellAttr0 attribute) const
std::vector< SpellEffectInfo > const & GetEffects() const
SpellCastTargets m_targets
static void SendCastResult(Player *caster, SpellInfo const *spellInfo, SpellCastVisual spellVisual, ObjectGuid cast_count, SpellCastResult result, SpellCustomErrors customError=SPELL_CUSTOM_ERROR_NONE, int32 *param1=nullptr, int32 *param2=nullptr)
SpellCastResult prepare(SpellCastTargets const &targets, AuraEffect const *triggeredByAura=nullptr)
SpellCastResult CheckPetCast(Unit *target)
void SendPetCastResult(SpellCastResult result, int32 *param1=nullptr, int32 *param2=nullptr) const
void finish(SpellCastResult result=SPELL_CAST_OK)
struct Spell::@321::@324 Raw
SpellCastVisual m_SpellVisual
virtual void UnSummon(uint32 msTime=0)
Unit * GetCharmed() const
bool HasPetFlag(UnitPetFlag flags) const
ObjectGuid GetOwnerGUID() const override
MotionMaster * GetMotionMaster()
void SetPetNameTimestamp(uint32 timestamp)
TempSummon * ToTempSummon()
CharmInfo * GetCharmInfo()
virtual bool HasSpell(uint32) const
Unit * GetCharmerOrOwner() const
bool Attack(Unit *victim, bool meleeAttack)
void SendPetTalk(uint32 pettalk)
bool HasAuraType(AuraType auraType) const
void RemovePetFlag(UnitPetFlag flags)
ObjectGuid GetCritterGUID() const
void SendPetAIReaction(ObjectGuid guid)
virtual float GetFollowAngle() const
Unit * GetFirstControlled() const
uint32 HasUnitTypeMask(uint32 mask) const
SpellHistory * GetSpellHistory()
ObjectGuid GetCharmerGUID() const
virtual bool HasSpellFocus(Spell const *=nullptr) const
bool HasAuraTypeWithTriggerSpell(AuraType auratype, uint32 triggerSpell) const
void SetInFront(WorldObject const *target)
ObjectGuid GetBattlePetCompanionGUID() const
Guardian * GetGuardianPet() const
void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed=true, bool withInstant=true)
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
std::string const & GetName() const
void SetName(std::string newname)
TaggedPosition< Position::XYZ > ActionPosition
WorldPacket const * Write() override
WorldPackets::Timestamp Timestamp
WorldPacket const * Write() override
DeclinedName DeclinedNames
WorldPacket const * Write() override
void HandlePetCastSpellOpcode(WorldPackets::Spells::PetCastSpell &petCastSpell)
void HandlePetAbandonByNumber(WorldPackets::Pet::PetAbandonByNumber const &petAbandonByNumber)
bool CheckStableMaster(ObjectGuid guid)
void HandleDismissCritter(WorldPackets::Pet::DismissCritter &dismissCritter)
void HandlePetStopAttack(WorldPackets::Pet::PetStopAttack &packet)
Player * GetPlayer() const
void HandlePetAction(WorldPackets::Pet::PetAction &packet)
void HandlePetRename(WorldPackets::Pet::PetRename &packet)
void HandleQueryPetName(WorldPackets::Query::QueryPetName &packet)
void HandleRequestPetInfo(WorldPackets::Pet::RequestPetInfo &requestPetInfo)
void HandlePetSpellAutocastOpcode(WorldPackets::Pet::PetSpellAutocast &packet)
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
uint32 GetAccountId() const
void HandlePetSetAction(WorldPackets::Pet::PetSetAction &packet)
void SendQueryPetNameResponse(ObjectGuid guid)
void SendPetNameInvalid(uint32 error, std::string const &name, Optional< DeclinedName > const &declinedName)
void HandlePetAbandon(WorldPackets::Pet::PetAbandon &packet)
void HandlePetActionHelper(Unit *pet, ObjectGuid guid1, uint32 spellid, uint16 flag, ObjectGuid guid2, Position const &pos)
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
TC_GAME_API Pet * GetPet(WorldObject const &, ObjectGuid const &guid)
TC_GAME_API Creature * GetCreatureOrPetOrVehicle(WorldObject const &, ObjectGuid const &)
void SetIsCommandFollow(bool val)
uint32 GetPetNumber() const
void SetActionBar(uint8 index, uint32 spellOrAction, ActiveStates type)
void SetIsAtStay(bool val)
void SetIsFollowing(bool val)
void SetIsReturning(bool val)
void SetSpellAutocast(SpellInfo const *spellInfo, bool state)
void ToggleCreatureAutocast(SpellInfo const *spellInfo, bool apply)
void SetCommandState(CommandStates st)
void SetIsCommandAttack(bool val)
Optional< DeclinedName > DeclinedNames
std::array< int32, 3 > Misc