Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class spell_custom_shadow_damage_transfer : public SpellScriptLoader {
- public:
- spell_custom_shadow_damage_transfer() : SpellScriptLoader("spell_custom_shadow_damage_transfer") {}
- class spell_custom_shadow_damage_transfer_SpellScript : public SpellScript {
- PrepareSpellScript(spell_custom_shadow_damage_transfer_SpellScript);
- void HandleOnHit() {
- if (Unit* caster = GetCaster()) {
- if (Unit* target = GetHitUnit()) {
- // Assuming SPELL_CORRUPTION is the spell ID for Corruption
- int32 corruptionDuration = 0, curseDuration = 0, uaDuration = 0;
- // Check for Corruption or Seed of Corruption
- if (Aura* aura = target->GetAura(SPELL_WARLOCK_CORRUPTION_R2, caster->GetGUID())) {
- corruptionDuration = aura->GetDuration(); // Positive value for Corruption
- }
- else if (Aura* aura = target->GetAura(SPELL_WARLOCK_SEED_OF_CORRUPTION_R1, caster->GetGUID())) {
- corruptionDuration = -aura->GetDuration(); // Negative value for Seed of Corruption
- }
- // Check for Curse of Agony or Curse of Doom
- if (Aura* aura = target->GetAura(SPELL_WARLOCK_CURSE_OF_AGONY_R2, caster->GetGUID())) {
- curseDuration = aura->GetDuration(); // Positive value for Curse of Agony
- }
- else if (Aura* aura = target->GetAura(SPELL_WARLOCK_CURSE_OF_DOOM_R1, caster->GetGUID())) {
- curseDuration = -aura->GetDuration(); // Negative value for Curse of Doom
- }
- // Check for Unstable Affliction
- if (Aura* aura = target->GetAura(SPELL_UNSTABLE_AFFLICTION_R1, caster->GetGUID())) {
- uaDuration = aura->GetDuration();
- }
- if (!(corruptionDuration == 0 && curseDuration == 0 && uaDuration == 0))
- {
- CastSpellExtraArgs args(TRIGGERED_FULL_MASK);
- args.AddSpellMod(SPELLVALUE_BASE_POINT0, corruptionDuration);
- args.AddSpellMod(SPELLVALUE_BASE_POINT1, curseDuration);
- args.AddSpellMod(SPELLVALUE_BASE_POINT2, uaDuration);
- args.SetOriginalCaster(target->GetGUID());
- target->CastSpell(caster, 85, args);
- target->RemoveAura(SPELL_WARLOCK_CORRUPTION_R2, caster->GetGUID());
- target->RemoveAura(SPELL_WARLOCK_SEED_OF_CORRUPTION_R1, caster->GetGUID());
- target->RemoveAura(SPELL_WARLOCK_CURSE_OF_AGONY_R2, caster->GetGUID());
- target->RemoveAura(SPELL_WARLOCK_CURSE_OF_DOOM_R1, caster->GetGUID());
- target->RemoveAura(SPELL_UNSTABLE_AFFLICTION_R1, caster->GetGUID());
- //caster->GetSpellHistory()->ModifyCooldown(82, 45000);
- ///caster->GetSpellHistory()->AddCooldown(82, 0, 45s);
- ///target->CastSpell(caster, 86);
- }
- else
- SetHitDamage(0);
- }
- }
- }
- SpellCastResult CheckCast()
- {
- Unit* caster = GetCaster();
- if (Unit* target = GetExplTargetUnit())
- {
- if (target->HasAura(SPELL_WARLOCK_CORRUPTION_R2) || target->HasAura(SPELL_WARLOCK_CURSE_OF_AGONY_R2) || target->HasAura(SPELL_WARLOCK_SEED_OF_CORRUPTION_R1)|| target->HasAura(SPELL_WARLOCK_CURSE_OF_DOOM_R1)|| target->HasAura(SPELL_UNSTABLE_AFFLICTION_R1))
- {
- return SPELL_CAST_OK;
- }
- else
- return SPELL_FAILED_BAD_TARGETS;
- }
- else
- return SPELL_FAILED_NO_VALID_TARGETS;
- return SPELL_FAILED_FIZZLE;
- }
- void Register() override
- {
- OnCheckCast += SpellCheckCastFn(spell_custom_shadow_damage_transfer_SpellScript::CheckCast);
- OnHit += SpellHitFn(spell_custom_shadow_damage_transfer_SpellScript::HandleOnHit);
- }
- };
- SpellScript* GetSpellScript() const override {
- return new spell_custom_shadow_damage_transfer_SpellScript();
- }
- };
- class spell_custom_shadow_damage_apply : public SpellScriptLoader {
- public:
- spell_custom_shadow_damage_apply() : SpellScriptLoader("spell_custom_shadow_damage_apply") {}
- class spell_custom_shadow_damage_apply_SpellScript : public SpellScript {
- PrepareSpellScript(spell_custom_shadow_damage_apply_SpellScript);
- void HandleOnHit() {
- if (Unit* caster = GetCaster()) {
- // Check if the warlock has the dummy aura
- if (Aura* aura = caster->GetAura(85)) {
- // Ensure the caster/owner of the aura is not the current target
- if (Unit* target = GetHitUnit()) {
- int32 Corruptionduration = aura->GetEffect(0)->GetAmount();
- int32 Curseduration = aura->GetEffect(1)->GetAmount();
- int32 UAduration = aura->GetEffect(2)->GetAmount();
- uint32 corruptionSpell = 0;
- uint32 curseSpell = 0;
- uint32 UASpell = 0;
- if (Corruptionduration > 0)
- corruptionSpell = SPELL_WARLOCK_CORRUPTION_R2;
- else if (Corruptionduration < 0)
- corruptionSpell = SPELL_WARLOCK_SEED_OF_CORRUPTION_R1;
- if (Curseduration > 0)
- curseSpell = SPELL_WARLOCK_CURSE_OF_AGONY_R2;
- else if (Curseduration < 0)
- curseSpell = SPELL_WARLOCK_CURSE_OF_DOOM_R1;
- if (UAduration)
- UASpell = SPELL_UNSTABLE_AFFLICTION_R1;
- if (Corruptionduration != 0)
- {
- CastDoTSpell(target, corruptionSpell, std::abs(Corruptionduration), caster);
- }
- if (Curseduration != 0)
- {
- CastDoTSpell(target, curseSpell, std::abs(Curseduration), caster);
- }
- if (UAduration != 0)
- {
- CastDoTSpell(target, SPELL_UNSTABLE_AFFLICTION_R1, std::abs(UAduration), caster);
- }
- // Remove the dummy aura
- caster->RemoveAurasDueToSpell(85);
- //caster->GetSpellHistory()->ModifyCooldown(83, 45000);
- ///caster->GetSpellHistory()->AddCooldown(83, 0, 45s);
- }
- }
- }
- }
- void CastDoTSpell(Unit* target, uint32 spellId, int32 duration, Unit* caster) {
- caster->CastSpell(target, spellId, true);
- if (Aura* newAura = target->GetAura(spellId, caster->GetGUID())) {
- newAura->SetDuration(duration);
- }
- }
- SpellCastResult CheckCast()
- {
- Unit* caster = GetCaster();
- if (Unit* target = GetExplTargetUnit())
- {
- if (Aura* COaura = caster->GetAura(85))
- {
- if (COaura->GetCasterGUID() != target->GetGUID())
- return SPELL_CAST_OK;
- }
- else
- return SPELL_FAILED_BAD_TARGETS;
- }
- else
- return SPELL_FAILED_NO_VALID_TARGETS;
- return SPELL_FAILED_FIZZLE;
- }
- void Register() override {
- OnHit += SpellHitFn(spell_custom_shadow_damage_apply_SpellScript::HandleOnHit);
- OnCheckCast += SpellCheckCastFn(spell_custom_shadow_damage_apply_SpellScript::CheckCast);
- }
- };
- SpellScript* GetSpellScript() const override {
- return new spell_custom_shadow_damage_apply_SpellScript();
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment