aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2022-10-14 17:12:33 +0200
committerShauren <shauren.trinity@gmail.com>2022-10-14 17:12:33 +0200
commit05f2f4e8f69133d542f3eadf99410deb932cd30d (patch)
treeaacf68a9c942086ccca9a47cabf74d1fc91497a1
parent277c063413e4ec54ba943abd87cc1d273ad035e5 (diff)
Core/BattlePets: Move revive battle pet cooldown to spell script and add serverside spell for stable master heal cooldown
-rw-r--r--sql/updates/world/master/2022_10_14_00_world.sql11
-rw-r--r--src/server/game/BattlePets/BattlePetMgr.h1
-rw-r--r--src/server/game/Entities/Player/Player.cpp19
-rw-r--r--src/server/game/Entities/Player/Player.h1
-rw-r--r--src/server/game/Handlers/CharacterHandler.cpp2
-rw-r--r--src/server/scripts/Spells/spell_generic.cpp44
6 files changed, 55 insertions, 23 deletions
diff --git a/sql/updates/world/master/2022_10_14_00_world.sql b/sql/updates/world/master/2022_10_14_00_world.sql
new file mode 100644
index 00000000000..dbc31ac1f8a
--- /dev/null
+++ b/sql/updates/world/master/2022_10_14_00_world.sql
@@ -0,0 +1,11 @@
+DELETE FROM `serverside_spell` WHERE `Id`=132334;
+INSERT INTO `serverside_spell` (`Id`,`DifficultyID`,`CategoryId`,`Dispel`,`Mechanic`,`Attributes`,`AttributesEx`,`AttributesEx2`,`AttributesEx3`,`AttributesEx4`,`AttributesEx5`,`AttributesEx6`,`AttributesEx7`,`AttributesEx8`,`AttributesEx9`,`AttributesEx10`,`AttributesEx11`,`AttributesEx12`,`AttributesEx13`,`AttributesEx14`,`Stances`,`StancesNot`,`Targets`,`TargetCreatureType`,`RequiresSpellFocus`,`FacingCasterFlags`,`CasterAuraState`,`TargetAuraState`,`ExcludeCasterAuraState`,`ExcludeTargetAuraState`,`CasterAuraSpell`,`TargetAuraSpell`,`ExcludeCasterAuraSpell`,`ExcludeTargetAuraSpell`,`CastingTimeIndex`,`RecoveryTime`,`CategoryRecoveryTime`,`StartRecoveryCategory`,`StartRecoveryTime`,`InterruptFlags`,`AuraInterruptFlags1`,`AuraInterruptFlags2`,`ChannelInterruptFlags1`,`ChannelInterruptFlags2`,`ProcFlags`,`ProcFlags2`,`ProcChance`,`ProcCharges`,`ProcCooldown`,`ProcBasePPM`,`MaxLevel`,`BaseLevel`,`SpellLevel`,`DurationIndex`,`RangeIndex`,`Speed`,`LaunchDelay`,`StackAmount`,`EquippedItemClass`,`EquippedItemSubClassMask`,`EquippedItemInventoryTypeMask`,`ContentTuningId`,`SpellName`,`ConeAngle`,`ConeWidth`,`MaxTargetLevel`,`MaxAffectedTargets`,`SpellFamilyName`,`SpellFamilyFlags1`,`SpellFamilyFlags2`,`SpellFamilyFlags3`,`SpellFamilyFlags4`,`DmgClass`,`PreventionType`,`AreaGroupId`,`SchoolMask`,`ChargeCategoryId`) VALUES
+(132334,0,0,0,0,0x2D800000,0x80000020,0x10024081,0x530000,0x100081,0x60408,0x10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,1,0,0,0,-1,0,0,0,'Trainer Heal Cooldown',0,0,0,0,0,0,0,0,0,0,0,0,0,0);
+
+DELETE FROM `serverside_spell_effect` WHERE `SpellID`=132334;
+INSERT INTO `serverside_spell_effect` (`SpellID`,`Effect`,`EffectAura`,`EffectChainAmplitude`) VALUES
+(132334,6,4,1);
+
+DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_gen_trainer_heal_cooldown';
+INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES
+(132334,'spell_gen_trainer_heal_cooldown');
diff --git a/src/server/game/BattlePets/BattlePetMgr.h b/src/server/game/BattlePets/BattlePetMgr.h
index 9de32cfa8cc..781adb0788c 100644
--- a/src/server/game/BattlePets/BattlePetMgr.h
+++ b/src/server/game/BattlePets/BattlePetMgr.h
@@ -39,7 +39,6 @@ enum BattlePetMisc
};
static constexpr uint16 MAX_BATTLE_PET_LEVEL = 25;
-static constexpr Milliseconds REVIVE_BATTLE_PETS_COOLDOWN = 180s;
enum class BattlePetBreedQuality : uint8
{
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 1e70772d262..d00152aa005 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -22575,25 +22575,6 @@ void Player::UpdatePotionCooldown(Spell* spell)
m_lastPotionId = 0;
}
-void Player::UpdateReviveBattlePetCooldown()
-{
- SpellInfo const* reviveBattlePetSpellInfo = sSpellMgr->GetSpellInfo(BattlePets::SPELL_REVIVE_BATTLE_PETS, DIFFICULTY_NONE);
-
- if (reviveBattlePetSpellInfo && HasSpell(BattlePets::SPELL_REVIVE_BATTLE_PETS))
- {
- SpellHistory::Duration remainingCooldown = GetSpellHistory()->GetRemainingCategoryCooldown(reviveBattlePetSpellInfo);
- if (remainingCooldown > SpellHistory::Duration::zero())
- {
- if (remainingCooldown < BattlePets::REVIVE_BATTLE_PETS_COOLDOWN)
- GetSpellHistory()->ModifyCooldown(reviveBattlePetSpellInfo, BattlePets::REVIVE_BATTLE_PETS_COOLDOWN - remainingCooldown);
- }
- else
- {
- GetSpellHistory()->StartCooldown(reviveBattlePetSpellInfo, 0, nullptr, false, BattlePets::REVIVE_BATTLE_PETS_COOLDOWN);
- }
- }
-}
-
void Player::SetResurrectRequestData(WorldObject const* caster, uint32 health, uint32 mana, uint32 appliedAura)
{
ASSERT(!IsResurrectRequested());
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index cbbacf92c49..221d9c08218 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -1842,7 +1842,6 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
uint32 GetLastPotionId() const { return m_lastPotionId; }
void SetLastPotionId(uint32 item_id) { m_lastPotionId = item_id; }
void UpdatePotionCooldown(Spell* spell = nullptr);
- void UpdateReviveBattlePetCooldown();
void SetResurrectRequestData(WorldObject const* caster, uint32 health, uint32 mana, uint32 appliedAura);
void ClearResurrectRequestData()
diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp
index 993d47cabc9..d02d01f512b 100644
--- a/src/server/game/Handlers/CharacterHandler.cpp
+++ b/src/server/game/Handlers/CharacterHandler.cpp
@@ -1203,8 +1203,6 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder const& holder)
pCurrChar->SendInitialPacketsAfterAddToMap();
- pCurrChar->UpdateReviveBattlePetCooldown();
-
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_ONLINE);
stmt->setUInt64(0, pCurrChar->GetGUID().GetCounter());
CharacterDatabase.Execute(stmt);
diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp
index 70b90d9c831..e2eae68c984 100644
--- a/src/server/scripts/Spells/spell_generic.cpp
+++ b/src/server/scripts/Spells/spell_generic.cpp
@@ -24,6 +24,7 @@
#include "ScriptMgr.h"
#include "Battleground.h"
+#include "BattlePetMgr.h"
#include "CellImpl.h"
#include "CreatureAI.h"
#include "DB2Stores.h"
@@ -5021,6 +5022,48 @@ class spell_summon_battle_pet : public SpellScript
}
};
+// 132334 - Trainer Heal Cooldown (SERVERSIDE)
+class spell_gen_trainer_heal_cooldown : public AuraScript
+{
+ PrepareAuraScript(spell_gen_trainer_heal_cooldown);
+
+ bool Validate(SpellInfo const* /*spellInfo*/) override
+ {
+ return ValidateSpellInfo({ BattlePets::SPELL_REVIVE_BATTLE_PETS });
+ }
+
+ bool Load() override
+ {
+ return GetUnitOwner()->IsPlayer();
+ }
+
+ void UpdateReviveBattlePetCooldown(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
+ {
+ Player* target = GetUnitOwner()->ToPlayer();
+ SpellInfo const* reviveBattlePetSpellInfo = sSpellMgr->AssertSpellInfo(BattlePets::SPELL_REVIVE_BATTLE_PETS, DIFFICULTY_NONE);
+
+ if (target->GetSession()->GetBattlePetMgr()->IsBattlePetSystemEnabled())
+ {
+ Milliseconds expectedCooldown = Milliseconds(GetAura()->GetMaxDuration());
+ SpellHistory::Duration remainingCooldown = target->GetSpellHistory()->GetRemainingCategoryCooldown(reviveBattlePetSpellInfo);
+ if (remainingCooldown > SpellHistory::Duration::zero())
+ {
+ if (remainingCooldown < expectedCooldown)
+ target->GetSpellHistory()->ModifyCooldown(reviveBattlePetSpellInfo, expectedCooldown - remainingCooldown);
+ }
+ else
+ {
+ target->GetSpellHistory()->StartCooldown(reviveBattlePetSpellInfo, 0, nullptr, false, expectedCooldown);
+ }
+ }
+ }
+
+ void Register() override
+ {
+ OnEffectApply += AuraEffectApplyFn(spell_gen_trainer_heal_cooldown::UpdateReviveBattlePetCooldown, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
+ }
+};
+
// 45313 - Anchor Here
class spell_gen_anchor_here : public SpellScript
{
@@ -5336,6 +5379,7 @@ void AddSC_generic_spell_scripts()
RegisterSpellScript(spell_defender_of_azeroth_death_gate_selector);
RegisterSpellScript(spell_defender_of_azeroth_speak_with_mograine);
RegisterSpellScript(spell_summon_battle_pet);
+ RegisterSpellScript(spell_gen_trainer_heal_cooldown);
RegisterSpellScript(spell_gen_anchor_here);
RegisterSpellScript(spell_gen_mount_check_aura);
RegisterSpellScript(spell_gen_ancestral_call);