[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;
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:

View file

@ -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())

View file

@ -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);
}

View file

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