Core/Spells: Implemented SpellValueMod duration

Port From (https://github.com/TrinityCore/TrinityCore/commit/a048475cb037a3a3672723c1f2ab32a343142927)
This commit is contained in:
hondacrx
2021-10-08 10:30:35 -04:00
parent 06e7a9ddd5
commit 3971aea8f9
2 changed files with 54 additions and 34 deletions
+2 -1
View File
@@ -396,7 +396,8 @@ namespace Framework.Constants
MaxTargets,
AuraStack,
CritChance,
DurationPct
DurationPct,
Duration
}
public enum CombatRating
+23 -4
View File
@@ -2048,7 +2048,9 @@ namespace Game.Spells
spellAura.SetDiminishGroup(hitInfo.DRGroup);
hitInfo.AuraDuration = caster.ModSpellDuration(m_spellInfo, unit, hitInfo.AuraDuration, hitInfo.Positive, spellAura.GetEffectMask());
if (!m_spellValue.Duration.HasValue)
{
hitInfo.AuraDuration *= caster.ModSpellDuration(m_spellInfo, unit, hitInfo.AuraDuration, hitInfo.Positive, spellAura.GetEffectMask());
if (hitInfo.AuraDuration > 0)
{
@@ -2076,6 +2078,9 @@ namespace Game.Spells
hitInfo.AuraDuration = (int)(origDuration * m_originalCaster.m_unitData.ModCastingSpeed);
}
}
}
else
hitInfo.AuraDuration = m_spellValue.Duration.Value;
if (hitInfo.AuraDuration != spellAura.GetMaxDuration())
{
@@ -2799,7 +2804,9 @@ namespace Game.Spells
if (m_spellInfo.IsChanneled())
{
int duration = m_spellInfo.GetDuration();
if (duration > 0)
if (duration > 0 || m_spellValue.Duration.HasValue)
{
if (!m_spellValue.Duration.HasValue)
{
// First mod_duration then haste - see Missile Barrage
// Apply duration mod
@@ -2811,11 +2818,15 @@ namespace Game.Spells
// Apply haste mods
m_caster.ModSpellDurationTime(m_spellInfo, ref duration, this);
}
else
duration = m_spellValue.Duration.Value;
m_channeledDuration = duration;
SendChannelStart((uint)duration);
}
else if (duration == -1)
SendChannelStart((uint)duration);
SendChannelStart(unchecked((uint)duration));
if (duration != 0)
{
@@ -6424,7 +6435,10 @@ namespace Game.Spells
return;
//check pushback reduce
int delaytime = MathFunctions.CalculatePct(m_spellInfo.GetDuration(), 25); // channeling delay is normally 25% of its time per hit
// should be affected by modifiers, not take the dbc duration.
int duration = ((m_channeledDuration > 0) ? m_channeledDuration : m_spellInfo.GetDuration());
int delaytime = MathFunctions.CalculatePct(duration, 25); // channeling delay is normally 25% of its time per hit
int delayReduce = 100; // must be initialized to 100 for percent modifiers
Player player = unitCaster.GetSpellModOwner();
@@ -6879,6 +6893,9 @@ namespace Game.Spells
case SpellValueMod.DurationPct:
m_spellValue.DurationMul = (float)value / 100.0f;
break;
case SpellValueMod.Duration:
m_spellValue.Duration.Set(value);
break;
}
}
@@ -7415,6 +7432,7 @@ namespace Game.Spells
List<SpellPowerCost> m_powerCost = new();
int m_casttime; // Calculated spell cast time initialized only in Spell.prepare
int m_channeledDuration; // Calculated channeled spell duration in order to calculate correct pushback.
bool m_canReflect; // can reflect this spell?
bool m_autoRepeat;
byte m_runesState;
@@ -8073,6 +8091,7 @@ namespace Game.Spells
public int AuraStackAmount;
public float DurationMul;
public float CriticalChance;
public Optional<int> Duration;
}
// Spell modifier (used for modify other spells)