Core/Spell: Proper SPELL_EFFECT_PULL_TOWARDS_DEST implementation for players

Port From (https://github.com/TrinityCore/TrinityCore/commit/8ec51bf3b69b2d34607b555f2d52b09f8b73c9e3)
This commit is contained in:
hondacrx
2022-01-07 11:16:51 -05:00
parent b30ded6189
commit ddbfe81071
2 changed files with 33 additions and 24 deletions
+4 -1
View File
@@ -395,9 +395,12 @@ namespace Game.Entities
return true; return true;
} }
public void JumpTo(float speedXY, float speedZ, bool forward) public void JumpTo(float speedXY, float speedZ, bool forward, Position dest = null)
{ {
float angle = forward ? 0 : MathFunctions.PI; float angle = forward ? 0 : MathFunctions.PI;
if (dest != null)
angle += GetRelativeAngle(dest);
if (IsTypeId(TypeId.Unit)) if (IsTypeId(TypeId.Unit))
GetMotionMaster().MoveJumpTo(angle, speedXY, speedZ); GetMotionMaster().MoveJumpTo(angle, speedXY, speedZ);
else else
+29 -23
View File
@@ -1822,8 +1822,6 @@ namespace Game.Spells
var dispellData = new SpellDispellData(); var dispellData = new SpellDispellData();
dispellData.SpellID = dispelableAura.GetAura().GetId(); dispellData.SpellID = dispelableAura.GetAura().GetId();
dispellData.Harmful = false; // TODO: use me dispellData.Harmful = false; // TODO: use me
//dispellData.Rolled = none; // TODO: use me
//dispellData.Needed = none; // TODO: use me
unitTarget.RemoveAurasDueToSpellByDispel(dispelableAura.GetAura().GetId(), m_spellInfo.Id, dispelableAura.GetAura().GetCasterGUID(), m_caster, dispelableAura.GetDispelCharges()); unitTarget.RemoveAurasDueToSpellByDispel(dispelableAura.GetAura().GetId(), m_spellInfo.Id, dispelableAura.GetAura().GetCasterGUID(), m_caster, dispelableAura.GetDispelCharges());
@@ -2772,10 +2770,6 @@ namespace Game.Spells
if (unitTarget.IsTypeId(TypeId.Unit) && unitTarget.ToCreature().IsSummon()) if (unitTarget.IsTypeId(TypeId.Unit) && unitTarget.ToCreature().IsSummon())
unitTarget.ToTempSummon().UnSummon(); unitTarget.ToTempSummon().UnSummon();
return; return;
case 52479: // Gift of the Harvester
if (unitTarget != null && unitCaster != null)
unitCaster.CastSpell(unitTarget, Convert.ToBoolean(RandomHelper.IRand(0, 1)) ? (uint)damage : 52505, new CastSpellExtraArgs(TriggerCastFlags.FullMask).SetOriginalCastId(m_castId));
return;
case 57347: // Retrieving (Wintergrasp RP-GG pickup spell) case 57347: // Retrieving (Wintergrasp RP-GG pickup spell)
{ {
if (unitTarget == null || !unitTarget.IsTypeId(TypeId.Unit) || !m_caster.IsTypeId(TypeId.Player)) if (unitTarget == null || !unitTarget.IsTypeId(TypeId.Unit) || !m_caster.IsTypeId(TypeId.Player))
@@ -3754,7 +3748,6 @@ namespace Game.Spells
} }
[SpellEffectHandler(SpellEffectName.PullTowards)] [SpellEffectHandler(SpellEffectName.PullTowards)]
[SpellEffectHandler(SpellEffectName.PullTowardsDest)]
void EffectPullTowards() void EffectPullTowards()
{ {
if (effectHandleMode != SpellEffectHandleMode.HitTarget) if (effectHandleMode != SpellEffectHandleMode.HitTarget)
@@ -3763,25 +3756,40 @@ namespace Game.Spells
if (!unitTarget) if (!unitTarget)
return; return;
float speedXY = effectInfo.MiscValue / 10.0f;
float speedZ = damage / 10.0f;
Position pos = new(); Position pos = new();
if (effectInfo.Effect == SpellEffectName.PullTowardsDest) pos.Relocate(m_caster);
{
if (m_targets.HasDst())
pos.Relocate(destTarget);
else
return;
}
else
{
pos.Relocate(m_caster.GetPosition());
}
float speedXY = effectInfo.MiscValue * 0.1f;
float speedZ = (float)(unitTarget.GetDistance(pos) / speedXY * 0.5f * MotionMaster.gravity);
unitTarget.GetMotionMaster().MoveJump(pos, speedXY, speedZ); unitTarget.GetMotionMaster().MoveJump(pos, speedXY, speedZ);
} }
[SpellEffectHandler(SpellEffectName.PullTowardsDest)]
void EffectPullTowardsDest()
{
if (effectHandleMode != SpellEffectHandleMode.HitTarget)
return;
if (!unitTarget)
return;
if (!m_targets.HasDst())
{
Log.outError(LogFilter.Spells, $"Spell {m_spellInfo.Id} with SPELL_EFFECT_PULL_TOWARDS_DEST has no dest target");
return;
}
Position pos = m_targets.GetDstPos();
// This is a blizzlike mistake: this should be 2D distance according to projectile motion formulas, but Blizzard erroneously used 3D distance
float distXY = unitTarget.GetExactDist(pos);
float distZ = pos.GetPositionZ() - unitTarget.GetPositionZ();
float speedXY = effectInfo.MiscValue / 10.0f;
float speedZ = (float)((2 * speedXY * speedXY * distZ + MotionMaster.gravity * distXY * distXY) / (2 * speedXY * distXY));
unitTarget.JumpTo(speedXY, speedZ, true, pos);
}
[SpellEffectHandler(SpellEffectName.ChangeRaidMarker)] [SpellEffectHandler(SpellEffectName.ChangeRaidMarker)]
void EffectChangeRaidMarker() void EffectChangeRaidMarker()
{ {
@@ -4301,8 +4309,6 @@ namespace Game.Spells
var dispellData = new SpellDispellData(); var dispellData = new SpellDispellData();
dispellData.SpellID = dispell.Item1; dispellData.SpellID = dispell.Item1;
dispellData.Harmful = false; // TODO: use me dispellData.Harmful = false; // TODO: use me
//dispellData.Rolled = none; // TODO: use me
//dispellData.Needed = none; // TODO: use me
unitTarget.RemoveAurasDueToSpellBySteal(dispell.Item1, dispell.Item2, m_caster); unitTarget.RemoveAurasDueToSpellBySteal(dispell.Item1, dispell.Item2, m_caster);