aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities/Creature
diff options
context:
space:
mode:
authorQAston <qaston@gmail.com>2011-07-26 23:09:28 +0200
committerQAston <qaston@gmail.com>2011-07-26 23:09:28 +0200
commitb0fe236265465a0f39aa98a8cee2916d1ccfaa02 (patch)
tree77ed4bde46de983c280a542d657a30b24865638c /src/server/game/Entities/Creature
parent29c228a80170e4264129d4e3bed4d2fc41aca5a7 (diff)
Core: Use new SpellInfo class in core. Sadly, this commit is not compatibile with some of the custom code. To make your code work again you may need to change:
*SpellEntry is now SpellInfo *GetSpellProto is now GetSpellInfo *SpellEntry::Effect*[effIndex] is now avalible under SpellInfo.Effects[effIndex].* *sSpellStore.LookupEntry is no longer valid, use sSpellMgr->GetSpellInfo() *SpellFunctions from SpellMgr.h like DoSpellStuff(spellId) are now: spellInfo->DoStuff() *SpellMgr::CalculateEffectValue and similar functions are now avalible in SpellEffectInfo class. *GET_SPELL macro is removed, code which used it is moved to SpellMgr::LoadDbcDataCorrections *code which affected dbc data in SpellMgr::LoadSpellCustomAttr is now moved to LoadDbcDataCorrections
Diffstat (limited to 'src/server/game/Entities/Creature')
-rwxr-xr-xsrc/server/game/Entities/Creature/Creature.cpp51
-rwxr-xr-xsrc/server/game/Entities/Creature/Creature.h10
2 files changed, 29 insertions, 32 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index 6b53576cb19..40445dbc8fd 100755
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -1641,7 +1641,7 @@ void Creature::DespawnOrUnsummon(uint32 msTimeToDespawn /*= 0*/)
ForcedDespawn(msTimeToDespawn);
}
-bool Creature::IsImmunedToSpell(SpellEntry const* spellInfo)
+bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo)
{
if (!spellInfo)
return false;
@@ -1652,18 +1652,18 @@ bool Creature::IsImmunedToSpell(SpellEntry const* spellInfo)
return Unit::IsImmunedToSpell(spellInfo);
}
-bool Creature::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const
+bool Creature::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const
{
- if (GetCreatureInfo()->MechanicImmuneMask & (1 << (spellInfo->EffectMechanic[index] - 1)))
+ if (GetCreatureInfo()->MechanicImmuneMask & (1 << (spellInfo->Effects[index].Mechanic - 1)))
return true;
- if (GetCreatureInfo()->type == CREATURE_TYPE_MECHANICAL && spellInfo->Effect[index] == SPELL_EFFECT_HEAL)
+ if (GetCreatureInfo()->type == CREATURE_TYPE_MECHANICAL && spellInfo->Effects[index].Effect == SPELL_EFFECT_HEAL)
return true;
return Unit::IsImmunedToSpellEffect(spellInfo, index);
}
-SpellEntry const *Creature::reachWithSpellAttack(Unit *pVictim)
+SpellInfo const *Creature::reachWithSpellAttack(Unit *pVictim)
{
if (!pVictim)
return NULL;
@@ -1672,7 +1672,7 @@ SpellEntry const *Creature::reachWithSpellAttack(Unit *pVictim)
{
if (!m_spells[i])
continue;
- SpellEntry const *spellInfo = sSpellStore.LookupEntry(m_spells[i]);
+ SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(m_spells[i]);
if (!spellInfo)
{
sLog->outError("WORLD: unknown spell id %i", m_spells[i]);
@@ -1682,10 +1682,10 @@ SpellEntry const *Creature::reachWithSpellAttack(Unit *pVictim)
bool bcontinue = true;
for (uint32 j = 0; j < MAX_SPELL_EFFECTS; j++)
{
- if ((spellInfo->Effect[j] == SPELL_EFFECT_SCHOOL_DAMAGE) ||
- (spellInfo->Effect[j] == SPELL_EFFECT_INSTAKILL) ||
- (spellInfo->Effect[j] == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE) ||
- (spellInfo->Effect[j] == SPELL_EFFECT_HEALTH_LEECH)
+ if ((spellInfo->Effects[j].Effect == SPELL_EFFECT_SCHOOL_DAMAGE) ||
+ (spellInfo->Effects[j].Effect == SPELL_EFFECT_INSTAKILL) ||
+ (spellInfo->Effects[j].Effect == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE) ||
+ (spellInfo->Effects[j].Effect == SPELL_EFFECT_HEALTH_LEECH)
)
{
bcontinue = false;
@@ -1694,14 +1694,11 @@ SpellEntry const *Creature::reachWithSpellAttack(Unit *pVictim)
}
if (bcontinue) continue;
- if (spellInfo->manaCost > GetPower(POWER_MANA))
+ if (spellInfo->ManaCost > GetPower(POWER_MANA))
continue;
- SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex);
- float range = GetSpellMaxRangeForHostile(srange);
- float minrange = GetSpellMinRangeForHostile(srange);
+ float range = spellInfo->GetMaxRange(false);
+ float minrange = spellInfo->GetMinRange(false);
float dist = GetDistance(pVictim);
- //if (!isInFront(pVictim, range) && spellInfo->AttributesEx)
- // continue;
if (dist > range || dist < minrange)
continue;
if (spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED))
@@ -1713,7 +1710,7 @@ SpellEntry const *Creature::reachWithSpellAttack(Unit *pVictim)
return NULL;
}
-SpellEntry const *Creature::reachWithSpellCure(Unit *pVictim)
+SpellInfo const *Creature::reachWithSpellCure(Unit *pVictim)
{
if (!pVictim)
return NULL;
@@ -1722,7 +1719,7 @@ SpellEntry const *Creature::reachWithSpellCure(Unit *pVictim)
{
if (!m_spells[i])
continue;
- SpellEntry const *spellInfo = sSpellStore.LookupEntry(m_spells[i]);
+ SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(m_spells[i]);
if (!spellInfo)
{
sLog->outError("WORLD: unknown spell id %i", m_spells[i]);
@@ -1732,7 +1729,7 @@ SpellEntry const *Creature::reachWithSpellCure(Unit *pVictim)
bool bcontinue = true;
for (uint32 j = 0; j < MAX_SPELL_EFFECTS; j++)
{
- if ((spellInfo->Effect[j] == SPELL_EFFECT_HEAL))
+ if ((spellInfo->Effects[j].Effect == SPELL_EFFECT_HEAL))
{
bcontinue = false;
break;
@@ -1740,11 +1737,11 @@ SpellEntry const *Creature::reachWithSpellCure(Unit *pVictim)
}
if (bcontinue) continue;
- if (spellInfo->manaCost > GetPower(POWER_MANA))
+ if (spellInfo->ManaCost > GetPower(POWER_MANA))
continue;
- SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex);
- float range = GetSpellMaxRangeForFriend(srange);
- float minrange = GetSpellMinRangeForFriend(srange);
+
+ float range = spellInfo->GetMaxRange(true);
+ float minrange = spellInfo->GetMinRange(true);
float dist = GetDistance(pVictim);
//if (!isInFront(pVictim, range) && spellInfo->AttributesEx)
// continue;
@@ -2075,7 +2072,7 @@ bool Creature::LoadCreaturesAddon(bool reload)
{
for (std::vector<uint32>::const_iterator itr = cainfo->auras.begin(); itr != cainfo->auras.end(); ++itr)
{
- SpellEntry const *AdditionalSpellInfo = sSpellStore.LookupEntry(*itr);
+ SpellInfo const *AdditionalSpellInfo = sSpellMgr->GetSpellInfo(*itr);
if (!AdditionalSpellInfo)
{
sLog->outErrorDb("Creature (GUID: %u Entry: %u) has wrong spell %u defined in `auras` field.", GetGUIDLow(), GetEntry(), *itr);
@@ -2158,11 +2155,11 @@ void Creature::_AddCreatureCategoryCooldown(uint32 category, time_t apply_time)
void Creature::AddCreatureSpellCooldown(uint32 spellid)
{
- SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellid);
+ SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(spellid);
if (!spellInfo)
return;
- uint32 cooldown = GetSpellRecoveryTime(spellInfo);
+ uint32 cooldown = spellInfo->GetRecoveryTime();
if (Player *modOwner = GetSpellModOwner())
modOwner->ApplySpellMod(spellid, SPELLMOD_COOLDOWN, cooldown);
@@ -2175,7 +2172,7 @@ void Creature::AddCreatureSpellCooldown(uint32 spellid)
bool Creature::HasCategoryCooldown(uint32 spell_id) const
{
- SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id);
+ SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(spell_id);
if (!spellInfo)
return false;
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index 3a5b2d1c5d1..9c3c0c4585e 100755
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -29,7 +29,7 @@
#include <list>
-struct SpellEntry;
+class SpellInfo;
class CreatureAI;
class Quest;
@@ -458,9 +458,9 @@ class Creature : public Unit, public GridObject<Creature>
bool isCanInteractWithBattleMaster(Player* player, bool msg) const;
bool isCanTrainingAndResetTalentsOf(Player* pPlayer) const;
bool canCreatureAttack(Unit const *pVictim, bool force = true) const;
- bool IsImmunedToSpell(SpellEntry const* spellInfo);
+ bool IsImmunedToSpell(SpellInfo const* spellInfo);
// redefine Unit::IsImmunedToSpell
- bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const;
+ bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const;
// redefine Unit::IsImmunedToSpellEffect
bool isElite() const
{
@@ -570,8 +570,8 @@ class Creature : public Unit, public GridObject<Creature>
void RemoveLootMode(uint16 lootMode) { m_LootMode &= ~lootMode; }
void ResetLootMode() { m_LootMode = LOOT_MODE_DEFAULT; }
- SpellEntry const *reachWithSpellAttack(Unit *pVictim);
- SpellEntry const *reachWithSpellCure(Unit *pVictim);
+ SpellInfo const *reachWithSpellAttack(Unit *pVictim);
+ SpellInfo const *reachWithSpellCure(Unit *pVictim);
uint32 m_spells[CREATURE_MAX_SPELLS];
CreatureSpellCooldowns m_CreatureSpellCooldowns;