Core/Spells: Support spells that have both charge recovery and separate cooldown
Port From (https://github.com/TrinityCore/TrinityCore/commit/b248e059064031fdbb75a863913d7d5eb461db41)
This commit is contained in:
@@ -185,8 +185,7 @@ namespace Game.Spells
|
|||||||
if (spell != null && spell.IsIgnoringCooldowns())
|
if (spell != null && spell.IsIgnoringCooldowns())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (ConsumeCharge(spellInfo.ChargeCategoryId))
|
ConsumeCharge(spellInfo.ChargeCategoryId);
|
||||||
return;
|
|
||||||
|
|
||||||
if (_owner.HasAuraTypeWithAffectMask(AuraType.IgnoreSpellCooldown, spellInfo))
|
if (_owner.HasAuraTypeWithAffectMask(AuraType.IgnoreSpellCooldown, spellInfo))
|
||||||
return;
|
return;
|
||||||
@@ -537,7 +536,7 @@ namespace Game.Spells
|
|||||||
public void ModifySpellCooldown(uint spellId, TimeSpan cooldownMod, bool withoutCategoryCooldown)
|
public void ModifySpellCooldown(uint spellId, TimeSpan cooldownMod, bool withoutCategoryCooldown)
|
||||||
{
|
{
|
||||||
var cooldownEntry = _spellCooldowns.LookupByKey(spellId);
|
var cooldownEntry = _spellCooldowns.LookupByKey(spellId);
|
||||||
if (cooldownMod.TotalMilliseconds == 0 || cooldownEntry == null)
|
if (cooldownEntry == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ModifySpellCooldown(cooldownEntry, cooldownMod, withoutCategoryCooldown);
|
ModifySpellCooldown(cooldownEntry, cooldownMod, withoutCategoryCooldown);
|
||||||
@@ -623,10 +622,8 @@ namespace Game.Spells
|
|||||||
if (cooldownMod == TimeSpan.Zero)
|
if (cooldownMod == TimeSpan.Zero)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (GetChargeRecoveryTime(spellInfo.ChargeCategoryId) > 0 && GetMaxCharges(spellInfo.ChargeCategoryId) > 0)
|
ModifyChargeRecoveryTime(spellInfo.ChargeCategoryId, cooldownMod);
|
||||||
ModifyChargeRecoveryTime(spellInfo.ChargeCategoryId, cooldownMod);
|
ModifySpellCooldown(spellInfo.Id, cooldownMod, withoutCategoryCooldown);
|
||||||
else
|
|
||||||
ModifySpellCooldown(spellInfo.Id, cooldownMod, withoutCategoryCooldown);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ModifyCoooldowns(Func<CooldownEntry, bool> predicate, TimeSpan cooldownMod, bool withoutCategoryCooldown = false)
|
public void ModifyCoooldowns(Func<CooldownEntry, bool> predicate, TimeSpan cooldownMod, bool withoutCategoryCooldown = false)
|
||||||
@@ -838,29 +835,26 @@ namespace Game.Spells
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ConsumeCharge(uint chargeCategoryId)
|
public void ConsumeCharge(uint chargeCategoryId)
|
||||||
{
|
{
|
||||||
if (!CliDB.SpellCategoryStorage.ContainsKey(chargeCategoryId))
|
if (!CliDB.SpellCategoryStorage.ContainsKey(chargeCategoryId))
|
||||||
return false;
|
return;
|
||||||
|
|
||||||
int chargeRecovery = GetChargeRecoveryTime(chargeCategoryId);
|
int chargeRecovery = GetChargeRecoveryTime(chargeCategoryId);
|
||||||
if (chargeRecovery > 0 && GetMaxCharges(chargeCategoryId) > 0)
|
if (chargeRecovery <= 0 && GetMaxCharges(chargeCategoryId) <= 0)
|
||||||
{
|
return;
|
||||||
if (_owner.HasAuraTypeWithMiscvalue(AuraType.IgnoreSpellChargeCooldown, (int)chargeCategoryId))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
DateTime recoveryStart;
|
if (_owner.HasAuraTypeWithMiscvalue(AuraType.IgnoreSpellChargeCooldown, (int)chargeCategoryId))
|
||||||
var charges = _categoryCharges.LookupByKey(chargeCategoryId);
|
return;
|
||||||
if (charges.Empty())
|
|
||||||
recoveryStart = GameTime.GetSystemTime();
|
|
||||||
else
|
|
||||||
recoveryStart = charges.Last().RechargeEnd;
|
|
||||||
|
|
||||||
_categoryCharges.Add(chargeCategoryId, new ChargeEntry(recoveryStart, TimeSpan.FromMilliseconds(chargeRecovery)));
|
DateTime recoveryStart;
|
||||||
return true;
|
var charges = _categoryCharges.LookupByKey(chargeCategoryId);
|
||||||
}
|
if (charges.Empty())
|
||||||
|
recoveryStart = GameTime.GetSystemTime();
|
||||||
|
else
|
||||||
|
recoveryStart = charges.Last().RechargeEnd;
|
||||||
|
|
||||||
return false;
|
_categoryCharges.Add(chargeCategoryId, new ChargeEntry(recoveryStart, TimeSpan.FromMilliseconds(chargeRecovery)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModifyChargeRecoveryTime(uint chargeCategoryId, TimeSpan cooldownMod)
|
void ModifyChargeRecoveryTime(uint chargeCategoryId, TimeSpan cooldownMod)
|
||||||
|
|||||||
Reference in New Issue
Block a user