diff options
Diffstat (limited to 'src/server')
-rw-r--r-- | src/server/game/Entities/Object/Object.cpp | 4 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 28 | ||||
-rw-r--r-- | src/server/game/Spells/SpellInfo.cpp | 1 | ||||
-rw-r--r-- | src/server/game/Spells/SpellInfo.h | 1 |
4 files changed, 18 insertions, 16 deletions
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 8dda5aab212..4e0aea7e99e 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -3376,9 +3376,9 @@ Unit* WorldObject::GetMagicHitRedirectTarget(Unit* victim, SpellInfo const* spel // Set up missile speed based delay float hitDelay = spellInfo->LaunchDelay; if (spellInfo->HasAttribute(SPELL_ATTR9_MISSILE_SPEED_IS_DELAY_IN_SEC)) - hitDelay += spellInfo->Speed; + hitDelay += std::max(spellInfo->Speed, spellInfo->MinDuration); else if (spellInfo->Speed > 0.0f) - hitDelay += std::max(victim->GetDistance(this), 5.0f) / spellInfo->Speed; + hitDelay += std::max(std::max(victim->GetDistance(this), 5.0f) / spellInfo->Speed, spellInfo->MinDuration); uint32 delay = uint32(std::floor(hitDelay * 1000.0f)); // Schedule charge drop diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 86fd0feeec8..4aa7d5bf05c 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -826,15 +826,15 @@ uint64 Spell::CalculateDelayMomentForDst(float launchDelay) const { float speed = m_targets.GetSpeedXY(); if (speed > 0.0f) - return uint64(std::floor((m_targets.GetDist2d() / speed + launchDelay) * 1000.0f)); + return uint64(std::floor((std::max(m_targets.GetDist2d() / speed, m_spellInfo->MinDuration) + launchDelay) * 1000.0f)); } else if (m_spellInfo->HasAttribute(SPELL_ATTR9_MISSILE_SPEED_IS_DELAY_IN_SEC)) - return uint64(std::floor((m_spellInfo->Speed + launchDelay) * 1000.0f)); + return uint64(std::floor((std::max(m_spellInfo->Speed, m_spellInfo->MinDuration) + launchDelay) * 1000.0f)); else if (m_spellInfo->Speed > 0.0f) { // We should not subtract caster size from dist calculation (fixes execution time desync with animation on client, eg. Malleable Goo cast by PP) float dist = m_caster->GetExactDist(*m_targets.GetDstPos()); - return uint64(std::floor((dist / m_spellInfo->Speed + launchDelay) * 1000.0f)); + return uint64(std::floor((std::max(dist / m_spellInfo->Speed, m_spellInfo->MinDuration) + launchDelay) * 1000.0f)); } return uint64(std::floor(launchDelay * 1000.0f)); @@ -2425,7 +2425,7 @@ void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*= ObjectGuid targetGUID = target->GetGUID(); // Lookup target in already in list - auto ihit = std::find_if(std::begin(m_UniqueTargetInfo), std::end(m_UniqueTargetInfo), [targetGUID](TargetInfo const& target) { return target.TargetGUID == targetGUID; }); + auto ihit = std::ranges::find(m_UniqueTargetInfo, targetGUID, &TargetInfo::TargetGUID); if (ihit != std::end(m_UniqueTargetInfo)) // Found in list { // Immune effects removed from mask @@ -2456,7 +2456,7 @@ void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*= WorldObject const* missileSource = m_caster; if (m_spellInfo->HasAttribute(SPELL_ATTR4_BOUNCY_CHAIN_MISSILES)) { - auto previousTargetItr = std::find_if(m_UniqueTargetInfo.rbegin(), m_UniqueTargetInfo.rend(), [effectMask](TargetInfo const& target) + auto previousTargetItr = std::ranges::find_if(m_UniqueTargetInfo.rbegin(), m_UniqueTargetInfo.rend(), [effectMask](TargetInfo const& target) { return (target.EffectMask & effectMask) != 0; }); @@ -2472,13 +2472,13 @@ void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*= } if (m_spellInfo->HasAttribute(SPELL_ATTR9_MISSILE_SPEED_IS_DELAY_IN_SEC)) - hitDelay += m_spellInfo->Speed; + hitDelay += std::max(m_spellInfo->Speed, m_spellInfo->MinDuration); else if (m_spellInfo->Speed > 0.0f) { // calculate spell incoming interval /// @todo this is a hack float dist = std::max(missileSource->GetDistance(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ()), 5.0f); - hitDelay += dist / m_spellInfo->Speed; + hitDelay += std::max(dist / m_spellInfo->Speed, m_spellInfo->MinDuration); } targetInfo.TimeDelay += uint64(std::floor(hitDelay * 1000.0f)); @@ -2523,7 +2523,7 @@ void Spell::AddGOTarget(GameObject* go, uint32 effectMask) ObjectGuid targetGUID = go->GetGUID(); // Lookup target in already in list - auto ihit = std::find_if(std::begin(m_UniqueGOTargetInfo), std::end(m_UniqueGOTargetInfo), [targetGUID](GOTargetInfo const& target) { return target.TargetGUID == targetGUID; }); + auto ihit = std::ranges::find(m_UniqueGOTargetInfo, targetGUID, &GOTargetInfo::TargetGUID); if (ihit != std::end(m_UniqueGOTargetInfo)) // Found in list { // Add only effect mask @@ -2542,12 +2542,12 @@ void Spell::AddGOTarget(GameObject* go, uint32 effectMask) { float hitDelay = m_spellInfo->LaunchDelay; if (m_spellInfo->HasAttribute(SPELL_ATTR9_MISSILE_SPEED_IS_DELAY_IN_SEC)) - hitDelay += m_spellInfo->Speed; + hitDelay += std::max(m_spellInfo->Speed, m_spellInfo->MinDuration); else if (m_spellInfo->Speed > 0.0f) { // calculate spell incoming interval float dist = std::max(m_caster->GetDistance(go->GetPositionX(), go->GetPositionY(), go->GetPositionZ()), 5.0f); - hitDelay += dist / m_spellInfo->Speed; + hitDelay += std::max(dist / m_spellInfo->Speed, m_spellInfo->MinDuration); } target.TimeDelay = uint64(std::floor(hitDelay * 1000.0f)); @@ -2574,7 +2574,7 @@ void Spell::AddItemTarget(Item* item, uint32 effectMask) return; // Lookup target in already in list - auto ihit = std::find_if(std::begin(m_UniqueItemInfo), std::end(m_UniqueItemInfo), [item](ItemTargetInfo const& target) { return target.TargetItem == item; }); + auto ihit = std::ranges::find(m_UniqueItemInfo, item, &ItemTargetInfo::TargetItem); if (ihit != std::end(m_UniqueItemInfo)) // Found in list { // Add only effect mask @@ -2604,7 +2604,7 @@ void Spell::AddCorpseTarget(Corpse* corpse, uint32 effectMask) ObjectGuid targetGUID = corpse->GetGUID(); // Lookup target in already in list - auto ihit = std::find_if(std::begin(m_UniqueCorpseTargetInfo), std::end(m_UniqueCorpseTargetInfo), [targetGUID](CorpseTargetInfo const& target) { return target.TargetGUID == targetGUID; }); + auto ihit = std::ranges::find(m_UniqueCorpseTargetInfo, targetGUID, &CorpseTargetInfo::TargetGUID); if (ihit != std::end(m_UniqueCorpseTargetInfo)) // Found in list { // Add only effect mask @@ -2622,12 +2622,12 @@ void Spell::AddCorpseTarget(Corpse* corpse, uint32 effectMask) { float hitDelay = m_spellInfo->LaunchDelay; if (m_spellInfo->HasAttribute(SPELL_ATTR9_MISSILE_SPEED_IS_DELAY_IN_SEC)) - hitDelay += m_spellInfo->Speed; + hitDelay += std::max(m_spellInfo->Speed, m_spellInfo->MinDuration); else if (m_spellInfo->Speed > 0.0f) { // calculate spell incoming interval float dist = std::max(m_caster->GetDistance(corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ()), 5.0f); - hitDelay += dist / m_spellInfo->Speed; + hitDelay += std::max(dist / m_spellInfo->Speed, m_spellInfo->MinDuration); } target.TimeDelay = uint64(std::floor(hitDelay * 1000.0f)); diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index 95432f8f02c..bb27b4c7488 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -1276,6 +1276,7 @@ SpellInfo::SpellInfo(SpellNameEntry const* spellName, ::Difficulty difficulty, S RangeEntry = sSpellRangeStore.LookupEntry(_misc->RangeIndex); Speed = _misc->Speed; LaunchDelay = _misc->LaunchDelay; + MinDuration = _misc->MinDuration; SchoolMask = _misc->SchoolMask; IconFileDataId = _misc->SpellIconFileDataID; ActiveIconFileDataId = _misc->ActiveIconFileDataID; diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h index f1e01769316..eda431859b6 100644 --- a/src/server/game/Spells/SpellInfo.h +++ b/src/server/game/Spells/SpellInfo.h @@ -385,6 +385,7 @@ class TC_GAME_API SpellInfo SpellRangeEntry const* RangeEntry = nullptr; float Speed = 0.0f; float LaunchDelay = 0.0f; + float MinDuration = 0.0f; uint32 StackAmount = 0; std::array<int32, MAX_SPELL_TOTEMS> Totem = {}; std::array<uint16, MAX_SPELL_TOTEMS> TotemCategory = {}; |