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
This commit is contained in:
QAston
2011-07-26 23:09:28 +02:00
parent 29c228a801
commit b0fe236265
195 changed files with 4630 additions and 6929 deletions
+9 -5
View File
@@ -18,6 +18,7 @@
#include "CombatAI.h"
#include "SpellMgr.h"
#include "SpellInfo.h"
#include "Vehicle.h"
#include "ObjectAccessor.h"
@@ -62,7 +63,7 @@ int VehicleAI::Permissible(const Creature* /*creature*/)
void CombatAI::InitializeAI()
{
for (uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i)
if (me->m_spells[i] && GetSpellStore()->LookupEntry(me->m_spells[i]))
if (me->m_spells[i] && sSpellMgr->GetSpellInfo(me->m_spells[i]))
spells.push_back(me->m_spells[i]);
CreatureAI::InitializeAI();
@@ -177,10 +178,12 @@ ArcherAI::ArcherAI(Creature *c) : CreatureAI(c)
if (!me->m_spells[0])
sLog->outError("ArcherAI set for creature (entry = %u) with spell1=0. AI will do nothing", me->GetEntry());
m_minRange = GetSpellMinRange(me->m_spells[0], false);
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(me->m_spells[0]);
m_minRange = spellInfo ? spellInfo->GetMinRange(false) : 0;
if (!m_minRange)
m_minRange = MELEE_RANGE;
me->m_CombatDistance = GetSpellMaxRange(me->m_spells[0], false);
me->m_CombatDistance = spellInfo ? spellInfo->GetMaxRange(false) : 0;
me->m_SightDistance = me->m_CombatDistance;
}
@@ -224,8 +227,9 @@ TurretAI::TurretAI(Creature *c) : CreatureAI(c)
if (!me->m_spells[0])
sLog->outError("TurretAI set for creature (entry = %u) with spell1=0. AI will do nothing", me->GetEntry());
m_minRange = GetSpellMinRange(me->m_spells[0], false);
me->m_CombatDistance = GetSpellMaxRange(me->m_spells[0], false);
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(me->m_spells[0]);
m_minRange = spellInfo ? spellInfo->GetMinRange(false) : 0;
me->m_CombatDistance = spellInfo ? spellInfo->GetMaxRange(false) : 0;
me->m_SightDistance = me->m_CombatDistance;
}
+8 -7
View File
@@ -28,6 +28,7 @@
#include "World.h"
#include "Util.h"
#include "Group.h"
#include "SpellInfo.h"
int PetAI::Permissible(const Creature *creature)
{
@@ -133,7 +134,7 @@ void PetAI::UpdateAI(const uint32 diff)
if (!spellID)
continue;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellID);
SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(spellID);
if (!spellInfo)
continue;
@@ -144,21 +145,21 @@ void PetAI::UpdateAI(const uint32 diff)
if (!me->getVictim())
{
// ignore attacking spells, and allow only self/around spells
if (!IsPositiveSpell(spellInfo->Id))
if (!spellInfo->IsPositive())
continue;
// non combat spells allowed
// only pet spells have IsNonCombatSpell and not fit this reqs:
// Consume Shadows, Lesser Invisibility, so ignore checks for its
if (!IsNonCombatSpell(spellInfo))
if (spellInfo->CanBeUsedInCombat())
{
// allow only spell without spell cost or with spell cost but not duration limit
int32 duration = GetSpellDuration(spellInfo);
if ((spellInfo->manaCost || spellInfo->ManaCostPercentage || spellInfo->manaPerSecond) && duration > 0)
int32 duration = spellInfo->GetDuration();
if ((spellInfo->ManaCost || spellInfo->ManaCostPercentage || spellInfo->ManaPerSecond) && duration > 0)
continue;
// allow only spell without cooldown > duration
int32 cooldown = GetSpellRecoveryTime(spellInfo);
int32 cooldown = spellInfo->GetRecoveryTime();
if (cooldown >= 0 && duration >= 0 && cooldown > duration)
continue;
}
@@ -166,7 +167,7 @@ void PetAI::UpdateAI(const uint32 diff)
else
{
// just ignore non-combat spells
if (IsNonCombatSpell(spellInfo))
if (!spellInfo->CanBeUsedInCombat())
continue;
}
+2 -3
View File
@@ -61,13 +61,12 @@ TotemAI::UpdateAI(const uint32 /*diff*/)
return;
// Search spell
SpellEntry const *spellInfo = sSpellStore.LookupEntry(me->ToTotem()->GetSpell());
SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(me->ToTotem()->GetSpell());
if (!spellInfo)
return;
// Get spell range
SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex);
float max_range = GetSpellMaxRangeForHostile(srange);
float max_range = spellInfo->GetMaxRange(false);
// SPELLMOD_RANGE not applied in this place just because not existence range mods for attacking totems
+25 -20
View File
@@ -22,6 +22,7 @@
#include "SpellAuras.h"
#include "SpellAuraEffects.h"
#include "SpellMgr.h"
#include "SpellInfo.h"
#include "CreatureAIImpl.h"
void UnitAI::AttackStart(Unit* victim)
@@ -69,10 +70,15 @@ bool UnitAI::DoSpellAttackIfReady(uint32 spell)
if (me->isAttackReady())
{
if (me->IsWithinCombatRange(me->getVictim(), GetSpellMaxRange(spell, false)))
if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell))
{
me->CastSpell(me->getVictim(), spell, false);
me->resetAttackTimer();
if (me->IsWithinCombatRange(me->getVictim(), spellInfo->GetMaxRange(false)))
{
me->CastSpell(me->getVictim(), spell, false);
me->resetAttackTimer();
}
else
return false;
}
else
return false;
@@ -92,7 +98,8 @@ void UnitAI::SelectTargetList(std::list<Unit*> &targetList, uint32 num, SelectAg
float UnitAI::DoGetSpellMaxRange(uint32 spellId, bool positive)
{
return GetSpellMaxRange(spellId, positive);
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
return spellInfo ? spellInfo->GetMaxRange(positive) : 0;
}
void UnitAI::DoAddAuraToAllHostilePlayers(uint32 spellid)
@@ -136,19 +143,19 @@ void UnitAI::DoCast(uint32 spellId)
case AITARGET_VICTIM: target = me->getVictim(); break;
case AITARGET_ENEMY:
{
const SpellEntry * spellInfo = GetSpellStore()->LookupEntry(spellId);
const SpellInfo * spellInfo = sSpellMgr->GetSpellInfo(spellId);
bool playerOnly = spellInfo->AttributesEx3 & SPELL_ATTR3_PLAYERS_ONLY;
//float range = GetSpellMaxRange(spellInfo, false);
target = SelectTarget(SELECT_TARGET_RANDOM, 0, GetSpellMaxRange(spellInfo, false), playerOnly);
target = SelectTarget(SELECT_TARGET_RANDOM, 0, spellInfo->GetMaxRange(false), playerOnly);
break;
}
case AITARGET_ALLY: target = me; break;
case AITARGET_BUFF: target = me; break;
case AITARGET_DEBUFF:
{
const SpellEntry * spellInfo = GetSpellStore()->LookupEntry(spellId);
const SpellInfo * spellInfo = sSpellMgr->GetSpellInfo(spellId);
bool playerOnly = spellInfo->AttributesEx3 & SPELL_ATTR3_PLAYERS_ONLY;
float range = GetSpellMaxRange(spellInfo, false);
float range = spellInfo->GetMaxRange(false);
DefaultTargetSelector targetSelector(me, range, playerOnly, -(int32)spellId);
if (!(spellInfo->Attributes & SPELL_ATTR0_BREAKABLE_BY_DAMAGE)
@@ -169,20 +176,20 @@ void UnitAI::DoCast(uint32 spellId)
void UnitAI::FillAISpellInfo()
{
AISpellInfo = new AISpellInfoType[GetSpellStore()->GetNumRows()];
AISpellInfo = new AISpellInfoType[sSpellMgr->GetSpellInfoStoreSize()];
AISpellInfoType *AIInfo = AISpellInfo;
const SpellEntry * spellInfo;
const SpellInfo * spellInfo;
for (uint32 i = 0; i < GetSpellStore()->GetNumRows(); ++i, ++AIInfo)
for (uint32 i = 0; i < sSpellMgr->GetSpellInfoStoreSize(); ++i, ++AIInfo)
{
spellInfo = GetSpellStore()->LookupEntry(i);
spellInfo = sSpellMgr->GetSpellInfo(i);
if (!spellInfo)
continue;
if (spellInfo->Attributes & SPELL_ATTR0_CASTABLE_WHILE_DEAD)
AIInfo->condition = AICOND_DIE;
else if (IsPassiveSpell(i) || GetSpellDuration(spellInfo) == -1)
else if (spellInfo->IsPassive() || spellInfo->GetDuration() == -1)
AIInfo->condition = AICOND_AGGRO;
else
AIInfo->condition = AICOND_COMBAT;
@@ -190,13 +197,13 @@ void UnitAI::FillAISpellInfo()
if (AIInfo->cooldown < spellInfo->RecoveryTime)
AIInfo->cooldown = spellInfo->RecoveryTime;
if (!GetSpellMaxRange(spellInfo, false))
if (!spellInfo->GetMaxRange(false))
UPDATE_TARGET(AITARGET_SELF)
else
{
for (uint32 j = 0; j < MAX_SPELL_EFFECTS; ++j)
{
uint32 targetType = spellInfo->EffectImplicitTargetA[j];
uint32 targetType = spellInfo->Effects[j].TargetA;
if (targetType == TARGET_UNIT_TARGET_ENEMY
|| targetType == TARGET_DST_TARGET_ENEMY)
@@ -204,19 +211,17 @@ void UnitAI::FillAISpellInfo()
else if (targetType == TARGET_UNIT_AREA_ENEMY_DST)
UPDATE_TARGET(AITARGET_ENEMY)
if (spellInfo->Effect[j] == SPELL_EFFECT_APPLY_AURA)
if (spellInfo->Effects[j].Effect == SPELL_EFFECT_APPLY_AURA)
{
if (targetType == TARGET_UNIT_TARGET_ENEMY)
UPDATE_TARGET(AITARGET_DEBUFF)
else if (IsPositiveSpell(i))
else if (spellInfo->IsPositive())
UPDATE_TARGET(AITARGET_BUFF)
}
}
}
AIInfo->realCooldown = spellInfo->RecoveryTime + spellInfo->StartRecoveryTime;
SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex);
if (srange)
AIInfo->maxRange = srange->maxRangeHostile * 3 / 4;
AIInfo->maxRange = spellInfo->GetMaxRange(false) * 3 / 4;
}
}
+3 -3
View File
@@ -27,7 +27,7 @@ class WorldObject;
class Unit;
class Creature;
class Player;
struct SpellEntry;
class SpellInfo;
#define TIME_INTERVAL_LOOK 5000
#define VISIBILITY_RANGE 10000
@@ -111,10 +111,10 @@ class CreatureAI : public UnitAI
virtual void SummonedCreatureDies(Creature* /*summon*/, Unit* /*killer*/) {}
// Called when hit by a spell
virtual void SpellHit(Unit* /*caster*/, SpellEntry const* /*spell*/) {}
virtual void SpellHit(Unit* /*caster*/, SpellInfo const* /*spell*/) {}
// Called when spell hits a target
virtual void SpellHitTarget(Unit* /*target*/, SpellEntry const* /*spell*/) {}
virtual void SpellHitTarget(Unit* /*target*/, SpellInfo const* /*spell*/) {}
// Called when the creature is target of hostile action: swing, hostile spell landed, fear/etc)
//virtual void AttackedBy(Unit* attacker);
+5 -11
View File
@@ -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;
+2 -2
View File
@@ -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);
@@ -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);
@@ -164,7 +164,7 @@ void ScriptedAI::DoStopAttack()
me->AttackStop();
}
void ScriptedAI::DoCastSpell(Unit* pTarget, SpellEntry const* pSpellInfo, bool bTriggered)
void ScriptedAI::DoCastSpell(Unit* pTarget, SpellInfo const* pSpellInfo, bool bTriggered)
{
if (!pTarget || me->IsNonMeleeSpellCasted(false))
return;
@@ -192,7 +192,7 @@ Creature* ScriptedAI::DoSpawnCreature(uint32 entry, float offsetX, float offsetY
return me->SummonCreature(entry, me->GetPositionX() + offsetX, me->GetPositionY() + offsetY, me->GetPositionZ() + offsetZ, angle, TempSummonType(type), despawntime);
}
SpellEntry const* ScriptedAI::SelectSpell(Unit* target, uint32 school, uint32 mechanic, SelectTargetType targets, uint32 powerCostMin, uint32 powerCostMax, float rangeMin, float rangeMax, SelectEffect effects)
SpellInfo const* ScriptedAI::SelectSpell(Unit* target, uint32 school, uint32 mechanic, SelectTargetType targets, uint32 powerCostMin, uint32 powerCostMax, float rangeMin, float rangeMax, SelectEffect effects)
{
//No target so we can't cast
if (!target)
@@ -203,18 +203,18 @@ SpellEntry const* ScriptedAI::SelectSpell(Unit* target, uint32 school, uint32 me
return false;
//Using the extended script system we first create a list of viable spells
SpellEntry const* apSpell[CREATURE_MAX_SPELLS];
memset(apSpell, 0, CREATURE_MAX_SPELLS * sizeof(SpellEntry*));
SpellInfo const* apSpell[CREATURE_MAX_SPELLS];
memset(apSpell, 0, CREATURE_MAX_SPELLS * sizeof(SpellInfo*));
uint32 spellCount = 0;
SpellEntry const* tempSpell = NULL;
SpellInfo const* tempSpell = NULL;
SpellRangeEntry const* tempRange = NULL;
//Check if each spell is viable(set it to null if not)
for (uint32 i = 0; i < CREATURE_MAX_SPELLS; i++)
{
tempSpell = sSpellStore.LookupEntry(me->m_spells[i]);
tempSpell = sSpellMgr->GetSpellInfo(me->m_spells[i]);
//This spell doesn't exist
if (!tempSpell)
@@ -238,31 +238,24 @@ SpellEntry const* ScriptedAI::SelectSpell(Unit* target, uint32 school, uint32 me
continue;
//Make sure that the spell uses the requested amount of power
if (powerCostMin && tempSpell->manaCost < powerCostMin)
if (powerCostMin && tempSpell->ManaCost < powerCostMin)
continue;
if (powerCostMax && tempSpell->manaCost > powerCostMax)
if (powerCostMax && tempSpell->ManaCost > powerCostMax)
continue;
//Continue if we don't have the mana to actually cast this spell
if (tempSpell->manaCost > me->GetPower(Powers(tempSpell->powerType)))
continue;
//Get the Range
tempRange = GetSpellRangeStore()->LookupEntry(tempSpell->rangeIndex);
//Spell has invalid range store so we can't use it
if (!tempRange)
if (tempSpell->ManaCost > me->GetPower(Powers(tempSpell->PowerType)))
continue;
//Check if the spell meets our range requirements
if (rangeMin && me->GetSpellMinRangeForTarget(target, tempRange) < rangeMin)
if (rangeMin && me->GetSpellMinRangeForTarget(target, tempSpell) < rangeMin)
continue;
if (rangeMax && me->GetSpellMaxRangeForTarget(target, tempRange) > rangeMax)
if (rangeMax && me->GetSpellMaxRangeForTarget(target, tempSpell) > rangeMax)
continue;
//Check if our target is in range
if (me->IsWithinDistInMap(target, float(me->GetSpellMinRangeForTarget(target, tempRange))) || !me->IsWithinDistInMap(target, float(me->GetSpellMaxRangeForTarget(target, tempRange))))
if (me->IsWithinDistInMap(target, float(me->GetSpellMinRangeForTarget(target, tempSpell))) || !me->IsWithinDistInMap(target, float(me->GetSpellMaxRangeForTarget(target, tempSpell))))
continue;
//All good so lets add it to the spell list
@@ -277,7 +270,7 @@ SpellEntry const* ScriptedAI::SelectSpell(Unit* target, uint32 school, uint32 me
return apSpell[urand(0, spellCount - 1)];
}
bool ScriptedAI::CanCast(Unit* target, SpellEntry const* spell, bool triggered /*= false*/)
bool ScriptedAI::CanCast(Unit* target, SpellInfo const* spell, bool triggered /*= false*/)
{
//No target so we can't cast
if (!target || !spell)
@@ -288,17 +281,11 @@ bool ScriptedAI::CanCast(Unit* target, SpellEntry const* spell, bool triggered /
return false;
//Check for power
if (!triggered && me->GetPower(Powers(spell->powerType)) < spell->manaCost)
return false;
SpellRangeEntry const* tempRange = GetSpellRangeStore()->LookupEntry(spell->rangeIndex);
//Spell has invalid range store so we can't use it
if (!tempRange)
if (!triggered && me->GetPower(Powers(spell->PowerType)) < spell->ManaCost)
return false;
//Unit is out of range of this spell
if (me->IsInRange(target, float(me->GetSpellMinRangeForTarget(target, tempRange)), float(me->GetSpellMaxRangeForTarget(target, tempRange))))
if (me->IsInRange(target, float(me->GetSpellMinRangeForTarget(target, spell)), float(me->GetSpellMaxRangeForTarget(target, spell))))
return false;
return true;
@@ -28,8 +28,6 @@
#define CAST_CRE(a) (dynamic_cast<Creature*>(a))
#define CAST_AI(a, b) (dynamic_cast<a*>(b))
#define GET_SPELL(a) (const_cast<SpellEntry*>(GetSpellStore()->LookupEntry(a)))
class InstanceScript;
class SummonList : public std::list<uint64>
@@ -78,10 +76,10 @@ struct ScriptedAI : public CreatureAI
void SummonedCreatureDespawn(Creature* /*summon*/) {}
// Called when hit by a spell
void SpellHit(Unit* /*caster*/, SpellEntry const* /*spell*/) {}
void SpellHit(Unit* /*caster*/, SpellInfo const* /*spell*/) {}
// Called when spell hits a target
void SpellHitTarget(Unit* /*target*/, SpellEntry const* /*spell*/) {}
void SpellHitTarget(Unit* /*target*/, SpellInfo const* /*spell*/) {}
//Called at waypoint reached or PointMovement end
void MovementInform(uint32 /*type*/, uint32 /*id*/) {}
@@ -123,7 +121,7 @@ struct ScriptedAI : public CreatureAI
void DoStopAttack();
//Cast spell by spell info
void DoCastSpell(Unit* target, SpellEntry const* spellInfo, bool triggered = false);
void DoCastSpell(Unit* target, SpellInfo const* spellInfo, bool triggered = false);
//Plays a sound to all nearby players
void DoPlaySoundToSet(WorldObject* source, uint32 soundId);
@@ -160,10 +158,10 @@ struct ScriptedAI : public CreatureAI
bool HealthAbovePct(uint32 pct) const { return me->HealthAbovePct(pct); }
//Returns spells that meet the specified criteria from the creatures spell list
SpellEntry const* SelectSpell(Unit* target, uint32 school, uint32 mechanic, SelectTargetType targets, uint32 powerCostMin, uint32 powerCostMax, float rangeMin, float rangeMax, SelectEffect effect);
SpellInfo const* SelectSpell(Unit* target, uint32 school, uint32 mechanic, SelectTargetType targets, uint32 powerCostMin, uint32 powerCostMax, float rangeMin, float rangeMax, SelectEffect effect);
//Checks if you can cast the specified spell
bool CanCast(Unit* target, SpellEntry const* spell, bool triggered = false);
bool CanCast(Unit* target, SpellInfo const* spell, bool triggered = false);
void SetEquipmentSlots(bool loadDefault, int32 mainHand = EQUIP_NO_CHANGE, int32 offHand = EQUIP_NO_CHANGE, int32 ranged = EQUIP_NO_CHANGE);
+2 -2
View File
@@ -606,12 +606,12 @@ void SmartAI::AttackStart(Unit* who)
}
}
void SmartAI::SpellHit(Unit* pUnit, const SpellEntry* pSpell)
void SmartAI::SpellHit(Unit* pUnit, const SpellInfo* pSpell)
{
GetScript()->ProcessEventsFor(SMART_EVENT_SPELLHIT, pUnit, 0, 0, false, pSpell);
}
void SmartAI::SpellHitTarget(Unit* target, const SpellEntry* pSpell)
void SmartAI::SpellHitTarget(Unit* target, const SpellInfo* pSpell)
{
GetScript()->ProcessEventsFor(SMART_EVENT_SPELLHIT_TARGET, target, 0, 0, false, pSpell);
}
+2 -2
View File
@@ -100,10 +100,10 @@ class SmartAI : public CreatureAI
void MoveInLineOfSight(Unit *who);
// Called when hit by a spell
void SpellHit(Unit* pUnit, const SpellEntry* pSpell);
void SpellHit(Unit* pUnit, const SpellInfo* pSpell);
// Called when spell hits a target
void SpellHitTarget(Unit* target, const SpellEntry* pSpell);
void SpellHitTarget(Unit* target, const SpellInfo* pSpell);
// Called at any Damage from any attacker (before damage apply)
void DamageTaken(Unit* done_by, uint32& damage);
@@ -74,7 +74,7 @@ void SmartScript::OnReset()
mLastInvoker = 0;
}
void SmartScript::ProcessEventsFor(SMART_EVENT e, Unit* unit, uint32 var0, uint32 var1, bool bvar, const SpellEntry* spell, GameObject* gob)
void SmartScript::ProcessEventsFor(SMART_EVENT e, Unit* unit, uint32 var0, uint32 var1, bool bvar, const SpellInfo* spell, GameObject* gob)
{
if (e == SMART_EVENT_AGGRO)
{
@@ -103,7 +103,7 @@ void SmartScript::ProcessEventsFor(SMART_EVENT e, Unit* unit, uint32 var0, uint3
}
}
void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, uint32 var1, bool bvar, const SpellEntry* spell, GameObject* gob)
void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, uint32 var1, bool bvar, const SpellInfo* spell, GameObject* gob)
{
//calc random
if (e.GetEventType() != SMART_EVENT_LINK && e.event.event_chance < 100 && e.event.event_chance)
@@ -2164,7 +2164,7 @@ ObjectList* SmartScript::GetWorldObjectsInDist(float dist)
return targets;
}
void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, uint32 var1, bool bvar, const SpellEntry* spell, GameObject* gob)
void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, uint32 var1, bool bvar, const SpellInfo* spell, GameObject* gob)
{
if (!e.active && e.GetEventType() != SMART_EVENT_LINK)
return;
@@ -40,13 +40,13 @@ class SmartScript
void GetScript();
void FillScript(SmartAIEventList e, WorldObject* obj, AreaTriggerEntry const* at);
void ProcessEventsFor(SMART_EVENT e, Unit* unit = NULL, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellEntry* spell = NULL, GameObject* gob = NULL);
void ProcessEvent(SmartScriptHolder& e, Unit* unit = NULL, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellEntry* spell = NULL, GameObject* gob = NULL);
void ProcessEventsFor(SMART_EVENT e, Unit* unit = NULL, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = NULL, GameObject* gob = NULL);
void ProcessEvent(SmartScriptHolder& e, Unit* unit = NULL, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = NULL, GameObject* gob = NULL);
bool CheckTimer(SmartScriptHolder const& e) const;
void RecalcTimer(SmartScriptHolder& e, uint32 min, uint32 max);
void UpdateTimer(SmartScriptHolder& e, uint32 const diff);
void InitTimer(SmartScriptHolder& e);
void ProcessAction(SmartScriptHolder& e, Unit* unit = NULL, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellEntry* spell = NULL, GameObject* gob = NULL);
void ProcessAction(SmartScriptHolder& e, Unit* unit = NULL, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = NULL, GameObject* gob = NULL);
ObjectList* GetTargets(SmartScriptHolder const& e, Unit* invoker = NULL);
ObjectList* GetWorldObjectsInDist(float dist);
void InstallTemplate(SmartScriptHolder const& e);
@@ -334,7 +334,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder &e)
case SMART_EVENT_SPELLHIT_TARGET:
if (e.event.spellHit.spell)
{
SpellEntry const* pSpell = sSpellStore.LookupEntry(e.event.spellHit.spell);
SpellInfo const* pSpell = sSpellMgr->GetSpellInfo(e.event.spellHit.spell);
if (!pSpell)
{
sLog->outErrorDb("SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent Spell entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.event.spellHit.spell);
@@ -1311,7 +1311,7 @@ class SmartAIMgr
bool IsSpellValid(SmartScriptHolder const& e, uint32 entry)
{
if (!sSpellStore.LookupEntry(entry))
if (!sSpellMgr->GetSpellInfo(entry))
{
sLog->outErrorDb("SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent Spell entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), entry);
return false;