MichaelCrow

Shadow Transferance

Mar 5th, 2024
869
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.46 KB | None | 0 0
  1. class spell_custom_shadow_damage_transfer : public SpellScriptLoader {
  2. public:
  3.     spell_custom_shadow_damage_transfer() : SpellScriptLoader("spell_custom_shadow_damage_transfer") {}
  4.  
  5.     class spell_custom_shadow_damage_transfer_SpellScript : public SpellScript {
  6.         PrepareSpellScript(spell_custom_shadow_damage_transfer_SpellScript);
  7.  
  8.         void HandleOnHit() {
  9.             if (Unit* caster = GetCaster()) {
  10.                 if (Unit* target = GetHitUnit()) {
  11.                     // Assuming SPELL_CORRUPTION is the spell ID for Corruption
  12.                     int32 corruptionDuration = 0, curseDuration = 0, uaDuration = 0;
  13.  
  14.                     // Check for Corruption or Seed of Corruption
  15.                     if (Aura* aura = target->GetAura(SPELL_WARLOCK_CORRUPTION_R2, caster->GetGUID())) {
  16.                         corruptionDuration = aura->GetDuration(); // Positive value for Corruption
  17.                     }
  18.                     else if (Aura* aura = target->GetAura(SPELL_WARLOCK_SEED_OF_CORRUPTION_R1, caster->GetGUID())) {
  19.                         corruptionDuration = -aura->GetDuration(); // Negative value for Seed of Corruption
  20.                     }
  21.  
  22.                     // Check for Curse of Agony or Curse of Doom
  23.                     if (Aura* aura = target->GetAura(SPELL_WARLOCK_CURSE_OF_AGONY_R2, caster->GetGUID())) {
  24.                         curseDuration = aura->GetDuration(); // Positive value for Curse of Agony
  25.                     }
  26.                     else if (Aura* aura = target->GetAura(SPELL_WARLOCK_CURSE_OF_DOOM_R1, caster->GetGUID())) {
  27.                         curseDuration = -aura->GetDuration(); // Negative value for Curse of Doom
  28.                     }
  29.  
  30.                     // Check for Unstable Affliction
  31.                     if (Aura* aura = target->GetAura(SPELL_UNSTABLE_AFFLICTION_R1, caster->GetGUID())) {
  32.                         uaDuration = aura->GetDuration();
  33.                     }
  34.  
  35.                     if (!(corruptionDuration == 0 && curseDuration == 0 && uaDuration == 0))
  36.                     {
  37.                         CastSpellExtraArgs args(TRIGGERED_FULL_MASK);
  38.  
  39.                         args.AddSpellMod(SPELLVALUE_BASE_POINT0, corruptionDuration);
  40.                         args.AddSpellMod(SPELLVALUE_BASE_POINT1, curseDuration);
  41.                         args.AddSpellMod(SPELLVALUE_BASE_POINT2, uaDuration);
  42.                         args.SetOriginalCaster(target->GetGUID());
  43.                         target->CastSpell(caster, 85, args);
  44.  
  45.                         target->RemoveAura(SPELL_WARLOCK_CORRUPTION_R2, caster->GetGUID());
  46.                         target->RemoveAura(SPELL_WARLOCK_SEED_OF_CORRUPTION_R1, caster->GetGUID());
  47.                         target->RemoveAura(SPELL_WARLOCK_CURSE_OF_AGONY_R2, caster->GetGUID());
  48.                         target->RemoveAura(SPELL_WARLOCK_CURSE_OF_DOOM_R1, caster->GetGUID());
  49.                         target->RemoveAura(SPELL_UNSTABLE_AFFLICTION_R1, caster->GetGUID());
  50.  
  51.                         //caster->GetSpellHistory()->ModifyCooldown(82, 45000);
  52.                         ///caster->GetSpellHistory()->AddCooldown(82, 0, 45s);
  53.  
  54.                         ///target->CastSpell(caster, 86);
  55.                     }
  56.                     else
  57.                         SetHitDamage(0);
  58.                     }
  59.                 }
  60.             }
  61.  
  62.         SpellCastResult CheckCast()
  63.         {
  64.             Unit* caster = GetCaster();
  65.             if (Unit* target = GetExplTargetUnit())
  66.             {
  67.                 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))
  68.                 {
  69.                     return SPELL_CAST_OK;
  70.                 }
  71.                 else
  72.                     return SPELL_FAILED_BAD_TARGETS;
  73.             }
  74.             else
  75.                 return SPELL_FAILED_NO_VALID_TARGETS;
  76.  
  77.             return SPELL_FAILED_FIZZLE;
  78.         }
  79.  
  80.         void Register() override
  81.         {
  82.             OnCheckCast += SpellCheckCastFn(spell_custom_shadow_damage_transfer_SpellScript::CheckCast);
  83.             OnHit += SpellHitFn(spell_custom_shadow_damage_transfer_SpellScript::HandleOnHit);
  84.         }
  85.     };
  86.  
  87.     SpellScript* GetSpellScript() const override {
  88.         return new spell_custom_shadow_damage_transfer_SpellScript();
  89.     }
  90. };
  91.  
  92.  
  93.  
  94.  
  95.  
  96. class spell_custom_shadow_damage_apply : public SpellScriptLoader {
  97. public:
  98.     spell_custom_shadow_damage_apply() : SpellScriptLoader("spell_custom_shadow_damage_apply") {}
  99.  
  100.     class spell_custom_shadow_damage_apply_SpellScript : public SpellScript {
  101.         PrepareSpellScript(spell_custom_shadow_damage_apply_SpellScript);
  102.  
  103.         void HandleOnHit() {
  104.             if (Unit* caster = GetCaster()) {
  105.                 // Check if the warlock has the dummy aura
  106.                 if (Aura* aura = caster->GetAura(85)) {
  107.                     // Ensure the caster/owner of the aura is not the current target
  108.                     if (Unit* target = GetHitUnit()) {
  109.                        
  110.                             int32 Corruptionduration = aura->GetEffect(0)->GetAmount();
  111.                             int32 Curseduration = aura->GetEffect(1)->GetAmount();
  112.                             int32 UAduration = aura->GetEffect(2)->GetAmount();
  113.  
  114.                             uint32 corruptionSpell = 0;
  115.                             uint32 curseSpell = 0;
  116.                             uint32 UASpell = 0;
  117.                            
  118.                             if (Corruptionduration > 0)
  119.                                 corruptionSpell = SPELL_WARLOCK_CORRUPTION_R2;
  120.                             else if (Corruptionduration < 0)
  121.                                 corruptionSpell = SPELL_WARLOCK_SEED_OF_CORRUPTION_R1;
  122.  
  123.                             if (Curseduration > 0)
  124.                                 curseSpell = SPELL_WARLOCK_CURSE_OF_AGONY_R2;
  125.                             else if (Curseduration < 0)
  126.                                 curseSpell = SPELL_WARLOCK_CURSE_OF_DOOM_R1;
  127.  
  128.                             if (UAduration)
  129.                                 UASpell = SPELL_UNSTABLE_AFFLICTION_R1;
  130.  
  131.                             if (Corruptionduration != 0)
  132.                             {
  133.                                 CastDoTSpell(target, corruptionSpell, std::abs(Corruptionduration), caster);
  134.                             }
  135.                             if (Curseduration != 0)
  136.                             {
  137.                                 CastDoTSpell(target, curseSpell, std::abs(Curseduration), caster);
  138.                             }
  139.                             if (UAduration != 0)
  140.                             {
  141.                                 CastDoTSpell(target, SPELL_UNSTABLE_AFFLICTION_R1, std::abs(UAduration), caster);
  142.                             }
  143.  
  144.                             // Remove the dummy aura
  145.                             caster->RemoveAurasDueToSpell(85);
  146.                             //caster->GetSpellHistory()->ModifyCooldown(83, 45000);
  147.                             ///caster->GetSpellHistory()->AddCooldown(83, 0, 45s);
  148.  
  149.                     }
  150.                 }
  151.             }
  152.         }
  153.  
  154.         void CastDoTSpell(Unit* target, uint32 spellId, int32 duration, Unit* caster) {
  155.             caster->CastSpell(target, spellId, true);
  156.             if (Aura* newAura = target->GetAura(spellId, caster->GetGUID())) {
  157.                 newAura->SetDuration(duration);
  158.             }
  159.         }
  160.  
  161.         SpellCastResult CheckCast()
  162.         {
  163.             Unit* caster = GetCaster();
  164.             if (Unit* target = GetExplTargetUnit())
  165.             {
  166.                 if (Aura* COaura = caster->GetAura(85))
  167.                 {
  168.                     if (COaura->GetCasterGUID() != target->GetGUID())
  169.                         return SPELL_CAST_OK;
  170.                 }
  171.                 else
  172.                     return SPELL_FAILED_BAD_TARGETS;
  173.             }
  174.             else
  175.                 return SPELL_FAILED_NO_VALID_TARGETS;
  176.  
  177.             return SPELL_FAILED_FIZZLE;
  178.         }
  179.  
  180.         void Register() override {
  181.             OnHit += SpellHitFn(spell_custom_shadow_damage_apply_SpellScript::HandleOnHit);
  182.             OnCheckCast += SpellCheckCastFn(spell_custom_shadow_damage_apply_SpellScript::CheckCast);
  183.         }
  184.     };
  185.  
  186.     SpellScript* GetSpellScript() const override {
  187.         return new spell_custom_shadow_damage_apply_SpellScript();
  188.     }
  189. };
  190.  
Advertisement
Add Comment
Please, Sign In to add comment