diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 6 | ||||
-rw-r--r-- | src/server/game/Spells/SpellScript.cpp | 37 | ||||
-rw-r--r-- | src/server/game/Spells/SpellScript.h | 28 | ||||
-rw-r--r-- | src/server/scripts/Examples/example_spell.cpp | 6 |
4 files changed, 60 insertions, 17 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index af5eab71799..e48b7845791 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -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); diff --git a/src/server/game/Spells/SpellScript.cpp b/src/server/game/Spells/SpellScript.cpp index fb2944fa651..8374632ca9b 100644 --- a/src/server/game/Spells/SpellScript.cpp +++ b/src/server/game/Spells/SpellScript.cpp @@ -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; diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h index b7a83748b75..76fe4b5f401 100644 --- a/src/server/game/Spells/SpellScript.h +++ b/src/server/game/Spells/SpellScript.h @@ -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 diff --git a/src/server/scripts/Examples/example_spell.cpp b/src/server/scripts/Examples/example_spell.cpp index 90655127aa9..1622c087468 100644 --- a/src/server/scripts/Examples/example_spell.cpp +++ b/src/server/scripts/Examples/example_spell.cpp @@ -36,7 +36,7 @@ class spell_ex_49375SpellScript : public SpellScript sLog.outError("WE ARE HANDLING DUMMY!"); sLog.outError(localVariable.c_str()); // make caster cast a spell on a unit target of effect - if (Unit * target = GetEffectUnitTarget()) + if (Unit * target = GetHitUnit()) GetCaster()->CastSpell(target, 70522, true); }; void Register() @@ -70,7 +70,7 @@ class spell_ex_49375SpellScript : public SpellScript // script will be immediately removed from the spell // for example - we don't want this script to be executed on a creature // if (GetCaster()->GetTypeID() != TYPEID_PLAYER) - // return false + // return false; } // function called just before script delete // we free allocated memory @@ -95,7 +95,7 @@ class spell_ex_SpellScript : public SpellScript //EffectHandlers += EffectHandlerFn(spell_ex_SpellScript::Function, EFFECT_ANY, SPELL_EFFECT_ANY); } - //bool Load(){return true} + //bool Load(){return true;} //void Unload(){} //bool Validate(SpellEntry const * spellEntry){return true;} }; |