diff options
| author | QAston <qaston@gmail.com> | 2011-07-26 23:09:28 +0200 |
|---|---|---|
| committer | QAston <qaston@gmail.com> | 2011-07-26 23:09:28 +0200 |
| commit | b0fe236265465a0f39aa98a8cee2916d1ccfaa02 (patch) | |
| tree | 77ed4bde46de983c280a542d657a30b24865638c /src/server/game/AI/EventAI | |
| parent | 29c228a80170e4264129d4e3bed4d2fc41aca5a7 (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/AI/EventAI')
| -rwxr-xr-x | src/server/game/AI/EventAI/CreatureEventAI.cpp | 16 | ||||
| -rwxr-xr-x | src/server/game/AI/EventAI/CreatureEventAI.h | 4 | ||||
| -rwxr-xr-x | src/server/game/AI/EventAI/CreatureEventAIMgr.cpp | 16 |
3 files changed, 16 insertions, 20 deletions
diff --git a/src/server/game/AI/EventAI/CreatureEventAI.cpp b/src/server/game/AI/EventAI/CreatureEventAI.cpp index f49df99554f..fa2c0e3856b 100755 --- a/src/server/game/AI/EventAI/CreatureEventAI.cpp +++ b/src/server/game/AI/EventAI/CreatureEventAI.cpp @@ -463,7 +463,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 if (canCast) { - const SpellEntry* tSpell = GetSpellStore()->LookupEntry(action.cast.spellId); + const SpellInfo* tSpell = sSpellMgr->GetSpellInfo(action.cast.spellId); //Verify that spell exists if (tSpell) @@ -1047,7 +1047,7 @@ void CreatureEventAI::MoveInLineOfSight(Unit *who) CreatureAI::MoveInLineOfSight(who); } -void CreatureEventAI::SpellHit(Unit* pUnit, const SpellEntry* pSpell) +void CreatureEventAI::SpellHit(Unit* pUnit, const SpellInfo* pSpell) { if (m_bEmptyList) @@ -1304,7 +1304,7 @@ void CreatureEventAI::DoScriptText(int32 textEntry, WorldObject* pSource, Unit* } } -bool CreatureEventAI::CanCast(Unit* Target, SpellEntry const *Spell, bool Triggered) +bool CreatureEventAI::CanCast(Unit* Target, SpellInfo const *Spell, bool Triggered) { //No target so we can't cast if (!Target || !Spell) @@ -1315,17 +1315,11 @@ bool CreatureEventAI::CanCast(Unit* Target, SpellEntry const *Spell, bool Trigge return false; //Check for power - if (!Triggered && me->GetPower((Powers)Spell->powerType) < CalculatePowerCost(Spell, me, GetSpellSchoolMask(Spell))) - return false; - - SpellRangeEntry const* tempRange = sSpellRangeStore.LookupEntry(Spell->rangeIndex); - - //Spell has invalid range store so we can't use it - if (!tempRange) + if (!Triggered && me->GetPower((Powers)Spell->PowerType) < Spell->CalcPowerCost(me, Spell->GetSchoolMask())) return false; //Unit is out of range of this spell - if (!me->IsInRange(Target, tempRange->minRangeHostile, tempRange->maxRangeHostile)) + if (!me->IsInRange(Target, Spell->GetMinRange(false), Spell->GetMinRange(true))) return false; return true; diff --git a/src/server/game/AI/EventAI/CreatureEventAI.h b/src/server/game/AI/EventAI/CreatureEventAI.h index 779e0d5ce37..7df0dc2d30d 100755 --- a/src/server/game/AI/EventAI/CreatureEventAI.h +++ b/src/server/game/AI/EventAI/CreatureEventAI.h @@ -606,7 +606,7 @@ class CreatureEventAI : public CreatureAI void JustSummoned(Creature* pUnit); void AttackStart(Unit *who); void MoveInLineOfSight(Unit *who); - void SpellHit(Unit* pUnit, const SpellEntry* pSpell); + void SpellHit(Unit* pUnit, const SpellInfo* pSpell); void DamageTaken(Unit* done_by, uint32& damage); void HealReceived(Unit* /*done_by*/, uint32& /*addhealth*/) {} void UpdateAI(const uint32 diff); @@ -620,7 +620,7 @@ class CreatureEventAI : public CreatureAI inline Unit* GetTargetByType(uint32 Target, Unit* pActionInvoker); void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target); - bool CanCast(Unit* Target, SpellEntry const *Spell, bool Triggered); + bool CanCast(Unit* Target, SpellInfo const *Spell, bool Triggered); bool SpawnedEventConditionsCheck(CreatureEventAI_Event const& event); diff --git a/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp b/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp index c38b7159e5a..3f1b2d71da1 100755 --- a/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp +++ b/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp @@ -24,6 +24,8 @@ #include "ObjectDefines.h" #include "GridDefines.h" #include "ConditionMgr.h" +#include "SpellMgr.h" +#include "SpellInfo.h" // ------------------- void CreatureEventAIMgr::LoadCreatureEventAI_Texts() @@ -248,7 +250,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() case EVENT_T_SPELLHIT: if (temp.spell_hit.spellId) { - SpellEntry const* pSpell = sSpellStore.LookupEntry(temp.spell_hit.spellId); + SpellInfo const* pSpell = sSpellMgr->GetSpellInfo(temp.spell_hit.spellId); if (!pSpell) { sLog->outErrorDb("CreatureEventAI: Creature %u has non-existant SpellID(%u) defined in event %u.", temp.creature_id, temp.spell_hit.spellId, i); @@ -302,7 +304,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() break; case EVENT_T_FRIENDLY_MISSING_BUFF: { - SpellEntry const* pSpell = sSpellStore.LookupEntry(temp.spell_hit.spellId); + SpellInfo const* pSpell = sSpellMgr->GetSpellInfo(temp.spell_hit.spellId); if (!pSpell) { sLog->outErrorDb("CreatureEventAI: Creature %u has non-existant SpellID(%u) defined in event %u.", temp.creature_id, temp.spell_hit.spellId, i); @@ -379,7 +381,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() case EVENT_T_BUFFED: case EVENT_T_TARGET_BUFFED: { - SpellEntry const* pSpell = sSpellStore.LookupEntry(temp.buffed.spellId); + SpellInfo const* pSpell = sSpellMgr->GetSpellInfo(temp.buffed.spellId); if (!pSpell) { sLog->outErrorDb("CreatureEventAI: Creature %u has non-existant SpellID(%u) defined in event %u.", temp.creature_id, temp.spell_hit.spellId, i); @@ -499,7 +501,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() break; case ACTION_T_CAST: { - const SpellEntry *spell = sSpellStore.LookupEntry(action.cast.spellId); + const SpellInfo *spell = sSpellMgr->GetSpellInfo(action.cast.spellId); if (!spell) sLog->outErrorDb("CreatureEventAI: Event %u Action %u uses non-existent SpellID %u.", i, j+1, action.cast.spellId); /* FIXME: temp.raw.param3 not have event tipes with recovery time in it.... @@ -555,7 +557,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() case ACTION_T_CAST_EVENT: if (!sObjectMgr->GetCreatureTemplate(action.cast_event.creatureId)) sLog->outErrorDb("CreatureEventAI: Event %u Action %u uses non-existent creature entry %u.", i, j+1, action.cast_event.creatureId); - if (!sSpellStore.LookupEntry(action.cast_event.spellId)) + if (!sSpellMgr->GetSpellInfo(action.cast_event.spellId)) sLog->outErrorDb("CreatureEventAI: Event %u Action %u uses non-existent SpellID %u.", i, j+1, action.cast_event.spellId); if (action.cast_event.target >= TARGET_T_END) sLog->outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); @@ -593,11 +595,11 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() case ACTION_T_CAST_EVENT_ALL: if (!sObjectMgr->GetCreatureTemplate(action.cast_event_all.creatureId)) sLog->outErrorDb("CreatureEventAI: Event %u Action %u uses non-existent creature entry %u.", i, j+1, action.cast_event_all.creatureId); - if (!sSpellStore.LookupEntry(action.cast_event_all.spellId)) + if (!sSpellMgr->GetSpellInfo(action.cast_event_all.spellId)) sLog->outErrorDb("CreatureEventAI: Event %u Action %u uses non-existent SpellID %u.", i, j+1, action.cast_event_all.spellId); break; case ACTION_T_REMOVEAURASFROMSPELL: - if (!sSpellStore.LookupEntry(action.remove_aura.spellId)) + if (!sSpellMgr->GetSpellInfo(action.remove_aura.spellId)) sLog->outErrorDb("CreatureEventAI: Event %u Action %u uses non-existent SpellID %u.", i, j+1, action.remove_aura.spellId); if (action.remove_aura.target >= TARGET_T_END) sLog->outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); |
