From 208e9acbffe6f239b284ba54324d50685ab9b9d7 Mon Sep 17 00:00:00 2001 From: Schmoozerd Date: Thu, 12 Jul 2012 21:57:18 +0200 Subject: [PATCH] [12031] Change way location targeting is handled --- src/game/Spell.cpp | 22 ++++++++++------------ src/game/Spell.h | 14 +++++++------- src/game/Unit.cpp | 25 ++++++++++++++++++++++++- src/shared/revision_nr.h | 2 +- 4 files changed, 42 insertions(+), 21 deletions(-) diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index fa6327a86..23c693b51 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -2308,9 +2308,9 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& break; case TARGET_CASTER_COORDINATES: { - // Check original caster is GO - set its coordinates as dst cast + // Check original caster is GO - set its coordinates as src cast if (WorldObject *caster = GetCastingObject()) - m_targets.setDestination(caster->GetPositionX(), caster->GetPositionY(), caster->GetPositionZ()); + m_targets.setSource(caster->GetPositionX(), caster->GetPositionY(), caster->GetPositionZ()); break; } case TARGET_ALL_HOSTILE_UNITS_AROUND_CASTER: @@ -2673,19 +2673,17 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& } case TARGET_TABLE_X_Y_Z_COORDINATES: { - SpellTargetPosition const* st = sSpellMgr.GetSpellTargetPosition(m_spellInfo->Id); - if(st) + if (SpellTargetPosition const* st = sSpellMgr.GetSpellTargetPosition(m_spellInfo->Id)) { - // teleport spells are handled in another way - if (m_spellInfo->Effect[effIndex] == SPELL_EFFECT_TELEPORT_UNITS) - break; - if (st->target_mapId == m_caster->GetMapId()) - m_targets.setDestination(st->target_X, st->target_Y, st->target_Z); - else - sLog.outError( "SPELL: wrong map (%u instead %u) target coordinates for spell ID %u", st->target_mapId, m_caster->GetMapId(), m_spellInfo->Id ); + m_targets.setDestination(st->target_X, st->target_Y, st->target_Z); + // TODO - maybe use an (internal) value for the map for neat far teleport handling + + // far-teleport spells are handled in SpellEffect, elsewise report an error about an unexpected map (spells are always locally) + if (st->target_mapId != m_caster->GetMapId() && m_spellInfo->Effect[effIndex] != SPELL_EFFECT_TELEPORT_UNITS) + sLog.outError( "SPELL: wrong map (%u instead %u) target coordinates for spell ID %u", st->target_mapId, m_caster->GetMapId(), m_spellInfo->Id); } else - sLog.outError( "SPELL: unknown target coordinates for spell ID %u", m_spellInfo->Id ); + sLog.outError("SPELL: unknown target coordinates for spell ID %u", m_spellInfo->Id); break; } case TARGET_INFRONT_OF_VICTIM: diff --git a/src/game/Spell.h b/src/game/Spell.h index 66e72ea8b..80997dc6d 100644 --- a/src/game/Spell.h +++ b/src/game/Spell.h @@ -736,18 +736,18 @@ namespace MaNGOS } break; case PUSH_DEST_CENTER: - if (i_spell.m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) - { - i_centerX = i_spell.m_targets.m_destX; - i_centerY = i_spell.m_targets.m_destY; - i_centerZ = i_spell.m_targets.m_destZ; - } - else + if (i_spell.m_targets.m_targetMask & TARGET_FLAG_SOURCE_LOCATION) { i_centerX = i_spell.m_targets.m_srcX; i_centerY = i_spell.m_targets.m_srcY; i_centerZ = i_spell.m_targets.m_srcZ; } + else + { + i_centerX = i_spell.m_targets.m_destX; + i_centerY = i_spell.m_targets.m_destY; + i_centerZ = i_spell.m_targets.m_destZ; + } break; case PUSH_TARGET_CENTER: if (Unit* target = i_spell.m_targets.getUnitTarget()) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index c8d8a4f56..cb7109e53 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -1124,6 +1124,13 @@ void Unit::CastSpell(Unit* Victim, SpellEntry const *spellInfo, bool triggered, SpellCastTargets targets; targets.setUnitTarget( Victim ); + + if (spellInfo->Targets & TARGET_FLAG_DEST_LOCATION) + targets.setDestination(Victim->GetPositionX(), Victim->GetPositionY(), Victim->GetPositionZ()); + if (spellInfo->Targets & TARGET_FLAG_SOURCE_LOCATION) + if (WorldObject* caster = spell->GetCastingObject()) + targets.setSource(caster->GetPositionX(), caster->GetPositionY(), caster->GetPositionZ()); + spell->m_CastItem = castItem; spell->prepare(&targets, triggeredByAura); } @@ -1180,6 +1187,13 @@ void Unit::CastCustomSpell(Unit* Victim, SpellEntry const *spellInfo, int32 cons SpellCastTargets targets; targets.setUnitTarget( Victim ); spell->m_CastItem = castItem; + + if (spellInfo->Targets & TARGET_FLAG_DEST_LOCATION) + targets.setDestination(Victim->GetPositionX(), Victim->GetPositionY(), Victim->GetPositionZ()); + if (spellInfo->Targets & TARGET_FLAG_SOURCE_LOCATION) + if (WorldObject* caster = spell->GetCastingObject()) + targets.setSource(caster->GetPositionX(), caster->GetPositionY(), caster->GetPositionZ()); + spell->prepare(&targets, triggeredByAura); } @@ -1226,7 +1240,16 @@ void Unit::CastSpell(float x, float y, float z, SpellEntry const *spellInfo, boo Spell *spell = new Spell(this, spellInfo, triggered, originalCaster, triggeredBy); SpellCastTargets targets; - targets.setDestination(x, y, z); + + if (spellInfo->Targets & TARGET_FLAG_DEST_LOCATION) + targets.setDestination(x, y, z); + if (spellInfo->Targets & TARGET_FLAG_SOURCE_LOCATION) + targets.setSource(x, y, z); + + // Spell cast with x,y,z but without dbc target-mask, set destination + if (!(targets.m_targetMask & (TARGET_FLAG_DEST_LOCATION | TARGET_FLAG_SOURCE_LOCATION))) + targets.setDestination(x, y, z); + spell->m_CastItem = castItem; spell->prepare(&targets, triggeredByAura); } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 818be4811..8ab010c51 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "12030" + #define REVISION_NR "12031" #endif // __REVISION_NR_H__