Core/Entities: Move complex function implementations from Creature.h to Creature.cpp

This commit is contained in:
QAston committed 2013-03-04 12:41:17 +01:00
1 parent 3439084082
commit 9fd6b7ee01
3 files changed
+61 -48

No files matched your search

@@ -863,6 +863,16 @@ bool Creature::Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry,
return true;
}
void Creature::InitializeReactState()
{
if (isTotem() || isTrigger() || GetCreatureType() == CREATURE_TYPE_CRITTER || isSpiritService())
SetReactState(REACT_PASSIVE);
else
SetReactState(REACT_AGGRESSIVE);
/*else if (isCivilian())
SetReactState(REACT_DEFENSIVE);*/;
}
bool Creature::isCanTrainingOf(Player* player, bool msg) const
{
if (!isTrainer())
@@ -1213,6 +1223,12 @@ float Creature::_GetHealthMod(int32 Rank)
}
}
void Creature::LowerPlayerDamageReq(uint32 unDamage)
{
if (m_PlayerDamageReq)
m_PlayerDamageReq > unDamage ? m_PlayerDamageReq -= unDamage : m_PlayerDamageReq = 0;
}
float Creature::_GetDamageMod(int32 Rank)
{
switch (Rank) // define rates for each elite rank
@@ -1731,6 +1747,23 @@ bool Creature::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index)
return Unit::IsImmunedToSpellEffect(spellInfo, index);
}
bool Creature::isElite() const
{
if (isPet())
return false;
uint32 rank = GetCreatureTemplate()->rank;
return rank != CREATURE_ELITE_NORMAL && rank != CREATURE_ELITE_RARE;
}
bool Creature::isWorldBoss() const
{
if (isPet())
return false;
return GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_BOSS;
}
SpellInfo const* Creature::reachWithSpellAttack(Unit* victim)
{
if (!victim)
@@ -2218,6 +2251,11 @@ void Creature::SetInCombatWithZone()
}
}
uint32 Creature::GetShieldBlockValue() const //dunno mob block value
{
return (getLevel()/2 + uint32(GetStat(STAT_STRENGTH)/20));
}
void Creature::_AddCreatureSpellCooldown(uint32 spell_id, time_t end_time)
{
m_CreatureSpellCooldowns[spell_id] = end_time;
@@ -2255,6 +2293,13 @@ bool Creature::HasCategoryCooldown(uint32 spell_id) const
return(itr != m_CreatureCategoryCooldowns.end() && time_t(itr->second + (spellInfo->CategoryRecoveryTime / IN_MILLISECONDS)) > time(NULL));
}
uint32 Creature::GetCreatureSpellCooldownDelay(uint32 spellId) const
{
CreatureSpellCooldowns::const_iterator itr = m_CreatureSpellCooldowns.find(spellId);
time_t t = time(NULL);
return uint32(itr != m_CreatureSpellCooldowns.end() && itr->second > t ? itr->second - t : 0);
}
bool Creature::HasSpellCooldown(uint32 spell_id) const
{
CreatureSpellCooldowns::const_iterator itr = m_CreatureSpellCooldowns.find(spell_id);
@@ -2499,6 +2544,14 @@ void Creature::FarTeleportTo(Map* map, float X, float Y, float Z, float O)
GetMap()->AddToMap(this);
}
uint32 Creature::GetPetAutoSpellOnPos(uint8 pos) const
{
if (pos >= MAX_SPELL_CHARM || m_charmInfo->GetCharmSpell(pos)->GetType() != ACT_ENABLED)
return 0;
else
return m_charmInfo->GetCharmSpell(pos)->GetAction();
}
void Creature::SetPosition(float x, float y, float z, float o)
{
// prevent crash when a bad coord is sent by the client
+7 -47
View File
@@ -474,15 +474,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
void SetReactState(ReactStates st) { m_reactState = st; }
ReactStates GetReactState() { return m_reactState; }
bool HasReactState(ReactStates state) const { return (m_reactState == state); }
void InitializeReactState()
{
if (isTotem() || isTrigger() || GetCreatureType() == CREATURE_TYPE_CRITTER || isSpiritService())
SetReactState(REACT_PASSIVE);
else
SetReactState(REACT_AGGRESSIVE);
/*else if (isCivilian())
SetReactState(REACT_DEFENSIVE);*/;
}
void InitializeReactState();
/// @todo Rename these properly
bool isCanTrainingOf(Player* player, bool msg) const;
@@ -491,22 +483,8 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
bool canCreatureAttack(Unit const* victim, bool force = true) const;
bool IsImmunedToSpell(SpellInfo const* spellInfo); //override Unit::IsImmunedToSpell
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const; //override Unit::IsImmunedToSpellEffect
bool isElite() const
{
if (isPet())
return false;
uint32 rank = GetCreatureTemplate()->rank;
return rank != CREATURE_ELITE_NORMAL && rank != CREATURE_ELITE_RARE;
}
bool isWorldBoss() const
{
if (isPet())
return false;
return GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_BOSS;
}
bool isElite() const;
bool isWorldBoss() const;
bool IsDungeonBoss() const;
@@ -523,10 +501,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
bool SetDisableGravity(bool disable, bool packetOnly = false);
bool SetHover(bool enable);
uint32 GetShieldBlockValue() const //dunno mob block value
{
return (getLevel()/2 + uint32(GetStat(STAT_STRENGTH)/20));
}
uint32 GetShieldBlockValue() const;
SpellSchoolMask GetMeleeDamageSchoolMask() const { return m_meleeDamageSchoolMask; }
void SetMeleeDamageSchool(SpellSchools school) { m_meleeDamageSchoolMask = SpellSchoolMask(1 << school); }
@@ -536,12 +511,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
void AddCreatureSpellCooldown(uint32 spellid);
bool HasSpellCooldown(uint32 spell_id) const;
bool HasCategoryCooldown(uint32 spell_id) const;
uint32 GetCreatureSpellCooldownDelay(uint32 spellId) const
{
CreatureSpellCooldowns::const_iterator itr = m_CreatureSpellCooldowns.find(spellId);
time_t t = time(NULL);
return uint32(itr != m_CreatureSpellCooldowns.end() && itr->second > t ? itr->second - t : 0);
}
uint32 GetCreatureSpellCooldownDelay(uint32 spellId) const;
virtual void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs);
bool HasSpell(uint32 spellID) const;
@@ -671,13 +641,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
bool isRegeneratingHealth() { return m_regenHealth; }
void setRegeneratingHealth(bool regenHealth) { m_regenHealth = regenHealth; }
virtual uint8 GetPetAutoSpellSize() const { return MAX_SPELL_CHARM; }
virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const
{
if (pos >= MAX_SPELL_CHARM || m_charmInfo->GetCharmSpell(pos)->GetType() != ACT_ENABLED)
return 0;
else
return m_charmInfo->GetCharmSpell(pos)->GetAction();
}
virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const;
void SetPosition(float x, float y, float z, float o);
void SetPosition(const Position &pos) { SetPosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()); }
@@ -707,11 +671,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
void SetDisableReputationGain(bool disable) { DisableReputationGain = disable; }
bool IsReputationGainDisabled() { return DisableReputationGain; }
bool IsDamageEnoughForLootingAndReward() const { return m_PlayerDamageReq == 0; }
void LowerPlayerDamageReq(uint32 unDamage)
{
if (m_PlayerDamageReq)
m_PlayerDamageReq > unDamage ? m_PlayerDamageReq -= unDamage : m_PlayerDamageReq = 0;
}
void LowerPlayerDamageReq(uint32 unDamage);
void ResetPlayerDamageReq() { m_PlayerDamageReq = GetHealth() / 2; }
uint32 m_PlayerDamageReq;
+1 -1
View File
@@ -1443,7 +1443,7 @@ void WorldObject::_Create(uint32 guidlow, HighGuid guidhigh, uint32 phaseMask)
m_phaseMask = phaseMask;
}
virtual void WorldObject::RemoveFromWorld()
void WorldObject::RemoveFromWorld()
{
if (!IsInWorld())
return;