aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Player/Player.cpp7
-rw-r--r--src/server/game/Spells/Spell.cpp2
-rw-r--r--src/server/game/Spells/SpellEffects.cpp46
-rw-r--r--src/server/game/Spells/SpellHistory.cpp5
-rw-r--r--src/server/scripts/Spells/spell_item.cpp138
5 files changed, 149 insertions, 49 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 9e1d00b72ce..9866d1e4af9 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -21701,7 +21701,12 @@ void Player::UpdatePotionCooldown(Spell* spell)
}
// from spell cases (m_lastPotionId set in Spell::SendSpellCooldown)
else
- GetSpellHistory()->SendCooldownEvent(spell->m_spellInfo, m_lastPotionId, spell);
+ {
+ if (spell->IsIgnoringCooldowns())
+ return;
+ else
+ GetSpellHistory()->SendCooldownEvent(spell->m_spellInfo, m_lastPotionId, spell);
+ }
m_lastPotionId = 0;
}
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 9c0d6e9fa8e..32fd73e1073 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -4831,7 +4831,7 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
return SPELL_FAILED_SPELL_IN_PROGRESS;
// check if we are using a potion in combat for the 2nd+ time. Cooldown is added only after caster gets out of combat
- if (m_caster->ToPlayer()->GetLastPotionId() && m_CastItem && (m_CastItem->IsPotion() || m_spellInfo->IsCooldownStartedOnEvent()))
+ if (!IsIgnoringCooldowns() && m_caster->ToPlayer()->GetLastPotionId() && m_CastItem && (m_CastItem->IsPotion() || m_spellInfo->IsCooldownStartedOnEvent()))
return SPELL_FAILED_NOT_READY;
}
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 73100254c4e..e557501c095 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -1814,52 +1814,6 @@ void Spell::EffectEnergize(SpellEffIndex effIndex)
return;
m_caster->EnergizeBySpell(unitTarget, m_spellInfo->Id, damage, power);
-
- // Mad Alchemist's Potion
- if (m_spellInfo->Id == 45051)
- {
- // find elixirs on target
- bool guardianFound = false;
- bool battleFound = false;
- Unit::AuraApplicationMap& Auras = unitTarget->GetAppliedAuras();
- for (Unit::AuraApplicationMap::iterator itr = Auras.begin(); itr != Auras.end(); ++itr)
- {
- uint32 spell_id = itr->second->GetBase()->GetId();
- if (!guardianFound)
- if (sSpellMgr->IsSpellMemberOfSpellGroup(spell_id, SPELL_GROUP_ELIXIR_GUARDIAN))
- guardianFound = true;
- if (!battleFound)
- if (sSpellMgr->IsSpellMemberOfSpellGroup(spell_id, SPELL_GROUP_ELIXIR_BATTLE))
- battleFound = true;
- if (battleFound && guardianFound)
- break;
- }
-
- // get all available elixirs by mask and spell level
- std::set<uint32> avalibleElixirs;
- if (!guardianFound)
- sSpellMgr->GetSetOfSpellsInSpellGroup(SPELL_GROUP_ELIXIR_GUARDIAN, avalibleElixirs);
- if (!battleFound)
- sSpellMgr->GetSetOfSpellsInSpellGroup(SPELL_GROUP_ELIXIR_BATTLE, avalibleElixirs);
- for (std::set<uint32>::iterator itr = avalibleElixirs.begin(); itr != avalibleElixirs.end();)
- {
- SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(*itr);
- if (spellInfo->SpellLevel < m_spellInfo->SpellLevel || spellInfo->SpellLevel > unitTarget->getLevel())
- avalibleElixirs.erase(itr++);
- else if (sSpellMgr->IsSpellMemberOfSpellGroup(*itr, SPELL_GROUP_ELIXIR_SHATTRATH))
- avalibleElixirs.erase(itr++);
- else if (sSpellMgr->IsSpellMemberOfSpellGroup(*itr, SPELL_GROUP_ELIXIR_UNSTABLE))
- avalibleElixirs.erase(itr++);
- else
- ++itr;
- }
-
- if (!avalibleElixirs.empty())
- {
- // cast random elixir on target
- m_caster->CastSpell(unitTarget, Trinity::Containers::SelectRandomContainerElement(avalibleElixirs), true, m_CastItem);
- }
- }
}
void Spell::EffectEnergizePct(SpellEffIndex effIndex)
diff --git a/src/server/game/Spells/SpellHistory.cpp b/src/server/game/Spells/SpellHistory.cpp
index 00edb2672b2..de7414a66d7 100644
--- a/src/server/game/Spells/SpellHistory.cpp
+++ b/src/server/game/Spells/SpellHistory.cpp
@@ -162,6 +162,9 @@ void SpellHistory::HandleCooldowns(SpellInfo const* spellInfo, Item const* item,
void SpellHistory::HandleCooldowns(SpellInfo const* spellInfo, uint32 itemID, Spell* spell /*= nullptr*/)
{
+ if (spell && spell->IsIgnoringCooldowns())
+ return;
+
if (Player* player = _owner->ToPlayer())
{
// potions start cooldown until exiting combat
@@ -175,7 +178,7 @@ void SpellHistory::HandleCooldowns(SpellInfo const* spellInfo, uint32 itemID, Sp
}
}
- if (spellInfo->IsCooldownStartedOnEvent() || spellInfo->IsPassive() || (spell && spell->IsIgnoringCooldowns()))
+ if (spellInfo->IsCooldownStartedOnEvent() || spellInfo->IsPassive())
return;
StartCooldown(spellInfo, itemID, spell);
diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp
index 2ff1e916f96..53ad94a9fc5 100644
--- a/src/server/scripts/Spells/spell_item.cpp
+++ b/src/server/scripts/Spells/spell_item.cpp
@@ -4562,6 +4562,141 @@ class spell_item_zandalarian_charm : public SpellScriptLoader
uint32 _spellId;
};
+// 45051 - Mad Alchemist's Potion (34440)
+class spell_item_mad_alchemists_potion : public SpellScriptLoader
+{
+public:
+ spell_item_mad_alchemists_potion() : SpellScriptLoader("spell_item_mad_alchemists_potion") {}
+
+ class mad_alchemists_potion_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(mad_alchemists_potion_SpellScript);
+
+ void SecondaryEffect()
+ {
+ std::vector<uint32> availableElixirs =
+ {
+ // Battle Elixirs
+ 33720, // Onslaught Elixir (28102)
+ 54452, // Adept's Elixir (28103)
+ 33726, // Elixir of Mastery (28104)
+ 28490, // Elixir of Major Strength (22824)
+ 28491, // Elixir of Healing Power (22825)
+ 28493, // Elixir of Major Frost Power (22827)
+ 54494, // Elixir of Major Agility (22831)
+ 28501, // Elixir of Major Firepower (22833)
+ 28503,// Elixir of Major Shadow Power (22835)
+ 38954, // Fel Strength Elixir (31679)
+ // Guardian Elixirs
+ 39625, // Elixir of Major Fortitude (32062)
+ 39626, // Earthen Elixir (32063)
+ 39627, // Elixir of Draenic Wisdom (32067)
+ 39628, // Elixir of Ironskin (32068)
+ 28502, // Elixir of Major Defense (22834)
+ 28514, // Elixir of Empowerment (22848)
+ // Other
+ 28489, // Elixir of Camouflage (22823)
+ 28496 // Elixir of the Searching Eye (22830)
+ };
+
+ Unit* target = GetCaster();
+
+ if (target->getPowerType() == POWER_MANA)
+ availableElixirs.push_back(28509); // Elixir of Major Mageblood (22840)
+
+ uint32 chosenElixir = Trinity::Containers::SelectRandomContainerElement(availableElixirs);
+
+ bool useElixir = true;
+
+ SpellGroup chosenSpellGroup = SPELL_GROUP_NONE;
+ if (sSpellMgr->IsSpellMemberOfSpellGroup(chosenElixir, SPELL_GROUP_ELIXIR_BATTLE))
+ chosenSpellGroup = SPELL_GROUP_ELIXIR_BATTLE;
+ if (sSpellMgr->IsSpellMemberOfSpellGroup(chosenElixir, SPELL_GROUP_ELIXIR_GUARDIAN))
+ chosenSpellGroup = SPELL_GROUP_ELIXIR_GUARDIAN;
+ // If another spell of the same group is already active the elixir should not be cast
+ if (chosenSpellGroup)
+ {
+ Unit::AuraApplicationMap& Auras = target->GetAppliedAuras();
+ for (Unit::AuraApplicationMap::iterator itr = Auras.begin(); itr != Auras.end(); ++itr)
+ {
+ uint32 spell_id = itr->second->GetBase()->GetId();
+ if (sSpellMgr->IsSpellMemberOfSpellGroup(spell_id, chosenSpellGroup) && spell_id != chosenElixir)
+ {
+ useElixir = false;
+ break;
+ }
+ }
+ }
+
+ if (useElixir)
+ target->CastSpell(target, chosenElixir, true, GetCastItem());
+ }
+
+ void Register() override
+ {
+ AfterCast += SpellCastFn(mad_alchemists_potion_SpellScript::SecondaryEffect);
+ }
+
+ };
+
+ SpellScript* GetSpellScript() const override
+ {
+ return new mad_alchemists_potion_SpellScript();
+ }
+};
+
+// 53750 - Crazy Alchemist's Potion (40077)
+class spell_item_crazy_alchemists_potion : public SpellScriptLoader
+{
+public:
+ spell_item_crazy_alchemists_potion() : SpellScriptLoader("spell_item_crazy_alchemists_potion") {}
+
+ class crazy_alchemists_potion_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(crazy_alchemists_potion_SpellScript);
+
+ void SecondaryEffect()
+ {
+ std::vector<uint32> availableElixirs =
+ {
+ 43185, // Runic Healing Potion (33447)
+ 53750, // Crazy Alchemist's Potion (40077)
+ 53761, // Powerful Rejuvenation Potion (40087)
+ 53762, // Indestructible Potion (40093)
+ 53908, // Potion of Speed (40211)
+ 53909, // Potion of Wild Magic (40212)
+ 53910, // Mighty Arcane Protection Potion (40213)
+ 53911, // Mighty Fire Protection Potion (40214)
+ 53913, // Mighty Frost Protection Potion (40215)
+ 53914, // Mighty Nature Protection Potion (40216)
+ 53915 // Mighty Shadow Protection Potion (40217)
+ };
+
+ Unit* target = GetCaster();
+
+ if (!target->IsInCombat())
+ availableElixirs.push_back(53753); // Potion of Nightmares (40081)
+ if (target->getPowerType() == POWER_MANA)
+ availableElixirs.push_back(43186); // Runic Mana Potion(33448)
+
+ uint32 chosenElixir = Trinity::Containers::SelectRandomContainerElement(availableElixirs);
+
+ target->CastSpell(target, chosenElixir, true, GetCastItem());
+ }
+
+ void Register() override
+ {
+ AfterCast += SpellCastFn(crazy_alchemists_potion_SpellScript::SecondaryEffect);
+ }
+
+ };
+
+ SpellScript* GetSpellScript() const override
+ {
+ return new crazy_alchemists_potion_SpellScript();
+ }
+};
+
void AddSC_item_spell_scripts()
{
// 23074 Arcanite Dragonling
@@ -4677,4 +4812,7 @@ void AddSC_item_spell_scripts()
new spell_item_zandalarian_charm("spell_item_unstable_power", SPELL_UNSTABLE_POWER_AURA_STACK);
new spell_item_zandalarian_charm("spell_item_restless_strength", SPELL_RESTLESS_STRENGTH_AURA_STACK);
+
+ new spell_item_mad_alchemists_potion();
+ new spell_item_crazy_alchemists_potion();
}