47 TC_LOG_DEBUG(
"entities.pet",
"Critter ({}) does not exist - player '{}' ({} / account: {}) attempted to dismiss it (possibly lagged out)",
85 if (pet !=
GetPlayer()->GetFirstControlled())
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!",
196 if (!owner->IsValidAttackTarget(TargetUnit))
215 petAI->_AttackStart(TargetUnit);
236 pet->
Attack(TargetUnit,
true);
257 ((
Minion*)pet)->UnSummon();
274 TC_LOG_ERROR(
"entities.pet",
"WORLD: unknown PET flag Action {} and spellid {}.",
uint32(flag), spellid);
294 Unit* unit_target =
nullptr;
303 TC_LOG_ERROR(
"spells.pet",
"WORLD: unknown PET spell id {}", spellid);
377 petAI->_AttackStart(unit_target);
379 AI->AttackStart(unit_target);
406 TC_LOG_ERROR(
"entities.pet",
"WORLD: unknown PET flag Action {} and spellid {}.",
uint32(flag), spellid);
423 response.
Allow =
true;
424 response.
Timestamp = *unit->m_unitData->PetNameTimestamp;
425 response.
Name = unit->GetName();
429 if (
DeclinedName const* names = pet->GetDeclinedNames())
447 TC_LOG_DEBUG(
"entities.player.cheat",
"{} attempt open stable in cheating way.", guid.
ToString());
456 TC_LOG_DEBUG(
"entities.player",
"Stablemaster {} not found or you can't interact with him.", guid.
ToString());
477 TC_LOG_ERROR(
"entities.pet",
"WorldSession::HandlePetSetAction: object {} is considered pet-like but doesn't have a charminfo!", pet->
GetGUID().
ToString());
481 std::vector<Unit*> pets;
484 pets.push_back(controlled);
492 TC_LOG_DEBUG(
"entities.pet",
"Player {} has changed pet spell action. Position: {}, Spell: {}, State: 0x{:X}",
495 for (
Unit* petControlled : pets)
500 if (
SpellInfo const* spellInfo =
sSpellMgr->GetSpellInfo(spell_id, petControlled->GetMap()->GetDifficultyID()))
505 if (petControlled->GetTypeId() ==
TYPEID_UNIT && petControlled->IsPet())
506 ((
Pet*)petControlled)->ToggleAutocast(spellInfo,
true);
509 if ((*itr)->GetEntry() == petControlled->GetEntry())
510 (*itr)->GetCharmInfo()->ToggleCreatureAutocast(spellInfo,
true);
515 if (petControlled->GetTypeId() ==
TYPEID_UNIT && petControlled->IsPet())
516 ((
Pet*)petControlled)->ToggleAutocast(spellInfo,
false);
519 if ((*itr)->GetEntry() == petControlled->GetEntry())
520 (*itr)->GetCharmInfo()->ToggleCreatureAutocast(spellInfo,
false);
591 for (
uint8 i = 0; i < 5; i++)
592 stmt->
setString(i + 2, declinedname->name[i]);
629 TC_LOG_ERROR(
"entities.pet",
"WorldSession::HandlePetSpellAutocastOpcode: {} isn't pet of player {} ({}).",
641 std::vector<Unit*> pets;
644 pets.push_back(controlled);
646 for (
Unit* petControlled : pets)
652 CharmInfo* charmInfo = petControlled->GetCharmInfo();
655 TC_LOG_ERROR(
"entities.pet",
"WorldSession::HandlePetSpellAutocastOpcode: object {} is considered pet-like but doesn't have a charminfo!", petControlled->GetGUID().ToString());
659 if (petControlled->IsPet())
660 petControlled->ToPet()->ToggleAutocast(spellInfo, packet.
AutocastEnabled);
680 TC_LOG_ERROR(
"spells.pet",
"WorldSession::HandlePetCastSpellOpcode: unknown spell id {} tried to cast by {}",
715 Spell* spell =
new Spell(caster, spellInfo, triggerCastFlags);
734 pet->SendPetAIReaction(petCastSpell.
PetGUID);
760 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__,...)
#define TC_LOG_ERROR(filterType__,...)
std::optional< T > Optional
Optional helper class to wrap optional values within.
uint32 urand(uint32 min, uint32 max)
@ 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
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
void AttackStart(Unit *victim) override
== Triggered Actions Requested ==================
void SetReactState(ReactStates st)
Difficulty GetDifficultyID() const
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={})
void MoveFollow(Unit *target, float dist, ChaseAngle angle, Optional< Milliseconds > duration={}, MovementSlot slot=MOTION_SLOT_ACTIVE)
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)
static Creature * ToCreature(Object *o)
static ObjectGuid GetGUID(Object const *o)
void SendUpdateToPlayer(Player *player)
static Player * ToPlayer(Object *o)
PetInfo * GetCurrentPet()
void SetGroupUpdateFlag(uint32 flag)
PetType getPetType() const
ObjectGuid GetSummonedBattlePetGUID() const
void SendDirectMessage(WorldPacket const *data) const
void CharmSpellInitialize()
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 setUInt32(const uint8 index, const uint32 value)
void setString(const uint8 index, const std::string &value)
void setUInt64(const uint8 index, const 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
struct Spell::@333::@335 Raw
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)
SpellCastVisual m_SpellVisual
virtual void UnSummon(uint32 msTime=0)
Unit * GetCharmed() const
bool HasPetFlag(UnitPetFlag flags) const
ObjectGuid GetOwnerGUID() const override
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
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
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)
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 bool GetName(uint32 accountId, std::string &name)
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 &)
std::string ToString(Type &&val, Params &&... params)
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