*Extend API of SpellScript by Dest and Damage/Heal setters and getters.

*Make some SpellScript function names shorter.

--HG--
branch : trunk
This commit is contained in:
QAston
2010-07-25 16:23:57 +02:00
parent 997b9e6b22
commit fce1f5b014
4 changed files with 60 additions and 17 deletions
+3 -3
View File
@@ -4504,6 +4504,9 @@ void Spell::HandleEffects(Unit *pUnitTarget,Item *pItemTarget,GameObject *pGOTar
sLog.outDebug("Spell: %u Effect : %u", m_spellInfo->Id, eff);
//we do not need DamageMultiplier here.
damage = CalculateDamage(i, NULL);
for(std::list<SpellScript *>::iterator scritr = m_loadedScripts.begin(); scritr != m_loadedScripts.end() ; ++scritr)
{
std::list<SpellScript::EffectHandler>::iterator effEndItr = (*scritr)->EffectHandlers.end(), effItr = (*scritr)->EffectHandlers.begin();
@@ -4514,9 +4517,6 @@ void Spell::HandleEffects(Unit *pUnitTarget,Item *pItemTarget,GameObject *pGOTar
}
}
//we do not need DamageMultiplier here.
damage = CalculateDamage(i, NULL);
if (eff < TOTAL_SPELL_EFFECTS)
{
(this->*SpellEffects[eff])(i);
+32 -5
View File
@@ -178,12 +178,19 @@ SpellEntry const * SpellScript::GetSpellInfo()
return m_spell->GetSpellInfo();
}
Unit * SpellScript::GetEffectUnitTarget()
WorldLocation * SpellScript::GetDest()
{
if (m_spell->m_targets.HasDst())
return &m_spell->m_targets.m_dstPos;
return NULL;
}
Unit * SpellScript::GetHitUnit()
{
return m_spell->unitTarget;
}
Creature * SpellScript::GetEffectCreatureTarget()
Creature * SpellScript::GetHitCreature()
{
if (m_spell->unitTarget)
return m_spell->unitTarget->ToCreature();
@@ -191,7 +198,7 @@ Creature * SpellScript::GetEffectCreatureTarget()
return NULL;
}
Player * SpellScript::GetEffectPlayerTarget()
Player * SpellScript::GetHitPlayer()
{
if (m_spell->unitTarget)
return m_spell->unitTarget->ToPlayer();
@@ -199,16 +206,36 @@ Player * SpellScript::GetEffectPlayerTarget()
return NULL;
}
Item * SpellScript::GetEffectItemTarget()
Item * SpellScript::GetHitItem()
{
return m_spell->itemTarget;
}
GameObject * SpellScript::GetEffectGOTarget()
GameObject * SpellScript::GetHitGObj()
{
return m_spell->gameObjTarget;
}
int32 SpellScript::GetHitDamage()
{
return m_spell->m_damage;
}
void SpellScript::SetHitDamage(int32 damage)
{
m_spell->m_damage = damage;
}
int32 SpellScript::GetHitHeal()
{
return m_spell->m_healing;
}
void SpellScript::SetHitHeal(int32 heal)
{
m_spell->m_healing = heal;
}
int32 SpellScript::GetEffectValue()
{
return m_spell->damage;
+22 -6
View File
@@ -29,6 +29,7 @@ class Creature;
class GameObject;
class Player;
class Item;
class WorldLocation;
typedef void(SpellScript::*EffectHandlerFnType)(SpellEffIndex);
@@ -120,23 +121,38 @@ class SpellScript : public _SpellScript
// example EffectHandlers += EffectHandlerFn(class::function, EffectIndexSpecifier, EffectNameSpecifier);
HookList<EffectHandler> EffectHandlers;
//
// methods allowing interaction with Spell object
//
// methods useable during all spell handling phases
Unit * GetCaster();
Unit * GetOriginalCaster();
SpellEntry const * GetSpellInfo();
// functions useable only during spell hit on target phase
// methods useable after spell targets are set
// returns: destination of the spell if exists, otherwise NULL
WorldLocation * GetDest();
// methods useable only during spell hit on target phase:
// returns: target of current effect if it was Unit otherwise NULL
Unit * GetEffectUnitTarget();
Unit * GetHitUnit();
// returns: target of current effect if it was Creature otherwise NULL
Creature * GetEffectCreatureTarget();
Creature * GetHitCreature();
// returns: target of current effect if it was Player otherwise NULL
Player * GetEffectPlayerTarget();
Player * GetHitPlayer();
// returns: target of current effect if it was Item otherwise NULL
Item * GetEffectItemTarget();
Item * GetHitItem();
// returns: target of current effect if it was GameObject otherwise NULL
GameObject * GetEffectGOTarget();
GameObject * GetHitGObj();
// setter/getter for for damage done by spell to target of spell hit
int32 GetHitDamage();
void SetHitDamage(int32 damage);
// setter/getter for for heal done by spell to target of spell hit
int32 GetHitHeal();
void SetHitHeal(int32 heal);
// method avalible only in EffectHandler method
int32 GetEffectValue();
};
// SpellScript interface