mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 18:36:31 +01:00
Core/Spell: Jump Speed Calculations (#22886)
* Jump Speed Calculations * Fix
This commit is contained in:
@@ -765,6 +765,7 @@ class TC_GAME_API Spell
|
||||
|
||||
// effect helpers
|
||||
void SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const* properties, uint32 numSummons);
|
||||
void CalculateJumpSpeeds(SpellInfo const* spellInfo, uint8 i, float dist, float& speedXY, float& speedZ);
|
||||
|
||||
SpellCastResult CanOpenLock(uint32 effIndex, uint32 lockid, SkillType& skillid, int32& reqSkillValue, int32& skillValue);
|
||||
// -------------------------------------------
|
||||
|
||||
@@ -965,16 +965,31 @@ void Spell::EffectTriggerRitualOfSummoning(SpellEffIndex effIndex)
|
||||
m_caster->CastSpell(nullptr, spellInfo->Id, false);
|
||||
}
|
||||
|
||||
inline void CalculateJumpSpeeds(SpellInfo const* spellInfo, uint8 i, float dist, float& speedXY, float& speedZ)
|
||||
void Spell::CalculateJumpSpeeds(SpellInfo const* spellInfo, uint8 i, float dist, float& speedXY, float& speedZ)
|
||||
{
|
||||
if (spellInfo->Effects[i].MiscValue)
|
||||
speedZ = spellInfo->Effects[i].MiscValue / 10.f;
|
||||
else if (spellInfo->Effects[i].MiscValueB)
|
||||
speedZ = spellInfo->Effects[i].MiscValueB / 10.f;
|
||||
else
|
||||
speedZ = 10.0f;
|
||||
float runSpeed = unitCaster->IsControlledByPlayer() ? playerBaseMoveSpeed[MOVE_RUN] : baseMoveSpeed[MOVE_RUN];
|
||||
if (Creature* creature = unitCaster->ToCreature())
|
||||
runSpeed *= creature->GetCreatureTemplate()->speed_run;
|
||||
|
||||
speedXY = dist * 10.0f / speedZ;
|
||||
float multiplier = m_spellInfo->Effects[i].ValueMultiplier;
|
||||
if (multiplier <= 0.0f)
|
||||
multiplier = 1.0f;
|
||||
|
||||
speedXY = std::min(runSpeed * 3.0f * multiplier, std::max(28.0f, unitCaster->GetSpeed(MOVE_RUN) * 4.0f));
|
||||
|
||||
float duration = dist / speedXY;
|
||||
float durationSqr = duration * duration;
|
||||
float minHeight = spellInfo->Effects[i].MiscValue ? spellInfo->Effects[i].MiscValue / 10.0f : 0.5f; // Lower bound is blizzlike
|
||||
float maxHeight = spellInfo->Effects[i].MiscValueB ? spellInfo->Effects[i].MiscValueB / 10.0f : 1000.0f; // Upper bound is unknown
|
||||
float height;
|
||||
if (durationSqr < minHeight * 8 / Movement::gravity)
|
||||
height = minHeight;
|
||||
else if (durationSqr > maxHeight * 8 / Movement::gravity)
|
||||
height = maxHeight;
|
||||
else
|
||||
height = Movement::gravity * durationSqr / 8;
|
||||
|
||||
speedZ = std::sqrt(2 * Movement::gravity * height);
|
||||
}
|
||||
|
||||
void Spell::EffectJump(SpellEffIndex effIndex)
|
||||
|
||||
Reference in New Issue
Block a user