aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/scripts/Spells/spell_rogue.cpp98
1 files changed, 98 insertions, 0 deletions
diff --git a/src/server/scripts/Spells/spell_rogue.cpp b/src/server/scripts/Spells/spell_rogue.cpp
index 6cce8f0ea4e..b5be2691ae8 100644
--- a/src/server/scripts/Spells/spell_rogue.cpp
+++ b/src/server/scripts/Spells/spell_rogue.cpp
@@ -22,6 +22,7 @@
*/
#include "ScriptPCH.h"
+#include "SpellAuraEffects.h"
enum RogueSpells
{
@@ -289,6 +290,102 @@ class spell_rog_shiv : public SpellScriptLoader
}
};
+class spell_rog_deadly_poison : public SpellScriptLoader
+{
+ public:
+ spell_rog_deadly_poison() : SpellScriptLoader("spell_rog_deadly_poison") { }
+
+ class spell_rog_deadly_poison_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_rog_deadly_poison_SpellScript)
+
+
+ bool Load()
+ {
+ _stackAmount = 0;
+ // at this point CastItem must already be initialized
+ return GetCaster()->GetTypeId() == TYPEID_PLAYER && GetCastItem();
+ }
+
+ void HandleBeforeHit()
+ {
+ Unit* target = GetHitUnit();
+ if (!target)
+ return;
+
+ // Deadly Poison
+ if (AuraEffect const* aurEff = target->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_ROGUE, 0x10000, 0x80000, 0, GetCaster()->GetGUID()))
+ _stackAmount = aurEff->GetBase()->GetStackAmount();
+ }
+
+ void HandleAfterHit()
+ {
+ if (_stackAmount < 5)
+ return;
+
+ Player* player = GetCaster()->ToPlayer();
+ Unit* target = GetHitUnit();
+ if (!target)
+ return;
+
+ Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND);
+
+ if (item == GetCastItem())
+ item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND);
+
+ if (!item)
+ return;
+
+ // item combat enchantments
+ for (uint8 slot = 0; slot < MAX_ENCHANTMENT_SLOT; ++slot)
+ {
+ SpellItemEnchantmentEntry const* enchant = sSpellItemEnchantmentStore.LookupEntry(item->GetEnchantmentId(EnchantmentSlot(slot)));
+ if (!enchant)
+ continue;
+
+ for (uint8 s = 0; s < 3; ++s)
+ {
+ if (enchant->type[s] != ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL)
+ continue;
+
+ SpellEntry const* spellInfo = sSpellStore.LookupEntry(enchant->spellid[s]);
+ if (!spellInfo)
+ {
+ sLog->outError("Player::CastItemCombatSpell Enchant %i, cast unknown spell %i", enchant->ID, enchant->spellid[s]);
+ continue;
+ }
+
+ // Proc only rogue poisons
+ if (spellInfo->SpellFamilyName != SPELLFAMILY_ROGUE || spellInfo->Dispel != DISPEL_POISON)
+ continue;
+
+ // Do not reproc deadly
+ if (spellInfo->SpellFamilyFlags.IsEqual(0x10000, 0x80000, 0))
+ continue;
+
+ if (IsPositiveSpell(enchant->spellid[s]))
+ player->CastSpell(player, enchant->spellid[s], true, item);
+ else
+ player->CastSpell(target, enchant->spellid[s], true, item);
+ }
+ }
+ }
+
+ void Register()
+ {
+ BeforeHit += SpellHitFn(spell_rog_deadly_poison_SpellScript::HandleBeforeHit);
+ AfterHit += SpellHitFn(spell_rog_deadly_poison_SpellScript::HandleAfterHit);
+ }
+
+ uint8 _stackAmount;
+ };
+
+ SpellScript* GetSpellScript() const
+ {
+ return new spell_rog_deadly_poison_SpellScript();
+ }
+};
+
void AddSC_rogue_spell_scripts()
{
new spell_rog_cheat_death();
@@ -296,4 +393,5 @@ void AddSC_rogue_spell_scripts()
new spell_rog_preparation();
new spell_rog_prey_on_the_weak();
new spell_rog_shiv();
+ new spell_rog_deadly_poison();
}