aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Maps/MapScripts.cpp
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2019-01-20 20:22:35 +0100
committerShauren <shauren.trinity@gmail.com>2021-11-21 21:10:10 +0100
commit3acb4204440f5dcbbc0f17816de24a3244e53771 (patch)
treed9a27bb83bf118619a57ed1b644e6dec9d39e7a1 /src/server/game/Maps/MapScripts.cpp
parent36468203ddf9adb1a4c64f663aff6505701b8fb6 (diff)
Core/MapScripts: Allow GameObjects to be caster of SCRIPT_COMMAND_CAST_SPELL
(cherry picked from commit 813cf761fcf8737e50486672be28900c9cf4f36f)
Diffstat (limited to 'src/server/game/Maps/MapScripts.cpp')
-rw-r--r--src/server/game/Maps/MapScripts.cpp27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/server/game/Maps/MapScripts.cpp b/src/server/game/Maps/MapScripts.cpp
index c82bb7212fa..541fdcf76b9 100644
--- a/src/server/game/Maps/MapScripts.cpp
+++ b/src/server/game/Maps/MapScripts.cpp
@@ -628,49 +628,48 @@ void Map::ScriptsProcess()
case SCRIPT_COMMAND_CAST_SPELL:
{
- /// @todo Allow gameobjects to be targets and casters
if (!source && !target)
{
TC_LOG_ERROR("scripts", "%s source and target objects are NULL.", step.script->GetDebugInfo().c_str());
break;
}
- Unit* uSource = nullptr;
- Unit* uTarget = nullptr;
+ WorldObject* uSource = nullptr;
+ WorldObject* uTarget = nullptr;
// source/target cast spell at target/source (script->datalong2: 0: s->t 1: s->s 2: t->t 3: t->s)
switch (step.script->CastSpell.Flags)
{
case SF_CASTSPELL_SOURCE_TO_TARGET: // source -> target
- uSource = source ? source->ToUnit() : nullptr;
- uTarget = target ? target->ToUnit() : nullptr;
+ uSource = dynamic_cast<WorldObject*>(source);
+ uTarget = target;
break;
case SF_CASTSPELL_SOURCE_TO_SOURCE: // source -> source
- uSource = source ? source->ToUnit() : nullptr;
+ uSource = dynamic_cast<WorldObject*>(source);
uTarget = uSource;
break;
case SF_CASTSPELL_TARGET_TO_TARGET: // target -> target
- uSource = target ? target->ToUnit() : nullptr;
+ uSource = target;
uTarget = uSource;
break;
case SF_CASTSPELL_TARGET_TO_SOURCE: // target -> source
- uSource = target ? target->ToUnit() : nullptr;
- uTarget = source ? source->ToUnit() : nullptr;
+ uSource = target;
+ uTarget = dynamic_cast<WorldObject*>(source);
break;
case SF_CASTSPELL_SEARCH_CREATURE: // source -> creature with entry
- uSource = source ? source->ToUnit() : nullptr;
+ uSource = dynamic_cast<WorldObject*>(source);
uTarget = uSource ? uSource->FindNearestCreature(abs(step.script->CastSpell.CreatureEntry), step.script->CastSpell.SearchRadius) : nullptr;
break;
}
- if (!uSource || !uSource->isType(TYPEMASK_UNIT))
+ if (!uSource)
{
- TC_LOG_ERROR("scripts", "%s no source unit found for spell %u", step.script->GetDebugInfo().c_str(), step.script->CastSpell.SpellID);
+ TC_LOG_ERROR("scripts", "%s no source worldobject found for spell %u", step.script->GetDebugInfo().c_str(), step.script->CastSpell.SpellID);
break;
}
- if (!uTarget || !uTarget->isType(TYPEMASK_UNIT))
+ if (!uTarget)
{
- TC_LOG_ERROR("scripts", "%s no target unit found for spell %u", step.script->GetDebugInfo().c_str(), step.script->CastSpell.SpellID);
+ TC_LOG_ERROR("scripts", "%s no target worldobject found for spell %u", step.script->GetDebugInfo().c_str(), step.script->CastSpell.SpellID);
break;
}