diff --git a/Source/Framework/Constants/SharedConst.cs b/Source/Framework/Constants/SharedConst.cs index 2e8cbd072..28a83f695 100644 --- a/Source/Framework/Constants/SharedConst.cs +++ b/Source/Framework/Constants/SharedConst.cs @@ -57,7 +57,6 @@ namespace Framework.Constants public const int SpellReviveBattlePets = 125439; public const int SpellSummonBattlePet = 118301; public const int MaxBattlePetLevel = 25; - public static TimeSpan ReviveBattlePetsCooldown = TimeSpan.FromSeconds(180); /// /// Lfg Const diff --git a/Source/Game/Entities/Player/Player.Spells.cs b/Source/Game/Entities/Player/Player.Spells.cs index ee1060a31..340b7853a 100644 --- a/Source/Game/Entities/Player/Player.Spells.cs +++ b/Source/Game/Entities/Player/Player.Spells.cs @@ -1014,25 +1014,6 @@ namespace Game.Entities m_lastPotionId = 0; } - public void UpdateReviveBattlePetCooldown() - { - SpellInfo reviveBattlePetSpellInfo = Global.SpellMgr.GetSpellInfo(SharedConst.SpellReviveBattlePets, Difficulty.None); - - if (reviveBattlePetSpellInfo != null && HasSpell(SharedConst.SpellReviveBattlePets)) - { - var remainingCooldown = GetSpellHistory().GetRemainingCategoryCooldown(reviveBattlePetSpellInfo); - if (remainingCooldown > TimeSpan.Zero) - { - if (remainingCooldown < SharedConst.ReviveBattlePetsCooldown) - GetSpellHistory().ModifyCooldown(reviveBattlePetSpellInfo, SharedConst.ReviveBattlePetsCooldown - remainingCooldown); - } - else - { - GetSpellHistory().StartCooldown(reviveBattlePetSpellInfo, 0, null, false, SharedConst.ReviveBattlePetsCooldown); - } - } - } - public bool CanUseMastery() { ChrSpecializationRecord chrSpec = CliDB.ChrSpecializationStorage.LookupByKey(GetPrimarySpecialization()); diff --git a/Source/Game/Handlers/CharacterHandler.cs b/Source/Game/Handlers/CharacterHandler.cs index 95838121b..2d85ed435 100644 --- a/Source/Game/Handlers/CharacterHandler.cs +++ b/Source/Game/Handlers/CharacterHandler.cs @@ -854,8 +854,6 @@ namespace Game pCurrChar.SendInitialPacketsAfterAddToMap(); - pCurrChar.UpdateReviveBattlePetCooldown(); - PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_CHAR_ONLINE); stmt.AddValue(0, pCurrChar.GetGUID().GetCounter()); DB.Characters.Execute(stmt); diff --git a/Source/Scripts/Spells/Generic.cs b/Source/Scripts/Spells/Generic.cs index 4b894a844..b5f7c68d1 100644 --- a/Source/Scripts/Spells/Generic.cs +++ b/Source/Scripts/Spells/Generic.cs @@ -4728,6 +4728,46 @@ namespace Scripts.Spells.Generic } } + [Script] // 132334 - Trainer Heal Cooldown (SERVERSIDE) + class spell_gen_trainer_heal_cooldown : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SharedConst.SpellReviveBattlePets); + } + + public override bool Load() + { + return GetUnitOwner().IsPlayer(); + } + + void UpdateReviveBattlePetCooldown(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Player target = GetUnitOwner().ToPlayer(); + SpellInfo reviveBattlePetSpellInfo = Global.SpellMgr.GetSpellInfo(SharedConst.SpellReviveBattlePets, Difficulty.None); + + if (target.GetSession().GetBattlePetMgr().IsBattlePetSystemEnabled()) + { + TimeSpan expectedCooldown = TimeSpan.FromMilliseconds(GetAura().GetMaxDuration()); + TimeSpan remainingCooldown = target.GetSpellHistory().GetRemainingCategoryCooldown(reviveBattlePetSpellInfo); + if (remainingCooldown > TimeSpan.Zero) + { + if (remainingCooldown < expectedCooldown) + target.GetSpellHistory().ModifyCooldown(reviveBattlePetSpellInfo, expectedCooldown - remainingCooldown); + } + else + { + target.GetSpellHistory().StartCooldown(reviveBattlePetSpellInfo, 0, null, false, expectedCooldown); + } + } + } + + public override void Register() + { + OnEffectApply.Add(new EffectApplyHandler(UpdateReviveBattlePetCooldown, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + } + } + [Script] // 45313 - Anchor Here class spell_gen_anchor_here : SpellScript {