Core/Spells: Fixed spell duration scaling with combo points
Port From (https://github.com/TrinityCore/TrinityCore/commit/9e68fd1458551ab0f007b6044c9220da8f7d4199)
This commit is contained in:
@@ -14,7 +14,6 @@ namespace Game.BattleGrounds.Zones
|
|||||||
public BgArathiBasin(BattlegroundTemplate battlegroundTemplate) : base(battlegroundTemplate)
|
public BgArathiBasin(BattlegroundTemplate battlegroundTemplate) : base(battlegroundTemplate)
|
||||||
{
|
{
|
||||||
m_IsInformedNearVictory = false;
|
m_IsInformedNearVictory = false;
|
||||||
m_BuffChange = true;
|
|
||||||
BgObjects = new ObjectGuid[ABObjectTypes.Max];
|
BgObjects = new ObjectGuid[ABObjectTypes.Max];
|
||||||
BgCreatures = new ObjectGuid[ABBattlegroundNodes.AllCount + 5];//+5 for aura triggers
|
BgCreatures = new ObjectGuid[ABBattlegroundNodes.AllCount + 5];//+5 for aura triggers
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ namespace Game.BattleGrounds.Zones
|
|||||||
{
|
{
|
||||||
public BgEyeofStorm(BattlegroundTemplate battlegroundTemplate) : base(battlegroundTemplate)
|
public BgEyeofStorm(BattlegroundTemplate battlegroundTemplate) : base(battlegroundTemplate)
|
||||||
{
|
{
|
||||||
m_BuffChange = true;
|
|
||||||
BgObjects = new ObjectGuid[EotSObjectTypes.Max];
|
BgObjects = new ObjectGuid[EotSObjectTypes.Max];
|
||||||
BgCreatures= new ObjectGuid[EotSCreaturesTypes.Max];
|
BgCreatures= new ObjectGuid[EotSCreaturesTypes.Max];
|
||||||
m_Points_Trigger[EotSPoints.FelReaver] = EotSPointsTrigger.FelReaverBuff;
|
m_Points_Trigger[EotSPoints.FelReaver] = EotSPointsTrigger.FelReaverBuff;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ using Game.Scenarios;
|
|||||||
using Game.Spells;
|
using Game.Spells;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
|
|
||||||
namespace Game.Entities
|
namespace Game.Entities
|
||||||
@@ -1874,27 +1875,39 @@ namespace Game.Entities
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int CalcSpellDuration(SpellInfo spellInfo)
|
public int CalcSpellDuration(SpellInfo spellInfo, List<SpellPowerCost> powerCosts)
|
||||||
{
|
{
|
||||||
int comboPoints = 0;
|
|
||||||
int maxComboPoints = 5;
|
|
||||||
Unit unit = ToUnit();
|
|
||||||
if (unit != null)
|
|
||||||
{
|
|
||||||
comboPoints = unit.GetPower(PowerType.ComboPoints);
|
|
||||||
maxComboPoints = unit.GetMaxPower(PowerType.ComboPoints);
|
|
||||||
}
|
|
||||||
|
|
||||||
int minduration = spellInfo.GetDuration();
|
int minduration = spellInfo.GetDuration();
|
||||||
|
if (minduration <= 0)
|
||||||
|
return minduration;
|
||||||
|
|
||||||
int maxduration = spellInfo.GetMaxDuration();
|
int maxduration = spellInfo.GetMaxDuration();
|
||||||
|
if (minduration == maxduration)
|
||||||
|
return minduration;
|
||||||
|
|
||||||
int duration;
|
Unit unit = ToUnit();
|
||||||
if (comboPoints != 0 && minduration != -1 && minduration != maxduration)
|
if (unit == null)
|
||||||
duration = minduration + ((maxduration - minduration) * comboPoints / maxComboPoints);
|
return minduration;
|
||||||
else
|
|
||||||
duration = minduration;
|
|
||||||
|
|
||||||
return duration;
|
if (powerCosts == null)
|
||||||
|
return minduration;
|
||||||
|
|
||||||
|
// we want only baseline cost here
|
||||||
|
var powerCostRecord = spellInfo.PowerCosts.FirstOrDefault(powerEntry => powerEntry != null && powerEntry.PowerType == PowerType.ComboPoints && (powerEntry.RequiredAuraSpellID == 0 || unit.HasAura(powerEntry.RequiredAuraSpellID)));
|
||||||
|
if (powerCostRecord == null)
|
||||||
|
return minduration;
|
||||||
|
|
||||||
|
var consumedCost = powerCosts.Find(consumed => consumed.Power == PowerType.ComboPoints);
|
||||||
|
if (consumedCost == null)
|
||||||
|
return minduration;
|
||||||
|
|
||||||
|
int baseComboCost = powerCostRecord.ManaCost + (int)powerCostRecord.OptionalCost;
|
||||||
|
var powerTypeEntry = Global.DB2Mgr.GetPowerTypeEntry(PowerType.ComboPoints);
|
||||||
|
if (powerTypeEntry != null)
|
||||||
|
baseComboCost += MathFunctions.CalculatePct(powerTypeEntry.MaxBasePower, powerCostRecord.PowerCostPct + powerCostRecord.OptionalCostPct);
|
||||||
|
|
||||||
|
float durationPerComboPoint = (float)(maxduration - minduration) / baseComboCost;
|
||||||
|
return minduration + (int)(durationPerComboPoint * consumedCost.Amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ModSpellDuration(SpellInfo spellInfo, WorldObject target, int duration, bool positive, uint effectMask)
|
public int ModSpellDuration(SpellInfo spellInfo, WorldObject target, int duration, bool positive, uint effectMask)
|
||||||
|
|||||||
@@ -742,10 +742,10 @@ namespace Game.Spells
|
|||||||
|
|
||||||
public int CalcMaxDuration(Unit caster)
|
public int CalcMaxDuration(Unit caster)
|
||||||
{
|
{
|
||||||
return CalcMaxDuration(GetSpellInfo(), caster);
|
return CalcMaxDuration(GetSpellInfo(), caster, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int CalcMaxDuration(SpellInfo spellInfo, WorldObject caster)
|
public static int CalcMaxDuration(SpellInfo spellInfo, WorldObject caster, List<SpellPowerCost> powerCosts)
|
||||||
{
|
{
|
||||||
Player modOwner = null;
|
Player modOwner = null;
|
||||||
int maxDuration;
|
int maxDuration;
|
||||||
@@ -753,7 +753,7 @@ namespace Game.Spells
|
|||||||
if (caster != null)
|
if (caster != null)
|
||||||
{
|
{
|
||||||
modOwner = caster.GetSpellModOwner();
|
modOwner = caster.GetSpellModOwner();
|
||||||
maxDuration = caster.CalcSpellDuration(spellInfo);
|
maxDuration = caster.CalcSpellDuration(spellInfo, powerCosts);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
maxDuration = spellInfo.GetDuration();
|
maxDuration = spellInfo.GetDuration();
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ namespace Game.Spells
|
|||||||
|
|
||||||
public static float CalculateEstimatedfTotalPeriodicAmount(Unit caster, Unit target, SpellInfo spellInfo, SpellEffectInfo spellEffectInfo, float amount, byte stack)
|
public static float CalculateEstimatedfTotalPeriodicAmount(Unit caster, Unit target, SpellInfo spellInfo, SpellEffectInfo spellEffectInfo, float amount, byte stack)
|
||||||
{
|
{
|
||||||
int maxDuration = Aura.CalcMaxDuration(spellInfo, caster);
|
int maxDuration = Aura.CalcMaxDuration(spellInfo, caster, null);
|
||||||
if (maxDuration <= 0)
|
if (maxDuration <= 0)
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
|
||||||
|
|||||||
@@ -2239,7 +2239,7 @@ namespace Game.Spells
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hitInfo.AuraDuration = Aura.CalcMaxDuration(m_spellInfo, origCaster);
|
hitInfo.AuraDuration = Aura.CalcMaxDuration(m_spellInfo, origCaster, m_powerCost);
|
||||||
|
|
||||||
// unit is immune to aura if it was diminished to 0 duration
|
// unit is immune to aura if it was diminished to 0 duration
|
||||||
if (!hitInfo.Positive && !unit.ApplyDiminishingToDuration(m_spellInfo, ref hitInfo.AuraDuration, origCaster, diminishLevel))
|
if (!hitInfo.Positive && !unit.ApplyDiminishingToDuration(m_spellInfo, ref hitInfo.AuraDuration, origCaster, diminishLevel))
|
||||||
|
|||||||
@@ -2792,25 +2792,19 @@ namespace Game.Spells
|
|||||||
if (power.RequiredAuraSpellID != 0 && !unitCaster.HasAura(power.RequiredAuraSpellID))
|
if (power.RequiredAuraSpellID != 0 && !unitCaster.HasAura(power.RequiredAuraSpellID))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
SpellPowerCost cost = new();
|
|
||||||
|
|
||||||
// Spell drain all exist power on cast (Only paladin lay of Hands)
|
// Spell drain all exist power on cast (Only paladin lay of Hands)
|
||||||
if (HasAttribute(SpellAttr1.UseAllMana))
|
if (HasAttribute(SpellAttr1.UseAllMana))
|
||||||
{
|
{
|
||||||
|
if (optionalCost)
|
||||||
|
return null;
|
||||||
|
|
||||||
// If power type - health drain all
|
// If power type - health drain all
|
||||||
if (power.PowerType == PowerType.Health)
|
if (power.PowerType == PowerType.Health)
|
||||||
{
|
return new SpellPowerCost() { Power = PowerType.Health, Amount = (int)unitCaster.GetHealth() };
|
||||||
cost.Power = PowerType.Health;
|
|
||||||
cost.Amount = (int)unitCaster.GetHealth();
|
|
||||||
return cost;
|
|
||||||
}
|
|
||||||
// Else drain all power
|
// Else drain all power
|
||||||
if (power.PowerType < PowerType.Max)
|
if (power.PowerType < PowerType.Max)
|
||||||
{
|
return new SpellPowerCost() { Power = power.PowerType, Amount = unitCaster.GetPower(power.PowerType) };
|
||||||
cost.Power = power.PowerType;
|
|
||||||
cost.Amount = unitCaster.GetPower(cost.Power);
|
|
||||||
return cost;
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.outError(LogFilter.Spells, $"SpellInfo.CalcPowerCost: Unknown power type '{power.PowerType}' in spell {Id}");
|
Log.outError(LogFilter.Spells, $"SpellInfo.CalcPowerCost: Unknown power type '{power.PowerType}' in spell {Id}");
|
||||||
return default;
|
return default;
|
||||||
@@ -2997,9 +2991,7 @@ namespace Game.Spells
|
|||||||
if (initiallyNegative != (powerCost < 0))
|
if (initiallyNegative != (powerCost < 0))
|
||||||
powerCost = 0;
|
powerCost = 0;
|
||||||
|
|
||||||
cost.Power = power.PowerType;
|
return new SpellPowerCost() { Power = power.PowerType, Amount = powerCost };
|
||||||
cost.Amount = powerCost;
|
|
||||||
return cost;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SpellPowerCost> CalcPowerCost(WorldObject caster, SpellSchoolMask schoolMask, Spell spell = null)
|
public List<SpellPowerCost> CalcPowerCost(WorldObject caster, SpellSchoolMask schoolMask, Spell spell = null)
|
||||||
@@ -3013,11 +3005,8 @@ namespace Game.Spells
|
|||||||
if (itr != null)
|
if (itr != null)
|
||||||
return itr;
|
return itr;
|
||||||
|
|
||||||
SpellPowerCost cost = new();
|
costs.Add(new SpellPowerCost() { Power = powerType, Amount = 0 });
|
||||||
cost.Power = powerType;
|
return costs.Last();
|
||||||
cost.Amount = 0;
|
|
||||||
costs.Add(cost);
|
|
||||||
return costs.Last();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (SpellPowerRecord power in PowerCosts)
|
foreach (SpellPowerRecord power in PowerCosts)
|
||||||
|
|||||||
Reference in New Issue
Block a user