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();
143 void SetFloating(
bool floating);
146 void UpdateFloatingMovementFlags();
150 void SetSessile(
bool sessile);
153 void UpdateSessileMovementFlags();
178 Unit* SelectVictim();
183 void InitializeReactState();
198 bool isCanInteractWithBattleMaster(
Player* player,
bool msg)
const;
199 bool CanResetTalents(
Player* player)
const;
200 bool CanCreatureAttack(
Unit const* victim,
bool force =
true)
const;
201 void LoadTemplateImmunities(
int32 creatureImmunitiesId);
203 bool IsElite()
const;
204 bool isWorldBoss()
const;
210 bool HasScalableLevels()
const;
211 void ApplyLevelScaling();
212 void ApplyLevelScaling(
int32 contentTuningId,
int32 scalingLevelDelta);
218 float GetBaseDamageForLevel(
uint8 level)
const;
221 float GetBaseArmorForLevel(
uint8 level)
const;
232 bool AIM_Initialize(
CreatureAI* ai =
nullptr);
233 void Motion_Initialize();
240 void SetCanMelee(
bool canMelee,
bool fleeFromMelee =
false);
248 bool UpdateEntry(
uint32 entry,
CreatureData const* data =
nullptr,
bool updateLevel =
true);
272 void SetPetitioner(
bool apply);
279 std::string
const& GetAIName()
const;
280 std::string GetScriptName()
const;
281 uint32 GetScriptId()
const;
282 void InheritStringIds(
Creature const* parent);
283 bool HasStringId(std::string_view
id)
const;
284 void SetScriptStringId(std::string
id);
285 std::string_view
GetStringId(
StringIdType type)
const {
return m_stringIds[size_t(type)] ? std::string_view(*m_stringIds[
size_t(type)]) : std::string_view(); }
292 bool HasLabel(
int32 cretureLabel)
const;
293 std::span<int32 const> GetLabels()
const;
300 virtual void SaveToDB(
uint32 mapid, std::vector<Difficulty>
const& spawnDifficulties);
309 void StartPickPocketRefillTimer();
311 bool CanGeneratePickPocketLoot()
const;
316 void SetDontClearTapListOnEvade(
bool dontClear);
317 bool isTappedBy(
Player const* player)
const;
319 bool IsFullyLooted()
const;
320 bool IsSkinnedBy(
Player const* player)
const;
322 void SetTappedBy(
Unit const* unit,
bool withGroup =
true);
323 void AllLootRemovedFromCorpse();
334 bool CanStartAttack(
Unit const* u,
bool force)
const;
335 float GetAttackDistance(
Unit const* player)
const;
336 float GetAggroRange(
Unit const* target)
const;
340 Unit* SelectNearestTarget(
float dist = 0,
bool playerOnly =
false)
const;
341 Unit* SelectNearestTargetInAttackDistance(
float dist = 0)
const;
342 Unit* SelectNearestHostileUnitInAggroRange(
bool useLOS =
false,
bool ignoreCivilians =
false)
const;
344 void DoFleeToGetAssistance();
346 void CallAssistance();
350 bool CanAssistTo(
Unit const* u,
Unit const* enemy,
bool checkfaction =
true)
const;
351 bool _IsTargetAcceptable(
Unit const* target)
const;
357 void RemoveCorpse(
bool setSpawnTime =
true,
bool destroyForNearbyPlayers =
true);
362 time_t GetRespawnTimeEx()
const;
363 void SetRespawnTime(
uint32 respawn);
364 void Respawn(
bool force =
false);
365 void SaveRespawnTime(
uint32 forceDelay = 0);
375 void SendZoneUnderAttackMessage(
Player* attacker);
382 virtual uint8 GetPetAutoSpellSize()
const;
383 virtual uint32 GetPetAutoSpellOnPos(
uint8 pos)
const;
384 float GetPetChaseDistance()
const;
389 void SetCannotReachTarget(
bool cannotReach);
394 void SetHomePosition(
float x,
float y,
float z,
float o) { m_homePosition.Relocate(x, y, z, o); }
396 void GetHomePosition(
float& x,
float& y,
float& z,
float& ori)
const { m_homePosition.GetPosition(x, y, z, ori); }
401 void GetTransportHomePosition(
float& x,
float& y,
float& z,
float& ori)
const { m_transportHomePosition.GetPosition(x, y, z, ori); }
411 bool IsReturningHome()
const;
413 void SearchFormation();
416 bool IsFormationLeader()
const;
417 void SignalFormationMovement();
418 bool IsFormationLeaderMoveAllowed()
const;
422 void LowerPlayerDamageReq(
uint64 unDamage);
441 void DoNotReacquireSpellFocusTarget();
444 void ReleaseSpellFocus(
Spell const* focusSpell =
nullptr,
bool withDelay =
true);
453 void SetTextRepeatId(
uint8 textGroup,
uint8 id);
454 void ClearTextRepeatGroup(
uint8 textGroup);
455 bool IsEscorted()
const;
457 bool CanGiveExperience()
const;
466 void ForcePartyMembersIntoCombat();
471 void OverrideSparringHealthPct(std::vector<float>
const& healthPct);
474 bool ShouldFakeDamageFrom(
Unit* attacker);
489 uint32 GetGossipMenuId()
const;
490 void SetGossipMenuId(
uint32 gossipMenuId);
492 uint32 GetTrainerId()
const;
495 void SummonGraveyardTeleporter();
497 void InitializeInteractSpellId();
520 void operator()(
Player const* player)
const;
546 void RegenerateHealth();
547 void Regenerate(
Powers power);
583 void ForcedDespawn(
uint32 timeMSToDespawn = 0,
Seconds forceRespawnTimer = 0s);
584 bool CheckNoGrayAggroConfig(
uint32 playerLevel,
uint32 creatureLevel)
const;
598 void ReacquireSpellFocusTarget();
604 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
ObjectGuid::LowType GetSpawnId() const
bool CanNotReachTarget() const
bool m_AlreadyCallAssistance
CreatureTemplate const * GetCreatureTemplate() const
uint32 GetRespawnDelay() const
Position const & GetTransportHomePosition() const
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
uint32 m_baseRangedAttackPower
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 ClassPowerTypes GetPowerTypes() const =0
virtual void SetCanDualWield(bool value)
virtual bool UpdateAllStats()=0
virtual void UpdateAttackPowerAndDamage(bool ranged=false)=0
virtual void AtDisengage()
std::string GetDebugInfo() const override
void SetImmuneToNPC(bool apply, bool keepCombat)
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
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
bool HasUnitMovementFlag(MovementFlags f) const
virtual void UpdateMaxHealth()=0
virtual bool HasSpellFocus(Spell const *=nullptr) const
virtual void setDeathState(DeathState s)
virtual void AtEngage(Unit *target)
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, 119 > InteractSpellID