Skip to content

Commit

Permalink
Adjust EffectPlayerPull so that it accounts for Z difference
Browse files Browse the repository at this point in the history
Fixes pull issues in murmurs room

The initial formula was the following:
distance/horizontal speed = time
1/2*gravitational acceleration*time = initial vertical speed

Problem is when intial Z != final Z
Then the formula is as following:
(final Z - initial Z + 1/2*gravitational acceleration*time*time) / time = initial vertical speed
if you set final z - initial z both to 0, or the same number, you get the initial formula

WOTLK:
The wotlk core uses movespline to compute this. MoveJump is used all over scripts with guessed Max Height, which sounds quite bad, since that should be a computed
value stemming from spells. (client is sent horizontal and vertical speed in packet)
In future need to change from max height to vertical speed so that it reflects client usage.
  • Loading branch information
killerwife committed Nov 23, 2017
1 parent 4fa6cff commit 31e2c5f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/game/Spells/SpellEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include "Entities/Vehicle.h"
#include "G3D/Vector3.h"
#include "Loot/LootMgr.h"
#include "Movement/MoveSpline.h"

pEffect SpellEffects[TOTAL_SPELL_EFFECTS] =
{
Expand Down Expand Up @@ -11592,16 +11593,15 @@ void Spell::EffectPlayerPull(SpellEffectIndex eff_idx)

float x, y, z;
m_caster->GetPosition(x, y, z);

// move back a bit
x = x - (0.6 * cos(m_caster->GetOrientation() + M_PI_F));
y = y - (0.6 * sin(m_caster->GetOrientation() + M_PI_F));

// Try to normalize Z coord because GetContactPoint do nothing with Z axis
unitTarget->UpdateAllowedPositionZ(x, y, z);

float speed = m_spellInfo->speed ? m_spellInfo->speed : 27.0f;
unitTarget->GetMotionMaster()->MoveJump(x, y, z, speed, 2.5f);
float dist = unitTarget->GetDistance2d(m_caster);

// Projectile motion
float speedXY = float(m_spellInfo->EffectMiscValue[eff_idx]) * 0.1f;
float time = dist / speedXY;
float speedZ = ((m_caster->GetPositionZ() - unitTarget->GetPositionZ()) + 0.5f*time*time*Movement::gravity) / time;
float moveTimeHalf = speedZ / Movement::gravity;
float max_height = -Movement::computeFallElevation(moveTimeHalf, false, -speedZ);
unitTarget->GetMotionMaster()->MoveJump(x, y, z, speedXY, max_height, 2.5f);

This comment has been minimized.

Copy link
@DomGries

DomGries Aug 26, 2018

Contributor

2.5f is used for MoveJump parameter uint32 id causing: Implicit conversion from 'float' to 'uint32' (aka 'unsigned int') changes value from 2.5 to 2 [clang-diagnostic-literal-conversion]

This comment has been minimized.

Copy link
@killerwife

killerwife Aug 26, 2018

Author Contributor

Yes, but the whole spline simulation is a tad wrong anyhow, because it doesn't check on collision. The TBC version is working correctly, and this one is basically a bandaid. TC has same issue on this front. So I didn't fuss over this too much. Besides our MoveJump defines the parabolic movement not like the blizzard client system does, so that needs to be changed as well in the future.

}

void Spell::EffectDispelMechanic(SpellEffectIndex eff_idx)
Expand Down

0 comments on commit 31e2c5f

Please sign in to comment.