18#ifndef TRINITYCORE_CREATURE_H
19#define TRINITYCORE_CREATURE_H
52#define CREATURE_Z_ATTACK_RANGE 3
54#define MAX_VENDOR_ITEMS 150
84 explicit Creature(
bool isWorldObject =
false);
93 void SetDisplayFromModel(
uint32 modelIdx);
102 bool LoadCreaturesAddon();
103 void LoadCreaturesSparringHealth(
bool force =
false);
105 void UpdateLevelDependantStats();
106 void SelectWildBattlePetLevel();
107 void LoadEquipment(
int8 id = 1,
bool force =
false);
108 void SetSpawnHealth();
115 Position GetRespawnPosition(
float* dist =
nullptr)
const;
120 m_corpseDelay = delay;
121 if (ignoreCorpseDecayRatio)
122 m_ignoreCorpseDecayRatio =
true;
130 void InitializeMovementCapabilities();
131 void UpdateMovementCapabilities();
172 Unit* SelectVictim();
177 void InitializeReactState();
192 bool isCanInteractWithBattleMaster(
Player* player,
bool msg)
const;
193 bool CanResetTalents(
Player* player)
const;
194 bool CanCreatureAttack(
Unit const* victim,
bool force =
true)
const;
195 void LoadTemplateImmunities(
int32 creatureImmunitiesId);
197 bool IsElite()
const;
198 bool isWorldBoss()
const;
204 bool HasScalableLevels()
const;
205 void ApplyLevelScaling();
211 float GetBaseDamageForLevel(
uint8 level)
const;
214 float GetBaseArmorForLevel(
uint8 level)
const;
225 bool AIM_Initialize(
CreatureAI* ai =
nullptr);
226 void Motion_Initialize();
233 void SetCanMelee(
bool canMelee,
bool fleeFromMelee =
false);
241 bool UpdateEntry(
uint32 entry,
CreatureData const* data =
nullptr,
bool updateLevel =
true);
264 void SetPetitioner(
bool apply);
271 std::string
const& GetAIName()
const;
272 std::string GetScriptName()
const;
273 uint32 GetScriptId()
const;
274 void InheritStringIds(
Creature const* parent);
275 bool HasStringId(std::string_view
id)
const;
276 void SetScriptStringId(std::string
id);
277 std::string_view
GetStringId(
StringIdType type)
const {
return m_stringIds[size_t(type)] ? std::string_view(*m_stringIds[
size_t(type)]) : std::string_view(); }
284 bool HasLabel(
int32 cretureLabel)
const;
285 std::span<int32 const> GetLabels()
const;
292 virtual void SaveToDB(
uint32 mapid, std::vector<Difficulty>
const& spawnDifficulties);
301 void StartPickPocketRefillTimer();
303 bool CanGeneratePickPocketLoot()
const;
308 void SetDontClearTapListOnEvade(
bool dontClear);
309 bool isTappedBy(
Player const* player)
const;
311 bool IsFullyLooted()
const;
312 bool IsSkinnedBy(
Player const* player)
const;
314 void SetTappedBy(
Unit const* unit,
bool withGroup =
true);
315 void AllLootRemovedFromCorpse();
326 bool CanStartAttack(
Unit const* u,
bool force)
const;
327 float GetAttackDistance(
Unit const* player)
const;
328 float GetAggroRange(
Unit const* target)
const;
332 Unit* SelectNearestTarget(
float dist = 0,
bool playerOnly =
false)
const;
333 Unit* SelectNearestTargetInAttackDistance(
float dist = 0)
const;
334 Unit* SelectNearestHostileUnitInAggroRange(
bool useLOS =
false,
bool ignoreCivilians =
false)
const;
336 void DoFleeToGetAssistance();
338 void CallAssistance();
342 bool CanAssistTo(
Unit const* u,
Unit const* enemy,
bool checkfaction =
true)
const;
343 bool _IsTargetAcceptable(
Unit const* target)
const;
349 void RemoveCorpse(
bool setSpawnTime =
true,
bool destroyForNearbyPlayers =
true);
354 time_t GetRespawnTimeEx()
const;
355 void SetRespawnTime(
uint32 respawn);
356 void Respawn(
bool force =
false);
357 void SaveRespawnTime(
uint32 forceDelay = 0);
367 void SendZoneUnderAttackMessage(
Player* attacker);
374 virtual uint8 GetPetAutoSpellSize()
const;
375 virtual uint32 GetPetAutoSpellOnPos(
uint8 pos)
const;
376 float GetPetChaseDistance()
const;
381 void SetCannotReachTarget(
bool cannotReach);
386 void SetHomePosition(
float x,
float y,
float z,
float o) { m_homePosition.Relocate(x, y, z, o); }
388 void GetHomePosition(
float& x,
float& y,
float& z,
float& ori)
const { m_homePosition.GetPosition(x, y, z, ori); }
393 void GetTransportHomePosition(
float& x,
float& y,
float& z,
float& ori)
const { m_transportHomePosition.GetPosition(x, y, z, ori); }
403 bool IsReturningHome()
const;
405 void SearchFormation();
408 bool IsFormationLeader()
const;
409 void SignalFormationMovement();
410 bool IsFormationLeaderMoveAllowed()
const;
414 void LowerPlayerDamageReq(
uint64 unDamage);
433 void DoNotReacquireSpellFocusTarget();
436 void ReleaseSpellFocus(
Spell const* focusSpell =
nullptr,
bool withDelay =
true);
445 void SetTextRepeatId(
uint8 textGroup,
uint8 id);
446 void ClearTextRepeatGroup(
uint8 textGroup);
447 bool IsEscorted()
const;
449 bool CanGiveExperience()
const;
458 void ForcePartyMembersIntoCombat();
463 void OverrideSparringHealthPct(std::vector<float>
const& healthPct);
466 bool ShouldFakeDamageFrom(
Unit* attacker);
481 uint32 GetGossipMenuId()
const;
482 void SetGossipMenuId(
uint32 gossipMenuId);
484 uint32 GetTrainerId()
const;
487 void SummonGraveyardTeleporter();
489 void InitializeInteractSpellId();
512 void operator()(
Player const* player)
const;
538 void RegenerateHealth();
539 void Regenerate(
Powers power);
573 void ForcedDespawn(
uint32 timeMSToDespawn = 0,
Seconds forceRespawnTimer = 0s);
574 bool CheckNoGrayAggroConfig(
uint32 playerLevel,
uint32 creatureLevel)
const;
588 void ReacquireSpellFocusTarget();
594 float Orientation = 0.0f;
@ CREATURE_FLAG_EXTRA_DUNGEON_BOSS
@ CREATURE_FLAG_EXTRA_TRIGGER
@ CREATURE_FLAG_EXTRA_CIVILIAN
@ CREATURE_FLAG_EXTRA_GUARD
@ CREATURE_FLAG_EXTRA_ALL_DIMINISH
@ CREATURE_STATIC_FLAG_6_ALWAYS_STAND_ON_TARGET
@ CREATURE_STATIC_FLAG_5_NO_HEALTH_REGEN
@ CREATURE_STATIC_FLAG_5_NO_LEAVE_COMBAT_STATE_RESTORE
@ CREATURE_STATIC_FLAG_AQUATIC
@ CREATURE_STATIC_FLAG_NO_XP
@ CREATURE_STATIC_FLAG_NO_MELEE_FLEE
@ CREATURE_STATIC_FLAG_UNKILLABLE
@ CREATURE_STATIC_FLAG_SESSILE
@ CREATURE_STATIC_FLAG_NO_LOOT
@ CREATURE_STATIC_FLAG_FLOATING
@ CREATURE_STATIC_FLAG_AMPHIBIOUS
@ CREATURE_STATIC_FLAG_3_CANT_SWIM
@ CREATURE_STATIC_FLAG_3_CANNOT_PENETRATE_WATER
@ CREATURE_STATIC_FLAG_3_NO_THREAT_FEEDBACK
@ CREATURE_STATIC_FLAG_4_AI_WILL_ONLY_SWIM_IF_TARGET_SWIMS
@ CREATURE_STATIC_FLAG_4_NO_MELEE_APPROACH
@ CREATURE_STATIC_FLAG_4_IGNORE_LOS_WHEN_CASTING_ON_ME
@ CREATURE_STATIC_FLAG_4_TREAT_AS_RAID_UNIT_FOR_HELPFUL_SPELLS
@ CREATURE_STATIC_FLAG_2_IGNORE_FEIGN_DEATH
@ CREATURE_STATIC_FLAG_2_IGNORE_SANCTUARY
const uint32 MAX_CREATURE_SPELLS
std::vector< uint8 > CreatureTextRepeatIds
std::list< VendorItemCount > VendorItemCounts
std::unordered_map< uint8, CreatureTextRepeatIds > CreatureTextRepeatGroup
static constexpr uint8 WILD_BATTLE_PET_DEFAULT_LEVEL
static constexpr size_t CREATURE_TAPPERS_SOFT_CAP
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
std::chrono::seconds Seconds
Seconds shorthand typedef.
#define DEFINE_ENUM_FLAG(enumType)
std::list< ObjectGuid > GuidList
std::unordered_set< ObjectGuid > GuidUnorderedSet
std::optional< T > Optional
Optional helper class to wrap optional values within.
static void SaveToDB(QuestPool const &pool, CharacterDatabaseTransaction trans)
NPCFlags
Non Player Character flags.
AssistDelayEvent(ObjectGuid victim, Unit &owner)
void AddAssistant(ObjectGuid guid)
void SetUpdateFieldValue(UF::UpdateFieldPrivateSetter< T > setter, typename UF::UpdateFieldPrivateSetter< T >::value_type value)
bool IsTreatedAsRaidUnit() const
bool HasClassification(CreatureClassifications classification) const
time_t _pickpocketLootRestore
Timers.
VendorItemCounts m_vendorItemCounts
time_t const & GetRespawnTime() const
void SetHomePosition(float x, float y, float z, float o)
bool IsTapListNotClearedOnEvade() const
void SetNoSearchAssistance(bool val)
void RemoveLootMode(uint16 lootMode)
void SetUnkillable(bool unkillable)
void SetIgnoreSanctuarySpellEffect(bool ignoreSanctuary)
CreatureDifficulty const * m_creatureDifficulty
bool HasLootMode(uint16 lootMode) const
int8 GetOriginalEquipmentId() const
std::array< std::string const *, 3 > m_stringIds
void SetHomePosition(Position const &pos)
void DoImmediateBoundaryCheck()
CreatureTextRepeatGroup m_textRepeat
CreatureStaticFlagsHolder _staticFlags
bool IsDungeonBoss() const
SpellSchoolMask m_meleeDamageSchoolMask
bool IsAggroGracePeriodExpired()
Optional< uint32 > m_lootId
int8 m_originalEquipmentId
bool GetRespawnCompatibilityMode() const
bool IsIgnoringChaseRange() const
void SetDisableReputationGain(bool disable)
ObjectGuid::LowType m_spawnId
For new or temporary creatures is 0 for saved it is lowguid.
std::unique_ptr< Loot > m_loot
CreatureDifficulty const * GetCreatureDifficulty() const
Position m_transportHomePosition
CreatureClassifications GetCreatureClassification() const
Optional< uint32 > _defaultMountDisplayIdOverride
uint16 GetLootMode() const
bool IsIgnoringFeignDeath() const
void SetImmuneToPC(bool apply) override
bool IsReputationGainDisabled() const
float GetSparringHealthPct() const
bool CanIgnoreLineOfSightWhenCastingOnMe() const
Optional< std::string > m_scriptStringId
bool m_respawnCompatibilityMode
bool IsSwimDisabled() const
std::unordered_map< ObjectGuid, std::unique_ptr< Loot > > m_personalLoot
CreatureTemplate const * m_creatureInfo
bool IsSpawnedOnTransport() const
bool CanFly() const override
void GetHomePosition(float &x, float &y, float &z, float &ori) const
Position const & GetHomePosition() const
void SetLastDamagedTime(time_t val)
bool IsEvadingAttacks() const
bool HasReactState(ReactStates state) const
bool m_triggerJustAppeared
bool _aggroGracePeriodExpired
void SetCanGiveExperience(bool xpEnabled)
void GetTransportHomePosition(float &x, float &y, float &z, float &ori) const
uint32 GetOriginalEntry() const
bool IsThreatFeedbackDisabled() const
MovementGeneratorType m_defaultMovementType
void SetReactState(ReactStates st)
UF::OptionalUpdateField< UF::VendorData, int32(WowCS::EntityFragment::FVendor_C), 0 > m_vendorData
GuidUnorderedSet const & GetTapList() const
void ResetPlayerDamageReq()
int32 _creatureImmunitiesId
std::pair< uint32, uint32 > _currentWaypointNodeInfo
void SetCannotPenetrateWater(bool cannotPenetrateWater)
bool hasLootRecipient() const
void SetRespawnCompatibilityMode(bool mode=true)
void SetCurrentEquipmentId(uint8 id)
void SetRespawnDelay(uint32 delay)
bool HasFlag(CreatureStaticFlags7 flag) const
uint32 m_cannotReachTimer
time_t m_corpseRemoveTime
void UpdateCurrentWaypointInfo(uint32 nodeId, uint32 pathId)
void SetRestoreStateOnEvade(bool restoreOnEvade)
void SetRegenerateHealth(bool value)
bool HasFlag(CreatureStaticFlags3 flag) const
CreatureData const * m_creatureData
SpellSchoolMask GetMeleeDamageSchoolMask(WeaponAttackType=BASE_ATTACK) const override
bool HasFlag(CreatureStaticFlags2 flag) const
uint32 m_boundaryCheckTime
uint32 GetWaypointPathId() const
CreatureData const * GetCreatureData() const
std::pair< uint32, uint32 > GetCurrentWaypointInfo() const
void SetFloating(bool floating)
ObjectGuid::LowType GetSpawnId() const
bool CanNotReachTarget() const
bool m_AlreadyCallAssistance
CreatureTemplate const * GetCreatureTemplate() const
uint32 GetRespawnDelay() const
Position const & GetTransportHomePosition() const
void SetSessile(bool sessile)
bool CanRegenerateHealth() const
bool DisableReputationGain
CreatureGroup * m_formation
void SetInteractSpellId(int32 interactSpellId)
bool HasSearchedAssistance() const
void SetTransportHomePosition(Position const &pos)
bool IsStateRestoredOnEvade() const
bool HasFlag(CreatureStaticFlags4 flag) const
bool HasFlag(CreatureStaticFlags6 flag) const
void SetCanHaveLoot(bool canHaveLoot)
void SetNoThreatFeedback(bool noThreatFeedback)
void SetImmuneToNPC(bool apply) override
CreatureGroup * GetFormation()
bool m_AlreadySearchedAssistance
uint32 GetCorpseDelay() const
GuidUnorderedSet m_tapList
bool m_dontClearTapListOnEvade
bool CannotPenetrateWater() const
void OverrideSparringHealthPct(float healthPct)
std::string_view GetStringId(StringIdType type) const
bool CanEnterWater() const override
void SetImmuneToAll(bool apply) override
bool IsIgnoringSanctuarySpellEffect() const
bool HasFlag(CreatureStaticFlags8 flag) const
void AddLootMode(uint16 lootMode)
ReactStates GetReactState() const
void SetTransportHomePosition(float x, float y, float z, float o)
void SetWanderDistance(float dist)
time_t GetLastDamagedTime() const
Optional< uint32 > _trainerId
bool HasFlag(CreatureStaticFlags flag) const
uint8 GetCurrentEquipmentId() const
void SetFormation(CreatureGroup *formation)
void SetCorpseDelay(uint32 delay, bool ignoreCorpseDecayRatio=false)
void SetMeleeDamageSchool(SpellSchools school)
float GetWanderDistance() const
bool IsAmphibious() const
void ResetPickPocketRefillTimer()
void SetNoCallAssistance(bool val)
void SetTreatAsRaidUnit(bool treatAsRaidUnit)
bool IsAffectedByDiminishingReturns() const override
bool IsRacialLeader() const
bool m_ignoreCorpseDecayRatio
bool CanOnlySwimIfTargetSwims() const
bool HasFlag(CreatureStaticFlags5 flag) const
void SetIgnoreChaseRange(bool ignoreChaseRange)
bool IsInEvadeMode() const
void SetLootMode(uint16 lootMode)
void SetDefaultMovementType(MovementGeneratorType mgt)
void LoadPath(uint32 pathid)
void SetTapList(GuidUnorderedSet tapList)
void SetOriginalEntry(uint32 entry)
void SetIgnoreFeignDeath(bool ignoreFeignDeath)
Seconds const m_respawnTimer
ForcedDespawnDelayEvent(Creature &owner, Seconds respawnTimer)
virtual void BuildValuesUpdateWithFlag(UF::UpdateFieldFlag flags, ByteBuffer &data, Player const *target) const
virtual bool hasQuest(uint32) const
virtual void BuildValuesCreate(UF::UpdateFieldFlag flags, ByteBuffer &data, Player const *target) const =0
virtual void BuildValuesUpdate(UF::UpdateFieldFlag flags, ByteBuffer &data, Player const *target) const =0
virtual Loot * GetLootForPlayer(Player const *player) const
virtual void SetObjectScale(float scale)
virtual bool hasInvolvedQuest(uint32) const
virtual SpawnTrackingStateData const * GetSpawnTrackingStateDataForPlayer(Player const *player) const
void SetImmuneToAll(bool apply, bool keepCombat)
void SetImmuneToPC(bool apply, bool keepCombat)
virtual bool IsMovementPreventedByCasting() const
virtual MovementGeneratorType GetDefaultMovementType() const
void Heartbeat() override
virtual int32 GetCreatePowerValue(Powers power) const
void AddToWorld() override
virtual float GetArmorMultiplierForTarget(WorldObject const *) const
virtual void SetCanDualWield(bool value)
void SetControlled(bool apply, UnitState state)
virtual bool UpdateAllStats()=0
virtual void AtEngage(Unit *)
virtual void UpdateAttackPowerAndDamage(bool ranged=false)=0
virtual void AtDisengage()
std::string GetDebugInfo() const override
void SetImmuneToNPC(bool apply, bool keepCombat)
bool SetDisableGravity(bool disable, bool updateAnimTier=true)
virtual void SetInteractionAllowedWhileHostile(bool interactionAllowed)
virtual bool HasSpell(uint32) const
virtual bool IsAffectedByDiminishingReturns() const
bool IsImmuneToNPC() const
virtual void SetInteractionAllowedInCombat(bool interactionAllowed)
virtual bool IsImmunedToSpellEffect(SpellInfo const *spellInfo, SpellEffectInfo const &spellEffectInfo, WorldObject const *caster, bool requireImmunityPurgesEffectAttribute=false) const
bool IsImmuneToAll() const
virtual void UpdateNearbyPlayersInteractions()
virtual void UpdateArmor()=0
virtual float GetDamageMultiplierForTarget(WorldObject const *) const
bool HasUnitMovementFlag(uint32 f) const
virtual void UpdateMaxPower(Powers power)=0
virtual bool UpdateStats(Stats stat)=0
uint8 GetLevelForTarget(WorldObject const *) const override
virtual void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float &minDamage, float &maxDamage) const =0
virtual void SetTarget(ObjectGuid const &)=0
virtual uint32 GetPowerIndex(Powers power) const =0
UF::UpdateField< UF::UnitData, int32(WowCS::EntityFragment::CGObject), TYPEID_UNIT > m_unitData
virtual float GetHealthMultiplierForTarget(WorldObject const *) const
bool HasUnitState(const uint32 f) const
virtual void Update(uint32 time) override
virtual bool CanSwim() const
virtual float GetNativeObjectScale() const
void RemoveFromWorld() override
virtual void UpdateMaxHealth()=0
virtual bool HasSpellFocus(Spell const *=nullptr) const
virtual void setDeathState(DeathState s)
virtual bool IsEngaged() const
bool IsImmuneToPC() const
virtual void SetDisplayId(uint32 displayId, bool setNative=false)
virtual void ExitVehicle(Position const *exitPosition=nullptr)
constexpr uint32 GetMapId() const
virtual bool IsInvisibleDueToDespawn(WorldObject const *seer) const
std::string GetNameForLocaleIdx(LocaleConstant) const override
virtual bool CanAlwaysSee(WorldObject const *) const
Player session in the World.
UF::ObjectData::Base ObjectMask
bool IgnoreNestedChangesMask
UF::UnitData::Base UnitMask
ValuesUpdateForPlayerWithMaskSender(Creature const *owner)
UpdateField< int32, 96, 117 > InteractSpellID