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
163{
164 for (CreatureModel const& model : Models)
165 if (CreatureModelInfo const* modelInfo = sObjectMgr->GetCreatureModelInfo(model.CreatureDisplayID))
166 if (modelInfo && modelInfo->is_trigger)
167 return &model;
168
170}
#define sObjectMgr
Definition: ObjectMgr.h:1623
Models
Definition: boss_black_knight.cpp:95
Definition: CreatureData.h:172
static CreatureModel const DefaultInvisibleModel
Definition: CreatureData.h:173
Definition: CreatureData.h:401

References CreatureModel::DefaultInvisibleModel, and sObjectMgr.

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

◆ GetFirstValidModel()

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

Referenced by Creature::InitEntry().

◆ GetFirstVisibleModel()

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

References CreatureModel::DefaultVisibleModel, and sObjectMgr.

Referenced by Unit::PatchValuesUpdate().

◆ GetModelByIdx()

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

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

◆ GetModelWithDisplayId()

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

Referenced by ObjectMgr::ChooseDisplayId().

◆ GetRandomValidModel()

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

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

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

◆ GetRequiredLootSkill()

SkillType CreatureTemplate::GetRequiredLootSkill ( ) const
inline
261 {
263 return SKILL_HERBALISM;
265 return SKILL_MINING;
267 return SKILL_ENGINEERING;
268 else
269 return SKILL_SKINNING; // normal case
270 }
@ 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:226

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
286{ return (flags_extra & flag) != 0; }
uint32 flags_extra
Definition: CreatureData.h:249

References flags_extra.

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

◆ InitializeQueryData()

void CreatureTemplate::InitializeQueryData ( )
183{
185
186 queryData << uint32(Entry); // creature entry
187 queryData << Name;
188 queryData << uint8(0) << uint8(0) << uint8(0); // name2, name3, name4, always empty
190 queryData << IconName; // "Directions" for guard, string for Icons 2.3.0
191 queryData << uint32(type_flags); // flags
192 queryData << uint32(type); // CreatureType.dbc
193 queryData << uint32(family); // CreatureFamily.dbc
194 queryData << uint32(rank); // Creature Rank (elite, boss, etc)
195 queryData << uint32(KillCredit[0]); // new in 3.1, kill credit
196 queryData << uint32(KillCredit[1]); // new in 3.1, kill credit
197 if (GetModelByIdx(0))
198 queryData << uint32(GetModelByIdx(0)->CreatureDisplayID); // Modelid1
199 else
200 queryData << uint32(0); // Modelid1
201 if (GetModelByIdx(1))
202 queryData << uint32(GetModelByIdx(1)->CreatureDisplayID); // Modelid2
203 else
204 queryData << uint32(0); // Modelid2
205 if (GetModelByIdx(2))
206 queryData << uint32(GetModelByIdx(2)->CreatureDisplayID); // Modelid3
207 else
208 queryData << uint32(0); // Modelid3
209 if (GetModelByIdx(3))
210 queryData << uint32(GetModelByIdx(3)->CreatureDisplayID); // Modelid4
211 else
212 queryData << uint32(0); // Modelid4
213 queryData << float(ModHealth); // dmg/hp modifier
214 queryData << float(ModMana); // dmg/mana modifier
216 queryData << uint32(movementId); // CreatureMovementInfo.dbc
217}
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:122
float ModHealth
Definition: CreatureData.h:240
float ModMana
Definition: CreatureData.h:241
WorldPacket queryData
Definition: CreatureData.h:251
uint32 Entry
Definition: CreatureData.h:190
uint32 type
Definition: CreatureData.h:225
uint32 rank
Definition: CreatureData.h:209
std::string SubName
Definition: CreatureData.h:195
std::string Name
Definition: CreatureData.h:194
uint32 KillCredit[MAX_KILL_CREDIT]
Definition: CreatureData.h:192
bool RacialLeader
Definition: CreatureData.h:244
uint32 family
Definition: CreatureData.h:220
uint32 movementId
Definition: CreatureData.h:245
std::string IconName
Definition: CreatureData.h:196
void Initialize(uint16 opcode, std::size_t newres=200)
Definition: WorldPacket.h:69

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
273 {
275 }
@ 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
278 {
280 return false;
281
282 // if can tame exotic then can tame any tameable
283 return exotic || (type_flags & CREATURE_TYPE_FLAG_TAMEABLE_EXOTIC) == 0;
284 }
@ 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