mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 22:37:02 +00:00
[7450] Fixes and improvements in TARGET_BEHIND_VICTIM, SPELL_EFFECT_JUMP2, SPELL_EFFECT_TELEPORT_UNITS work.
* Move near teleport code for player/creature in Unit::NearTeleportTo * Allow correctly seelct target and end point orientation for script casted spells with TARGET_BEHIND_VICTIM * Replace use BuildTeleportAckMsg by BuildHeartBeatMsg for creature teleports. BuildTeleportAckMsg set active mover for targeted player to affected creature and "freeze" player.
This commit is contained in:
parent
571c56ff07
commit
3a5d59c0c7
5 changed files with 93 additions and 70 deletions
|
|
@ -2009,39 +2009,41 @@ void Spell::EffectJump(uint32 i)
|
|||
x = m_targets.m_destX;
|
||||
y = m_targets.m_destY;
|
||||
z = m_targets.m_destZ;
|
||||
o = m_caster->GetOrientation();
|
||||
|
||||
if(m_spellInfo->EffectImplicitTargetA[i] == TARGET_BEHIND_VICTIM)
|
||||
{
|
||||
// explicit cast data from client or server-side cast
|
||||
// some spell at client send caster
|
||||
Unit* pTarget = NULL;
|
||||
if(m_targets.getUnitTarget() && m_targets.getUnitTarget()!=m_caster)
|
||||
pTarget = m_targets.getUnitTarget();
|
||||
else if(unitTarget->getVictim())
|
||||
pTarget = m_caster->getVictim();
|
||||
else if(m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||
pTarget = ObjectAccessor::GetUnit(*m_caster, ((Player*)m_caster)->GetSelection());
|
||||
|
||||
o = pTarget ? pTarget->GetOrientation() : m_caster->GetOrientation();
|
||||
}
|
||||
else
|
||||
o = m_caster->GetOrientation();
|
||||
}
|
||||
else if(unitTarget)
|
||||
{
|
||||
x = unitTarget->GetPositionX();
|
||||
y = unitTarget->GetPositionY();
|
||||
z = unitTarget->GetPositionZ();
|
||||
o = m_spellInfo->EffectImplicitTargetA[i] == TARGET_BEHIND_VICTIM
|
||||
? unitTarget->GetOrientation()
|
||||
: m_caster->GetOrientation();
|
||||
unitTarget->GetContactPoint(m_caster,x,y,z,CONTACT_DISTANCE);
|
||||
o = m_caster->GetOrientation();
|
||||
}
|
||||
else if(gameObjTarget)
|
||||
{
|
||||
x = gameObjTarget->GetPositionX();
|
||||
y = gameObjTarget->GetPositionY();
|
||||
z = gameObjTarget->GetPositionZ();
|
||||
gameObjTarget->GetContactPoint(m_caster,x,y,z,CONTACT_DISTANCE);
|
||||
o = m_caster->GetOrientation();
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
|
||||
// Teleport
|
||||
if(m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||
((Player*)m_caster)->TeleportTo(m_caster->GetMapId(), x, y, z, o,
|
||||
TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0));
|
||||
else
|
||||
{
|
||||
m_caster->GetMap()->CreatureRelocation((Creature*)m_caster, x, y, z, o);
|
||||
WorldPacket data;
|
||||
m_caster->BuildTeleportAckMsg(&data, x, y, z, o);
|
||||
m_caster->SendMessageToSet(&data, false);
|
||||
sLog.outError( "Spell::EffectJump - unsupported target mode for spell ID %u", m_spellInfo->Id );
|
||||
return;
|
||||
}
|
||||
|
||||
m_caster->NearTeleportTo(x,y,z,o,true);
|
||||
}
|
||||
|
||||
void Spell::EffectTeleportUnits(uint32 i)
|
||||
|
|
@ -2062,45 +2064,38 @@ void Spell::EffectTeleportUnits(uint32 i)
|
|||
}
|
||||
case TARGET_TABLE_X_Y_Z_COORDINATES:
|
||||
{
|
||||
// TODO: Only players can teleport?
|
||||
if (unitTarget->GetTypeId() != TYPEID_PLAYER)
|
||||
return;
|
||||
SpellTargetPosition const* st = spellmgr.GetSpellTargetPosition(m_spellInfo->Id);
|
||||
if(!st)
|
||||
{
|
||||
sLog.outError( "Spell::EffectTeleportUnits - unknown Teleport coordinates for spell ID %u", m_spellInfo->Id );
|
||||
return;
|
||||
}
|
||||
((Player*)unitTarget)->TeleportTo(st->target_mapId,st->target_X,st->target_Y,st->target_Z,st->target_Orientation,unitTarget==m_caster ? TELE_TO_SPELL : 0);
|
||||
|
||||
if(st->target_mapId==unitTarget->GetMapId())
|
||||
unitTarget->NearTeleportTo(st->target_X,st->target_Y,st->target_Z,st->target_Orientation,unitTarget==m_caster);
|
||||
else if(unitTarget->GetTypeId()==TYPEID_PLAYER)
|
||||
((Player*)unitTarget)->TeleportTo(st->target_mapId,st->target_X,st->target_Y,st->target_Z,st->target_Orientation,unitTarget==m_caster ? TELE_TO_SPELL : 0);
|
||||
break;
|
||||
}
|
||||
case TARGET_BEHIND_VICTIM:
|
||||
{
|
||||
// Get selected target for player (or victim for units)
|
||||
Unit *pTarget = NULL;
|
||||
if(m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||
pTarget = ObjectAccessor::GetUnit(*m_caster, ((Player*)m_caster)->GetSelection());
|
||||
else
|
||||
pTarget = m_caster->getVictim();
|
||||
// No target present - return
|
||||
if (!pTarget)
|
||||
return;
|
||||
|
||||
// explicit cast data from client or server-side cast
|
||||
// some spell at client send caster
|
||||
if(m_targets.getUnitTarget() && m_targets.getUnitTarget()!=unitTarget)
|
||||
pTarget = m_targets.getUnitTarget();
|
||||
else if(unitTarget->getVictim())
|
||||
pTarget = unitTarget->getVictim();
|
||||
else if(unitTarget->GetTypeId() == TYPEID_PLAYER)
|
||||
pTarget = ObjectAccessor::GetUnit(*unitTarget, ((Player*)unitTarget)->GetSelection());
|
||||
|
||||
// Init dest coordinates
|
||||
uint32 mapid = m_caster->GetMapId();
|
||||
float x = m_targets.m_destX;
|
||||
float y = m_targets.m_destY;
|
||||
float z = m_targets.m_destZ;
|
||||
float orientation = pTarget->GetOrientation();
|
||||
// Teleport
|
||||
if(unitTarget->GetTypeId() == TYPEID_PLAYER)
|
||||
((Player*)unitTarget)->TeleportTo(mapid, x, y, z, orientation, TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0));
|
||||
else
|
||||
{
|
||||
m_caster->GetMap()->CreatureRelocation((Creature*)unitTarget, x, y, z, orientation);
|
||||
WorldPacket data;
|
||||
unitTarget->BuildTeleportAckMsg(&data, x, y, z, orientation);
|
||||
unitTarget->SendMessageToSet(&data, false);
|
||||
}
|
||||
float orientation = pTarget ? pTarget->GetOrientation() : unitTarget->GetOrientation();
|
||||
unitTarget->NearTeleportTo(x,y,z,orientation,unitTarget==m_caster);
|
||||
return;
|
||||
}
|
||||
default:
|
||||
|
|
@ -2118,15 +2113,7 @@ void Spell::EffectTeleportUnits(uint32 i)
|
|||
float z = m_targets.m_destZ;
|
||||
float orientation = unitTarget->GetOrientation();
|
||||
// Teleport
|
||||
if(unitTarget->GetTypeId() == TYPEID_PLAYER)
|
||||
((Player*)unitTarget)->TeleportTo(mapid, x, y, z, orientation, TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0));
|
||||
else
|
||||
{
|
||||
m_caster->GetMap()->CreatureRelocation((Creature*)unitTarget, x, y, z, orientation);
|
||||
WorldPacket data;
|
||||
unitTarget->BuildTeleportAckMsg(&data, x, y, z, orientation);
|
||||
unitTarget->SendMessageToSet(&data, false);
|
||||
}
|
||||
unitTarget->NearTeleportTo(x,y,z,orientation,unitTarget==m_caster);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -3787,16 +3774,12 @@ void Spell::EffectTeleUnitsFaceCaster(uint32 i)
|
|||
if(unitTarget->isInFlight())
|
||||
return;
|
||||
|
||||
uint32 mapid = m_caster->GetMapId();
|
||||
float dis = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
|
||||
|
||||
float fx,fy,fz;
|
||||
m_caster->GetClosePoint(fx,fy,fz,unitTarget->GetObjectSize(),dis);
|
||||
|
||||
if(unitTarget->GetTypeId() == TYPEID_PLAYER)
|
||||
((Player*)unitTarget)->TeleportTo(mapid, fx, fy, fz, -m_caster->GetOrientation(), TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0));
|
||||
else
|
||||
m_caster->GetMap()->CreatureRelocation((Creature*)m_caster, fx, fy, fz, -m_caster->GetOrientation());
|
||||
unitTarget->NearTeleportTo(fx,fy,fz,-m_caster->GetOrientation(),unitTarget==m_caster);
|
||||
}
|
||||
|
||||
void Spell::EffectLearnSkill(uint32 i)
|
||||
|
|
@ -5800,7 +5783,6 @@ void Spell::EffectMomentMove(uint32 i)
|
|||
|
||||
if( m_spellInfo->rangeIndex== 1) //self range
|
||||
{
|
||||
uint32 mapid = m_caster->GetMapId();
|
||||
float dis = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
|
||||
|
||||
// before caster
|
||||
|
|
@ -5810,7 +5792,7 @@ void Spell::EffectMomentMove(uint32 i)
|
|||
unitTarget->GetPosition(ox,oy,oz);
|
||||
|
||||
float fx2,fy2,fz2; // getObjectHitPos overwrite last args in any result case
|
||||
if(VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(mapid, ox,oy,oz+0.5, fx,fy,oz+0.5,fx2,fy2,fz2, -0.5))
|
||||
if(VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(unitTarget->GetMapId(), ox,oy,oz+0.5, fx,fy,oz+0.5,fx2,fy2,fz2, -0.5))
|
||||
{
|
||||
fx = fx2;
|
||||
fy = fy2;
|
||||
|
|
@ -5818,10 +5800,7 @@ void Spell::EffectMomentMove(uint32 i)
|
|||
unitTarget->UpdateGroundPositionZ(fx,fy,fz);
|
||||
}
|
||||
|
||||
if(unitTarget->GetTypeId() == TYPEID_PLAYER)
|
||||
((Player*)unitTarget)->TeleportTo(mapid, fx, fy, fz, unitTarget->GetOrientation(), TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0));
|
||||
else
|
||||
m_caster->GetMap()->CreatureRelocation((Creature*)unitTarget, fx, fy, fz, unitTarget->GetOrientation());
|
||||
unitTarget->NearTeleportTo(fx, fy, fz, unitTarget->GetOrientation(),unitTarget==m_caster);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue