[12031] Change way location targeting is handled

This commit is contained in:
Schmoozerd 2012-07-12 21:57:18 +02:00
parent 6b6b2379a3
commit 208e9acbff
4 changed files with 42 additions and 21 deletions

View file

@ -2308,9 +2308,9 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
break; break;
case TARGET_CASTER_COORDINATES: 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()) if (WorldObject *caster = GetCastingObject())
m_targets.setDestination(caster->GetPositionX(), caster->GetPositionY(), caster->GetPositionZ()); m_targets.setSource(caster->GetPositionX(), caster->GetPositionY(), caster->GetPositionZ());
break; break;
} }
case TARGET_ALL_HOSTILE_UNITS_AROUND_CASTER: 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: case TARGET_TABLE_X_Y_Z_COORDINATES:
{ {
SpellTargetPosition const* st = sSpellMgr.GetSpellTargetPosition(m_spellInfo->Id); if (SpellTargetPosition const* st = sSpellMgr.GetSpellTargetPosition(m_spellInfo->Id))
if(st)
{ {
// teleport spells are handled in another way m_targets.setDestination(st->target_X, st->target_Y, st->target_Z);
if (m_spellInfo->Effect[effIndex] == SPELL_EFFECT_TELEPORT_UNITS) // TODO - maybe use an (internal) value for the map for neat far teleport handling
break;
if (st->target_mapId == m_caster->GetMapId()) // far-teleport spells are handled in SpellEffect, elsewise report an error about an unexpected map (spells are always locally)
m_targets.setDestination(st->target_X, st->target_Y, st->target_Z); if (st->target_mapId != m_caster->GetMapId() && m_spellInfo->Effect[effIndex] != SPELL_EFFECT_TELEPORT_UNITS)
else sLog.outError( "SPELL: wrong map (%u instead %u) target coordinates for spell ID %u", st->target_mapId, m_caster->GetMapId(), m_spellInfo->Id);
sLog.outError( "SPELL: wrong map (%u instead %u) target coordinates for spell ID %u", st->target_mapId, m_caster->GetMapId(), m_spellInfo->Id );
} }
else 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; break;
} }
case TARGET_INFRONT_OF_VICTIM: case TARGET_INFRONT_OF_VICTIM:

View file

@ -736,18 +736,18 @@ namespace MaNGOS
} }
break; break;
case PUSH_DEST_CENTER: case PUSH_DEST_CENTER:
if (i_spell.m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) if (i_spell.m_targets.m_targetMask & TARGET_FLAG_SOURCE_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
{ {
i_centerX = i_spell.m_targets.m_srcX; i_centerX = i_spell.m_targets.m_srcX;
i_centerY = i_spell.m_targets.m_srcY; i_centerY = i_spell.m_targets.m_srcY;
i_centerZ = i_spell.m_targets.m_srcZ; 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; break;
case PUSH_TARGET_CENTER: case PUSH_TARGET_CENTER:
if (Unit* target = i_spell.m_targets.getUnitTarget()) if (Unit* target = i_spell.m_targets.getUnitTarget())

View file

@ -1124,6 +1124,13 @@ void Unit::CastSpell(Unit* Victim, SpellEntry const *spellInfo, bool triggered,
SpellCastTargets targets; SpellCastTargets targets;
targets.setUnitTarget( Victim ); 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->m_CastItem = castItem;
spell->prepare(&targets, triggeredByAura); spell->prepare(&targets, triggeredByAura);
} }
@ -1180,6 +1187,13 @@ void Unit::CastCustomSpell(Unit* Victim, SpellEntry const *spellInfo, int32 cons
SpellCastTargets targets; SpellCastTargets targets;
targets.setUnitTarget( Victim ); targets.setUnitTarget( Victim );
spell->m_CastItem = castItem; 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); 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); Spell *spell = new Spell(this, spellInfo, triggered, originalCaster, triggeredBy);
SpellCastTargets targets; 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->m_CastItem = castItem;
spell->prepare(&targets, triggeredByAura); spell->prepare(&targets, triggeredByAura);
} }

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "12030" #define REVISION_NR "12031"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__