From a3be4c25db9ca3921b288c8ec737de985c0d3e18 Mon Sep 17 00:00:00 2001 From: Jelle Meeus Date: Mon, 29 Jul 2024 14:57:25 +0200 Subject: [PATCH] refactor(Scripts/IcecrownCitadel): Spell Scripts use registry macros (#19508) * boss_blood_queen_lana_thel aura:spell_blood_queen_pact_of_the_darkfallen_dmg_aura * boss_blood_queen_lana_thel spell:spell_blood_queen_pact_of_the_darkfallen * boss_blood_queen_lana_thel spell:spell_blood_queen_pact_of_the_darkfallen_dmg_target * boss_blood_queen_lana_thel spell:spell_blood_queen_bloodbolt * boss_blood_queen_lana_thel aura:spell_blood_queen_frenzied_bloodthirst_aura * boss_blood_queen_lana_thel aura:spell_blood_queen_essence_of_the_blood_queen_aura * boss_blood_queen_lana_thel spell:spell_blood_queen_vampiric_bite * boss_blood_queen_lana_thel spell:spell_blood_queen_swarming_shadows_floor_dmg * boss_blood_queen_lana_thel spell:spell_blood_queen_presence_of_the_darkfallen * icecrown_citadel aura:spell_icc_stoneform_aura * icecrown_citadel spell:spell_icc_sprit_alarm * icecrown_citadel spell:spell_icc_geist_alarm * icecrown_citadel spell:spell_frost_giant_death_plague * icecrown_citadel spell:spell_icc_harvest_blight_specimen * icecrown_citadel spell:spell_svalna_revive_champion * icecrown_citadel spell:spell_svalna_remove_spear * icecrown_citadel spell:spell_icc_soul_missile * icecrown_citadel aura:spell_icc_web_wrap_aura * icecrown_citadel aura:spell_icc_dark_reckoning_aura * icecrown_citadel spell:spell_stinky_precious_decimate * icecrown_citadel aura:spell_icc_yf_frozen_orb_aura * icecrown_citadel aura:spell_icc_yh_volley_aura * icecrown_citadel spell:spell_icc_yd_summon_undead * icecrown_citadel spell:spell_icc_shattered_bones * boss_deathbringer_saurfang aura:spell_deathbringer_blood_link_aura * boss_deathbringer_saurfang aura:spell_deathbringer_blood_link_blood_beast_aura * boss_deathbringer_saurfang spell:spell_deathbringer_blood_link * boss_deathbringer_saurfang pair:spell_deathbringer_blood_power * boss_deathbringer_saurfang spell:spell_deathbringer_blood_nova_targeting * boss_deathbringer_saurfang spell:spell_deathbringer_boiling_blood * boss_festergut spell:spell_festergut_pungent_blight * boss_festergut aura:spell_festergut_blighted_spores_aura * boss_festergut spell:spell_festergut_gastric_bloat * boss_valithria_dreamwalker spell:spell_dreamwalker_summon_portal * boss_valithria_dreamwalker spell:spell_dreamwalker_twisted_nightmares * boss_valithria_dreamwalker aura:spell_dreamwalker_nightmare_cloud_aura * boss_valithria_dreamwalker aura:spell_dreamwalker_mana_void_aura * boss_valithria_dreamwalker aura:spell_dreamwalker_decay_periodic_timer_aura * boss_valithria_dreamwalker spell:spell_dreamwalker_summoner * boss_valithria_dreamwalker aura:spell_dreamwalker_summon_suppresser_aura * boss_valithria_dreamwalker spell:spell_dreamwalker_summon_suppresser_effect * boss_valithria_dreamwalker aura:spell_valithria_suppression_aura * boss_lady_deathwhisper aura:spell_deathwhisper_mana_barrier_aura * boss_professor_putricide spell:spell_putricide_slime_puddle * boss_professor_putricide spell:spell_putricide_slime_puddle_spawn * boss_professor_putricide aura:spell_putricide_grow_stacker_aura * boss_professor_putricide spell:spell_putricide_unstable_experiment * boss_professor_putricide spell:spell_putricide_tear_gas_effect * boss_professor_putricide aura:spell_putricide_gaseous_bloat_aura * boss_professor_putricide spell:spell_putricide_ooze_channel * boss_professor_putricide spell:spell_putricide_ooze_eruption_searcher * boss_professor_putricide aura:spell_putricide_mutated_plague_aura * boss_professor_putricide spell:spell_putricide_unbound_plague * boss_professor_putricide aura:spell_putricide_unbound_plague_dmg_aura * boss_professor_putricide spell:spell_putricide_choking_gas_bomb * boss_professor_putricide spell:spell_putricide_clear_aura_effect_value * boss_professor_putricide pair:spell_putricide_mutation_init * boss_professor_putricide spell:spell_putricide_mutated_transformation * boss_professor_putricide aura:spell_putricide_mutated_transformation_dismiss_aura * boss_professor_putricide spell:spell_putricide_mutated_transformation_dmg * boss_professor_putricide spell:spell_putricide_eat_ooze * boss_professor_putricide spell:spell_putricide_regurgitated_ooze * boss_sindragosa spell:spell_sindragosa_s_fury * boss_sindragosa aura:spell_sindragosa_permeating_chill_aura * boss_sindragosa aura:spell_sindragosa_instability_aura * boss_sindragosa spell:spell_sindragosa_icy_grip * boss_sindragosa spell:spell_sindragosa_icy_grip_jump * boss_sindragosa aura:spell_sindragosa_frost_beacon_aura * boss_sindragosa spell:spell_sindragosa_ice_tomb_filter * boss_sindragosa pair:spell_sindragosa_ice_tomb * boss_sindragosa spell:spell_sindragosa_mystic_buffet * boss_sindragosa aura:spell_sindragosa_soul_preservation_aura * boss_sindragosa spell:spell_rimefang_icy_blast * boss_sindragosa spell:spell_frostwarden_handler_order_whelp * boss_sindragosa pair:spell_frostwarden_handler_focus_fire * boss_sindragosa spell:spell_sindragosa_frost_breath * boss_lord_marrowgar spell:spell_marrowgar_coldflame * boss_lord_marrowgar spell:spell_marrowgar_bone_spike_graveyard * boss_lord_marrowgar spell:spell_marrowgar_coldflame_bonestorm * boss_lord_marrowgar spell:spell_marrowgar_bone_storm * boss_lord_marrowgar spell:spell_marrowgar_bone_slice * boss_the_lich_king spell:spell_the_lich_king_quake * boss_the_lich_king spell:spell_the_lich_king_jump * boss_the_lich_king spell:spell_the_lich_king_jump_remove_aura * boss_the_lich_king spell:spell_the_lich_king_play_movie * boss_the_lich_king aura:spell_the_lich_king_infest_aura * boss_the_lich_king aura:spell_the_lich_king_necrotic_plague_aura * boss_the_lich_king pair:spell_the_lich_king_necrotic_plague_jump * boss_the_lich_king aura:spell_the_lich_king_shadow_trap_visual_aura * boss_the_lich_king spell:spell_the_lich_king_shadow_trap_periodic * boss_the_lich_king spell:spell_the_lich_king_ice_burst_target_search * boss_the_lich_king spell:spell_the_lich_king_raging_spirit * boss_the_lich_king spell:spell_the_lich_king_defile * boss_the_lich_king aura:spell_the_lich_king_soul_reaper_aura * boss_the_lich_king spell:spell_the_lich_king_summon_into_air * boss_the_lich_king spell:spell_the_lich_king_teleport_to_frostmourne_hc * boss_the_lich_king spell:spell_the_lich_king_valkyr_target_search * boss_the_lich_king spell:spell_the_lich_king_cast_back_to_caster * boss_the_lich_king spell:spell_the_lich_king_life_siphon * boss_the_lich_king aura:spell_the_lich_king_vile_spirits_aura * boss_the_lich_king spell:spell_the_lich_king_vile_spirits_visual * boss_the_lich_king spell:spell_the_lich_king_vile_spirit_move_target_search * boss_the_lich_king spell:spell_the_lich_king_vile_spirit_damage_target_search * boss_the_lich_king aura:spell_the_lich_king_harvest_soul_aura * boss_the_lich_king aura:spell_the_lich_king_lights_favor_aura * boss_the_lich_king spell:spell_the_lich_king_restore_soul * boss_the_lich_king aura:spell_the_lich_king_dark_hunger_aura * boss_the_lich_king aura:spell_the_lich_king_soul_rip_aura * boss_the_lich_king spell:spell_the_lich_king_summon_spirit_bomb * boss_the_lich_king spell:spell_the_lich_king_trigger_vile_spirit * boss_icecrown_gunship_battle aura:spell_igb_rocket_pack_aura * boss_icecrown_gunship_battle aura:spell_igb_rocket_pack_useable_aura * boss_icecrown_gunship_battle spell:spell_igb_teleport_to_enemy_ship * boss_icecrown_gunship_battle spell:spell_igb_check_for_players * boss_icecrown_gunship_battle spell:spell_igb_gunship_fall_teleport * boss_icecrown_gunship_battle aura:spell_igb_explosion_main_aura * boss_icecrown_gunship_battle spell:spell_igb_explosion * boss_icecrown_gunship_battle spell:spell_igb_teleport_players_on_victory * boss_icecrown_gunship_battle aura:spell_igb_periodic_trigger_with_power_cost_aura * boss_icecrown_gunship_battle aura:spell_igb_overheat_aura * boss_icecrown_gunship_battle spell:spell_igb_cannon_blast * boss_icecrown_gunship_battle spell:spell_igb_incinerating_blast * boss_icecrown_gunship_battle spell:spell_igb_burning_pitch_selector * boss_icecrown_gunship_battle spell:spell_igb_burning_pitch * boss_icecrown_gunship_battle spell:spell_igb_rocket_artillery * boss_icecrown_gunship_battle spell:spell_igb_rocket_artillery_explosion * boss_icecrown_gunship_battle spell:spell_igb_below_zero * boss_icecrown_gunship_battle aura:spell_igb_on_gunship_deck_aura * boss_blood_prince_council aura:spell_blood_council_shadow_prison_aura * boss_blood_prince_council spell:spell_blood_council_shadow_prison_damage * boss_blood_prince_council spell:spell_taldaram_glittering_sparks * boss_blood_prince_council spell:spell_taldaram_summon_flame_ball * boss_blood_prince_council spell:spell_taldaram_ball_of_inferno_flame * boss_blood_prince_council pair:spell_valanar_kinetic_bomb * boss_blood_prince_council aura:spell_valanar_kinetic_bomb_absorb_aura * boss_blood_prince_council spell:spell_valanar_kinetic_bomb_knockback * boss_blood_prince_council spell:spell_valanar_kinetic_bomb_summon * boss_blood_prince_council spell:spell_blood_council_summon_shadow_resonance * boss_rotface pair:spell_rotface_mutated_infection * boss_rotface spell:spell_rotface_little_ooze_combine * boss_rotface spell:spell_rotface_large_ooze_combine * boss_rotface spell:spell_rotface_large_ooze_buff_combine * boss_rotface spell:spell_rotface_unstable_ooze_explosion_init * boss_rotface spell:spell_rotface_unstable_ooze_explosion * boss_rotface aura:spell_rotface_unstable_ooze_explosion_suicide_aura * icecrown_citadel.h spell:spell_trigger_spell_from_caster --- .../rev_1719841493844689528.sql | 43 + .../boss_blood_prince_council.cpp | 579 +++--- .../boss_blood_queen_lana_thel.cpp | 536 +++--- .../boss_deathbringer_saurfang.cpp | 484 +++-- .../IcecrownCitadel/boss_festergut.cpp | 175 +- .../boss_icecrown_gunship_battle.cpp | 1019 +++++----- .../boss_lady_deathwhisper.cpp | 35 +- .../IcecrownCitadel/boss_lord_marrowgar.cpp | 327 ++-- .../boss_professor_putricide.cpp | 1375 ++++++-------- .../IcecrownCitadel/boss_rotface.cpp | 514 +++-- .../IcecrownCitadel/boss_sindragosa.cpp | 833 ++++---- .../IcecrownCitadel/boss_the_lich_king.cpp | 1682 +++++++---------- .../boss_valithria_dreamwalker.cpp | 584 +++--- .../IcecrownCitadel/icecrown_citadel.cpp | 771 ++++---- .../IcecrownCitadel/icecrown_citadel.h | 41 +- 15 files changed, 3812 insertions(+), 5186 deletions(-) create mode 100644 data/sql/updates/pending_db_world/rev_1719841493844689528.sql diff --git a/data/sql/updates/pending_db_world/rev_1719841493844689528.sql b/data/sql/updates/pending_db_world/rev_1719841493844689528.sql new file mode 100644 index 000000000..e61ec6ca1 --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1719841493844689528.sql @@ -0,0 +1,43 @@ +-- +UPDATE `spell_script_names` SET `ScriptName`='spell_blood_queen_pact_of_the_darkfallen_dmg_aura' WHERE `spell_id`=71340 AND `ScriptName`='spell_blood_queen_pact_of_the_darkfallen_dmg'; +UPDATE `spell_script_names` SET `ScriptName`='spell_blood_queen_frenzied_bloodthirst_aura' WHERE `spell_id` IN (70877,71474) AND `ScriptName`='spell_blood_queen_frenzied_bloodthirst'; +UPDATE `spell_script_names` SET `ScriptName`='spell_blood_queen_essence_of_the_blood_queen_aura' WHERE `spell_id`=70871 AND `ScriptName`='spell_blood_queen_essence_of_the_blood_queen'; +UPDATE `spell_script_names` SET `ScriptName`='spell_icc_stoneform_aura' WHERE `spell_id`=70733 AND `ScriptName`='spell_icc_stoneform'; +UPDATE `spell_script_names` SET `ScriptName`='spell_icc_web_wrap_aura' WHERE `spell_id`=70980 AND `ScriptName`='spell_icc_web_wrap'; +UPDATE `spell_script_names` SET `ScriptName`='spell_icc_dark_reckoning_aura' WHERE `spell_id`=69483 AND `ScriptName`='spell_icc_dark_reckoning'; +UPDATE `spell_script_names` SET `ScriptName`='spell_icc_yf_frozen_orb_aura' WHERE `spell_id`=71274 AND `ScriptName`='spell_icc_yf_frozen_orb'; +UPDATE `spell_script_names` SET `ScriptName`='spell_icc_yh_volley_aura' WHERE `spell_id`=71252 AND `ScriptName`='spell_icc_yh_volley'; +UPDATE `spell_script_names` SET `ScriptName`='spell_festergut_blighted_spores_aura' WHERE `spell_id` IN (69290,71222,73033,73034) AND `ScriptName`='spell_festergut_blighted_spores'; +UPDATE `spell_script_names` SET `ScriptName`='spell_dreamwalker_nightmare_cloud_aura' WHERE `spell_id`=71970 AND `ScriptName`='spell_dreamwalker_nightmare_cloud'; +UPDATE `spell_script_names` SET `ScriptName`='spell_dreamwalker_mana_void_aura' WHERE `spell_id`=71085 AND `ScriptName`='spell_dreamwalker_mana_void'; +UPDATE `spell_script_names` SET `ScriptName`='spell_dreamwalker_decay_periodic_timer_aura' WHERE `spell_id` IN (70912,70913,70915,70916) AND `ScriptName`='spell_dreamwalker_decay_periodic_timer'; +UPDATE `spell_script_names` SET `ScriptName`='spell_dreamwalker_summon_suppresser_aura' WHERE `spell_id`=70912 AND `ScriptName`='spell_dreamwalker_summon_suppresser'; +UPDATE `spell_script_names` SET `ScriptName`='spell_valithria_suppression_aura' WHERE `spell_id`=70588 AND `ScriptName`='spell_valithria_suppression'; +UPDATE `spell_script_names` SET `ScriptName`='spell_deathwhisper_mana_barrier_aura' WHERE `spell_id`=70842 AND `ScriptName`='spell_deathwhisper_mana_barrier'; +UPDATE `spell_script_names` SET `ScriptName`='spell_putricide_grow_stacker_aura' WHERE `spell_id`=70345 AND `ScriptName`='spell_putricide_grow_stacker'; +UPDATE `spell_script_names` SET `ScriptName`='spell_putricide_gaseous_bloat_aura' WHERE `spell_id` IN (70672,72455,72832,72833) AND `ScriptName`='spell_putricide_gaseous_bloat'; +UPDATE `spell_script_names` SET `ScriptName`='spell_putricide_mutated_plague_aura' WHERE `spell_id` IN (72451,72463,72671,72672) AND `ScriptName`='spell_putricide_mutated_plague'; +UPDATE `spell_script_names` SET `ScriptName`='spell_putricide_unbound_plague_dmg_aura' WHERE `spell_id` IN (70911,72854,72855,72856) AND `ScriptName`='spell_putricide_unbound_plague_dmg'; +UPDATE `spell_script_names` SET `ScriptName`='spell_putricide_mutated_transformation_dismiss_aura' WHERE `spell_id` IN (70405,72508,72509,72510) AND `ScriptName`='spell_putricide_mutated_transformation_dismiss'; +UPDATE `spell_script_names` SET `ScriptName`='spell_sindragosa_permeating_chill_aura' WHERE `spell_id`=70107 AND `ScriptName`='spell_sindragosa_permeating_chill'; +UPDATE `spell_script_names` SET `ScriptName`='spell_sindragosa_instability_aura' WHERE `spell_id`=69766 AND `ScriptName`='spell_sindragosa_instability'; +UPDATE `spell_script_names` SET `ScriptName`='spell_sindragosa_frost_beacon_aura' WHERE `spell_id`=70126 AND `ScriptName`='spell_sindragosa_frost_beacon'; +UPDATE `spell_script_names` SET `ScriptName`='spell_sindragosa_soul_preservation_aura' WHERE `spell_id`=72465 AND `ScriptName`='spell_sindragosa_soul_preservation'; +UPDATE `spell_script_names` SET `ScriptName`='spell_the_lich_king_infest_aura' WHERE `spell_id` IN (70541,73779,73780,73781) AND `ScriptName`='spell_the_lich_king_infest'; +UPDATE `spell_script_names` SET `ScriptName`='spell_the_lich_king_necrotic_plague_aura' WHERE `spell_id` IN (70337,73912,73913,73914) AND `ScriptName`='spell_the_lich_king_necrotic_plague'; +UPDATE `spell_script_names` SET `ScriptName`='spell_the_lich_king_shadow_trap_visual_aura' WHERE `spell_id`=73530 AND `ScriptName`='spell_the_lich_king_shadow_trap_visual'; +UPDATE `spell_script_names` SET `ScriptName`='spell_the_lich_king_soul_reaper_aura' WHERE `spell_id` IN (69409,73797,73798,73799) AND `ScriptName`='spell_the_lich_king_soul_reaper'; +UPDATE `spell_script_names` SET `ScriptName`='spell_the_lich_king_vile_spirits_aura' WHERE `spell_id`=70498 AND `ScriptName`='spell_the_lich_king_vile_spirits'; +UPDATE `spell_script_names` SET `ScriptName`='spell_the_lich_king_harvest_soul_aura' WHERE `spell_id` IN (68980,74296,74297,74325) AND `ScriptName`='spell_the_lich_king_harvest_soul'; +UPDATE `spell_script_names` SET `ScriptName`='spell_the_lich_king_lights_favor_aura' WHERE `spell_id`=69382 AND `ScriptName`='spell_the_lich_king_lights_favor'; +UPDATE `spell_script_names` SET `ScriptName`='spell_the_lich_king_dark_hunger_aura' WHERE `spell_id`=69383 AND `ScriptName`='spell_the_lich_king_dark_hunger'; +UPDATE `spell_script_names` SET `ScriptName`='spell_the_lich_king_soul_rip_aura' WHERE `spell_id`=69397 AND `ScriptName`='spell_the_lich_king_soul_rip'; +UPDATE `spell_script_names` SET `ScriptName`='spell_igb_rocket_pack_aura' WHERE `spell_id`=68721 AND `ScriptName`='spell_igb_rocket_pack'; +UPDATE `spell_script_names` SET `ScriptName`='spell_igb_rocket_pack_useable_aura' WHERE `spell_id`=70348 AND `ScriptName`='spell_igb_rocket_pack_useable'; +UPDATE `spell_script_names` SET `ScriptName`='spell_igb_explosion_main_aura' WHERE `spell_id` IN (72134,72137) AND `ScriptName`='spell_igb_explosion_main'; +UPDATE `spell_script_names` SET `ScriptName`='spell_igb_periodic_trigger_with_power_cost_aura' WHERE `spell_id` IN (69470,69487) AND `ScriptName`='spell_igb_periodic_trigger_with_power_cost'; +UPDATE `spell_script_names` SET `ScriptName`='spell_igb_overheat_aura' WHERE `spell_id`=69487 AND `ScriptName`='spell_igb_overheat'; +UPDATE `spell_script_names` SET `ScriptName`='spell_igb_on_gunship_deck_aura' WHERE `spell_id` IN (70120,70121) AND `ScriptName`='spell_igb_on_gunship_deck'; +UPDATE `spell_script_names` SET `ScriptName`='spell_blood_council_shadow_prison_aura' WHERE `spell_id`=73001 AND `ScriptName`='spell_blood_council_shadow_prison'; +UPDATE `spell_script_names` SET `ScriptName`='spell_valanar_kinetic_bomb_absorb_aura' WHERE `spell_id`=72054 AND `ScriptName`='spell_valanar_kinetic_bomb_absorb'; +UPDATE `spell_script_names` SET `ScriptName`='spell_rotface_unstable_ooze_explosion_suicide_aura' WHERE `spell_id`=71441 AND `ScriptName`='spell_rotface_unstable_ooze_explosion_suicide'; diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp index f61ccaaf3..4b519e659 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp @@ -1440,358 +1440,253 @@ public: } }; -class spell_blood_council_shadow_prison : public SpellScriptLoader +class spell_blood_council_shadow_prison_aura : public AuraScript { -public: - spell_blood_council_shadow_prison() : SpellScriptLoader("spell_blood_council_shadow_prison") { } + PrepareAuraScript(spell_blood_council_shadow_prison_aura); - class spell_blood_council_shadow_prison_AuraScript : public AuraScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareAuraScript(spell_blood_council_shadow_prison_AuraScript); + return ValidateSpellInfo({ SPELL_SHADOW_PRISON_DAMAGE }); + } - void HandleDummyTick(AuraEffect const* aurEff) - { - if (GetTarget()->GetTypeId() == TYPEID_PLAYER && GetTarget()->isMoving()) - { - GetTarget()->CastSpell(GetTarget(), SPELL_SHADOW_PRISON_DAMAGE, true, nullptr, aurEff); - } - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_blood_council_shadow_prison_AuraScript::HandleDummyTick, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); - } - }; - - AuraScript* GetAuraScript() const override + void HandleDummyTick(AuraEffect const* aurEff) { - return new spell_blood_council_shadow_prison_AuraScript(); + if (GetTarget()->GetTypeId() == TYPEID_PLAYER && GetTarget()->isMoving()) + { + GetTarget()->CastSpell(GetTarget(), SPELL_SHADOW_PRISON_DAMAGE, true, nullptr, aurEff); + } + } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_blood_council_shadow_prison_aura::HandleDummyTick, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); } }; -class spell_blood_council_shadow_prison_damage : public SpellScriptLoader +class spell_blood_council_shadow_prison_damage : public SpellScript { -public: - spell_blood_council_shadow_prison_damage() : SpellScriptLoader("spell_blood_council_shadow_prison_damage") { } + PrepareSpellScript(spell_blood_council_shadow_prison_damage); - class spell_blood_council_shadow_prison_SpellScript : public SpellScript + void AddExtraDamage() { - PrepareSpellScript(spell_blood_council_shadow_prison_SpellScript); - - void AddExtraDamage() + if (Aura* aur = GetHitUnit()->GetAura(GetSpellInfo()->Id)) { - if (Aura* aur = GetHitUnit()->GetAura(GetSpellInfo()->Id)) + if (AuraEffect const* eff = aur->GetEffect(EFFECT_1)) { - if (AuraEffect const* eff = aur->GetEffect(EFFECT_1)) + SetHitDamage(GetHitDamage() + eff->GetAmount()); + } + } + } + + void Register() override + { + OnHit += SpellHitFn(spell_blood_council_shadow_prison_damage::AddExtraDamage); + } +}; + +class spell_taldaram_glittering_sparks : public SpellScript +{ + PrepareSpellScript(spell_taldaram_glittering_sparks); + + void HandleScript(SpellEffIndex effIndex) + { + PreventHitDefaultEffect(effIndex); + GetCaster()->CastSpell(GetCaster(), uint32(GetEffectValue()), true); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_taldaram_glittering_sparks::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } +}; + +class spell_taldaram_summon_flame_ball : public SpellScript +{ + PrepareSpellScript(spell_taldaram_summon_flame_ball); + + bool Load() override + { + if (GetCaster()->GetTypeId() != TYPEID_UNIT) + { + return false; + } + GetCaster()->CastSpell(GetCaster(), uint32(GetSpellInfo()->Effects[0].CalcValue()), true); + return true; + } + + void HandleScript(SpellEffIndex effIndex) + { + PreventHitDefaultEffect(effIndex); + GetCaster()->ToCreature()->AI()->DoAction(ACTION_FLAME_BALL_CHASE); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_taldaram_summon_flame_ball::HandleScript, EFFECT_0, SPELL_EFFECT_DUMMY); + } +}; + +class spell_taldaram_ball_of_inferno_flame : public SpellScript +{ + PrepareSpellScript(spell_taldaram_ball_of_inferno_flame); + + void ModAuraStack() + { + if (Aura* aur = GetHitAura()) + aur->SetStackAmount(uint8(GetSpellInfo()->StackAmount)); + } + + void Register() override + { + AfterHit += SpellHitFn(spell_taldaram_ball_of_inferno_flame::ModAuraStack); + } +}; + +class spell_valanar_kinetic_bomb : public SpellScript +{ + PrepareSpellScript(spell_valanar_kinetic_bomb); + + void ChangeSummonPos(SpellEffIndex /*effIndex*/) + { + WorldLocation summonPos = *GetExplTargetDest(); + Position offset = {0.0f, 0.0f, 20.0f, 0.0f}; + summonPos.RelocateOffset(offset); + SetExplTargetDest(summonPos); + GetHitDest()->RelocateOffset(offset); + } + + void Register() override + { + OnEffectHit += SpellEffectFn(spell_valanar_kinetic_bomb::ChangeSummonPos, EFFECT_0, SPELL_EFFECT_SUMMON); + } +}; + +class spell_valanar_kinetic_bomb_aura : public AuraScript +{ + PrepareAuraScript(spell_valanar_kinetic_bomb_aura); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_KINETIC_BOMB_EXPLOSION, SPELL_KINETIC_BOMB_VISUAL }); + } + + void HandleDummyTick(AuraEffect const* /*aurEff*/) + { + Unit* target = GetTarget(); + if (target->GetTypeId() != TYPEID_UNIT) + return; + + if (Creature* bomb = target->FindNearestCreature(NPC_KINETIC_BOMB, 1.0f, true)) + { + bomb->CastSpell(bomb, SPELL_KINETIC_BOMB_EXPLOSION, true); + bomb->RemoveAurasDueToSpell(SPELL_KINETIC_BOMB_VISUAL); + target->RemoveAura(GetAura()); + bomb->AI()->DoAction(SPELL_KINETIC_BOMB_EXPLOSION); + } + } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_valanar_kinetic_bomb_aura::HandleDummyTick, EFFECT_1, SPELL_AURA_PERIODIC_DUMMY); + } +}; + +class spell_valanar_kinetic_bomb_absorb_aura : public AuraScript +{ + PrepareAuraScript(spell_valanar_kinetic_bomb_absorb_aura); + + void OnAbsorb(AuraEffect* aurEff, DamageInfo& dmgInfo, uint32& absorbAmount) + { + absorbAmount = CalculatePct(dmgInfo.GetDamage(), aurEff->GetAmount()); + RoundToInterval(absorbAmount, 0, dmgInfo.GetDamage()); + dmgInfo.AbsorbDamage(absorbAmount); + } + + void Register() override + { + OnEffectAbsorb += AuraEffectAbsorbFn(spell_valanar_kinetic_bomb_absorb_aura::OnAbsorb, EFFECT_0); + } +}; + +class spell_valanar_kinetic_bomb_knockback : public SpellScript +{ + PrepareSpellScript(spell_valanar_kinetic_bomb_knockback); + + void KnockIntoAir(SpellMissInfo missInfo) + { + if (missInfo != SPELL_MISS_NONE) + { + return; + } + + if (Creature* target = GetHitCreature()) + target->AI()->DoAction(ACTION_KINETIC_BOMB_JUMP); + } + + void Register() override + { + BeforeHit += BeforeSpellHitFn(spell_valanar_kinetic_bomb_knockback::KnockIntoAir); + } +}; + +class spell_valanar_kinetic_bomb_summon : public SpellScript +{ + PrepareSpellScript(spell_valanar_kinetic_bomb_summon); + + void SelectDest() + { + if (Position* dest = const_cast(GetExplTargetDest())) + { + float angle = dest->GetAngle(GetCaster()); + Position offset = {6.0f * cos(angle), 6.0f * std::sin(angle), 10.0f, 0.0f}; + dest->RelocateOffset(offset); + GetCaster()->UpdateAllowedPositionZ(dest->GetPositionX(), dest->GetPositionY(), dest->m_positionZ); + } + } + + void Register() override + { + BeforeCast += SpellCastFn(spell_valanar_kinetic_bomb_summon::SelectDest); + } +}; + +class spell_blood_council_summon_shadow_resonance : public SpellScript +{ + PrepareSpellScript(spell_blood_council_summon_shadow_resonance); + + void SetDest(SpellDestination& dest) + { + Unit* summoner = GetCaster(); + float x = dest._position.GetPositionX(); + float y = dest._position.GetPositionY(); + float angle = summoner->GetAngle(x, y); + if (dest._position.GetExactDist2d(summoner) > 35.0f && x > 4585.0f && y > 2716.0f && y < 2822.0f) + return; + + for (uint8 a = 0; a < 2; ++a) + for (uint8 i = 6; i > 0; --i) + { + float destX = summoner->GetPositionX() + cos(angle + a * M_PI) * i * 10.0f; + float destY = summoner->GetPositionY() + std::sin(angle + a * M_PI) * i * 10.0f; + if (summoner->GetMap()->isInLineOfSight(summoner->GetPositionX(), summoner->GetPositionY(), summoner->GetPositionZ() + 10.0f, destX, destY, + summoner->GetPositionZ() + 10.0f, summoner->GetPhaseMask(), LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags::Nothing) && + destX > 4585.0f && destY > 2716.0f && destY < 2822.0f) { - SetHitDamage(GetHitDamage() + eff->GetAmount()); - } - } - } - - void Register() override - { - OnHit += SpellHitFn(spell_blood_council_shadow_prison_SpellScript::AddExtraDamage); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_blood_council_shadow_prison_SpellScript(); - } -}; - -class spell_taldaram_glittering_sparks : public SpellScriptLoader -{ -public: - spell_taldaram_glittering_sparks() : SpellScriptLoader("spell_taldaram_glittering_sparks") { } - - class spell_taldaram_glittering_sparks_SpellScript : public SpellScript - { - PrepareSpellScript(spell_taldaram_glittering_sparks_SpellScript); - - void HandleScript(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - GetCaster()->CastSpell(GetCaster(), uint32(GetEffectValue()), true); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_taldaram_glittering_sparks_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_taldaram_glittering_sparks_SpellScript(); - } -}; - -class spell_taldaram_summon_flame_ball : public SpellScriptLoader -{ -public: - spell_taldaram_summon_flame_ball() : SpellScriptLoader("spell_taldaram_summon_flame_ball") { } - - class spell_taldaram_summon_flame_ball_SpellScript : public SpellScript - { - PrepareSpellScript(spell_taldaram_summon_flame_ball_SpellScript); - - bool Load() override - { - if (GetCaster()->GetTypeId() != TYPEID_UNIT) - { - return false; - } - GetCaster()->CastSpell(GetCaster(), uint32(GetSpellInfo()->Effects[0].CalcValue()), true); - return true; - } - - void HandleScript(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - GetCaster()->ToCreature()->AI()->DoAction(ACTION_FLAME_BALL_CHASE); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_taldaram_summon_flame_ball_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_taldaram_summon_flame_ball_SpellScript(); - } -}; - -class spell_taldaram_ball_of_inferno_flame : public SpellScriptLoader -{ -public: - spell_taldaram_ball_of_inferno_flame() : SpellScriptLoader("spell_taldaram_ball_of_inferno_flame") { } - - class spell_taldaram_ball_of_inferno_flame_SpellScript : public SpellScript - { - PrepareSpellScript(spell_taldaram_ball_of_inferno_flame_SpellScript); - - void ModAuraStack() - { - if (Aura* aur = GetHitAura()) - aur->SetStackAmount(uint8(GetSpellInfo()->StackAmount)); - } - - void Register() override - { - AfterHit += SpellHitFn(spell_taldaram_ball_of_inferno_flame_SpellScript::ModAuraStack); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_taldaram_ball_of_inferno_flame_SpellScript(); - } -}; - -class spell_valanar_kinetic_bomb : public SpellScriptLoader -{ -public: - spell_valanar_kinetic_bomb() : SpellScriptLoader("spell_valanar_kinetic_bomb") { } - - class spell_valanar_kinetic_bomb_SpellScript : public SpellScript - { - PrepareSpellScript(spell_valanar_kinetic_bomb_SpellScript); - - void ChangeSummonPos(SpellEffIndex /*effIndex*/) - { - WorldLocation summonPos = *GetExplTargetDest(); - Position offset = {0.0f, 0.0f, 20.0f, 0.0f}; - summonPos.RelocateOffset(offset); - SetExplTargetDest(summonPos); - GetHitDest()->RelocateOffset(offset); - } - - void Register() override - { - OnEffectHit += SpellEffectFn(spell_valanar_kinetic_bomb_SpellScript::ChangeSummonPos, EFFECT_0, SPELL_EFFECT_SUMMON); - } - }; - - class spell_valanar_kinetic_bomb_AuraScript : public AuraScript - { - PrepareAuraScript(spell_valanar_kinetic_bomb_AuraScript); - - void HandleDummyTick(AuraEffect const* /*aurEff*/) - { - Unit* target = GetTarget(); - if (target->GetTypeId() != TYPEID_UNIT) - return; - - if (Creature* bomb = target->FindNearestCreature(NPC_KINETIC_BOMB, 1.0f, true)) - { - bomb->CastSpell(bomb, SPELL_KINETIC_BOMB_EXPLOSION, true); - bomb->RemoveAurasDueToSpell(SPELL_KINETIC_BOMB_VISUAL); - target->RemoveAura(GetAura()); - bomb->AI()->DoAction(SPELL_KINETIC_BOMB_EXPLOSION); - } - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_valanar_kinetic_bomb_AuraScript::HandleDummyTick, EFFECT_1, SPELL_AURA_PERIODIC_DUMMY); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_valanar_kinetic_bomb_SpellScript(); - } - - AuraScript* GetAuraScript() const override - { - return new spell_valanar_kinetic_bomb_AuraScript(); - } -}; - -class spell_valanar_kinetic_bomb_absorb : public SpellScriptLoader -{ -public: - spell_valanar_kinetic_bomb_absorb() : SpellScriptLoader("spell_valanar_kinetic_bomb_absorb") { } - - class spell_valanar_kinetic_bomb_absorb_AuraScript : public AuraScript - { - PrepareAuraScript(spell_valanar_kinetic_bomb_absorb_AuraScript); - - void OnAbsorb(AuraEffect* aurEff, DamageInfo& dmgInfo, uint32& absorbAmount) - { - absorbAmount = CalculatePct(dmgInfo.GetDamage(), aurEff->GetAmount()); - RoundToInterval(absorbAmount, 0, dmgInfo.GetDamage()); - dmgInfo.AbsorbDamage(absorbAmount); - } - - void Register() override - { - OnEffectAbsorb += AuraEffectAbsorbFn(spell_valanar_kinetic_bomb_absorb_AuraScript::OnAbsorb, EFFECT_0); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_valanar_kinetic_bomb_absorb_AuraScript(); - } -}; - -class spell_valanar_kinetic_bomb_knockback : public SpellScriptLoader -{ -public: - spell_valanar_kinetic_bomb_knockback() : SpellScriptLoader("spell_valanar_kinetic_bomb_knockback") { } - - class spell_valanar_kinetic_bomb_knockback_SpellScript : public SpellScript - { - PrepareSpellScript(spell_valanar_kinetic_bomb_knockback_SpellScript); - - void KnockIntoAir(SpellMissInfo missInfo) - { - if (missInfo != SPELL_MISS_NONE) - { - return; - } - - if (Creature* target = GetHitCreature()) - target->AI()->DoAction(ACTION_KINETIC_BOMB_JUMP); - } - - void Register() override - { - BeforeHit += BeforeSpellHitFn(spell_valanar_kinetic_bomb_knockback_SpellScript::KnockIntoAir); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_valanar_kinetic_bomb_knockback_SpellScript(); - } -}; - -class spell_valanar_kinetic_bomb_summon : public SpellScriptLoader -{ -public: - spell_valanar_kinetic_bomb_summon() : SpellScriptLoader("spell_valanar_kinetic_bomb_summon") { } - - class spell_valanar_kinetic_bomb_summon_SpellScript : public SpellScript - { - PrepareSpellScript(spell_valanar_kinetic_bomb_summon_SpellScript); - - void SelectDest() - { - if (Position* dest = const_cast(GetExplTargetDest())) - { - float angle = dest->GetAngle(GetCaster()); - Position offset = {6.0f * cos(angle), 6.0f * std::sin(angle), 10.0f, 0.0f}; - dest->RelocateOffset(offset); - GetCaster()->UpdateAllowedPositionZ(dest->GetPositionX(), dest->GetPositionY(), dest->m_positionZ); - } - } - - void Register() override - { - BeforeCast += SpellCastFn(spell_valanar_kinetic_bomb_summon_SpellScript::SelectDest); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_valanar_kinetic_bomb_summon_SpellScript(); - } -}; - -class spell_blood_council_summon_shadow_resonance : public SpellScriptLoader -{ -public: - spell_blood_council_summon_shadow_resonance() : SpellScriptLoader("spell_blood_council_summon_shadow_resonance") { } - - class spell_blood_council_summon_shadow_resonance_SpellScript : public SpellScript - { - PrepareSpellScript(spell_blood_council_summon_shadow_resonance_SpellScript); - - void SetDest(SpellDestination& dest) - { - Unit* summoner = GetCaster(); - float x = dest._position.GetPositionX(); - float y = dest._position.GetPositionY(); - float angle = summoner->GetAngle(x, y); - if (dest._position.GetExactDist2d(summoner) > 35.0f && x > 4585.0f && y > 2716.0f && y < 2822.0f) - return; - - for (uint8 a = 0; a < 2; ++a) - for (uint8 i = 6; i > 0; --i) - { - float destX = summoner->GetPositionX() + cos(angle + a * M_PI) * i * 10.0f; - float destY = summoner->GetPositionY() + std::sin(angle + a * M_PI) * i * 10.0f; - if (summoner->GetMap()->isInLineOfSight(summoner->GetPositionX(), summoner->GetPositionY(), summoner->GetPositionZ() + 10.0f, destX, destY, - summoner->GetPositionZ() + 10.0f, summoner->GetPhaseMask(), LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags::Nothing) && - destX > 4585.0f && destY > 2716.0f && destY < 2822.0f) + float destZ = summoner->GetMapHeight(summoner->GetPhaseMask(), destX, destY, summoner->GetPositionZ()); + if (std::fabs(destZ - summoner->GetPositionZ()) < 10.0f) // valid z found { - float destZ = summoner->GetMapHeight(summoner->GetPhaseMask(), destX, destY, summoner->GetPositionZ()); - if (std::fabs(destZ - summoner->GetPositionZ()) < 10.0f) // valid z found - { - dest._position.Relocate(destX, destY, destZ); - return; - } + dest._position.Relocate(destX, destY, destZ); + return; } } + } - dest._position.Relocate(summoner->GetPositionX(), summoner->GetPositionY(), summoner->GetPositionZ()); - } + dest._position.Relocate(summoner->GetPositionX(), summoner->GetPositionY(), summoner->GetPositionZ()); + } - void Register() override - { - OnDestinationTargetSelect += SpellDestinationTargetSelectFn(spell_blood_council_summon_shadow_resonance_SpellScript::SetDest, EFFECT_0, TARGET_DEST_CASTER_RANDOM); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_blood_council_summon_shadow_resonance_SpellScript(); + OnDestinationTargetSelect += SpellDestinationTargetSelectFn(spell_blood_council_summon_shadow_resonance::SetDest, EFFECT_0, TARGET_DEST_CASTER_RANDOM); } }; @@ -1804,15 +1699,15 @@ void AddSC_boss_blood_prince_council() new npc_dark_nucleus(); new npc_ball_of_flame(); new npc_kinetic_bomb(); - new spell_blood_council_shadow_prison(); - new spell_blood_council_shadow_prison_damage(); - new spell_taldaram_glittering_sparks(); - new spell_taldaram_summon_flame_ball(); - new spell_taldaram_ball_of_inferno_flame(); - new spell_valanar_kinetic_bomb(); - new spell_valanar_kinetic_bomb_absorb(); - new spell_valanar_kinetic_bomb_knockback(); - new spell_valanar_kinetic_bomb_summon(); - new spell_blood_council_summon_shadow_resonance(); + RegisterSpellScript(spell_blood_council_shadow_prison_aura); + RegisterSpellScript(spell_blood_council_shadow_prison_damage); + RegisterSpellScript(spell_taldaram_glittering_sparks); + RegisterSpellScript(spell_taldaram_summon_flame_ball); + RegisterSpellScript(spell_taldaram_ball_of_inferno_flame); + RegisterSpellAndAuraScriptPair(spell_valanar_kinetic_bomb, spell_valanar_kinetic_bomb_aura); + RegisterSpellScript(spell_valanar_kinetic_bomb_absorb_aura); + RegisterSpellScript(spell_valanar_kinetic_bomb_knockback); + RegisterSpellScript(spell_valanar_kinetic_bomb_summon); + RegisterSpellScript(spell_blood_council_summon_shadow_resonance); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp index 275b5f25b..3b1dd9843 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp @@ -587,114 +587,81 @@ public: // shortened version for clear code typedef boss_blood_queen_lana_thel::boss_blood_queen_lana_thelAI LanaThelAI; -class spell_blood_queen_pact_of_the_darkfallen_dmg : public SpellScriptLoader +class spell_blood_queen_pact_of_the_darkfallen_dmg_aura : public AuraScript { -public: - spell_blood_queen_pact_of_the_darkfallen_dmg() : SpellScriptLoader("spell_blood_queen_pact_of_the_darkfallen_dmg") { } + PrepareAuraScript(spell_blood_queen_pact_of_the_darkfallen_dmg_aura); - class spell_blood_queen_pact_of_the_darkfallen_dmg_AuraScript : public AuraScript + bool Validate(SpellInfo const* /*spell*/) override { - PrepareAuraScript(spell_blood_queen_pact_of_the_darkfallen_dmg_AuraScript); + return ValidateSpellInfo({ SPELL_PACT_OF_THE_DARKFALLEN_DAMAGE }); + } - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_PACT_OF_THE_DARKFALLEN_DAMAGE }); - } - - // this is an additional effect to be executed - void PeriodicTick(AuraEffect const* aurEff) - { - if ((aurEff->GetTickNumber() % 2) == 0) - return; - SpellInfo const* damageSpell = sSpellMgr->AssertSpellInfo(SPELL_PACT_OF_THE_DARKFALLEN_DAMAGE); - int32 damage = damageSpell->Effects[EFFECT_0].CalcValue(); - float herobonus = ((GetTarget()->FindMap() && GetTarget()->FindMap()->IsHeroic()) ? 0.2f : 0.0f); - float multiplier = 0.5f + herobonus + 0.1f * uint32(aurEff->GetTickNumber() / 10); // do not convert to 0.01f - we need tick number/10 as INT (damage increases every 10 ticks) - damage = int32(damage * multiplier); - GetTarget()->CastCustomSpell(SPELL_PACT_OF_THE_DARKFALLEN_DAMAGE, SPELLVALUE_BASE_POINT0, damage, GetTarget(), true); - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_blood_queen_pact_of_the_darkfallen_dmg_AuraScript::PeriodicTick, EFFECT_1, SPELL_AURA_PERIODIC_TRIGGER_SPELL); - } - }; - - AuraScript* GetAuraScript() const override + // this is an additional effect to be executed + void PeriodicTick(AuraEffect const* aurEff) { - return new spell_blood_queen_pact_of_the_darkfallen_dmg_AuraScript(); + if ((aurEff->GetTickNumber() % 2) == 0) + return; + SpellInfo const* damageSpell = sSpellMgr->AssertSpellInfo(SPELL_PACT_OF_THE_DARKFALLEN_DAMAGE); + int32 damage = damageSpell->Effects[EFFECT_0].CalcValue(); + float herobonus = ((GetTarget()->FindMap() && GetTarget()->FindMap()->IsHeroic()) ? 0.2f : 0.0f); + float multiplier = 0.5f + herobonus + 0.1f * uint32(aurEff->GetTickNumber() / 10); // do not convert to 0.01f - we need tick number/10 as INT (damage increases every 10 ticks) + damage = int32(damage * multiplier); + GetTarget()->CastCustomSpell(SPELL_PACT_OF_THE_DARKFALLEN_DAMAGE, SPELLVALUE_BASE_POINT0, damage, GetTarget(), true); + } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_blood_queen_pact_of_the_darkfallen_dmg_aura::PeriodicTick, EFFECT_1, SPELL_AURA_PERIODIC_TRIGGER_SPELL); } }; -class spell_blood_queen_pact_of_the_darkfallen : public SpellScriptLoader +class spell_blood_queen_pact_of_the_darkfallen : public SpellScript { -public: - spell_blood_queen_pact_of_the_darkfallen() : SpellScriptLoader("spell_blood_queen_pact_of_the_darkfallen") { } + PrepareSpellScript(spell_blood_queen_pact_of_the_darkfallen); - class spell_blood_queen_pact_of_the_darkfallen_SpellScript : public SpellScript + void FilterTargets(std::list& targets) { - PrepareSpellScript(spell_blood_queen_pact_of_the_darkfallen_SpellScript); + targets.remove_if(Acore::UnitAuraCheck(false, SPELL_PACT_OF_THE_DARKFALLEN)); - void FilterTargets(std::list& targets) + bool remove = true; + std::list::const_iterator itr, itr2, itrEnd = targets.end(); + for (itr = targets.begin(); itr != itrEnd && remove; ++itr) { - targets.remove_if(Acore::UnitAuraCheck(false, SPELL_PACT_OF_THE_DARKFALLEN)); + if (GetCaster()->GetExactDist2d(*itr) > 5.0f) + remove = false; - bool remove = true; - std::list::const_iterator itr, itr2, itrEnd = targets.end(); - for (itr = targets.begin(); itr != itrEnd && remove; ++itr) - { - if (GetCaster()->GetExactDist2d(*itr) > 5.0f) + for (itr2 = targets.begin(); itr2 != itrEnd && remove; ++itr2) + if (itr != itr2 && (*itr2)->GetExactDist2d(*itr) > 5.0f) remove = false; + } - for (itr2 = targets.begin(); itr2 != itrEnd && remove; ++itr2) - if (itr != itr2 && (*itr2)->GetExactDist2d(*itr) > 5.0f) - remove = false; + if (remove) + if (InstanceScript* instance = GetCaster()->GetInstanceScript()) + { + targets.clear(); + instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_PACT_OF_THE_DARKFALLEN); } + } - if (remove) - if (InstanceScript* instance = GetCaster()->GetInstanceScript()) - { - targets.clear(); - instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_PACT_OF_THE_DARKFALLEN); - } - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_blood_queen_pact_of_the_darkfallen_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ALLY); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_blood_queen_pact_of_the_darkfallen_SpellScript(); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_blood_queen_pact_of_the_darkfallen::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ALLY); } }; -class spell_blood_queen_pact_of_the_darkfallen_dmg_target : public SpellScriptLoader +class spell_blood_queen_pact_of_the_darkfallen_dmg_target : public SpellScript { -public: - spell_blood_queen_pact_of_the_darkfallen_dmg_target() : SpellScriptLoader("spell_blood_queen_pact_of_the_darkfallen_dmg_target") { } + PrepareSpellScript(spell_blood_queen_pact_of_the_darkfallen_dmg_target); - class spell_blood_queen_pact_of_the_darkfallen_dmg_SpellScript : public SpellScript + void FilterTargets(std::list& unitList) { - PrepareSpellScript(spell_blood_queen_pact_of_the_darkfallen_dmg_SpellScript); + unitList.remove_if(Acore::UnitAuraCheck(true, SPELL_PACT_OF_THE_DARKFALLEN)); + unitList.push_back(GetCaster()); + } - void FilterTargets(std::list& unitList) - { - unitList.remove_if(Acore::UnitAuraCheck(true, SPELL_PACT_OF_THE_DARKFALLEN)); - unitList.push_back(GetCaster()); - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_blood_queen_pact_of_the_darkfallen_dmg_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ALLY); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_blood_queen_pact_of_the_darkfallen_dmg_SpellScript(); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_blood_queen_pact_of_the_darkfallen_dmg_target::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ALLY); } }; @@ -712,283 +679,222 @@ private: LanaThelAI* _ai; }; -class spell_blood_queen_bloodbolt : public SpellScriptLoader +class spell_blood_queen_bloodbolt : public SpellScript { -public: - spell_blood_queen_bloodbolt() : SpellScriptLoader("spell_blood_queen_bloodbolt") { } + PrepareSpellScript(spell_blood_queen_bloodbolt); - class spell_blood_queen_bloodbolt_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spell*/) override { - PrepareSpellScript(spell_blood_queen_bloodbolt_SpellScript); + return ValidateSpellInfo({ SPELL_TWILIGHT_BLOODBOLT_FROM_WHIRL }); + } - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_TWILIGHT_BLOODBOLT_FROM_WHIRL }); - } - - bool Load() override - { - return GetCaster()->GetEntry() == NPC_BLOOD_QUEEN_LANA_THEL; - } - - void FilterTargets(std::list& targets) - { - uint32 targetCount = (targets.size() + 2) / 3; - targets.remove_if(BloodboltHitCheck(static_cast(GetCaster()->GetAI()))); - Acore::Containers::RandomResize(targets, targetCount); - // mark targets now, effect hook has missile travel time delay (might cast next in that time) - for (std::list::const_iterator itr = targets.begin(); itr != targets.end(); ++itr) - GetCaster()->GetAI()->SetGUID((*itr)->GetGUID(), GUID_BLOODBOLT); - } - - void HandleScript(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - GetCaster()->CastSpell(GetHitUnit(), SPELL_TWILIGHT_BLOODBOLT_FROM_WHIRL, true); - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_blood_queen_bloodbolt_SpellScript::FilterTargets, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY); - OnEffectHitTarget += SpellEffectFn(spell_blood_queen_bloodbolt_SpellScript::HandleScript, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + bool Load() override { - return new spell_blood_queen_bloodbolt_SpellScript(); + return GetCaster()->GetEntry() == NPC_BLOOD_QUEEN_LANA_THEL; + } + + void FilterTargets(std::list& targets) + { + uint32 targetCount = (targets.size() + 2) / 3; + targets.remove_if(BloodboltHitCheck(static_cast(GetCaster()->GetAI()))); + Acore::Containers::RandomResize(targets, targetCount); + // mark targets now, effect hook has missile travel time delay (might cast next in that time) + for (std::list::const_iterator itr = targets.begin(); itr != targets.end(); ++itr) + GetCaster()->GetAI()->SetGUID((*itr)->GetGUID(), GUID_BLOODBOLT); + } + + void HandleScript(SpellEffIndex effIndex) + { + PreventHitDefaultEffect(effIndex); + GetCaster()->CastSpell(GetHitUnit(), SPELL_TWILIGHT_BLOODBOLT_FROM_WHIRL, true); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_blood_queen_bloodbolt::FilterTargets, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY); + OnEffectHitTarget += SpellEffectFn(spell_blood_queen_bloodbolt::HandleScript, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT); } }; -class spell_blood_queen_frenzied_bloodthirst : public SpellScriptLoader +class spell_blood_queen_frenzied_bloodthirst_aura : public AuraScript { -public: - spell_blood_queen_frenzied_bloodthirst() : SpellScriptLoader("spell_blood_queen_frenzied_bloodthirst") { } + PrepareAuraScript(spell_blood_queen_frenzied_bloodthirst_aura); - class spell_blood_queen_frenzied_bloodthirst_AuraScript : public AuraScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareAuraScript(spell_blood_queen_frenzied_bloodthirst_AuraScript); + return ValidateSpellInfo({ SPELL_UNCONTROLLABLE_FRENZY }); + } - void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (InstanceScript* instance = GetTarget()->GetInstanceScript()) - if (Creature* bloodQueen = ObjectAccessor::GetCreature(*GetTarget(), instance->GetGuidData(DATA_BLOOD_QUEEN_LANA_THEL))) - bloodQueen->AI()->Talk(EMOTE_BLOODTHIRST, GetTarget()); - } - - void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - Unit* target = GetTarget(); - if (GetTargetApplication()->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE) - if (InstanceScript* instance = target->GetInstanceScript()) - if (Creature* bloodQueen = ObjectAccessor::GetCreature(*target, instance->GetGuidData(DATA_BLOOD_QUEEN_LANA_THEL))) - if (bloodQueen->IsAlive() && bloodQueen->IsInCombat()) - { - // this needs to be done BEFORE charm aura or we hit an assert in Unit::SetCharmedBy - if (target->GetVehicleKit()) - target->RemoveVehicleKit(); - - bloodQueen->AI()->Talk(SAY_MIND_CONTROL); - bloodQueen->CastSpell(target, SPELL_UNCONTROLLABLE_FRENZY, true); - } - } - - void Register() override - { - OnEffectApply += AuraEffectApplyFn(spell_blood_queen_frenzied_bloodthirst_AuraScript::OnApply, EFFECT_0, SPELL_AURA_OVERRIDE_SPELLS, AURA_EFFECT_HANDLE_REAL); - AfterEffectRemove += AuraEffectRemoveFn(spell_blood_queen_frenzied_bloodthirst_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_OVERRIDE_SPELLS, AURA_EFFECT_HANDLE_REAL); - } - }; - - AuraScript* GetAuraScript() const override + void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - return new spell_blood_queen_frenzied_bloodthirst_AuraScript(); + if (InstanceScript* instance = GetTarget()->GetInstanceScript()) + if (Creature* bloodQueen = ObjectAccessor::GetCreature(*GetTarget(), instance->GetGuidData(DATA_BLOOD_QUEEN_LANA_THEL))) + bloodQueen->AI()->Talk(EMOTE_BLOODTHIRST, GetTarget()); + } + + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Unit* target = GetTarget(); + if (GetTargetApplication()->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE) + if (InstanceScript* instance = target->GetInstanceScript()) + if (Creature* bloodQueen = ObjectAccessor::GetCreature(*target, instance->GetGuidData(DATA_BLOOD_QUEEN_LANA_THEL))) + if (bloodQueen->IsAlive() && bloodQueen->IsInCombat()) + { + // this needs to be done BEFORE charm aura or we hit an assert in Unit::SetCharmedBy + if (target->GetVehicleKit()) + target->RemoveVehicleKit(); + + bloodQueen->AI()->Talk(SAY_MIND_CONTROL); + bloodQueen->CastSpell(target, SPELL_UNCONTROLLABLE_FRENZY, true); + } + } + + void Register() override + { + OnEffectApply += AuraEffectApplyFn(spell_blood_queen_frenzied_bloodthirst_aura::OnApply, EFFECT_0, SPELL_AURA_OVERRIDE_SPELLS, AURA_EFFECT_HANDLE_REAL); + AfterEffectRemove += AuraEffectRemoveFn(spell_blood_queen_frenzied_bloodthirst_aura::OnRemove, EFFECT_0, SPELL_AURA_OVERRIDE_SPELLS, AURA_EFFECT_HANDLE_REAL); } }; -class spell_blood_queen_essence_of_the_blood_queen : public SpellScriptLoader +class spell_blood_queen_essence_of_the_blood_queen_aura : public AuraScript { -public: - spell_blood_queen_essence_of_the_blood_queen() : SpellScriptLoader("spell_blood_queen_essence_of_the_blood_queen") { } + PrepareAuraScript(spell_blood_queen_essence_of_the_blood_queen_aura); - class spell_blood_queen_essence_of_the_blood_queen_AuraScript : public AuraScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareAuraScript(spell_blood_queen_essence_of_the_blood_queen_AuraScript); + return ValidateSpellInfo({ SPELL_ESSENCE_OF_THE_BLOOD_QUEEN_HEAL }); + } - bool Validate(SpellInfo const* /*spellInfo*/) override + void OnProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) + { + PreventDefaultAction(); + + DamageInfo* damageInfo = eventInfo.GetDamageInfo(); + + if (!damageInfo || !damageInfo->GetDamage()) { - return ValidateSpellInfo({ SPELL_ESSENCE_OF_THE_BLOOD_QUEEN_HEAL }); + return; } - void OnProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) - { - PreventDefaultAction(); + int32 heal = CalculatePct(static_cast(damageInfo->GetDamage()), aurEff->GetAmount()); + GetTarget()->CastCustomSpell(SPELL_ESSENCE_OF_THE_BLOOD_QUEEN_HEAL, SPELLVALUE_BASE_POINT0, heal, GetTarget(), TRIGGERED_FULL_MASK, nullptr, aurEff); + } - DamageInfo* damageInfo = eventInfo.GetDamageInfo(); + void Register() override + { + OnEffectProc += AuraEffectProcFn(spell_blood_queen_essence_of_the_blood_queen_aura::OnProc, EFFECT_1, SPELL_AURA_DUMMY); + } +}; - if (!damageInfo || !damageInfo->GetDamage()) +class spell_blood_queen_vampiric_bite : public SpellScript +{ + PrepareSpellScript(spell_blood_queen_vampiric_bite); + + bool Validate(SpellInfo const* /*spell*/) override + { + return ValidateSpellInfo( { - return; - } - - int32 heal = CalculatePct(static_cast(damageInfo->GetDamage()), aurEff->GetAmount()); - GetTarget()->CastCustomSpell(SPELL_ESSENCE_OF_THE_BLOOD_QUEEN_HEAL, SPELLVALUE_BASE_POINT0, heal, GetTarget(), TRIGGERED_FULL_MASK, nullptr, aurEff); - } - - void Register() override - { - OnEffectProc += AuraEffectProcFn(spell_blood_queen_essence_of_the_blood_queen_AuraScript::OnProc, EFFECT_1, SPELL_AURA_DUMMY); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_blood_queen_essence_of_the_blood_queen_AuraScript(); + SPELL_ESSENCE_OF_THE_BLOOD_QUEEN_PLR, + SPELL_FRENZIED_BLOODTHIRST, + SPELL_PRESENCE_OF_THE_DARKFALLEN_DUMMY + }); } -}; -class spell_blood_queen_vampiric_bite : public SpellScriptLoader -{ -public: - spell_blood_queen_vampiric_bite() : SpellScriptLoader("spell_blood_queen_vampiric_bite") { } - - class spell_blood_queen_vampiric_bite_SpellScript : public SpellScript + SpellCastResult CheckTarget() { - PrepareSpellScript(spell_blood_queen_vampiric_bite_SpellScript); - - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo( - { - SPELL_ESSENCE_OF_THE_BLOOD_QUEEN_PLR, - SPELL_FRENZIED_BLOODTHIRST, - SPELL_PRESENCE_OF_THE_DARKFALLEN_DUMMY - }); - } - - SpellCastResult CheckTarget() - { - if (GetExplTargetUnit()->GetMapId() != 631) - return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW; - if (IsVampire(GetExplTargetUnit())) - { - SetCustomCastResultMessage(SPELL_CUSTOM_ERROR_CANT_TARGET_VAMPIRES); - return SPELL_FAILED_CUSTOM_ERROR; - } - if (InstanceScript* instance = GetExplTargetUnit()->GetInstanceScript()) - if (instance->GetBossState(DATA_BLOOD_QUEEN_LANA_THEL) == IN_PROGRESS) - return SPELL_CAST_OK; - + if (GetExplTargetUnit()->GetMapId() != 631) return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW; - } - - void OnCast(SpellMissInfo missInfo) + if (IsVampire(GetExplTargetUnit())) { - if (missInfo != SPELL_MISS_NONE) - { - return; - } - - if (GetCaster()->GetTypeId() != TYPEID_PLAYER || GetCaster()->GetMapId() != 631) - return; - InstanceScript* instance = GetCaster()->GetInstanceScript(); - if (!instance || instance->GetBossState(DATA_BLOOD_QUEEN_LANA_THEL) != IN_PROGRESS) - return; - - uint32 spellId = sSpellMgr->GetSpellIdForDifficulty(SPELL_FRENZIED_BLOODTHIRST, GetCaster()); - GetCaster()->RemoveAura(spellId, ObjectGuid::Empty, 0, AURA_REMOVE_BY_ENEMY_SPELL); - GetCaster()->CastSpell(GetCaster(), SPELL_ESSENCE_OF_THE_BLOOD_QUEEN_PLR, TRIGGERED_FULL_MASK); - - if (Aura* aura = GetCaster()->GetAura(SPELL_GUSHING_WOUND)) - { - if (aura->GetStackAmount() == 3) - { - GetCaster()->CastSpell(GetCaster(), SPELL_THIRST_QUENCHED, TRIGGERED_FULL_MASK); - GetCaster()->RemoveAura(aura); - } - else - GetCaster()->CastSpell(GetCaster(), SPELL_GUSHING_WOUND, TRIGGERED_FULL_MASK); - } - - if (InstanceScript* instance = GetCaster()->GetInstanceScript()) - if (Creature* bloodQueen = ObjectAccessor::GetCreature(*GetCaster(), instance->GetGuidData(DATA_BLOOD_QUEEN_LANA_THEL))) - bloodQueen->AI()->SetGUID(GetHitUnit()->GetGUID(), GUID_VAMPIRE); + SetCustomCastResultMessage(SPELL_CUSTOM_ERROR_CANT_TARGET_VAMPIRES); + return SPELL_FAILED_CUSTOM_ERROR; } + if (InstanceScript* instance = GetExplTargetUnit()->GetInstanceScript()) + if (instance->GetBossState(DATA_BLOOD_QUEEN_LANA_THEL) == IN_PROGRESS) + return SPELL_CAST_OK; - void HandlePresence(SpellEffIndex /*effIndex*/) - { - GetHitUnit()->CastSpell(GetHitUnit(), SPELL_PRESENCE_OF_THE_DARKFALLEN_DUMMY, TRIGGERED_FULL_MASK); - GetHitUnit()->CastSpell(GetHitUnit(), SPELL_PRESENCE_OF_THE_DARKFALLEN_SE, TRIGGERED_FULL_MASK); - } + return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW; + } - void Register() override - { - OnCheckCast += SpellCheckCastFn(spell_blood_queen_vampiric_bite_SpellScript::CheckTarget); - BeforeHit += BeforeSpellHitFn(spell_blood_queen_vampiric_bite_SpellScript::OnCast); - OnEffectHitTarget += SpellEffectFn(spell_blood_queen_vampiric_bite_SpellScript::HandlePresence, EFFECT_1, SPELL_EFFECT_TRIGGER_SPELL); - } - }; - - SpellScript* GetSpellScript() const override + void OnCast(SpellMissInfo missInfo) { - return new spell_blood_queen_vampiric_bite_SpellScript(); + if (missInfo != SPELL_MISS_NONE) + { + return; + } + + if (GetCaster()->GetTypeId() != TYPEID_PLAYER || GetCaster()->GetMapId() != 631) + return; + InstanceScript* instance = GetCaster()->GetInstanceScript(); + if (!instance || instance->GetBossState(DATA_BLOOD_QUEEN_LANA_THEL) != IN_PROGRESS) + return; + + uint32 spellId = sSpellMgr->GetSpellIdForDifficulty(SPELL_FRENZIED_BLOODTHIRST, GetCaster()); + GetCaster()->RemoveAura(spellId, ObjectGuid::Empty, 0, AURA_REMOVE_BY_ENEMY_SPELL); + GetCaster()->CastSpell(GetCaster(), SPELL_ESSENCE_OF_THE_BLOOD_QUEEN_PLR, TRIGGERED_FULL_MASK); + + if (Aura* aura = GetCaster()->GetAura(SPELL_GUSHING_WOUND)) + { + if (aura->GetStackAmount() == 3) + { + GetCaster()->CastSpell(GetCaster(), SPELL_THIRST_QUENCHED, TRIGGERED_FULL_MASK); + GetCaster()->RemoveAura(aura); + } + else + GetCaster()->CastSpell(GetCaster(), SPELL_GUSHING_WOUND, TRIGGERED_FULL_MASK); + } + + if (InstanceScript* instance = GetCaster()->GetInstanceScript()) + if (Creature* bloodQueen = ObjectAccessor::GetCreature(*GetCaster(), instance->GetGuidData(DATA_BLOOD_QUEEN_LANA_THEL))) + bloodQueen->AI()->SetGUID(GetHitUnit()->GetGUID(), GUID_VAMPIRE); + } + + void HandlePresence(SpellEffIndex /*effIndex*/) + { + GetHitUnit()->CastSpell(GetHitUnit(), SPELL_PRESENCE_OF_THE_DARKFALLEN_DUMMY, TRIGGERED_FULL_MASK); + GetHitUnit()->CastSpell(GetHitUnit(), SPELL_PRESENCE_OF_THE_DARKFALLEN_SE, TRIGGERED_FULL_MASK); + } + + void Register() override + { + OnCheckCast += SpellCheckCastFn(spell_blood_queen_vampiric_bite::CheckTarget); + BeforeHit += BeforeSpellHitFn(spell_blood_queen_vampiric_bite::OnCast); + OnEffectHitTarget += SpellEffectFn(spell_blood_queen_vampiric_bite::HandlePresence, EFFECT_1, SPELL_EFFECT_TRIGGER_SPELL); } }; -class spell_blood_queen_swarming_shadows_floor_dmg : public SpellScriptLoader +class spell_blood_queen_swarming_shadows_floor_dmg : public SpellScript { -public: - spell_blood_queen_swarming_shadows_floor_dmg() : SpellScriptLoader("spell_blood_queen_swarming_shadows_floor_dmg") { } + PrepareSpellScript(spell_blood_queen_swarming_shadows_floor_dmg); - class spell_blood_queen_swarming_shadows_floor_dmg_SpellScript : public SpellScript + void FilterTargets(std::list& targets) { - PrepareSpellScript(spell_blood_queen_swarming_shadows_floor_dmg_SpellScript); + targets.remove_if(Acore::AllWorldObjectsInExactRange(GetCaster(), GetSpellInfo()->Effects[0].CalcRadius(), true)); + } - void FilterTargets(std::list& targets) - { - targets.remove_if(Acore::AllWorldObjectsInExactRange(GetCaster(), GetSpellInfo()->Effects[0].CalcRadius(), true)); - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_blood_queen_swarming_shadows_floor_dmg_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_blood_queen_swarming_shadows_floor_dmg_SpellScript(); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_blood_queen_swarming_shadows_floor_dmg::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); } }; -class spell_blood_queen_presence_of_the_darkfallen : public SpellScriptLoader +class spell_blood_queen_presence_of_the_darkfallen : public SpellScript { -public: - spell_blood_queen_presence_of_the_darkfallen() : SpellScriptLoader("spell_blood_queen_presence_of_the_darkfallen") { } + PrepareSpellScript(spell_blood_queen_presence_of_the_darkfallen); - class spell_blood_queen_presence_of_the_darkfallen_SpellScript : public SpellScript + void HandleScript(SpellEffIndex effIndex) { - PrepareSpellScript(spell_blood_queen_presence_of_the_darkfallen_SpellScript); + PreventHitDefaultEffect(effIndex); + if (!GetHitUnit()) + return; - void HandleScript(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - if (!GetHitUnit()) - return; + if (InstanceScript* instance = GetHitUnit()->GetInstanceScript()) + GetHitUnit()->CastSpell((Unit*)nullptr, GetSpellInfo()->Effects[effIndex].TriggerSpell, true, nullptr, nullptr, instance->GetGuidData(DATA_BLOOD_QUEEN_LANA_THEL)); + } - if (InstanceScript* instance = GetHitUnit()->GetInstanceScript()) - GetHitUnit()->CastSpell((Unit*)nullptr, GetSpellInfo()->Effects[effIndex].TriggerSpell, true, nullptr, nullptr, instance->GetGuidData(DATA_BLOOD_QUEEN_LANA_THEL)); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_blood_queen_presence_of_the_darkfallen_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_FORCE_CAST); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_blood_queen_presence_of_the_darkfallen_SpellScript(); + OnEffectHitTarget += SpellEffectFn(spell_blood_queen_presence_of_the_darkfallen::HandleScript, EFFECT_0, SPELL_EFFECT_FORCE_CAST); } }; @@ -1014,15 +920,15 @@ public: void AddSC_boss_blood_queen_lana_thel() { new boss_blood_queen_lana_thel(); - new spell_blood_queen_pact_of_the_darkfallen_dmg(); - new spell_blood_queen_pact_of_the_darkfallen(); - new spell_blood_queen_pact_of_the_darkfallen_dmg_target(); - new spell_blood_queen_bloodbolt(); - new spell_blood_queen_frenzied_bloodthirst(); - new spell_blood_queen_essence_of_the_blood_queen(); - new spell_blood_queen_vampiric_bite(); - new spell_blood_queen_swarming_shadows_floor_dmg(); - new spell_blood_queen_presence_of_the_darkfallen(); + RegisterSpellScript(spell_blood_queen_pact_of_the_darkfallen_dmg_aura); + RegisterSpellScript(spell_blood_queen_pact_of_the_darkfallen); + RegisterSpellScript(spell_blood_queen_pact_of_the_darkfallen_dmg_target); + RegisterSpellScript(spell_blood_queen_bloodbolt); + RegisterSpellScript(spell_blood_queen_frenzied_bloodthirst_aura); + RegisterSpellScript(spell_blood_queen_essence_of_the_blood_queen_aura); + RegisterSpellScript(spell_blood_queen_vampiric_bite); + RegisterSpellScript(spell_blood_queen_swarming_shadows_floor_dmg); + RegisterSpellScript(spell_blood_queen_presence_of_the_darkfallen); new achievement_once_bitten_twice_shy("achievement_once_bitten_twice_shy_n_10", 0, false); new achievement_once_bitten_twice_shy("achievement_once_bitten_twice_shy_v_10", 0, true); new achievement_once_bitten_twice_shy("achievement_once_bitten_twice_shy_n_25", 1, false); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp index c99a924a0..08058a970 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp @@ -1042,307 +1042,245 @@ public: } }; -class spell_deathbringer_blood_link_aura : public SpellScriptLoader +class spell_deathbringer_blood_link_aura : public AuraScript { -public: - spell_deathbringer_blood_link_aura() : SpellScriptLoader("spell_deathbringer_blood_link_aura") { } + PrepareAuraScript(spell_deathbringer_blood_link_aura); - class spell_deathbringer_blood_link_AuraScript : public AuraScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareAuraScript(spell_deathbringer_blood_link_AuraScript); + return ValidateSpellInfo({ SPELL_BLOOD_LINK_DUMMY }); + } - void HandlePeriodicTick(AuraEffect const* /*aurEff*/) + void HandlePeriodicTick(AuraEffect const* /*aurEff*/) + { + PreventDefaultAction(); + if (GetUnitOwner()->getPowerType() == POWER_ENERGY && GetUnitOwner()->GetPower(POWER_ENERGY) == GetUnitOwner()->GetMaxPower(POWER_ENERGY)) + if (Creature* saurfang = GetUnitOwner()->ToCreature()) + saurfang->AI()->DoAction(ACTION_MARK_OF_THE_FALLEN_CHAMPION); + } + + bool CheckProc(ProcEventInfo& eventInfo) + { + DamageInfo* damageInfo = eventInfo.GetDamageInfo(); + SpellInfo const* procSpell = eventInfo.GetSpellInfo(); + return eventInfo.GetActor() && eventInfo.GetActionTarget() && ((damageInfo && damageInfo->GetDamage()) || eventInfo.GetHitMask() & PROC_EX_ABSORB) && procSpell && procSpell->SpellIconID != 2731; // Xinef: Mark of the Fallen Champion + } + + void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo) + { + PreventDefaultAction(); + Unit* victim = eventInfo.GetActionTarget(); + SpellInfo const* procSpell = eventInfo.GetSpellInfo(); + + //uint32 markCount = 0; + //if (Creature* saurfang = eventInfo.GetActor()->ToCreature()) + //markCount = saurfang->IsAIEnabled ? saurfang->AI()->GetData(123456 /*FALLEN_CHAMPION_CAST_COUNT*/) : 0; + int32 basepoints = int32(1.0f /*+ 0.5f + 0.5f*markCount*/); + switch (procSpell->Id) // some spells give more Blood Power { - PreventDefaultAction(); - if (GetUnitOwner()->getPowerType() == POWER_ENERGY && GetUnitOwner()->GetPower(POWER_ENERGY) == GetUnitOwner()->GetMaxPower(POWER_ENERGY)) - if (Creature* saurfang = GetUnitOwner()->ToCreature()) - saurfang->AI()->DoAction(ACTION_MARK_OF_THE_FALLEN_CHAMPION); + case 72380: + case 72438: + case 72439: + case 72440: // Blood Nova + basepoints = int32(2.0f /*+ 0.5f + 0.75f*markCount*/); + break; } - bool CheckProc(ProcEventInfo& eventInfo) - { - DamageInfo* damageInfo = eventInfo.GetDamageInfo(); - SpellInfo const* procSpell = eventInfo.GetSpellInfo(); - return eventInfo.GetActor() && eventInfo.GetActionTarget() && ((damageInfo && damageInfo->GetDamage()) || eventInfo.GetHitMask() & PROC_EX_ABSORB) && procSpell && procSpell->SpellIconID != 2731; // Xinef: Mark of the Fallen Champion - } + victim->CastCustomSpell(SPELL_BLOOD_LINK_DUMMY, SPELLVALUE_BASE_POINT0, basepoints, eventInfo.GetActor(), true); + return; + } - void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo) - { - PreventDefaultAction(); - Unit* victim = eventInfo.GetActionTarget(); - SpellInfo const* procSpell = eventInfo.GetSpellInfo(); + void Register() override + { + DoCheckProc += AuraCheckProcFn(spell_deathbringer_blood_link_aura::CheckProc); + OnEffectProc += AuraEffectProcFn(spell_deathbringer_blood_link_aura::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL); + OnEffectPeriodic += AuraEffectPeriodicFn(spell_deathbringer_blood_link_aura::HandlePeriodicTick, EFFECT_1, SPELL_AURA_PERIODIC_DUMMY); + } +}; - //uint32 markCount = 0; - //if (Creature* saurfang = eventInfo.GetActor()->ToCreature()) - //markCount = saurfang->IsAIEnabled ? saurfang->AI()->GetData(123456 /*FALLEN_CHAMPION_CAST_COUNT*/) : 0; - int32 basepoints = int32(1.0f /*+ 0.5f + 0.5f*markCount*/); - switch (procSpell->Id) // some spells give more Blood Power - { - case 72380: - case 72438: - case 72439: - case 72440: // Blood Nova - basepoints = int32(2.0f /*+ 0.5f + 0.75f*markCount*/); - break; - } +class spell_deathbringer_blood_link_blood_beast_aura : public AuraScript +{ + PrepareAuraScript(spell_deathbringer_blood_link_blood_beast_aura); - victim->CastCustomSpell(SPELL_BLOOD_LINK_DUMMY, SPELLVALUE_BASE_POINT0, basepoints, eventInfo.GetActor(), true); + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_BLOOD_LINK_DUMMY }); + } + + bool CheckProc(ProcEventInfo& eventInfo) + { + DamageInfo* damageInfo = eventInfo.GetDamageInfo(); + SpellInfo const* procSpell = eventInfo.GetSpellInfo(); + return eventInfo.GetActor() && eventInfo.GetActionTarget() && ((damageInfo && damageInfo->GetDamage()) || eventInfo.GetHitMask() & PROC_EX_ABSORB) && (!procSpell || procSpell->SpellIconID != 2731); // Xinef: Mark of the Fallen Champion + } + + void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo) + { + PreventDefaultAction(); + + /* + uint32 markCount = 0; + if (Map* map = eventInfo.GetActor()->FindMap()) + if (InstanceMap* imap = map->ToInstanceMap()) + if (InstanceScript* isc = imap->GetInstanceScript()) + if (ObjectGuid sguid = isc->GetGuidData(3) //DATA_DEATHBRINGER_SAURFANG + if (Creature* saurfang = ObjectAccessor::GetCreature(*eventInfo.GetActor(), sguid)) + markCount = saurfang->IsAIEnabled ? saurfang->AI()->GetData(123456) : 0; //FALLEN_CHAMPION_CAST_COUNT + */ + int32 basepoints = int32(3.0f /*+ 0.5f + 0.5f*markCount*/); + + eventInfo.GetActor()->CastCustomSpell(SPELL_BLOOD_LINK_DUMMY, SPELLVALUE_BASE_POINT0, basepoints, eventInfo.GetActionTarget(), true); + return; + } + + void Register() override + { + DoCheckProc += AuraCheckProcFn(spell_deathbringer_blood_link_blood_beast_aura::CheckProc); + OnEffectProc += AuraEffectProcFn(spell_deathbringer_blood_link_blood_beast_aura::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL); + } +}; + +class spell_deathbringer_blood_link : public SpellScript +{ + PrepareSpellScript(spell_deathbringer_blood_link); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_BLOOD_LINK_POWER }); + } + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + GetHitUnit()->CastCustomSpell(SPELL_BLOOD_LINK_POWER, SPELLVALUE_BASE_POINT0, GetEffectValue(), GetHitUnit(), true); + if (Aura* bloodPower = GetHitUnit()->GetAura(SPELL_BLOOD_POWER)) + bloodPower->RecalculateAmountOfEffects(); + PreventHitDefaultEffect(EFFECT_0); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_deathbringer_blood_link::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } +}; + +class spell_deathbringer_blood_power : public SpellScript +{ + PrepareSpellScript(spell_deathbringer_blood_power); + + void ModAuraValue() + { + if (Aura* aura = GetHitAura()) + aura->RecalculateAmountOfEffects(); + } + + void Register() override + { + AfterHit += SpellHitFn(spell_deathbringer_blood_power::ModAuraValue); + } +}; + +class spell_deathbringer_blood_power_aura : public AuraScript +{ + PrepareAuraScript(spell_deathbringer_blood_power_aura); + + void RecalculateHook(AuraEffect const* /*aurEffect*/, int32& amount, bool& canBeRecalculated) + { + amount = int32(GetUnitOwner()->GetPower(POWER_ENERGY)); + canBeRecalculated = true; + } + + void Register() override + { + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_deathbringer_blood_power_aura::RecalculateHook, EFFECT_0, SPELL_AURA_MOD_SCALE); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_deathbringer_blood_power_aura::RecalculateHook, EFFECT_1, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE); + } +}; + +class spell_deathbringer_blood_nova_targeting : public SpellScript +{ + PrepareSpellScript(spell_deathbringer_blood_nova_targeting); + + bool Load() override + { + // initialize variable + _target = nullptr; + return true; + } + + void FilterTargetsInitial(std::list& targets) + { + // select one random target, with preference of ranged targets + uint32 targetsAtRange = 0; + uint32 const minTargets = uint32(GetCaster()->GetMap()->GetSpawnMode() & 1 ? 10 : 4); + targets.sort(Acore::ObjectDistanceOrderPred(GetCaster(), false)); + + // get target count at range + for (std::list::iterator itr = targets.begin(); itr != targets.end(); ++itr, ++targetsAtRange) + if ((*itr)->GetDistance(GetCaster()) < 12.0f) + break; + + // set the upper cap + if (targetsAtRange < minTargets) + targetsAtRange = std::min(targets.size(), minTargets); + + if (!targetsAtRange) return; - } - void Register() override - { - DoCheckProc += AuraCheckProcFn(spell_deathbringer_blood_link_AuraScript::CheckProc); - OnEffectProc += AuraEffectProcFn(spell_deathbringer_blood_link_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL); - OnEffectPeriodic += AuraEffectPeriodicFn(spell_deathbringer_blood_link_AuraScript::HandlePeriodicTick, EFFECT_1, SPELL_AURA_PERIODIC_DUMMY); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_deathbringer_blood_link_AuraScript(); + std::list::iterator itrTarget = targets.begin(); + std::advance(itrTarget, urand(0, targetsAtRange - 1)); + _target = *itrTarget; + targets.clear(); + targets.push_back(_target); } -}; -class spell_deathbringer_blood_link_blood_beast_aura : public SpellScriptLoader -{ -public: - spell_deathbringer_blood_link_blood_beast_aura() : SpellScriptLoader("spell_deathbringer_blood_link_blood_beast_aura") { } - - class spell_deathbringer_blood_link_blood_beast_aura_AuraScript : public AuraScript + // use the same target for first and second effect + void FilterTargetsSubsequent(std::list& targets) { - PrepareAuraScript(spell_deathbringer_blood_link_blood_beast_aura_AuraScript); - - bool CheckProc(ProcEventInfo& eventInfo) - { - DamageInfo* damageInfo = eventInfo.GetDamageInfo(); - SpellInfo const* procSpell = eventInfo.GetSpellInfo(); - return eventInfo.GetActor() && eventInfo.GetActionTarget() && ((damageInfo && damageInfo->GetDamage()) || eventInfo.GetHitMask() & PROC_EX_ABSORB) && (!procSpell || procSpell->SpellIconID != 2731); // Xinef: Mark of the Fallen Champion - } - - void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo) - { - PreventDefaultAction(); - - /* - uint32 markCount = 0; - if (Map* map = eventInfo.GetActor()->FindMap()) - if (InstanceMap* imap = map->ToInstanceMap()) - if (InstanceScript* isc = imap->GetInstanceScript()) - if (ObjectGuid sguid = isc->GetGuidData(3) //DATA_DEATHBRINGER_SAURFANG - if (Creature* saurfang = ObjectAccessor::GetCreature(*eventInfo.GetActor(), sguid)) - markCount = saurfang->IsAIEnabled ? saurfang->AI()->GetData(123456) : 0; //FALLEN_CHAMPION_CAST_COUNT - */ - int32 basepoints = int32(3.0f /*+ 0.5f + 0.5f*markCount*/); - - eventInfo.GetActor()->CastCustomSpell(SPELL_BLOOD_LINK_DUMMY, SPELLVALUE_BASE_POINT0, basepoints, eventInfo.GetActionTarget(), true); + if (!_target) return; - } - void Register() override - { - DoCheckProc += AuraCheckProcFn(spell_deathbringer_blood_link_blood_beast_aura_AuraScript::CheckProc); - OnEffectProc += AuraEffectProcFn(spell_deathbringer_blood_link_blood_beast_aura_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_deathbringer_blood_link_blood_beast_aura_AuraScript(); + targets.clear(); + targets.push_back(_target); } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_deathbringer_blood_nova_targeting::FilterTargetsInitial, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_deathbringer_blood_nova_targeting::FilterTargetsSubsequent, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY); + } + +private: + WorldObject* _target; }; -class spell_deathbringer_blood_link : public SpellScriptLoader +class spell_deathbringer_boiling_blood : public SpellScript { -public: - spell_deathbringer_blood_link() : SpellScriptLoader("spell_deathbringer_blood_link") { } + PrepareSpellScript(spell_deathbringer_boiling_blood); - class spell_deathbringer_blood_link_SpellScript : public SpellScript + bool Load() override { - PrepareSpellScript(spell_deathbringer_blood_link_SpellScript); - - void HandleDummy(SpellEffIndex /*effIndex*/) - { - GetHitUnit()->CastCustomSpell(SPELL_BLOOD_LINK_POWER, SPELLVALUE_BASE_POINT0, GetEffectValue(), GetHitUnit(), true); - if (Aura* bloodPower = GetHitUnit()->GetAura(SPELL_BLOOD_POWER)) - bloodPower->RecalculateAmountOfEffects(); - PreventHitDefaultEffect(EFFECT_0); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_deathbringer_blood_link_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_deathbringer_blood_link_SpellScript(); - } -}; - -class spell_deathbringer_blood_power : public SpellScriptLoader -{ -public: - spell_deathbringer_blood_power() : SpellScriptLoader("spell_deathbringer_blood_power") { } - - class spell_deathbringer_blood_power_SpellScript : public SpellScript - { - PrepareSpellScript(spell_deathbringer_blood_power_SpellScript); - - void ModAuraValue() - { - if (Aura* aura = GetHitAura()) - aura->RecalculateAmountOfEffects(); - } - - void Register() override - { - AfterHit += SpellHitFn(spell_deathbringer_blood_power_SpellScript::ModAuraValue); - } - }; - - class spell_deathbringer_blood_power_AuraScript : public AuraScript - { - PrepareAuraScript(spell_deathbringer_blood_power_AuraScript); - - void RecalculateHook(AuraEffect const* /*aurEffect*/, int32& amount, bool& canBeRecalculated) - { - amount = int32(GetUnitOwner()->GetPower(POWER_ENERGY)); - canBeRecalculated = true; - } - - void Register() override - { - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_deathbringer_blood_power_AuraScript::RecalculateHook, EFFECT_0, SPELL_AURA_MOD_SCALE); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_deathbringer_blood_power_AuraScript::RecalculateHook, EFFECT_1, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE); - } - - bool Load() override - { - if (GetUnitOwner()->getPowerType() != POWER_ENERGY) - return false; - return true; - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_deathbringer_blood_power_SpellScript(); + return GetCaster()->GetTypeId() == TYPEID_UNIT; } - AuraScript* GetAuraScript() const override + void FilterTargets(std::list& targets) { - return new spell_deathbringer_blood_power_AuraScript(); - } -}; + targets.remove(GetCaster()->GetVictim()); + if (targets.empty()) + return; -class spell_deathbringer_blood_nova_targeting : public SpellScriptLoader -{ -public: - spell_deathbringer_blood_nova_targeting() : SpellScriptLoader("spell_deathbringer_blood_nova_targeting") { } - - class spell_deathbringer_blood_nova_targeting_SpellScript : public SpellScript - { - PrepareSpellScript(spell_deathbringer_blood_nova_targeting_SpellScript); - - bool Load() override + if (GetSpellInfo()->Id == 72385 || GetSpellInfo()->Id == 72442) // 10n, 10h { - // initialize variable - target = nullptr; - return true; - } - - void FilterTargetsInitial(std::list& targets) - { - // select one random target, with preference of ranged targets - uint32 targetsAtRange = 0; - uint32 const minTargets = uint32(GetCaster()->GetMap()->GetSpawnMode() & 1 ? 10 : 4); - targets.sort(Acore::ObjectDistanceOrderPred(GetCaster(), false)); - - // get target count at range - for (std::list::iterator itr = targets.begin(); itr != targets.end(); ++itr, ++targetsAtRange) - if ((*itr)->GetDistance(GetCaster()) < 12.0f) - break; - - // set the upper cap - if (targetsAtRange < minTargets) - targetsAtRange = std::min(targets.size(), minTargets); - - if (!targetsAtRange) - return; - - std::list::iterator itrTarget = targets.begin(); - std::advance(itrTarget, urand(0, targetsAtRange - 1)); - target = *itrTarget; + WorldObject* target = Acore::Containers::SelectRandomContainerElement(targets); targets.clear(); targets.push_back(target); } - - // use the same target for first and second effect - void FilterTargetsSubsequent(std::list& targets) - { - if (!target) - return; - - targets.clear(); - targets.push_back(target); - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_deathbringer_blood_nova_targeting_SpellScript::FilterTargetsInitial, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_deathbringer_blood_nova_targeting_SpellScript::FilterTargetsSubsequent, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY); - } - - WorldObject* target; - }; - - SpellScript* GetSpellScript() const override - { - return new spell_deathbringer_blood_nova_targeting_SpellScript(); + else + Acore::Containers::RandomResize(targets, 3); } -}; -class spell_deathbringer_boiling_blood : public SpellScriptLoader -{ -public: - spell_deathbringer_boiling_blood() : SpellScriptLoader("spell_deathbringer_boiling_blood") { } - - class spell_deathbringer_boiling_blood_SpellScript : public SpellScript + void Register() override { - PrepareSpellScript(spell_deathbringer_boiling_blood_SpellScript); - - bool Load() override - { - return GetCaster()->GetTypeId() == TYPEID_UNIT; - } - - void FilterTargets(std::list& targets) - { - targets.remove(GetCaster()->GetVictim()); - if (targets.empty()) - return; - - if (GetSpellInfo()->Id == 72385 || GetSpellInfo()->Id == 72442) // 10n, 10h - { - WorldObject* target = Acore::Containers::SelectRandomContainerElement(targets); - targets.clear(); - targets.push_back(target); - } - else - Acore::Containers::RandomResize(targets, 3); - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_deathbringer_boiling_blood_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_deathbringer_boiling_blood_SpellScript(); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_deathbringer_boiling_blood::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); } }; @@ -1412,12 +1350,12 @@ void AddSC_boss_deathbringer_saurfang() new npc_high_overlord_saurfang_icc(); new npc_muradin_bronzebeard_icc(); new npc_saurfang_event(); - new spell_deathbringer_blood_link_aura(); - new spell_deathbringer_blood_link_blood_beast_aura(); - new spell_deathbringer_blood_link(); - new spell_deathbringer_blood_power(); - new spell_deathbringer_blood_nova_targeting(); - new spell_deathbringer_boiling_blood(); + RegisterSpellScript(spell_deathbringer_blood_link_aura); + RegisterSpellScript(spell_deathbringer_blood_link_blood_beast_aura); + RegisterSpellScript(spell_deathbringer_blood_link); + RegisterSpellAndAuraScriptPair(spell_deathbringer_blood_power, spell_deathbringer_blood_power_aura); + RegisterSpellScript(spell_deathbringer_blood_nova_targeting); + RegisterSpellScript(spell_deathbringer_boiling_blood); new achievement_ive_gone_and_made_a_mess(); new npc_icc_blood_beast(); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp index 0bd29e02c..de01ce804 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp @@ -284,128 +284,95 @@ public: } }; -class spell_festergut_pungent_blight : public SpellScriptLoader +class spell_festergut_pungent_blight : public SpellScript { -public: - spell_festergut_pungent_blight() : SpellScriptLoader("spell_festergut_pungent_blight") { } + PrepareSpellScript(spell_festergut_pungent_blight); - class spell_festergut_pungent_blight_SpellScript : public SpellScript + bool Load() override { - PrepareSpellScript(spell_festergut_pungent_blight_SpellScript); + return GetCaster()->GetTypeId() == TYPEID_UNIT; + } - bool Load() override - { - return GetCaster()->GetTypeId() == TYPEID_UNIT; - } - - void HandleScript(SpellEffIndex /*effIndex*/) - { - Unit* caster = GetCaster(); - if (caster->GetTypeId() != TYPEID_UNIT) - return; - - // Get Inhaled Blight id for our difficulty - uint32 blightId = sSpellMgr->GetSpellIdForDifficulty(uint32(GetEffectValue()), caster); - - // ...and remove it - caster->RemoveAurasDueToSpell(blightId); - caster->ToCreature()->AI()->Talk(EMOTE_PUNGENT_BLIGHT); - - if (InstanceScript* inst = caster->GetInstanceScript()) - if (Creature* professor = ObjectAccessor::GetCreature(*caster, inst->GetGuidData(DATA_PROFESSOR_PUTRICIDE))) - professor->AI()->DoAction(ACTION_FESTERGUT_GAS); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_festergut_pungent_blight_SpellScript::HandleScript, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void HandleScript(SpellEffIndex /*effIndex*/) { - return new spell_festergut_pungent_blight_SpellScript(); + Unit* caster = GetCaster(); + if (caster->GetTypeId() != TYPEID_UNIT) + return; + + // Get Inhaled Blight id for our difficulty + uint32 blightId = sSpellMgr->GetSpellIdForDifficulty(uint32(GetEffectValue()), caster); + + // ...and remove it + caster->RemoveAurasDueToSpell(blightId); + caster->ToCreature()->AI()->Talk(EMOTE_PUNGENT_BLIGHT); + + if (InstanceScript* inst = caster->GetInstanceScript()) + if (Creature* professor = ObjectAccessor::GetCreature(*caster, inst->GetGuidData(DATA_PROFESSOR_PUTRICIDE))) + professor->AI()->DoAction(ACTION_FESTERGUT_GAS); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_festergut_pungent_blight::HandleScript, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT); } }; -class spell_festergut_blighted_spores : public SpellScriptLoader +class spell_festergut_blighted_spores_aura : public AuraScript { -public: - spell_festergut_blighted_spores() : SpellScriptLoader("spell_festergut_blighted_spores") { } + PrepareAuraScript(spell_festergut_blighted_spores_aura); - class spell_festergut_blighted_spores_AuraScript : public AuraScript + bool Validate(SpellInfo const* /*spell*/) override { - PrepareAuraScript(spell_festergut_blighted_spores_AuraScript); + return ValidateSpellInfo({ SPELL_INOCULATED }); + } - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_INOCULATED }); - } - - void ExtraEffect(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) - { - if (Aura* a = aurEff->GetBase()) - if (a->GetDuration() > a->GetMaxDuration() - 1000) // this does not stack for different casters and previous is removed by new DoT, prevent it from giving inoculation in such case - return; - uint32 inoculatedId = sSpellMgr->GetSpellIdForDifficulty(SPELL_INOCULATED, GetTarget()); - uint8 inoculatedStack = 1; - if (Aura* a = GetTarget()->GetAura(inoculatedId)) - { - inoculatedStack += a->GetStackAmount(); - if (a->GetDuration() > a->GetMaxDuration() - 10000) // player may gain only one stack at a time, no matter how many spores explode near him - return; - } - GetTarget()->CastSpell(GetTarget(), SPELL_INOCULATED, true); - if (InstanceScript* instance = GetTarget()->GetInstanceScript()) - if (Creature* festergut = ObjectAccessor::GetCreature(*GetTarget(), instance->GetGuidData(DATA_FESTERGUT))) - festergut->AI()->SetData(DATA_INOCULATED_STACK, inoculatedStack); - } - - void Register() override - { - AfterEffectRemove += AuraEffectRemoveFn(spell_festergut_blighted_spores_AuraScript::ExtraEffect, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAL); - } - }; - - AuraScript* GetAuraScript() const override + void ExtraEffect(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) { - return new spell_festergut_blighted_spores_AuraScript(); + if (Aura* a = aurEff->GetBase()) + if (a->GetDuration() > a->GetMaxDuration() - 1000) // this does not stack for different casters and previous is removed by new DoT, prevent it from giving inoculation in such case + return; + uint32 inoculatedId = sSpellMgr->GetSpellIdForDifficulty(SPELL_INOCULATED, GetTarget()); + uint8 inoculatedStack = 1; + if (Aura* a = GetTarget()->GetAura(inoculatedId)) + { + inoculatedStack += a->GetStackAmount(); + if (a->GetDuration() > a->GetMaxDuration() - 10000) // player may gain only one stack at a time, no matter how many spores explode near him + return; + } + GetTarget()->CastSpell(GetTarget(), SPELL_INOCULATED, true); + if (InstanceScript* instance = GetTarget()->GetInstanceScript()) + if (Creature* festergut = ObjectAccessor::GetCreature(*GetTarget(), instance->GetGuidData(DATA_FESTERGUT))) + festergut->AI()->SetData(DATA_INOCULATED_STACK, inoculatedStack); + } + + void Register() override + { + AfterEffectRemove += AuraEffectRemoveFn(spell_festergut_blighted_spores_aura::ExtraEffect, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAL); } }; -class spell_festergut_gastric_bloat : public SpellScriptLoader +class spell_festergut_gastric_bloat : public SpellScript { -public: - spell_festergut_gastric_bloat() : SpellScriptLoader("spell_festergut_gastric_bloat") { } + PrepareSpellScript(spell_festergut_gastric_bloat); - class spell_festergut_gastric_bloat_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spell*/) override { - PrepareSpellScript(spell_festergut_gastric_bloat_SpellScript); + return ValidateSpellInfo({ SPELL_GASTRIC_EXPLOSION }); + } - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_GASTRIC_EXPLOSION }); - } - - void HandleScript(SpellEffIndex /*effIndex*/) - { - Aura const* aura = GetHitUnit()->GetAura(GetSpellInfo()->Id); - if (!(aura && aura->GetStackAmount() == 10)) - return; - - GetHitUnit()->RemoveAurasDueToSpell(GetSpellInfo()->Id); - GetHitUnit()->CastSpell(GetHitUnit(), SPELL_GASTRIC_EXPLOSION, true); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_festergut_gastric_bloat_SpellScript::HandleScript, EFFECT_2, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void HandleScript(SpellEffIndex /*effIndex*/) { - return new spell_festergut_gastric_bloat_SpellScript(); + Aura const* aura = GetHitUnit()->GetAura(GetSpellInfo()->Id); + if (!(aura && aura->GetStackAmount() == 10)) + return; + + GetHitUnit()->RemoveAurasDueToSpell(GetSpellInfo()->Id); + GetHitUnit()->CastSpell(GetHitUnit(), SPELL_GASTRIC_EXPLOSION, true); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_festergut_gastric_bloat::HandleScript, EFFECT_2, SPELL_EFFECT_SCRIPT_EFFECT); } }; @@ -496,9 +463,9 @@ public: void AddSC_boss_festergut() { new boss_festergut(); - new spell_festergut_pungent_blight(); - new spell_festergut_blighted_spores(); - new spell_festergut_gastric_bloat(); + RegisterSpellScript(spell_festergut_pungent_blight); + RegisterSpellScript(spell_festergut_blighted_spores_aura); + RegisterSpellScript(spell_festergut_gastric_bloat); new achievement_flu_shot_shortage(); new npc_stinky_icc(); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp index 51bf4d127..5edeaa542 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp @@ -1974,254 +1974,195 @@ public: } }; -class spell_igb_rocket_pack : public SpellScriptLoader +class spell_igb_rocket_pack_aura : public AuraScript { -public: - spell_igb_rocket_pack() : SpellScriptLoader("spell_igb_rocket_pack") { } + PrepareAuraScript(spell_igb_rocket_pack_aura); - class spell_igb_rocket_pack_AuraScript : public AuraScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareAuraScript(spell_igb_rocket_pack_AuraScript); + return ValidateSpellInfo( + { + SPELL_ROCKET_PACK_DAMAGE, + SPELL_ROCKET_BURST + }); + } - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo( - { - SPELL_ROCKET_PACK_DAMAGE, - SPELL_ROCKET_BURST - }); - } - - void HandlePeriodic(AuraEffect const* /*aurEff*/) - { - if (GetTarget()->movespline->Finalized()) - Remove(AURA_REMOVE_BY_EXPIRE); - } - - void HandleRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) - { - SpellInfo const* damageInfo = sSpellMgr->AssertSpellInfo(SPELL_ROCKET_PACK_DAMAGE); - GetTarget()->CastCustomSpell(SPELL_ROCKET_PACK_DAMAGE, SPELLVALUE_BASE_POINT0, 2 * (damageInfo->Effects[EFFECT_0].CalcValue() + aurEff->GetTickNumber() * aurEff->GetAmplitude()), nullptr, true); - GetTarget()->CastSpell((Unit*)nullptr, SPELL_ROCKET_BURST, true); - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_igb_rocket_pack_AuraScript::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); - OnEffectRemove += AuraEffectRemoveFn(spell_igb_rocket_pack_AuraScript::HandleRemove, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL); - } - }; - - AuraScript* GetAuraScript() const override + void HandlePeriodic(AuraEffect const* /*aurEff*/) { - return new spell_igb_rocket_pack_AuraScript(); + if (GetTarget()->movespline->Finalized()) + Remove(AURA_REMOVE_BY_EXPIRE); + } + + void HandleRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) + { + SpellInfo const* damageInfo = sSpellMgr->AssertSpellInfo(SPELL_ROCKET_PACK_DAMAGE); + GetTarget()->CastCustomSpell(SPELL_ROCKET_PACK_DAMAGE, SPELLVALUE_BASE_POINT0, 2 * (damageInfo->Effects[EFFECT_0].CalcValue() + aurEff->GetTickNumber() * aurEff->GetAmplitude()), nullptr, true); + GetTarget()->CastSpell((Unit*)nullptr, SPELL_ROCKET_BURST, true); + } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_igb_rocket_pack_aura::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); + OnEffectRemove += AuraEffectRemoveFn(spell_igb_rocket_pack_aura::HandleRemove, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL); } }; -class spell_igb_rocket_pack_useable : public SpellScriptLoader +class spell_igb_rocket_pack_useable_aura : public AuraScript { -public: - spell_igb_rocket_pack_useable() : SpellScriptLoader("spell_igb_rocket_pack_useable") { } + PrepareAuraScript(spell_igb_rocket_pack_useable_aura); - class spell_igb_rocket_pack_useable_AuraScript : public AuraScript + bool Load() override { - PrepareAuraScript(spell_igb_rocket_pack_useable_AuraScript); + return GetOwner()->GetInstanceScript(); + } - bool Load() override - { - return GetOwner()->GetInstanceScript(); - } - - bool CheckAreaTarget(Unit* target) - { - return target->GetTypeId() == TYPEID_PLAYER && GetOwner()->GetInstanceScript()->GetBossState(DATA_ICECROWN_GUNSHIP_BATTLE) != DONE; - } - - void HandleApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (Creature* owner = GetOwner()->ToCreature()) - if (Player* target = GetTarget()->ToPlayer()) - if (target->HasItemCount(ITEM_GOBLIN_ROCKET_PACK, 1)) - sCreatureTextMgr->SendChat(owner, SAY_ZAFOD_ROCKET_PACK_ACTIVE, target, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, TEAM_NEUTRAL, false, target); - } - - void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (Creature* owner = GetOwner()->ToCreature()) - if (Player* target = GetTarget()->ToPlayer()) - if (target->HasItemCount(ITEM_GOBLIN_ROCKET_PACK, 1)) - sCreatureTextMgr->SendChat(owner, SAY_ZAFOD_ROCKET_PACK_DISABLED, target, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, TEAM_NEUTRAL, false, target); - } - - void Register() override - { - DoCheckAreaTarget += AuraCheckAreaTargetFn(spell_igb_rocket_pack_useable_AuraScript::CheckAreaTarget); - AfterEffectApply += AuraEffectApplyFn(spell_igb_rocket_pack_useable_AuraScript::HandleApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - AfterEffectRemove += AuraEffectRemoveFn(spell_igb_rocket_pack_useable_AuraScript::HandleRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - } - }; - - AuraScript* GetAuraScript() const override + bool CheckAreaTarget(Unit* target) { - return new spell_igb_rocket_pack_useable_AuraScript(); + return target->GetTypeId() == TYPEID_PLAYER && GetOwner()->GetInstanceScript()->GetBossState(DATA_ICECROWN_GUNSHIP_BATTLE) != DONE; + } + + void HandleApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (Creature* owner = GetOwner()->ToCreature()) + if (Player* target = GetTarget()->ToPlayer()) + if (target->HasItemCount(ITEM_GOBLIN_ROCKET_PACK, 1)) + sCreatureTextMgr->SendChat(owner, SAY_ZAFOD_ROCKET_PACK_ACTIVE, target, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, TEAM_NEUTRAL, false, target); + } + + void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (Creature* owner = GetOwner()->ToCreature()) + if (Player* target = GetTarget()->ToPlayer()) + if (target->HasItemCount(ITEM_GOBLIN_ROCKET_PACK, 1)) + sCreatureTextMgr->SendChat(owner, SAY_ZAFOD_ROCKET_PACK_DISABLED, target, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, TEAM_NEUTRAL, false, target); + } + + void Register() override + { + DoCheckAreaTarget += AuraCheckAreaTargetFn(spell_igb_rocket_pack_useable_aura::CheckAreaTarget); + AfterEffectApply += AuraEffectApplyFn(spell_igb_rocket_pack_useable_aura::HandleApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + AfterEffectRemove += AuraEffectRemoveFn(spell_igb_rocket_pack_useable_aura::HandleRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); } }; -class spell_igb_teleport_to_enemy_ship : public SpellScriptLoader +class spell_igb_teleport_to_enemy_ship : public SpellScript { -public: - spell_igb_teleport_to_enemy_ship() : SpellScriptLoader("spell_igb_teleport_to_enemy_ship") { } + PrepareSpellScript(spell_igb_teleport_to_enemy_ship); - class spell_igb_teleport_to_enemy_ship_SpellScript : public SpellScript + void RelocateTransportOffset(SpellEffIndex /*effIndex*/) { - PrepareSpellScript(spell_igb_teleport_to_enemy_ship_SpellScript); + WorldLocation const* dest = GetHitDest(); + Unit* target = GetHitUnit(); + if (!dest || !target || !target->GetTransport()) + return; - void RelocateTransportOffset(SpellEffIndex /*effIndex*/) - { - WorldLocation const* dest = GetHitDest(); - Unit* target = GetHitUnit(); - if (!dest || !target || !target->GetTransport()) - return; + float x, y, z, o; + dest->GetPosition(x, y, z, o); + target->GetTransport()->CalculatePassengerOffset(x, y, z, &o); + target->m_movementInfo.transport.pos.Relocate(x, y, z, o); + } - float x, y, z, o; - dest->GetPosition(x, y, z, o); - target->GetTransport()->CalculatePassengerOffset(x, y, z, &o); - target->m_movementInfo.transport.pos.Relocate(x, y, z, o); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_igb_teleport_to_enemy_ship_SpellScript::RelocateTransportOffset, EFFECT_0, SPELL_EFFECT_TELEPORT_UNITS); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_igb_teleport_to_enemy_ship_SpellScript(); + OnEffectHitTarget += SpellEffectFn(spell_igb_teleport_to_enemy_ship::RelocateTransportOffset, EFFECT_0, SPELL_EFFECT_TELEPORT_UNITS); } }; -class spell_igb_check_for_players : public SpellScriptLoader +class spell_igb_check_for_players : public SpellScript { -public: - spell_igb_check_for_players() : SpellScriptLoader("spell_igb_check_for_players") { } + PrepareSpellScript(spell_igb_check_for_players); - class spell_igb_check_for_players_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareSpellScript(spell_igb_check_for_players_SpellScript); + return ValidateSpellInfo({ SPELL_GUNSHIP_FALL_TELEPORT }); + } - bool Load() override - { - _playerCount = 0; - return GetCaster()->GetTypeId() == TYPEID_UNIT; - } - - void CountTargets(std::list& targets) - { - _playerCount = targets.size(); - } - - void TriggerWipe() - { - if (!_playerCount) - GetCaster()->ToCreature()->AI()->JustDied(nullptr); - } - - void TeleportPlayer(SpellEffIndex /*effIndex*/) - { - if (GetHitUnit()->GetPositionZ() < GetCaster()->GetPositionZ() - 10.0f) - GetHitUnit()->CastSpell(GetHitUnit(), SPELL_GUNSHIP_FALL_TELEPORT, true); - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_igb_check_for_players_SpellScript::CountTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); - AfterCast += SpellCastFn(spell_igb_check_for_players_SpellScript::TriggerWipe); - OnEffectHitTarget += SpellEffectFn(spell_igb_check_for_players_SpellScript::TeleportPlayer, EFFECT_0, SPELL_EFFECT_DUMMY); - } - - uint32 _playerCount; - }; - - SpellScript* GetSpellScript() const override + bool Load() override { - return new spell_igb_check_for_players_SpellScript(); + _playerCount = 0; + return GetCaster()->GetTypeId() == TYPEID_UNIT; + } + + void CountTargets(std::list& targets) + { + _playerCount = targets.size(); + } + + void TriggerWipe() + { + if (!_playerCount) + GetCaster()->ToCreature()->AI()->JustDied(nullptr); + } + + void TeleportPlayer(SpellEffIndex /*effIndex*/) + { + if (GetHitUnit()->GetPositionZ() < GetCaster()->GetPositionZ() - 10.0f) + GetHitUnit()->CastSpell(GetHitUnit(), SPELL_GUNSHIP_FALL_TELEPORT, true); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_igb_check_for_players::CountTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); + AfterCast += SpellCastFn(spell_igb_check_for_players::TriggerWipe); + OnEffectHitTarget += SpellEffectFn(spell_igb_check_for_players::TeleportPlayer, EFFECT_0, SPELL_EFFECT_DUMMY); + } + +private: + uint32 _playerCount; +}; + +class spell_igb_gunship_fall_teleport : public SpellScript +{ + PrepareSpellScript(spell_igb_gunship_fall_teleport); + + bool Load() override + { + return GetCaster()->GetInstanceScript(); + } + + void SelectTransport(WorldObject*& target) + { + if (InstanceScript* instance = target->GetInstanceScript()) + target = instance->instance->GetTransport(instance->GetGuidData(DATA_ICECROWN_GUNSHIP_BATTLE)); + } + + void RelocateDest(SpellEffIndex /*effIndex*/) + { + Position offset = {0.0f, 0.0f, 0.0f, 0.0f}; + offset.m_positionZ = GetCaster()->GetInstanceScript()->GetData(DATA_TEAMID_IN_INSTANCE) == TEAM_HORDE ? 36.0f : 21.0f; + GetHitDest()->RelocateOffset(offset); + } + + void Register() override + { + OnObjectTargetSelect += SpellObjectTargetSelectFn(spell_igb_gunship_fall_teleport::SelectTransport, EFFECT_0, TARGET_DEST_NEARBY_ENTRY); + OnEffectLaunch += SpellEffectFn(spell_igb_gunship_fall_teleport::RelocateDest, EFFECT_0, SPELL_EFFECT_TELEPORT_UNITS); } }; -class spell_igb_gunship_fall_teleport : public SpellScriptLoader +class spell_igb_explosion_main_aura : public AuraScript { -public: - spell_igb_gunship_fall_teleport() : SpellScriptLoader("spell_igb_gunship_fall_teleport") { } + PrepareAuraScript(spell_igb_explosion_main_aura); - class spell_igb_gunship_fall_teleport_SpellScript : public SpellScript + bool Load() override { - PrepareSpellScript(spell_igb_gunship_fall_teleport_SpellScript); - - bool Load() override - { - return GetCaster()->GetInstanceScript(); - } - - void SelectTransport(WorldObject*& target) - { - if (InstanceScript* instance = target->GetInstanceScript()) - target = instance->instance->GetTransport(instance->GetGuidData(DATA_ICECROWN_GUNSHIP_BATTLE)); - } - - void RelocateDest(SpellEffIndex /*effIndex*/) - { - Position offset = {0.0f, 0.0f, 0.0f, 0.0f}; - offset.m_positionZ = GetCaster()->GetInstanceScript()->GetData(DATA_TEAMID_IN_INSTANCE) == TEAM_HORDE ? 36.0f : 21.0f; - GetHitDest()->RelocateOffset(offset); - } - - void Register() override - { - OnObjectTargetSelect += SpellObjectTargetSelectFn(spell_igb_gunship_fall_teleport_SpellScript::SelectTransport, EFFECT_0, TARGET_DEST_NEARBY_ENTRY); - OnEffectLaunch += SpellEffectFn(spell_igb_gunship_fall_teleport_SpellScript::RelocateDest, EFFECT_0, SPELL_EFFECT_TELEPORT_UNITS); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_igb_gunship_fall_teleport_SpellScript(); + _tickNo = urand(0, 3); + return true; } -}; -class spell_igb_explosion_main : public SpellScriptLoader -{ -public: - spell_igb_explosion_main() : SpellScriptLoader("spell_igb_explosion_main") { } - - class spell_igb_explosion_main_AuraScript : public AuraScript + void PeriodicTick(AuraEffect const* aurEff) { - PrepareAuraScript(spell_igb_explosion_main_AuraScript); - - bool Load() override - { - tickNo = urand(0, 3); - return true; - } - - void PeriodicTick(AuraEffect const* aurEff) - { - if ((aurEff->GetTickNumber() % 4) != tickNo) - PreventDefaultAction(); - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_igb_explosion_main_AuraScript::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); - } - - uint32 tickNo; - }; - - AuraScript* GetAuraScript() const override - { - return new spell_igb_explosion_main_AuraScript(); + if ((aurEff->GetTickNumber() % 4) != _tickNo) + PreventDefaultAction(); } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_igb_explosion_main_aura::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + } + +private: + uint32 _tickNo; }; class IgbExplosionCheck @@ -2238,30 +2179,19 @@ private: Unit* _source; }; -class spell_igb_explosion : public SpellScriptLoader +class spell_igb_explosion : public SpellScript { -public: - spell_igb_explosion() : SpellScriptLoader("spell_igb_explosion") { } + PrepareSpellScript(spell_igb_explosion); - class spell_igb_explosion_SpellScript : public SpellScript + void SelectTarget(std::list& targets) { - PrepareSpellScript(spell_igb_explosion_SpellScript); + targets.remove_if(IgbExplosionCheck(GetCaster())); + Acore::Containers::RandomResize(targets, 1); + } - void SelectTarget(std::list& targets) - { - targets.remove_if(IgbExplosionCheck(GetCaster())); - Acore::Containers::RandomResize(targets, 1); - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_igb_explosion_SpellScript::SelectTarget, EFFECT_0, TARGET_UNIT_DEST_AREA_ENTRY); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_igb_explosion_SpellScript(); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_igb_explosion::SelectTarget, EFFECT_0, TARGET_UNIT_DEST_AREA_ENTRY); } }; @@ -2279,234 +2209,185 @@ private: InstanceScript* _inst; }; -class spell_igb_teleport_players_on_victory : public SpellScriptLoader +class spell_igb_teleport_players_on_victory : public SpellScript { -public: - spell_igb_teleport_players_on_victory() : SpellScriptLoader("spell_igb_teleport_players_on_victory") { } + PrepareSpellScript(spell_igb_teleport_players_on_victory); - class spell_igb_teleport_players_on_victory_SpellScript : public SpellScript + bool Load() override { - PrepareSpellScript(spell_igb_teleport_players_on_victory_SpellScript); + return GetCaster()->GetInstanceScript(); + } - bool Load() override - { - return GetCaster()->GetInstanceScript(); - } - - void FilterTargets(std::list& targets) - { - InstanceScript* instance = GetCaster()->GetInstanceScript(); - targets.remove_if(IgbTeleportOnVictoryCheck(instance)); - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_igb_teleport_players_on_victory_SpellScript::FilterTargets, EFFECT_1, TARGET_UNIT_DEST_AREA_ENTRY); - } - }; - - SpellScript* GetSpellScript() const override + void FilterTargets(std::list& targets) { - return new spell_igb_teleport_players_on_victory_SpellScript(); + InstanceScript* instance = GetCaster()->GetInstanceScript(); + targets.remove_if(IgbTeleportOnVictoryCheck(instance)); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_igb_teleport_players_on_victory::FilterTargets, EFFECT_1, TARGET_UNIT_DEST_AREA_ENTRY); } }; -class spell_igb_periodic_trigger_with_power_cost : public SpellScriptLoader +class spell_igb_periodic_trigger_with_power_cost_aura : public AuraScript { -public: - spell_igb_periodic_trigger_with_power_cost() : SpellScriptLoader("spell_igb_periodic_trigger_with_power_cost") { } + PrepareAuraScript(spell_igb_periodic_trigger_with_power_cost_aura); - class spell_igb_periodic_trigger_with_power_cost_AuraScript : public AuraScript + void HandlePeriodicTick(AuraEffect const* /*aurEff*/) { - PrepareAuraScript(spell_igb_periodic_trigger_with_power_cost_AuraScript); + PreventDefaultAction(); + GetTarget()->CastSpell(GetTarget(), GetSpellInfo()->Effects[EFFECT_0].TriggerSpell, TriggerCastFlags(TRIGGERED_FULL_MASK & ~TRIGGERED_IGNORE_POWER_AND_REAGENT_COST)); + } - void HandlePeriodicTick(AuraEffect const* /*aurEff*/) - { - PreventDefaultAction(); - GetTarget()->CastSpell(GetTarget(), GetSpellInfo()->Effects[EFFECT_0].TriggerSpell, TriggerCastFlags(TRIGGERED_FULL_MASK & ~TRIGGERED_IGNORE_POWER_AND_REAGENT_COST)); - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_igb_periodic_trigger_with_power_cost_AuraScript::HandlePeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); - } - }; - - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_igb_periodic_trigger_with_power_cost_AuraScript(); + OnEffectPeriodic += AuraEffectPeriodicFn(spell_igb_periodic_trigger_with_power_cost_aura::HandlePeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); } }; -class spell_igb_overheat : public SpellScriptLoader +class spell_igb_overheat_aura : public AuraScript { -public: - spell_igb_overheat() : SpellScriptLoader("spell_igb_overheat") { } + PrepareAuraScript(spell_igb_overheat_aura); - class spell_igb_overheat_AuraScript : public AuraScript + bool Load() override { - PrepareAuraScript(spell_igb_overheat_AuraScript); + if (GetAura()->GetType() != UNIT_AURA_TYPE) + return false; + return GetUnitOwner()->IsVehicle(); + } - bool Load() override + void SendClientControl(uint8 value) + { + if (Vehicle* vehicle = GetUnitOwner()->GetVehicleKit()) { - if (GetAura()->GetType() != UNIT_AURA_TYPE) - return false; - return GetUnitOwner()->IsVehicle(); - } - - void SendClientControl(uint8 value) - { - if (Vehicle* vehicle = GetUnitOwner()->GetVehicleKit()) + if (Unit* passenger = vehicle->GetPassenger(0)) { - if (Unit* passenger = vehicle->GetPassenger(0)) + if (Player* player = passenger->ToPlayer()) { - if (Player* player = passenger->ToPlayer()) - { - WorldPacket data(SMSG_CLIENT_CONTROL_UPDATE, GetUnitOwner()->GetPackGUID().size() + 1); - data << GetUnitOwner()->GetPackGUID(); - data << uint8(value); - player->GetSession()->SendPacket(&data); - } + WorldPacket data(SMSG_CLIENT_CONTROL_UPDATE, GetUnitOwner()->GetPackGUID().size() + 1); + data << GetUnitOwner()->GetPackGUID(); + data << uint8(value); + player->GetSession()->SendPacket(&data); } } } + } - void HandleApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - SendClientControl(0); - } - - void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - SendClientControl(1); - } - - void Register() override - { - AfterEffectApply += AuraEffectApplyFn(spell_igb_overheat_AuraScript::HandleApply, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL); - AfterEffectRemove += AuraEffectRemoveFn(spell_igb_overheat_AuraScript::HandleRemove, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL); - } - }; - - AuraScript* GetAuraScript() const override + void HandleApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - return new spell_igb_overheat_AuraScript(); + SendClientControl(0); + } + + void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + SendClientControl(1); + } + + void Register() override + { + AfterEffectApply += AuraEffectApplyFn(spell_igb_overheat_aura::HandleApply, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL); + AfterEffectRemove += AuraEffectRemoveFn(spell_igb_overheat_aura::HandleRemove, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL); } }; -class spell_igb_cannon_blast : public SpellScriptLoader +class spell_igb_cannon_blast : public SpellScript { -public: - spell_igb_cannon_blast() : SpellScriptLoader("spell_igb_cannon_blast") { } + PrepareSpellScript(spell_igb_cannon_blast); - class spell_igb_cannon_blast_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareSpellScript(spell_igb_cannon_blast_SpellScript); + return ValidateSpellInfo({ SPELL_OVERHEAT }); + } - bool Load() override - { - return GetCaster()->GetTypeId() == TYPEID_UNIT; - } - - void CalculatePower() - { - Unit* caster = GetCaster(); - if (!caster) - return; - - SpellInfo const* spellInfo = GetSpellInfo(); - if (!spellInfo) - return; - - // Check if the effect is energize - if (spellInfo->Effects[EFFECT_1].Effect == SPELL_EFFECT_ENERGIZE) - { - int32 energizeAmount = spellInfo->Effects[EFFECT_1].CalcValue(caster); - - // Apply the power gain directly to the caster - caster->ModifyPower(POWER_ENERGY, energizeAmount); - } - - if (caster->GetPower(POWER_ENERGY) >= 100) - { - caster->CastSpell(caster, SPELL_OVERHEAT, true); - if (Vehicle* vehicle = caster->GetVehicleKit()) - if (Unit* passenger = vehicle->GetPassenger(0)) - sCreatureTextMgr->SendChat(caster->ToCreature(), SAY_OVERHEAT, passenger); - } - - } - - void PreventPowerGainOnHit(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - } - - void Register() override - { - OnCast += SpellCastFn(spell_igb_cannon_blast_SpellScript::CalculatePower); - OnEffectHitTarget += SpellEffectFn(spell_igb_cannon_blast_SpellScript::PreventPowerGainOnHit, EFFECT_1, SPELL_EFFECT_ENERGIZE); - - } - }; - - SpellScript* GetSpellScript() const override + bool Load() override { - return new spell_igb_cannon_blast_SpellScript(); + return GetCaster()->GetTypeId() == TYPEID_UNIT; + } + + void CalculatePower() + { + Unit* caster = GetCaster(); + if (!caster) + return; + + SpellInfo const* spellInfo = GetSpellInfo(); + if (!spellInfo) + return; + + // Check if the effect is energize + if (spellInfo->Effects[EFFECT_1].Effect == SPELL_EFFECT_ENERGIZE) + { + int32 energizeAmount = spellInfo->Effects[EFFECT_1].CalcValue(caster); + + // Apply the power gain directly to the caster + caster->ModifyPower(POWER_ENERGY, energizeAmount); + } + + if (caster->GetPower(POWER_ENERGY) >= 100) + { + caster->CastSpell(caster, SPELL_OVERHEAT, true); + if (Vehicle* vehicle = caster->GetVehicleKit()) + if (Unit* passenger = vehicle->GetPassenger(0)) + sCreatureTextMgr->SendChat(caster->ToCreature(), SAY_OVERHEAT, passenger); + } + + } + + void PreventPowerGainOnHit(SpellEffIndex effIndex) + { + PreventHitDefaultEffect(effIndex); + } + + void Register() override + { + OnCast += SpellCastFn(spell_igb_cannon_blast::CalculatePower); + OnEffectHitTarget += SpellEffectFn(spell_igb_cannon_blast::PreventPowerGainOnHit, EFFECT_1, SPELL_EFFECT_ENERGIZE); + } }; -class spell_igb_incinerating_blast : public SpellScriptLoader +class spell_igb_incinerating_blast : public SpellScript { -public: - spell_igb_incinerating_blast() : SpellScriptLoader("spell_igb_incinerating_blast") { } + PrepareSpellScript(spell_igb_incinerating_blast); - class spell_igb_incinerating_blast_SpellScript : public SpellScript + void StoreEnergy() { - PrepareSpellScript(spell_igb_incinerating_blast_SpellScript); - - void StoreEnergy() - { - _energyLeft = GetCaster()->GetPower(POWER_ENERGY) - 10; - } - - void RemoveEnergy() - { - GetCaster()->SetPower(POWER_ENERGY, 0); - } - - void CalculateDamage(SpellEffIndex /*effIndex*/) - { - PreventHitEffect(EFFECT_0); - SpellInfo const* si = sSpellMgr->GetSpellInfo(GetSpellInfo()->Effects[0].TriggerSpell); - if (!si) - return; - SpellCastTargets targets; - Position dest = GetExplTargetDest()->GetPosition(); - targets.SetDst(dest); - CustomSpellValues values; - int32 damage = si->Effects[0].CalcValue() + _energyLeft * _energyLeft * 8; - values.AddSpellMod(SPELLVALUE_BASE_POINT0, damage); - values.AddSpellMod(SPELLVALUE_BASE_POINT1, damage); - values.AddSpellMod(SPELLVALUE_BASE_POINT2, damage); - GetCaster()->CastSpell(targets, si, &values, TRIGGERED_FULL_MASK); - //SetEffectValue(GetEffectValue() + _energyLeft * _energyLeft * 8); - } - - void Register() override - { - OnCast += SpellCastFn(spell_igb_incinerating_blast_SpellScript::StoreEnergy); - AfterCast += SpellCastFn(spell_igb_incinerating_blast_SpellScript::RemoveEnergy); - OnEffectHit += SpellEffectFn(spell_igb_incinerating_blast_SpellScript::CalculateDamage, EFFECT_0, SPELL_EFFECT_TRIGGER_MISSILE); - } - - uint32 _energyLeft; - }; - - SpellScript* GetSpellScript() const override - { - return new spell_igb_incinerating_blast_SpellScript(); + _energyLeft = GetCaster()->GetPower(POWER_ENERGY) - 10; } + + void RemoveEnergy() + { + GetCaster()->SetPower(POWER_ENERGY, 0); + } + + void CalculateDamage(SpellEffIndex /*effIndex*/) + { + PreventHitEffect(EFFECT_0); + SpellInfo const* si = sSpellMgr->GetSpellInfo(GetSpellInfo()->Effects[0].TriggerSpell); + if (!si) + return; + SpellCastTargets targets; + Position dest = GetExplTargetDest()->GetPosition(); + targets.SetDst(dest); + CustomSpellValues values; + int32 damage = si->Effects[0].CalcValue() + _energyLeft * _energyLeft * 8; + values.AddSpellMod(SPELLVALUE_BASE_POINT0, damage); + values.AddSpellMod(SPELLVALUE_BASE_POINT1, damage); + values.AddSpellMod(SPELLVALUE_BASE_POINT2, damage); + GetCaster()->CastSpell(targets, si, &values, TRIGGERED_FULL_MASK); + //SetEffectValue(GetEffectValue() + _energyLeft * _energyLeft * 8); + } + + void Register() override + { + OnCast += SpellCastFn(spell_igb_incinerating_blast::StoreEnergy); + AfterCast += SpellCastFn(spell_igb_incinerating_blast::RemoveEnergy); + OnEffectHit += SpellEffectFn(spell_igb_incinerating_blast::CalculateDamage, EFFECT_0, SPELL_EFFECT_TRIGGER_MISSILE); + } + +private: + uint32 _energyLeft; }; class BurningPitchFilterCheck @@ -2525,74 +2406,57 @@ private: uint32 _entry; }; -class spell_igb_burning_pitch_selector : public SpellScriptLoader +class spell_igb_burning_pitch_selector : public SpellScript { -public: - spell_igb_burning_pitch_selector() : SpellScriptLoader("spell_igb_burning_pitch_selector") { } + PrepareSpellScript(spell_igb_burning_pitch_selector); - class spell_igb_burning_pitch_selector_SpellScript : public SpellScript + void FilterTargets(std::list& targets) { - PrepareSpellScript(spell_igb_burning_pitch_selector_SpellScript); + TeamId teamId = TEAM_HORDE; + if (InstanceScript* instance = GetCaster()->GetInstanceScript()) + teamId = TeamId(instance->GetData(DATA_TEAMID_IN_INSTANCE)); - void FilterTargets(std::list& targets) + targets.remove_if(BurningPitchFilterCheck(teamId == TEAM_HORDE ? GO_ORGRIMS_HAMMER_H : GO_THE_SKYBREAKER_A)); + if (!targets.empty()) { - TeamId teamId = TEAM_HORDE; - if (InstanceScript* instance = GetCaster()->GetInstanceScript()) - teamId = TeamId(instance->GetData(DATA_TEAMID_IN_INSTANCE)); - - targets.remove_if(BurningPitchFilterCheck(teamId == TEAM_HORDE ? GO_ORGRIMS_HAMMER_H : GO_THE_SKYBREAKER_A)); - if (!targets.empty()) - { - WorldObject* target = Acore::Containers::SelectRandomContainerElement(targets); - targets.clear(); - targets.push_back(target); - } + WorldObject* target = Acore::Containers::SelectRandomContainerElement(targets); + targets.clear(); + targets.push_back(target); } + } - void HandleDummy(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValue()), TRIGGERED_NONE); - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_igb_burning_pitch_selector_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); - OnEffectHitTarget += SpellEffectFn(spell_igb_burning_pitch_selector_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; - - SpellScript* GetSpellScript() const override + void HandleDummy(SpellEffIndex effIndex) { - return new spell_igb_burning_pitch_selector_SpellScript(); + PreventHitDefaultEffect(effIndex); + GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValue()), TRIGGERED_NONE); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_igb_burning_pitch_selector::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); + OnEffectHitTarget += SpellEffectFn(spell_igb_burning_pitch_selector::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } }; -class spell_igb_burning_pitch : public SpellScriptLoader +class spell_igb_burning_pitch : public SpellScript { -public: - spell_igb_burning_pitch() : SpellScriptLoader("spell_igb_burning_pitch") { } + PrepareSpellScript(spell_igb_burning_pitch); - class spell_igb_burning_pitch_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareSpellScript(spell_igb_burning_pitch_SpellScript); + return ValidateSpellInfo({ 8000, SPELL_BURNING_PITCH }); + } - void HandleDummy(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - GetCaster()->CastCustomSpell(uint32(GetEffectValue()), SPELLVALUE_BASE_POINT0, 8000, nullptr, TRIGGERED_FULL_MASK); - GetHitUnit()->CastSpell(GetHitUnit(), SPELL_BURNING_PITCH, TRIGGERED_FULL_MASK); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_igb_burning_pitch_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; - - SpellScript* GetSpellScript() const override + void HandleDummy(SpellEffIndex effIndex) { - return new spell_igb_burning_pitch_SpellScript(); + PreventHitDefaultEffect(effIndex); + GetCaster()->CastCustomSpell(uint32(GetEffectValue()), SPELLVALUE_BASE_POINT0, 8000, nullptr, TRIGGERED_FULL_MASK); + GetHitUnit()->CastSpell(GetHitUnit(), SPELL_BURNING_PITCH, TRIGGERED_FULL_MASK); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_igb_burning_pitch::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } }; @@ -2611,153 +2475,120 @@ private: uint32 _entry; }; -class spell_igb_rocket_artillery : public SpellScriptLoader +class spell_igb_rocket_artillery : public SpellScript { -public: - spell_igb_rocket_artillery() : SpellScriptLoader("spell_igb_rocket_artillery") { } + PrepareSpellScript(spell_igb_rocket_artillery); - class spell_igb_rocket_artillery_SpellScript : public SpellScript + void SelectRandomTarget(std::list& targets) { - PrepareSpellScript(spell_igb_rocket_artillery_SpellScript); + TeamId teamId = TEAM_HORDE; + if (InstanceScript* instance = GetCaster()->GetInstanceScript()) + teamId = TeamId(instance->GetData(DATA_TEAMID_IN_INSTANCE)); + targets.remove_if(IgbArtilleryCheck(teamId == TEAM_HORDE ? GO_ORGRIMS_HAMMER_H : GO_THE_SKYBREAKER_A)); - void SelectRandomTarget(std::list& targets) + if (!targets.empty()) { - TeamId teamId = TEAM_HORDE; - if (InstanceScript* instance = GetCaster()->GetInstanceScript()) - teamId = TeamId(instance->GetData(DATA_TEAMID_IN_INSTANCE)); - targets.remove_if(IgbArtilleryCheck(teamId == TEAM_HORDE ? GO_ORGRIMS_HAMMER_H : GO_THE_SKYBREAKER_A)); - - if (!targets.empty()) - { - WorldObject* target = Acore::Containers::SelectRandomContainerElement(targets); - targets.clear(); - targets.push_back(target); - } + WorldObject* target = Acore::Containers::SelectRandomContainerElement(targets); + targets.clear(); + targets.push_back(target); } + } - void HandleScript(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - GetCaster()->CastSpell(GetHitUnit()->GetPositionX(), GetHitUnit()->GetPositionY(), - GetHitUnit()->GetMapHeight(GetCaster()->GetPhaseMask(), GetHitUnit()->GetPositionX(), GetHitUnit()->GetPositionY(), GetHitUnit()->GetPositionZ()), - uint32(GetEffectValue()), TRIGGERED_NONE); - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_igb_rocket_artillery_SpellScript::SelectRandomTarget, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - OnEffectHitTarget += SpellEffectFn(spell_igb_rocket_artillery_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void HandleScript(SpellEffIndex effIndex) { - return new spell_igb_rocket_artillery_SpellScript(); + PreventHitDefaultEffect(effIndex); + GetCaster()->CastSpell(GetHitUnit()->GetPositionX(), GetHitUnit()->GetPositionY(), + GetHitUnit()->GetMapHeight(GetCaster()->GetPhaseMask(), GetHitUnit()->GetPositionX(), GetHitUnit()->GetPositionY(), GetHitUnit()->GetPositionZ()), + uint32(GetEffectValue()), TRIGGERED_NONE); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_igb_rocket_artillery::SelectRandomTarget, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + OnEffectHitTarget += SpellEffectFn(spell_igb_rocket_artillery::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; -class spell_igb_rocket_artillery_explosion : public SpellScriptLoader +class spell_igb_rocket_artillery_explosion : public SpellScript { -public: - spell_igb_rocket_artillery_explosion() : SpellScriptLoader("spell_igb_rocket_artillery_explosion") { } + PrepareSpellScript(spell_igb_rocket_artillery_explosion); - class spell_igb_rocket_artillery_explosion_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareSpellScript(spell_igb_rocket_artillery_explosion_SpellScript); + return ValidateSpellInfo({ SPELL_BURNING_PITCH_DAMAGE_A, SPELL_BURNING_PITCH_DAMAGE_H, 5000 }); + } - void DamageGunship(SpellEffIndex /*effIndex*/) - { - if (InstanceScript* instance = GetCaster()->GetInstanceScript()) - GetCaster()->CastCustomSpell(instance->GetData(DATA_TEAMID_IN_INSTANCE) == TEAM_HORDE ? SPELL_BURNING_PITCH_DAMAGE_A : SPELL_BURNING_PITCH_DAMAGE_H, SPELLVALUE_BASE_POINT0, 5000, nullptr, TRIGGERED_FULL_MASK); - } - - void Register() override - { - OnEffectHit += SpellEffectFn(spell_igb_rocket_artillery_explosion_SpellScript::DamageGunship, EFFECT_0, SPELL_EFFECT_TRIGGER_MISSILE); - } - }; - - SpellScript* GetSpellScript() const override + void DamageGunship(SpellEffIndex /*effIndex*/) { - return new spell_igb_rocket_artillery_explosion_SpellScript(); + if (InstanceScript* instance = GetCaster()->GetInstanceScript()) + GetCaster()->CastCustomSpell(instance->GetData(DATA_TEAMID_IN_INSTANCE) == TEAM_HORDE ? SPELL_BURNING_PITCH_DAMAGE_A : SPELL_BURNING_PITCH_DAMAGE_H, SPELLVALUE_BASE_POINT0, 5000, nullptr, TRIGGERED_FULL_MASK); + } + + void Register() override + { + OnEffectHit += SpellEffectFn(spell_igb_rocket_artillery_explosion::DamageGunship, EFFECT_0, SPELL_EFFECT_TRIGGER_MISSILE); } }; -class spell_igb_below_zero : public SpellScriptLoader +class spell_igb_below_zero : public SpellScript { -public: - spell_igb_below_zero() : SpellScriptLoader("spell_igb_below_zero") { } + PrepareSpellScript(spell_igb_below_zero); - class spell_igb_below_zero_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareSpellScript(spell_igb_below_zero_SpellScript); + return ValidateSpellInfo({ SPELL_EJECT_ALL_PASSENGERS }); + } - void RemovePassengers(SpellMissInfo missInfo) + void RemovePassengers(SpellMissInfo missInfo) + { + if (missInfo != SPELL_MISS_NONE) { - if (missInfo != SPELL_MISS_NONE) - { - return; - } - - GetHitUnit()->SetPower(POWER_ENERGY, 0); - GetHitUnit()->CastSpell(GetHitUnit(), SPELL_EJECT_ALL_PASSENGERS, TRIGGERED_FULL_MASK); + return; } - void Register() override - { - BeforeHit += BeforeSpellHitFn(spell_igb_below_zero_SpellScript::RemovePassengers); - } - }; + GetHitUnit()->SetPower(POWER_ENERGY, 0); + GetHitUnit()->CastSpell(GetHitUnit(), SPELL_EJECT_ALL_PASSENGERS, TRIGGERED_FULL_MASK); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_igb_below_zero_SpellScript(); + BeforeHit += BeforeSpellHitFn(spell_igb_below_zero::RemovePassengers); } }; -class spell_igb_on_gunship_deck : public SpellScriptLoader +class spell_igb_on_gunship_deck_aura : public AuraScript { -public: - spell_igb_on_gunship_deck() : SpellScriptLoader("spell_igb_on_gunship_deck") { } + PrepareAuraScript(spell_igb_on_gunship_deck_aura); - class spell_igb_on_gunship_deck_AuraScript : public AuraScript + bool Load() override { - PrepareAuraScript(spell_igb_on_gunship_deck_AuraScript); - - bool Load() override - { - if (InstanceScript* instance = GetOwner()->GetInstanceScript()) - _teamIdInInstance = TeamId(instance->GetData(DATA_TEAMID_IN_INSTANCE)); - else - _teamIdInInstance = TEAM_ALLIANCE; - return true; - } - - bool CheckAreaTarget(Unit* unit) - { - return unit->GetTypeId() == TYPEID_PLAYER; - } - - void HandleApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - bool enemy = GetSpellInfo()->Id == uint32(_teamIdInInstance == TEAM_HORDE ? SPELL_ON_SKYBREAKER_DECK : SPELL_ON_ORGRIMS_HAMMER_DECK); - if (Creature* gunship = GetOwner()->FindNearestCreature(_teamIdInInstance == TEAM_HORDE ? NPC_ORGRIMS_HAMMER : NPC_THE_SKYBREAKER, 200.0f)) - gunship->AI()->SetGUID(GetTarget()->GetGUID(), enemy ? ACTION_SHIP_VISITS_ENEMY : ACTION_SHIP_VISITS_SELF); - } - - void Register() override - { - DoCheckAreaTarget += AuraCheckAreaTargetFn(spell_igb_on_gunship_deck_AuraScript::CheckAreaTarget); - AfterEffectApply += AuraEffectApplyFn(spell_igb_on_gunship_deck_AuraScript::HandleApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - } - - TeamId _teamIdInInstance; - }; - - AuraScript* GetAuraScript() const override - { - return new spell_igb_on_gunship_deck_AuraScript(); + if (InstanceScript* instance = GetOwner()->GetInstanceScript()) + _teamIdInInstance = TeamId(instance->GetData(DATA_TEAMID_IN_INSTANCE)); + else + _teamIdInInstance = TEAM_ALLIANCE; + return true; } + + bool CheckAreaTarget(Unit* unit) + { + return unit->GetTypeId() == TYPEID_PLAYER; + } + + void HandleApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + bool enemy = GetSpellInfo()->Id == uint32(_teamIdInInstance == TEAM_HORDE ? SPELL_ON_SKYBREAKER_DECK : SPELL_ON_ORGRIMS_HAMMER_DECK); + if (Creature* gunship = GetOwner()->FindNearestCreature(_teamIdInInstance == TEAM_HORDE ? NPC_ORGRIMS_HAMMER : NPC_THE_SKYBREAKER, 200.0f)) + gunship->AI()->SetGUID(GetTarget()->GetGUID(), enemy ? ACTION_SHIP_VISITS_ENEMY : ACTION_SHIP_VISITS_SELF); + } + + void Register() override + { + DoCheckAreaTarget += AuraCheckAreaTargetFn(spell_igb_on_gunship_deck_aura::CheckAreaTarget); + AfterEffectApply += AuraEffectApplyFn(spell_igb_on_gunship_deck_aura::HandleApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + } + +private: + TeamId _teamIdInInstance; }; class achievement_im_on_a_boat : public AchievementCriteriaScript @@ -2799,24 +2630,24 @@ void AddSC_boss_icecrown_gunship_battle() new npc_gunship_mage(); new npc_gunship_gunner(); new npc_gunship_rocketeer(); - new spell_igb_rocket_pack(); - new spell_igb_rocket_pack_useable(); - new spell_igb_teleport_to_enemy_ship(); - new spell_igb_check_for_players(); - new spell_igb_gunship_fall_teleport(); - new spell_igb_explosion_main(); - new spell_igb_explosion(); - new spell_igb_teleport_players_on_victory(); - new spell_igb_periodic_trigger_with_power_cost(); - new spell_igb_overheat(); - new spell_igb_cannon_blast(); - new spell_igb_incinerating_blast(); - new spell_igb_burning_pitch_selector(); - new spell_igb_burning_pitch(); - new spell_igb_rocket_artillery(); - new spell_igb_rocket_artillery_explosion(); - new spell_igb_below_zero(); - new spell_igb_on_gunship_deck(); + RegisterSpellScript(spell_igb_rocket_pack_aura); + RegisterSpellScript(spell_igb_rocket_pack_useable_aura); + RegisterSpellScript(spell_igb_teleport_to_enemy_ship); + RegisterSpellScript(spell_igb_check_for_players); + RegisterSpellScript(spell_igb_gunship_fall_teleport); + RegisterSpellScript(spell_igb_explosion_main_aura); + RegisterSpellScript(spell_igb_explosion); + RegisterSpellScript(spell_igb_teleport_players_on_victory); + RegisterSpellScript(spell_igb_periodic_trigger_with_power_cost_aura); + RegisterSpellScript(spell_igb_overheat_aura); + RegisterSpellScript(spell_igb_cannon_blast); + RegisterSpellScript(spell_igb_incinerating_blast); + RegisterSpellScript(spell_igb_burning_pitch_selector); + RegisterSpellScript(spell_igb_burning_pitch); + RegisterSpellScript(spell_igb_rocket_artillery); + RegisterSpellScript(spell_igb_rocket_artillery_explosion); + RegisterSpellScript(spell_igb_below_zero); + RegisterSpellScript(spell_igb_on_gunship_deck_aura); new achievement_im_on_a_boat(); RegisterSpellScript(spell_igb_battle_experience_check); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp index cc62e50a9..4e28ec371 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp @@ -1113,35 +1113,24 @@ public: } }; -class spell_deathwhisper_mana_barrier : public SpellScriptLoader +class spell_deathwhisper_mana_barrier_aura : public AuraScript { -public: - spell_deathwhisper_mana_barrier() : SpellScriptLoader("spell_deathwhisper_mana_barrier") { } + PrepareAuraScript(spell_deathwhisper_mana_barrier_aura); - class spell_deathwhisper_mana_barrier_AuraScript : public AuraScript + void HandlePeriodicTick(AuraEffect const* /*aurEff*/) { - PrepareAuraScript(spell_deathwhisper_mana_barrier_AuraScript); - - void HandlePeriodicTick(AuraEffect const* /*aurEff*/) + PreventDefaultAction(); + if (Unit* caster = GetCaster()) { - PreventDefaultAction(); - if (Unit* caster = GetCaster()) - { - int32 missingHealth = int32(caster->GetMaxHealth() - caster->GetHealth()); - caster->ModifyHealth(missingHealth); - caster->ModifyPower(POWER_MANA, -missingHealth); - } + int32 missingHealth = int32(caster->GetMaxHealth() - caster->GetHealth()); + caster->ModifyHealth(missingHealth); + caster->ModifyPower(POWER_MANA, -missingHealth); } + } - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_deathwhisper_mana_barrier_AuraScript::HandlePeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); - } - }; - - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_deathwhisper_mana_barrier_AuraScript(); + OnEffectPeriodic += AuraEffectPeriodicFn(spell_deathwhisper_mana_barrier_aura::HandlePeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); } }; @@ -1197,7 +1186,7 @@ void AddSC_boss_lady_deathwhisper() new npc_darnavan(); // Spells - new spell_deathwhisper_mana_barrier(); + RegisterSpellScript(spell_deathwhisper_mana_barrier_aura); RegisterSpellScript(spell_deathwhisper_dark_reckoning); // AreaTriggers diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp index 3c6c04ed0..b27a314ad 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp @@ -475,229 +475,180 @@ public: } }; -class spell_marrowgar_coldflame : public SpellScriptLoader +class spell_marrowgar_coldflame : public SpellScript { -public: - spell_marrowgar_coldflame() : SpellScriptLoader("spell_marrowgar_coldflame") { } + PrepareSpellScript(spell_marrowgar_coldflame); - class spell_marrowgar_coldflame_SpellScript : public SpellScript + void SelectTarget(std::list& targets) { - PrepareSpellScript(spell_marrowgar_coldflame_SpellScript); + targets.clear(); + Unit* target = GetCaster()->GetAI()->SelectTarget(SelectTargetMethod::Random, 1, -1.0f, true,true, -SPELL_IMPALED); // -1.0f as it takes into account object size + if (!target) + target = GetCaster()->GetAI()->SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true); // if only tank or noone outside of boss' model + if (!target) + return; - void SelectTarget(std::list& targets) + targets.push_back(target); + } + + void HandleScriptEffect(SpellEffIndex /*effIndex*/) + { + Unit* caster = GetCaster(); + float angle = caster->GetAngle(GetHitUnit()); + float dist = caster->GetObjectSize() / 2.0f; + float z = caster->GetPositionZ() + 2.5f; + float nx = caster->GetPositionX() + dist * cos(angle); + float ny = caster->GetPositionY() + dist * std::sin(angle); + + if (!caster->IsWithinLOS(nx, ny, z)) { - targets.clear(); - Unit* target = GetCaster()->GetAI()->SelectTarget(SelectTargetMethod::Random, 1, -1.0f, true,true, -SPELL_IMPALED); // -1.0f as it takes into account object size - if (!target) - target = GetCaster()->GetAI()->SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true); // if only tank or noone outside of boss' model - if (!target) - return; - - targets.push_back(target); + nx = caster->GetPositionX() + 0.5f * cos(angle); + ny = caster->GetPositionY() + 0.5f * std::sin(angle); } - void HandleScriptEffect(SpellEffIndex /*effIndex*/) + if (caster->IsWithinLOS(nx, ny, z)) { - Unit* caster = GetCaster(); - float angle = caster->GetAngle(GetHitUnit()); - float dist = caster->GetObjectSize() / 2.0f; - float z = caster->GetPositionZ() + 2.5f; - float nx = caster->GetPositionX() + dist * cos(angle); - float ny = caster->GetPositionY() + dist * std::sin(angle); + caster->SetOrientation(angle); + caster->CastSpell(nx, ny, z, uint32(GetEffectValue()), true); + } + } - if (!caster->IsWithinLOS(nx, ny, z)) + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_marrowgar_coldflame::SelectTarget, EFFECT_0, TARGET_UNIT_DEST_AREA_ENEMY); + OnEffectHitTarget += SpellEffectFn(spell_marrowgar_coldflame::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } +}; + +class spell_marrowgar_bone_spike_graveyard : public SpellScript +{ + PrepareSpellScript(spell_marrowgar_bone_spike_graveyard); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_IMPALED }); + } + + void HandleSpikes(SpellEffIndex effIndex) + { + PreventHitDefaultEffect(effIndex); + if (Creature* marrowgar = GetCaster()->ToCreature()) + { + bool didHit = false; + CreatureAI* marrowgarAI = marrowgar->AI(); + uint8 boneSpikeCount = uint8(GetCaster()->GetMap()->GetSpawnMode() & 1 ? 3 : 1); + + std::vector validPlayers; + Map::PlayerList const& pList = marrowgar->GetMap()->GetPlayers(); + for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr) + if (Player* plr = itr->GetSource()) + if (plr->IsAlive() && !plr->IsGameMaster() && plr->GetExactDist2dSq(marrowgar) < (150.0f * 150.0f) && !plr->HasAura(SPELL_IMPALED)) + if (!marrowgar->GetVictim() || marrowgar->GetVictim()->GetGUID() != plr->GetGUID()) + if (plr->GetGUID() != marrowgarAI->GetGUID(0) && plr->GetGUID() != marrowgarAI->GetGUID(1) && plr->GetGUID() != marrowgarAI->GetGUID(2)) // not a bone slice target + validPlayers.push_back(plr); + + std::vector::iterator begin = validPlayers.begin(), end = validPlayers.end(); + + std::random_device rd; + std::shuffle(begin, end, std::default_random_engine{rd()}); + + for (uint8 i = 0; i < boneSpikeCount && i < validPlayers.size(); ++i) { - nx = caster->GetPositionX() + 0.5f * cos(angle); - ny = caster->GetPositionY() + 0.5f * std::sin(angle); + Unit* target = validPlayers[i]; + didHit = true; + //target->CastCustomSpell(boneSpikeSummonId[i], SPELLVALUE_BASE_POINT0, 0, target, true); + target->CastSpell(target, boneSpikeSummonId[i], true); } + if (didHit) + marrowgarAI->Talk(SAY_BONESPIKE); + } + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_marrowgar_bone_spike_graveyard::HandleSpikes, EFFECT_1, SPELL_EFFECT_APPLY_AURA); + } +}; + +class spell_marrowgar_coldflame_bonestorm : public SpellScript +{ + PrepareSpellScript(spell_marrowgar_coldflame_bonestorm); + + void HandleScriptEffect(SpellEffIndex effIndex) + { + PreventHitDefaultEffect(effIndex); + Unit* caster = GetCaster(); + float x = caster->GetPositionX(); + float y = caster->GetPositionY(); + float z = caster->GetPositionZ() + 2.5f; + for (uint8 i = 0; i < 4; ++i) + { + float nx = x + 2.5f * cos((M_PI / 4) + (i * (M_PI / 2))); + float ny = y + 2.5f * std::sin((M_PI / 4) + (i * (M_PI / 2))); if (caster->IsWithinLOS(nx, ny, z)) { - caster->SetOrientation(angle); - caster->CastSpell(nx, ny, z, uint32(GetEffectValue()), true); + caster->SetOrientation((M_PI / 4) + (i * (M_PI / 2))); + caster->CastSpell(nx, ny, z, uint32(GetEffectValue() + i), true); } } + } - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_marrowgar_coldflame_SpellScript::SelectTarget, EFFECT_0, TARGET_UNIT_DEST_AREA_ENEMY); - OnEffectHitTarget += SpellEffectFn(spell_marrowgar_coldflame_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_marrowgar_coldflame_SpellScript(); + OnEffectHitTarget += SpellEffectFn(spell_marrowgar_coldflame_bonestorm::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; -class spell_marrowgar_bone_spike_graveyard : public SpellScriptLoader +class spell_marrowgar_bone_storm : public SpellScript { -public: - spell_marrowgar_bone_spike_graveyard() : SpellScriptLoader("spell_marrowgar_bone_spike_graveyard") { } + PrepareSpellScript(spell_marrowgar_bone_storm); - class spell_marrowgar_bone_spike_graveyard_SpellScript : public SpellScript + void RecalculateDamage() { - PrepareSpellScript(spell_marrowgar_bone_spike_graveyard_SpellScript); + float dist = GetHitUnit()->GetExactDist2d(GetCaster()); + if (dist >= 9.0f) dist -= 9.0f; + else dist = 0.0f; + SetHitDamage(int32(GetHitDamage() / std::max(sqrtf(dist), 1.0f))); + } - void HandleSpikes(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - if (Creature* marrowgar = GetCaster()->ToCreature()) - { - bool didHit = false; - CreatureAI* marrowgarAI = marrowgar->AI(); - uint8 boneSpikeCount = uint8(GetCaster()->GetMap()->GetSpawnMode() & 1 ? 3 : 1); - - std::vector validPlayers; - Map::PlayerList const& pList = marrowgar->GetMap()->GetPlayers(); - for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr) - if (Player* plr = itr->GetSource()) - if (plr->IsAlive() && !plr->IsGameMaster() && plr->GetExactDist2dSq(marrowgar) < (150.0f * 150.0f) && !plr->HasAura(SPELL_IMPALED)) - if (!marrowgar->GetVictim() || marrowgar->GetVictim()->GetGUID() != plr->GetGUID()) - if (plr->GetGUID() != marrowgarAI->GetGUID(0) && plr->GetGUID() != marrowgarAI->GetGUID(1) && plr->GetGUID() != marrowgarAI->GetGUID(2)) // not a bone slice target - validPlayers.push_back(plr); - - std::vector::iterator begin = validPlayers.begin(), end = validPlayers.end(); - - std::random_device rd; - std::shuffle(begin, end, std::default_random_engine{rd()}); - - for (uint8 i = 0; i < boneSpikeCount && i < validPlayers.size(); ++i) - { - Unit* target = validPlayers[i]; - didHit = true; - //target->CastCustomSpell(boneSpikeSummonId[i], SPELLVALUE_BASE_POINT0, 0, target, true); - target->CastSpell(target, boneSpikeSummonId[i], true); - } - - if (didHit) - marrowgarAI->Talk(SAY_BONESPIKE); - } - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_marrowgar_bone_spike_graveyard_SpellScript::HandleSpikes, EFFECT_1, SPELL_EFFECT_APPLY_AURA); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_marrowgar_bone_spike_graveyard_SpellScript(); + OnHit += SpellHitFn(spell_marrowgar_bone_storm::RecalculateDamage); } }; -class spell_marrowgar_coldflame_bonestorm : public SpellScriptLoader +class spell_marrowgar_bone_slice : public SpellScript { -public: - spell_marrowgar_coldflame_bonestorm() : SpellScriptLoader("spell_marrowgar_coldflame_bonestorm") { } + PrepareSpellScript(spell_marrowgar_bone_slice); - class spell_marrowgar_coldflame_SpellScript : public SpellScript + bool Load() override { - PrepareSpellScript(spell_marrowgar_coldflame_SpellScript); - - void HandleScriptEffect(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - Unit* caster = GetCaster(); - float x = caster->GetPositionX(); - float y = caster->GetPositionY(); - float z = caster->GetPositionZ() + 2.5f; - for (uint8 i = 0; i < 4; ++i) - { - float nx = x + 2.5f * cos((M_PI / 4) + (i * (M_PI / 2))); - float ny = y + 2.5f * std::sin((M_PI / 4) + (i * (M_PI / 2))); - if (caster->IsWithinLOS(nx, ny, z)) - { - caster->SetOrientation((M_PI / 4) + (i * (M_PI / 2))); - caster->CastSpell(nx, ny, z, uint32(GetEffectValue() + i), true); - } - } - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_marrowgar_coldflame_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_marrowgar_coldflame_SpellScript(); + _targetCount = 0; + return true; } -}; -class spell_marrowgar_bone_storm : public SpellScriptLoader -{ -public: - spell_marrowgar_bone_storm() : SpellScriptLoader("spell_marrowgar_bone_storm") { } - - class spell_marrowgar_bone_storm_SpellScript : public SpellScript + void CountTargets(std::list& targets) { - PrepareSpellScript(spell_marrowgar_bone_storm_SpellScript); - - void RecalculateDamage() - { - float dist = GetHitUnit()->GetExactDist2d(GetCaster()); - if (dist >= 9.0f) dist -= 9.0f; - else dist = 0.0f; - SetHitDamage(int32(GetHitDamage() / std::max(sqrtf(dist), 1.0f))); - } - - void Register() override - { - OnHit += SpellHitFn(spell_marrowgar_bone_storm_SpellScript::RecalculateDamage); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_marrowgar_bone_storm_SpellScript(); + _targetCount = std::min(targets.size(), GetSpellInfo()->MaxAffectedTargets); } -}; -class spell_marrowgar_bone_slice : public SpellScriptLoader -{ -public: - spell_marrowgar_bone_slice() : SpellScriptLoader("spell_marrowgar_bone_slice") { } - - class spell_marrowgar_bone_slice_SpellScript : public SpellScript + void SplitDamage() { - PrepareSpellScript(spell_marrowgar_bone_slice_SpellScript); + if (!_targetCount) + return; // This spell can miss all targets - bool Load() override - { - _targetCount = 0; - return true; - } - - void CountTargets(std::list& targets) - { - _targetCount = std::min(targets.size(), GetSpellInfo()->MaxAffectedTargets); - } - - void SplitDamage() - { - if (!_targetCount) - return; // This spell can miss all targets - - SetHitDamage(GetHitDamage() / _targetCount); - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_marrowgar_bone_slice_SpellScript::CountTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ENEMY); - OnHit += SpellHitFn(spell_marrowgar_bone_slice_SpellScript::SplitDamage); - } - - uint32 _targetCount; - }; - - SpellScript* GetSpellScript() const override - { - return new spell_marrowgar_bone_slice_SpellScript(); + SetHitDamage(GetHitDamage() / _targetCount); } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_marrowgar_bone_slice::CountTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ENEMY); + OnHit += SpellHitFn(spell_marrowgar_bone_slice::SplitDamage); + } + +private: + uint32 _targetCount; }; void AddSC_boss_lord_marrowgar() @@ -705,10 +656,10 @@ void AddSC_boss_lord_marrowgar() RegisterIcecrownCitadelCreatureAI(boss_lord_marrowgar); new npc_coldflame(); new npc_bone_spike(); - new spell_marrowgar_coldflame(); - new spell_marrowgar_coldflame_bonestorm(); - new spell_marrowgar_bone_spike_graveyard(); - new spell_marrowgar_bone_storm(); - new spell_marrowgar_bone_slice(); + RegisterSpellScript(spell_marrowgar_coldflame); + RegisterSpellScript(spell_marrowgar_coldflame_bonestorm); + RegisterSpellScript(spell_marrowgar_bone_spike_graveyard); + RegisterSpellScript(spell_marrowgar_bone_storm); + RegisterSpellScript(spell_marrowgar_bone_slice); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp index 491d951c5..242866a20 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp @@ -873,835 +873,652 @@ public: } }; -class spell_putricide_slime_puddle : public SpellScriptLoader +class spell_putricide_slime_puddle : public SpellScript { -public: - spell_putricide_slime_puddle() : SpellScriptLoader("spell_putricide_slime_puddle") { } + PrepareSpellScript(spell_putricide_slime_puddle); - class spell_putricide_slime_puddle_SpellScript : public SpellScript + void ScaleRange(std::list& targets) { - PrepareSpellScript(spell_putricide_slime_puddle_SpellScript); + targets.remove_if(Acore::AllWorldObjectsInExactRange(GetCaster(), 2.5f * GetCaster()->GetFloatValue(OBJECT_FIELD_SCALE_X), true)); + } - void ScaleRange(std::list& targets) + // big hax to unlock Abomination Eat Ooze ability, requires caster aura spell from difficulty X, but unlocks clientside when got base aura + void HandleScript(SpellEffIndex /*effIndex*/) + { + SpellInfo const* s1 = sSpellMgr->GetSpellInfo(70346); + SpellInfo const* s2 = sSpellMgr->GetSpellInfo(72456); + if (s1 && s2) + if (Unit* target = GetHitUnit()) + { + Aura::TryRefreshStackOrCreate(s1, MAX_EFFECT_MASK, target, target); + Aura::TryRefreshStackOrCreate(s2, MAX_EFFECT_MASK, target, target); + } + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_putricide_slime_puddle::ScaleRange, EFFECT_0, TARGET_UNIT_DEST_AREA_ENEMY); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_putricide_slime_puddle::ScaleRange, EFFECT_1, TARGET_UNIT_DEST_AREA_ENTRY); + OnEffectHitTarget += SpellEffectFn(spell_putricide_slime_puddle::HandleScript, EFFECT_1, SPELL_EFFECT_APPLY_AURA); + } +}; + +class spell_putricide_slime_puddle_spawn : public SpellScript +{ + PrepareSpellScript(spell_putricide_slime_puddle_spawn); + + void SelectDest() + { + if (Position* dest = const_cast(GetExplTargetDest())) { - targets.remove_if(Acore::AllWorldObjectsInExactRange(GetCaster(), 2.5f * GetCaster()->GetFloatValue(OBJECT_FIELD_SCALE_X), true)); + float destZ = 395.0f; // random number close to ground, get exact in next call + GetCaster()->UpdateGroundPositionZ(dest->GetPositionX(), dest->GetPositionY(), destZ); + dest->m_positionZ = destZ; + } + } + + void Register() override + { + BeforeCast += SpellCastFn(spell_putricide_slime_puddle_spawn::SelectDest); + } +}; + +class spell_putricide_grow_stacker_aura : public AuraScript +{ + PrepareAuraScript(spell_putricide_grow_stacker_aura); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_TEAR_GAS_CREATURE }); + } + + void HandleTriggerSpell(AuraEffect const* /*aurEff*/) + { + if (Unit* target = GetTarget()) + if (target->HasAura(SPELL_TEAR_GAS_CREATURE)) + PreventDefaultAction(); + } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_putricide_grow_stacker_aura::HandleTriggerSpell, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + } +}; + +class spell_putricide_unstable_experiment : public SpellScript +{ + PrepareSpellScript(spell_putricide_unstable_experiment); + + void HandleScript(SpellEffIndex effIndex) + { + PreventHitDefaultEffect(effIndex); + if (GetCaster()->GetTypeId() != TYPEID_UNIT) + return; + + Creature* creature = GetCaster()->ToCreature(); + + uint8 stage = creature->AI()->GetData(DATA_EXPERIMENT_STAGE); + creature->AI()->SetData(DATA_EXPERIMENT_STAGE, stage ? 0 : 1); + + Creature* target = nullptr; + std::list creList; + GetCreatureListWithEntryInGrid(creList, GetCaster(), NPC_ABOMINATION_WING_MAD_SCIENTIST_STALKER, 200.0f); + for (std::list::iterator itr = creList.begin(); itr != creList.end(); ++itr) + if (((*itr)->GetPositionX() > 4350.0f && stage == 0) || ((*itr)->GetPositionX() < 4350.0f && stage == 1)) + { + target = (*itr); + break; + } + + if (target) + { + if (Aura* aura = target->GetAura(uint32(GetSpellInfo()->Effects[stage].CalcValue()))) + if (aura->GetOwner() == target) // avoid assert(false) at any cost + aura->UpdateOwner(5000, target); // update whole aura so previous periodic ticks before refreshed by new one } - // big hax to unlock Abomination Eat Ooze ability, requires caster aura spell from difficulty X, but unlocks clientside when got base aura - void HandleScript(SpellEffIndex /*effIndex*/) + GetCaster()->CastSpell(target, uint32(GetSpellInfo()->Effects[stage].CalcValue()), true, nullptr, nullptr, GetCaster()->GetGUID()); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_putricide_unstable_experiment::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } +}; + +class spell_putricide_tear_gas_effect : public SpellScript +{ + PrepareSpellScript(spell_putricide_tear_gas_effect); + + void FilterTargets(std::list& targets) + { + // vanish rank 1-3, mage invisibility + targets.remove_if(Acore::UnitAuraCheck(true, 11327)); + targets.remove_if(Acore::UnitAuraCheck(true, 11329)); + targets.remove_if(Acore::UnitAuraCheck(true, 26888)); + targets.remove_if(Acore::UnitAuraCheck(true, 32612)); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_putricide_tear_gas_effect::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_putricide_tear_gas_effect::FilterTargets, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY); + } +}; + +class spell_putricide_gaseous_bloat_aura : public AuraScript +{ + PrepareAuraScript(spell_putricide_gaseous_bloat_aura); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_GASEOUS_BLOAT }); + } + + void HandleExtraEffect(AuraEffect const* /*aurEff*/) + { + Unit* target = GetTarget(); + target->RemoveAuraFromStack(GetSpellInfo()->Id, GetCasterGUID()); + /*if (!target->HasAura(GetId())) + if (Unit* caster = GetCaster()) + caster->CastCustomSpell(SPELL_GASEOUS_BLOAT, SPELLVALUE_AURA_STACK, 10, caster, false);*/ + } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_putricide_gaseous_bloat_aura::HandleExtraEffect, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE); + } +}; + +class spell_putricide_ooze_channel : public SpellScript +{ + PrepareSpellScript(spell_putricide_ooze_channel); + + bool Validate(SpellInfo const* spell) override + { + return ValidateSpellInfo({ spell->ExcludeTargetAuraSpell }); + } + + // set up initial variables and check if caster is creature + // this will let use safely use ToCreature() casts in entire script + bool Load() override + { + _target = nullptr; + return GetCaster()->GetTypeId() == TYPEID_UNIT; + } + + void SelectTarget(std::list& targets) + { + // dbc has only 1 field for excluding, this will prevent anyone from getting both at the same time + targets.remove_if(Acore::UnitAuraCheck(true, SPELL_VOLATILE_OOZE_PROTECTION)); + targets.remove_if(Acore::UnitAuraCheck(true, SPELL_GASEOUS_BLOAT_PROTECTION)); + + if (targets.empty()) { - SpellInfo const* s1 = sSpellMgr->GetSpellInfo(70346); - SpellInfo const* s2 = sSpellMgr->GetSpellInfo(72456); - if (s1 && s2) - if (Unit* target = GetHitUnit()) + FinishCast(SPELL_FAILED_NO_VALID_TARGETS); + GetCaster()->ToCreature()->DespawnOrUnsummon(1); // despawn next update + return; + } + + WorldObject* target = Acore::Containers::SelectRandomContainerElement(targets); + targets.clear(); + targets.push_back(target); + _target = target; + } + + void SetTarget(std::list& targets) + { + targets.clear(); + if (_target) + targets.push_back(_target); + } + + void StartAttack() + { + GetCaster()->ClearUnitState(UNIT_STATE_CASTING); + GetCaster()->GetThreatMgr().ClearAllThreat(); + GetCaster()->ToCreature()->SetInCombatWithZone(); + GetCaster()->ToCreature()->AI()->AttackStart(GetHitUnit()); + GetCaster()->AddThreat(GetHitUnit(), 500000000.0f); // value seen in sniff + if (Creature* c = GetCaster()->ToCreature()) + c->AI()->SetGUID(GetHitUnit()->GetGUID(), -1); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_putricide_ooze_channel::SelectTarget, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_putricide_ooze_channel::SetTarget, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_putricide_ooze_channel::SetTarget, EFFECT_2, TARGET_UNIT_SRC_AREA_ENEMY); + AfterHit += SpellHitFn(spell_putricide_ooze_channel::StartAttack); + } + +private: + WorldObject* _target; +}; + +class spell_putricide_ooze_eruption_searcher : public SpellScript +{ + PrepareSpellScript(spell_putricide_ooze_eruption_searcher); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_OOZE_ERUPTION }); + } + + void HandleDummy(SpellEffIndex /*effIndex*/) + { + uint32 adhesiveId = sSpellMgr->GetSpellIdForDifficulty(SPELL_VOLATILE_OOZE_ADHESIVE, GetCaster()); + if (GetHitUnit()->HasAura(adhesiveId)) + { + GetHitUnit()->RemoveAurasDueToSpell(adhesiveId, GetCaster()->GetGUID(), 0, AURA_REMOVE_BY_ENEMY_SPELL); + GetCaster()->CastSpell(GetHitUnit(), SPELL_OOZE_ERUPTION, true); + } + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_putricide_ooze_eruption_searcher::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } +}; + +class spell_putricide_mutated_plague_aura : public AuraScript +{ + PrepareAuraScript(spell_putricide_mutated_plague_aura); + + void HandleTriggerSpell(AuraEffect const* aurEff) + { + PreventDefaultAction(); + Unit* caster = GetCaster(); + if (!caster) + return; + + uint32 triggerSpell = GetSpellInfo()->Effects[aurEff->GetEffIndex()].TriggerSpell; + SpellInfo const* spell = sSpellMgr->AssertSpellInfo(triggerSpell); + spell = sSpellMgr->GetSpellForDifficultyFromSpell(spell, caster); + + int32 damage = spell->Effects[EFFECT_0].CalcValue(caster); + damage = damage * pow(2.5f, GetStackAmount()); + + GetTarget()->CastCustomSpell(triggerSpell, SPELLVALUE_BASE_POINT0, damage, GetTarget(), true, nullptr, aurEff, GetCasterGUID()); + } + + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + uint32 healSpell = uint32(GetSpellInfo()->Effects[EFFECT_0].CalcValue()); + SpellInfo const* spell = sSpellMgr->GetSpellInfo(healSpell); + if (!spell) + return; + spell = sSpellMgr->GetSpellForDifficultyFromSpell(spell, GetTarget()); + int32 healAmount = spell->Effects[EFFECT_0].CalcValue(); + healAmount *= GetStackAmount(); + GetTarget()->CastCustomSpell(healSpell, SPELLVALUE_BASE_POINT0, healAmount, GetTarget(), TRIGGERED_FULL_MASK, nullptr, nullptr, GetCasterGUID()); + } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_putricide_mutated_plague_aura::HandleTriggerSpell, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + AfterEffectRemove += AuraEffectRemoveFn(spell_putricide_mutated_plague_aura::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL); + } +}; + +class spell_putricide_unbound_plague : public SpellScript +{ + PrepareSpellScript(spell_putricide_unbound_plague); + + bool Validate(SpellInfo const* /*spell*/) override + { + return ValidateSpellInfo({ SPELL_UNBOUND_PLAGUE, SPELL_UNBOUND_PLAGUE_SEARCHER }); + } + + void FilterTargets(std::list& targets) + { + if (AuraEffect const* eff = GetCaster()->GetAuraEffect(SPELL_UNBOUND_PLAGUE_SEARCHER, EFFECT_0)) + { + if (eff->GetTickNumber() < 2) + { + targets.clear(); + return; + } + } + + targets.remove_if(Acore::UnitAuraCheck(true, sSpellMgr->GetSpellIdForDifficulty(SPELL_UNBOUND_PLAGUE, GetCaster()))); + Acore::Containers::RandomResize(targets, 1); + } + + void HandleScript(SpellEffIndex /*effIndex*/) + { + if (!GetHitUnit()) + return; + + InstanceScript* instance = GetCaster()->GetInstanceScript(); + if (!instance) + return; + + uint32 plagueId = sSpellMgr->GetSpellIdForDifficulty(SPELL_UNBOUND_PLAGUE, GetCaster()); + + if (!GetHitUnit()->HasAura(plagueId)) + { + if (Creature* professor = ObjectAccessor::GetCreature(*GetCaster(), instance->GetGuidData(DATA_PROFESSOR_PUTRICIDE))) + { + if (Aura* oldPlague = GetCaster()->GetAura(plagueId, professor->GetGUID())) { - Aura::TryRefreshStackOrCreate(s1, MAX_EFFECT_MASK, target, target); - Aura::TryRefreshStackOrCreate(s2, MAX_EFFECT_MASK, target, target); - } - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_putricide_slime_puddle_SpellScript::ScaleRange, EFFECT_0, TARGET_UNIT_DEST_AREA_ENEMY); - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_putricide_slime_puddle_SpellScript::ScaleRange, EFFECT_1, TARGET_UNIT_DEST_AREA_ENTRY); - OnEffectHitTarget += SpellEffectFn(spell_putricide_slime_puddle_SpellScript::HandleScript, EFFECT_1, SPELL_EFFECT_APPLY_AURA); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_putricide_slime_puddle_SpellScript(); - } -}; - -class spell_putricide_slime_puddle_spawn : public SpellScriptLoader -{ -public: - spell_putricide_slime_puddle_spawn() : SpellScriptLoader("spell_putricide_slime_puddle_spawn") { } - - class spell_putricide_slime_puddle_spawn_SpellScript : public SpellScript - { - PrepareSpellScript(spell_putricide_slime_puddle_spawn_SpellScript); - - void SelectDest() - { - if (Position* dest = const_cast(GetExplTargetDest())) - { - float destZ = 395.0f; // random number close to ground, get exact in next call - GetCaster()->UpdateGroundPositionZ(dest->GetPositionX(), dest->GetPositionY(), destZ); - dest->m_positionZ = destZ; - } - } - - void Register() override - { - BeforeCast += SpellCastFn(spell_putricide_slime_puddle_spawn_SpellScript::SelectDest); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_putricide_slime_puddle_spawn_SpellScript(); - } -}; - -class spell_putricide_grow_stacker : public SpellScriptLoader -{ -public: - spell_putricide_grow_stacker() : SpellScriptLoader("spell_putricide_grow_stacker") { } - - class spell_putricide_grow_stacker_AuraScript : public AuraScript - { - PrepareAuraScript(spell_putricide_grow_stacker_AuraScript); - - void HandleTriggerSpell(AuraEffect const* /*aurEff*/) - { - if (Unit* target = GetTarget()) - if (target->HasAura(SPELL_TEAR_GAS_CREATURE)) - PreventDefaultAction(); - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_putricide_grow_stacker_AuraScript::HandleTriggerSpell, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_putricide_grow_stacker_AuraScript(); - } -}; - -class spell_putricide_unstable_experiment : public SpellScriptLoader -{ -public: - spell_putricide_unstable_experiment() : SpellScriptLoader("spell_putricide_unstable_experiment") { } - - class spell_putricide_unstable_experiment_SpellScript : public SpellScript - { - PrepareSpellScript(spell_putricide_unstable_experiment_SpellScript); - - void HandleScript(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - if (GetCaster()->GetTypeId() != TYPEID_UNIT) - return; - - Creature* creature = GetCaster()->ToCreature(); - - uint8 stage = creature->AI()->GetData(DATA_EXPERIMENT_STAGE); - creature->AI()->SetData(DATA_EXPERIMENT_STAGE, stage ? 0 : 1); - - Creature* target = nullptr; - std::list creList; - GetCreatureListWithEntryInGrid(creList, GetCaster(), NPC_ABOMINATION_WING_MAD_SCIENTIST_STALKER, 200.0f); - for (std::list::iterator itr = creList.begin(); itr != creList.end(); ++itr) - if (((*itr)->GetPositionX() > 4350.0f && stage == 0) || ((*itr)->GetPositionX() < 4350.0f && stage == 1)) - { - target = (*itr); - break; - } - - if (target) - { - if (Aura* aura = target->GetAura(uint32(GetSpellInfo()->Effects[stage].CalcValue()))) - if (aura->GetOwner() == target) // avoid assert(false) at any cost - aura->UpdateOwner(5000, target); // update whole aura so previous periodic ticks before refreshed by new one - } - - GetCaster()->CastSpell(target, uint32(GetSpellInfo()->Effects[stage].CalcValue()), true, nullptr, nullptr, GetCaster()->GetGUID()); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_putricide_unstable_experiment_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_putricide_unstable_experiment_SpellScript(); - } -}; - -class spell_putricide_tear_gas_effect : public SpellScriptLoader -{ -public: - spell_putricide_tear_gas_effect() : SpellScriptLoader("spell_putricide_tear_gas_effect") { } - - class spell_putricide_tear_gas_effect_SpellScript : public SpellScript - { - PrepareSpellScript(spell_putricide_tear_gas_effect_SpellScript); - - void FilterTargets(std::list& targets) - { - // vanish rank 1-3, mage invisibility - targets.remove_if(Acore::UnitAuraCheck(true, 11327)); - targets.remove_if(Acore::UnitAuraCheck(true, 11329)); - targets.remove_if(Acore::UnitAuraCheck(true, 26888)); - targets.remove_if(Acore::UnitAuraCheck(true, 32612)); - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_putricide_tear_gas_effect_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_putricide_tear_gas_effect_SpellScript::FilterTargets, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_putricide_tear_gas_effect_SpellScript(); - } -}; - -class spell_putricide_gaseous_bloat : public SpellScriptLoader -{ -public: - spell_putricide_gaseous_bloat() : SpellScriptLoader("spell_putricide_gaseous_bloat") { } - - class spell_putricide_gaseous_bloat_AuraScript : public AuraScript - { - PrepareAuraScript(spell_putricide_gaseous_bloat_AuraScript); - - void HandleExtraEffect(AuraEffect const* /*aurEff*/) - { - Unit* target = GetTarget(); - target->RemoveAuraFromStack(GetSpellInfo()->Id, GetCasterGUID()); - /*if (!target->HasAura(GetId())) - if (Unit* caster = GetCaster()) - caster->CastCustomSpell(SPELL_GASEOUS_BLOAT, SPELLVALUE_AURA_STACK, 10, caster, false);*/ - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_putricide_gaseous_bloat_AuraScript::HandleExtraEffect, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_putricide_gaseous_bloat_AuraScript(); - } -}; - -class spell_putricide_ooze_channel : public SpellScriptLoader -{ -public: - spell_putricide_ooze_channel() : SpellScriptLoader("spell_putricide_ooze_channel") { } - - class spell_putricide_ooze_channel_SpellScript : public SpellScript - { - PrepareSpellScript(spell_putricide_ooze_channel_SpellScript); - - bool Validate(SpellInfo const* spell) override - { - return ValidateSpellInfo({ spell->ExcludeTargetAuraSpell }); - } - - // set up initial variables and check if caster is creature - // this will let use safely use ToCreature() casts in entire script - bool Load() override - { - _target = nullptr; - return GetCaster()->GetTypeId() == TYPEID_UNIT; - } - - void SelectTarget(std::list& targets) - { - // dbc has only 1 field for excluding, this will prevent anyone from getting both at the same time - targets.remove_if(Acore::UnitAuraCheck(true, SPELL_VOLATILE_OOZE_PROTECTION)); - targets.remove_if(Acore::UnitAuraCheck(true, SPELL_GASEOUS_BLOAT_PROTECTION)); - - if (targets.empty()) - { - FinishCast(SPELL_FAILED_NO_VALID_TARGETS); - GetCaster()->ToCreature()->DespawnOrUnsummon(1); // despawn next update - return; - } - - WorldObject* target = Acore::Containers::SelectRandomContainerElement(targets); - targets.clear(); - targets.push_back(target); - _target = target; - } - - void SetTarget(std::list& targets) - { - targets.clear(); - if (_target) - targets.push_back(_target); - } - - void StartAttack() - { - GetCaster()->ClearUnitState(UNIT_STATE_CASTING); - GetCaster()->GetThreatMgr().ClearAllThreat(); - GetCaster()->ToCreature()->SetInCombatWithZone(); - GetCaster()->ToCreature()->AI()->AttackStart(GetHitUnit()); - GetCaster()->AddThreat(GetHitUnit(), 500000000.0f); // value seen in sniff - if (Creature* c = GetCaster()->ToCreature()) - c->AI()->SetGUID(GetHitUnit()->GetGUID(), -1); - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_putricide_ooze_channel_SpellScript::SelectTarget, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_putricide_ooze_channel_SpellScript::SetTarget, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY); - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_putricide_ooze_channel_SpellScript::SetTarget, EFFECT_2, TARGET_UNIT_SRC_AREA_ENEMY); - AfterHit += SpellHitFn(spell_putricide_ooze_channel_SpellScript::StartAttack); - } - - WorldObject* _target; - }; - - SpellScript* GetSpellScript() const override - { - return new spell_putricide_ooze_channel_SpellScript(); - } -}; - -class spell_putricide_ooze_eruption_searcher : public SpellScriptLoader -{ -public: - spell_putricide_ooze_eruption_searcher() : SpellScriptLoader("spell_putricide_ooze_eruption_searcher") { } - - class spell_putricide_ooze_eruption_searcher_SpellScript : public SpellScript - { - PrepareSpellScript(spell_putricide_ooze_eruption_searcher_SpellScript); - - void HandleDummy(SpellEffIndex /*effIndex*/) - { - uint32 adhesiveId = sSpellMgr->GetSpellIdForDifficulty(SPELL_VOLATILE_OOZE_ADHESIVE, GetCaster()); - if (GetHitUnit()->HasAura(adhesiveId)) - { - GetHitUnit()->RemoveAurasDueToSpell(adhesiveId, GetCaster()->GetGUID(), 0, AURA_REMOVE_BY_ENEMY_SPELL); - GetCaster()->CastSpell(GetHitUnit(), SPELL_OOZE_ERUPTION, true); - } - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_putricide_ooze_eruption_searcher_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_putricide_ooze_eruption_searcher_SpellScript(); - } -}; - -class spell_putricide_mutated_plague : public SpellScriptLoader -{ -public: - spell_putricide_mutated_plague() : SpellScriptLoader("spell_putricide_mutated_plague") { } - - class spell_putricide_mutated_plague_AuraScript : public AuraScript - { - PrepareAuraScript(spell_putricide_mutated_plague_AuraScript); - - void HandleTriggerSpell(AuraEffect const* aurEff) - { - PreventDefaultAction(); - Unit* caster = GetCaster(); - if (!caster) - return; - - uint32 triggerSpell = GetSpellInfo()->Effects[aurEff->GetEffIndex()].TriggerSpell; - SpellInfo const* spell = sSpellMgr->AssertSpellInfo(triggerSpell); - spell = sSpellMgr->GetSpellForDifficultyFromSpell(spell, caster); - - int32 damage = spell->Effects[EFFECT_0].CalcValue(caster); - damage = damage * pow(2.5f, GetStackAmount()); - - GetTarget()->CastCustomSpell(triggerSpell, SPELLVALUE_BASE_POINT0, damage, GetTarget(), true, nullptr, aurEff, GetCasterGUID()); - } - - void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - uint32 healSpell = uint32(GetSpellInfo()->Effects[EFFECT_0].CalcValue()); - SpellInfo const* spell = sSpellMgr->GetSpellInfo(healSpell); - if (!spell) - return; - spell = sSpellMgr->GetSpellForDifficultyFromSpell(spell, GetTarget()); - int32 healAmount = spell->Effects[EFFECT_0].CalcValue(); - healAmount *= GetStackAmount(); - GetTarget()->CastCustomSpell(healSpell, SPELLVALUE_BASE_POINT0, healAmount, GetTarget(), TRIGGERED_FULL_MASK, nullptr, nullptr, GetCasterGUID()); - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_putricide_mutated_plague_AuraScript::HandleTriggerSpell, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); - AfterEffectRemove += AuraEffectRemoveFn(spell_putricide_mutated_plague_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_putricide_mutated_plague_AuraScript(); - } -}; - -class spell_putricide_unbound_plague : public SpellScriptLoader -{ -public: - spell_putricide_unbound_plague() : SpellScriptLoader("spell_putricide_unbound_plague") { } - - class spell_putricide_unbound_plague_SpellScript : public SpellScript - { - PrepareSpellScript(spell_putricide_unbound_plague_SpellScript); - - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_UNBOUND_PLAGUE, SPELL_UNBOUND_PLAGUE_SEARCHER }); - } - - void FilterTargets(std::list& targets) - { - if (AuraEffect const* eff = GetCaster()->GetAuraEffect(SPELL_UNBOUND_PLAGUE_SEARCHER, EFFECT_0)) - { - if (eff->GetTickNumber() < 2) - { - targets.clear(); - return; - } - } - - targets.remove_if(Acore::UnitAuraCheck(true, sSpellMgr->GetSpellIdForDifficulty(SPELL_UNBOUND_PLAGUE, GetCaster()))); - Acore::Containers::RandomResize(targets, 1); - } - - void HandleScript(SpellEffIndex /*effIndex*/) - { - if (!GetHitUnit()) - return; - - InstanceScript* instance = GetCaster()->GetInstanceScript(); - if (!instance) - return; - - uint32 plagueId = sSpellMgr->GetSpellIdForDifficulty(SPELL_UNBOUND_PLAGUE, GetCaster()); - - if (!GetHitUnit()->HasAura(plagueId)) - { - if (Creature* professor = ObjectAccessor::GetCreature(*GetCaster(), instance->GetGuidData(DATA_PROFESSOR_PUTRICIDE))) - { - if (Aura* oldPlague = GetCaster()->GetAura(plagueId, professor->GetGUID())) + if (Aura* newPlague = professor->AddAura(plagueId, GetHitUnit())) { - if (Aura* newPlague = professor->AddAura(plagueId, GetHitUnit())) - { - newPlague->SetMaxDuration(oldPlague->GetMaxDuration()); - newPlague->SetDuration(oldPlague->GetDuration()); - oldPlague->Remove(); - GetCaster()->RemoveAurasDueToSpell(SPELL_UNBOUND_PLAGUE_SEARCHER); - GetCaster()->CastSpell(GetCaster(), SPELL_PLAGUE_SICKNESS, true); - GetCaster()->CastSpell(GetCaster(), SPELL_UNBOUND_PLAGUE_PROTECTION, true); - professor->CastSpell(GetHitUnit(), SPELL_UNBOUND_PLAGUE_SEARCHER, true); - } + newPlague->SetMaxDuration(oldPlague->GetMaxDuration()); + newPlague->SetDuration(oldPlague->GetDuration()); + oldPlague->Remove(); + GetCaster()->RemoveAurasDueToSpell(SPELL_UNBOUND_PLAGUE_SEARCHER); + GetCaster()->CastSpell(GetCaster(), SPELL_PLAGUE_SICKNESS, true); + GetCaster()->CastSpell(GetCaster(), SPELL_UNBOUND_PLAGUE_PROTECTION, true); + professor->CastSpell(GetHitUnit(), SPELL_UNBOUND_PLAGUE_SEARCHER, true); } } } } + } - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_putricide_unbound_plague_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ALLY); - OnEffectHitTarget += SpellEffectFn(spell_putricide_unbound_plague_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_putricide_unbound_plague_SpellScript(); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_putricide_unbound_plague::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ALLY); + OnEffectHitTarget += SpellEffectFn(spell_putricide_unbound_plague::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; -class spell_putricide_unbound_plague_dmg : public SpellScriptLoader +class spell_putricide_unbound_plague_dmg_aura : public AuraScript { -public: - spell_putricide_unbound_plague_dmg() : SpellScriptLoader("spell_putricide_unbound_plague_dmg") { } + PrepareAuraScript(spell_putricide_unbound_plague_dmg_aura); - class spell_putricide_unbound_plague_dmg_AuraScript : public AuraScript + void HandlePeriodic(AuraEffect* aurEff) { - PrepareAuraScript(spell_putricide_unbound_plague_dmg_AuraScript); + int32 baseAmt = aurEff->GetSpellInfo()->Effects[0].CalcValue(); + int32 dmg = int32(baseAmt * pow(1.25f, float(aurEff->GetTickNumber()))); + if (dmg <= 0) // safety check, impossible + return; + aurEff->SetAmount(dmg); + } - void HandlePeriodic(AuraEffect* aurEff) - { - int32 baseAmt = aurEff->GetSpellInfo()->Effects[0].CalcValue(); - int32 dmg = int32(baseAmt * pow(1.25f, float(aurEff->GetTickNumber()))); - if (dmg <= 0) // safety check, impossible - return; - aurEff->SetAmount(dmg); - } - - void Register() override - { - OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_putricide_unbound_plague_dmg_AuraScript::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE); - } - }; - - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_putricide_unbound_plague_dmg_AuraScript(); + OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_putricide_unbound_plague_dmg_aura::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE); } }; -class spell_putricide_choking_gas_bomb : public SpellScriptLoader +class spell_putricide_choking_gas_bomb : public SpellScript { -public: - spell_putricide_choking_gas_bomb() : SpellScriptLoader("spell_putricide_choking_gas_bomb") { } + PrepareSpellScript(spell_putricide_choking_gas_bomb); - class spell_putricide_choking_gas_bomb_SpellScript : public SpellScript + void HandleScript(SpellEffIndex /*effIndex*/) { - PrepareSpellScript(spell_putricide_choking_gas_bomb_SpellScript); - - void HandleScript(SpellEffIndex /*effIndex*/) + uint32 skipIndex = urand(0, 2); + for (uint32 i = 0; i < 3; ++i) { - uint32 skipIndex = urand(0, 2); - for (uint32 i = 0; i < 3; ++i) - { - if (i == skipIndex) - continue; + if (i == skipIndex) + continue; - uint32 spellId = uint32(GetSpellInfo()->Effects[i].CalcValue()); - GetCaster()->CastSpell(GetCaster(), spellId, true, nullptr, nullptr, GetCaster()->GetGUID()); - } + uint32 spellId = uint32(GetSpellInfo()->Effects[i].CalcValue()); + GetCaster()->CastSpell(GetCaster(), spellId, true, nullptr, nullptr, GetCaster()->GetGUID()); } + } - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_putricide_choking_gas_bomb_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_putricide_choking_gas_bomb_SpellScript(); + OnEffectHitTarget += SpellEffectFn(spell_putricide_choking_gas_bomb::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; // Removes aura with id stored in effect value -class spell_putricide_clear_aura_effect_value : public SpellScriptLoader +class spell_putricide_clear_aura_effect_value : public SpellScript { -public: - spell_putricide_clear_aura_effect_value() : SpellScriptLoader("spell_putricide_clear_aura_effect_value") { } + PrepareSpellScript(spell_putricide_clear_aura_effect_value); - class spell_putricide_clear_aura_effect_value_SpellScript : public SpellScript + void HandleScript(SpellEffIndex effIndex) { - PrepareSpellScript(spell_putricide_clear_aura_effect_value_SpellScript); + PreventHitDefaultEffect(effIndex); + uint32 auraId = sSpellMgr->GetSpellIdForDifficulty(uint32(GetEffectValue()), GetCaster()); + GetHitUnit()->RemoveAurasDueToSpell(auraId); + } - void HandleScript(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - uint32 auraId = sSpellMgr->GetSpellIdForDifficulty(uint32(GetEffectValue()), GetCaster()); - GetHitUnit()->RemoveAurasDueToSpell(auraId); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_putricide_clear_aura_effect_value_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_putricide_clear_aura_effect_value_SpellScript(); + OnEffectHitTarget += SpellEffectFn(spell_putricide_clear_aura_effect_value::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; -class spell_putricide_mutation_init : public SpellScriptLoader +class spell_putricide_mutation_init : public SpellScript { -public: - spell_putricide_mutation_init() : SpellScriptLoader("spell_putricide_mutation_init") { } + PrepareSpellScript(spell_putricide_mutation_init); - class spell_putricide_mutation_init_SpellScript : public SpellScript + SpellCastResult CheckRequirementInternal(SpellCustomErrors& extendedError) { - PrepareSpellScript(spell_putricide_mutation_init_SpellScript); + InstanceScript* instance = GetExplTargetUnit()->GetInstanceScript(); + if (!instance) + return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW; - SpellCastResult CheckRequirementInternal(SpellCustomErrors& extendedError) + Creature* professor = ObjectAccessor::GetCreature(*GetExplTargetUnit(), instance->GetGuidData(DATA_PROFESSOR_PUTRICIDE)); + if (!professor) + return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW; + + if (professor->AI()->GetData(DATA_PHASE) == 3 || !professor->IsAlive()) { - InstanceScript* instance = GetExplTargetUnit()->GetInstanceScript(); - if (!instance) - return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW; + extendedError = SPELL_CUSTOM_ERROR_ALL_POTIONS_USED; + return SPELL_FAILED_CUSTOM_ERROR; + } - Creature* professor = ObjectAccessor::GetCreature(*GetExplTargetUnit(), instance->GetGuidData(DATA_PROFESSOR_PUTRICIDE)); - if (!professor) - return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW; + if (professor->AI()->GetData(DATA_ABOMINATION)) + { + extendedError = SPELL_CUSTOM_ERROR_TOO_MANY_ABOMINATIONS; + return SPELL_FAILED_CUSTOM_ERROR; + } - if (professor->AI()->GetData(DATA_PHASE) == 3 || !professor->IsAlive()) + return SPELL_CAST_OK; + } + + SpellCastResult CheckRequirement() + { + if (!GetExplTargetUnit()) + return SPELL_FAILED_BAD_TARGETS; + + if (GetExplTargetUnit()->GetTypeId() != TYPEID_PLAYER) + return SPELL_FAILED_TARGET_NOT_PLAYER; + + SpellCustomErrors extension = SPELL_CUSTOM_ERROR_NONE; + SpellCastResult result = CheckRequirementInternal(extension); + if (result != SPELL_CAST_OK) + { + Spell::SendCastResult(GetExplTargetUnit()->ToPlayer(), GetSpellInfo(), 0, result, extension); + return result; + } + + return SPELL_CAST_OK; + } + + void Register() override + { + OnCheckCast += SpellCheckCastFn(spell_putricide_mutation_init::CheckRequirement); + } +}; + +class spell_putricide_mutation_init_aura : public AuraScript +{ + PrepareAuraScript(spell_putricide_mutation_init_aura); + + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + uint32 spellId = 70311; + if (GetTarget()->GetMap()->GetSpawnMode() & 1) + spellId = 71503; + + GetTarget()->CastSpell(GetTarget(), spellId, true); + } + + void Register() override + { + AfterEffectRemove += AuraEffectRemoveFn(spell_putricide_mutation_init_aura::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + } +}; + +class spell_putricide_mutated_transformation : public SpellScript +{ + PrepareSpellScript(spell_putricide_mutated_transformation); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ + SPELL_ABOMINATION_VEHICLE_POWER_DRAIN, + SPELL_MUTATED_TRANSFORMATION_DAMAGE, + SPELL_MUTATED_TRANSFORMATION_NAME, + VEHICLE_SPELL_RIDE_HARDCODED + }); + } + + void HandleSummon(SpellEffIndex effIndex) + { + PreventHitDefaultEffect(effIndex); + Unit* caster = GetOriginalCaster(); + if (!caster) + return; + + InstanceScript* instance = caster->GetInstanceScript(); + if (!instance) + return; + + Creature* putricide = ObjectAccessor::GetCreature(*caster, instance->GetGuidData(DATA_PROFESSOR_PUTRICIDE)); + if (!putricide) + return; + + if (putricide->AI()->GetData(DATA_ABOMINATION)) + { + if (Player* player = caster->ToPlayer()) + Spell::SendCastResult(player, GetSpellInfo(), 0, SPELL_FAILED_CUSTOM_ERROR, SPELL_CUSTOM_ERROR_TOO_MANY_ABOMINATIONS); + return; + } + + if (!putricide->IsInCombat()) + putricide->SetInCombatWithZone(); + + uint32 entry = uint32(GetSpellInfo()->Effects[effIndex].MiscValue); + SummonPropertiesEntry const* properties = sSummonPropertiesStore.LookupEntry(uint32(GetSpellInfo()->Effects[effIndex].MiscValueB)); + uint32 duration = uint32(GetSpellInfo()->GetDuration()); + + Position pos = caster->GetPosition(); + TempSummon* summon = caster->GetMap()->SummonCreature(entry, pos, properties, duration, caster, GetSpellInfo()->Id); + if (!summon || !summon->IsVehicle()) + return; + + summon->CastSpell(summon, SPELL_ABOMINATION_VEHICLE_POWER_DRAIN, true); + summon->CastSpell(summon, SPELL_MUTATED_TRANSFORMATION_DAMAGE, true); + caster->CastSpell(summon, SPELL_MUTATED_TRANSFORMATION_NAME, true); + + //EnterVehicle(summon, 0); // VEHICLE_SPELL_RIDE_HARDCODED is used according to sniff, this is ok + caster->CastCustomSpell(VEHICLE_SPELL_RIDE_HARDCODED, SPELLVALUE_BASE_POINT0, 1, summon, TRIGGERED_FULL_MASK); + summon->SetCreatorGUID(caster->GetGUID()); + putricide->AI()->JustSummoned(summon); + + summon->setPowerType(POWER_ENERGY); + summon->SetMaxPower(POWER_ENERGY, 100); + summon->SetPower(POWER_ENERGY, 0); + summon->SetStatFloatValue(UNIT_FIELD_POWER_REGEN_INTERRUPTED_FLAT_MODIFIER, 0); + summon->SetStatFloatValue(UNIT_FIELD_POWER_REGEN_FLAT_MODIFIER, 0); + } + + void Register() override + { + OnEffectHit += SpellEffectFn(spell_putricide_mutated_transformation::HandleSummon, EFFECT_0, SPELL_EFFECT_SUMMON); + } +}; + +class spell_putricide_mutated_transformation_dismiss_aura : public AuraScript +{ + PrepareAuraScript(spell_putricide_mutated_transformation_dismiss_aura); + + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (Vehicle* veh = GetTarget()->GetVehicleKit()) + veh->RemoveAllPassengers(); + } + + void Register() override + { + AfterEffectRemove += AuraEffectRemoveFn(spell_putricide_mutated_transformation_dismiss_aura::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL); + } +}; + +class spell_putricide_mutated_transformation_dmg : public SpellScript +{ + PrepareSpellScript(spell_putricide_mutated_transformation_dmg); + + void FilterTargetsInitial(std::list& targets) + { + if (Unit* owner = ObjectAccessor::GetUnit(*GetCaster(), GetCaster()->GetCreatorGUID())) + targets.remove(owner); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_putricide_mutated_transformation_dmg::FilterTargetsInitial, EFFECT_0, TARGET_UNIT_SRC_AREA_ALLY); + } +}; + +class spell_putricide_eat_ooze : public SpellScript +{ + PrepareSpellScript(spell_putricide_eat_ooze); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_GROW_STACKER }); + } + + void SelectTarget(std::list& targets) + { + if (targets.empty()) + return; + + targets.sort(Acore::ObjectDistanceOrderPred(GetCaster())); + WorldObject* target = targets.front(); + targets.clear(); + targets.push_back(target); + } + + void HandleScript(SpellEffIndex /*effIndex*/) + { + Creature* target = GetHitCreature(); + if (!target) + return; + + if (Aura* grow = target->GetAura(uint32(GetEffectValue()))) + { + if (grow->GetStackAmount() <= 4) { - extendedError = SPELL_CUSTOM_ERROR_ALL_POTIONS_USED; - return SPELL_FAILED_CUSTOM_ERROR; + target->RemoveAurasDueToSpell(SPELL_GROW_STACKER); + target->RemoveAura(grow); + target->DespawnOrUnsummon(1); } - - if (professor->AI()->GetData(DATA_ABOMINATION)) - { - extendedError = SPELL_CUSTOM_ERROR_TOO_MANY_ABOMINATIONS; - return SPELL_FAILED_CUSTOM_ERROR; - } - - return SPELL_CAST_OK; + else + grow->ModStackAmount(-4); } - - SpellCastResult CheckRequirement() - { - if (!GetExplTargetUnit()) - return SPELL_FAILED_BAD_TARGETS; - - if (GetExplTargetUnit()->GetTypeId() != TYPEID_PLAYER) - return SPELL_FAILED_TARGET_NOT_PLAYER; - - SpellCustomErrors extension = SPELL_CUSTOM_ERROR_NONE; - SpellCastResult result = CheckRequirementInternal(extension); - if (result != SPELL_CAST_OK) - { - Spell::SendCastResult(GetExplTargetUnit()->ToPlayer(), GetSpellInfo(), 0, result, extension); - return result; - } - - return SPELL_CAST_OK; - } - - void Register() override - { - OnCheckCast += SpellCheckCastFn(spell_putricide_mutation_init_SpellScript::CheckRequirement); - } - }; - - class spell_putricide_mutation_init_AuraScript : public AuraScript - { - PrepareAuraScript(spell_putricide_mutation_init_AuraScript); - - void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - uint32 spellId = 70311; - if (GetTarget()->GetMap()->GetSpawnMode() & 1) - spellId = 71503; - - GetTarget()->CastSpell(GetTarget(), spellId, true); - } - - void Register() override - { - AfterEffectRemove += AuraEffectRemoveFn(spell_putricide_mutation_init_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_putricide_mutation_init_SpellScript(); } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_putricide_mutation_init_AuraScript(); + OnEffectHitTarget += SpellEffectFn(spell_putricide_eat_ooze::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_putricide_eat_ooze::SelectTarget, EFFECT_0, TARGET_UNIT_DEST_AREA_ENTRY); } }; -class spell_putricide_mutated_transformation : public SpellScriptLoader +class spell_putricide_regurgitated_ooze : public SpellScript { -public: - spell_putricide_mutated_transformation() : SpellScriptLoader("spell_putricide_mutated_transformation") { } + PrepareSpellScript(spell_putricide_regurgitated_ooze); - class spell_putricide_mutated_transformation_SpellScript : public SpellScript + // the only purpose of this hook is to fail the achievement + void ExtraEffect(SpellEffIndex /*effIndex*/) { - PrepareSpellScript(spell_putricide_mutated_transformation_SpellScript); - - void HandleSummon(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - Unit* caster = GetOriginalCaster(); - if (!caster) - return; - - InstanceScript* instance = caster->GetInstanceScript(); - if (!instance) - return; - - Creature* putricide = ObjectAccessor::GetCreature(*caster, instance->GetGuidData(DATA_PROFESSOR_PUTRICIDE)); - if (!putricide) - return; - - if (putricide->AI()->GetData(DATA_ABOMINATION)) - { - if (Player* player = caster->ToPlayer()) - Spell::SendCastResult(player, GetSpellInfo(), 0, SPELL_FAILED_CUSTOM_ERROR, SPELL_CUSTOM_ERROR_TOO_MANY_ABOMINATIONS); - return; - } - - if (!putricide->IsInCombat()) - putricide->SetInCombatWithZone(); - - uint32 entry = uint32(GetSpellInfo()->Effects[effIndex].MiscValue); - SummonPropertiesEntry const* properties = sSummonPropertiesStore.LookupEntry(uint32(GetSpellInfo()->Effects[effIndex].MiscValueB)); - uint32 duration = uint32(GetSpellInfo()->GetDuration()); - - Position pos = caster->GetPosition(); - TempSummon* summon = caster->GetMap()->SummonCreature(entry, pos, properties, duration, caster, GetSpellInfo()->Id); - if (!summon || !summon->IsVehicle()) - return; - - summon->CastSpell(summon, SPELL_ABOMINATION_VEHICLE_POWER_DRAIN, true); - summon->CastSpell(summon, SPELL_MUTATED_TRANSFORMATION_DAMAGE, true); - caster->CastSpell(summon, SPELL_MUTATED_TRANSFORMATION_NAME, true); - - //EnterVehicle(summon, 0); // VEHICLE_SPELL_RIDE_HARDCODED is used according to sniff, this is ok - caster->CastCustomSpell(VEHICLE_SPELL_RIDE_HARDCODED, SPELLVALUE_BASE_POINT0, 1, summon, TRIGGERED_FULL_MASK); - summon->SetCreatorGUID(caster->GetGUID()); - putricide->AI()->JustSummoned(summon); - - summon->setPowerType(POWER_ENERGY); - summon->SetMaxPower(POWER_ENERGY, 100); - summon->SetPower(POWER_ENERGY, 0); - summon->SetStatFloatValue(UNIT_FIELD_POWER_REGEN_INTERRUPTED_FLAT_MODIFIER, 0); - summon->SetStatFloatValue(UNIT_FIELD_POWER_REGEN_FLAT_MODIFIER, 0); - } - - void Register() override - { - OnEffectHit += SpellEffectFn(spell_putricide_mutated_transformation_SpellScript::HandleSummon, EFFECT_0, SPELL_EFFECT_SUMMON); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_putricide_mutated_transformation_SpellScript(); + if (InstanceScript* instance = GetCaster()->GetInstanceScript()) + instance->SetData(DATA_NAUSEA_ACHIEVEMENT, uint32(false)); } -}; -class spell_putricide_mutated_transformation_dismiss : public SpellScriptLoader -{ -public: - spell_putricide_mutated_transformation_dismiss() : SpellScriptLoader("spell_putricide_mutated_transformation_dismiss") { } - - class spell_putricide_mutated_transformation_dismiss_AuraScript : public AuraScript + void Register() override { - PrepareAuraScript(spell_putricide_mutated_transformation_dismiss_AuraScript); - - void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (Vehicle* veh = GetTarget()->GetVehicleKit()) - veh->RemoveAllPassengers(); - } - - void Register() override - { - AfterEffectRemove += AuraEffectRemoveFn(spell_putricide_mutated_transformation_dismiss_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_putricide_mutated_transformation_dismiss_AuraScript(); - } -}; - -class spell_putricide_mutated_transformation_dmg : public SpellScriptLoader -{ -public: - spell_putricide_mutated_transformation_dmg() : SpellScriptLoader("spell_putricide_mutated_transformation_dmg") { } - - class spell_putricide_mutated_transformation_dmg_SpellScript : public SpellScript - { - PrepareSpellScript(spell_putricide_mutated_transformation_dmg_SpellScript); - - void FilterTargetsInitial(std::list& targets) - { - if (Unit* owner = ObjectAccessor::GetUnit(*GetCaster(), GetCaster()->GetCreatorGUID())) - targets.remove(owner); - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_putricide_mutated_transformation_dmg_SpellScript::FilterTargetsInitial, EFFECT_0, TARGET_UNIT_SRC_AREA_ALLY); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_putricide_mutated_transformation_dmg_SpellScript(); - } -}; - -class spell_putricide_eat_ooze : public SpellScriptLoader -{ -public: - spell_putricide_eat_ooze() : SpellScriptLoader("spell_putricide_eat_ooze") { } - - class spell_putricide_eat_ooze_SpellScript : public SpellScript - { - PrepareSpellScript(spell_putricide_eat_ooze_SpellScript); - - void SelectTarget(std::list& targets) - { - if (targets.empty()) - return; - - targets.sort(Acore::ObjectDistanceOrderPred(GetCaster())); - WorldObject* target = targets.front(); - targets.clear(); - targets.push_back(target); - } - - void HandleScript(SpellEffIndex /*effIndex*/) - { - Creature* target = GetHitCreature(); - if (!target) - return; - - if (Aura* grow = target->GetAura(uint32(GetEffectValue()))) - { - if (grow->GetStackAmount() <= 4) - { - target->RemoveAurasDueToSpell(SPELL_GROW_STACKER); - target->RemoveAura(grow); - target->DespawnOrUnsummon(1); - } - else - grow->ModStackAmount(-4); - } - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_putricide_eat_ooze_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_putricide_eat_ooze_SpellScript::SelectTarget, EFFECT_0, TARGET_UNIT_DEST_AREA_ENTRY); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_putricide_eat_ooze_SpellScript(); - } -}; - -class spell_putricide_regurgitated_ooze : public SpellScriptLoader -{ -public: - spell_putricide_regurgitated_ooze() : SpellScriptLoader("spell_putricide_regurgitated_ooze") { } - - class spell_putricide_regurgitated_ooze_SpellScript : public SpellScript - { - PrepareSpellScript(spell_putricide_regurgitated_ooze_SpellScript); - - // the only purpose of this hook is to fail the achievement - void ExtraEffect(SpellEffIndex /*effIndex*/) - { - if (InstanceScript* instance = GetCaster()->GetInstanceScript()) - instance->SetData(DATA_NAUSEA_ACHIEVEMENT, uint32(false)); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_putricide_regurgitated_ooze_SpellScript::ExtraEffect, EFFECT_0, SPELL_EFFECT_APPLY_AURA); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_putricide_regurgitated_ooze_SpellScript(); + OnEffectHitTarget += SpellEffectFn(spell_putricide_regurgitated_ooze::ExtraEffect, EFFECT_0, SPELL_EFFECT_APPLY_AURA); } }; @@ -1710,24 +1527,24 @@ void AddSC_boss_professor_putricide() new boss_professor_putricide(); new npc_volatile_ooze(); new npc_gas_cloud(); - new spell_putricide_slime_puddle(); - new spell_putricide_slime_puddle_spawn(); - new spell_putricide_grow_stacker(); - new spell_putricide_unstable_experiment(); - new spell_putricide_tear_gas_effect(); - new spell_putricide_gaseous_bloat(); - new spell_putricide_ooze_channel(); - new spell_putricide_ooze_eruption_searcher(); - new spell_putricide_mutated_plague(); - new spell_putricide_unbound_plague(); - new spell_putricide_unbound_plague_dmg(); - new spell_putricide_choking_gas_bomb(); - new spell_putricide_clear_aura_effect_value(); - new spell_putricide_mutation_init(); - new spell_putricide_mutated_transformation(); - new spell_putricide_mutated_transformation_dismiss(); - new spell_putricide_mutated_transformation_dmg(); - new spell_putricide_eat_ooze(); - new spell_putricide_regurgitated_ooze(); + RegisterSpellScript(spell_putricide_slime_puddle); + RegisterSpellScript(spell_putricide_slime_puddle_spawn); + RegisterSpellScript(spell_putricide_grow_stacker_aura); + RegisterSpellScript(spell_putricide_unstable_experiment); + RegisterSpellScript(spell_putricide_tear_gas_effect); + RegisterSpellScript(spell_putricide_gaseous_bloat_aura); + RegisterSpellScript(spell_putricide_ooze_channel); + RegisterSpellScript(spell_putricide_ooze_eruption_searcher); + RegisterSpellScript(spell_putricide_mutated_plague_aura); + RegisterSpellScript(spell_putricide_unbound_plague); + RegisterSpellScript(spell_putricide_unbound_plague_dmg_aura); + RegisterSpellScript(spell_putricide_choking_gas_bomb); + RegisterSpellScript(spell_putricide_clear_aura_effect_value); + RegisterSpellAndAuraScriptPair(spell_putricide_mutation_init, spell_putricide_mutation_init_aura); + RegisterSpellScript(spell_putricide_mutated_transformation); + RegisterSpellScript(spell_putricide_mutated_transformation_dismiss_aura); + RegisterSpellScript(spell_putricide_mutated_transformation_dmg); + RegisterSpellScript(spell_putricide_eat_ooze); + RegisterSpellScript(spell_putricide_regurgitated_ooze); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp index 9fa5a9354..f9ae6e1d9 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp @@ -506,158 +506,194 @@ public: } }; -class spell_rotface_mutated_infection : public SpellScriptLoader +class spell_rotface_mutated_infection : public SpellScript { -public: - spell_rotface_mutated_infection() : SpellScriptLoader("spell_rotface_mutated_infection") { } + PrepareSpellScript(spell_rotface_mutated_infection); - class spell_rotface_mutated_infection_SpellScript : public SpellScript + bool Load() override { - PrepareSpellScript(spell_rotface_mutated_infection_SpellScript); - - bool Load() override - { - _target = nullptr; - return true; - } - - void FilterTargets(std::list& targets) - { - // remove targets with this aura already - // tank is not on this list - targets.remove_if(Acore::UnitAuraCheck(true, GetSpellInfo()->Id)); - targets.remove(GetCaster()->GetVictim()); - if (targets.empty()) - return; - - WorldObject* target = Acore::Containers::SelectRandomContainerElement(targets); - targets.clear(); - targets.push_back(target); - _target = target; - } - - void ReplaceTargets(std::list& targets) - { - targets.clear(); - if (_target) - targets.push_back(_target); - } - - void NotifyTargets() - { - if (Creature* caster = GetCaster()->ToCreature()) - if (Unit* target = GetHitUnit()) - caster->AI()->Talk(EMOTE_MUTATED_INFECTION, target); - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_rotface_mutated_infection_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_rotface_mutated_infection_SpellScript::ReplaceTargets, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY); - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_rotface_mutated_infection_SpellScript::ReplaceTargets, EFFECT_2, TARGET_UNIT_SRC_AREA_ENEMY); - AfterHit += SpellHitFn(spell_rotface_mutated_infection_SpellScript::NotifyTargets); - } - - WorldObject* _target; - }; - - class spell_rotface_mutated_infection_AuraScript : public AuraScript - { - PrepareAuraScript(spell_rotface_mutated_infection_AuraScript); - - void ExtraRemoveEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - GetTarget()->CastSpell(GetTarget(), GetSpellInfo()->Effects[2].CalcValue(), true); - } - - void Register() override - { - AfterEffectRemove += AuraEffectRemoveFn(spell_rotface_mutated_infection_AuraScript::ExtraRemoveEffect, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAL); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_rotface_mutated_infection_SpellScript(); + _target = nullptr; + return true; } - AuraScript* GetAuraScript() const override + void FilterTargets(std::list& targets) { - return new spell_rotface_mutated_infection_AuraScript(); + // remove targets with this aura already + // tank is not on this list + targets.remove_if(Acore::UnitAuraCheck(true, GetSpellInfo()->Id)); + targets.remove(GetCaster()->GetVictim()); + if (targets.empty()) + return; + + WorldObject* target = Acore::Containers::SelectRandomContainerElement(targets); + targets.clear(); + targets.push_back(target); + _target = target; + } + + void ReplaceTargets(std::list& targets) + { + targets.clear(); + if (_target) + targets.push_back(_target); + } + + void NotifyTargets() + { + if (Creature* caster = GetCaster()->ToCreature()) + if (Unit* target = GetHitUnit()) + caster->AI()->Talk(EMOTE_MUTATED_INFECTION, target); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_rotface_mutated_infection::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_rotface_mutated_infection::ReplaceTargets, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_rotface_mutated_infection::ReplaceTargets, EFFECT_2, TARGET_UNIT_SRC_AREA_ENEMY); + AfterHit += SpellHitFn(spell_rotface_mutated_infection::NotifyTargets); + } + +private: + WorldObject* _target; +}; + +class spell_rotface_mutated_infection_aura : public AuraScript +{ + PrepareAuraScript(spell_rotface_mutated_infection_aura); + + void ExtraRemoveEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + GetTarget()->CastSpell(GetTarget(), GetSpellInfo()->Effects[2].CalcValue(), true); + } + + void Register() override + { + AfterEffectRemove += AuraEffectRemoveFn(spell_rotface_mutated_infection_aura::ExtraRemoveEffect, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAL); } }; -class spell_rotface_little_ooze_combine : public SpellScriptLoader +class spell_rotface_little_ooze_combine : public SpellScript { -public: - spell_rotface_little_ooze_combine() : SpellScriptLoader("spell_rotface_little_ooze_combine") { } + PrepareSpellScript(spell_rotface_little_ooze_combine); - class spell_rotface_little_ooze_combine_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareSpellScript(spell_rotface_little_ooze_combine_SpellScript); + return ValidateSpellInfo({ SPELL_LITTLE_OOZE_COMBINE, SPELL_OOZE_MERGE }); + } - void HandleScript(SpellEffIndex /*effIndex*/) - { - // little targetting little - - if (!GetHitCreature() || !GetHitCreature()->IsAlive()) - return; - - GetCaster()->RemoveAurasDueToSpell(SPELL_LITTLE_OOZE_COMBINE); - GetHitCreature()->RemoveAurasDueToSpell(SPELL_LITTLE_OOZE_COMBINE); - GetHitCreature()->CastSpell(GetCaster(), SPELL_OOZE_MERGE, true); - GetHitCreature()->DespawnOrUnsummon(); - if (GetCaster()->ToCreature()) - GetCaster()->ToCreature()->DespawnOrUnsummon(); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_rotface_little_ooze_combine_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void HandleScript(SpellEffIndex /*effIndex*/) { - return new spell_rotface_little_ooze_combine_SpellScript(); + // little targetting little + + if (!GetHitCreature() || !GetHitCreature()->IsAlive()) + return; + + GetCaster()->RemoveAurasDueToSpell(SPELL_LITTLE_OOZE_COMBINE); + GetHitCreature()->RemoveAurasDueToSpell(SPELL_LITTLE_OOZE_COMBINE); + GetHitCreature()->CastSpell(GetCaster(), SPELL_OOZE_MERGE, true); + GetHitCreature()->DespawnOrUnsummon(); + if (GetCaster()->ToCreature()) + GetCaster()->ToCreature()->DespawnOrUnsummon(); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_rotface_little_ooze_combine::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; -class spell_rotface_large_ooze_combine : public SpellScriptLoader +class spell_rotface_large_ooze_combine : public SpellScript { -public: - spell_rotface_large_ooze_combine() : SpellScriptLoader("spell_rotface_large_ooze_combine") { } + PrepareSpellScript(spell_rotface_large_ooze_combine); - class spell_rotface_large_ooze_combine_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareSpellScript(spell_rotface_large_ooze_combine_SpellScript); + return ValidateSpellInfo({ SPELL_UNSTABLE_OOZE, 69844, SPELL_LARGE_OOZE_BUFF_COMBINE, SPELL_LARGE_OOZE_COMBINE, SPELL_UNSTABLE_OOZE_EXPLOSION }); + } - void HandleScript(SpellEffIndex /*effIndex*/) + void HandleScript(SpellEffIndex /*effIndex*/) + { + // large targetting large + + if (!GetHitCreature() || !GetHitCreature()->IsAlive()) + return; + + uint8 casterStack = 1; + uint8 targetStack = 1; + Aura* casterAura = GetCaster()->GetAura(SPELL_UNSTABLE_OOZE); + if (casterAura) + casterStack = casterAura->GetStackAmount(); + Aura* targetAura = GetHitCreature()->GetAura(SPELL_UNSTABLE_OOZE); + if (targetAura) + targetStack = targetAura->GetStackAmount(); + uint8 newStack = casterStack + targetStack; + if (newStack > 5) + newStack = 5; + if (casterAura) + casterAura->SetStackAmount(newStack); + else { - // large targetting large + GetCaster()->CastSpell(GetCaster(), SPELL_UNSTABLE_OOZE, true); + if (Aura* aur = GetCaster()->GetAura(SPELL_UNSTABLE_OOZE)) + aur->SetStackAmount(newStack); + } - if (!GetHitCreature() || !GetHitCreature()->IsAlive()) - return; + // red color! + if (newStack >= 4) + GetCaster()->CastSpell(GetCaster(), 69844, true); - uint8 casterStack = 1; - uint8 targetStack = 1; - Aura* casterAura = GetCaster()->GetAura(SPELL_UNSTABLE_OOZE); - if (casterAura) - casterStack = casterAura->GetStackAmount(); - Aura* targetAura = GetHitCreature()->GetAura(SPELL_UNSTABLE_OOZE); - if (targetAura) - targetStack = targetAura->GetStackAmount(); - uint8 newStack = casterStack + targetStack; - if (newStack > 5) - newStack = 5; - if (casterAura) - casterAura->SetStackAmount(newStack); - else - { - GetCaster()->CastSpell(GetCaster(), SPELL_UNSTABLE_OOZE, true); - if (Aura* aur = GetCaster()->GetAura(SPELL_UNSTABLE_OOZE)) - aur->SetStackAmount(newStack); - } + // explode! + if (newStack >= 5) + { + GetCaster()->RemoveAurasDueToSpell(SPELL_LARGE_OOZE_BUFF_COMBINE); + GetCaster()->RemoveAurasDueToSpell(SPELL_LARGE_OOZE_COMBINE); + if (InstanceScript* instance = GetCaster()->GetInstanceScript()) + if (Creature* rotface = ObjectAccessor::GetCreature(*GetCaster(), instance->GetGuidData(DATA_ROTFACE))) + if (rotface->IsAlive()) + { + if (GetCaster()->GetTypeId() == TYPEID_UNIT) + GetCaster()->ToCreature()->AI()->Talk(EMOTE_UNSTABLE_EXPLOSION); + rotface->AI()->Talk(SAY_UNSTABLE_EXPLOSION); + } + + if (Creature* cre = GetCaster()->ToCreature()) + cre->AI()->DoAction(EVENT_STICKY_OOZE); + GetCaster()->CastSpell(GetCaster(), SPELL_UNSTABLE_OOZE_EXPLOSION, false, nullptr, nullptr, GetCaster()->GetGUID()); + if (InstanceScript* instance = GetCaster()->GetInstanceScript()) + instance->SetData(DATA_OOZE_DANCE_ACHIEVEMENT, uint32(false)); + } + + GetHitCreature()->RemoveAurasDueToSpell(SPELL_LARGE_OOZE_BUFF_COMBINE); + GetHitCreature()->RemoveAurasDueToSpell(SPELL_LARGE_OOZE_COMBINE); + GetHitCreature()->DespawnOrUnsummon(); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_rotface_large_ooze_combine::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } +}; + +class spell_rotface_large_ooze_buff_combine : public SpellScript +{ + PrepareSpellScript(spell_rotface_large_ooze_buff_combine); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ 69844, SPELL_LARGE_OOZE_BUFF_COMBINE, SPELL_LARGE_OOZE_COMBINE, SPELL_UNSTABLE_OOZE_EXPLOSION, SPELL_LITTLE_OOZE_COMBINE }); + } + + void HandleScript(SpellEffIndex /*effIndex*/) + { + // large targetting little + + if (!GetHitCreature() || !GetHitCreature()->IsAlive()) + return; + + if (Aura* unstable = GetCaster()->GetAura(SPELL_UNSTABLE_OOZE)) + { + uint8 newStack = uint8(unstable->GetStackAmount() + 1); + unstable->SetStackAmount(newStack); // red color! if (newStack >= 4) @@ -683,193 +719,91 @@ public: if (InstanceScript* instance = GetCaster()->GetInstanceScript()) instance->SetData(DATA_OOZE_DANCE_ACHIEVEMENT, uint32(false)); } - - GetHitCreature()->RemoveAurasDueToSpell(SPELL_LARGE_OOZE_BUFF_COMBINE); - GetHitCreature()->RemoveAurasDueToSpell(SPELL_LARGE_OOZE_COMBINE); - GetHitCreature()->DespawnOrUnsummon(); } - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_rotface_large_ooze_combine_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; + GetHitCreature()->RemoveAurasDueToSpell(SPELL_LITTLE_OOZE_COMBINE); + GetHitCreature()->DespawnOrUnsummon(); + } - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_rotface_large_ooze_combine_SpellScript(); + OnEffectHitTarget += SpellEffectFn(spell_rotface_large_ooze_buff_combine::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; -class spell_rotface_large_ooze_buff_combine : public SpellScriptLoader +class spell_rotface_unstable_ooze_explosion_init : public SpellScript { -public: - spell_rotface_large_ooze_buff_combine() : SpellScriptLoader("spell_rotface_large_ooze_buff_combine") { } + PrepareSpellScript(spell_rotface_unstable_ooze_explosion_init); - class spell_rotface_large_ooze_buff_combine_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spell*/) override { - PrepareSpellScript(spell_rotface_large_ooze_buff_combine_SpellScript); + return ValidateSpellInfo({ SPELL_UNSTABLE_OOZE_EXPLOSION_TRIGGER }); + } - void HandleScript(SpellEffIndex /*effIndex*/) - { - // large targetting little - - if (!GetHitCreature() || !GetHitCreature()->IsAlive()) - return; - - if (Aura* unstable = GetCaster()->GetAura(SPELL_UNSTABLE_OOZE)) - { - uint8 newStack = uint8(unstable->GetStackAmount() + 1); - unstable->SetStackAmount(newStack); - - // red color! - if (newStack >= 4) - GetCaster()->CastSpell(GetCaster(), 69844, true); - - // explode! - if (newStack >= 5) - { - GetCaster()->RemoveAurasDueToSpell(SPELL_LARGE_OOZE_BUFF_COMBINE); - GetCaster()->RemoveAurasDueToSpell(SPELL_LARGE_OOZE_COMBINE); - if (InstanceScript* instance = GetCaster()->GetInstanceScript()) - if (Creature* rotface = ObjectAccessor::GetCreature(*GetCaster(), instance->GetGuidData(DATA_ROTFACE))) - if (rotface->IsAlive()) - { - if (GetCaster()->GetTypeId() == TYPEID_UNIT) - GetCaster()->ToCreature()->AI()->Talk(EMOTE_UNSTABLE_EXPLOSION); - rotface->AI()->Talk(SAY_UNSTABLE_EXPLOSION); - } - - if (Creature* cre = GetCaster()->ToCreature()) - cre->AI()->DoAction(EVENT_STICKY_OOZE); - GetCaster()->CastSpell(GetCaster(), SPELL_UNSTABLE_OOZE_EXPLOSION, false, nullptr, nullptr, GetCaster()->GetGUID()); - if (InstanceScript* instance = GetCaster()->GetInstanceScript()) - instance->SetData(DATA_OOZE_DANCE_ACHIEVEMENT, uint32(false)); - } - } - - GetHitCreature()->RemoveAurasDueToSpell(SPELL_LITTLE_OOZE_COMBINE); - GetHitCreature()->DespawnOrUnsummon(); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_rotface_large_ooze_buff_combine_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void HandleCast(SpellEffIndex effIndex) { - return new spell_rotface_large_ooze_buff_combine_SpellScript(); + PreventHitEffect(effIndex); + if (!GetHitUnit()) + return; + + float x, y, z; + GetHitUnit()->GetPosition(x, y, z); + Creature* dummy = GetCaster()->SummonCreature(NPC_UNSTABLE_EXPLOSION_STALKER, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 60000); + GetCaster()->CastSpell(dummy, SPELL_UNSTABLE_OOZE_EXPLOSION_TRIGGER, true); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_rotface_unstable_ooze_explosion_init::HandleCast, EFFECT_0, SPELL_EFFECT_FORCE_CAST); } }; -class spell_rotface_unstable_ooze_explosion_init : public SpellScriptLoader +class spell_rotface_unstable_ooze_explosion : public SpellScript { -public: - spell_rotface_unstable_ooze_explosion_init() : SpellScriptLoader("spell_rotface_unstable_ooze_explosion_init") { } + PrepareSpellScript(spell_rotface_unstable_ooze_explosion); - class spell_rotface_unstable_ooze_explosion_init_SpellScript : public SpellScript + void CheckTarget(SpellEffIndex effIndex) { - PrepareSpellScript(spell_rotface_unstable_ooze_explosion_init_SpellScript); + PreventHitDefaultEffect(EFFECT_0); + if (!GetExplTargetDest()) + return; - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_UNSTABLE_OOZE_EXPLOSION_TRIGGER }); - } + uint32 triggered_spell_id = GetSpellInfo()->Effects[effIndex].TriggerSpell; - void HandleCast(SpellEffIndex effIndex) - { - PreventHitEffect(effIndex); - if (!GetHitUnit()) - return; + float x, y, z; + GetExplTargetDest()->GetPosition(x, y, z); + // let Rotface handle the cast - caster dies before this executes + if (InstanceScript* script = GetCaster()->GetInstanceScript()) + if (Creature* rotface = script->instance->GetCreature(script->GetGuidData(DATA_ROTFACE))) + rotface->CastSpell(x, y, z, triggered_spell_id, true/*, nullptr, nullptr, GetCaster()->GetGUID()*/); // caster not available on clientside, no log in such case + } - float x, y, z; - GetHitUnit()->GetPosition(x, y, z); - Creature* dummy = GetCaster()->SummonCreature(NPC_UNSTABLE_EXPLOSION_STALKER, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 60000); - GetCaster()->CastSpell(dummy, SPELL_UNSTABLE_OOZE_EXPLOSION_TRIGGER, true); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_rotface_unstable_ooze_explosion_init_SpellScript::HandleCast, EFFECT_0, SPELL_EFFECT_FORCE_CAST); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_rotface_unstable_ooze_explosion_init_SpellScript(); + OnEffectHit += SpellEffectFn(spell_rotface_unstable_ooze_explosion::CheckTarget, EFFECT_0, SPELL_EFFECT_TRIGGER_MISSILE); } }; -class spell_rotface_unstable_ooze_explosion : public SpellScriptLoader +class spell_rotface_unstable_ooze_explosion_suicide_aura : public AuraScript { -public: - spell_rotface_unstable_ooze_explosion() : SpellScriptLoader("spell_rotface_unstable_ooze_explosion") { } + PrepareAuraScript(spell_rotface_unstable_ooze_explosion_suicide_aura); - class spell_rotface_unstable_ooze_explosion_SpellScript : public SpellScript + void DespawnSelf(AuraEffect const* /*aurEff*/) { - PrepareSpellScript(spell_rotface_unstable_ooze_explosion_SpellScript); + PreventDefaultAction(); + Unit* target = GetTarget(); + if (target->GetTypeId() != TYPEID_UNIT) + return; - void CheckTarget(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(EFFECT_0); - if (!GetExplTargetDest()) - return; - - uint32 triggered_spell_id = GetSpellInfo()->Effects[effIndex].TriggerSpell; - - float x, y, z; - GetExplTargetDest()->GetPosition(x, y, z); - // let Rotface handle the cast - caster dies before this executes - if (InstanceScript* script = GetCaster()->GetInstanceScript()) - if (Creature* rotface = script->instance->GetCreature(script->GetGuidData(DATA_ROTFACE))) - rotface->CastSpell(x, y, z, triggered_spell_id, true/*, nullptr, nullptr, GetCaster()->GetGUID()*/); // caster not available on clientside, no log in such case - } - - void Register() override - { - OnEffectHit += SpellEffectFn(spell_rotface_unstable_ooze_explosion_SpellScript::CheckTarget, EFFECT_0, SPELL_EFFECT_TRIGGER_MISSILE); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_rotface_unstable_ooze_explosion_SpellScript(); + target->SetVisible(false); + target->RemoveAllAuras(); + //target->ToCreature()->DespawnOrUnsummon(); + target->ToCreature()->DespawnOrUnsummon(60000); } -}; -class spell_rotface_unstable_ooze_explosion_suicide : public SpellScriptLoader -{ -public: - spell_rotface_unstable_ooze_explosion_suicide() : SpellScriptLoader("spell_rotface_unstable_ooze_explosion_suicide") { } - - class spell_rotface_unstable_ooze_explosion_suicide_AuraScript : public AuraScript + void Register() override { - PrepareAuraScript(spell_rotface_unstable_ooze_explosion_suicide_AuraScript); - - void DespawnSelf(AuraEffect const* /*aurEff*/) - { - PreventDefaultAction(); - Unit* target = GetTarget(); - if (target->GetTypeId() != TYPEID_UNIT) - return; - - target->SetVisible(false); - target->RemoveAllAuras(); - //target->ToCreature()->DespawnOrUnsummon(); - target->ToCreature()->DespawnOrUnsummon(60000); - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_rotface_unstable_ooze_explosion_suicide_AuraScript::DespawnSelf, EFFECT_2, SPELL_AURA_PERIODIC_TRIGGER_SPELL); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_rotface_unstable_ooze_explosion_suicide_AuraScript(); + OnEffectPeriodic += AuraEffectPeriodicFn(spell_rotface_unstable_ooze_explosion_suicide_aura::DespawnSelf, EFFECT_2, SPELL_AURA_PERIODIC_TRIGGER_SPELL); } }; @@ -969,13 +903,13 @@ void AddSC_boss_rotface() new boss_rotface(); new npc_little_ooze(); new npc_big_ooze(); - new spell_rotface_mutated_infection(); - new spell_rotface_little_ooze_combine(); - new spell_rotface_large_ooze_combine(); - new spell_rotface_large_ooze_buff_combine(); - new spell_rotface_unstable_ooze_explosion_init(); - new spell_rotface_unstable_ooze_explosion(); - new spell_rotface_unstable_ooze_explosion_suicide(); + RegisterSpellAndAuraScriptPair(spell_rotface_mutated_infection, spell_rotface_mutated_infection_aura); + RegisterSpellScript(spell_rotface_little_ooze_combine); + RegisterSpellScript(spell_rotface_large_ooze_combine); + RegisterSpellScript(spell_rotface_large_ooze_buff_combine); + RegisterSpellScript(spell_rotface_unstable_ooze_explosion_init); + RegisterSpellScript(spell_rotface_unstable_ooze_explosion); + RegisterSpellScript(spell_rotface_unstable_ooze_explosion_suicide_aura); new npc_precious_icc(); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp index b9326859a..7f084643f 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp @@ -767,79 +767,69 @@ public: } }; -class spell_sindragosa_s_fury : public SpellScriptLoader +class spell_sindragosa_s_fury : public SpellScript { -public: - spell_sindragosa_s_fury() : SpellScriptLoader("spell_sindragosa_s_fury") { } + PrepareSpellScript(spell_sindragosa_s_fury); - class spell_sindragosa_s_fury_SpellScript : public SpellScript + bool Load() override { - PrepareSpellScript(spell_sindragosa_s_fury_SpellScript); + _targetCount = 0; - bool Load() override - { - _targetCount = 0; + // This script should execute only in Icecrown Citadel + if (InstanceMap* instance = GetCaster()->GetMap()->ToInstanceMap()) + if (instance->GetInstanceScript()) + if (instance->GetScriptId() == sObjectMgr->GetScriptId(ICCScriptName)) + return true; - // This script should execute only in Icecrown Citadel - if (InstanceMap* instance = GetCaster()->GetMap()->ToInstanceMap()) - if (instance->GetInstanceScript()) - if (instance->GetScriptId() == sObjectMgr->GetScriptId(ICCScriptName)) - return true; - - return false; - } - - void SelectDest() - { - if (Position* dest = const_cast(GetExplTargetDest())) - { - float destX = float(rand_norm()) * 75.0f + 4350.0f; - float destY = float(rand_norm()) * 75.0f + 2450.0f; - float destZ = 205.0f; // random number close to ground, get exact in next call - GetCaster()->UpdateGroundPositionZ(destX, destY, destZ); - dest->Relocate(destX, destY, destZ); - } - } - - void CountTargets(std::list& targets) - { - _targetCount = targets.size(); - } - - void HandleDummy(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - - if (!GetHitUnit()->IsAlive() || (GetHitUnit()->GetTypeId() == TYPEID_PLAYER && GetHitUnit()->ToPlayer()->IsGameMaster()) || !_targetCount) - return; - - float resistance = float(GetHitUnit()->GetResistance(SpellSchoolMask(GetSpellInfo()->SchoolMask))); - float ResistFactor = ((resistance * 2.0f) / (resistance + 510.0f)); - if (ResistFactor > 0.9f) - ResistFactor = 0.9f; - - uint32 damage = uint32( (GetEffectValue() / _targetCount) * (1.0f - ResistFactor) ); - - SpellNonMeleeDamage damageInfo(GetCaster(), GetHitUnit(), GetSpellInfo(), GetSpellInfo()->SchoolMask); - damageInfo.damage = damage; - GetCaster()->SendSpellNonMeleeDamageLog(&damageInfo); - GetCaster()->DealSpellDamage(&damageInfo, false); - } - - void Register() override - { - BeforeCast += SpellCastFn(spell_sindragosa_s_fury_SpellScript::SelectDest); - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_sindragosa_s_fury_SpellScript::CountTargets, EFFECT_1, TARGET_UNIT_DEST_AREA_ENTRY); - OnEffectHitTarget += SpellEffectFn(spell_sindragosa_s_fury_SpellScript::HandleDummy, EFFECT_1, SPELL_EFFECT_DUMMY); - } - - uint32 _targetCount; - }; - - SpellScript* GetSpellScript() const override - { - return new spell_sindragosa_s_fury_SpellScript(); + return false; } + + void SelectDest() + { + if (Position* dest = const_cast(GetExplTargetDest())) + { + float destX = float(rand_norm()) * 75.0f + 4350.0f; + float destY = float(rand_norm()) * 75.0f + 2450.0f; + float destZ = 205.0f; // random number close to ground, get exact in next call + GetCaster()->UpdateGroundPositionZ(destX, destY, destZ); + dest->Relocate(destX, destY, destZ); + } + } + + void CountTargets(std::list& targets) + { + _targetCount = targets.size(); + } + + void HandleDummy(SpellEffIndex effIndex) + { + PreventHitDefaultEffect(effIndex); + + if (!GetHitUnit()->IsAlive() || (GetHitUnit()->GetTypeId() == TYPEID_PLAYER && GetHitUnit()->ToPlayer()->IsGameMaster()) || !_targetCount) + return; + + float resistance = float(GetHitUnit()->GetResistance(SpellSchoolMask(GetSpellInfo()->SchoolMask))); + float ResistFactor = ((resistance * 2.0f) / (resistance + 510.0f)); + if (ResistFactor > 0.9f) + ResistFactor = 0.9f; + + uint32 damage = uint32( (GetEffectValue() / _targetCount) * (1.0f - ResistFactor) ); + + SpellNonMeleeDamage damageInfo(GetCaster(), GetHitUnit(), GetSpellInfo(), GetSpellInfo()->SchoolMask); + damageInfo.damage = damage; + GetCaster()->SendSpellNonMeleeDamageLog(&damageInfo); + GetCaster()->DealSpellDamage(&damageInfo, false); + } + + void Register() override + { + BeforeCast += SpellCastFn(spell_sindragosa_s_fury::SelectDest); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_sindragosa_s_fury::CountTargets, EFFECT_1, TARGET_UNIT_DEST_AREA_ENTRY); + OnEffectHitTarget += SpellEffectFn(spell_sindragosa_s_fury::HandleDummy, EFFECT_1, SPELL_EFFECT_DUMMY); + } + +private: + uint32 _targetCount; }; class UnchainedMagicTargetSelector @@ -895,170 +885,115 @@ class spell_sindragosa_unchained_magic : public SpellScript } }; -class spell_sindragosa_permeating_chill : public SpellScriptLoader +class spell_sindragosa_permeating_chill_aura : public AuraScript { -public: - spell_sindragosa_permeating_chill() : SpellScriptLoader("spell_sindragosa_permeating_chill") { } + PrepareAuraScript(spell_sindragosa_permeating_chill_aura); - class spell_sindragosa_permeating_chill_AuraScript : public AuraScript + bool CheckProc(ProcEventInfo& eventInfo) { - PrepareAuraScript(spell_sindragosa_permeating_chill_AuraScript); + return eventInfo.GetProcTarget() && eventInfo.GetProcTarget()->GetEntry() == NPC_SINDRAGOSA; + } - bool CheckProc(ProcEventInfo& eventInfo) - { - return eventInfo.GetProcTarget() && eventInfo.GetProcTarget()->GetEntry() == NPC_SINDRAGOSA; - } - - void Register() override - { - DoCheckProc += AuraCheckProcFn(spell_sindragosa_permeating_chill_AuraScript::CheckProc); - } - }; - - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_sindragosa_permeating_chill_AuraScript(); + DoCheckProc += AuraCheckProcFn(spell_sindragosa_permeating_chill_aura::CheckProc); } }; -class spell_sindragosa_instability : public SpellScriptLoader +class spell_sindragosa_instability_aura : public AuraScript { -public: - spell_sindragosa_instability() : SpellScriptLoader("spell_sindragosa_instability") { } + PrepareAuraScript(spell_sindragosa_instability_aura); - class spell_sindragosa_instability_AuraScript : public AuraScript + bool Validate(SpellInfo const* /*spell*/) override { - PrepareAuraScript(spell_sindragosa_instability_AuraScript); + return ValidateSpellInfo({ SPELL_BACKLASH }); + } - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_BACKLASH }); - } - - void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) - { - if (GetTargetApplication()->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE) - GetTarget()->CastCustomSpell(SPELL_BACKLASH, SPELLVALUE_BASE_POINT0, aurEff->GetAmount(), GetTarget(), true, nullptr, aurEff, GetCasterGUID()); - } - - void Register() override - { - AfterEffectRemove += AuraEffectRemoveFn(spell_sindragosa_instability_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - } - }; - - AuraScript* GetAuraScript() const override + void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) { - return new spell_sindragosa_instability_AuraScript(); + if (GetTargetApplication()->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE) + GetTarget()->CastCustomSpell(SPELL_BACKLASH, SPELLVALUE_BASE_POINT0, aurEff->GetAmount(), GetTarget(), true, nullptr, aurEff, GetCasterGUID()); + } + + void Register() override + { + AfterEffectRemove += AuraEffectRemoveFn(spell_sindragosa_instability_aura::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); } }; -class spell_sindragosa_icy_grip : public SpellScriptLoader +class spell_sindragosa_icy_grip : public SpellScript { -public: - spell_sindragosa_icy_grip() : SpellScriptLoader("spell_sindragosa_icy_grip") { } + PrepareSpellScript(spell_sindragosa_icy_grip); - class spell_sindragosa_icy_grip_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spell*/) override { - PrepareSpellScript(spell_sindragosa_icy_grip_SpellScript); + return ValidateSpellInfo({ SPELL_ICY_GRIP_JUMP }); + } - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_ICY_GRIP_JUMP }); - } - - void HandleScript(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - if (!GetHitUnit()->IsWithinLOSInMap(GetCaster()) || GetHitUnit()->HasAura(SPELL_TANK_MARKER_AURA)) - return; - - GetHitUnit()->CastSpell(GetCaster(), SPELL_ICY_GRIP_JUMP, true); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_sindragosa_icy_grip_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void HandleScript(SpellEffIndex effIndex) { - return new spell_sindragosa_icy_grip_SpellScript(); + PreventHitDefaultEffect(effIndex); + if (!GetHitUnit()->IsWithinLOSInMap(GetCaster()) || GetHitUnit()->HasAura(SPELL_TANK_MARKER_AURA)) + return; + + GetHitUnit()->CastSpell(GetCaster(), SPELL_ICY_GRIP_JUMP, true); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_sindragosa_icy_grip::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; -class spell_sindragosa_icy_grip_jump : public SpellScriptLoader +class spell_sindragosa_icy_grip_jump : public SpellScript { -public: - spell_sindragosa_icy_grip_jump() : SpellScriptLoader("spell_sindragosa_icy_grip_jump") { } + PrepareSpellScript(spell_sindragosa_icy_grip_jump); - class spell_sindragosa_icy_grip_jump_SpellScript : public SpellScript + void HandleSpecial(SpellEffIndex effIndex) { - PrepareSpellScript(spell_sindragosa_icy_grip_jump_SpellScript); + PreventHitDefaultEffect(effIndex); - void HandleSpecial(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); + float x = GetHitUnit()->GetPositionX(); + float y = GetHitUnit()->GetPositionY(); + float z = GetHitUnit()->GetPositionZ() + 0.1f; + float speedXY, speedZ; - float x = GetHitUnit()->GetPositionX(); - float y = GetHitUnit()->GetPositionY(); - float z = GetHitUnit()->GetPositionZ() + 0.1f; - float speedXY, speedZ; + if (GetSpellInfo()->Effects[effIndex].MiscValue) + speedZ = float(GetSpellInfo()->Effects[effIndex].MiscValue) / 10; + else if (GetSpellInfo()->Effects[effIndex].MiscValueB) + speedZ = float(GetSpellInfo()->Effects[effIndex].MiscValueB) / 10; + else + speedZ = 10.0f; + speedXY = GetCaster()->GetExactDist2d(x, y) * 10.0f / speedZ; - if (GetSpellInfo()->Effects[effIndex].MiscValue) - speedZ = float(GetSpellInfo()->Effects[effIndex].MiscValue) / 10; - else if (GetSpellInfo()->Effects[effIndex].MiscValueB) - speedZ = float(GetSpellInfo()->Effects[effIndex].MiscValueB) / 10; - else - speedZ = 10.0f; - speedXY = GetCaster()->GetExactDist2d(x, y) * 10.0f / speedZ; + GetCaster()->GetMotionMaster()->MoveJump(x, y, z, speedXY, speedZ); + } - GetCaster()->GetMotionMaster()->MoveJump(x, y, z, speedXY, speedZ); - } - - void Register() override - { - OnEffectLaunchTarget += SpellEffectFn(spell_sindragosa_icy_grip_jump_SpellScript::HandleSpecial, EFFECT_0, SPELL_EFFECT_JUMP); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_sindragosa_icy_grip_jump_SpellScript(); + OnEffectLaunchTarget += SpellEffectFn(spell_sindragosa_icy_grip_jump::HandleSpecial, EFFECT_0, SPELL_EFFECT_JUMP); } }; -class spell_sindragosa_frost_beacon : public SpellScriptLoader +class spell_sindragosa_frost_beacon_aura : public AuraScript { -public: - spell_sindragosa_frost_beacon() : SpellScriptLoader("spell_sindragosa_frost_beacon") { } + PrepareAuraScript(spell_sindragosa_frost_beacon_aura); - class spell_sindragosa_frost_beacon_AuraScript : public AuraScript + bool Validate(SpellInfo const* /*spell*/) override { - PrepareAuraScript(spell_sindragosa_frost_beacon_AuraScript); + return ValidateSpellInfo({ SPELL_ICE_TOMB_DAMAGE }); + } - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_ICE_TOMB_DAMAGE }); - } - - void PeriodicTick(AuraEffect const* /*aurEff*/) - { - PreventDefaultAction(); - if (Unit* caster = GetCaster()) - caster->CastSpell(GetTarget(), SPELL_ICE_TOMB_DAMAGE, true); - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_sindragosa_frost_beacon_AuraScript::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); - } - }; - - AuraScript* GetAuraScript() const override + void PeriodicTick(AuraEffect const* /*aurEff*/) { - return new spell_sindragosa_frost_beacon_AuraScript(); + PreventDefaultAction(); + if (Unit* caster = GetCaster()) + caster->CastSpell(GetTarget(), SPELL_ICE_TOMB_DAMAGE, true); + } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_sindragosa_frost_beacon_aura::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); } }; @@ -1076,109 +1011,88 @@ public: } }; -class spell_sindragosa_ice_tomb_filter : public SpellScriptLoader +class spell_sindragosa_ice_tomb_filter : public SpellScript { -public: - spell_sindragosa_ice_tomb_filter() : SpellScriptLoader("spell_sindragosa_ice_tomb_filter") { } + PrepareSpellScript(spell_sindragosa_ice_tomb_filter); - class spell_sindragosa_ice_tomb_filter_SpellScript : public SpellScript + void FilterTargets(std::list& unitList) { - PrepareSpellScript(spell_sindragosa_ice_tomb_filter_SpellScript); + unitList.remove_if(SindragosaIceTombCheck()); + } - void FilterTargets(std::list& unitList) - { - unitList.remove_if(SindragosaIceTombCheck()); - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_sindragosa_ice_tomb_filter_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_sindragosa_ice_tomb_filter_SpellScript(); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_sindragosa_ice_tomb_filter::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); } }; -class spell_sindragosa_ice_tomb : public SpellScriptLoader +class spell_sindragosa_ice_tomb_trap : public SpellScript { -public: - spell_sindragosa_ice_tomb() : SpellScriptLoader("spell_sindragosa_ice_tomb_trap") { } + PrepareSpellScript(spell_sindragosa_ice_tomb_trap); - class spell_sindragosa_ice_tomb_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spell*/) override { - PrepareSpellScript(spell_sindragosa_ice_tomb_SpellScript); - - std::list targetList; - - bool Validate(SpellInfo const* /*spell*/) override - { - if (!sObjectMgr->GetCreatureTemplate(NPC_ICE_TOMB)) - return false; - if (!sObjectMgr->GetGameObjectTemplate(GO_ICE_BLOCK)) - return false; - return true; - } - - void FilterTargets(std::list& unitList) - { - unitList.remove_if(Acore::UnitAuraCheck(true, GetSpellInfo()->Id)); - targetList.clear(); - targetList = unitList; - } - - void FilterTargetsSubseq(std::list& unitList) - { - unitList.clear(); - unitList = targetList; - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_sindragosa_ice_tomb_SpellScript::FilterTargets, EFFECT_1, TARGET_UNIT_DEST_AREA_ENEMY); - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_sindragosa_ice_tomb_SpellScript::FilterTargetsSubseq, EFFECT_2, TARGET_UNIT_DEST_AREA_ENEMY); - } - }; - - class spell_sindragosa_ice_tomb_AuraScript : public AuraScript - { - PrepareAuraScript(spell_sindragosa_ice_tomb_AuraScript); - - void PeriodicTick(AuraEffect const* /*aurEff*/) - { - PreventDefaultAction(); - } - - void AfterApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (Unit* c = GetCaster()) - GetTarget()->m_Events.AddEvent(new IceTombSummonEvent(GetTarget(), c->GetGUID()), GetTarget()->m_Events.CalculateTime(500)); - } - - void ExtraRemoveEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - GetTarget()->RemoveAurasDueToSpell(SPELL_ASPHYXIATION); - GetTarget()->RemoveAurasDueToSpell(SPELL_ICE_TOMB_UNTARGETABLE); - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_sindragosa_ice_tomb_AuraScript::PeriodicTick, EFFECT_2, SPELL_AURA_PERIODIC_TRIGGER_SPELL); - AfterEffectRemove += AuraEffectRemoveFn(spell_sindragosa_ice_tomb_AuraScript::ExtraRemoveEffect, EFFECT_1, SPELL_AURA_MOD_STUN, AURA_EFFECT_HANDLE_REAL); - AfterEffectApply += AuraEffectApplyFn(spell_sindragosa_ice_tomb_AuraScript::AfterApply, EFFECT_1, SPELL_AURA_MOD_STUN, AURA_EFFECT_HANDLE_REAL); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_sindragosa_ice_tomb_SpellScript(); + if (!sObjectMgr->GetCreatureTemplate(NPC_ICE_TOMB)) + return false; + if (!sObjectMgr->GetGameObjectTemplate(GO_ICE_BLOCK)) + return false; + return true; } - AuraScript* GetAuraScript() const override + void FilterTargets(std::list& unitList) { - return new spell_sindragosa_ice_tomb_AuraScript(); + unitList.remove_if(Acore::UnitAuraCheck(true, GetSpellInfo()->Id)); + _targetList.clear(); + _targetList = unitList; + } + + void FilterTargetsSubseq(std::list& unitList) + { + unitList.clear(); + unitList = _targetList; + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_sindragosa_ice_tomb_trap::FilterTargets, EFFECT_1, TARGET_UNIT_DEST_AREA_ENEMY); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_sindragosa_ice_tomb_trap::FilterTargetsSubseq, EFFECT_2, TARGET_UNIT_DEST_AREA_ENEMY); + } + +private: + std::list _targetList; +}; + +class spell_sindragosa_ice_tomb_trap_aura : public AuraScript +{ + PrepareAuraScript(spell_sindragosa_ice_tomb_trap_aura); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_ASPHYXIATION, SPELL_ICE_TOMB_UNTARGETABLE }); + } + + void PeriodicTick(AuraEffect const* /*aurEff*/) + { + PreventDefaultAction(); + } + + void AfterApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (Unit* c = GetCaster()) + GetTarget()->m_Events.AddEvent(new IceTombSummonEvent(GetTarget(), c->GetGUID()), GetTarget()->m_Events.CalculateTime(500)); + } + + void ExtraRemoveEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + GetTarget()->RemoveAurasDueToSpell(SPELL_ASPHYXIATION); + GetTarget()->RemoveAurasDueToSpell(SPELL_ICE_TOMB_UNTARGETABLE); + } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_sindragosa_ice_tomb_trap_aura::PeriodicTick, EFFECT_2, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + AfterEffectRemove += AuraEffectRemoveFn(spell_sindragosa_ice_tomb_trap_aura::ExtraRemoveEffect, EFFECT_1, SPELL_AURA_MOD_STUN, AURA_EFFECT_HANDLE_REAL); + AfterEffectApply += AuraEffectApplyFn(spell_sindragosa_ice_tomb_trap_aura::AfterApply, EFFECT_1, SPELL_AURA_MOD_STUN, AURA_EFFECT_HANDLE_REAL); } }; @@ -1208,63 +1122,46 @@ private: Unit* _caster; }; -class spell_sindragosa_mystic_buffet : public SpellScriptLoader +class spell_sindragosa_mystic_buffet : public SpellScript { -public: - spell_sindragosa_mystic_buffet() : SpellScriptLoader("spell_sindragosa_mystic_buffet") { } + PrepareSpellScript(spell_sindragosa_mystic_buffet); - class spell_sindragosa_mystic_buffet_SpellScript : public SpellScript + void FilterTargets(std::list& targets) { - PrepareSpellScript(spell_sindragosa_mystic_buffet_SpellScript); + targets.remove_if(MysticBuffetTargetFilter(GetCaster())); + } - void FilterTargets(std::list& targets) - { - targets.remove_if(MysticBuffetTargetFilter(GetCaster())); - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_sindragosa_mystic_buffet_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_sindragosa_mystic_buffet_SpellScript(); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_sindragosa_mystic_buffet::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); } }; -class spell_sindragosa_soul_preservation : public SpellScriptLoader +class spell_sindragosa_soul_preservation_aura : public AuraScript { -public: - spell_sindragosa_soul_preservation() : SpellScriptLoader("spell_sindragosa_soul_preservation") { } + PrepareAuraScript(spell_sindragosa_soul_preservation_aura); - class spell_sindragosa_soul_preservation_AuraScript : public AuraScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareAuraScript(spell_sindragosa_soul_preservation_AuraScript); + return ValidateSpellInfo({ 72466, 72424 }); + } - void PeriodicTick(AuraEffect const* /*aurEff*/) - { - PreventDefaultAction(); - if (Unit* s = GetTarget()) - if (GetStackAmount() >= (s->GetMap()->Is25ManRaid() ? 75 : 30)) - { - s->CastSpell(s, 72466, true); - s->RemoveAurasDueToSpell(72424); - if (s->GetTypeId() == TYPEID_UNIT) s->ToCreature()->SetLootMode(3); - SetDuration(1); - } - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_sindragosa_soul_preservation_AuraScript::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); - } - }; - - AuraScript* GetAuraScript() const override + void PeriodicTick(AuraEffect const* /*aurEff*/) { - return new spell_sindragosa_soul_preservation_AuraScript(); + PreventDefaultAction(); + if (Unit* s = GetTarget()) + if (GetStackAmount() >= (s->GetMap()->Is25ManRaid() ? 75 : 30)) + { + s->CastSpell(s, 72466, true); + s->RemoveAurasDueToSpell(72424); + if (s->GetTypeId() == TYPEID_UNIT) s->ToCreature()->SetLootMode(3); + SetDuration(1); + } + } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_sindragosa_soul_preservation_aura::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); } }; @@ -1597,37 +1494,26 @@ public: } }; -class spell_rimefang_icy_blast : public SpellScriptLoader +class spell_rimefang_icy_blast : public SpellScript { -public: - spell_rimefang_icy_blast() : SpellScriptLoader("spell_rimefang_icy_blast") { } + PrepareSpellScript(spell_rimefang_icy_blast); - class spell_rimefang_icy_blast_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spell*/) override { - PrepareSpellScript(spell_rimefang_icy_blast_SpellScript); + return ValidateSpellInfo({ SPELL_ICY_BLAST_AREA }); + } - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_ICY_BLAST_AREA }); - } - - void HandleTriggerMissile(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - if (Position const* pos = GetExplTargetDest()) - if (TempSummon* summon = GetCaster()->SummonCreature(NPC_ICY_BLAST, *pos, TEMPSUMMON_TIMED_DESPAWN, 40000)) - summon->CastSpell(summon, SPELL_ICY_BLAST_AREA, true); - } - - void Register() override - { - OnEffectHit += SpellEffectFn(spell_rimefang_icy_blast_SpellScript::HandleTriggerMissile, EFFECT_1, SPELL_EFFECT_TRIGGER_MISSILE); - } - }; - - SpellScript* GetSpellScript() const override + void HandleTriggerMissile(SpellEffIndex effIndex) { - return new spell_rimefang_icy_blast_SpellScript(); + PreventHitDefaultEffect(effIndex); + if (Position const* pos = GetExplTargetDest()) + if (TempSummon* summon = GetCaster()->SummonCreature(NPC_ICY_BLAST, *pos, TEMPSUMMON_TIMED_DESPAWN, 40000)) + summon->CastSpell(summon, SPELL_ICY_BLAST_AREA, true); + } + + void Register() override + { + OnEffectHit += SpellEffectFn(spell_rimefang_icy_blast::HandleTriggerMissile, EFFECT_1, SPELL_EFFECT_TRIGGER_MISSILE); } }; @@ -1800,154 +1686,121 @@ private: Creature* _owner; }; -class spell_frostwarden_handler_order_whelp : public SpellScriptLoader +class spell_frostwarden_handler_order_whelp : public SpellScript { -public: - spell_frostwarden_handler_order_whelp() : SpellScriptLoader("spell_frostwarden_handler_order_whelp") { } + PrepareSpellScript(spell_frostwarden_handler_order_whelp); - class spell_frostwarden_handler_order_whelp_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spell*/) override { - PrepareSpellScript(spell_frostwarden_handler_order_whelp_SpellScript); + return ValidateSpellInfo({ SPELL_FOCUS_FIRE }); + } - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_FOCUS_FIRE }); - } - - void FilterTargets(std::list& targets) - { - targets.remove_if(Acore::ObjectTypeIdCheck(TYPEID_PLAYER, false)); - if (targets.empty()) - return; - - WorldObject* target = Acore::Containers::SelectRandomContainerElement(targets); - targets.clear(); - targets.push_back(target); - } - - void HandleForcedCast(SpellEffIndex effIndex) - { - // caster is Frostwarden Handler, target is player, caster of triggered is whelp - PreventHitDefaultEffect(effIndex); - std::list unitList; - GetCreatureListWithEntryInGrid(unitList, GetCaster(), NPC_FROSTWING_WHELP, 150.0f); - if (Creature* creature = GetCaster()->ToCreature()) - unitList.remove_if(OrderWhelpTargetSelector(creature)); - - if (unitList.empty()) - return; - - Acore::Containers::SelectRandomContainerElement(unitList)->CastSpell(GetHitUnit(), uint32(GetEffectValue()), true); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_frostwarden_handler_order_whelp_SpellScript::HandleForcedCast, EFFECT_0, SPELL_EFFECT_FORCE_CAST); - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_frostwarden_handler_order_whelp_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ENEMY); - } - }; - - SpellScript* GetSpellScript() const override + void FilterTargets(std::list& targets) { - return new spell_frostwarden_handler_order_whelp_SpellScript(); + targets.remove_if(Acore::ObjectTypeIdCheck(TYPEID_PLAYER, false)); + if (targets.empty()) + return; + + WorldObject* target = Acore::Containers::SelectRandomContainerElement(targets); + targets.clear(); + targets.push_back(target); + } + + void HandleForcedCast(SpellEffIndex effIndex) + { + // caster is Frostwarden Handler, target is player, caster of triggered is whelp + PreventHitDefaultEffect(effIndex); + std::list unitList; + GetCreatureListWithEntryInGrid(unitList, GetCaster(), NPC_FROSTWING_WHELP, 150.0f); + if (Creature* creature = GetCaster()->ToCreature()) + unitList.remove_if(OrderWhelpTargetSelector(creature)); + + if (unitList.empty()) + return; + + Acore::Containers::SelectRandomContainerElement(unitList)->CastSpell(GetHitUnit(), uint32(GetEffectValue()), true); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_frostwarden_handler_order_whelp::HandleForcedCast, EFFECT_0, SPELL_EFFECT_FORCE_CAST); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_frostwarden_handler_order_whelp::FilterTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ENEMY); } }; -class spell_frostwarden_handler_focus_fire : public SpellScriptLoader +class spell_frostwarden_handler_focus_fire : public SpellScript { -public: - spell_frostwarden_handler_focus_fire() : SpellScriptLoader("spell_frostwarden_handler_focus_fire") { } + PrepareSpellScript(spell_frostwarden_handler_focus_fire); - class spell_frostwarden_handler_focus_fire_SpellScript : public SpellScript + void HandleScript(SpellEffIndex effIndex) { - PrepareSpellScript(spell_frostwarden_handler_focus_fire_SpellScript); - - void HandleScript(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - GetCaster()->AddThreat(GetHitUnit(), float(GetEffectValue())); - GetCaster()->GetAI()->SetData(DATA_WHELP_MARKER, 1); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_frostwarden_handler_focus_fire_SpellScript::HandleScript, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - class spell_frostwarden_handler_focus_fire_AuraScript : public AuraScript - { - PrepareAuraScript(spell_frostwarden_handler_focus_fire_AuraScript); - - void PeriodicTick(AuraEffect const* /*aurEff*/) - { - PreventDefaultAction(); - if (Unit* caster = GetCaster()) - { - caster->AddThreat(GetTarget(), -float(GetSpellInfo()->Effects[EFFECT_1].CalcValue())); - caster->GetAI()->SetData(DATA_WHELP_MARKER, 0); - } - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_frostwarden_handler_focus_fire_AuraScript::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_frostwarden_handler_focus_fire_SpellScript(); + PreventHitDefaultEffect(effIndex); + GetCaster()->AddThreat(GetHitUnit(), float(GetEffectValue())); + GetCaster()->GetAI()->SetData(DATA_WHELP_MARKER, 1); } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_frostwarden_handler_focus_fire_AuraScript(); + OnEffectHitTarget += SpellEffectFn(spell_frostwarden_handler_focus_fire::HandleScript, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT); } }; -class spell_sindragosa_frost_breath : public SpellScriptLoader +class spell_frostwarden_handler_focus_fire_aura : public AuraScript { -public: - spell_sindragosa_frost_breath() : SpellScriptLoader("spell_sindragosa_frost_breath") { } + PrepareAuraScript(spell_frostwarden_handler_focus_fire_aura); - class spell_sindragosa_frost_breath_SpellScript : public SpellScript + void PeriodicTick(AuraEffect const* /*aurEff*/) { - PrepareSpellScript(spell_sindragosa_frost_breath_SpellScript); - - void HandleInfusion() + PreventDefaultAction(); + if (Unit* caster = GetCaster()) { - Player* target = GetHitPlayer(); - if (!target) - return; - - // Check difficulty and quest status - if (!(target->GetRaidDifficulty() & RAID_DIFFICULTY_MASK_25MAN) || target->GetQuestStatus(QUEST_FROST_INFUSION) != QUEST_STATUS_INCOMPLETE) - return; - - // Check if player has Shadow's Edge equipped and not ready for infusion - if (!target->HasAura(SPELL_UNSATED_CRAVING) || target->HasAura(SPELL_FROST_IMBUED_BLADE)) - return; - - Aura* infusion = target->GetAura(SPELL_FROST_INFUSION, target->GetGUID()); - if (infusion && infusion->GetStackAmount() >= 3) - { - target->RemoveAura(infusion); - target->CastSpell(target, SPELL_FROST_IMBUED_BLADE, TRIGGERED_FULL_MASK); - } - else - target->CastSpell(target, SPELL_FROST_INFUSION, TRIGGERED_FULL_MASK); + caster->AddThreat(GetTarget(), -float(GetSpellInfo()->Effects[EFFECT_1].CalcValue())); + caster->GetAI()->SetData(DATA_WHELP_MARKER, 0); } + } - void Register() override - { - AfterHit += SpellHitFn(spell_sindragosa_frost_breath_SpellScript::HandleInfusion); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_sindragosa_frost_breath_SpellScript(); + OnEffectPeriodic += AuraEffectPeriodicFn(spell_frostwarden_handler_focus_fire_aura::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); + } +}; + +class spell_sindragosa_frost_breath : public SpellScript +{ + PrepareSpellScript(spell_sindragosa_frost_breath); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_UNSATED_CRAVING, SPELL_FROST_IMBUED_BLADE, SPELL_FROST_INFUSION }); + } + + void HandleInfusion() + { + Player* target = GetHitPlayer(); + if (!target) + return; + + // Check difficulty and quest status + if (!(target->GetRaidDifficulty() & RAID_DIFFICULTY_MASK_25MAN) || target->GetQuestStatus(QUEST_FROST_INFUSION) != QUEST_STATUS_INCOMPLETE) + return; + + // Check if player has Shadow's Edge equipped and not ready for infusion + if (!target->HasAura(SPELL_UNSATED_CRAVING) || target->HasAura(SPELL_FROST_IMBUED_BLADE)) + return; + + Aura* infusion = target->GetAura(SPELL_FROST_INFUSION, target->GetGUID()); + if (infusion && infusion->GetStackAmount() >= 3) + { + target->RemoveAura(infusion); + target->CastSpell(target, SPELL_FROST_IMBUED_BLADE, TRIGGERED_FULL_MASK); + } + else + target->CastSpell(target, SPELL_FROST_INFUSION, TRIGGERED_FULL_MASK); + } + + void Register() override + { + AfterHit += SpellHitFn(spell_sindragosa_frost_breath::HandleInfusion); } }; @@ -1955,29 +1808,29 @@ void AddSC_boss_sindragosa() { new boss_sindragosa(); new npc_ice_tomb(); - new spell_sindragosa_s_fury(); + RegisterSpellScript(spell_sindragosa_s_fury); RegisterSpellScript(spell_sindragosa_unchained_magic); - new spell_sindragosa_permeating_chill(); - new spell_sindragosa_instability(); - new spell_sindragosa_icy_grip(); - new spell_sindragosa_icy_grip_jump(); - new spell_sindragosa_ice_tomb_filter(); - new spell_trigger_spell_from_caster("spell_sindragosa_ice_tomb", SPELL_ICE_TOMB_DUMMY); - new spell_trigger_spell_from_caster("spell_sindragosa_ice_tomb_dummy", SPELL_FROST_BEACON); - new spell_sindragosa_frost_beacon(); - new spell_sindragosa_ice_tomb(); - new spell_sindragosa_mystic_buffet(); - new spell_sindragosa_soul_preservation(); + RegisterSpellScript(spell_sindragosa_permeating_chill_aura); + RegisterSpellScript(spell_sindragosa_instability_aura); + RegisterSpellScript(spell_sindragosa_icy_grip); + RegisterSpellScript(spell_sindragosa_icy_grip_jump); + RegisterSpellScript(spell_sindragosa_ice_tomb_filter); + RegisterSpellScriptWithArgs(spell_trigger_spell_from_caster, "spell_sindragosa_ice_tomb", SPELL_ICE_TOMB_DUMMY); + RegisterSpellScriptWithArgs(spell_trigger_spell_from_caster, "spell_sindragosa_ice_tomb_dummy", SPELL_FROST_BEACON); + RegisterSpellScript(spell_sindragosa_frost_beacon_aura); + RegisterSpellAndAuraScriptPair(spell_sindragosa_ice_tomb_trap, spell_sindragosa_ice_tomb_trap_aura); + RegisterSpellScript(spell_sindragosa_mystic_buffet); + RegisterSpellScript(spell_sindragosa_soul_preservation_aura); new achievement_all_you_can_eat(); new npc_spinestalker(); new npc_rimefang(); - new spell_rimefang_icy_blast(); + RegisterSpellScript(spell_rimefang_icy_blast); new at_sindragosa_lair(); new npc_sindragosa_trash(); - new spell_frostwarden_handler_order_whelp(); - new spell_frostwarden_handler_focus_fire(); + RegisterSpellScript(spell_frostwarden_handler_order_whelp); + RegisterSpellAndAuraScriptPair(spell_frostwarden_handler_focus_fire, spell_frostwarden_handler_focus_fire_aura); - new spell_sindragosa_frost_breath(); + RegisterSpellScript(spell_sindragosa_frost_breath); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp index 96ec7df6b..1a64dd1f6 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp @@ -1675,135 +1675,96 @@ public: } }; -class spell_the_lich_king_quake : public SpellScriptLoader +class spell_the_lich_king_quake : public SpellScript { -public: - spell_the_lich_king_quake() : SpellScriptLoader("spell_the_lich_king_quake") { } + PrepareSpellScript(spell_the_lich_king_quake); - class spell_the_lich_king_quake_SpellScript : public SpellScript + bool Load() override { - PrepareSpellScript(spell_the_lich_king_quake_SpellScript); + return GetCaster()->GetInstanceScript() != nullptr; + } - bool Load() override - { - return GetCaster()->GetInstanceScript() != nullptr; - } - - void FilterTargets(std::list& targets) - { - if (GameObject* platform = ObjectAccessor::GetGameObject(*GetCaster(), GetCaster()->GetInstanceScript()->GetGuidData(DATA_ARTHAS_PLATFORM))) - targets.remove_if(HeightDifferenceCheck(platform, 5.0f, false)); - } - - void HandleSendEvent(SpellEffIndex /*effIndex*/) - { - if (GetCaster()->IsAIEnabled) - GetCaster()->GetAI()->DoAction(ACTION_START_ATTACK); - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_the_lich_king_quake_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); - OnEffectHit += SpellEffectFn(spell_the_lich_king_quake_SpellScript::HandleSendEvent, EFFECT_1, SPELL_EFFECT_SEND_EVENT); - } - }; - - SpellScript* GetSpellScript() const override + void FilterTargets(std::list& targets) { - return new spell_the_lich_king_quake_SpellScript(); + if (GameObject* platform = ObjectAccessor::GetGameObject(*GetCaster(), GetCaster()->GetInstanceScript()->GetGuidData(DATA_ARTHAS_PLATFORM))) + targets.remove_if(HeightDifferenceCheck(platform, 5.0f, false)); + } + + void HandleSendEvent(SpellEffIndex /*effIndex*/) + { + if (GetCaster()->IsAIEnabled) + GetCaster()->GetAI()->DoAction(ACTION_START_ATTACK); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_the_lich_king_quake::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); + OnEffectHit += SpellEffectFn(spell_the_lich_king_quake::HandleSendEvent, EFFECT_1, SPELL_EFFECT_SEND_EVENT); } }; -class spell_the_lich_king_jump : public SpellScriptLoader +class spell_the_lich_king_jump : public SpellScript { -public: - spell_the_lich_king_jump() : SpellScriptLoader("spell_the_lich_king_jump") { } + PrepareSpellScript(spell_the_lich_king_jump); - class spell_the_lich_king_jump_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareSpellScript(spell_the_lich_king_jump_SpellScript); + return ValidateSpellInfo({ SPELL_RAISE_DEAD, SPELL_JUMP_2 }); + } - void HandleScript(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - GetHitUnit()->RemoveAurasDueToSpell(SPELL_RAISE_DEAD); - GetHitUnit()->InterruptNonMeleeSpells(true); - GetHitUnit()->CastSpell((Unit*)nullptr, SPELL_JUMP_2, true); - if (Creature* creature = GetHitCreature()) - creature->AI()->DoAction(ACTION_BREAK_FROSTMOURNE); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_the_lich_king_jump_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void HandleScript(SpellEffIndex effIndex) { - return new spell_the_lich_king_jump_SpellScript(); + PreventHitDefaultEffect(effIndex); + GetHitUnit()->RemoveAurasDueToSpell(SPELL_RAISE_DEAD); + GetHitUnit()->InterruptNonMeleeSpells(true); + GetHitUnit()->CastSpell((Unit*)nullptr, SPELL_JUMP_2, true); + if (Creature* creature = GetHitCreature()) + creature->AI()->DoAction(ACTION_BREAK_FROSTMOURNE); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_the_lich_king_jump::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; -class spell_the_lich_king_jump_remove_aura : public SpellScriptLoader +class spell_the_lich_king_jump_remove_aura : public SpellScript { -public: - spell_the_lich_king_jump_remove_aura() : SpellScriptLoader("spell_the_lich_king_jump_remove_aura") { } + PrepareSpellScript(spell_the_lich_king_jump_remove_aura); - class spell_the_lich_king_jump_SpellScript : public SpellScript + void HandleScript(SpellEffIndex effIndex) { - PrepareSpellScript(spell_the_lich_king_jump_SpellScript); + PreventHitDefaultEffect(effIndex); + GetHitUnit()->RemoveAurasDueToSpell(uint32(GetEffectValue())); + } - void HandleScript(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - GetHitUnit()->RemoveAurasDueToSpell(uint32(GetEffectValue())); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_the_lich_king_jump_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_the_lich_king_jump_SpellScript(); + OnEffectHitTarget += SpellEffectFn(spell_the_lich_king_jump_remove_aura::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; -class spell_the_lich_king_play_movie : public SpellScriptLoader +class spell_the_lich_king_play_movie : public SpellScript { -public: - spell_the_lich_king_play_movie() : SpellScriptLoader("spell_the_lich_king_play_movie") { } + PrepareSpellScript(spell_the_lich_king_play_movie); - class spell_the_lich_king_play_movie_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spell*/) override { - PrepareSpellScript(spell_the_lich_king_play_movie_SpellScript); + if (!sMovieStore.LookupEntry(MOVIE_FALL_OF_THE_LICH_KING)) + return false; + return true; + } - bool Validate(SpellInfo const* /*spell*/) override - { - if (!sMovieStore.LookupEntry(MOVIE_FALL_OF_THE_LICH_KING)) - return false; - return true; - } - - void HandleScript(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - if (Player* player = GetHitPlayer()) - player->SendMovieStart(MOVIE_FALL_OF_THE_LICH_KING); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_the_lich_king_play_movie_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void HandleScript(SpellEffIndex effIndex) { - return new spell_the_lich_king_play_movie_SpellScript(); + PreventHitDefaultEffect(effIndex); + if (Player* player = GetHitPlayer()) + player->SendMovieStart(MOVIE_FALL_OF_THE_LICH_KING); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_the_lich_king_play_movie::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; @@ -1879,329 +1840,275 @@ public: } }; -class spell_the_lich_king_infest : public SpellScriptLoader +class spell_the_lich_king_infest_aura : public AuraScript { -public: - spell_the_lich_king_infest() : SpellScriptLoader("spell_the_lich_king_infest") { } + PrepareAuraScript(spell_the_lich_king_infest_aura); - class spell_the_lich_king_infest_AuraScript : public AuraScript + void OnPeriodic(AuraEffect const* /*aurEff*/) { - PrepareAuraScript(spell_the_lich_king_infest_AuraScript); - - void OnPeriodic(AuraEffect const* /*aurEff*/) + if (GetUnitOwner()->HealthAbovePct(90)) { - if (GetUnitOwner()->HealthAbovePct(90)) - { - PreventDefaultAction(); - Remove(AURA_REMOVE_BY_ENEMY_SPELL); - } - } - - void OnUpdate(AuraEffect* aurEff) - { - // multiply, starting from 2nd tick - if (aurEff->GetTickNumber() == 1) - return; - - aurEff->SetAmount(int32(aurEff->GetAmount() * 1.15f)); - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_the_lich_king_infest_AuraScript::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE); - OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_the_lich_king_infest_AuraScript::OnUpdate, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_the_lich_king_infest_AuraScript(); - } -}; - -class spell_the_lich_king_necrotic_plague : public SpellScriptLoader -{ -public: - spell_the_lich_king_necrotic_plague() : SpellScriptLoader("spell_the_lich_king_necrotic_plague") { } - - class spell_the_lich_king_necrotic_plague_AuraScript : public AuraScript - { - PrepareAuraScript(spell_the_lich_king_necrotic_plague_AuraScript); - - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_NECROTIC_PLAGUE_JUMP }); - } - - void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - bool dispel = false; - switch (GetTargetApplication()->GetRemoveMode()) - { - case AURA_REMOVE_BY_ENEMY_SPELL: - dispel = true; - case AURA_REMOVE_BY_EXPIRE: - case AURA_REMOVE_BY_DEATH: - break; - default: - return; - } - - CustomSpellValues values; - if (dispel) - values.AddSpellMod(SPELLVALUE_BASE_POINT1, AURA_REMOVE_BY_ENEMY_SPELL); // add as marker (spell has no effect 1) - GetTarget()->CastCustomSpell(SPELL_NECROTIC_PLAGUE_JUMP, values, nullptr, TRIGGERED_FULL_MASK, nullptr, nullptr, GetCasterGUID()); - - if (Unit* caster = GetCaster()) - caster->CastSpell(caster, SPELL_PLAGUE_SIPHON, true); - } - - void Register() override - { - AfterEffectRemove += AuraEffectRemoveFn(spell_the_lich_king_necrotic_plague_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAL); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_the_lich_king_necrotic_plague_AuraScript(); - } -}; - -class spell_the_lich_king_necrotic_plague_jump : public SpellScriptLoader -{ -public: - spell_the_lich_king_necrotic_plague_jump() : SpellScriptLoader("spell_the_lich_king_necrotic_plague_jump") { } - - class spell_the_lich_king_necrotic_plague_SpellScript : public SpellScript - { - PrepareSpellScript(spell_the_lich_king_necrotic_plague_SpellScript); - - bool Load() override - { - _hadJumpingAura = false; - _hadInitialAura = false; - return true; - } - - void FilterTargets(std::list& targets) - { - targets.sort(Acore::ObjectDistanceOrderPred(GetCaster())); - if (targets.size() <= 1) - return; - - targets.resize(1); - } - - void CheckAura(SpellMissInfo missInfo) - { - if (missInfo != SPELL_MISS_NONE) - { - return; - } - - if (GetHitUnit()->HasAura(GetSpellInfo()->Id)) - _hadJumpingAura = true; - else if (uint32 spellId = sSpellMgr->GetSpellIdForDifficulty(SPELL_NECROTIC_PLAGUE, GetHitUnit())) - if (GetHitUnit()->HasAura(spellId)) - _hadInitialAura = true; - } - - void AddMissingStack() - { - if (GetHitAura() && !_hadJumpingAura) - { - uint32 spellId = sSpellMgr->GetSpellIdForDifficulty(SPELL_NECROTIC_PLAGUE, GetHitUnit()); - if (GetSpellValue()->EffectBasePoints[EFFECT_1] != AURA_REMOVE_BY_ENEMY_SPELL || _hadInitialAura) - GetHitAura()->ModStackAmount(1); - if (_hadInitialAura) - if (Aura* a = GetHitUnit()->GetAura(spellId)) - a->Remove(AURA_REMOVE_BY_DEFAULT); - } - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_the_lich_king_necrotic_plague_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); - BeforeHit += BeforeSpellHitFn(spell_the_lich_king_necrotic_plague_SpellScript::CheckAura); - OnHit += SpellHitFn(spell_the_lich_king_necrotic_plague_SpellScript::AddMissingStack); - } - - bool _hadJumpingAura; - bool _hadInitialAura; - }; - - class spell_the_lich_king_necrotic_plague_AuraScript : public AuraScript - { - PrepareAuraScript(spell_the_lich_king_necrotic_plague_AuraScript); - - bool Load() override - { - _lastAmount = 0; - return true; - } - - void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (Unit* caster = GetCaster()) - if (caster->GetAI()) - caster->GetAI()->SetData(DATA_PLAGUE_STACK, GetStackAmount()); - } - - void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) - { - _lastAmount = aurEff->GetAmount(); - switch (GetTargetApplication()->GetRemoveMode()) - { - case AURA_REMOVE_BY_EXPIRE: - case AURA_REMOVE_BY_DEATH: - break; - default: - return; - } - - CustomSpellValues values; - values.AddSpellMod(SPELLVALUE_AURA_STACK, GetStackAmount()); - GetTarget()->CastCustomSpell(SPELL_NECROTIC_PLAGUE_JUMP, values, nullptr, TRIGGERED_FULL_MASK, nullptr, nullptr, GetCasterGUID()); - if (Unit* caster = GetCaster()) - caster->CastSpell(caster, SPELL_PLAGUE_SIPHON, true); - } - - void OnDispel(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) - { - _lastAmount = aurEff->GetAmount(); - } - - void AfterDispel(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) - { - // this means the stack increased so don't process as if dispelled - if (aurEff->GetAmount() > _lastAmount) - return; - - CustomSpellValues values; - values.AddSpellMod(SPELLVALUE_AURA_STACK, GetStackAmount()); - values.AddSpellMod(SPELLVALUE_BASE_POINT1, AURA_REMOVE_BY_ENEMY_SPELL); // add as marker (spell has no effect 1) - GetTarget()->CastCustomSpell(SPELL_NECROTIC_PLAGUE_JUMP, values, nullptr, TRIGGERED_FULL_MASK, nullptr, nullptr, GetCasterGUID()); - if (Unit* caster = GetCaster()) - caster->CastSpell(caster, SPELL_PLAGUE_SIPHON, true); - + PreventDefaultAction(); Remove(AURA_REMOVE_BY_ENEMY_SPELL); } - - void Register() override - { - OnEffectApply += AuraEffectApplyFn(spell_the_lich_king_necrotic_plague_AuraScript::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); - AfterEffectRemove += AuraEffectRemoveFn(spell_the_lich_king_necrotic_plague_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAL); - AfterEffectRemove += AuraEffectRemoveFn(spell_the_lich_king_necrotic_plague_AuraScript::OnDispel, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAPPLY); - AfterEffectApply += AuraEffectApplyFn(spell_the_lich_king_necrotic_plague_AuraScript::AfterDispel, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAPPLY); - } - - int32 _lastAmount; - }; - - SpellScript* GetSpellScript() const override - { - return new spell_the_lich_king_necrotic_plague_SpellScript(); } - AuraScript* GetAuraScript() const override + void OnUpdate(AuraEffect* aurEff) { - return new spell_the_lich_king_necrotic_plague_AuraScript(); + // multiply, starting from 2nd tick + if (aurEff->GetTickNumber() == 1) + return; + + aurEff->SetAmount(int32(aurEff->GetAmount() * 1.15f)); + } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_the_lich_king_infest_aura::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE); + OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_the_lich_king_infest_aura::OnUpdate, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE); } }; -class spell_the_lich_king_shadow_trap_visual : public SpellScriptLoader +class spell_the_lich_king_necrotic_plague_aura : public AuraScript { -public: - spell_the_lich_king_shadow_trap_visual() : SpellScriptLoader("spell_the_lich_king_shadow_trap_visual") { } + PrepareAuraScript(spell_the_lich_king_necrotic_plague_aura); - class spell_the_lich_king_shadow_trap_visual_AuraScript : public AuraScript + bool Validate(SpellInfo const* /*spell*/) override { - PrepareAuraScript(spell_the_lich_king_shadow_trap_visual_AuraScript); - - void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (GetTargetApplication()->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE) - GetTarget()->CastSpell(GetTarget(), SPELL_SHADOW_TRAP_AURA, TRIGGERED_NONE); - } - - void Register() override - { - AfterEffectRemove += AuraEffectRemoveFn(spell_the_lich_king_shadow_trap_visual_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_the_lich_king_shadow_trap_visual_AuraScript(); + return ValidateSpellInfo({ SPELL_NECROTIC_PLAGUE_JUMP }); } -}; -class spell_the_lich_king_shadow_trap_periodic : public SpellScriptLoader -{ -public: - spell_the_lich_king_shadow_trap_periodic() : SpellScriptLoader("spell_the_lich_king_shadow_trap_periodic") { } - - class spell_the_lich_king_shadow_trap_periodic_SpellScript : public SpellScript + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - PrepareSpellScript(spell_the_lich_king_shadow_trap_periodic_SpellScript); - - void CheckTargetCount(std::list& targets) + bool dispel = false; + switch (GetTargetApplication()->GetRemoveMode()) { - if (targets.empty()) + case AURA_REMOVE_BY_ENEMY_SPELL: + dispel = true; + case AURA_REMOVE_BY_EXPIRE: + case AURA_REMOVE_BY_DEATH: + break; + default: return; - - GetCaster()->CastSpell((Unit*)nullptr, SPELL_SHADOW_TRAP_KNOCKBACK, true); - if (Aura* a = GetCaster()->GetAura(SPELL_SHADOW_TRAP_AURA)) - a->SetDuration(0); - if (GetCaster()->GetTypeId() == TYPEID_UNIT) - GetCaster()->ToCreature()->DespawnOrUnsummon(3000); } - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_the_lich_king_shadow_trap_periodic_SpellScript::CheckTargetCount, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - } - }; + CustomSpellValues values; + if (dispel) + values.AddSpellMod(SPELLVALUE_BASE_POINT1, AURA_REMOVE_BY_ENEMY_SPELL); // add as marker (spell has no effect 1) + GetTarget()->CastCustomSpell(SPELL_NECROTIC_PLAGUE_JUMP, values, nullptr, TRIGGERED_FULL_MASK, nullptr, nullptr, GetCasterGUID()); - SpellScript* GetSpellScript() const override + if (Unit* caster = GetCaster()) + caster->CastSpell(caster, SPELL_PLAGUE_SIPHON, true); + } + + void Register() override { - return new spell_the_lich_king_shadow_trap_periodic_SpellScript(); + AfterEffectRemove += AuraEffectRemoveFn(spell_the_lich_king_necrotic_plague_aura::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAL); } }; -class spell_the_lich_king_ice_burst_target_search : public SpellScriptLoader +class spell_the_lich_king_necrotic_plague_jump : public SpellScript { -public: - spell_the_lich_king_ice_burst_target_search() : SpellScriptLoader("spell_the_lich_king_ice_burst_target_search") { } + PrepareSpellScript(spell_the_lich_king_necrotic_plague_jump); - class spell_the_lich_king_ice_burst_target_search_SpellScript : public SpellScript + bool Load() override { - PrepareSpellScript(spell_the_lich_king_ice_burst_target_search_SpellScript); + _hadJumpingAura = false; + _hadInitialAura = false; + return true; + } - bool Validate(SpellInfo const* /*spell*/) override + void FilterTargets(std::list& targets) + { + targets.sort(Acore::ObjectDistanceOrderPred(GetCaster())); + if (targets.size() <= 1) + return; + + targets.resize(1); + } + + void CheckAura(SpellMissInfo missInfo) + { + if (missInfo != SPELL_MISS_NONE) { - return ValidateSpellInfo({ SPELL_ICE_BURST }); + return; } - void CheckTargetCount(std::list& unitList) + if (GetHitUnit()->HasAura(GetSpellInfo()->Id)) + _hadJumpingAura = true; + else if (uint32 spellId = sSpellMgr->GetSpellIdForDifficulty(SPELL_NECROTIC_PLAGUE, GetHitUnit())) + if (GetHitUnit()->HasAura(spellId)) + _hadInitialAura = true; + } + + void AddMissingStack() + { + if (GetHitAura() && !_hadJumpingAura) { - if (unitList.empty()) + uint32 spellId = sSpellMgr->GetSpellIdForDifficulty(SPELL_NECROTIC_PLAGUE, GetHitUnit()); + if (GetSpellValue()->EffectBasePoints[EFFECT_1] != AURA_REMOVE_BY_ENEMY_SPELL || _hadInitialAura) + GetHitAura()->ModStackAmount(1); + if (_hadInitialAura) + if (Aura* a = GetHitUnit()->GetAura(spellId)) + a->Remove(AURA_REMOVE_BY_DEFAULT); + } + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_the_lich_king_necrotic_plague_jump::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); + BeforeHit += BeforeSpellHitFn(spell_the_lich_king_necrotic_plague_jump::CheckAura); + OnHit += SpellHitFn(spell_the_lich_king_necrotic_plague_jump::AddMissingStack); + } + +private: + bool _hadJumpingAura; + bool _hadInitialAura; +}; + +class spell_the_lich_king_necrotic_plague_jump_aura : public AuraScript +{ + PrepareAuraScript(spell_the_lich_king_necrotic_plague_jump_aura); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_NECROTIC_PLAGUE_JUMP, SPELL_PLAGUE_SIPHON }); + } + + bool Load() override + { + _lastAmount = 0; + return true; + } + + void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (Unit* caster = GetCaster()) + if (caster->GetAI()) + caster->GetAI()->SetData(DATA_PLAGUE_STACK, GetStackAmount()); + } + + void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) + { + _lastAmount = aurEff->GetAmount(); + switch (GetTargetApplication()->GetRemoveMode()) + { + case AURA_REMOVE_BY_EXPIRE: + case AURA_REMOVE_BY_DEATH: + break; + default: return; - - if (GetCaster()->GetTypeId() == TYPEID_UNIT) - GetCaster()->ToCreature()->AI()->DoAction(-1); } - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_the_lich_king_ice_burst_target_search_SpellScript::CheckTargetCount, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - } - }; + CustomSpellValues values; + values.AddSpellMod(SPELLVALUE_AURA_STACK, GetStackAmount()); + GetTarget()->CastCustomSpell(SPELL_NECROTIC_PLAGUE_JUMP, values, nullptr, TRIGGERED_FULL_MASK, nullptr, nullptr, GetCasterGUID()); + if (Unit* caster = GetCaster()) + caster->CastSpell(caster, SPELL_PLAGUE_SIPHON, true); + } - SpellScript* GetSpellScript() const override + void OnDispel(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) { - return new spell_the_lich_king_ice_burst_target_search_SpellScript(); + _lastAmount = aurEff->GetAmount(); + } + + void AfterDispel(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) + { + // this means the stack increased so don't process as if dispelled + if (aurEff->GetAmount() > _lastAmount) + return; + + CustomSpellValues values; + values.AddSpellMod(SPELLVALUE_AURA_STACK, GetStackAmount()); + values.AddSpellMod(SPELLVALUE_BASE_POINT1, AURA_REMOVE_BY_ENEMY_SPELL); // add as marker (spell has no effect 1) + GetTarget()->CastCustomSpell(SPELL_NECROTIC_PLAGUE_JUMP, values, nullptr, TRIGGERED_FULL_MASK, nullptr, nullptr, GetCasterGUID()); + if (Unit* caster = GetCaster()) + caster->CastSpell(caster, SPELL_PLAGUE_SIPHON, true); + + Remove(AURA_REMOVE_BY_ENEMY_SPELL); + } + + void Register() override + { + OnEffectApply += AuraEffectApplyFn(spell_the_lich_king_necrotic_plague_jump_aura::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); + AfterEffectRemove += AuraEffectRemoveFn(spell_the_lich_king_necrotic_plague_jump_aura::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAL); + AfterEffectRemove += AuraEffectRemoveFn(spell_the_lich_king_necrotic_plague_jump_aura::OnDispel, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAPPLY); + AfterEffectApply += AuraEffectApplyFn(spell_the_lich_king_necrotic_plague_jump_aura::AfterDispel, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAPPLY); + } + +private: + int32 _lastAmount; +}; + +class spell_the_lich_king_shadow_trap_visual_aura : public AuraScript +{ + PrepareAuraScript(spell_the_lich_king_shadow_trap_visual_aura); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_SHADOW_TRAP_AURA }); + } + + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (GetTargetApplication()->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE) + GetTarget()->CastSpell(GetTarget(), SPELL_SHADOW_TRAP_AURA, TRIGGERED_NONE); + } + + void Register() override + { + AfterEffectRemove += AuraEffectRemoveFn(spell_the_lich_king_shadow_trap_visual_aura::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + } +}; + +class spell_the_lich_king_shadow_trap_periodic : public SpellScript +{ + PrepareSpellScript(spell_the_lich_king_shadow_trap_periodic); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_SHADOW_TRAP_KNOCKBACK }); + } + + void CheckTargetCount(std::list& targets) + { + if (targets.empty()) + return; + + GetCaster()->CastSpell((Unit*)nullptr, SPELL_SHADOW_TRAP_KNOCKBACK, true); + if (Aura* a = GetCaster()->GetAura(SPELL_SHADOW_TRAP_AURA)) + a->SetDuration(0); + if (GetCaster()->GetTypeId() == TYPEID_UNIT) + GetCaster()->ToCreature()->DespawnOrUnsummon(3000); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_the_lich_king_shadow_trap_periodic::CheckTargetCount, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + } +}; + +class spell_the_lich_king_ice_burst_target_search : public SpellScript +{ + PrepareSpellScript(spell_the_lich_king_ice_burst_target_search); + + bool Validate(SpellInfo const* /*spell*/) override + { + return ValidateSpellInfo({ SPELL_ICE_BURST }); + } + + void CheckTargetCount(std::list& unitList) + { + if (unitList.empty()) + return; + + if (GetCaster()->GetTypeId() == TYPEID_UNIT) + GetCaster()->ToCreature()->AI()->DoAction(-1); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_the_lich_king_ice_burst_target_search::CheckTargetCount, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); } }; @@ -2283,31 +2190,20 @@ public: } }; -class spell_the_lich_king_raging_spirit : public SpellScriptLoader +class spell_the_lich_king_raging_spirit : public SpellScript { -public: - spell_the_lich_king_raging_spirit() : SpellScriptLoader("spell_the_lich_king_raging_spirit") { } + PrepareSpellScript(spell_the_lich_king_raging_spirit); - class spell_the_lich_king_raging_spirit_SpellScript : public SpellScript + void HandleScript(SpellEffIndex effIndex) { - PrepareSpellScript(spell_the_lich_king_raging_spirit_SpellScript); + PreventHitDefaultEffect(effIndex); + if (Unit* target = GetHitUnit()) + target->CastSpell(target, uint32(GetEffectValue()), true, 0, 0, target->GetGUID()); + } - void HandleScript(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - if (Unit* target = GetHitUnit()) - target->CastSpell(target, uint32(GetEffectValue()), true, 0, 0, target->GetGUID()); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_the_lich_king_raging_spirit_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_the_lich_king_raging_spirit_SpellScript(); + OnEffectHitTarget += SpellEffectFn(spell_the_lich_king_raging_spirit::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; @@ -2444,75 +2340,58 @@ public: } }; -class spell_the_lich_king_defile : public SpellScriptLoader +class spell_the_lich_king_defile : public SpellScript { -public: - spell_the_lich_king_defile() : SpellScriptLoader("spell_the_lich_king_defile") { } + PrepareSpellScript(spell_the_lich_king_defile); - class spell_the_lich_king_defile_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareSpellScript(spell_the_lich_king_defile_SpellScript); + return ValidateSpellInfo({ SPELL_DEFILE_GROW }); + } - void CorrectRange(std::list& targets) - { - targets.remove_if(VehicleCheck()); - targets.remove_if(Acore::AllWorldObjectsInExactRange(GetCaster(), 10.0f * GetCaster()->GetFloatValue(OBJECT_FIELD_SCALE_X), true)); - uint32 strangulatedAura[4] = {68980, 74325, 74296, 74297}; - targets.remove_if(Acore::UnitAuraCheck(true, strangulatedAura[GetCaster()->GetMap()->GetDifficulty()])); - } - - void ChangeDamageAndGrow() - { - SetHitDamage(int32(GetHitDamage() * GetCaster()->GetFloatValue(OBJECT_FIELD_SCALE_X))); - // HACK: target player should cast this spell on defile - // however with current aura handling auras cast by different units - // cannot stack on the same aura object increasing the stack count - GetCaster()->CastSpell(GetCaster(), SPELL_DEFILE_GROW, true); - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_the_lich_king_defile_SpellScript::CorrectRange, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_the_lich_king_defile_SpellScript::CorrectRange, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY); - OnHit += SpellHitFn(spell_the_lich_king_defile_SpellScript::ChangeDamageAndGrow); - } - }; - - SpellScript* GetSpellScript() const override + void CorrectRange(std::list& targets) { - return new spell_the_lich_king_defile_SpellScript(); + targets.remove_if(VehicleCheck()); + targets.remove_if(Acore::AllWorldObjectsInExactRange(GetCaster(), 10.0f * GetCaster()->GetFloatValue(OBJECT_FIELD_SCALE_X), true)); + uint32 strangulatedAura[4] = {68980, 74325, 74296, 74297}; + targets.remove_if(Acore::UnitAuraCheck(true, strangulatedAura[GetCaster()->GetMap()->GetDifficulty()])); + } + + void ChangeDamageAndGrow() + { + SetHitDamage(int32(GetHitDamage() * GetCaster()->GetFloatValue(OBJECT_FIELD_SCALE_X))); + // HACK: target player should cast this spell on defile + // however with current aura handling auras cast by different units + // cannot stack on the same aura object increasing the stack count + GetCaster()->CastSpell(GetCaster(), SPELL_DEFILE_GROW, true); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_the_lich_king_defile::CorrectRange, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_the_lich_king_defile::CorrectRange, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY); + OnHit += SpellHitFn(spell_the_lich_king_defile::ChangeDamageAndGrow); } }; -class spell_the_lich_king_soul_reaper : public SpellScriptLoader +class spell_the_lich_king_soul_reaper_aura : public AuraScript { -public: - spell_the_lich_king_soul_reaper() : SpellScriptLoader("spell_the_lich_king_soul_reaper") { } + PrepareAuraScript(spell_the_lich_king_soul_reaper_aura); - class spell_the_lich_king_soul_reaper_AuraScript : public AuraScript + bool Validate(SpellInfo const* /*spell*/) override { - PrepareAuraScript(spell_the_lich_king_soul_reaper_AuraScript); + return ValidateSpellInfo({ SPELL_SOUL_REAPER_BUFF }); + } - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_SOUL_REAPER_BUFF }); - } - - void OnPeriodic(AuraEffect const* /*aurEff*/) - { - if (Unit* caster = GetCaster()) - GetTarget()->CastSpell(caster, SPELL_SOUL_REAPER_BUFF, true); - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_the_lich_king_soul_reaper_AuraScript::OnPeriodic, EFFECT_1, SPELL_AURA_PERIODIC_DAMAGE); - } - }; - - AuraScript* GetAuraScript() const override + void OnPeriodic(AuraEffect const* /*aurEff*/) { - return new spell_the_lich_king_soul_reaper_AuraScript(); + if (Unit* caster = GetCaster()) + GetTarget()->CastSpell(caster, SPELL_SOUL_REAPER_BUFF, true); + } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_the_lich_king_soul_reaper_aura::OnPeriodic, EFFECT_1, SPELL_AURA_PERIODIC_DAMAGE); } }; @@ -2725,395 +2604,297 @@ public: } }; -class spell_the_lich_king_summon_into_air : public SpellScriptLoader +class spell_the_lich_king_summon_into_air : public SpellScript { -public: - spell_the_lich_king_summon_into_air() : SpellScriptLoader("spell_the_lich_king_summon_into_air") { } + PrepareSpellScript(spell_the_lich_king_summon_into_air); - class spell_the_lich_king_summon_into_air_SpellScript : public SpellScript + void ModDestHeight(SpellEffIndex effIndex) { - PrepareSpellScript(spell_the_lich_king_summon_into_air_SpellScript); - - void ModDestHeight(SpellEffIndex effIndex) + float addZ; + switch (GetSpellInfo()->Effects[effIndex].MiscValue) { - float addZ; - switch (GetSpellInfo()->Effects[effIndex].MiscValue) - { - case NPC_SPIRIT_BOMB: - addZ = 30.0f; - break; - case NPC_VILE_SPIRIT: - addZ = 13.0f; - break; - default: - addZ = 15.0f; - break; - } - Position const offset = {0.0f, 0.0f, addZ, 0.0f}; - WorldLocation* dest = const_cast(GetExplTargetDest()); - dest->RelocateOffset(offset); - GetHitDest()->RelocateOffset(offset); + case NPC_SPIRIT_BOMB: + addZ = 30.0f; + break; + case NPC_VILE_SPIRIT: + addZ = 13.0f; + break; + default: + addZ = 15.0f; + break; } + Position const offset = {0.0f, 0.0f, addZ, 0.0f}; + WorldLocation* dest = const_cast(GetExplTargetDest()); + dest->RelocateOffset(offset); + GetHitDest()->RelocateOffset(offset); + } - void Register() override - { - OnEffectHit += SpellEffectFn(spell_the_lich_king_summon_into_air_SpellScript::ModDestHeight, EFFECT_0, SPELL_EFFECT_SUMMON); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_the_lich_king_summon_into_air_SpellScript(); + OnEffectHit += SpellEffectFn(spell_the_lich_king_summon_into_air::ModDestHeight, EFFECT_0, SPELL_EFFECT_SUMMON); } }; -class spell_the_lich_king_teleport_to_frostmourne_hc : public SpellScriptLoader +class spell_the_lich_king_teleport_to_frostmourne_hc : public SpellScript { -public: - spell_the_lich_king_teleport_to_frostmourne_hc() : SpellScriptLoader("spell_the_lich_king_teleport_to_frostmourne_hc") { } + PrepareSpellScript(spell_the_lich_king_teleport_to_frostmourne_hc); - class spell_the_lich_king_teleport_to_frostmourne_hc_SpellScript : public SpellScript + void ModDest(SpellEffIndex /*effIndex*/) { - PrepareSpellScript(spell_the_lich_king_teleport_to_frostmourne_hc_SpellScript); + float dist = 2.0f + rand_norm() * 18.0f; + float angle = rand_norm() * 2 * M_PI; + Position const offset = {dist * cos(angle), dist * std::sin(angle), 0.0f, 0.0f}; + WorldLocation* dest = const_cast(GetExplTargetDest()); + dest->RelocateOffset(offset); + GetHitDest()->RelocateOffset(offset); + } - void ModDest(SpellEffIndex /*effIndex*/) - { - float dist = 2.0f + rand_norm() * 18.0f; - float angle = rand_norm() * 2 * M_PI; - Position const offset = {dist * cos(angle), dist * std::sin(angle), 0.0f, 0.0f}; - WorldLocation* dest = const_cast(GetExplTargetDest()); - dest->RelocateOffset(offset); - GetHitDest()->RelocateOffset(offset); - } - - void Register() override - { - OnEffectHit += SpellEffectFn(spell_the_lich_king_teleport_to_frostmourne_hc_SpellScript::ModDest, EFFECT_1, SPELL_EFFECT_TELEPORT_UNITS); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_the_lich_king_teleport_to_frostmourne_hc_SpellScript(); + OnEffectHit += SpellEffectFn(spell_the_lich_king_teleport_to_frostmourne_hc::ModDest, EFFECT_1, SPELL_EFFECT_TELEPORT_UNITS); } }; -class spell_the_lich_king_valkyr_target_search : public SpellScriptLoader +class spell_the_lich_king_valkyr_target_search : public SpellScript { -public: - spell_the_lich_king_valkyr_target_search() : SpellScriptLoader("spell_the_lich_king_valkyr_target_search") { } + PrepareSpellScript(spell_the_lich_king_valkyr_target_search); - class spell_the_lich_king_valkyr_target_search_SpellScript : public SpellScript + WorldObject* _target; + + bool Load() override { - PrepareSpellScript(spell_the_lich_king_valkyr_target_search_SpellScript); + _target = nullptr; + return true; + } - WorldObject* _target; - - bool Load() override + void SelectTarget(std::list& targets) + { + if (targets.empty()) + return; + Creature* caster = GetCaster()->ToCreature(); + if (!caster) { - _target = nullptr; - return true; - } - - void SelectTarget(std::list& targets) - { - if (targets.empty()) - return; - Creature* caster = GetCaster()->ToCreature(); - if (!caster) - { - targets.clear(); - return; - } - targets.remove_if(Acore::UnitAuraCheck(true, GetSpellInfo()->Id)); - targets.remove_if(Acore::UnitAuraCheck(true, SPELL_BOSS_HITTIN_YA_AURA)); // done in dbc, but just to be sure xd - targets.remove_if(Acore::UnitAuraCheck(true, SPELL_HARVEST_SOUL_VALKYR)); - if (InstanceScript* _instance = caster->GetInstanceScript()) - if (Creature* lichKing = ObjectAccessor::GetCreature(*caster, _instance->GetGuidData(DATA_THE_LICH_KING))) - if (Spell* s = lichKing->GetCurrentSpell(CURRENT_GENERIC_SPELL)) - if (s->GetSpellInfo()->Id == SPELL_DEFILE && s->m_targets.GetUnitTarget()) - targets.remove(s->m_targets.GetUnitTarget()); - - if (targets.empty()) - return; - - _target = Acore::Containers::SelectRandomContainerElement(targets); targets.clear(); + return; + } + targets.remove_if(Acore::UnitAuraCheck(true, GetSpellInfo()->Id)); + targets.remove_if(Acore::UnitAuraCheck(true, SPELL_BOSS_HITTIN_YA_AURA)); // done in dbc, but just to be sure xd + targets.remove_if(Acore::UnitAuraCheck(true, SPELL_HARVEST_SOUL_VALKYR)); + if (InstanceScript* _instance = caster->GetInstanceScript()) + if (Creature* lichKing = ObjectAccessor::GetCreature(*caster, _instance->GetGuidData(DATA_THE_LICH_KING))) + if (Spell* s = lichKing->GetCurrentSpell(CURRENT_GENERIC_SPELL)) + if (s->GetSpellInfo()->Id == SPELL_DEFILE && s->m_targets.GetUnitTarget()) + targets.remove(s->m_targets.GetUnitTarget()); + + if (targets.empty()) + return; + + _target = Acore::Containers::SelectRandomContainerElement(targets); + targets.clear(); + targets.push_back(_target); + if (Creature* caster = GetCaster()->ToCreature()) + caster->AI()->SetGUID(_target->GetGUID()); + } + + void ReplaceTarget(std::list& targets) + { + targets.clear(); + if (_target) targets.push_back(_target); - if (Creature* caster = GetCaster()->ToCreature()) - caster->AI()->SetGUID(_target->GetGUID()); - } + } - void ReplaceTarget(std::list& targets) - { - targets.clear(); - if (_target) - targets.push_back(_target); - } - - void HandleScript(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - if (Unit* target = GetHitUnit()) - { - GetCaster()->GetMotionMaster()->MoveCharge(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ() + 4.0f, 42.0f, EVENT_CHARGE); - GetCaster()->SetDisableGravity(true, true); - } - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_the_lich_king_valkyr_target_search_SpellScript::SelectTarget, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_the_lich_king_valkyr_target_search_SpellScript::ReplaceTarget, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY); - OnEffectHitTarget += SpellEffectFn(spell_the_lich_king_valkyr_target_search_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void HandleScript(SpellEffIndex effIndex) { - return new spell_the_lich_king_valkyr_target_search_SpellScript(); + PreventHitDefaultEffect(effIndex); + if (Unit* target = GetHitUnit()) + { + GetCaster()->GetMotionMaster()->MoveCharge(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ() + 4.0f, 42.0f, EVENT_CHARGE); + GetCaster()->SetDisableGravity(true, true); + } + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_the_lich_king_valkyr_target_search::SelectTarget, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_the_lich_king_valkyr_target_search::ReplaceTarget, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY); + OnEffectHitTarget += SpellEffectFn(spell_the_lich_king_valkyr_target_search::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; -class spell_the_lich_king_cast_back_to_caster : public SpellScriptLoader +class spell_the_lich_king_cast_back_to_caster : public SpellScript { -public: - spell_the_lich_king_cast_back_to_caster() : SpellScriptLoader("spell_the_lich_king_cast_back_to_caster") { } + PrepareSpellScript(spell_the_lich_king_cast_back_to_caster); - class spell_the_lich_king_cast_back_to_caster_SpellScript : public SpellScript + void HandleScript(SpellEffIndex /*effIndex*/) { - PrepareSpellScript(spell_the_lich_king_cast_back_to_caster_SpellScript); + GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValue()), true); + } - void HandleScript(SpellEffIndex /*effIndex*/) - { - GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValue()), true); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_the_lich_king_cast_back_to_caster_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_the_lich_king_cast_back_to_caster_SpellScript(); + OnEffectHitTarget += SpellEffectFn(spell_the_lich_king_cast_back_to_caster::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; -class spell_the_lich_king_life_siphon : public SpellScriptLoader +class spell_the_lich_king_life_siphon : public SpellScript { -public: - spell_the_lich_king_life_siphon() : SpellScriptLoader("spell_the_lich_king_life_siphon") { } + PrepareSpellScript(spell_the_lich_king_life_siphon); - class spell_the_lich_king_life_siphon_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spell*/) override { - PrepareSpellScript(spell_the_lich_king_life_siphon_SpellScript); + return ValidateSpellInfo({ SPELL_LIFE_SIPHON_HEAL }); + } - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_LIFE_SIPHON_HEAL }); - } - - void TriggerHeal() - { - GetHitUnit()->CastCustomSpell(SPELL_LIFE_SIPHON_HEAL, SPELLVALUE_BASE_POINT0, GetHitDamage() * 10, GetCaster(), true); - } - - void Register() override - { - AfterHit += SpellHitFn(spell_the_lich_king_life_siphon_SpellScript::TriggerHeal); - } - }; - - SpellScript* GetSpellScript() const override + void TriggerHeal() { - return new spell_the_lich_king_life_siphon_SpellScript(); + GetHitUnit()->CastCustomSpell(SPELL_LIFE_SIPHON_HEAL, SPELLVALUE_BASE_POINT0, GetHitDamage() * 10, GetCaster(), true); + } + + void Register() override + { + AfterHit += SpellHitFn(spell_the_lich_king_life_siphon::TriggerHeal); } }; -class spell_the_lich_king_vile_spirits : public SpellScriptLoader +class spell_the_lich_king_vile_spirits_aura : public AuraScript { -public: - spell_the_lich_king_vile_spirits() : SpellScriptLoader("spell_the_lich_king_vile_spirits") { } + PrepareAuraScript(spell_the_lich_king_vile_spirits_aura); - class spell_the_lich_king_vile_spirits_AuraScript : public AuraScript + bool Load() override { - PrepareAuraScript(spell_the_lich_king_vile_spirits_AuraScript); + _is25Man = GetUnitOwner()->GetMap()->Is25ManRaid(); + return true; + } - bool Load() override - { - _is25Man = GetUnitOwner()->GetMap()->Is25ManRaid(); - return true; - } - - void OnPeriodic(AuraEffect const* aurEff) - { - if (_is25Man || ((aurEff->GetTickNumber() - 1) % 5)) - GetTarget()->CastSpell((Unit*)nullptr, GetSpellInfo()->Effects[aurEff->GetEffIndex()].TriggerSpell, true, nullptr, aurEff, GetCasterGUID()); - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_the_lich_king_vile_spirits_AuraScript::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); - } - - bool _is25Man; - }; - - AuraScript* GetAuraScript() const override + void OnPeriodic(AuraEffect const* aurEff) { - return new spell_the_lich_king_vile_spirits_AuraScript(); + if (_is25Man || ((aurEff->GetTickNumber() - 1) % 5)) + GetTarget()->CastSpell((Unit*)nullptr, GetSpellInfo()->Effects[aurEff->GetEffIndex()].TriggerSpell, true, nullptr, aurEff, GetCasterGUID()); + } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_the_lich_king_vile_spirits_aura::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); + } + +private: + bool _is25Man; +}; + +class spell_the_lich_king_vile_spirits_visual : public SpellScript +{ + PrepareSpellScript(spell_the_lich_king_vile_spirits_visual); + + void ModDestHeight(SpellEffIndex /*effIndex*/) + { + Position offset = {0.0f, 0.0f, 15.0f, 0.0f}; + const_cast(GetExplTargetDest())->RelocateOffset(offset); + } + + void Register() override + { + OnEffectLaunch += SpellEffectFn(spell_the_lich_king_vile_spirits_visual::ModDestHeight, EFFECT_0, SPELL_EFFECT_DUMMY); } }; -class spell_the_lich_king_vile_spirits_visual : public SpellScriptLoader +class spell_the_lich_king_vile_spirit_move_target_search : public SpellScript { -public: - spell_the_lich_king_vile_spirits_visual() : SpellScriptLoader("spell_the_lich_king_vile_spirits_visual") { } + PrepareSpellScript(spell_the_lich_king_vile_spirit_move_target_search); - class spell_the_lich_king_vile_spirits_visual_SpellScript : public SpellScript + bool Load() override { - PrepareSpellScript(spell_the_lich_king_vile_spirits_visual_SpellScript); + _target = nullptr; + return GetCaster()->GetTypeId() == TYPEID_UNIT; + } - void ModDestHeight(SpellEffIndex /*effIndex*/) - { - Position offset = {0.0f, 0.0f, 15.0f, 0.0f}; - const_cast(GetExplTargetDest())->RelocateOffset(offset); - } - - void Register() override - { - OnEffectLaunch += SpellEffectFn(spell_the_lich_king_vile_spirits_visual_SpellScript::ModDestHeight, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; - - SpellScript* GetSpellScript() const override + void SelectTarget(std::list& targets) { - return new spell_the_lich_king_vile_spirits_visual_SpellScript(); + if (targets.empty()) + return; + + _target = Acore::Containers::SelectRandomContainerElement(targets); + } + + void HandleScript(SpellEffIndex effIndex) + { + PreventHitDefaultEffect(effIndex); + if (GetHitUnit() != _target) + return; + + GetCaster()->ToCreature()->SetInCombatWithZone(); + GetCaster()->ToCreature()->AI()->AttackStart(GetHitUnit()); + GetCaster()->AddThreat(GetHitUnit(), GetCaster()->GetMaxHealth() * 0.2f); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_the_lich_king_vile_spirit_move_target_search::SelectTarget, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + OnEffectHitTarget += SpellEffectFn(spell_the_lich_king_vile_spirit_move_target_search::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } + +private: + WorldObject* _target; +}; + +class spell_the_lich_king_vile_spirit_damage_target_search : public SpellScript +{ + PrepareSpellScript(spell_the_lich_king_vile_spirit_damage_target_search); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_VILE_SPIRIT_DAMAGE_SEARCH, SPELL_SPIRIT_BURST }); + } + + void CheckTargetCount(std::list& targets) + { + if (targets.empty()) + return; + + if (TempSummon* summon = GetCaster()->ToTempSummon()) + if (Unit* summoner = summon->GetSummonerUnit()) + summoner->GetAI()->SetData(DATA_VILE, 1); + + if (Creature* c = GetCaster()->ToCreature()) + { + c->RemoveAurasDueToSpell(SPELL_VILE_SPIRIT_DAMAGE_SEARCH); + c->GetMotionMaster()->Clear(true); + c->StopMoving(); + c->CastSpell((Unit*)nullptr, SPELL_SPIRIT_BURST, true); + c->DespawnOrUnsummon(3000); + c->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE); + } + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_the_lich_king_vile_spirit_damage_target_search::CheckTargetCount, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); } }; -class spell_the_lich_king_vile_spirit_move_target_search : public SpellScriptLoader +class spell_the_lich_king_harvest_soul_aura : public AuraScript { -public: - spell_the_lich_king_vile_spirit_move_target_search() : SpellScriptLoader("spell_the_lich_king_vile_spirit_move_target_search") { } + PrepareAuraScript(spell_the_lich_king_harvest_soul_aura); - class spell_the_lich_king_vile_spirit_move_target_search_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareSpellScript(spell_the_lich_king_vile_spirit_move_target_search_SpellScript); - - bool Load() override - { - _target = nullptr; - return GetCaster()->GetTypeId() == TYPEID_UNIT; - } - - void SelectTarget(std::list& targets) - { - if (targets.empty()) - return; - - _target = Acore::Containers::SelectRandomContainerElement(targets); - } - - void HandleScript(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - if (GetHitUnit() != _target) - return; - - GetCaster()->ToCreature()->SetInCombatWithZone(); - GetCaster()->ToCreature()->AI()->AttackStart(GetHitUnit()); - GetCaster()->AddThreat(GetHitUnit(), GetCaster()->GetMaxHealth() * 0.2f); - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_the_lich_king_vile_spirit_move_target_search_SpellScript::SelectTarget, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - OnEffectHitTarget += SpellEffectFn(spell_the_lich_king_vile_spirit_move_target_search_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - - WorldObject* _target; - }; - - SpellScript* GetSpellScript() const override - { - return new spell_the_lich_king_vile_spirit_move_target_search_SpellScript(); + return ValidateSpellInfo({ SPELL_HARVESTED_SOUL_LK_BUFF }); } -}; -class spell_the_lich_king_vile_spirit_damage_target_search : public SpellScriptLoader -{ -public: - spell_the_lich_king_vile_spirit_damage_target_search() : SpellScriptLoader("spell_the_lich_king_vile_spirit_damage_target_search") { } - - class spell_the_lich_king_vile_spirit_damage_target_search_SpellScript : public SpellScript + bool Load() override { - PrepareSpellScript(spell_the_lich_king_vile_spirit_damage_target_search_SpellScript); - - void CheckTargetCount(std::list& targets) - { - if (targets.empty()) - return; - - if (TempSummon* summon = GetCaster()->ToTempSummon()) - if (Unit* summoner = summon->GetSummonerUnit()) - summoner->GetAI()->SetData(DATA_VILE, 1); - - if (Creature* c = GetCaster()->ToCreature()) - { - c->RemoveAurasDueToSpell(SPELL_VILE_SPIRIT_DAMAGE_SEARCH); - c->GetMotionMaster()->Clear(true); - c->StopMoving(); - c->CastSpell((Unit*)nullptr, SPELL_SPIRIT_BURST, true); - c->DespawnOrUnsummon(3000); - c->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE); - } - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_the_lich_king_vile_spirit_damage_target_search_SpellScript::CheckTargetCount, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_the_lich_king_vile_spirit_damage_target_search_SpellScript(); + return GetOwner()->GetInstanceScript() != nullptr; } -}; -class spell_the_lich_king_harvest_soul : public SpellScriptLoader -{ -public: - spell_the_lich_king_harvest_soul() : SpellScriptLoader("spell_the_lich_king_harvest_soul") { } - - class spell_the_lich_king_harvest_soul_AuraScript : public AuraScript + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - PrepareAuraScript(spell_the_lich_king_harvest_soul_AuraScript); + // m_originalCaster to allow stacking from different casters, meh + if (GetTargetApplication()->GetRemoveMode() == AURA_REMOVE_BY_DEATH) + GetTarget()->CastSpell((Unit*)nullptr, SPELL_HARVESTED_SOUL_LK_BUFF, true, nullptr, nullptr, GetTarget()->GetInstanceScript()->GetGuidData(DATA_THE_LICH_KING)); + } - bool Load() override - { - return GetOwner()->GetInstanceScript() != nullptr; - } - - void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - // m_originalCaster to allow stacking from different casters, meh - if (GetTargetApplication()->GetRemoveMode() == AURA_REMOVE_BY_DEATH) - GetTarget()->CastSpell((Unit*)nullptr, SPELL_HARVESTED_SOUL_LK_BUFF, true, nullptr, nullptr, GetTarget()->GetInstanceScript()->GetGuidData(DATA_THE_LICH_KING)); - } - - void Register() override - { - AfterEffectRemove += AuraEffectRemoveFn(spell_the_lich_king_harvest_soul_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAL); - } - }; - - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_the_lich_king_harvest_soul_AuraScript(); + AfterEffectRemove += AuraEffectRemoveFn(spell_the_lich_king_harvest_soul_aura::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAL); } }; @@ -3389,94 +3170,78 @@ public: } }; -class spell_the_lich_king_lights_favor : public SpellScriptLoader +class spell_the_lich_king_lights_favor_aura : public AuraScript { -public: - spell_the_lich_king_lights_favor() : SpellScriptLoader("spell_the_lich_king_lights_favor") { } + PrepareAuraScript(spell_the_lich_king_lights_favor_aura); - class spell_the_lich_king_lights_favor_AuraScript : public AuraScript + void OnPeriodic(AuraEffect const* /*aurEff*/) { - PrepareAuraScript(spell_the_lich_king_lights_favor_AuraScript); + if (Unit* caster = GetCaster()) + if (AuraEffect* effect = GetAura()->GetEffect(EFFECT_1)) + effect->RecalculateAmount(caster); + } - void OnPeriodic(AuraEffect const* /*aurEff*/) - { - if (Unit* caster = GetCaster()) - if (AuraEffect* effect = GetAura()->GetEffect(EFFECT_1)) - effect->RecalculateAmount(caster); - } - - void CalculateBonus(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) - { - canBeRecalculated = true; - amount = 0; - if (Unit* caster = GetCaster()) - amount = int32(caster->GetHealthPct()); - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_the_lich_king_lights_favor_AuraScript::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_HEAL); - DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_the_lich_king_lights_favor_AuraScript::CalculateBonus, EFFECT_1, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE); - } - }; - - AuraScript* GetAuraScript() const override + void CalculateBonus(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) { - return new spell_the_lich_king_lights_favor_AuraScript(); + canBeRecalculated = true; + amount = 0; + if (Unit* caster = GetCaster()) + amount = int32(caster->GetHealthPct()); + } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_the_lich_king_lights_favor_aura::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_HEAL); + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_the_lich_king_lights_favor_aura::CalculateBonus, EFFECT_1, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE); } }; -class spell_the_lich_king_restore_soul : public SpellScriptLoader +class spell_the_lich_king_restore_soul : public SpellScript { -public: - spell_the_lich_king_restore_soul() : SpellScriptLoader("spell_the_lich_king_restore_soul") { } + PrepareSpellScript(spell_the_lich_king_restore_soul); - class spell_the_lich_king_restore_soul_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareSpellScript(spell_the_lich_king_restore_soul_SpellScript); - - bool Load() override - { - _instance = GetCaster()->GetInstanceScript(); - return _instance != nullptr; - } - - void FilterTargets(std::list& unitList) - { - for (std::list::const_iterator itr = unitList.begin(); itr != unitList.end(); ++itr) - if (Unit* target = (*itr)->ToUnit()) - target->RemoveAurasDueToSpell(target->GetMap()->IsHeroic() ? SPELL_HARVEST_SOULS_TELEPORT : SPELL_HARVEST_SOUL_TELEPORT); - if (Creature* lichKing = ObjectAccessor::GetCreature(*GetCaster(), _instance->GetGuidData(DATA_THE_LICH_KING))) - lichKing->AI()->DoAction(ACTION_TELEPORT_BACK); - if (Creature* spawner = GetCaster()->FindNearestCreature(NPC_WORLD_TRIGGER_INFINITE_AOI, 50.0f, true)) - { - spawner->RemoveAllAuras(); - spawner->m_Events.KillAllEvents(true); - } - - std::list spirits; - GetCaster()->GetCreatureListWithEntryInGrid(spirits, NPC_WICKED_SPIRIT, 200.0f); - for (std::list::iterator itr = spirits.begin(); itr != spirits.end(); ++itr) - { - (*itr)->m_Events.KillAllEvents(true); - (*itr)->RemoveAllAuras(); - (*itr)->AI()->EnterEvadeMode(); - (*itr)->SetReactState(REACT_PASSIVE); - } - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_the_lich_king_restore_soul_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); - } - - InstanceScript* _instance; - }; - - SpellScript* GetSpellScript() const override - { - return new spell_the_lich_king_restore_soul_SpellScript(); + return ValidateSpellInfo({ SPELL_HARVEST_SOULS_TELEPORT, SPELL_HARVEST_SOUL_TELEPORT }); } + + bool Load() override + { + _instance = GetCaster()->GetInstanceScript(); + return _instance != nullptr; + } + + void FilterTargets(std::list& unitList) + { + for (std::list::const_iterator itr = unitList.begin(); itr != unitList.end(); ++itr) + if (Unit* target = (*itr)->ToUnit()) + target->RemoveAurasDueToSpell(target->GetMap()->IsHeroic() ? SPELL_HARVEST_SOULS_TELEPORT : SPELL_HARVEST_SOUL_TELEPORT); + if (Creature* lichKing = ObjectAccessor::GetCreature(*GetCaster(), _instance->GetGuidData(DATA_THE_LICH_KING))) + lichKing->AI()->DoAction(ACTION_TELEPORT_BACK); + if (Creature* spawner = GetCaster()->FindNearestCreature(NPC_WORLD_TRIGGER_INFINITE_AOI, 50.0f, true)) + { + spawner->RemoveAllAuras(); + spawner->m_Events.KillAllEvents(true); + } + + std::list spirits; + GetCaster()->GetCreatureListWithEntryInGrid(spirits, NPC_WICKED_SPIRIT, 200.0f); + for (std::list::iterator itr = spirits.begin(); itr != spirits.end(); ++itr) + { + (*itr)->m_Events.KillAllEvents(true); + (*itr)->RemoveAllAuras(); + (*itr)->AI()->EnterEvadeMode(); + (*itr)->SetReactState(REACT_PASSIVE); + } + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_the_lich_king_restore_soul::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); + } + +private: + InstanceScript* _instance; }; class npc_spirit_warden : public CreatureScript @@ -3526,73 +3291,56 @@ public: } }; -class spell_the_lich_king_dark_hunger : public SpellScriptLoader +class spell_the_lich_king_dark_hunger_aura : public AuraScript { -public: - spell_the_lich_king_dark_hunger() : SpellScriptLoader("spell_the_lich_king_dark_hunger") { } + PrepareAuraScript(spell_the_lich_king_dark_hunger_aura); - class spell_the_lich_king_dark_hunger_AuraScript : public AuraScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareAuraScript(spell_the_lich_king_dark_hunger_AuraScript); + return ValidateSpellInfo({ SPELL_DARK_HUNGER_HEAL }); + } - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo({ SPELL_DARK_HUNGER_HEAL }); - } - - void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) - { - PreventDefaultAction(); - - DamageInfo* damageInfo = eventInfo.GetDamageInfo(); - - if (!damageInfo || !damageInfo->GetDamage()) - { - return; - } - - int32 heal = static_cast(damageInfo->GetDamage() / 2); - GetTarget()->CastCustomSpell(SPELL_DARK_HUNGER_HEAL, SPELLVALUE_BASE_POINT0, heal, GetTarget(), true, nullptr, aurEff); - } - - void Register() override - { - OnEffectProc += AuraEffectProcFn(spell_the_lich_king_dark_hunger_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); - } - }; - - AuraScript* GetAuraScript() const override + void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) { - return new spell_the_lich_king_dark_hunger_AuraScript(); + PreventDefaultAction(); + + DamageInfo* damageInfo = eventInfo.GetDamageInfo(); + + if (!damageInfo || !damageInfo->GetDamage()) + { + return; + } + + int32 heal = static_cast(damageInfo->GetDamage() / 2); + GetTarget()->CastCustomSpell(SPELL_DARK_HUNGER_HEAL, SPELLVALUE_BASE_POINT0, heal, GetTarget(), true, nullptr, aurEff); + } + + void Register() override + { + OnEffectProc += AuraEffectProcFn(spell_the_lich_king_dark_hunger_aura::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); } }; -class spell_the_lich_king_soul_rip : public SpellScriptLoader +class spell_the_lich_king_soul_rip_aura : public AuraScript { -public: - spell_the_lich_king_soul_rip() : SpellScriptLoader("spell_the_lich_king_soul_rip") { } + PrepareAuraScript(spell_the_lich_king_soul_rip_aura); - class spell_the_lich_king_soul_rip_AuraScript : public AuraScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareAuraScript(spell_the_lich_king_soul_rip_AuraScript); + return ValidateSpellInfo({ SPELL_SOUL_RIP_DAMAGE, 5000 }); + } - void OnPeriodic(AuraEffect const* aurEff) - { - PreventDefaultAction(); - // shouldn't be needed, this is channeled - if (Unit* caster = GetCaster()) - caster->CastCustomSpell(SPELL_SOUL_RIP_DAMAGE, SPELLVALUE_BASE_POINT0, 5000 * aurEff->GetTickNumber(), GetTarget(), true, nullptr, aurEff, GetCasterGUID()); - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_the_lich_king_soul_rip_AuraScript::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); - } - }; - - AuraScript* GetAuraScript() const override + void OnPeriodic(AuraEffect const* aurEff) { - return new spell_the_lich_king_soul_rip_AuraScript(); + PreventDefaultAction(); + // shouldn't be needed, this is channeled + if (Unit* caster = GetCaster()) + caster->CastCustomSpell(SPELL_SOUL_RIP_DAMAGE, SPELLVALUE_BASE_POINT0, 5000 * aurEff->GetTickNumber(), GetTarget(), true, nullptr, aurEff, GetCasterGUID()); + } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_the_lich_king_soul_rip_aura::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); } }; @@ -3617,30 +3365,19 @@ public: } }; -class spell_the_lich_king_summon_spirit_bomb : public SpellScriptLoader +class spell_the_lich_king_summon_spirit_bomb : public SpellScript { -public: - spell_the_lich_king_summon_spirit_bomb() : SpellScriptLoader("spell_the_lich_king_summon_spirit_bomb") { } + PrepareSpellScript(spell_the_lich_king_summon_spirit_bomb); - class spell_the_lich_king_summon_spirit_bomb_SpellScript : public SpellScript + void HandleScript(SpellEffIndex effIndex) { - PrepareSpellScript(spell_the_lich_king_summon_spirit_bomb_SpellScript); + PreventHitDefaultEffect(effIndex); + GetHitUnit()->CastSpell((Unit*)nullptr, uint32(GetEffectValue()), true); + } - void HandleScript(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - GetHitUnit()->CastSpell((Unit*)nullptr, uint32(GetEffectValue()), true); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_the_lich_king_summon_spirit_bomb_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_the_lich_king_summon_spirit_bomb_SpellScript(); + OnEffectHitTarget += SpellEffectFn(spell_the_lich_king_summon_spirit_bomb::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; @@ -3701,36 +3438,25 @@ public: } }; -class spell_the_lich_king_trigger_vile_spirit : public SpellScriptLoader +class spell_the_lich_king_trigger_vile_spirit : public SpellScript { -public: - spell_the_lich_king_trigger_vile_spirit() : SpellScriptLoader("spell_the_lich_king_trigger_vile_spirit") { } + PrepareSpellScript(spell_the_lich_king_trigger_vile_spirit); - class spell_the_lich_king_trigger_vile_spirit_SpellScript : public SpellScript + void ActivateSpirit() { - PrepareSpellScript(spell_the_lich_king_trigger_vile_spirit_SpellScript); + Creature* target = GetHitCreature(); + if (!target) + return; - void ActivateSpirit() - { - Creature* target = GetHitCreature(); - if (!target) - return; + target->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_ATTACKABLE_1); + target->SetImmuneToAll(false); + target->ForceValuesUpdateAtIndex(UNIT_FIELD_FLAGS); + VileSpiritActivateEvent(target).Execute(0, 0); + } - target->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_ATTACKABLE_1); - target->SetImmuneToAll(false); - target->ForceValuesUpdateAtIndex(UNIT_FIELD_FLAGS); - VileSpiritActivateEvent(target).Execute(0, 0); - } - - void Register() override - { - OnHit += SpellHitFn(spell_the_lich_king_trigger_vile_spirit_SpellScript::ActivateSpirit); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_the_lich_king_trigger_vile_spirit_SpellScript(); + OnHit += SpellHitFn(spell_the_lich_king_trigger_vile_spirit::ActivateSpirit); } }; @@ -3803,47 +3529,47 @@ void AddSC_boss_the_lich_king() { new boss_the_lich_king(); new npc_tirion_fordring_tft(); - new spell_the_lich_king_quake(); - new spell_the_lich_king_jump(); - new spell_the_lich_king_jump_remove_aura(); - new spell_trigger_spell_from_caster("spell_the_lich_king_mass_resurrection", SPELL_MASS_RESURRECTION_REAL); - new spell_the_lich_king_play_movie(); + RegisterSpellScript(spell_the_lich_king_quake); + RegisterSpellScript(spell_the_lich_king_jump); + RegisterSpellScript(spell_the_lich_king_jump_remove_aura); + RegisterSpellScriptWithArgs(spell_trigger_spell_from_caster, "spell_the_lich_king_mass_resurrection", SPELL_MASS_RESURRECTION_REAL); + RegisterSpellScript(spell_the_lich_king_play_movie); // fight stuff below new npc_shambling_horror_icc(); - new spell_the_lich_king_infest(); - new spell_the_lich_king_necrotic_plague(); - new spell_the_lich_king_necrotic_plague_jump(); - new spell_the_lich_king_shadow_trap_visual(); - new spell_the_lich_king_shadow_trap_periodic(); - new spell_the_lich_king_ice_burst_target_search(); + RegisterSpellScript(spell_the_lich_king_infest_aura); + RegisterSpellScript(spell_the_lich_king_necrotic_plague_aura); + RegisterSpellAndAuraScriptPair(spell_the_lich_king_necrotic_plague_jump, spell_the_lich_king_necrotic_plague_jump_aura); + RegisterSpellScript(spell_the_lich_king_shadow_trap_visual_aura); + RegisterSpellScript(spell_the_lich_king_shadow_trap_periodic); + RegisterSpellScript(spell_the_lich_king_ice_burst_target_search); new npc_icc_ice_sphere(); - new spell_the_lich_king_raging_spirit(); + RegisterSpellScript(spell_the_lich_king_raging_spirit); new npc_raging_spirit(); - new spell_the_lich_king_defile(); - new spell_the_lich_king_soul_reaper(); + RegisterSpellScript(spell_the_lich_king_defile); + RegisterSpellScript(spell_the_lich_king_soul_reaper_aura); new npc_valkyr_shadowguard(); - new spell_the_lich_king_summon_into_air(); - new spell_the_lich_king_teleport_to_frostmourne_hc(); - new spell_the_lich_king_valkyr_target_search(); - new spell_the_lich_king_cast_back_to_caster(); - new spell_the_lich_king_life_siphon(); - new spell_the_lich_king_vile_spirits(); - new spell_the_lich_king_vile_spirits_visual(); - new spell_the_lich_king_vile_spirit_move_target_search(); - new spell_the_lich_king_vile_spirit_damage_target_search(); - new spell_the_lich_king_harvest_soul(); + RegisterSpellScript(spell_the_lich_king_summon_into_air); + RegisterSpellScript(spell_the_lich_king_teleport_to_frostmourne_hc); + RegisterSpellScript(spell_the_lich_king_valkyr_target_search); + RegisterSpellScript(spell_the_lich_king_cast_back_to_caster); + RegisterSpellScript(spell_the_lich_king_life_siphon); + RegisterSpellScript(spell_the_lich_king_vile_spirits_aura); + RegisterSpellScript(spell_the_lich_king_vile_spirits_visual); + RegisterSpellScript(spell_the_lich_king_vile_spirit_move_target_search); + RegisterSpellScript(spell_the_lich_king_vile_spirit_damage_target_search); + RegisterSpellScript(spell_the_lich_king_harvest_soul_aura); new npc_strangulate_vehicle(); new npc_terenas_menethil(); - new spell_the_lich_king_lights_favor(); - new spell_the_lich_king_restore_soul(); + RegisterSpellScript(spell_the_lich_king_lights_favor_aura); + RegisterSpellScript(spell_the_lich_king_restore_soul); new npc_spirit_warden(); - new spell_the_lich_king_dark_hunger(); - new spell_the_lich_king_soul_rip(); + RegisterSpellScript(spell_the_lich_king_dark_hunger_aura); + RegisterSpellScript(spell_the_lich_king_soul_rip_aura); new npc_icc_lk_checktarget(); - new spell_the_lich_king_summon_spirit_bomb(); + RegisterSpellScript(spell_the_lich_king_summon_spirit_bomb); new npc_lk_spirit_bomb(); - new spell_the_lich_king_trigger_vile_spirit(); + RegisterSpellScript(spell_the_lich_king_trigger_vile_spirit); new npc_lk_wicked_spirit(); new achievement_been_waiting_long_time(); new achievement_neck_deep_in_vile(); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp index 71beac42d..97485ee5b 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp @@ -1138,372 +1138,280 @@ public: } }; -class spell_dreamwalker_summon_portal : public SpellScriptLoader +class spell_dreamwalker_summon_portal : public SpellScript { -public: - spell_dreamwalker_summon_portal() : SpellScriptLoader("spell_dreamwalker_summon_portal") { } + PrepareSpellScript(spell_dreamwalker_summon_portal); - class spell_dreamwalker_summon_portal_SpellScript : public SpellScript + void HandleScript(SpellEffIndex effIndex) { - PrepareSpellScript(spell_dreamwalker_summon_portal_SpellScript); + PreventHitDefaultEffect(effIndex); + Unit* target = GetHitUnit(); + if (!target) + return; - void HandleScript(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - Unit* target = GetHitUnit(); - if (!target) - return; + uint32 spellId = (GetSpellInfo()->Id == 72224 ? 71301 : 71977); // spell implicit target replaced to TARGET_DEST_DEST + float minDist = 20.0f; + float maxDist = 30.0f; + float dist = (maxDist - minDist) * rand_norm() + minDist; + float startAngle = 3 * M_PI / 2; + float maxAddAngle = ((target->GetMap()->GetSpawnMode() % 2) == 0 ? M_PI : 2 * M_PI); + float angle = startAngle + rand_norm() * maxAddAngle; + target->CastSpell(target->GetPositionX() + cos(angle)*dist, target->GetPositionY() + std::sin(angle)*dist, target->GetPositionZ(), spellId, true); + } - uint32 spellId = (GetSpellInfo()->Id == 72224 ? 71301 : 71977); // spell implicit target replaced to TARGET_DEST_DEST - float minDist = 20.0f; - float maxDist = 30.0f; - float dist = (maxDist - minDist) * rand_norm() + minDist; - float startAngle = 3 * M_PI / 2; - float maxAddAngle = ((target->GetMap()->GetSpawnMode() % 2) == 0 ? M_PI : 2 * M_PI); - float angle = startAngle + rand_norm() * maxAddAngle; - target->CastSpell(target->GetPositionX() + cos(angle)*dist, target->GetPositionY() + std::sin(angle)*dist, target->GetPositionZ(), spellId, true); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_dreamwalker_summon_portal_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_dreamwalker_summon_portal_SpellScript(); + OnEffectHitTarget += SpellEffectFn(spell_dreamwalker_summon_portal::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; -class spell_dreamwalker_twisted_nightmares : public SpellScriptLoader +class spell_dreamwalker_twisted_nightmares : public SpellScript { -public: - spell_dreamwalker_twisted_nightmares() : SpellScriptLoader("spell_dreamwalker_twisted_nightmares") { } + PrepareSpellScript(spell_dreamwalker_twisted_nightmares); - class spell_dreamwalker_twisted_nightmares_SpellScript : public SpellScript + void HandleScript(SpellEffIndex effIndex) { - PrepareSpellScript(spell_dreamwalker_twisted_nightmares_SpellScript); + PreventHitDefaultEffect(effIndex); + if (!GetHitUnit()) + return; - void HandleScript(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - if (!GetHitUnit()) - return; + if (InstanceScript* instance = GetHitUnit()->GetInstanceScript()) + GetHitUnit()->CastSpell((Unit*)nullptr, GetSpellInfo()->Effects[effIndex].TriggerSpell, true, nullptr, nullptr, instance->GetGuidData(DATA_VALITHRIA_DREAMWALKER)); + } - if (InstanceScript* instance = GetHitUnit()->GetInstanceScript()) - GetHitUnit()->CastSpell((Unit*)nullptr, GetSpellInfo()->Effects[effIndex].TriggerSpell, true, nullptr, nullptr, instance->GetGuidData(DATA_VALITHRIA_DREAMWALKER)); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_dreamwalker_twisted_nightmares_SpellScript::HandleScript, EFFECT_2, SPELL_EFFECT_FORCE_CAST); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_dreamwalker_twisted_nightmares_SpellScript(); + OnEffectHitTarget += SpellEffectFn(spell_dreamwalker_twisted_nightmares::HandleScript, EFFECT_2, SPELL_EFFECT_FORCE_CAST); } }; -class spell_dreamwalker_nightmare_cloud : public SpellScriptLoader +class spell_dreamwalker_nightmare_cloud_aura : public AuraScript { -public: - spell_dreamwalker_nightmare_cloud() : SpellScriptLoader("spell_dreamwalker_nightmare_cloud") { } + PrepareAuraScript(spell_dreamwalker_nightmare_cloud_aura); - class spell_dreamwalker_nightmare_cloud_AuraScript : public AuraScript + bool Load() override { - PrepareAuraScript(spell_dreamwalker_nightmare_cloud_AuraScript); - - bool Load() override - { - _instance = GetOwner()->GetInstanceScript(); - return _instance != nullptr; - } - - void PeriodicTick(AuraEffect const* /*aurEff*/) - { - if (_instance->GetBossState(DATA_VALITHRIA_DREAMWALKER) != IN_PROGRESS) - PreventDefaultAction(); - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_dreamwalker_nightmare_cloud_AuraScript::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); - } - - InstanceScript* _instance; - }; - - AuraScript* GetAuraScript() const override - { - return new spell_dreamwalker_nightmare_cloud_AuraScript(); + _instance = GetOwner()->GetInstanceScript(); + return _instance != nullptr; } -}; -class spell_dreamwalker_mana_void : public SpellScriptLoader -{ -public: - spell_dreamwalker_mana_void() : SpellScriptLoader("spell_dreamwalker_mana_void") { } - - class spell_dreamwalker_mana_void_AuraScript : public AuraScript + void PeriodicTick(AuraEffect const* /*aurEff*/) { - PrepareAuraScript(spell_dreamwalker_mana_void_AuraScript); - - void PeriodicTick(AuraEffect const* aurEff) - { - // first 3 ticks have amplitude 1 second - // remaining tick every 500ms - if (aurEff->GetTickNumber() <= 5) - if (!(aurEff->GetTickNumber() & 1)) - PreventDefaultAction(); - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_dreamwalker_mana_void_AuraScript::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_dreamwalker_mana_void_AuraScript(); - } -}; - -class spell_dreamwalker_decay_periodic_timer : public SpellScriptLoader -{ -public: - spell_dreamwalker_decay_periodic_timer() : SpellScriptLoader("spell_dreamwalker_decay_periodic_timer") { } - - class spell_dreamwalker_decay_periodic_timer_AuraScript : public AuraScript - { - PrepareAuraScript(spell_dreamwalker_decay_periodic_timer_AuraScript); - - bool Load() override - { - _decayRate = GetId() != SPELL_TIMER_BLAZING_SKELETON ? 1000 : 5000; - return true; - } - - void DecayPeriodicTimer(AuraEffect* aurEff) - { - int32 timer = aurEff->GetPeriodicTimer(); - if (timer <= 5000) - return; - - aurEff->SetPeriodicTimer(timer - _decayRate); - } - - void Register() override - { - OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_dreamwalker_decay_periodic_timer_AuraScript::DecayPeriodicTimer, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); - } - - int32 _decayRate; - }; - - AuraScript* GetAuraScript() const override - { - return new spell_dreamwalker_decay_periodic_timer_AuraScript(); - } -}; - -class spell_dreamwalker_summoner : public SpellScriptLoader -{ -public: - spell_dreamwalker_summoner() : SpellScriptLoader("spell_dreamwalker_summoner") { } - - class spell_dreamwalker_summoner_SpellScript : public SpellScript - { - PrepareSpellScript(spell_dreamwalker_summoner_SpellScript); - - bool Load() override - { - if (!GetCaster()->GetInstanceScript()) - return false; - return true; - } - - void FilterTargets(std::list& targets) - { - targets.remove_if(Acore::AllWorldObjectsInExactRange(GetCaster(), 250.0f, true)); - std::list list_copy = targets; - targets.remove_if(Acore::UnitAuraCheck(true, SPELL_RECENTLY_SPAWNED)); - if (targets.empty()) - { - if (list_copy.empty()) - return; - targets = list_copy; - } - - WorldObject* target = Acore::Containers::SelectRandomContainerElement(targets); - targets.clear(); - targets.push_back(target); - } - - void HandleForceCast(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - if (!GetHitUnit()) - return; - - GetHitUnit()->CastSpell(GetCaster(), GetSpellInfo()->Effects[effIndex].TriggerSpell, true, nullptr, nullptr, GetCaster()->GetInstanceScript()->GetGuidData(DATA_VALITHRIA_LICH_KING)); - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_dreamwalker_summoner_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); - OnEffectHitTarget += SpellEffectFn(spell_dreamwalker_summoner_SpellScript::HandleForceCast, EFFECT_0, SPELL_EFFECT_FORCE_CAST); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_dreamwalker_summoner_SpellScript(); - } -}; - -class spell_dreamwalker_summon_suppresser : public SpellScriptLoader -{ -public: - spell_dreamwalker_summon_suppresser() : SpellScriptLoader("spell_dreamwalker_summon_suppresser") { } - - class spell_dreamwalker_summon_suppresser_AuraScript : public AuraScript - { - PrepareAuraScript(spell_dreamwalker_summon_suppresser_AuraScript); - - void PeriodicTick(AuraEffect const* /*aurEff*/) - { + if (_instance->GetBossState(DATA_VALITHRIA_DREAMWALKER) != IN_PROGRESS) PreventDefaultAction(); - Unit* caster = GetCaster(); - if (!caster) - return; + } - std::list summoners; - caster->GetCreaturesWithEntryInRange(summoners, 200.0f, NPC_WORLD_TRIGGER); - std::list list_copy = summoners; - summoners.remove_if(Acore::UnitAuraCheck(true, SPELL_RECENTLY_SPAWNED)); - if (summoners.empty()) + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_dreamwalker_nightmare_cloud_aura::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + } + +private: + InstanceScript* _instance; +}; + +class spell_dreamwalker_mana_void_aura : public AuraScript +{ + PrepareAuraScript(spell_dreamwalker_mana_void_aura); + + void PeriodicTick(AuraEffect const* aurEff) + { + // first 3 ticks have amplitude 1 second + // remaining tick every 500ms + if (aurEff->GetTickNumber() <= 5) + if (!(aurEff->GetTickNumber() & 1)) + PreventDefaultAction(); + } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_dreamwalker_mana_void_aura::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + } +}; + +class spell_dreamwalker_decay_periodic_timer_aura : public AuraScript +{ + PrepareAuraScript(spell_dreamwalker_decay_periodic_timer_aura); + + bool Load() override + { + _decayRate = GetId() != SPELL_TIMER_BLAZING_SKELETON ? 1000 : 5000; + return true; + } + + void DecayPeriodicTimer(AuraEffect* aurEff) + { + int32 timer = aurEff->GetPeriodicTimer(); + if (timer <= 5000) + return; + + aurEff->SetPeriodicTimer(timer - _decayRate); + } + + void Register() override + { + OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_dreamwalker_decay_periodic_timer_aura::DecayPeriodicTimer, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + } + +private: + int32 _decayRate; +}; + +class spell_dreamwalker_summoner : public SpellScript +{ + PrepareSpellScript(spell_dreamwalker_summoner); + + bool Load() override + { + if (!GetCaster()->GetInstanceScript()) + return false; + return true; + } + + void FilterTargets(std::list& targets) + { + targets.remove_if(Acore::AllWorldObjectsInExactRange(GetCaster(), 250.0f, true)); + std::list list_copy = targets; + targets.remove_if(Acore::UnitAuraCheck(true, SPELL_RECENTLY_SPAWNED)); + if (targets.empty()) + { + if (list_copy.empty()) + return; + targets = list_copy; + } + + WorldObject* target = Acore::Containers::SelectRandomContainerElement(targets); + targets.clear(); + targets.push_back(target); + } + + void HandleForceCast(SpellEffIndex effIndex) + { + PreventHitDefaultEffect(effIndex); + if (!GetHitUnit()) + return; + + GetHitUnit()->CastSpell(GetCaster(), GetSpellInfo()->Effects[effIndex].TriggerSpell, true, nullptr, nullptr, GetCaster()->GetInstanceScript()->GetGuidData(DATA_VALITHRIA_LICH_KING)); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_dreamwalker_summoner::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); + OnEffectHitTarget += SpellEffectFn(spell_dreamwalker_summoner::HandleForceCast, EFFECT_0, SPELL_EFFECT_FORCE_CAST); + } +}; + +class spell_dreamwalker_summon_suppresser_aura : public AuraScript +{ + PrepareAuraScript(spell_dreamwalker_summon_suppresser_aura); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_SUMMON_SUPPRESSER }); + } + + void PeriodicTick(AuraEffect const* /*aurEff*/) + { + PreventDefaultAction(); + Unit* caster = GetCaster(); + if (!caster) + return; + + std::list summoners; + caster->GetCreaturesWithEntryInRange(summoners, 200.0f, NPC_WORLD_TRIGGER); + std::list list_copy = summoners; + summoners.remove_if(Acore::UnitAuraCheck(true, SPELL_RECENTLY_SPAWNED)); + if (summoners.empty()) + { + if (list_copy.empty()) + return; + summoners = list_copy; + } + Acore::Containers::RandomResize(summoners, 2); + + for (uint32 i = 0; i < 3; ++i) + caster->CastSpell(summoners.front(), SPELL_SUMMON_SUPPRESSER, true); + for (uint32 i = 0; i < 3; ++i) + caster->CastSpell(summoners.back(), SPELL_SUMMON_SUPPRESSER, true); + } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_dreamwalker_summon_suppresser_aura::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + } +}; + +class spell_dreamwalker_summon_suppresser_effect : public SpellScript +{ + PrepareSpellScript(spell_dreamwalker_summon_suppresser_effect); + + bool Load() override + { + if (!GetCaster()->GetInstanceScript()) + return false; + return true; + } + + void HandleForceCast(SpellEffIndex effIndex) + { + PreventHitDefaultEffect(effIndex); + if (!GetHitUnit()) + return; + + GetHitUnit()->CastSpell(GetCaster(), GetSpellInfo()->Effects[effIndex].TriggerSpell, true, nullptr, nullptr, GetCaster()->GetInstanceScript()->GetGuidData(DATA_VALITHRIA_LICH_KING)); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_dreamwalker_summon_suppresser_effect::HandleForceCast, EFFECT_0, SPELL_EFFECT_FORCE_CAST); + } +}; + +class spell_valithria_suppression_aura : public AuraScript +{ + PrepareAuraScript(spell_valithria_suppression_aura); + + void OnApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) + { + const_cast(aurEff)->SetAmount(0); + + Unit* target = GetTarget(); + Unit::AuraApplicationMap& aam = target->GetAppliedAuras(); + Unit::AuraApplicationMapBounds range = aam.equal_range(GetSpellInfo()->Id); + uint32 count = target->GetAuraCount(GetSpellInfo()->Id); + + if (range.first == range.second) + return; + + for (Unit::AuraApplicationMap::const_iterator itr = range.first; itr != range.second; ++itr) + if (count == 1 || itr->second->GetBase()->GetEffect(EFFECT_0)->GetAmount()) { - if (list_copy.empty()) - return; - summoners = list_copy; + itr->second->GetBase()->GetEffect(EFFECT_0)->SetAmount(count * GetSpellInfo()->Effects[0].CalcValue()); + break; } - Acore::Containers::RandomResize(summoners, 2); - - for (uint32 i = 0; i < 3; ++i) - caster->CastSpell(summoners.front(), SPELL_SUMMON_SUPPRESSER, true); - for (uint32 i = 0; i < 3; ++i) - caster->CastSpell(summoners.back(), SPELL_SUMMON_SUPPRESSER, true); - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_dreamwalker_summon_suppresser_AuraScript::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_dreamwalker_summon_suppresser_AuraScript(); } -}; -class spell_dreamwalker_summon_suppresser_effect : public SpellScriptLoader -{ -public: - spell_dreamwalker_summon_suppresser_effect() : SpellScriptLoader("spell_dreamwalker_summon_suppresser_effect") { } - - class spell_dreamwalker_summon_suppresser_effect_SpellScript : public SpellScript + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - PrepareSpellScript(spell_dreamwalker_summon_suppresser_effect_SpellScript); + Unit* target = GetTarget(); + Unit::AuraApplicationMap& aam = target->GetAppliedAuras(); + Unit::AuraApplicationMapBounds range = aam.equal_range(GetSpellInfo()->Id); + uint32 count = target->GetAuraCount(GetSpellInfo()->Id); - bool Load() override - { - if (!GetCaster()->GetInstanceScript()) - return false; - return true; - } + if (range.first == range.second) + return; - void HandleForceCast(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - if (!GetHitUnit()) - return; + for (Unit::AuraApplicationMap::const_iterator itr = range.first; itr != range.second; ++itr) + if (itr->second->GetBase()->GetEffect(EFFECT_0)->GetAmount()) + itr->second->GetBase()->GetEffect(EFFECT_0)->SetAmount(0); - GetHitUnit()->CastSpell(GetCaster(), GetSpellInfo()->Effects[effIndex].TriggerSpell, true, nullptr, nullptr, GetCaster()->GetInstanceScript()->GetGuidData(DATA_VALITHRIA_LICH_KING)); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_dreamwalker_summon_suppresser_effect_SpellScript::HandleForceCast, EFFECT_0, SPELL_EFFECT_FORCE_CAST); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_dreamwalker_summon_suppresser_effect_SpellScript(); + range.first->second->GetBase()->GetEffect(EFFECT_0)->SetAmount(count * GetSpellInfo()->Effects[0].CalcValue()); } -}; -class spell_valithria_suppression : public SpellScriptLoader -{ -public: - spell_valithria_suppression() : SpellScriptLoader("spell_valithria_suppression") { } - - class spell_valithria_suppression_AuraScript : public AuraScript + void Register() override { - PrepareAuraScript(spell_valithria_suppression_AuraScript); - - void OnApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) - { - const_cast(aurEff)->SetAmount(0); - - Unit* target = GetTarget(); - Unit::AuraApplicationMap& aam = target->GetAppliedAuras(); - Unit::AuraApplicationMapBounds range = aam.equal_range(GetSpellInfo()->Id); - uint32 count = target->GetAuraCount(GetSpellInfo()->Id); - - if (range.first == range.second) - return; - - for (Unit::AuraApplicationMap::const_iterator itr = range.first; itr != range.second; ++itr) - if (count == 1 || itr->second->GetBase()->GetEffect(EFFECT_0)->GetAmount()) - { - itr->second->GetBase()->GetEffect(EFFECT_0)->SetAmount(count * GetSpellInfo()->Effects[0].CalcValue()); - break; - } - } - - void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - Unit* target = GetTarget(); - Unit::AuraApplicationMap& aam = target->GetAppliedAuras(); - Unit::AuraApplicationMapBounds range = aam.equal_range(GetSpellInfo()->Id); - uint32 count = target->GetAuraCount(GetSpellInfo()->Id); - - if (range.first == range.second) - return; - - for (Unit::AuraApplicationMap::const_iterator itr = range.first; itr != range.second; ++itr) - if (itr->second->GetBase()->GetEffect(EFFECT_0)->GetAmount()) - itr->second->GetBase()->GetEffect(EFFECT_0)->SetAmount(0); - - range.first->second->GetBase()->GetEffect(EFFECT_0)->SetAmount(count * GetSpellInfo()->Effects[0].CalcValue()); - } - - void Register() override - { - AfterEffectApply += AuraEffectApplyFn(spell_valithria_suppression_AuraScript::OnApply, EFFECT_0, SPELL_AURA_MOD_HEALING_PCT, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); - AfterEffectRemove += AuraEffectRemoveFn(spell_valithria_suppression_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_MOD_HEALING_PCT, AURA_EFFECT_HANDLE_REAL); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_valithria_suppression_AuraScript(); + AfterEffectApply += AuraEffectApplyFn(spell_valithria_suppression_aura::OnApply, EFFECT_0, SPELL_AURA_MOD_HEALING_PCT, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); + AfterEffectRemove += AuraEffectRemoveFn(spell_valithria_suppression_aura::OnRemove, EFFECT_0, SPELL_AURA_MOD_HEALING_PCT, AURA_EFFECT_HANDLE_REAL); } }; @@ -1531,15 +1439,15 @@ void AddSC_boss_valithria_dreamwalker() new npc_blistering_zombie(); new npc_gluttonous_abomination(); - new spell_dreamwalker_summon_portal(); - new spell_dreamwalker_twisted_nightmares(); - new spell_dreamwalker_nightmare_cloud(); - new spell_dreamwalker_mana_void(); - new spell_dreamwalker_decay_periodic_timer(); - new spell_dreamwalker_summoner(); - new spell_dreamwalker_summon_suppresser(); - new spell_dreamwalker_summon_suppresser_effect(); - new spell_valithria_suppression(); + RegisterSpellScript(spell_dreamwalker_summon_portal); + RegisterSpellScript(spell_dreamwalker_twisted_nightmares); + RegisterSpellScript(spell_dreamwalker_nightmare_cloud_aura); + RegisterSpellScript(spell_dreamwalker_mana_void_aura); + RegisterSpellScript(spell_dreamwalker_decay_periodic_timer_aura); + RegisterSpellScript(spell_dreamwalker_summoner); + RegisterSpellScript(spell_dreamwalker_summon_suppresser_aura); + RegisterSpellScript(spell_dreamwalker_summon_suppresser_effect); + RegisterSpellScript(spell_valithria_suppression_aura); new achievement_portal_jockey(); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp index b6be91e6a..b94169666 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp @@ -1890,252 +1890,207 @@ public: } }; -class spell_icc_stoneform : public SpellScriptLoader +class spell_icc_stoneform_aura : public AuraScript { -public: - spell_icc_stoneform() : SpellScriptLoader("spell_icc_stoneform") { } + PrepareAuraScript(spell_icc_stoneform_aura); - class spell_icc_stoneform_AuraScript : public AuraScript + void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - PrepareAuraScript(spell_icc_stoneform_AuraScript); - - void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + if (Creature* target = GetTarget()->ToCreature()) { - if (Creature* target = GetTarget()->ToCreature()) - { - target->SetReactState(REACT_PASSIVE); - target->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE); - target->SetImmuneToPC(true); - target->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_CUSTOM_SPELL_02); - } + target->SetReactState(REACT_PASSIVE); + target->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE); + target->SetImmuneToPC(true); + target->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_CUSTOM_SPELL_02); } + } - void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - if (Creature* target = GetTarget()->ToCreature()) - { - target->SetReactState(REACT_AGGRESSIVE); - target->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE); - target->SetImmuneToPC(false); - target->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0); - } - } - - void Register() override - { - OnEffectApply += AuraEffectApplyFn(spell_icc_stoneform_AuraScript::OnApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - OnEffectRemove += AuraEffectRemoveFn(spell_icc_stoneform_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); - } - }; - - AuraScript* GetAuraScript() const override + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - return new spell_icc_stoneform_AuraScript(); + if (Creature* target = GetTarget()->ToCreature()) + { + target->SetReactState(REACT_AGGRESSIVE); + target->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE); + target->SetImmuneToPC(false); + target->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0); + } + } + + void Register() override + { + OnEffectApply += AuraEffectApplyFn(spell_icc_stoneform_aura::OnApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); + OnEffectRemove += AuraEffectRemoveFn(spell_icc_stoneform_aura::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); } }; -class spell_icc_sprit_alarm : public SpellScriptLoader +class spell_icc_sprit_alarm : public SpellScript { -public: - spell_icc_sprit_alarm() : SpellScriptLoader("spell_icc_sprit_alarm") { } + PrepareSpellScript(spell_icc_sprit_alarm); - class spell_icc_sprit_alarm_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareSpellScript(spell_icc_sprit_alarm_SpellScript); + return ValidateSpellInfo({ SPELL_STONEFORM }); + } - void HandleEvent(SpellEffIndex effIndex) + void HandleEvent(SpellEffIndex effIndex) + { + PreventHitDefaultEffect(effIndex); + uint32 trapId = 0; + switch (GetSpellInfo()->Effects[effIndex].MiscValue) { - PreventHitDefaultEffect(effIndex); - uint32 trapId = 0; - switch (GetSpellInfo()->Effects[effIndex].MiscValue) - { - case EVENT_AWAKEN_WARD_1: - trapId = GO_SPIRIT_ALARM_1; - break; - case EVENT_AWAKEN_WARD_2: - trapId = GO_SPIRIT_ALARM_2; - break; - case EVENT_AWAKEN_WARD_3: - trapId = GO_SPIRIT_ALARM_3; - break; - case EVENT_AWAKEN_WARD_4: - trapId = GO_SPIRIT_ALARM_4; - break; - default: - return; - } + case EVENT_AWAKEN_WARD_1: + trapId = GO_SPIRIT_ALARM_1; + break; + case EVENT_AWAKEN_WARD_2: + trapId = GO_SPIRIT_ALARM_2; + break; + case EVENT_AWAKEN_WARD_3: + trapId = GO_SPIRIT_ALARM_3; + break; + case EVENT_AWAKEN_WARD_4: + trapId = GO_SPIRIT_ALARM_4; + break; + default: + return; + } - if (GameObject* trap = GetCaster()->FindNearestGameObject(trapId, 5.0f)) - { - trap->SetRespawnTime(trap->GetGOInfo()->GetAutoCloseTime() / IN_MILLISECONDS); - } + if (GameObject* trap = GetCaster()->FindNearestGameObject(trapId, 5.0f)) + { + trap->SetRespawnTime(trap->GetGOInfo()->GetAutoCloseTime() / IN_MILLISECONDS); + } - std::list wards; - GetCaster()->GetCreatureListWithEntryInGrid(wards, NPC_DEATHBOUND_WARD, 150.0f); - wards.sort(Acore::ObjectDistanceOrderPred(GetCaster())); - for (std::list::iterator itr = wards.begin(); itr != wards.end(); ++itr) + std::list wards; + GetCaster()->GetCreatureListWithEntryInGrid(wards, NPC_DEATHBOUND_WARD, 150.0f); + wards.sort(Acore::ObjectDistanceOrderPred(GetCaster())); + for (std::list::iterator itr = wards.begin(); itr != wards.end(); ++itr) + { + if ((*itr)->IsAlive() && (*itr)->HasAura(SPELL_STONEFORM)) { - if ((*itr)->IsAlive() && (*itr)->HasAura(SPELL_STONEFORM)) + (*itr)->AI()->Talk(SAY_TRAP_ACTIVATE); + (*itr)->RemoveAurasDueToSpell(SPELL_STONEFORM); + (*itr)->AI()->SetData(1, 1); + break; + } + } + } + + void Register() override + { + OnEffectHit += SpellEffectFn(spell_icc_sprit_alarm::HandleEvent, EFFECT_2, SPELL_EFFECT_SEND_EVENT); + } +}; + +class spell_icc_geist_alarm : public SpellScript +{ + PrepareSpellScript(spell_icc_geist_alarm); + + void HandleEvent(SpellEffIndex effIndex) + { + PreventHitDefaultEffect(effIndex); + if (InstanceScript* instance = GetCaster()->GetInstanceScript()) + { + Position p = {4356.77f, 2971.90f, 360.52f, M_PI / 2}; + if (Creature* l = instance->instance->SummonCreature(NPC_VENGEFUL_FLESHREAPER, p)) + { + bool hasTarget = false; + Unit* target = nullptr; + if ((target = l->SelectNearestTarget(20.0f))) + hasTarget = true; + else { - (*itr)->AI()->Talk(SAY_TRAP_ACTIVATE); - (*itr)->RemoveAurasDueToSpell(SPELL_STONEFORM); - (*itr)->AI()->SetData(1, 1); - break; + target = l->SelectNearestTarget(120.0f); + l->GetMotionMaster()->MoveJump(l->GetPositionX(), l->GetPositionY() + 55.0f, l->GetPositionZ(), 20.0f, 6.0f); } - } - } - - void Register() override - { - OnEffectHit += SpellEffectFn(spell_icc_sprit_alarm_SpellScript::HandleEvent, EFFECT_2, SPELL_EFFECT_SEND_EVENT); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_icc_sprit_alarm_SpellScript(); - } -}; - -class spell_icc_geist_alarm : public SpellScriptLoader -{ -public: - spell_icc_geist_alarm() : SpellScriptLoader("spell_icc_geist_alarm") { } - - class spell_icc_geist_alarm_SpellScript : public SpellScript - { - PrepareSpellScript(spell_icc_geist_alarm_SpellScript); - - void HandleEvent(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - if (InstanceScript* instance = GetCaster()->GetInstanceScript()) - { - Position p = {4356.77f, 2971.90f, 360.52f, M_PI / 2}; - if (Creature* l = instance->instance->SummonCreature(NPC_VENGEFUL_FLESHREAPER, p)) + l->AI()->Talk(0); + l->AI()->AttackStart(target); + l->AddThreat(target, 1.0f); + for (uint8 i = 0; i < 5; ++i) { - bool hasTarget = false; - Unit* target = nullptr; - if ((target = l->SelectNearestTarget(20.0f))) - hasTarget = true; - else + float dist = 2.0f + rand_norm() * 4.0f; + float angle = rand_norm() * 2 * M_PI; + Position pos(p); + l->MovePosition(pos, dist, angle); + if (Creature* c = l->SummonCreature(NPC_VENGEFUL_FLESHREAPER, pos, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30 * MINUTE * IN_MILLISECONDS)) { - target = l->SelectNearestTarget(120.0f); - l->GetMotionMaster()->MoveJump(l->GetPositionX(), l->GetPositionY() + 55.0f, l->GetPositionZ(), 20.0f, 6.0f); - } - l->AI()->Talk(0); - l->AI()->AttackStart(target); - l->AddThreat(target, 1.0f); - for (uint8 i = 0; i < 5; ++i) - { - float dist = 2.0f + rand_norm() * 4.0f; - float angle = rand_norm() * 2 * M_PI; - Position pos(p); - l->MovePosition(pos, dist, angle); - if (Creature* c = l->SummonCreature(NPC_VENGEFUL_FLESHREAPER, pos, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30 * MINUTE * IN_MILLISECONDS)) - { - c->AI()->AttackStart(l->GetVictim()); - c->AddThreat(l->GetVictim(), 1.0f); - if (!hasTarget) - c->GetMotionMaster()->MoveJump(c->GetPositionX(), c->GetPositionY() + 55.0f, c->GetPositionZ(), 20.0f, 6.0f); - } + c->AI()->AttackStart(l->GetVictim()); + c->AddThreat(l->GetVictim(), 1.0f); + if (!hasTarget) + c->GetMotionMaster()->MoveJump(c->GetPositionX(), c->GetPositionY() + 55.0f, c->GetPositionZ(), 20.0f, 6.0f); } } } } + } - void Register() override - { - OnEffectHit += SpellEffectFn(spell_icc_geist_alarm_SpellScript::HandleEvent, EFFECT_2, SPELL_EFFECT_SEND_EVENT); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_icc_geist_alarm_SpellScript(); + OnEffectHit += SpellEffectFn(spell_icc_geist_alarm::HandleEvent, EFFECT_2, SPELL_EFFECT_SEND_EVENT); } }; -class spell_frost_giant_death_plague : public SpellScriptLoader +class spell_frost_giant_death_plague : public SpellScript { -public: - spell_frost_giant_death_plague() : SpellScriptLoader("spell_frost_giant_death_plague") { } + PrepareSpellScript(spell_frost_giant_death_plague); - class spell_frost_giant_death_plague_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareSpellScript(spell_frost_giant_death_plague_SpellScript); + return ValidateSpellInfo({ SPELL_DEATH_PLAGUE_AURA, SPELL_DEATH_PLAGUE_KILL, SPELL_RECENTLY_INFECTED }); + } - // First effect - void CountTargets(std::list& targets) - { - targets.remove_if(Acore::ObjectTypeIdCheck(TYPEID_PLAYER, false)); - targets.remove_if(Acore::ObjectGUIDCheck(GetCaster()->GetGUID(), true)); + // First effect + void CountTargets(std::list& targets) + { + targets.remove_if(Acore::ObjectTypeIdCheck(TYPEID_PLAYER, false)); + targets.remove_if(Acore::ObjectGUIDCheck(GetCaster()->GetGUID(), true)); - bool kill = true; - for (std::list::const_iterator itr = targets.begin(); itr != targets.end(); ++itr) - if (!(*itr)->ToUnit()->HasAura(SPELL_DEATH_PLAGUE_AURA)) - { - kill = false; - break; - } - if (kill) - GetCaster()->CastSpell(GetCaster(), SPELL_DEATH_PLAGUE_KILL, true); - else + bool kill = true; + for (std::list::const_iterator itr = targets.begin(); itr != targets.end(); ++itr) + if (!(*itr)->ToUnit()->HasAura(SPELL_DEATH_PLAGUE_AURA)) { - GetCaster()->CastSpell(GetCaster(), SPELL_RECENTLY_INFECTED, true); - targets.push_back(GetCaster()); + kill = false; + break; } - } - - void HandleScript(SpellEffIndex /*effIndex*/) + if (kill) + GetCaster()->CastSpell(GetCaster(), SPELL_DEATH_PLAGUE_KILL, true); + else { - if (!GetHitUnit()->HasAura(SPELL_RECENTLY_INFECTED) && !GetHitUnit()->HasAura(SPELL_DEATH_PLAGUE_AURA)) - GetHitUnit()->CastSpell(GetHitUnit(), SPELL_DEATH_PLAGUE_AURA, true); + GetCaster()->CastSpell(GetCaster(), SPELL_RECENTLY_INFECTED, true); + targets.push_back(GetCaster()); } + } - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_frost_giant_death_plague_SpellScript::CountTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ALLY); - OnEffectHitTarget += SpellEffectFn(spell_frost_giant_death_plague_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); - } - }; - - SpellScript* GetSpellScript() const override + void HandleScript(SpellEffIndex /*effIndex*/) { - return new spell_frost_giant_death_plague_SpellScript(); + if (!GetHitUnit()->HasAura(SPELL_RECENTLY_INFECTED) && !GetHitUnit()->HasAura(SPELL_DEATH_PLAGUE_AURA)) + GetHitUnit()->CastSpell(GetHitUnit(), SPELL_DEATH_PLAGUE_AURA, true); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_frost_giant_death_plague::CountTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ALLY); + OnEffectHitTarget += SpellEffectFn(spell_frost_giant_death_plague::HandleScript, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); } }; -class spell_icc_harvest_blight_specimen : public SpellScriptLoader +class spell_icc_harvest_blight_specimen : public SpellScript { -public: - spell_icc_harvest_blight_specimen() : SpellScriptLoader("spell_icc_harvest_blight_specimen") { } + PrepareSpellScript(spell_icc_harvest_blight_specimen); - class spell_icc_harvest_blight_specimen_SpellScript : public SpellScript + void HandleScript(SpellEffIndex effIndex) { - PrepareSpellScript(spell_icc_harvest_blight_specimen_SpellScript); + PreventHitDefaultEffect(effIndex); + GetHitUnit()->RemoveAurasDueToSpell(uint32(GetEffectValue())); + } - void HandleScript(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - GetHitUnit()->RemoveAurasDueToSpell(uint32(GetEffectValue())); - } - - void HandleQuestComplete(SpellEffIndex /*effIndex*/) - { - GetHitUnit()->RemoveAurasDueToSpell(uint32(GetEffectValue())); - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_icc_harvest_blight_specimen_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - OnEffectHitTarget += SpellEffectFn(spell_icc_harvest_blight_specimen_SpellScript::HandleQuestComplete, EFFECT_1, SPELL_EFFECT_QUEST_COMPLETE); - } - }; - - SpellScript* GetSpellScript() const override + void HandleQuestComplete(SpellEffIndex /*effIndex*/) { - return new spell_icc_harvest_blight_specimen_SpellScript(); + GetHitUnit()->RemoveAurasDueToSpell(uint32(GetEffectValue())); + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_icc_harvest_blight_specimen::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + OnEffectHitTarget += SpellEffectFn(spell_icc_harvest_blight_specimen::HandleQuestComplete, EFFECT_1, SPELL_EFFECT_QUEST_COMPLETE); } }; @@ -2150,103 +2105,75 @@ public: } }; -class spell_svalna_revive_champion : public SpellScriptLoader +class spell_svalna_revive_champion : public SpellScript { -public: - spell_svalna_revive_champion() : SpellScriptLoader("spell_svalna_revive_champion") { } + PrepareSpellScript(spell_svalna_revive_champion); - class spell_svalna_revive_champion_SpellScript : public SpellScript + void RemoveAliveTarget(std::list& targets) { - PrepareSpellScript(spell_svalna_revive_champion_SpellScript); + targets.remove_if(AliveCheck()); + Acore::Containers::RandomResize(targets, 2); + } - void RemoveAliveTarget(std::list& targets) - { - targets.remove_if(AliveCheck()); - Acore::Containers::RandomResize(targets, 2); - } - - void Land(SpellEffIndex /*effIndex*/) - { - Creature* caster = GetCaster()->ToCreature(); - if (!caster) - return; - - Position pos = caster->GetNearPosition(5.0f, 0.0f); - pos.m_positionZ = caster->GetMap()->GetHeight(caster->GetPhaseMask(), pos.GetPositionX(), pos.GetPositionY(), caster->GetPositionZ(), true, 50.0f); - pos.m_positionZ += 0.1f; - caster->SendMeleeAttackStop(caster->GetVictim()); - caster->GetMotionMaster()->MoveLand(POINT_LAND, pos, 7.0f); - } - - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_svalna_revive_champion_SpellScript::RemoveAliveTarget, EFFECT_0, TARGET_UNIT_DEST_AREA_ENTRY); - OnEffectHit += SpellEffectFn(spell_svalna_revive_champion_SpellScript::Land, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void Land(SpellEffIndex /*effIndex*/) { - return new spell_svalna_revive_champion_SpellScript(); + Creature* caster = GetCaster()->ToCreature(); + if (!caster) + return; + + Position pos = caster->GetNearPosition(5.0f, 0.0f); + pos.m_positionZ = caster->GetMap()->GetHeight(caster->GetPhaseMask(), pos.GetPositionX(), pos.GetPositionY(), caster->GetPositionZ(), true, 50.0f); + pos.m_positionZ += 0.1f; + caster->SendMeleeAttackStop(caster->GetVictim()); + caster->GetMotionMaster()->MoveLand(POINT_LAND, pos, 7.0f); + } + + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_svalna_revive_champion::RemoveAliveTarget, EFFECT_0, TARGET_UNIT_DEST_AREA_ENTRY); + OnEffectHit += SpellEffectFn(spell_svalna_revive_champion::Land, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; -class spell_svalna_remove_spear : public SpellScriptLoader +class spell_svalna_remove_spear : public SpellScript { -public: - spell_svalna_remove_spear() : SpellScriptLoader("spell_svalna_remove_spear") { } + PrepareSpellScript(spell_svalna_remove_spear); - class spell_svalna_remove_spear_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareSpellScript(spell_svalna_remove_spear_SpellScript); + return ValidateSpellInfo({ SPELL_IMPALING_SPEAR }); + } - void HandleScript(SpellEffIndex effIndex) - { - PreventHitDefaultEffect(effIndex); - if (Creature* target = GetHitCreature()) - { - if (Unit* vehicle = target->GetVehicleBase()) - vehicle->RemoveAurasDueToSpell(SPELL_IMPALING_SPEAR); - target->DespawnOrUnsummon(1); - } - } - - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_svalna_remove_spear_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void HandleScript(SpellEffIndex effIndex) { - return new spell_svalna_remove_spear_SpellScript(); + PreventHitDefaultEffect(effIndex); + if (Creature* target = GetHitCreature()) + { + if (Unit* vehicle = target->GetVehicleBase()) + vehicle->RemoveAurasDueToSpell(SPELL_IMPALING_SPEAR); + target->DespawnOrUnsummon(1); + } + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_svalna_remove_spear::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); } }; -class spell_icc_soul_missile : public SpellScriptLoader +class spell_icc_soul_missile : public SpellScript { -public: - spell_icc_soul_missile() : SpellScriptLoader("spell_icc_soul_missile") { } + PrepareSpellScript(spell_icc_soul_missile); - class spell_icc_soul_missile_SpellScript : public SpellScript + void RelocateDest() { - PrepareSpellScript(spell_icc_soul_missile_SpellScript); + static Position const offset = {0.0f, 0.0f, 200.0f, 0.0f}; + const_cast(GetExplTargetDest())->RelocateOffset(offset); + } - void RelocateDest() - { - static Position const offset = {0.0f, 0.0f, 200.0f, 0.0f}; - const_cast(GetExplTargetDest())->RelocateOffset(offset); - } - - void Register() override - { - OnCast += SpellCastFn(spell_icc_soul_missile_SpellScript::RelocateDest); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_icc_soul_missile_SpellScript(); + OnCast += SpellCastFn(spell_icc_soul_missile::RelocateDest); } }; @@ -2346,207 +2273,160 @@ public: // pussywizard below: -class spell_icc_web_wrap : public SpellScriptLoader +class spell_icc_web_wrap_aura : public AuraScript { -public: - spell_icc_web_wrap() : SpellScriptLoader("spell_icc_web_wrap") { } + PrepareAuraScript(spell_icc_web_wrap_aura); - class spell_icc_web_wrap_AuraScript : public AuraScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareAuraScript(spell_icc_web_wrap_AuraScript); + return ValidateSpellInfo({ 71010 }); + } - void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) - { - Unit* target = GetTarget(); - if (!target->HasAura(71010)) - target->CastSpell(target, 71010, true); - } - - void Register() override - { - OnEffectRemove += AuraEffectRemoveFn(spell_icc_web_wrap_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_MOD_ROOT, AURA_EFFECT_HANDLE_REAL); - } - }; - - AuraScript* GetAuraScript() const override + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - return new spell_icc_web_wrap_AuraScript(); + Unit* target = GetTarget(); + if (!target->HasAura(71010)) + target->CastSpell(target, 71010, true); + } + + void Register() override + { + OnEffectRemove += AuraEffectRemoveFn(spell_icc_web_wrap_aura::OnRemove, EFFECT_0, SPELL_AURA_MOD_ROOT, AURA_EFFECT_HANDLE_REAL); } }; -class spell_icc_dark_reckoning : public SpellScriptLoader +class spell_icc_dark_reckoning_aura : public AuraScript { -public: - spell_icc_dark_reckoning() : SpellScriptLoader("spell_icc_dark_reckoning") { } + PrepareAuraScript(spell_icc_dark_reckoning_aura); - class spell_icc_dark_reckoning_AuraScript : public AuraScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareAuraScript(spell_icc_dark_reckoning_AuraScript); + return ValidateSpellInfo({ 69482 }); + } - void OnPeriodic(AuraEffect const* /*aurEff*/) - { - if (Unit* caster = GetCaster()) - caster->CastSpell(GetTarget(), 69482, true); - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_icc_dark_reckoning_AuraScript::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); - } - }; - - AuraScript* GetAuraScript() const override + void OnPeriodic(AuraEffect const* /*aurEff*/) { - return new spell_icc_dark_reckoning_AuraScript(); + if (Unit* caster = GetCaster()) + caster->CastSpell(GetTarget(), 69482, true); + } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_icc_dark_reckoning_aura::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); } }; -class spell_stinky_precious_decimate : public SpellScriptLoader +class spell_stinky_precious_decimate : public SpellScript { -public: - spell_stinky_precious_decimate() : SpellScriptLoader("spell_stinky_precious_decimate") { } + PrepareSpellScript(spell_stinky_precious_decimate); - class spell_stinky_precious_decimate_SpellScript : public SpellScript + void HandleScript(SpellEffIndex /*effIndex*/) { - PrepareSpellScript(spell_stinky_precious_decimate_SpellScript); - - void HandleScript(SpellEffIndex /*effIndex*/) + if (GetHitUnit()->GetHealthPct() > float(GetEffectValue())) { - if (GetHitUnit()->GetHealthPct() > float(GetEffectValue())) + uint32 newHealth = GetHitUnit()->GetMaxHealth() * uint32(GetEffectValue()) / 100; + GetHitUnit()->SetHealth(newHealth); + } + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_stinky_precious_decimate::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } +}; + +class spell_icc_yf_frozen_orb_aura : public AuraScript +{ + PrepareAuraScript(spell_icc_yf_frozen_orb_aura); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ 71285 }); + } + + void HandleEffectPeriodic(AuraEffect const* /*aurEff*/) + { + PreventDefaultAction(); + if (Unit* c = GetCaster()) + if (Unit* t = GetTarget()) + c->CastSpell(t->GetPositionX(), t->GetPositionY(), t->GetPositionZ(), 71285, true); + } + + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_icc_yf_frozen_orb_aura::HandleEffectPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + } +}; + +class spell_icc_yh_volley_aura : public AuraScript +{ + PrepareAuraScript(spell_icc_yh_volley_aura); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ 41089 }); + } + + void HandleEffectPeriodic(AuraEffect const* aurEff) + { + PreventDefaultAction(); + if (Unit* c = GetCaster()) + if (Unit* t = GetTarget()) { - uint32 newHealth = GetHitUnit()->GetMaxHealth() * uint32(GetEffectValue()) / 100; - GetHitUnit()->SetHealth(newHealth); + if ((aurEff->GetTickNumber() % 5) == 0) + c->SetFacingToObject(t); + int32 basepoints1 = aurEff->GetAmount(); + c->CastCustomSpell(t, 41089, 0, &basepoints1, 0, true); } - } + } - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_stinky_precious_decimate_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); - } - }; - - SpellScript* GetSpellScript() const override + void Register() override { - return new spell_stinky_precious_decimate_SpellScript(); + OnEffectPeriodic += AuraEffectPeriodicFn(spell_icc_yh_volley_aura::HandleEffectPeriodic, EFFECT_1, SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE); } }; -class spell_icc_yf_frozen_orb : public SpellScriptLoader +class spell_icc_yd_summon_undead : public SpellScript { -public: - spell_icc_yf_frozen_orb() : SpellScriptLoader("spell_icc_yf_frozen_orb") { } + PrepareSpellScript(spell_icc_yd_summon_undead); - class spell_icc_yf_frozen_orb_AuraScript : public AuraScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareAuraScript(spell_icc_yf_frozen_orb_AuraScript) + return ValidateSpellInfo({ 71302 }); + } - void HandleEffectPeriodic(AuraEffect const* /*aurEff*/) - { - PreventDefaultAction(); - if (Unit* c = GetCaster()) - if (Unit* t = GetTarget()) - c->CastSpell(t->GetPositionX(), t->GetPositionY(), t->GetPositionZ(), 71285, true); - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_icc_yf_frozen_orb_AuraScript::HandleEffectPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); - } - }; - - AuraScript* GetAuraScript() const override + void HandleDummyLaunch(SpellEffIndex /*effIndex*/) { - return new spell_icc_yf_frozen_orb_AuraScript(); + if (Unit* c = GetCaster()) + if (c->GetMapId() == 631) + for (uint8 i = 0; i < 5; ++i) + c->CastSpell(c, 71302, true); + } + + void Register() override + { + OnEffectLaunch += SpellEffectFn(spell_icc_yd_summon_undead::HandleDummyLaunch, EFFECT_0, SPELL_EFFECT_DUMMY); } }; -class spell_icc_yh_volley : public SpellScriptLoader +class spell_icc_shattered_bones : public SpellScript { -public: - spell_icc_yh_volley() : SpellScriptLoader("spell_icc_yh_volley") { } + PrepareSpellScript(spell_icc_shattered_bones); - class spell_icc_yh_volley_AuraScript : public AuraScript + bool Validate(SpellInfo const* /*spellInfo*/) override { - PrepareAuraScript(spell_icc_yh_volley_AuraScript) - - void HandleEffectPeriodic(AuraEffect const* aurEff) - { - PreventDefaultAction(); - if (Unit* c = GetCaster()) - if (Unit* t = GetTarget()) - { - if ((aurEff->GetTickNumber() % 5) == 0) - c->SetFacingToObject(t); - int32 basepoints1 = aurEff->GetAmount(); - c->CastCustomSpell(t, 41089, 0, &basepoints1, 0, true); - } - } - - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_icc_yh_volley_AuraScript::HandleEffectPeriodic, EFFECT_1, SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE); - } - }; - - AuraScript* GetAuraScript() const override - { - return new spell_icc_yh_volley_AuraScript(); + return ValidateSpellInfo({ 70963 }); } -}; -class spell_icc_yd_summon_undead : public SpellScriptLoader -{ -public: - spell_icc_yd_summon_undead() : SpellScriptLoader("spell_icc_yd_summon_undead") { } - - class spell_icc_yd_summon_undead_SpellScript : public SpellScript + void HandleDummy() { - PrepareSpellScript(spell_icc_yd_summon_undead_SpellScript); - - void HandleDummyLaunch(SpellEffIndex /*effIndex*/) - { - if (Unit* c = GetCaster()) - if (c->GetMapId() == 631) - for (uint8 i = 0; i < 5; ++i) - c->CastSpell(c, 71302, true); - } - - void Register() override - { - OnEffectLaunch += SpellEffectFn(spell_icc_yd_summon_undead_SpellScript::HandleDummyLaunch, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_icc_yd_summon_undead_SpellScript(); + for (uint8 i = 0; i < 10; ++i) + GetCaster()->CastSpell((Unit*)nullptr, 70963, true); } -}; -class spell_icc_shattered_bones : public SpellScriptLoader -{ -public: - spell_icc_shattered_bones() : SpellScriptLoader("spell_icc_shattered_bones") { } - - class spell_icc_shattered_bones_SpellScript : public SpellScript + void Register() override { - PrepareSpellScript(spell_icc_shattered_bones_SpellScript); - - void HandleDummy() - { - for (uint8 i = 0; i < 10; ++i) - GetCaster()->CastSpell((Unit*)nullptr, 70963, true); - } - - void Register() override - { - AfterCast += SpellCastFn(spell_icc_shattered_bones_SpellScript::HandleDummy); - } - }; - - SpellScript* GetSpellScript() const override - { - return new spell_icc_shattered_bones_SpellScript(); + AfterCast += SpellCastFn(spell_icc_shattered_bones::HandleDummy); } }; @@ -3780,28 +3660,29 @@ void AddSC_icecrown_citadel() new npc_frostwing_vrykul(); new npc_impaling_spear(); new npc_arthas_teleport_visual(); - new spell_icc_stoneform(); - new spell_icc_sprit_alarm(); - new spell_icc_geist_alarm(); - new spell_frost_giant_death_plague(); - new spell_icc_harvest_blight_specimen(); - new spell_trigger_spell_from_caster("spell_svalna_caress_of_death", SPELL_IMPALING_SPEAR_KILL); - new spell_svalna_revive_champion(); - new spell_svalna_remove_spear(); - new spell_icc_soul_missile(); + RegisterSpellScript(spell_icc_stoneform_aura); + RegisterSpellScript(spell_icc_sprit_alarm); + RegisterSpellScript(spell_icc_geist_alarm); + RegisterSpellScript(spell_frost_giant_death_plague); + RegisterSpellScript(spell_icc_harvest_blight_specimen); + RegisterSpellScriptWithArgs(spell_trigger_spell_from_caster, "spell_svalna_caress_of_death", SPELL_IMPALING_SPEAR_KILL); + + RegisterSpellScript(spell_svalna_revive_champion); + RegisterSpellScript(spell_svalna_remove_spear); + RegisterSpellScript(spell_icc_soul_missile); new at_icc_saurfang_portal(); new at_icc_shutdown_traps(); new at_icc_start_blood_quickening(); new at_icc_start_frostwing_gauntlet(); // pussywizard below: - new spell_icc_web_wrap(); - new spell_icc_dark_reckoning(); - new spell_stinky_precious_decimate(); - new spell_icc_yf_frozen_orb(); - new spell_icc_yh_volley(); - new spell_icc_yd_summon_undead(); - new spell_icc_shattered_bones(); + RegisterSpellScript(spell_icc_web_wrap_aura); + RegisterSpellScript(spell_icc_dark_reckoning_aura); + RegisterSpellScript(spell_stinky_precious_decimate); + RegisterSpellScript(spell_icc_yf_frozen_orb_aura); + RegisterSpellScript(spell_icc_yh_volley_aura); + RegisterSpellScript(spell_icc_yd_summon_undead); + RegisterSpellScript(spell_icc_shattered_bones); new npc_icc_skybreaker_hierophant(); new npc_icc_skybreaker_marksman(); new npc_icc_skybreaker_vicar(); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h index fa4516546..5c94d4880 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h +++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h @@ -591,39 +591,26 @@ enum ItemIds ITEM_GOBLIN_ROCKET_PACK = 49278 }; -class spell_trigger_spell_from_caster : public SpellScriptLoader +class spell_trigger_spell_from_caster : public SpellScript { + PrepareSpellScript(spell_trigger_spell_from_caster); + public: - spell_trigger_spell_from_caster(char const* scriptName, uint32 triggerId) : SpellScriptLoader(scriptName), _triggerId(triggerId) { } + spell_trigger_spell_from_caster(uint32 triggerId) : SpellScript(), _triggerId(triggerId) { } - class spell_trigger_spell_from_caster_SpellScript : public SpellScript + bool Validate(SpellInfo const* /*spell*/) override { - PrepareSpellScript(spell_trigger_spell_from_caster_SpellScript); + return ValidateSpellInfo({ _triggerId }); + } - public: - spell_trigger_spell_from_caster_SpellScript(uint32 triggerId) : SpellScript(), _triggerId(triggerId) { } - - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ _triggerId }); - } - - void HandleTrigger() - { - GetCaster()->CastSpell(GetHitUnit(), _triggerId, true); - } - - void Register() override - { - AfterHit += SpellHitFn(spell_trigger_spell_from_caster_SpellScript::HandleTrigger); - } - - uint32 _triggerId; - }; - - SpellScript* GetSpellScript() const override + void HandleTrigger() { - return new spell_trigger_spell_from_caster_SpellScript(_triggerId); + GetCaster()->CastSpell(GetHitUnit(), _triggerId, true); + } + + void Register() override + { + AfterHit += SpellHitFn(spell_trigger_spell_from_caster::HandleTrigger); } private: