diff options
| author | Shauren <shauren.trinity@gmail.com> | 2015-02-17 01:01:44 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2015-02-17 01:01:44 +0100 |
| commit | 56186319bdd41dd26b6cc14f84e6e41eef5d953b (patch) | |
| tree | 7b531cdf71b59170f9fa65120c09935ce51f3307 /src/server/scripts/Spells | |
| parent | 7829412416c9709991fd686030ab77908c27922b (diff) | |
Core/Spells: Cooldown updates
* Refactored cooldown handling to separate class shared by creatures and players
* Updated and enabled cooldown packets
* Implemented creature school lockouts
* Implemented spell charges
* Fixed AuraUpdate structure
* Fixed aura flag AFLAG_NOCASTER handling
* Implemented spell charge related auras
Diffstat (limited to 'src/server/scripts/Spells')
| -rw-r--r-- | src/server/scripts/Spells/spell_dk.cpp | 3 | ||||
| -rw-r--r-- | src/server/scripts/Spells/spell_druid.cpp | 5 | ||||
| -rw-r--r-- | src/server/scripts/Spells/spell_generic.cpp | 7 | ||||
| -rw-r--r-- | src/server/scripts/Spells/spell_hunter.cpp | 17 | ||||
| -rw-r--r-- | src/server/scripts/Spells/spell_item.cpp | 5 | ||||
| -rw-r--r-- | src/server/scripts/Spells/spell_mage.cpp | 21 | ||||
| -rw-r--r-- | src/server/scripts/Spells/spell_paladin.cpp | 3 | ||||
| -rw-r--r-- | src/server/scripts/Spells/spell_rogue.cpp | 29 | ||||
| -rw-r--r-- | src/server/scripts/Spells/spell_shaman.cpp | 15 | ||||
| -rw-r--r-- | src/server/scripts/Spells/spell_warrior.cpp | 7 |
10 files changed, 48 insertions, 64 deletions
diff --git a/src/server/scripts/Spells/spell_dk.cpp b/src/server/scripts/Spells/spell_dk.cpp index 9edf3f42b88..98c6781e866 100644 --- a/src/server/scripts/Spells/spell_dk.cpp +++ b/src/server/scripts/Spells/spell_dk.cpp @@ -25,6 +25,7 @@ #include "ScriptMgr.h" #include "SpellScript.h" #include "SpellAuraEffects.h" +#include "SpellHistory.h" #include "Containers.h" enum DeathKnightSpells @@ -148,7 +149,7 @@ class spell_dk_anti_magic_shell : public SpellScriptLoader { // Cannot reduce cooldown by more than 50% int32 val = std::min(glyph->GetAmount(), int32(absorbedAmount) * 100 / maxHealth); - player->ModifySpellCooldown(GetId(), -int32(player->GetSpellCooldownDelay(GetId()) * val / 100)); + player->GetSpellHistory()->ModifyCooldown(GetId(), -int32(player->GetSpellHistory()->GetRemainingCooldown(GetId()) * val / 100)); } } diff --git a/src/server/scripts/Spells/spell_druid.cpp b/src/server/scripts/Spells/spell_druid.cpp index dd002dedee5..2418e75d22c 100644 --- a/src/server/scripts/Spells/spell_druid.cpp +++ b/src/server/scripts/Spells/spell_druid.cpp @@ -25,6 +25,7 @@ #include "ScriptMgr.h" #include "SpellScript.h" #include "SpellAuraEffects.h" +#include "SpellHistory.h" #include "Containers.h" enum DruidSpells @@ -122,8 +123,8 @@ class spell_dru_eclipse : public SpellScriptLoader if (!caster) return; - if (caster->ToPlayer()->GetAuraOfRankedSpell(SPELL_DRUID_NATURES_GRACE)) - caster->ToPlayer()->RemoveSpellCooldown(SPELL_DRUID_NATURES_GRACE_TRIGGER, true); + if (caster->GetAuraOfRankedSpell(SPELL_DRUID_NATURES_GRACE)) + caster->GetSpellHistory()->ResetCooldown(SPELL_DRUID_NATURES_GRACE_TRIGGER, true); } void Register() override diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index a05eab1cd08..31779c4df22 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -36,6 +36,7 @@ #include "SkillDiscovery.h" #include "SpellScript.h" #include "SpellAuraEffects.h" +#include "SpellHistory.h" #include "Vehicle.h" class spell_gen_absorb0_hitlimit1 : public SpellScriptLoader @@ -1313,9 +1314,7 @@ class spell_gen_divine_storm_cd_reset : public SpellScriptLoader void HandleScript(SpellEffIndex /*effIndex*/) { - Player* caster = GetCaster()->ToPlayer(); - if (caster->HasSpellCooldown(SPELL_DIVINE_STORM)) - caster->RemoveSpellCooldown(SPELL_DIVINE_STORM, true); + GetCaster()->GetSpellHistory()->ResetCooldown(SPELL_DIVINE_STORM, true); } void Register() override @@ -3324,7 +3323,7 @@ class spell_pvp_trinket_wotf_shared_cd : public SpellScriptLoader { // This is only needed because spells cast from spell_linked_spell are triggered by default // Spell::SendSpellCooldown() skips all spells with TRIGGERED_IGNORE_SPELL_AND_CATEGORY_CD - GetCaster()->ToPlayer()->AddSpellAndCategoryCooldowns(GetSpellInfo(), GetCastItem() ? GetCastItem()->GetEntry() : 0, GetSpell()); + GetCaster()->GetSpellHistory()->StartCooldown(GetSpellInfo(), 0, GetSpell()); } void Register() override diff --git a/src/server/scripts/Spells/spell_hunter.cpp b/src/server/scripts/Spells/spell_hunter.cpp index 205965910c1..a0c01479cdb 100644 --- a/src/server/scripts/Spells/spell_hunter.cpp +++ b/src/server/scripts/Spells/spell_hunter.cpp @@ -29,6 +29,7 @@ #include "GridNotifiersImpl.h" #include "SpellScript.h" #include "SpellAuraEffects.h" +#include "SpellHistory.h" enum HunterSpells { @@ -641,24 +642,20 @@ class spell_hun_readiness : public SpellScriptLoader void HandleDummy(SpellEffIndex /*effIndex*/) { - Player* caster = GetCaster()->ToPlayer(); // immediately finishes the cooldown on your other Hunter abilities except Bestial Wrath - const SpellCooldowns& cm = caster->ToPlayer()->GetSpellCooldownMap(); - for (SpellCooldowns::const_iterator itr = cm.begin(); itr != cm.end();) + GetCaster()->GetSpellHistory()->ResetCooldowns([](SpellHistory::CooldownStorageType::iterator itr) { - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first); + SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(itr->first); ///! If spellId in cooldown map isn't valid, the above will return a null pointer. - if (spellInfo && - spellInfo->SpellFamilyName == SPELLFAMILY_HUNTER && + if (spellInfo->SpellFamilyName == SPELLFAMILY_HUNTER && spellInfo->Id != SPELL_HUNTER_READINESS && spellInfo->Id != SPELL_HUNTER_BESTIAL_WRATH && spellInfo->Id != SPELL_DRAENEI_GIFT_OF_THE_NAARU && spellInfo->GetRecoveryTime() > 0) - caster->RemoveSpellCooldown((itr++)->first, true); - else - ++itr; - } + return true; + return false; + }, true); } void Register() override diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index eb5c4c147a8..66c90c85e55 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -26,6 +26,7 @@ #include "ScriptedCreature.h" #include "SpellScript.h" #include "SpellAuraEffects.h" +#include "SpellHistory.h" #include "SkillDiscovery.h" #include "Battleground.h" @@ -1355,7 +1356,7 @@ class spell_item_red_rider_air_rifle : public SpellScriptLoader caster->CastSpell(caster, SPELL_AIR_RIFLE_HOLD_VISUAL, true); // needed because this spell shares GCD with its triggered spells (which must not be cast with triggered flag) if (Player* player = caster->ToPlayer()) - player->GetGlobalCooldownMgr().CancelGlobalCooldown(GetSpellInfo()); + player->GetSpellHistory()->CancelGlobalCooldown(GetSpellInfo()); if (urand(0, 4)) caster->CastSpell(target, SPELL_AIR_RIFLE_SHOOT, false); else @@ -2374,7 +2375,7 @@ class spell_item_rocket_boots : public SpellScriptLoader if (Battleground* bg = caster->GetBattleground()) bg->EventPlayerDroppedFlag(caster); - caster->RemoveSpellCooldown(SPELL_ROCKET_BOOTS_PROC); + caster->GetSpellHistory()->ResetCooldown(SPELL_ROCKET_BOOTS_PROC); caster->CastSpell(caster, SPELL_ROCKET_BOOTS_PROC, true, NULL); } diff --git a/src/server/scripts/Spells/spell_mage.cpp b/src/server/scripts/Spells/spell_mage.cpp index ea8630acc59..16e819430d2 100644 --- a/src/server/scripts/Spells/spell_mage.cpp +++ b/src/server/scripts/Spells/spell_mage.cpp @@ -24,6 +24,7 @@ #include "Player.h" #include "ScriptMgr.h" #include "SpellScript.h" +#include "SpellHistory.h" #include "SpellAuraEffects.h" #include "Pet.h" #include "GridNotifiers.h" @@ -326,22 +327,12 @@ class spell_mage_cold_snap : public SpellScriptLoader void HandleDummy(SpellEffIndex /*effIndex*/) { - Player* caster = GetCaster()->ToPlayer(); - // immediately finishes the cooldown on Frost spells - const SpellCooldowns& cm = caster->GetSpellCooldownMap(); - for (SpellCooldowns::const_iterator itr = cm.begin(); itr != cm.end();) + GetCaster()->GetSpellHistory()->ResetCooldowns([](SpellHistory::CooldownStorageType::iterator itr) { SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(itr->first); - - if (spellInfo->SpellFamilyName == SPELLFAMILY_MAGE && - (spellInfo->GetSchoolMask() & SPELL_SCHOOL_MASK_FROST) && - spellInfo->Id != SPELL_MAGE_COLD_SNAP && spellInfo->GetRecoveryTime() > 0) - { - caster->RemoveSpellCooldown((itr++)->first, true); - } - else - ++itr; - } + return spellInfo->SpellFamilyName == SPELLFAMILY_MAGE && (spellInfo->GetSchoolMask() & SPELL_SCHOOL_MASK_FROST) && + spellInfo->Id != SPELL_MAGE_COLD_SNAP && spellInfo->GetRecoveryTime() > 0; + }, true); } void Register() override @@ -703,7 +694,7 @@ class spell_mage_glyph_of_ice_block : public SpellScriptLoader { PreventDefaultAction(); // Remove Frost Nova cooldown - GetTarget()->ToPlayer()->RemoveSpellCooldown(SPELL_MAGE_FROST_NOVA, true); + GetTarget()->GetSpellHistory()->ResetCooldown(SPELL_MAGE_FROST_NOVA, true); } void Register() override diff --git a/src/server/scripts/Spells/spell_paladin.cpp b/src/server/scripts/Spells/spell_paladin.cpp index 305f1cce9e3..2af1b8c14f2 100644 --- a/src/server/scripts/Spells/spell_paladin.cpp +++ b/src/server/scripts/Spells/spell_paladin.cpp @@ -25,6 +25,7 @@ #include "ScriptMgr.h" #include "SpellScript.h" #include "SpellAuraEffects.h" +#include "SpellHistory.h" #include "Group.h" enum PaladinSpells @@ -600,7 +601,7 @@ class spell_pal_grand_crusader : public SpellScriptLoader void HandleEffectProc(AuraEffect const* /*aurEff*/, ProcEventInfo& /*eventInfo*/) { - GetTarget()->ToPlayer()->RemoveSpellCooldown(SPELL_PALADIN_AVENGERS_SHIELD, true); + GetTarget()->GetSpellHistory()->ResetCooldown(SPELL_PALADIN_AVENGERS_SHIELD, true); } void Register() override diff --git a/src/server/scripts/Spells/spell_rogue.cpp b/src/server/scripts/Spells/spell_rogue.cpp index 902e89f6c56..b70ae177928 100644 --- a/src/server/scripts/Spells/spell_rogue.cpp +++ b/src/server/scripts/Spells/spell_rogue.cpp @@ -25,6 +25,7 @@ #include "ScriptMgr.h" #include "SpellScript.h" #include "SpellAuraEffects.h" +#include "SpellHistory.h" #include "Containers.h" enum RogueSpells @@ -159,11 +160,11 @@ class spell_rog_cheat_death : public SpellScriptLoader void Absorb(AuraEffect* /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount) { Player* target = GetTarget()->ToPlayer(); - if (dmgInfo.GetDamage() < target->GetHealth() || target->HasSpellCooldown(SPELL_ROGUE_CHEAT_DEATH_COOLDOWN) || !roll_chance_i(absorbChance)) + if (dmgInfo.GetDamage() < target->GetHealth() || target->GetSpellHistory()->HasCooldown(SPELL_ROGUE_CHEAT_DEATH_COOLDOWN) || !roll_chance_i(absorbChance)) return; target->CastSpell(target, SPELL_ROGUE_CHEAT_DEATH_COOLDOWN, true); - target->AddSpellCooldown(SPELL_ROGUE_CHEAT_DEATH_COOLDOWN, 0, time(NULL) + 60); + target->GetSpellHistory()->AddCooldown(SPELL_ROGUE_CHEAT_DEATH_COOLDOWN, 0, std::chrono::minutes(1)); uint32 health10 = target->CountPctFromMaxHealth(10); @@ -550,31 +551,21 @@ class spell_rog_preparation : public SpellScriptLoader void HandleDummy(SpellEffIndex /*effIndex*/) { - Player* caster = GetCaster()->ToPlayer(); - - // immediately finishes the cooldown on certain Rogue abilities - SpellCooldowns const& cm = caster->GetSpellCooldownMap(); - for (SpellCooldowns::const_iterator itr = cm.begin(); itr != cm.end();) + Unit* caster = GetCaster(); + caster->GetSpellHistory()->ResetCooldowns([caster](SpellHistory::CooldownStorageType::iterator itr) { SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(itr->first); if (spellInfo->SpellFamilyName != SPELLFAMILY_ROGUE) - { - ++itr; - continue; - } + return false; - if ((spellInfo->SpellFamilyFlags[1] & SPELLFAMILYFLAG1_ROGUE_SHADOWSTEP || // Shadowstep + return (spellInfo->SpellFamilyFlags[1] & SPELLFAMILYFLAG1_ROGUE_SHADOWSTEP || // Shadowstep spellInfo->SpellFamilyFlags[0] & SPELLFAMILYFLAG0_ROGUE_VAN_SPRINT) || // Vanish, Sprint // Glyph of Preparation (caster->HasAura(SPELL_ROGUE_GLYPH_OF_PREPARATION) && (spellInfo->SpellFamilyFlags[1] & SPELLFAMILYFLAG1_ROGUE_DISMANTLE_SMOKE_BOMB || // Dismantle, Smoke Bomb - spellInfo->SpellFamilyFlags[0] & SPELLFAMILYFLAG0_ROGUE_KICK))) // Kick - { - caster->RemoveSpellCooldown((itr++)->first, true); - } - else - ++itr; - } + spellInfo->SpellFamilyFlags[0] & SPELLFAMILYFLAG0_ROGUE_KICK)); // Kick + + }, true); } void Register() override diff --git a/src/server/scripts/Spells/spell_shaman.cpp b/src/server/scripts/Spells/spell_shaman.cpp index b5c9c23fa5c..589f67fc39b 100644 --- a/src/server/scripts/Spells/spell_shaman.cpp +++ b/src/server/scripts/Spells/spell_shaman.cpp @@ -26,6 +26,7 @@ #include "GridNotifiers.h" #include "Unit.h" #include "SpellScript.h" +#include "SpellHistory.h" #include "SpellAuraEffects.h" enum ShamanSpells @@ -310,7 +311,7 @@ class spell_sha_earth_shield : public SpellScriptLoader { //! HACK due to currenct proc system implementation if (Player* player = GetTarget()->ToPlayer()) - if (player->HasSpellCooldown(SPELL_SHAMAN_EARTH_SHIELD_HEAL)) + if (player->GetSpellHistory()->HasCooldown(SPELL_SHAMAN_EARTH_SHIELD_HEAL)) return false; return true; } @@ -323,7 +324,7 @@ class spell_sha_earth_shield : public SpellScriptLoader /// @hack: due to currenct proc system implementation if (Player* player = GetTarget()->ToPlayer()) - player->AddSpellCooldown(SPELL_SHAMAN_EARTH_SHIELD_HEAL, 0, time(NULL) + 3); + player->GetSpellHistory()->AddCooldown(SPELL_SHAMAN_EARTH_SHIELD_HEAL, 0, std::chrono::seconds(3)); } void Register() override @@ -462,7 +463,7 @@ class spell_sha_feedback : public SpellScriptLoader { PreventDefaultAction(); // will prevent default effect execution if (Player* target = GetTarget()->ToPlayer()) - target->ModifySpellCooldown(SPELL_SHAMAN_ELEMENTAL_MASTERY, aurEff->GetBaseAmount()); + target->GetSpellHistory()->ModifyCooldown(SPELL_SHAMAN_ELEMENTAL_MASTERY, aurEff->GetBaseAmount()); } void Register() override @@ -832,7 +833,7 @@ class spell_sha_item_t10_elemental_2p_bonus : public SpellScriptLoader { PreventDefaultAction(); if (Player* target = GetTarget()->ToPlayer()) - target->ModifySpellCooldown(SPELL_SHAMAN_ELEMENTAL_MASTERY, -aurEff->GetAmount()); + target->GetSpellHistory()->ModifyCooldown(SPELL_SHAMAN_ELEMENTAL_MASTERY, -aurEff->GetAmount()); } void Register() override @@ -949,7 +950,7 @@ class spell_sha_lava_surge_proc : public SpellScriptLoader void HandleDummy(SpellEffIndex /*effIndex*/) { - GetCaster()->ToPlayer()->RemoveSpellCooldown(SPELL_SHAMAN_LAVA_BURST, true); + GetCaster()->GetSpellHistory()->ResetCooldown(SPELL_SHAMAN_LAVA_BURST, true); } void Register() override @@ -1017,7 +1018,7 @@ class spell_sha_nature_guardian : public SpellScriptLoader { //! HACK due to currenct proc system implementation if (Player* player = GetTarget()->ToPlayer()) - if (player->HasSpellCooldown(GetSpellInfo()->Id)) + if (player->GetSpellHistory()->HasCooldown(GetSpellInfo()->Id)) return false; return GetTarget()->HealthBelowPctDamaged(30, eventInfo.GetDamageInfo()->GetDamage()); @@ -1034,7 +1035,7 @@ class spell_sha_nature_guardian : public SpellScriptLoader eventInfo.GetProcTarget()->getThreatManager().modifyThreatPercent(GetTarget(), -10); if (Player* player = GetTarget()->ToPlayer()) - player->AddSpellCooldown(GetSpellInfo()->Id, 0, time(NULL) + aurEff->GetSpellInfo()->GetEffect(EFFECT_1)->CalcValue()); + player->GetSpellHistory()->AddCooldown(GetSpellInfo()->Id, 0, std::chrono::seconds(aurEff->GetSpellInfo()->GetEffect(EFFECT_1)->CalcValue())); } void Register() override diff --git a/src/server/scripts/Spells/spell_warrior.cpp b/src/server/scripts/Spells/spell_warrior.cpp index b3caff679df..80e738c7442 100644 --- a/src/server/scripts/Spells/spell_warrior.cpp +++ b/src/server/scripts/Spells/spell_warrior.cpp @@ -23,6 +23,7 @@ #include "Player.h" #include "ScriptMgr.h" +#include "SpellHistory.h" #include "SpellScript.h" #include "SpellAuraEffects.h" @@ -697,7 +698,7 @@ class spell_warr_sudden_death : public SpellScriptLoader { // Remove cooldown on Colossus Smash if (Player* player = GetTarget()->ToPlayer()) - player->RemoveSpellCooldown(SPELL_WARRIOR_COLOSSUS_SMASH, true); + player->GetSpellHistory()->ResetCooldown(SPELL_WARRIOR_COLOSSUS_SMASH, true); } void Register() override @@ -799,7 +800,7 @@ class spell_warr_sword_and_board : public SpellScriptLoader { // Remove cooldown on Shield Slam if (Player* player = GetTarget()->ToPlayer()) - player->RemoveSpellCooldown(SPELL_WARRIOR_SHIELD_SLAM, true); + player->GetSpellHistory()->ResetCooldown(SPELL_WARRIOR_SHIELD_SLAM, true); } void Register() override @@ -932,7 +933,7 @@ class spell_warr_vigilance_trigger : public SpellScriptLoader // Remove Taunt cooldown if (Player* target = GetHitPlayer()) - target->RemoveSpellCooldown(SPELL_WARRIOR_TAUNT, true); + target->GetSpellHistory()->ResetCooldown(SPELL_WARRIOR_TAUNT, true); } void Register() override |
