AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
CreatureTemplate Struct Reference

#include "CreatureData.h"

Public Member Functions

CreatureModel const * GetModelByIdx (uint32 idx) const
 
CreatureModel const * GetRandomValidModel () const
 
CreatureModel const * GetFirstValidModel () const
 
CreatureModel const * GetModelWithDisplayId (uint32 displayId) const
 
CreatureModel const * GetFirstInvisibleModel () const
 
CreatureModel const * GetFirstVisibleModel () const
 
SkillType GetRequiredLootSkill () const
 
bool IsExotic () const
 
bool IsTameable (bool exotic) const
 
bool HasFlagsExtra (uint32 flag) const
 
void InitializeQueryData ()
 

Public Attributes

uint32 Entry
 
uint32 DifficultyEntry [MAX_DIFFICULTY - 1]
 
uint32 KillCredit [MAX_KILL_CREDIT]
 
std::vector< CreatureModelModels
 
std::string Name
 
std::string SubName
 
std::string IconName
 
uint32 GossipMenuId
 
uint8 minlevel
 
uint8 maxlevel
 
uint32 expansion
 
uint32 faction
 
uint32 npcflag
 
float speed_walk
 
float speed_run
 
float speed_swim
 
float speed_flight
 
float detection_range
 
float scale
 
uint32 rank
 
uint32 dmgschool
 
float DamageModifier
 
uint32 BaseAttackTime
 
uint32 RangeAttackTime
 
float BaseVariance
 
float RangeVariance
 
uint32 unit_class
 
uint32 unit_flags
 
uint32 unit_flags2
 
uint32 dynamicflags
 
uint32 family
 
uint32 trainer_type
 
uint32 trainer_spell
 
uint32 trainer_class
 
uint32 trainer_race
 
uint32 type
 
uint32 type_flags
 
uint32 lootid
 
uint32 pickpocketLootId
 
uint32 SkinLootId
 
int32 resistance [MAX_SPELL_SCHOOL]
 
uint32 spells [MAX_CREATURE_SPELLS]
 
uint32 PetSpellDataId
 
uint32 VehicleId
 
uint32 mingold
 
uint32 maxgold
 
std::string AIName
 
uint32 MovementType
 
CreatureMovementData Movement
 
float HoverHeight
 
float ModHealth
 
float ModMana
 
float ModArmor
 
float ModExperience
 
bool RacialLeader
 
uint32 movementId
 
bool RegenHealth
 
uint32 MechanicImmuneMask
 
uint8 SpellSchoolImmuneMask
 
uint32 flags_extra
 
uint32 ScriptID
 
WorldPacket queryData
 

Detailed Description

Member Function Documentation

◆ GetFirstInvisibleModel()

CreatureModel const * CreatureTemplate::GetFirstInvisibleModel ( ) const
162{
163 for (CreatureModel const& model : Models)
164 if (CreatureModelInfo const* modelInfo = sObjectMgr->GetCreatureModelInfo(model.CreatureDisplayID))
165 if (modelInfo && modelInfo->is_trigger)
166 return &model;
167
169}
Models
Definition: boss_black_knight.cpp:95
#define sObjectMgr
Definition: ObjectMgr.h:1635
Definition: CreatureData.h:169
static CreatureModel const DefaultInvisibleModel
Definition: CreatureData.h:170
Definition: CreatureData.h:398

References CreatureModel::DefaultInvisibleModel, and sObjectMgr.

Referenced by ObjectMgr::ChooseDisplayId(), and Unit::PatchValuesUpdate().

◆ GetFirstValidModel()

CreatureModel const * CreatureTemplate::GetFirstValidModel ( ) const
144{
145 for (CreatureModel const& model : Models)
146 if (model.CreatureDisplayID)
147 return &model;
148
149 return nullptr;
150}

Referenced by Creature::InitEntry().

◆ GetFirstVisibleModel()

CreatureModel const * CreatureTemplate::GetFirstVisibleModel ( ) const
172{
173 for (CreatureModel const& model : Models)
174 if (CreatureModelInfo const* modelInfo = sObjectMgr->GetCreatureModelInfo(model.CreatureDisplayID))
175 if (modelInfo && !modelInfo->is_trigger)
176 return &model;
177
179}
static CreatureModel const DefaultVisibleModel
Definition: CreatureData.h:171

References CreatureModel::DefaultVisibleModel, and sObjectMgr.

Referenced by Unit::PatchValuesUpdate().

◆ GetModelByIdx()

CreatureModel const * CreatureTemplate::GetModelByIdx ( uint32  idx) const
122{
123 return idx < Models.size() ? &Models[idx] : nullptr;
124}

Referenced by WorldSession::HandleCreatureQueryOpcode(), and InitializeQueryData().

◆ GetModelWithDisplayId()

CreatureModel const * CreatureTemplate::GetModelWithDisplayId ( uint32  displayId) const
153{
154 for (CreatureModel const& model : Models)
155 if (displayId == model.CreatureDisplayID)
156 return &model;
157
158 return nullptr;
159}

Referenced by ObjectMgr::ChooseDisplayId().

◆ GetRandomValidModel()

CreatureModel const * CreatureTemplate::GetRandomValidModel ( ) const
127{
128 if (!Models.size())
129 return nullptr;
130
131 // If only one element, ignore the Probability (even if 0)
132 if (Models.size() == 1)
133 return &Models[0];
134
136 {
137 return model.Probability;
138 });
139
140 return &(*selectedItr);
141}
auto SelectRandomWeightedContainerElement(C const &container, std::vector< double > weights) -> decltype(std::begin(container))
Definition: Containers.h:165
float Probability
Definition: CreatureData.h:181

References CreatureModel::Probability, and Acore::Containers::SelectRandomWeightedContainerElement().

Referenced by ObjectMgr::ChooseDisplayId(), and ObjectMgr::GetTaxiMountDisplayId().

◆ GetRequiredLootSkill()

SkillType CreatureTemplate::GetRequiredLootSkill ( ) const
inline
258 {
260 return SKILL_HERBALISM;
262 return SKILL_MINING;
264 return SKILL_ENGINEERING;
265 else
266 return SKILL_SKINNING; // normal case
267 }
@ CREATURE_TYPE_FLAG_SKIN_WITH_ENGINEERING
Definition: SharedDefines.h:2710
@ CREATURE_TYPE_FLAG_SKIN_WITH_HERBALISM
Definition: SharedDefines.h:2703
@ CREATURE_TYPE_FLAG_SKIN_WITH_MINING
Definition: SharedDefines.h:2704
@ SKILL_MINING
Definition: SharedDefines.h:2919
@ SKILL_ENGINEERING
Definition: SharedDefines.h:2923
@ SKILL_SKINNING
Definition: SharedDefines.h:2961
@ SKILL_HERBALISM
Definition: SharedDefines.h:2915
uint32 type_flags
Definition: CreatureData.h:223

References CREATURE_TYPE_FLAG_SKIN_WITH_ENGINEERING, CREATURE_TYPE_FLAG_SKIN_WITH_HERBALISM, CREATURE_TYPE_FLAG_SKIN_WITH_MINING, SKILL_ENGINEERING, SKILL_HERBALISM, SKILL_MINING, SKILL_SKINNING, and type_flags.

Referenced by Spell::CheckCast(), and Spell::EffectSkinning().

◆ HasFlagsExtra()

bool CreatureTemplate::HasFlagsExtra ( uint32  flag) const
inline
283{ return (flags_extra & flag) != 0; }
uint32 flags_extra
Definition: CreatureData.h:246

References flags_extra.

Referenced by Creature::CanAssistTo(), Unit::DealMeleeDamage(), CreatureAI::EnterEvadeMode(), and Creature::Respawn().

◆ InitializeQueryData()

void CreatureTemplate::InitializeQueryData ( )
182{
184
185 queryData << uint32(Entry); // creature entry
186 queryData << Name;
187 queryData << uint8(0) << uint8(0) << uint8(0); // name2, name3, name4, always empty
189 queryData << IconName; // "Directions" for guard, string for Icons 2.3.0
190 queryData << uint32(type_flags); // flags
191 queryData << uint32(type); // CreatureType.dbc
192 queryData << uint32(family); // CreatureFamily.dbc
193 queryData << uint32(rank); // Creature Rank (elite, boss, etc)
194 queryData << uint32(KillCredit[0]); // new in 3.1, kill credit
195 queryData << uint32(KillCredit[1]); // new in 3.1, kill credit
196 if (GetModelByIdx(0))
197 queryData << uint32(GetModelByIdx(0)->CreatureDisplayID); // Modelid1
198 else
199 queryData << uint32(0); // Modelid1
200 if (GetModelByIdx(1))
201 queryData << uint32(GetModelByIdx(1)->CreatureDisplayID); // Modelid2
202 else
203 queryData << uint32(0); // Modelid2
204 if (GetModelByIdx(2))
205 queryData << uint32(GetModelByIdx(2)->CreatureDisplayID); // Modelid3
206 else
207 queryData << uint32(0); // Modelid3
208 if (GetModelByIdx(3))
209 queryData << uint32(GetModelByIdx(3)->CreatureDisplayID); // Modelid4
210 else
211 queryData << uint32(0); // Modelid4
212 queryData << float(ModHealth); // dmg/hp modifier
213 queryData << float(ModMana); // dmg/mana modifier
215 queryData << uint32(movementId); // CreatureMovementInfo.dbc
216}
std::uint8_t uint8
Definition: Define.h:109
std::uint32_t uint32
Definition: Define.h:107
@ SMSG_CREATURE_QUERY_RESPONSE
Definition: Opcodes.h:127
CreatureModel const * GetModelByIdx(uint32 idx) const
Definition: Creature.cpp:121
float ModHealth
Definition: CreatureData.h:237
float ModMana
Definition: CreatureData.h:238
WorldPacket queryData
Definition: CreatureData.h:248
uint32 Entry
Definition: CreatureData.h:187
uint32 type
Definition: CreatureData.h:222
uint32 rank
Definition: CreatureData.h:206
std::string SubName
Definition: CreatureData.h:192
std::string Name
Definition: CreatureData.h:191
uint32 KillCredit[MAX_KILL_CREDIT]
Definition: CreatureData.h:189
bool RacialLeader
Definition: CreatureData.h:241
uint32 family
Definition: CreatureData.h:217
uint32 movementId
Definition: CreatureData.h:242
std::string IconName
Definition: CreatureData.h:193
void Initialize(uint16 opcode, std::size_t newres=200)
Definition: WorldPacket.h:68

References Entry, family, GetModelByIdx(), IconName, WorldPacket::Initialize(), KillCredit, ModHealth, ModMana, movementId, Name, queryData, RacialLeader, rank, SMSG_CREATURE_QUERY_RESPONSE, SubName, type, and type_flags.

◆ IsExotic()

bool CreatureTemplate::IsExotic ( ) const
inline
270 {
272 }
@ CREATURE_TYPE_FLAG_TAMEABLE_EXOTIC
Definition: SharedDefines.h:2711

References CREATURE_TYPE_FLAG_TAMEABLE_EXOTIC, and type_flags.

◆ IsTameable()

bool CreatureTemplate::IsTameable ( bool  exotic) const
inline
275 {
277 return false;
278
279 // if can tame exotic then can tame any tameable
280 return exotic || (type_flags & CREATURE_TYPE_FLAG_TAMEABLE_EXOTIC) == 0;
281 }
@ CREATURE_TYPE_BEAST
Definition: SharedDefines.h:2628
@ CREATURE_TYPE_FLAG_TAMEABLE
Definition: SharedDefines.h:2695

References CREATURE_TYPE_BEAST, CREATURE_TYPE_FLAG_TAMEABLE, CREATURE_TYPE_FLAG_TAMEABLE_EXOTIC, family, type, and type_flags.

Referenced by Spell::CheckCast(), npc_commandscript::HandleNpcTameCommand(), WorldSession::HandleStableSwapPet(), WorldSession::HandleUnstablePet(), and Pet::LoadPetFromDB().

Member Data Documentation

◆ AIName

std::string CreatureTemplate::AIName

◆ BaseAttackTime

◆ BaseVariance

float CreatureTemplate::BaseVariance

◆ DamageModifier

float CreatureTemplate::DamageModifier

◆ detection_range

float CreatureTemplate::detection_range

Referenced by Creature::UpdateEntry().

◆ DifficultyEntry

◆ dmgschool

◆ dynamicflags

uint32 CreatureTemplate::dynamicflags

◆ Entry

◆ expansion

◆ faction

◆ family

◆ flags_extra

◆ GossipMenuId

◆ HoverHeight

float CreatureTemplate::HoverHeight

◆ IconName

std::string CreatureTemplate::IconName

◆ KillCredit

◆ lootid

◆ maxgold

uint32 CreatureTemplate::maxgold

Referenced by Unit::Kill().

◆ maxlevel

uint8 CreatureTemplate::maxlevel

◆ MechanicImmuneMask

uint32 CreatureTemplate::MechanicImmuneMask

◆ mingold

uint32 CreatureTemplate::mingold

Referenced by Unit::Kill().

◆ minlevel

uint8 CreatureTemplate::minlevel

◆ ModArmor

float CreatureTemplate::ModArmor

◆ Models

◆ ModExperience

float CreatureTemplate::ModExperience

Referenced by Acore::XP::Gain().

◆ ModHealth

◆ ModMana

◆ Movement

◆ movementId

uint32 CreatureTemplate::movementId

◆ MovementType

uint32 CreatureTemplate::MovementType

◆ Name

◆ npcflag

◆ PetSpellDataId

◆ pickpocketLootId

uint32 CreatureTemplate::pickpocketLootId

◆ queryData

WorldPacket CreatureTemplate::queryData

Referenced by InitializeQueryData().

◆ RacialLeader

bool CreatureTemplate::RacialLeader

◆ RangeAttackTime

uint32 CreatureTemplate::RangeAttackTime

◆ RangeVariance

float CreatureTemplate::RangeVariance

◆ rank

◆ RegenHealth

bool CreatureTemplate::RegenHealth

Referenced by Creature::UpdateEntry().

◆ resistance

◆ scale

float CreatureTemplate::scale

◆ ScriptID

uint32 CreatureTemplate::ScriptID

◆ SkinLootId

◆ speed_flight

float CreatureTemplate::speed_flight

Referenced by Creature::InitEntry().

◆ speed_run

◆ speed_swim

float CreatureTemplate::speed_swim

Referenced by Creature::InitEntry().

◆ speed_walk

◆ spells

◆ SpellSchoolImmuneMask

uint8 CreatureTemplate::SpellSchoolImmuneMask

◆ SubName

std::string CreatureTemplate::SubName

◆ trainer_class

◆ trainer_race

uint32 CreatureTemplate::trainer_race

◆ trainer_spell

uint32 CreatureTemplate::trainer_spell

◆ trainer_type

◆ type

◆ type_flags

◆ unit_class

◆ unit_flags

uint32 CreatureTemplate::unit_flags

◆ unit_flags2

uint32 CreatureTemplate::unit_flags2

Referenced by Creature::UpdateEntry().

◆ VehicleId

uint32 CreatureTemplate::VehicleId