diff --git a/Source/Scripts/Spells/Generic.cs b/Source/Scripts/Spells/Generic.cs index c2fe5a12c..dd3028d9a 100644 --- a/Source/Scripts/Spells/Generic.cs +++ b/Source/Scripts/Spells/Generic.cs @@ -1240,8 +1240,8 @@ namespace Scripts.Spells.Generic { void HandleDamageCalc(uint effIndex) { - Unit caster = GetCaster(); - if (caster == null || !caster.IsCreature()) + Creature caster = GetCaster().ToCreature(); + if (caster == null) return; int damage = 0; @@ -1449,6 +1449,25 @@ namespace Scripts.Spells.Generic } } + [Script] + class spell_gen_despawn_target : SpellScript + { + void HandleDespawn(uint effIndex) + { + if (GetEffectInfo().IsEffect(SpellEffectName.Dummy) || GetEffectInfo().IsEffect(SpellEffectName.ScriptEffect)) + { + Creature target = GetHitCreature(); + if (target != null) + target.DespawnOrUnsummon(); + } + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDespawn, SpellConst.EffectAll, SpellEffectName.Any)); + } + } + [Script] // 70769 Divine Storm! class spell_gen_divine_storm_cd_reset : SpellScript { @@ -2379,6 +2398,28 @@ namespace Scripts.Spells.Generic } } + [Script] + class spell_gen_player_say : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return CliDB.BroadcastTextStorage.HasRecord((uint)spellInfo.GetEffect(0).CalcValue()); + } + + void HandleScript(uint effIndex) + { + // Note: target here is always player; caster here is gameobject, creature or player (self cast) + Unit target = GetHitUnit(); + if (target != null) + target.Say((uint)GetEffectValue(), target); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + } + } + [Script("spell_item_soul_harvesters_charm")] [Script("spell_item_commendation_of_kaelthas")] [Script("spell_item_corpse_tongue_coin")] @@ -2952,50 +2993,6 @@ namespace Scripts.Spells.Generic } } - [Script("spell_gen_summon_fire_elemental", SpellIds.SummonFireElemental)] - [Script("spell_gen_summon_earth_elemental", SpellIds.SummonEarthElemental)] - class spell_gen_summon_elemental : AuraScript - { - readonly uint _spellId; - - public spell_gen_summon_elemental(uint spellId) - { - _spellId = spellId; - } - - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(_spellId); - } - - void AfterApply(AuraEffect aurEff, AuraEffectHandleModes mode) - { - if (GetCaster()) - { - Unit owner = GetCaster().GetOwner(); - if (owner) - owner.CastSpell(owner, _spellId, true); - } - } - - void AfterRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - if (GetCaster()) - { - Unit owner = GetCaster().GetOwner(); - if (owner) - if (owner.IsTypeId(TypeId.Player)) // @todo this check is maybe wrong - owner.ToPlayer().RemovePet(null, PetSaveMode.NotInSlot, true); - } - } - - public override void Register() - { - AfterEffectApply.Add(new EffectApplyHandler(AfterApply, 1, AuraType.Dummy, AuraEffectHandleModes.Real)); - AfterEffectRemove.Add(new EffectApplyHandler(AfterRemove, 1, AuraType.Dummy, AuraEffectHandleModes.Real)); - } - } - [Script] class spell_gen_summon_tournament_mount : SpellScript { @@ -3408,16 +3405,12 @@ namespace Scripts.Spells.Generic void HandleScript(uint effIndex) { - Unit caster = GetCaster(); - if (caster != null) + TempSummon casterSummon = GetCaster().ToTempSummon(); + if (casterSummon != null) { - TempSummon casterSummon = caster.ToTempSummon(); - if (casterSummon != null) - { - Player target = casterSummon.GetSummonerUnit().ToPlayer(); - if (target != null) - casterSummon.Whisper((uint)GetEffectValue(), target, false); - } + Player target = casterSummon.GetSummonerUnit().ToPlayer(); + if (target != null) + casterSummon.Whisper((uint)GetEffectValue(), target, false); } } diff --git a/Source/Scripts/Spells/Items.cs b/Source/Scripts/Spells/Items.cs index eb251ca59..53b1be93a 100644 --- a/Source/Scripts/Spells/Items.cs +++ b/Source/Scripts/Spells/Items.cs @@ -2633,35 +2633,6 @@ namespace Scripts.Spells.Items } } - [Script] - class spell_item_crystal_prison_dummy_dnd : SpellScript - { - public override bool Validate(SpellInfo spell) - { - if (Global.ObjectMgr.GetGameObjectTemplate(ObjectIds.ImprisonedDoomguard) == null) - return false; - return true; - } - - void HandleDummy(uint effIndex) - { - Creature target = GetHitCreature(); - if (target) - { - if (target.IsDead() && !target.IsPet()) - { - GetCaster().SummonGameObject(ObjectIds.ImprisonedDoomguard, target, Quaternion.CreateFromRotationMatrix(Extensions.fromEulerAnglesZYX(target.GetOrientation(), 0.0f, 0.0f)), TimeSpan.FromSeconds(target.GetRespawnTime() - GameTime.GetGameTime())); - target.DespawnOrUnsummon(); - } - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } - } - [Script] class spell_item_reindeer_transformation : SpellScript { diff --git a/Source/Scripts/Spells/Quest.cs b/Source/Scripts/Spells/Quest.cs index 01358a3c6..d10f5b98c 100644 --- a/Source/Scripts/Spells/Quest.cs +++ b/Source/Scripts/Spells/Quest.cs @@ -70,29 +70,15 @@ namespace Scripts.Spells.Quest //Quest12937 public const uint TriggerAidOfTheEarthen = 55809; - //Whoarethey - public const uint MaleDisguise = 38080; - public const uint FemaleDisguise = 38081; - public const uint GenericDisguise = 32756; - //Symboloflife public const uint PermanentFeignDeath = 29266; - //Stoppingthespread - public const uint Flames = 39199; - //BattleStandard public const uint PlantHordeBattleStandard = 59643; public const uint HordeBattleStandardState = 59642; public const uint AllianceBattleStandardState = 4339; public const uint JumpRocketBlast = 4340; - //Chumthewatersummons - public const uint SummonAngryKvaldir = 66737; - public const uint SummonNorthSeaMako = 66738; - public const uint SummonNorthSeaThresher = 66739; - public const uint SummonNorthSeaBlueShark = 66740; - //Redsnapperverytasty public const uint FishedUpRedSnapper = 29867; public const uint FishedUpMurloc = 29869; @@ -108,11 +94,6 @@ namespace Scripts.Spells.Quest //Focusonthebeach public const uint BunnyCreditBeam = 47390; - //Acleansingsong - public const uint SummonSpiritAtah = 52954; - public const uint SummonSpiritHakhalan = 52958; - public const uint SummonSpiritKoosu = 52959; - //Defendingwyrmresttemple public const uint SummonWyrmrestDefender = 49207; @@ -278,9 +259,6 @@ namespace Scripts.Spells.Quest //Quest12659 public const uint ScalpsKcBunny = 28622; - //Stoppingthespread - public const uint VillagerKillCredit = 18240; - //Salvaginglifesstength public const uint ShardKillCredit = 29303; @@ -727,33 +705,6 @@ namespace Scripts.Spells.Quest } } - // http://www.wowhead.com/quest=12683 Burning to Help - [Script] // 52308 Take Sputum Sample - class spell_q12683_take_sputum_sample : SpellScript - { - public override bool Validate(SpellInfo spellInfo) - { - return spellInfo.GetEffects().Count > 1; - } - - void HandleDummy(uint effIndex) - { - uint reqAuraId = (uint)GetEffectInfo(1).CalcValue(); - - Unit caster = GetCaster(); - if (caster.HasAuraEffect(reqAuraId, 0)) - { - uint spellId = (uint)GetEffectInfo(0).CalcValue(); - caster.CastSpell(caster, spellId, true); - } - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } - } - // http://www.wowhead.com/quest=12851 Going Bearback [Script] // 54798 FLAMING Arrow Triggered Effect class spell_q12851_going_bearback : AuraScript @@ -793,31 +744,6 @@ namespace Scripts.Spells.Quest } } - [Script] // 48917 - Who Are They: Cast from Questgiver - class spell_q10041_q10040_who_are_they : SpellScript - { - public override bool Validate(SpellInfo spellEntry) - { - return ValidateSpellInfo(SpellIds.MaleDisguise, SpellIds.FemaleDisguise, SpellIds.GenericDisguise); - } - - void HandleScript(uint effIndex) - { - PreventHitDefaultEffect(effIndex); - Player target = GetHitPlayer(); - if (target) - { - target.CastSpell(target, target.GetNativeGender() == Gender.Male ? SpellIds.MaleDisguise : SpellIds.FemaleDisguise, true); - target.CastSpell(target, SpellIds.GenericDisguise, true); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } - } - // http://www.wowhead.com/quest=12659 Scalps! [Script] // 52090 Ahunae's Knife class spell_q12659_ahunaes_knife : SpellScript @@ -845,35 +771,6 @@ namespace Scripts.Spells.Quest } } - [Script] // 32146 - Liquid Fire - class spell_q9874_liquid_fire : SpellScript - { - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Player); - } - - void HandleDummy(uint effIndex) - { - Player caster = GetCaster().ToPlayer(); - Creature target = GetHitCreature(); - if (target != null) - { - if (!target.HasAura(SpellIds.Flames)) - { - caster.KilledMonsterCredit(CreatureIds.VillagerKillCredit); - target.CastSpell(target, SpellIds.Flames, true); - target.DespawnOrUnsummon(TimeSpan.FromSeconds(60)); - } - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } - } - [Script] // 54190 - Lifeblood Dummy class spell_q12805_lifeblood_dummy : SpellScript { @@ -956,26 +853,6 @@ namespace Scripts.Spells.Quest } } - [Script] // 66741 - Chum the Water - class spell_q14112_14145_chum_the_water : SpellScript - { - public override bool Validate(SpellInfo spellEntry) - { - return ValidateSpellInfo(SpellIds.SummonAngryKvaldir, SpellIds.SummonNorthSeaMako, SpellIds.SummonNorthSeaThresher, SpellIds.SummonNorthSeaBlueShark); - } - - void HandleScriptEffect(uint effIndex) - { - Unit caster = GetCaster(); - caster.CastSpell(caster, RandomHelper.RAND(SpellIds.SummonAngryKvaldir, SpellIds.SummonNorthSeaMako, SpellIds.SummonNorthSeaThresher, SpellIds.SummonNorthSeaBlueShark)); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); - } - } - [Script] // 29866 - Cast Fishing Net class spell_q9452_cast_net : SpellScript { @@ -1000,30 +877,6 @@ namespace Scripts.Spells.Quest } } - [Script] // 66512 - Pound Drum - class spell_q14076_14092_pound_drum : SpellScript - { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.SummonDeepJormungar, SpellIds.StormforgedMoleMachine); - } - - void HandleSummon() - { - Unit caster = GetCaster(); - - if (RandomHelper.randChance(50)) - caster.CastSpell(caster, SpellIds.SummonDeepJormungar, true); - else - caster.CastSpell(caster, SpellIds.StormforgedMoleMachine, true); - } - - public override void Register() - { - OnCast.Add(new CastHandler(HandleSummon)); - } - } - [Script] class spell_q12279_cast_net : SpellScript { @@ -1038,70 +891,6 @@ namespace Scripts.Spells.Quest } } - [Script] // 56278 - Read Pronouncement - class spell_q12987_read_pronouncement : AuraScript - { - void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) - { - // player must cast kill credit and do emote text, according to sniff - Player target = GetTarget().ToPlayer(); - if (target) - { - Creature trigger = target.FindNearestCreature(CreatureIds.IceSpikeBunny, 25.0f); - if (trigger) - { - Global.CreatureTextMgr.SendChat(trigger, Misc.Say1, target, ChatMsg.Addon, Language.Addon, Game.CreatureTextRange.Normal, 0, SoundKitPlayType.Normal, Team.Other, false, target); - target.KilledMonsterCredit(CreatureIds.Killcredit); - Global.CreatureTextMgr.SendChat(trigger, Misc.Say2, target, ChatMsg.Addon, Language.Addon, Game.CreatureTextRange.Normal, 0, SoundKitPlayType.Normal, Team.Other, false, target); - } - } - } - - public override void Register() - { - AfterEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.None, AuraEffectHandleModes.Real)); - } - } - - [Script] // 48742 - Wintergarde Mine Explosion - class spell_q12277_wintergarde_mine_explosion : SpellScript - { - void HandleDummy(uint effIndex) - { - Creature unitTarget = GetHitCreature(); - if (unitTarget) - { - Unit caster = GetCaster(); - if (caster) - { - if (caster.IsTypeId(TypeId.Unit)) - { - Unit owner = caster.GetOwner(); - if (owner) - { - switch (unitTarget.GetEntry()) - { - case CreatureIds.UpperMineShaft: - caster.CastSpell(owner, SpellIds.UpperMineShaftCredit, true); - break; - case CreatureIds.LowerMineShaft: - caster.CastSpell(owner, SpellIds.LowerMineShaftCredit, true); - break; - default: - break; - } - } - } - } - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } - } - [Script] // 50546 - The Focus on the Beach: Ley Line Focus Control Ring Effect class spell_q12066_bunny_kill_credit : SpellScript { @@ -1118,34 +907,6 @@ namespace Scripts.Spells.Quest } } - [Script] // 52941 - Song of Cleansing - class spell_q12735_song_of_cleansing : SpellScript - { - void HandleScript(uint effIndex) - { - Unit caster = GetCaster(); - switch (caster.GetAreaId()) - { - case Misc.AreaIdBittertidelake: - caster.CastSpell(caster, SpellIds.SummonSpiritAtah); - break; - case Misc.AreaIdRiversheart: - caster.CastSpell(caster, SpellIds.SummonSpiritHakhalan); - break; - case Misc.AreaIdWintergraspriver: - caster.CastSpell(caster, SpellIds.SummonSpiritKoosu); - break; - default: - break; - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } - } - [Script] // 49213 - Defending Wyrmrest Temple: Character Script Cast From Gossip class spell_q12372_cast_from_gossip_trigger : SpellScript { @@ -1444,41 +1205,6 @@ namespace Scripts.Spells.Quest } } - [Script] // 56565 - Bear Flank Master - class spell_q13011_bear_flank_master : SpellScript - { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.BearFlankMaster, SpellIds.CreateBearFlank); - } - - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Unit); - } - - void HandleScript(uint effIndex) - { - Player player = GetHitPlayer(); - if (player) - { - if (RandomHelper.randChance(50)) - { - Creature creature = GetCaster().ToCreature(); - player.CastSpell(creature, SpellIds.BearFlankFail); - creature.GetAI().Talk(0, player); - } - else - player.CastSpell(player, SpellIds.CreateBearFlank); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } - } - // 57385 - Argent Cannon [Script] // 57412 - Reckoning Bomb class spell_q13086_cannons_target : SpellScript