From cb22fe570d602953e5902278a88c959c490e3868 Mon Sep 17 00:00:00 2001 From: Vincent-Michael Date: Sun, 16 Jun 2013 22:55:14 +0200 Subject: Core/Spells: Add function for modify cooldown Thx shauren for helping --- src/server/game/Entities/Player/Player.cpp | 21 +++++++++++++++++++++ src/server/game/Entities/Player/Player.h | 1 + 2 files changed, 22 insertions(+) (limited to 'src/server/game/Entities') diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 9fac78bc5a0..5c96e607355 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -22061,6 +22061,27 @@ void Player::AddSpellCooldown(uint32 spellid, uint32 itemid, time_t end_time) m_spellCooldowns[spellid] = sc; } +void Player::ModifySpellCooldown(uint32 spellId, int32 cooldown) +{ + SpellCooldowns::iterator itr = m_spellCooldowns.find(spellId); + if (itr == m_spellCooldowns.end()) + return; + + time_t now = time(NULL); + if (itr->second.end + (cooldown / IN_MILLISECONDS) > now) + itr->second.end += (cooldown / IN_MILLISECONDS); + else + m_spellCooldowns.erase(itr); + + WorldPacket data(SMSG_MODIFY_COOLDOWN, 4 + 8 + 4); + data << uint32(spellId); // Spell ID + data << uint64(GetGUID()); // Player GUID + data << int32(cooldown); // Cooldown mod in milliseconds + GetSession()->SendPacket(&data); + + TC_LOG_DEBUG("misc", "ModifySpellCooldown:: Player: %s (GUID: %u) Spell: %u cooldown: %u", GetName().c_str(), GetGUIDLow(), spellId, GetSpellCooldownDelay(spellId)); +} + void Player::SendCooldownEvent(SpellInfo const* spellInfo, uint32 itemId /*= 0*/, Spell* spell /*= NULL*/, bool setCooldown /*= true*/) { // start cooldowns at server side, if any diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 5f500b7f1d8..a146b5d672a 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1647,6 +1647,7 @@ class Player : public Unit, public GridObject uint32 GetSpellCooldownDelay(uint32 spell_id) const; void AddSpellAndCategoryCooldowns(SpellInfo const* spellInfo, uint32 itemId, Spell* spell = NULL, bool infinityCooldown = false); void AddSpellCooldown(uint32 spell_id, uint32 itemid, time_t end_time); + void ModifySpellCooldown(uint32 spellId, int32 cooldown); void SendCooldownEvent(SpellInfo const* spellInfo, uint32 itemId = 0, Spell* spell = NULL, bool setCooldown = true); void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs); void RemoveSpellCooldown(uint32 spell_id, bool update = false); -- cgit v1.2.3 From 60bcd6c98cb403e357631c0a666ee8eea753c3e5 Mon Sep 17 00:00:00 2001 From: Vincent-Michael Date: Mon, 7 Jul 2014 21:33:58 +0200 Subject: Core/GameObject: GAMEOBJECT_TYPE_SPELL_FOCUS serverOnly == 1 are now invisible (only server) --- src/server/game/Entities/GameObject/GameObject.cpp | 11 +++++++++++ src/server/game/Entities/GameObject/GameObject.h | 2 ++ 2 files changed, 13 insertions(+) (limited to 'src/server/game/Entities') diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index ae08a4251a5..23e40382fa2 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -958,6 +958,17 @@ void GameObject::SaveRespawnTime() GetMap()->SaveGORespawnTime(m_DBTableGuid, m_respawnTime); } +bool GameObject::IsNeverVisible() const +{ + if (WorldObject::IsNeverVisible()) + return true; + + if (GetGoType() == GAMEOBJECT_TYPE_SPELL_FOCUS && GetGOInfo()->spellFocus.serverOnly == 1) + return true; + + return false; +} + bool GameObject::IsAlwaysVisibleFor(WorldObject const* seer) const { if (WorldObject::IsAlwaysVisibleFor(seer)) diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index 8f70fc0e907..549de28bb12 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -778,6 +778,8 @@ class GameObject : public WorldObject, public GridObject, public Map void TriggeringLinkedGameObject(uint32 trapEntry, Unit* target); + bool IsNeverVisible() const override; + bool IsAlwaysVisibleFor(WorldObject const* seer) const; bool IsInvisibleDueToDespawn() const; -- cgit v1.2.3 From ba2563da5a7451274de40357b1476d847fe8e69f Mon Sep 17 00:00:00 2001 From: Vincent-Michael Date: Mon, 7 Jul 2014 21:50:18 +0200 Subject: Core/Spells: Convert "Shaman T10 Elemental 2P Bonus" in spell script --- .../world/2014_07_07_03_world_spell_misc.sql | 7 ++++ src/server/game/Entities/Unit/Unit.cpp | 25 -------------- src/server/scripts/Spells/spell_shaman.cpp | 38 ++++++++++++++++++++++ 3 files changed, 45 insertions(+), 25 deletions(-) create mode 100644 sql/updates/world/2014_07_07_03_world_spell_misc.sql (limited to 'src/server/game/Entities') diff --git a/sql/updates/world/2014_07_07_03_world_spell_misc.sql b/sql/updates/world/2014_07_07_03_world_spell_misc.sql new file mode 100644 index 00000000000..8e200267797 --- /dev/null +++ b/sql/updates/world/2014_07_07_03_world_spell_misc.sql @@ -0,0 +1,7 @@ +DELETE FROM `spell_script_names` WHERE `spell_id`=70811; +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES +(70811,'spell_sha_item_t10_elemental_2p_bonus'); + +DELETE FROM `spell_proc_event` WHERE `entry`=70811; +INSERT INTO `spell_proc_event` (`entry`, `SchoolMask`, `SpellFamilyName`, `SpellFamilyMask0`, `SpellFamilyMask1`, `SpellFamilyMask2`, `procFlags`, `procEx`, `ppmRate`, `CustomChance`, `Cooldown`) VALUES +(70811, 0, 11, 3, 0, 0, 0, 0, 0, 0, 0); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 72c1a071487..902d99d888b 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -6889,31 +6889,6 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere } break; } - // Item - Shaman T10 Elemental 2P Bonus - case 70811: - { - // Lightning Bolt & Chain Lightning - if (procSpell->SpellFamilyFlags[0] & 0x3) - { - if (ToPlayer()->HasSpellCooldown(16166)) - { - uint32 newCooldownDelay = ToPlayer()->GetSpellCooldownDelay(16166); - if (newCooldownDelay < 3) - newCooldownDelay = 0; - else - newCooldownDelay -= 2; - ToPlayer()->AddSpellCooldown(16166, 0, uint32(time(NULL) + newCooldownDelay)); - - WorldPacket data(SMSG_MODIFY_COOLDOWN, 4+8+4); - data << uint32(16166); // Spell ID - data << uint64(GetGUID()); // Player GUID - data << int32(-2000); // Cooldown mod in milliseconds - ToPlayer()->GetSession()->SendPacket(&data); - return true; - } - } - return false; - } // Item - Shaman T10 Elemental 4P Bonus case 70817: { diff --git a/src/server/scripts/Spells/spell_shaman.cpp b/src/server/scripts/Spells/spell_shaman.cpp index 61ff79c505e..a1c2d0e1d1c 100644 --- a/src/server/scripts/Spells/spell_shaman.cpp +++ b/src/server/scripts/Spells/spell_shaman.cpp @@ -34,6 +34,7 @@ enum ShamanSpells SPELL_SHAMAN_BIND_SIGHT = 6277, SPELL_SHAMAN_CLEANSING_TOTEM_EFFECT = 52025, SPELL_SHAMAN_EARTH_SHIELD_HEAL = 379, + SPELL_SHAMAN_ELEMENTAL_MASTERY = 16166, SPELL_SHAMAN_EXHAUSTION = 57723, SPELL_SHAMAN_FIRE_NOVA_R1 = 1535, SPELL_SHAMAN_FIRE_NOVA_TRIGGERED_R1 = 8349, @@ -767,6 +768,42 @@ class spell_sha_item_mana_surge : public SpellScriptLoader } }; +// 70811 - Item - Shaman T10 Elemental 2P Bonus +class spell_sha_item_t10_elemental_2p_bonus : public SpellScriptLoader +{ + public: + spell_sha_item_t10_elemental_2p_bonus() : SpellScriptLoader("spell_sha_item_t10_elemental_2p_bonus") { } + + class spell_sha_item_t10_elemental_2p_bonus_AuraScript : public AuraScript + { + PrepareAuraScript(spell_sha_item_t10_elemental_2p_bonus_AuraScript); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + if (!sSpellMgr->GetSpellInfo(SPELL_SHAMAN_ELEMENTAL_MASTERY)) + return false; + return true; + } + + void HandleEffectProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/) + { + PreventDefaultAction(); + if (Player* target = GetTarget()->ToPlayer()) + target->ModifySpellCooldown(SPELL_SHAMAN_ELEMENTAL_MASTERY, -aurEff->GetAmount()); + } + + void Register() override + { + OnEffectProc += AuraEffectProcFn(spell_sha_item_t10_elemental_2p_bonus_AuraScript::HandleEffectProc, EFFECT_0, SPELL_AURA_DUMMY); + } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_sha_item_t10_elemental_2p_bonus_AuraScript(); + } +}; + // 60103 - Lava Lash class spell_sha_lava_lash : public SpellScriptLoader { @@ -989,6 +1026,7 @@ void AddSC_shaman_spell_scripts() new spell_sha_item_lightning_shield(); new spell_sha_item_lightning_shield_trigger(); new spell_sha_item_mana_surge(); + new spell_sha_item_t10_elemental_2p_bonus(); new spell_sha_lava_lash(); new spell_sha_mana_spring_totem(); new spell_sha_mana_tide_totem(); -- cgit v1.2.3