From 2db988576a469976ba2a009633c74ba15d8f1458 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Thu, 20 Jul 2017 19:43:24 -0400 Subject: [PATCH] Implement generic script loaders to greatly reduce code duplication --- Game/Globals/ObjectManager.cs | 26 +- Game/Scripting/CoreScripts.cs | 63 +- Game/Scripting/ScriptManager.cs | 94 +- Scripts/EasternKingdoms/EversongWoods.cs | 367 +- .../Karazhan/AttumenMidnight.cs | 406 +- Scripts/EasternKingdoms/Karazhan/Curator.cs | 176 +- .../Karazhan/InstanceKarazhan.cs | 6 + Scripts/EasternKingdoms/Karazhan/Moroes.cs | 904 ++- .../EasternKingdoms/Karazhan/OperaEvent.cs | 2123 ++++--- .../ScarletEnclave/Chapter1.cs | 473 +- .../EasternKingdoms/TheStockade/BossHogger.cs | 172 +- Scripts/Kalimdor/ZoneAshenvale.cs | 408 +- Scripts/Kalimdor/ZoneDurotar.cs | 166 +- .../AzjolNerub/Ahnkahet/BossAmanitar.cs | 234 +- .../AzjolNerub/Ahnkahet/BossElderNadox.cs | 295 +- .../AzjolNerub/Ahnkahet/BossHeraldVolazj.cs | 393 +- .../Ahnkahet/BossJedogaShadowseeker.cs | 894 ++- .../AzjolNerub/Ahnkahet/BossPrinceTaldaram.cs | 572 +- .../AzjolNerub/Ahnkahet/InstanceAhnahet.cs | 108 +- .../AzjolNerub/AzjolNerub/BossAnubarak.cs | 930 ++- .../AzjolNerub/BossKrikthirTheGatewatcher.cs | 1272 ++-- .../AzjolNerub/AzjolNerub/BossNadronox.cs | 927 ++- .../AzjolNerub/InstanceAzjolNerub.cs | 70 +- .../TrialOfTheChampion/GrandChampions.cs | 827 ++- .../InstanceTrialOfTheChampion.cs | 16 +- .../TrialOfTheChampion/TrialOfTheChampion.cs | 13 +- .../TrialOfTheCrusader/LordJaraxxus.cs | 795 ++- .../TrialOfTheCrusader/NorthrendBeasts.cs | 1364 ++--- .../TrialOfTheCrusader/TrialOfTheCrusader.cs | 1418 +++-- .../TrialOfTheCrusaderConst.cs | 2 +- Scripts/Northrend/Dalaran.cs | 274 +- .../Northrend/DraktharonKeep/BossKingDred.cs | 352 +- Scripts/Northrend/DraktharonKeep/BossNovos.cs | 552 +- .../Northrend/DraktharonKeep/BossTharonJa.cs | 284 +- .../Northrend/DraktharonKeep/BossTrollgore.cs | 344 +- .../Northrend/Gundrak/BossDrakkariColossus.cs | 608 +- Scripts/Northrend/Gundrak/BossEck.cs | 150 +- Scripts/Northrend/Gundrak/InstanceGundrak.cs | 2 +- .../IcecrownCitadel/GunshipBattle.cs | 2464 ++++---- .../IcecrownCitadel/IcecrownCitadel.cs | 2654 ++++----- .../IcecrownCitadel/IcecrownCitadelConst.cs | 2 +- .../IcecrownCitadel/LadyDeathwhisper.cs | 1540 +++-- .../IcecrownCitadel/LordMarrowgar.cs | 921 ++- .../IcecrownCitadel/ValithriaDreamwalker.cs | 2 +- .../Nexus/EyeOfEternity/EyeOfEternity.cs | 2 +- Scripts/Northrend/Nexus/Nexus/BossAnomalus.cs | 322 +- .../Northrend/Nexus/Nexus/BossKeristrasza.cs | 288 +- .../Nexus/Nexus/BossMagusTelestra.cs | 458 +- .../Nexus/Nexus/BossNexusCommanders.cs | 102 +- Scripts/Northrend/Nexus/Nexus/BossOrmorok.cs | 312 +- .../Northrend/Nexus/Oculus/InstanceOculus.cs | 7 +- Scripts/Northrend/Ulduar/FlameLeviathan.cs | 3117 +++++----- Scripts/Northrend/Ulduar/Mimiron.cs | 3467 +++++------ Scripts/Northrend/Ulduar/Razorscale.cs | 10 +- Scripts/Northrend/Ulduar/UlduarConst.cs | 6 + Scripts/Northrend/Ulduar/Xt002.cs | 1278 ++-- Scripts/Northrend/Ulduar/YoggSaron.cs | 2 +- Scripts/Northrend/WinterGrasp.cs | 60 +- Scripts/Outlands/HellfirePeninsula.cs | 421 +- Scripts/Outlands/Zangarmarsh.cs | 68 +- Scripts/Pets/DeathKinght.cs | 154 +- Scripts/Pets/Generic.cs | 90 +- Scripts/Pets/Hunter.cs | 140 +- Scripts/Pets/Mage.cs | 361 +- Scripts/Pets/Priest.cs | 51 +- Scripts/Pets/Shaman.cs | 154 +- Scripts/Spells/DeathKnight.cs | 1006 ++-- Scripts/Spells/Druid.cs | 1360 ++--- Scripts/Spells/Generic.cs | 5159 +++++++---------- Scripts/Spells/Holiday.cs | 978 ++-- Scripts/Spells/Hunter.cs | 1124 ++-- Scripts/Spells/Items.cs | 4491 ++++++-------- Scripts/Spells/Mage.cs | 1133 ++-- Scripts/Spells/Monk.cs | 176 +- Scripts/Spells/Paladin.cs | 1289 ++-- Scripts/Spells/Priest.cs | 1684 +++--- Scripts/Spells/Quest.cs | 2222 +++---- Scripts/Spells/Rogue.cs | 209 +- Scripts/Spells/Shaman.cs | 1350 ++--- Scripts/Spells/Warlock.cs | 1492 ++--- Scripts/Spells/Warrior.cs | 1350 ++--- Scripts/World/BossEmeraldDragons.cs | 204 +- Scripts/World/DuelReset.cs | 2 +- Scripts/World/GameObjects.cs | 7 +- Scripts/World/Guards.cs | 512 +- Scripts/World/ItemScripts.cs | 6 +- Scripts/World/MobGenericCreature.cs | 28 +- Scripts/World/NpcProfessions.cs | 134 +- Scripts/World/NpcSpecial.cs | 2279 ++++---- 89 files changed, 28255 insertions(+), 36473 deletions(-) diff --git a/Game/Globals/ObjectManager.cs b/Game/Globals/ObjectManager.cs index df7f4a7ca..90dc2c1de 100644 --- a/Game/Globals/ObjectManager.cs +++ b/Game/Globals/ObjectManager.cs @@ -1585,17 +1585,16 @@ namespace Game foreach (var script in spellScriptsStorage.ToList()) { SpellInfo spellEntry = Global.SpellMgr.GetSpellInfo(script.Key); - Dictionary SpellScriptLoaders = Global.ScriptMgr.CreateSpellScriptLoaders(script.Key); + Dictionary SpellScriptLoaders = Global.ScriptMgr.CreateSpellScriptLoaders(script.Key); foreach (var pair in SpellScriptLoaders) { SpellScript spellScript = pair.Key.GetSpellScript(); - AuraScript auraScript = pair.Key.GetAuraScript(); bool valid = true; - if (spellScript == null && auraScript == null) + if (spellScript == null) { - Log.outError(LogFilter.Scripts, "Functions GetSpellScript() and GetAuraScript() of script `{0}` do not return objects - script skipped", GetScriptName(pair.Value)); + Log.outError(LogFilter.Scripts, "Functions GetSpellScript() of script `{0}` do not return object - script skipped", GetScriptName(pair.Value)); valid = false; } @@ -1607,6 +1606,22 @@ namespace Game valid = false; } + if (!valid) + spellScriptsStorage.Remove(pair.Value); + } + + Dictionary AuraScriptLoaders = Global.ScriptMgr.CreateAuraScriptLoaders(script.Key); + foreach (var pair in AuraScriptLoaders) + { + AuraScript auraScript = pair.Key.GetAuraScript(); + bool valid = true; + + if (auraScript == null) + { + Log.outError(LogFilter.Scripts, "Functions GetAuraScript() of script `{0}` do not return object - script skipped", GetScriptName(pair.Value)); + valid = false; + } + if (auraScript != null) { auraScript._Init(pair.Key.GetName(), spellEntry.Id); @@ -1639,6 +1654,9 @@ namespace Game if (string.IsNullOrEmpty(name)) return 0; + if (!scriptNamesStorage.Contains(name)) + return 0; + return (uint)scriptNamesStorage.IndexOf(name); } public uint GetAreaTriggerScriptId(uint triggerid) diff --git a/Game/Scripting/CoreScripts.cs b/Game/Scripting/CoreScripts.cs index 52bd7d844..a33114723 100644 --- a/Game/Scripting/CoreScripts.cs +++ b/Game/Scripting/CoreScripts.cs @@ -49,11 +49,12 @@ namespace Game.Scripting { InstanceMap instance = obj.GetMap().ToInstanceMap(); if (instance != null && instance.GetInstanceScript() != null) - if (instance.GetScriptId() == Global.ObjectMgr.GetScriptId(scriptName)) + if (instance.GetScriptName() == scriptName) return (T)Activator.CreateInstance(typeof(T), new object[] { obj }); return null; } + public static T GetInstanceAI(WorldObject obj) where T : class { InstanceMap instance = obj.GetMap().ToInstanceMap(); @@ -66,23 +67,57 @@ namespace Game.Scripting string _name; } + class GenericSpellScriptLoader : SpellScriptLoader where S : SpellScript + { + public GenericSpellScriptLoader(string name, object[] args) : base(name) + { + _args = args; + } + + public override SpellScript GetSpellScript() { return (S)Activator.CreateInstance(typeof(S), _args); } + + object[] _args; + } + + class GenericAuraScriptLoader : AuraScriptLoader where A : AuraScript + { + public GenericAuraScriptLoader(string name, object[] args) : base(name) + { + _args = args; + } + + public override AuraScript GetAuraScript() { return (A)Activator.CreateInstance(typeof(A), _args); } + + object[] _args; + } + public class SpellScriptLoader : ScriptObject { public SpellScriptLoader(string name) : base(name) { - Global.ScriptMgr.AddScript(this); + Global.ScriptMgr.AddScript(this); } public override bool IsDatabaseBound() { return true; } // Should return a fully valid SpellScript. public virtual SpellScript GetSpellScript() { return null; } + } + + public class AuraScriptLoader : ScriptObject + { + public AuraScriptLoader(string name) : base(name) + { + Global.ScriptMgr.AddScript(this); + } + + public override bool IsDatabaseBound() { return true; } // Should return a fully valid AuraScript. public virtual AuraScript GetAuraScript() { return null; } } - class WorldScript : ScriptObject + public class WorldScript : ScriptObject { protected WorldScript(string name) : base(name) { @@ -113,7 +148,7 @@ namespace Game.Scripting // Called when the world is actually shut down. public virtual void OnShutdown() { } } - + public class FormulaScript : ScriptObject { public FormulaScript(string name) : base(name) { } @@ -258,11 +293,29 @@ namespace Game.Scripting public virtual void ModifySpellDamageTaken(Unit target, Unit attacker, ref int damage) { } } + public class GenericCreatureScript : CreatureScript where AI : CreatureAI + { + public GenericCreatureScript(string name, object[] args) : base(name) + { + _args = args; + } + + public override CreatureAI GetAI(Creature me) + { + if (me.GetInstanceScript() != null) + return GetInstanceAI(me); + else + return (AI)Activator.CreateInstance(typeof(AI), me, _args); + } + + object[] _args; + } + public class CreatureScript : UnitScript { public CreatureScript(string name) : base(name, false) { - Global.ScriptMgr.AddScript(this); + Global.ScriptMgr.AddScript(this); } public override bool IsDatabaseBound() { return true; } diff --git a/Game/Scripting/ScriptManager.cs b/Game/Scripting/ScriptManager.cs index 7930aa7e4..d5dc40317 100644 --- a/Game/Scripting/ScriptManager.cs +++ b/Game/Scripting/ScriptManager.cs @@ -54,7 +54,7 @@ namespace Game.Scripting Log.outInfo(LogFilter.ServerLoading, "Loading C# scripts"); - FillSpellSummary(); + //FillSpellSummary(); if (LoadScripts()) Log.outInfo(LogFilter.ServerLoading, "Loaded {0} C# scripts in {1} ms", GetScriptCount(), Time.GetMSTimeDiffToNow(oldMSTime)); @@ -103,12 +103,62 @@ namespace Game.Scripting foreach (var attribute in attributes) { - if (!constructors.Any(p => p.GetParameters().Length == attribute.Args.Length)) + var genericType = type; + string name = type.Name; + + switch (type.BaseType.Name) { - Log.outError(LogFilter.Scripts, "Type: {0} has ScriptAttribute that does not match paramter count: {1} Can't load script.", type.Name, attribute.Args.Length); - continue; + case "SpellScript": + genericType = typeof(GenericSpellScriptLoader<>).MakeGenericType(type); + name = name.Replace("_SpellScript", ""); + break; + case "AuraScript": + genericType = typeof(GenericAuraScriptLoader<>).MakeGenericType(type); + name = name.Replace("_AuraScript", ""); + break; + case "SpellScriptLoader": + case "AuraScriptLoader": + case "WorldScript": + case "FormulaScript": + case "WorldMapScript": + case "InstanceMapScript": + case "BattlegroundMapScript": + case "ItemScript": + case "UnitScript": + case "CreatureScript": + case "GameObjectScript": + case "AreaTriggerScript": + case "OutdoorPvPScript": + case "WeatherScript": + case "AuctionHouseScript": + case "ConditionScript": + case "VehicleScript": + case "DynamicObjectScript": + case "TransportScript": + case "AchievementCriteriaScript": + case "PlayerScript": + case "GuildScript": + case "GroupScript": + case "AreaTriggerEntityScript": + case "SceneScript": + if (!attribute.Name.IsEmpty()) + name = attribute.Name; + + if (attribute.Args.Empty()) + Activator.CreateInstance(genericType); + else + Activator.CreateInstance(genericType, new object[] { name }.Combine(attribute.Args)); + + continue; + default: + genericType = typeof(GenericCreatureScript<>).MakeGenericType(type); + break; } - Activator.CreateInstance(type, attribute.Args); + + if (!attribute.Name.IsEmpty()) + name = attribute.Name; + + Activator.CreateInstance(genericType, name, attribute.Args); } } } @@ -389,7 +439,7 @@ namespace Game.Scripting var scriptList = new List(); var bounds = Global.ObjectMgr.GetSpellScriptsBounds(spellId); - var reg = GetScriptRegistry(); + var reg = GetScriptRegistry(); if (reg == null) return scriptList; @@ -432,6 +482,26 @@ namespace Game.Scripting return scriptDic; } + public Dictionary CreateAuraScriptLoaders(uint spellId) + { + var scriptDic = new Dictionary(); + var bounds = Global.ObjectMgr.GetSpellScriptsBounds(spellId); + + var reg = GetScriptRegistry(); + if (reg == null) + return scriptDic; + + foreach (var id in bounds) + { + var tmpscript = reg.GetScriptById(id); + if (tmpscript == null) + continue; + + scriptDic.Add(tmpscript, id); + } + + return scriptDic; + } //WorldScript public void OnOpenStateChange(bool open) @@ -1299,7 +1369,7 @@ namespace Game.Scripting return m_mPointMoveMap.LookupByKey(creatureEntry); } - ScriptRegistry GetScriptRegistry() where T : ScriptObject + public ScriptRegistry GetScriptRegistry() where T : ScriptObject { if (ScriptStorage.ContainsKey(typeof(T))) return (ScriptRegistry)ScriptStorage[typeof(T)]; @@ -1312,8 +1382,8 @@ namespace Game.Scripting Hashtable ScriptStorage = new Hashtable(); MultiMap m_mPointMoveMap = new MultiMap(); - - // creature entry + chain ID + + // creature entry + chain ID MultiMap, SplineChainLink> m_mSplineChainsMap = new MultiMap, SplineChainLink>(); // spline chains } @@ -1415,11 +1485,15 @@ namespace Game.Scripting [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] public class ScriptAttribute : Attribute { - public ScriptAttribute(params object[] args) + //public ScriptAttribute() { } + + public ScriptAttribute(string name="", params object[] args) { + Name = name; Args = args; } + public string Name { get; private set; } public object[] Args { get; private set; } } } diff --git a/Scripts/EasternKingdoms/EversongWoods.cs b/Scripts/EasternKingdoms/EversongWoods.cs index 01131e029..c9e6f297f 100644 --- a/Scripts/EasternKingdoms/EversongWoods.cs +++ b/Scripts/EasternKingdoms/EversongWoods.cs @@ -25,129 +25,124 @@ using Game.Scripting; namespace Scripts.EasternKingdoms { [Script] - class npc_apprentice_mirveda : CreatureScript + class npc_apprentice_mirveda : ScriptedAI { - public npc_apprentice_mirveda() : base("npc_apprentice_mirveda") { } - - class npc_apprentice_mirvedaAI : ScriptedAI + public npc_apprentice_mirveda(Creature creature) + : base(creature) { - public npc_apprentice_mirvedaAI(Creature creature) - : base(creature) - { - Summons = new SummonList(me); - } - - public override void Reset() - { - SetCombatMovement(false); - KillCount = 0; - PlayerGUID.Clear(); - Summons.DespawnAll(); - } - - public override void sQuestReward(Player player, Quest quest, uint opt) - { - if (quest.Id == QUEST_CORRUPTED_SOIL) - { - me.RemoveFlag64(UnitFields.NpcFlags, NPCFlags.QuestGiver); - _events.ScheduleEvent(EventTalk, 2000); - } - } - - public override void sQuestAccept(Player player, Quest quest) - { - if (quest.Id == QUEST_UNEXPECTED_RESULT) - { - me.SetFaction(FactionCombat); - me.RemoveFlag64(UnitFields.NpcFlags, NPCFlags.QuestGiver); - _events.ScheduleEvent(EventSummon, 1000); - PlayerGUID = player.GetGUID(); - } - } - - public override void EnterCombat(Unit who) - { - _events.ScheduleEvent(EventFireball, 1000); - } - - public override void JustSummoned(Creature summoned) - { - // This is the best I can do because AttackStart does nothing - summoned.GetMotionMaster().MovePoint(1, me.GetPositionX(), me.GetPositionY(), me.GetPositionZ()); - // summoned.AI().AttackStart(me); - Summons.Summon(summoned); - } - - public override void SummonedCreatureDies(Creature summoned, Unit who) - { - Summons.Despawn(summoned); - ++KillCount; - } - - public override void JustDied(Unit killer) - { - me.SetFaction(FactionNormal); - - if (!PlayerGUID.IsEmpty()) - { - Player player = Global.ObjAccessor.GetPlayer(me, PlayerGUID); - if (player) - player.FailQuest(QUEST_UNEXPECTED_RESULT); - } - } - - public override void UpdateAI(uint diff) - { - if (KillCount >= 3 && !PlayerGUID.IsEmpty()) - { - Player player = Global.ObjAccessor.GetPlayer(me, PlayerGUID); - if (player) - { - if (player.GetQuestStatus(QUEST_UNEXPECTED_RESULT) == QuestStatus.Incomplete) - { - player.CompleteQuest(QUEST_UNEXPECTED_RESULT); - me.SetFaction(FactionNormal); - me.SetFlag64(UnitFields.NpcFlags, NPCFlags.QuestGiver); - } - } - } - - _events.Update(diff); - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case EventTalk: - Talk(SayTestSoil); - _events.ScheduleEvent(EventAddQuestGiverFlag, 7000); - break; - case EventAddQuestGiverFlag: - me.SetFlag64(UnitFields.NpcFlags, NPCFlags.QuestGiver); - break; - case EventSummon: - me.SummonCreature(NPC_GHARZUL, 8749.505f, -7132.595f, 35.31983f, 3.816502f, TempSummonType.CorpseTimedDespawn, 180000); - me.SummonCreature(NPC_ANGERSHADE, 8755.38f, -7131.521f, 35.30957f, 3.816502f, TempSummonType.CorpseTimedDespawn, 180000); - me.SummonCreature(NPC_ANGERSHADE, 8753.199f, -7125.975f, 35.31986f, 3.816502f, TempSummonType.CorpseTimedDespawn, 180000); - break; - case EventFireball: - if (UpdateVictim()) - { - DoCastVictim(SpellFireball, true); // Not casting in combat - _events.ScheduleEvent(EventFireball, 3000); - } - break; - default: - break; - } - }); - DoMeleeAttackIfReady(); - } - - uint KillCount; - ObjectGuid PlayerGUID; - SummonList Summons; + Summons = new SummonList(me); } + public override void Reset() + { + SetCombatMovement(false); + KillCount = 0; + PlayerGUID.Clear(); + Summons.DespawnAll(); + } + + public override void sQuestReward(Player player, Quest quest, uint opt) + { + if (quest.Id == QUEST_CORRUPTED_SOIL) + { + me.RemoveFlag64(UnitFields.NpcFlags, NPCFlags.QuestGiver); + _events.ScheduleEvent(EventTalk, 2000); + } + } + + public override void sQuestAccept(Player player, Quest quest) + { + if (quest.Id == QUEST_UNEXPECTED_RESULT) + { + me.SetFaction(FactionCombat); + me.RemoveFlag64(UnitFields.NpcFlags, NPCFlags.QuestGiver); + _events.ScheduleEvent(EventSummon, 1000); + PlayerGUID = player.GetGUID(); + } + } + + public override void EnterCombat(Unit who) + { + _events.ScheduleEvent(EventFireball, 1000); + } + + public override void JustSummoned(Creature summoned) + { + // This is the best I can do because AttackStart does nothing + summoned.GetMotionMaster().MovePoint(1, me.GetPositionX(), me.GetPositionY(), me.GetPositionZ()); + // summoned.AI().AttackStart(me); + Summons.Summon(summoned); + } + + public override void SummonedCreatureDies(Creature summoned, Unit who) + { + Summons.Despawn(summoned); + ++KillCount; + } + + public override void JustDied(Unit killer) + { + me.SetFaction(FactionNormal); + + if (!PlayerGUID.IsEmpty()) + { + Player player = Global.ObjAccessor.GetPlayer(me, PlayerGUID); + if (player) + player.FailQuest(QUEST_UNEXPECTED_RESULT); + } + } + + public override void UpdateAI(uint diff) + { + if (KillCount >= 3 && !PlayerGUID.IsEmpty()) + { + Player player = Global.ObjAccessor.GetPlayer(me, PlayerGUID); + if (player) + { + if (player.GetQuestStatus(QUEST_UNEXPECTED_RESULT) == QuestStatus.Incomplete) + { + player.CompleteQuest(QUEST_UNEXPECTED_RESULT); + me.SetFaction(FactionNormal); + me.SetFlag64(UnitFields.NpcFlags, NPCFlags.QuestGiver); + } + } + } + + _events.Update(diff); + _events.ExecuteEvents(eventId => + { + switch (eventId) + { + case EventTalk: + Talk(SayTestSoil); + _events.ScheduleEvent(EventAddQuestGiverFlag, 7000); + break; + case EventAddQuestGiverFlag: + me.SetFlag64(UnitFields.NpcFlags, NPCFlags.QuestGiver); + break; + case EventSummon: + me.SummonCreature(NPC_GHARZUL, 8749.505f, -7132.595f, 35.31983f, 3.816502f, TempSummonType.CorpseTimedDespawn, 180000); + me.SummonCreature(NPC_ANGERSHADE, 8755.38f, -7131.521f, 35.30957f, 3.816502f, TempSummonType.CorpseTimedDespawn, 180000); + me.SummonCreature(NPC_ANGERSHADE, 8753.199f, -7125.975f, 35.31986f, 3.816502f, TempSummonType.CorpseTimedDespawn, 180000); + break; + case EventFireball: + if (UpdateVictim()) + { + DoCastVictim(SpellFireball, true); // Not casting in combat + _events.ScheduleEvent(EventFireball, 3000); + } + break; + default: + break; + } + }); + DoMeleeAttackIfReady(); + } + + uint KillCount; + ObjectGuid PlayerGUID; + SummonList Summons; + const uint EventTalk = 1; // Quest 8487 const uint EventAddQuestGiverFlag = 2; // Quest 8487 const uint EventSummon = 3; // Quest 8488 @@ -171,106 +166,90 @@ namespace Scripts.EasternKingdoms // Quest const uint QUEST_CORRUPTED_SOIL = 8487; const uint QUEST_UNEXPECTED_RESULT = 8488; - - public override CreatureAI GetAI(Creature creature) - { - return new npc_apprentice_mirvedaAI(creature); - } } [Script] - class npc_infused_crystal : CreatureScript + class npc_infused_crystal : ScriptedAI { - public npc_infused_crystal() : base("npc_infused_crystal") { } - - class npc_infused_crystalAI : ScriptedAI + public npc_infused_crystal(Creature creature) : base(creature) { - public npc_infused_crystalAI(Creature creature) - : base(creature) - { - SetCombatMovement(false); - } + SetCombatMovement(false); + } - public override void Reset() - { - EndTimer = 0; - Completed = false; - Progress = false; - PlayerGUID.Clear(); - WaveTimer = 0; - } + public override void Reset() + { + EndTimer = 0; + Completed = false; + Progress = false; + PlayerGUID.Clear(); + WaveTimer = 0; + } - public override void MoveInLineOfSight(Unit who) + public override void MoveInLineOfSight(Unit who) + { + if (!Progress && who.IsTypeId(TypeId.Player) && me.IsWithinDistInMap(who, 10.0f)) { - if (!Progress && who.IsTypeId(TypeId.Player) && me.IsWithinDistInMap(who, 10.0f)) + if (who.ToPlayer().GetQuestStatus(QuestPoweringOurDefenses) == QuestStatus.Incomplete) { - if (who.ToPlayer().GetQuestStatus(QuestPoweringOurDefenses) == QuestStatus.Incomplete) - { - PlayerGUID = who.GetGUID(); - WaveTimer = 1000; - EndTimer = 60000; - Progress = true; - } + PlayerGUID = who.GetGUID(); + WaveTimer = 1000; + EndTimer = 60000; + Progress = true; } } + } - public override void JustSummoned(Creature summoned) + public override void JustSummoned(Creature summoned) + { + summoned.GetAI().AttackStart(me); + } + + public override void JustDied(Unit killer) + { + if (!PlayerGUID.IsEmpty() && !Completed) { - summoned.GetAI().AttackStart(me); + Player player = Global.ObjAccessor.GetPlayer(me, PlayerGUID); + if (player) + player.FailQuest(QuestPoweringOurDefenses); } + } - public override void JustDied(Unit killer) + public override void UpdateAI(uint diff) + { + if (EndTimer < diff && Progress) { - if (!PlayerGUID.IsEmpty() && !Completed) + Talk(Emote); + Completed = true; + if (!PlayerGUID.IsEmpty()) { Player player = Global.ObjAccessor.GetPlayer(me, PlayerGUID); if (player) - player.FailQuest(QuestPoweringOurDefenses); + player.CompleteQuest(QuestPoweringOurDefenses); } - } - public override void UpdateAI(uint diff) + me.DealDamage(me, (uint)me.GetHealth(), null, DamageEffectType.Direct, SpellSchoolMask.Normal, null, false); + me.RemoveCorpse(); + } + else EndTimer -= diff; + + if (WaveTimer < diff && !Completed && Progress) { - if (EndTimer < diff && Progress) - { - Talk(Emote); - Completed = true; - if (!PlayerGUID.IsEmpty()) - { - Player player = Global.ObjAccessor.GetPlayer(me, PlayerGUID); - if (player) - player.CompleteQuest(QuestPoweringOurDefenses); - } - - me.DealDamage(me, (uint)me.GetHealth(), null, DamageEffectType.Direct, SpellSchoolMask.Normal, null, false); - me.RemoveCorpse(); - } - else EndTimer -= diff; - - if (WaveTimer < diff && !Completed && Progress) - { - uint ran1 = RandomHelper.Rand32() % 8; - uint ran2 = RandomHelper.Rand32() % 8; - uint ran3 = RandomHelper.Rand32() % 8; - me.SummonCreature(NpcEnragedWeaith, SpawnLocations[ran1].X, SpawnLocations[ran1].Y, SpawnLocations[ran1].Z, 0, TempSummonType.TimedOrCorpseDespawn, 10000); - me.SummonCreature(NpcEnragedWeaith, SpawnLocations[ran2].X, SpawnLocations[ran2].Y, SpawnLocations[ran2].Z, 0, TempSummonType.TimedOrCorpseDespawn, 10000); - me.SummonCreature(NpcEnragedWeaith, SpawnLocations[ran3].X, SpawnLocations[ran3].Y, SpawnLocations[ran3].Z, 0, TempSummonType.TimedOrCorpseDespawn, 10000); - WaveTimer = 30000; - } - else WaveTimer -= diff; + uint ran1 = RandomHelper.Rand32() % 8; + uint ran2 = RandomHelper.Rand32() % 8; + uint ran3 = RandomHelper.Rand32() % 8; + me.SummonCreature(NpcEnragedWeaith, SpawnLocations[ran1].X, SpawnLocations[ran1].Y, SpawnLocations[ran1].Z, 0, TempSummonType.TimedOrCorpseDespawn, 10000); + me.SummonCreature(NpcEnragedWeaith, SpawnLocations[ran2].X, SpawnLocations[ran2].Y, SpawnLocations[ran2].Z, 0, TempSummonType.TimedOrCorpseDespawn, 10000); + me.SummonCreature(NpcEnragedWeaith, SpawnLocations[ran3].X, SpawnLocations[ran3].Y, SpawnLocations[ran3].Z, 0, TempSummonType.TimedOrCorpseDespawn, 10000); + WaveTimer = 30000; } - - uint EndTimer; - uint WaveTimer; - bool Completed; - bool Progress; - ObjectGuid PlayerGUID; + else WaveTimer -= diff; } - public override CreatureAI GetAI(Creature creature) - { - return new npc_infused_crystalAI(creature); - } + uint EndTimer; + uint WaveTimer; + bool Completed; + bool Progress; + ObjectGuid PlayerGUID; // Quest const uint QuestPoweringOurDefenses = 8490; diff --git a/Scripts/EasternKingdoms/Karazhan/AttumenMidnight.cs b/Scripts/EasternKingdoms/Karazhan/AttumenMidnight.cs index 6fe5892e9..e6a2b9ad2 100644 --- a/Scripts/EasternKingdoms/Karazhan/AttumenMidnight.cs +++ b/Scripts/EasternKingdoms/Karazhan/AttumenMidnight.cs @@ -53,273 +53,253 @@ namespace Scripts.EasternKingdoms.Karazhan.Midnight } [Script] - class boss_attumen : CreatureScript + public class boss_attumen : ScriptedAI { - public boss_attumen() : base("boss_attumen") { } - - public class boss_attumenAI : ScriptedAI + public boss_attumen(Creature creature) : base(creature) { - public boss_attumenAI(Creature creature) : base(creature) + CleaveTimer = RandomHelper.URand(10000, 15000); + CurseTimer = 30000; + RandomYellTimer = RandomHelper.URand(30000, 60000); //Occasionally yell + ChargeTimer = 20000; + ResetTimer = 0; + } + + public override void Reset() + { + ResetTimer = 0; + Midnight.Clear(); + } + + public override void EnterEvadeMode(EvadeReason why) + { + base.EnterEvadeMode(why); + ResetTimer = 2000; + } + + public override void EnterCombat(Unit who) { } + + public override void KilledUnit(Unit victim) + { + Talk(TextIds.SayKill); + } + + public override void JustDied(Unit killer) + { + Talk(TextIds.SayDeath); + Unit midnight = Global.ObjAccessor.GetUnit(me, Midnight); + if (midnight) + midnight.KillSelf(); + } + + public override void UpdateAI(uint diff) + { + if (ResetTimer != 0) { + if (ResetTimer <= diff) + { + ResetTimer = 0; + Unit pMidnight = Global.ObjAccessor.GetUnit(me, Midnight); + if (pMidnight) + { + pMidnight.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); + pMidnight.SetVisible(true); + } + Midnight.Clear(); + me.SetVisible(false); + me.KillSelf(); + } + else ResetTimer -= diff; + } + + //Return since we have no target + if (!UpdateVictim()) + return; + + if (me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable)) + return; + + if (CleaveTimer <= diff) + { + DoCastVictim(SpellIds.Shadowcleave); CleaveTimer = RandomHelper.URand(10000, 15000); + } + else CleaveTimer -= diff; + + if (CurseTimer <= diff) + { + DoCastVictim(SpellIds.IntangiblePresence); CurseTimer = 30000; - RandomYellTimer = RandomHelper.URand(30000, 60000); //Occasionally yell - ChargeTimer = 20000; - ResetTimer = 0; } + else CurseTimer -= diff; - public override void Reset() + if (RandomYellTimer <= diff) { - ResetTimer = 0; - Midnight.Clear(); + Talk(TextIds.SayRandom); + RandomYellTimer = RandomHelper.URand(30000, 60000); } + else RandomYellTimer -= diff; - public override void EnterEvadeMode(EvadeReason why) + if (me.GetUInt32Value(UnitFields.DisplayId) == Misc.MountedDisplayid) { - base.EnterEvadeMode(why); - ResetTimer = 2000; - } - - public override void EnterCombat(Unit who) { } - - public override void KilledUnit(Unit victim) - { - Talk(TextIds.SayKill); - } - - public override void JustDied(Unit killer) - { - Talk(TextIds.SayDeath); - Unit midnight = Global.ObjAccessor.GetUnit(me, Midnight); - if (midnight) - midnight.KillSelf(); - } - - public override void UpdateAI(uint diff) - { - if (ResetTimer != 0) + if (ChargeTimer <= diff) { - if (ResetTimer <= diff) + var t_list = me.GetThreatManager().getThreatList(); + List target_list = new List(); + foreach (var hostileRefe in t_list) { - ResetTimer = 0; - Unit pMidnight = Global.ObjAccessor.GetUnit(me, Midnight); - if (pMidnight) - { - pMidnight.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); - pMidnight.SetVisible(true); - } - Midnight.Clear(); - me.SetVisible(false); - me.KillSelf(); + var unit = Global.ObjAccessor.GetUnit(me, hostileRefe.getUnitGuid()); + if (unit && !unit.IsWithinDist(me, SharedConst.AttackDistance, false)) + target_list.Add(unit); + unit = null; } - else ResetTimer -= diff; + Unit target = null; + if (!target_list.Empty()) + target = target_list.SelectRandom(); + + DoCast(target, SpellIds.BerserkerCharge); + ChargeTimer = 20000; } - - //Return since we have no target - if (!UpdateVictim()) - return; - - if (me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable)) - return; - - if (CleaveTimer <= diff) + else ChargeTimer -= diff; + } + else + { + if (HealthBelowPct(25)) { - DoCastVictim(SpellIds.Shadowcleave); - CleaveTimer = RandomHelper.URand(10000, 15000); - } - else CleaveTimer -= diff; - - if (CurseTimer <= diff) - { - DoCastVictim(SpellIds.IntangiblePresence); - CurseTimer = 30000; - } - else CurseTimer -= diff; - - if (RandomYellTimer <= diff) - { - Talk(TextIds.SayRandom); - RandomYellTimer = RandomHelper.URand(30000, 60000); - } - else RandomYellTimer -= diff; - - if (me.GetUInt32Value(UnitFields.DisplayId) == Misc.MountedDisplayid) - { - if (ChargeTimer <= diff) + Creature pMidnight = ObjectAccessor.GetCreature(me, Midnight); + if (pMidnight && pMidnight.IsTypeId(TypeId.Unit)) { - var t_list = me.GetThreatManager().getThreatList(); - List target_list = new List(); - foreach (var hostileRefe in t_list) - { - var unit = Global.ObjAccessor.GetUnit(me, hostileRefe.getUnitGuid()); - if (unit && !unit.IsWithinDist(me, SharedConst.AttackDistance, false)) - target_list.Add(unit); - unit = null; - } - Unit target = null; - if (!target_list.Empty()) - target = target_list.SelectRandom(); - - DoCast(target, SpellIds.BerserkerCharge); - ChargeTimer = 20000; - } - else ChargeTimer -= diff; - } - else - { - if (HealthBelowPct(25)) - { - Creature pMidnight = ObjectAccessor.GetCreature(me, Midnight); - if (pMidnight && pMidnight.IsTypeId(TypeId.Unit)) - { - ((boss_midnight.boss_midnightAI)pMidnight.GetAI()).Mount(me); - me.SetHealth(pMidnight.GetHealth()); - DoResetThreat(); - } + ((boss_midnight)pMidnight.GetAI()).Mount(me); + me.SetHealth(pMidnight.GetHealth()); + DoResetThreat(); } } - - DoMeleeAttackIfReady(); } - public override void SpellHit(Unit source, SpellInfo spell) - { - if (spell.Mechanic == Mechanics.Disarm) - Talk(TextIds.SayDisarmed); - } - - public ObjectGuid Midnight; - uint CleaveTimer; - uint CurseTimer; - uint RandomYellTimer; - uint ChargeTimer; //only when mounted - uint ResetTimer; + DoMeleeAttackIfReady(); } - public override CreatureAI GetAI(Creature creature) + public override void SpellHit(Unit source, SpellInfo spell) { - return new boss_attumenAI(creature); + if (spell.Mechanic == Mechanics.Disarm) + Talk(TextIds.SayDisarmed); } + + public ObjectGuid Midnight; + uint CleaveTimer; + uint CurseTimer; + uint RandomYellTimer; + uint ChargeTimer; //only when mounted + uint ResetTimer; } [Script] - class boss_midnight : CreatureScript + public class boss_midnight : ScriptedAI { - public boss_midnight() : base("boss_midnight") { } + public boss_midnight(Creature creature) : base(creature) { } - public class boss_midnightAI : ScriptedAI + public override void Reset() { - public boss_midnightAI(Creature creature) : base(creature) { } + Phase = 1; + Attumen.Clear(); + mountTimer = 0; - public override void Reset() + me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); + me.SetVisible(true); + } + + public override void EnterCombat(Unit who) { } + + public override void KilledUnit(Unit victim) + { + if (Phase == 2) { - Phase = 1; - Attumen.Clear(); - mountTimer = 0; - - me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); - me.SetVisible(true); + Unit unit = Global.ObjAccessor.GetUnit(me, Attumen); + if (unit) + Talk(TextIds.SayMidnightKill, unit); } + } - public override void EnterCombat(Unit who) { } + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; - public override void KilledUnit(Unit victim) + if (Phase == 1 && HealthBelowPct(95)) { - if (Phase == 2) + Phase = 2; + Creature attumen = me.SummonCreature(Misc.SummonAttumen, 0.0f, 0.0f, 0.0f, 0.0f, TempSummonType.TimedOrDeadDespawn, 30000); + if (attumen) { - Unit unit = Global.ObjAccessor.GetUnit(me, Attumen); - if (unit) - Talk(TextIds.SayMidnightKill, unit); + Attumen = attumen.GetGUID(); + attumen.GetAI().AttackStart(me.GetVictim()); + SetMidnight(attumen, me.GetGUID()); + Talk(TextIds.SayAppear, attumen); } } - - public override void UpdateAI(uint diff) + else if (Phase == 2 && HealthBelowPct(25)) { - if (!UpdateVictim()) - return; - - if (Phase == 1 && HealthBelowPct(95)) + Unit pAttumen = Global.ObjAccessor.GetUnit(me, Attumen); + if (pAttumen) + Mount(pAttumen); + } + else if (Phase == 3) + { + if (mountTimer != 0) { - Phase = 2; - Creature attumen = me.SummonCreature(Misc.SummonAttumen, 0.0f, 0.0f, 0.0f, 0.0f, TempSummonType.TimedOrDeadDespawn, 30000); - if (attumen) + if (mountTimer <= diff) { - Attumen = attumen.GetGUID(); - attumen.GetAI().AttackStart(me.GetVictim()); - SetMidnight(attumen, me.GetGUID()); - Talk(TextIds.SayAppear, attumen); - } - } - else if (Phase == 2 && HealthBelowPct(25)) - { - Unit pAttumen = Global.ObjAccessor.GetUnit(me, Attumen); - if (pAttumen) - Mount(pAttumen); - } - else if (Phase == 3) - { - if (mountTimer != 0) - { - if (mountTimer <= diff) + mountTimer = 0; + me.SetVisible(false); + me.GetMotionMaster().MoveIdle(); + Unit pAttumen = Global.ObjAccessor.GetUnit(me, Attumen); + if (pAttumen) { - mountTimer = 0; - me.SetVisible(false); - me.GetMotionMaster().MoveIdle(); - Unit pAttumen = Global.ObjAccessor.GetUnit(me, Attumen); - if (pAttumen) + pAttumen.SetDisplayId(Misc.MountedDisplayid); + pAttumen.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); + if (pAttumen.GetVictim()) { - pAttumen.SetDisplayId(Misc.MountedDisplayid); - pAttumen.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); - if (pAttumen.GetVictim()) - { - pAttumen.GetMotionMaster().MoveChase(pAttumen.GetVictim()); - pAttumen.SetTarget(pAttumen.GetVictim().GetGUID()); - } - pAttumen.SetObjectScale(1); + pAttumen.GetMotionMaster().MoveChase(pAttumen.GetVictim()); + pAttumen.SetTarget(pAttumen.GetVictim().GetGUID()); } + pAttumen.SetObjectScale(1); } - else mountTimer -= diff; } + else mountTimer -= diff; } - - if (Phase != 3) - DoMeleeAttackIfReady(); } - public void Mount(Unit pAttumen) - { - Talk(TextIds.SayMount, pAttumen); - Phase = 3; - me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable); - pAttumen.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable); - float angle = me.GetAngle(pAttumen); - float distance = me.GetDistance2d(pAttumen); - float newX = me.GetPositionX() + (float)Math.Cos(angle) * (distance / 2); - float newY = me.GetPositionY() + (float)Math.Sin(angle) * (distance / 2); - float newZ = 50; - me.GetMotionMaster().Clear(); - me.GetMotionMaster().MovePoint(0, newX, newY, newZ); - distance += 10; - newX = me.GetPositionX() + (float)Math.Cos(angle) * (distance / 2); - newY = me.GetPositionY() + (float)Math.Sin(angle) * (distance / 2); - pAttumen.GetMotionMaster().Clear(); - pAttumen.GetMotionMaster().MovePoint(0, newX, newY, newZ); - mountTimer = 1000; - } - - void SetMidnight(Creature pAttumen, ObjectGuid value) - { - ((boss_attumen.boss_attumenAI)pAttumen.GetAI()).Midnight = value; - } - - ObjectGuid Attumen; - byte Phase; - uint mountTimer; + if (Phase != 3) + DoMeleeAttackIfReady(); } - public override CreatureAI GetAI(Creature creature) + public void Mount(Unit pAttumen) { - return new boss_midnightAI(creature); + Talk(TextIds.SayMount, pAttumen); + Phase = 3; + me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable); + pAttumen.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable); + float angle = me.GetAngle(pAttumen); + float distance = me.GetDistance2d(pAttumen); + float newX = me.GetPositionX() + (float)Math.Cos(angle) * (distance / 2); + float newY = me.GetPositionY() + (float)Math.Sin(angle) * (distance / 2); + float newZ = 50; + me.GetMotionMaster().Clear(); + me.GetMotionMaster().MovePoint(0, newX, newY, newZ); + distance += 10; + newX = me.GetPositionX() + (float)Math.Cos(angle) * (distance / 2); + newY = me.GetPositionY() + (float)Math.Sin(angle) * (distance / 2); + pAttumen.GetMotionMaster().Clear(); + pAttumen.GetMotionMaster().MovePoint(0, newX, newY, newZ); + mountTimer = 1000; } + + void SetMidnight(Creature pAttumen, ObjectGuid value) + { + ((boss_attumen)pAttumen.GetAI()).Midnight = value; + } + + ObjectGuid Attumen; + byte Phase; + uint mountTimer; } } diff --git a/Scripts/EasternKingdoms/Karazhan/Curator.cs b/Scripts/EasternKingdoms/Karazhan/Curator.cs index d9ecf9272..01100045d 100644 --- a/Scripts/EasternKingdoms/Karazhan/Curator.cs +++ b/Scripts/EasternKingdoms/Karazhan/Curator.cs @@ -34,7 +34,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Curator } struct SpellIds - { + { //Flare spell info public const uint AstralFlarePassive = 30234; //Visual effect + Flare damage @@ -46,123 +46,113 @@ namespace Scripts.EasternKingdoms.Karazhan.Curator } [Script] - class boss_curator : CreatureScript + class boss_curator : ScriptedAI { - public boss_curator() : base("boss_curator") { } - - class boss_curatorAI : ScriptedAI + public boss_curator(Creature creature) : base(creature) { - public boss_curatorAI(Creature creature) : base(creature) - { - Initialize(); - } + Initialize(); + } - void Initialize() + void Initialize() + { + _scheduler.Schedule(TimeSpan.FromSeconds(10), task => { - _scheduler.Schedule(TimeSpan.FromSeconds(10), task => - { //Summon Astral Flare Creature AstralFlare = DoSpawnCreature(17096, RandomHelper.Rand32() % 37, RandomHelper.Rand32() % 37, 0, 0, TempSummonType.TimedDespawnOOC, 5000); - Unit target = SelectTarget(SelectAggroTarget.Random, 0); + Unit target = SelectTarget(SelectAggroTarget.Random, 0); - if (AstralFlare && target) - { - AstralFlare.CastSpell(AstralFlare, SpellIds.AstralFlarePassive, false); - AstralFlare.GetAI().AttackStart(target); - } + if (AstralFlare && target) + { + AstralFlare.CastSpell(AstralFlare, SpellIds.AstralFlarePassive, false); + AstralFlare.GetAI().AttackStart(target); + } //Reduce Mana by 10% of max health int mana = me.GetMaxPower(PowerType.Mana); - if (mana != 0) - { - mana /= 10; - me.ModifyPower(PowerType.Mana, -mana); + if (mana != 0) + { + mana /= 10; + me.ModifyPower(PowerType.Mana, -mana); //if this get's us below 10%, then we evocate (the 10th should be summoned now) if (me.GetPower(PowerType.Mana) * 100 / me.GetMaxPower(PowerType.Mana) < 10) - { - Talk(TextIds.SayEvocate); - me.InterruptNonMeleeSpells(false); - DoCast(me, SpellIds.Evocation); - _scheduler.DelayAll(TimeSpan.FromSeconds(20)); + { + Talk(TextIds.SayEvocate); + me.InterruptNonMeleeSpells(false); + DoCast(me, SpellIds.Evocation); + _scheduler.DelayAll(TimeSpan.FromSeconds(20)); //Evocating = true; //no AddTimer cooldown, this will make first flare appear instantly after evocate end, like expected return; - } - else - { - if (RandomHelper.URand(0, 1) == 0) - { - Talk(TextIds.SaySummon); - } - } } - - task.Repeat(); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(15), task => - { - if (Enraged) - task.Repeat(TimeSpan.FromSeconds(7)); else - task.Repeat(); - - Unit target = SelectTarget(SelectAggroTarget.TopAggro, 1); - if (target) - DoCast(target, SpellIds.HatefulBolt); - }); - - Enraged = false; - } - - public override void Reset() - { - Initialize(); - - me.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchoolMask.Arcane, true); - } - - public override void KilledUnit(Unit victim) - { - Talk(TextIds.SayKill); - } - - public override void JustDied(Unit killer) - { - Talk(TextIds.SayDeath); - } - - public override void EnterCombat(Unit victim) - { - Talk(TextIds.SayAggro); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _scheduler.Update(diff); - - if (!Enraged) - { - if (!HealthAbovePct(15)) { - Enraged = true; - DoCast(me, SpellIds.Enrage); - Talk(TextIds.SayEnrage); + if (RandomHelper.URand(0, 1) == 0) + { + Talk(TextIds.SaySummon); + } } } + task.Repeat(); + }); + + _scheduler.Schedule(TimeSpan.FromSeconds(15), task => + { + if (Enraged) + task.Repeat(TimeSpan.FromSeconds(7)); + else + task.Repeat(); + + Unit target = SelectTarget(SelectAggroTarget.TopAggro, 1); + if (target) + DoCast(target, SpellIds.HatefulBolt); + }); + + Enraged = false; + } + + public override void Reset() + { + Initialize(); + + me.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchoolMask.Arcane, true); + } + + public override void KilledUnit(Unit victim) + { + Talk(TextIds.SayKill); + } + + public override void JustDied(Unit killer) + { + Talk(TextIds.SayDeath); + } + + public override void EnterCombat(Unit victim) + { + Talk(TextIds.SayAggro); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _scheduler.Update(diff); + + if (!Enraged) + { + if (!HealthAbovePct(15)) + { + Enraged = true; + DoCast(me, SpellIds.Enrage); + Talk(TextIds.SayEnrage); + } } - bool Enraged; } - public override CreatureAI GetAI(Creature creature) - { - return new boss_curatorAI(creature); - } + bool Enraged; } } diff --git a/Scripts/EasternKingdoms/Karazhan/InstanceKarazhan.cs b/Scripts/EasternKingdoms/Karazhan/InstanceKarazhan.cs index 68b5d1b5d..6bc957ce5 100644 --- a/Scripts/EasternKingdoms/Karazhan/InstanceKarazhan.cs +++ b/Scripts/EasternKingdoms/Karazhan/InstanceKarazhan.cs @@ -20,6 +20,7 @@ using Framework.IO; using Game.Entities; using Game.Maps; using Game.Scripting; +using Game.AI; namespace Scripts.EasternKingdoms.Karazhan { @@ -458,5 +459,10 @@ namespace Scripts.EasternKingdoms.Karazhan { return new instance_karazhan_InstanceMapScript(map); } + + public static T GetKarazhanAI(Creature creature) where T : CreatureAI + { + return GetInstanceAI(creature, "instance_karazhan"); + } } } diff --git a/Scripts/EasternKingdoms/Karazhan/Moroes.cs b/Scripts/EasternKingdoms/Karazhan/Moroes.cs index 99052f811..d5fdfd518 100644 --- a/Scripts/EasternKingdoms/Karazhan/Moroes.cs +++ b/Scripts/EasternKingdoms/Karazhan/Moroes.cs @@ -92,130 +92,156 @@ namespace Scripts.EasternKingdoms.Karazhan.Moroes } [Script] - class boss_moroes : CreatureScript + public class boss_moroes : ScriptedAI { - public boss_moroes() : base("boss_moroes") { } - - public override CreatureAI GetAI(Creature creature) + public boss_moroes(Creature creature) : base(creature) { - return GetInstanceAI(creature); + instance = creature.GetInstanceScript(); } - public class boss_moroesAI : ScriptedAI + public override void Reset() { - public boss_moroesAI(Creature creature) : base(creature) + Vanish_Timer = 30000; + Blind_Timer = 35000; + Gouge_Timer = 23000; + Wait_Timer = 0; + CheckAdds_Timer = 5000; + + Enrage = false; + InVanish = false; + if (me.IsAlive()) + SpawnAdds(); + + instance.SetData(karazhanConst.BossMoroes, (uint)EncounterState.NotStarted); + } + + void StartEvent() + { + instance.SetData(karazhanConst.BossMoroes, (uint)EncounterState.InProgress); + + DoZoneInCombat(); + } + + public override void EnterCombat(Unit who) + { + StartEvent(); + + Talk(TextIds.Aggro); + AddsAttack(); + DoZoneInCombat(); + } + + public override void KilledUnit(Unit victim) + { + Talk(TextIds.Kill); + } + + public override void JustDied(Unit killer) + { + Talk(TextIds.Death); + + instance.SetData(karazhanConst.BossMoroes, (uint)EncounterState.Done); + + DeSpawnAdds(); + + //remove aura from spell Garrote when Moroes dies + instance.DoRemoveAurasDueToSpellOnPlayers(SpellIds.Garrote); + } + + void SpawnAdds() + { + DeSpawnAdds(); + + if (isAddlistEmpty()) { - instance = creature.GetInstanceScript(); - } + List AddList = new List(); - public override void Reset() - { - Vanish_Timer = 30000; - Blind_Timer = 35000; - Gouge_Timer = 23000; - Wait_Timer = 0; - CheckAdds_Timer = 5000; + for (byte i = 0; i < 6; ++i) + AddList.Add(Misc.Adds[i]); - Enrage = false; - InVanish = false; - if (me.IsAlive()) - SpawnAdds(); + AddList.RandomResize(4); - instance.SetData(karazhanConst.BossMoroes, (uint)EncounterState.NotStarted); - } - - void StartEvent() - { - instance.SetData(karazhanConst.BossMoroes, (uint)EncounterState.InProgress); - - DoZoneInCombat(); - } - - public override void EnterCombat(Unit who) - { - StartEvent(); - - Talk(TextIds.Aggro); - AddsAttack(); - DoZoneInCombat(); - } - - public override void KilledUnit(Unit victim) - { - Talk(TextIds.Kill); - } - - public override void JustDied(Unit killer) - { - Talk(TextIds.Death); - - instance.SetData(karazhanConst.BossMoroes, (uint)EncounterState.Done); - - DeSpawnAdds(); - - //remove aura from spell Garrote when Moroes dies - instance.DoRemoveAurasDueToSpellOnPlayers(SpellIds.Garrote); - } - - void SpawnAdds() - { - DeSpawnAdds(); - - if (isAddlistEmpty()) + byte c = 0; + for (var i = 0; i != AddList.Count && c < 4; ++i, ++c) { - List AddList = new List(); - - for (byte i = 0; i < 6; ++i) - AddList.Add(Misc.Adds[i]); - - AddList.RandomResize(4); - - byte c = 0; - for (var i = 0; i != AddList.Count && c < 4; ++i, ++c) + uint entry = AddList[i]; + Creature creature = me.SummonCreature(entry, Misc.Locations[c], TempSummonType.CorpseTimedDespawn, 10000); + if (creature) { - uint entry = AddList[i]; - Creature creature = me.SummonCreature(entry, Misc.Locations[c], TempSummonType.CorpseTimedDespawn, 10000); - if (creature) - { - AddGUID[c] = creature.GetGUID(); - AddId[c] = entry; - } - } - } - else - { - for (byte i = 0; i < 4; ++i) - { - Creature creature = me.SummonCreature(AddId[i], Misc.Locations[i], TempSummonType.CorpseTimedDespawn, 10000); - if (creature) - AddGUID[i] = creature.GetGUID(); + AddGUID[c] = creature.GetGUID(); + AddId[c] = entry; } } } - - bool isAddlistEmpty() - { - for (byte i = 0; i < 4; ++i) - if (AddId[i] == 0) - return true; - - return false; - } - - void DeSpawnAdds() + else { for (byte i = 0; i < 4; ++i) { - if (!AddGUID[i].IsEmpty()) - { - Creature temp = ObjectAccessor.GetCreature(me, AddGUID[i]); - if (temp) - temp.DespawnOrUnsummon(); - } + Creature creature = me.SummonCreature(AddId[i], Misc.Locations[i], TempSummonType.CorpseTimedDespawn, 10000); + if (creature) + AddGUID[i] = creature.GetGUID(); } } + } - void AddsAttack() + bool isAddlistEmpty() + { + for (byte i = 0; i < 4; ++i) + if (AddId[i] == 0) + return true; + + return false; + } + + void DeSpawnAdds() + { + for (byte i = 0; i < 4; ++i) + { + if (!AddGUID[i].IsEmpty()) + { + Creature temp = ObjectAccessor.GetCreature(me, AddGUID[i]); + if (temp) + temp.DespawnOrUnsummon(); + } + } + } + + void AddsAttack() + { + for (byte i = 0; i < 4; ++i) + { + if (!AddGUID[i].IsEmpty()) + { + Creature temp = ObjectAccessor.GetCreature((me), AddGUID[i]); + if (temp && temp.IsAlive()) + { + temp.GetAI().AttackStart(me.GetVictim()); + DoZoneInCombat(temp); + } + else + EnterEvadeMode(); + } + } + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + if (instance.GetData(karazhanConst.BossMoroes) == 0) + { + EnterEvadeMode(); + return; + } + + if (!Enrage && HealthBelowPct(30)) + { + DoCast(me, SpellIds.Frenzy); + Enrage = true; + } + + if (CheckAdds_Timer <= diff) { for (byte i = 0; i < 4; ++i) { @@ -223,117 +249,84 @@ namespace Scripts.EasternKingdoms.Karazhan.Moroes { Creature temp = ObjectAccessor.GetCreature((me), AddGUID[i]); if (temp && temp.IsAlive()) - { - temp.GetAI().AttackStart(me.GetVictim()); - DoZoneInCombat(temp); - } - else - EnterEvadeMode(); + if (!temp.GetVictim()) + temp.GetAI().AttackStart(me.GetVictim()); } } + CheckAdds_Timer = 5000; } + else CheckAdds_Timer -= diff; - public override void UpdateAI(uint diff) + if (!Enrage) { - if (!UpdateVictim()) - return; - - if (instance.GetData(karazhanConst.BossMoroes) == 0) + //Cast Vanish, then Garrote random victim + if (Vanish_Timer <= diff) { - EnterEvadeMode(); - return; + DoCast(me, SpellIds.Vanish); + InVanish = true; + Vanish_Timer = 30000; + Wait_Timer = 5000; } + else Vanish_Timer -= diff; - if (!Enrage && HealthBelowPct(30)) + if (Gouge_Timer <= diff) { - DoCast(me, SpellIds.Frenzy); - Enrage = true; + DoCastVictim(SpellIds.Gouge); + Gouge_Timer = 40000; } + else Gouge_Timer -= diff; - if (CheckAdds_Timer <= diff) + if (Blind_Timer <= diff) { - for (byte i = 0; i < 4; ++i) + List targets = SelectTargetList(5, SelectAggroTarget.Random, me.GetCombatReach() * 5, true); + foreach (var i in targets) { - if (!AddGUID[i].IsEmpty()) + + if (!me.IsWithinMeleeRange(i)) { - Creature temp = ObjectAccessor.GetCreature((me), AddGUID[i]); - if (temp && temp.IsAlive()) - if (!temp.GetVictim()) - temp.GetAI().AttackStart(me.GetVictim()); + DoCast(i, SpellIds.Blind); + break; } } - CheckAdds_Timer = 5000; - } else CheckAdds_Timer -= diff; - - if (!Enrage) - { - //Cast Vanish, then Garrote random victim - if (Vanish_Timer <= diff) - { - DoCast(me, SpellIds.Vanish); - InVanish = true; - Vanish_Timer = 30000; - Wait_Timer = 5000; - } else Vanish_Timer -= diff; - - if (Gouge_Timer <= diff) - { - DoCastVictim(SpellIds.Gouge); - Gouge_Timer = 40000; - } else Gouge_Timer -= diff; - - if (Blind_Timer <= diff) - { - List targets = SelectTargetList(5, SelectAggroTarget.Random, me.GetCombatReach() * 5, true); - foreach (var i in targets) - { - - if (!me.IsWithinMeleeRange(i)) - { - DoCast(i, SpellIds.Blind); - break; - } - } - Blind_Timer = 40000; - } - else - Blind_Timer -= diff; + Blind_Timer = 40000; } - - if (InVanish) - { - if (Wait_Timer <= diff) - { - Talk(TextIds.Special); - - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100, true); - if (target) - target.CastSpell(target, SpellIds.Garrote, true); - - InVanish = false; - } - else - Wait_Timer -= diff; - } - - if (!InVanish) - DoMeleeAttackIfReady(); + else + Blind_Timer -= diff; } - InstanceScript instance; + if (InVanish) + { + if (Wait_Timer <= diff) + { + Talk(TextIds.Special); - public ObjectGuid[] AddGUID = new ObjectGuid[4]; + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100, true); + if (target) + target.CastSpell(target, SpellIds.Garrote, true); - uint Vanish_Timer; - uint Blind_Timer; - uint Gouge_Timer; - uint Wait_Timer; - uint CheckAdds_Timer; - uint[] AddId = new uint[4]; + InVanish = false; + } + else + Wait_Timer -= diff; + } - bool InVanish; - bool Enrage; + if (!InVanish) + DoMeleeAttackIfReady(); } + + InstanceScript instance; + + public ObjectGuid[] AddGUID = new ObjectGuid[4]; + + uint Vanish_Timer; + uint Blind_Timer; + uint Gouge_Timer; + uint Wait_Timer; + uint CheckAdds_Timer; + uint[] AddId = new uint[4]; + + bool InVanish; + bool Enrage; } class boss_moroes_guestAI : ScriptedAI @@ -355,7 +348,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Moroes { for (byte i = 0; i < 4; ++i) { - ObjectGuid GUID = ((boss_moroes.boss_moroesAI)Moroes.GetAI()).AddGUID[i]; + ObjectGuid GUID = ((boss_moroes)Moroes.GetAI()).AddGUID[i]; if (!GUID.IsEmpty()) GuestGUID[i] = GUID; } @@ -390,389 +383,350 @@ namespace Scripts.EasternKingdoms.Karazhan.Moroes } [Script] - class boss_baroness_dorothea_millstipe : CreatureScript + class boss_baroness_dorothea_millstipe : boss_moroes_guestAI { - public boss_baroness_dorothea_millstipe() : base("boss_baroness_dorothea_millstipe") { } + //Shadow Priest + public boss_baroness_dorothea_millstipe(Creature creature) : base(creature) { } - public override CreatureAI GetAI(Creature creature) + uint ManaBurn_Timer; + uint MindFlay_Timer; + uint ShadowWordPain_Timer; + + public override void Reset() { - return GetInstanceAI(creature); + ManaBurn_Timer = 7000; + MindFlay_Timer = 1000; + ShadowWordPain_Timer = 6000; + + DoCast(me, SpellIds.Shadowform, true); + + base.Reset(); } - class boss_baroness_dorothea_millstipeAI : boss_moroes_guestAI + public override void UpdateAI(uint diff) { - //Shadow Priest - public boss_baroness_dorothea_millstipeAI(Creature creature) : base(creature) { } + if (!UpdateVictim()) + return; - uint ManaBurn_Timer; - uint MindFlay_Timer; - uint ShadowWordPain_Timer; + base.UpdateAI(diff); - public override void Reset() + if (MindFlay_Timer <= diff) { - ManaBurn_Timer = 7000; - MindFlay_Timer = 1000; - ShadowWordPain_Timer = 6000; - - DoCast(me, SpellIds.Shadowform, true); - - base.Reset(); + DoCastVictim(SpellIds.Mindfly); + MindFlay_Timer = 12000; // 3 sec channeled } + else MindFlay_Timer -= diff; - public override void UpdateAI(uint diff) + if (ManaBurn_Timer <= diff) { - if (!UpdateVictim()) - return; - - base.UpdateAI(diff); - - if (MindFlay_Timer <= diff) - { - DoCastVictim(SpellIds.Mindfly); - MindFlay_Timer = 12000; // 3 sec channeled - } else MindFlay_Timer -= diff; - - if (ManaBurn_Timer <= diff) - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100, true); - if (target) - if (target.getPowerType() == PowerType.Mana) - DoCast(target, SpellIds.Manaburn); - ManaBurn_Timer = 5000; // 3 sec cast - } else ManaBurn_Timer -= diff; - - if (ShadowWordPain_Timer <= diff) - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100, true); - if (target) - { - DoCast(target, SpellIds.Swpain); - ShadowWordPain_Timer = 7000; - } - } else ShadowWordPain_Timer -= diff; + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100, true); + if (target) + if (target.getPowerType() == PowerType.Mana) + DoCast(target, SpellIds.Manaburn); + ManaBurn_Timer = 5000; // 3 sec cast } + else ManaBurn_Timer -= diff; + + if (ShadowWordPain_Timer <= diff) + { + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100, true); + if (target) + { + DoCast(target, SpellIds.Swpain); + ShadowWordPain_Timer = 7000; + } + } + else ShadowWordPain_Timer -= diff; } } [Script] - class boss_baron_rafe_dreuger : CreatureScript + class boss_baron_rafe_dreuger : boss_moroes_guestAI { - public boss_baron_rafe_dreuger() : base("boss_baron_rafe_dreuger") { } + //Retr Pally + public boss_baron_rafe_dreuger(Creature creature) : base(creature) { } - public override CreatureAI GetAI(Creature creature) + uint HammerOfJustice_Timer; + uint SealOfCommand_Timer; + uint JudgementOfCommand_Timer; + + public override void Reset() { - return GetInstanceAI(creature); + HammerOfJustice_Timer = 1000; + SealOfCommand_Timer = 7000; + JudgementOfCommand_Timer = SealOfCommand_Timer + 29000; + + base.Reset(); } - class boss_baron_rafe_dreugerAI : boss_moroes_guestAI + public override void UpdateAI(uint diff) { - //Retr Pally - public boss_baron_rafe_dreugerAI(Creature creature) : base(creature) { } + if (!UpdateVictim()) + return; - uint HammerOfJustice_Timer; - uint SealOfCommand_Timer; - uint JudgementOfCommand_Timer; + base.UpdateAI(diff); - public override void Reset() + if (SealOfCommand_Timer <= diff) { - HammerOfJustice_Timer = 1000; - SealOfCommand_Timer = 7000; + DoCast(me, SpellIds.Sealofcommand); + SealOfCommand_Timer = 32000; + JudgementOfCommand_Timer = 29000; + } + else SealOfCommand_Timer -= diff; + + if (JudgementOfCommand_Timer <= diff) + { + DoCastVictim(SpellIds.Judgementofcommand); JudgementOfCommand_Timer = SealOfCommand_Timer + 29000; - - base.Reset(); } + else JudgementOfCommand_Timer -= diff; - public override void UpdateAI(uint diff) + if (HammerOfJustice_Timer <= diff) { - if (!UpdateVictim()) - return; - - base.UpdateAI(diff); - - if (SealOfCommand_Timer <= diff) - { - DoCast(me, SpellIds.Sealofcommand); - SealOfCommand_Timer = 32000; - JudgementOfCommand_Timer = 29000; - } else SealOfCommand_Timer -= diff; - - if (JudgementOfCommand_Timer <= diff) - { - DoCastVictim(SpellIds.Judgementofcommand); - JudgementOfCommand_Timer = SealOfCommand_Timer + 29000; - } else JudgementOfCommand_Timer -= diff; - - if (HammerOfJustice_Timer <= diff) - { - DoCastVictim(SpellIds.Hammerofjustice); - HammerOfJustice_Timer = 12000; - } else HammerOfJustice_Timer -= diff; + DoCastVictim(SpellIds.Hammerofjustice); + HammerOfJustice_Timer = 12000; } + else HammerOfJustice_Timer -= diff; } } [Script] - class boss_lady_catriona_von_indi : CreatureScript + class boss_lady_catriona_von_indi : boss_moroes_guestAI { - public boss_lady_catriona_von_indi() : base("boss_lady_catriona_von_indi") { } + //Holy Priest + public boss_lady_catriona_von_indi(Creature creature) : base(creature) { } - public override CreatureAI GetAI(Creature creature) + uint DispelMagic_Timer; + uint GreaterHeal_Timer; + uint HolyFire_Timer; + uint PowerWordShield_Timer; + + public override void Reset() { - return GetInstanceAI(creature); + DispelMagic_Timer = 11000; + GreaterHeal_Timer = 1500; + HolyFire_Timer = 5000; + PowerWordShield_Timer = 1000; + + AcquireGUID(); + + base.Reset(); } - class boss_lady_catriona_von_indiAI : boss_moroes_guestAI + public override void UpdateAI(uint diff) { - //Holy Priest - public boss_lady_catriona_von_indiAI(Creature creature) : base(creature) { } + if (!UpdateVictim()) + return; - uint DispelMagic_Timer; - uint GreaterHeal_Timer; - uint HolyFire_Timer; - uint PowerWordShield_Timer; + base.UpdateAI(diff); - public override void Reset() + if (PowerWordShield_Timer <= diff) { - DispelMagic_Timer = 11000; - GreaterHeal_Timer = 1500; - HolyFire_Timer = 5000; - PowerWordShield_Timer = 1000; - - AcquireGUID(); - - base.Reset(); + DoCast(me, SpellIds.Pwshield); + PowerWordShield_Timer = 15000; } + else PowerWordShield_Timer -= diff; - public override void UpdateAI(uint diff) + if (GreaterHeal_Timer <= diff) { - if (!UpdateVictim()) - return; + Unit target = SelectGuestTarget(); - base.UpdateAI(diff); - - if (PowerWordShield_Timer <= diff) - { - DoCast(me, SpellIds.Pwshield); - PowerWordShield_Timer = 15000; - } else PowerWordShield_Timer -= diff; - - if (GreaterHeal_Timer <= diff) - { - Unit target = SelectGuestTarget(); - - DoCast(target, SpellIds.Greaterheal); - GreaterHeal_Timer = 17000; - } else GreaterHeal_Timer -= diff; - - if (HolyFire_Timer <= diff) - { - DoCastVictim(SpellIds.Holyfire); - HolyFire_Timer = 22000; - } else HolyFire_Timer -= diff; - - if (DispelMagic_Timer <= diff) - { - Unit target = RandomHelper.RAND(SelectGuestTarget(), SelectTarget(SelectAggroTarget.Random, 0, 100, true)); - if (target) - DoCast(target, SpellIds.Dispelmagic); - - DispelMagic_Timer = 25000; - } else DispelMagic_Timer -= diff; + DoCast(target, SpellIds.Greaterheal); + GreaterHeal_Timer = 17000; } + else GreaterHeal_Timer -= diff; + + if (HolyFire_Timer <= diff) + { + DoCastVictim(SpellIds.Holyfire); + HolyFire_Timer = 22000; + } + else HolyFire_Timer -= diff; + + if (DispelMagic_Timer <= diff) + { + Unit target = RandomHelper.RAND(SelectGuestTarget(), SelectTarget(SelectAggroTarget.Random, 0, 100, true)); + if (target) + DoCast(target, SpellIds.Dispelmagic); + + DispelMagic_Timer = 25000; + } + else DispelMagic_Timer -= diff; } } [Script] - class boss_lady_keira_berrybuck : CreatureScript + class boss_lady_keira_berrybuck : boss_moroes_guestAI { - public boss_lady_keira_berrybuck() : base("boss_lady_keira_berrybuck") { } + //Holy Pally + public boss_lady_keira_berrybuck(Creature creature) : base(creature) { } - public override CreatureAI GetAI(Creature creature) + uint Cleanse_Timer; + uint GreaterBless_Timer; + uint HolyLight_Timer; + uint DivineShield_Timer; + + public override void Reset() { - return GetInstanceAI(creature); + Cleanse_Timer = 13000; + GreaterBless_Timer = 1000; + HolyLight_Timer = 7000; + DivineShield_Timer = 31000; + + AcquireGUID(); + + base.Reset(); } - class boss_lady_keira_berrybuckAI : boss_moroes_guestAI + public override void UpdateAI(uint diff) { - //Holy Pally - public boss_lady_keira_berrybuckAI(Creature creature) : base(creature) { } + if (!UpdateVictim()) + return; - uint Cleanse_Timer; - uint GreaterBless_Timer; - uint HolyLight_Timer; - uint DivineShield_Timer; + base.UpdateAI(diff); - public override void Reset() + if (DivineShield_Timer <= diff) { - Cleanse_Timer = 13000; - GreaterBless_Timer = 1000; - HolyLight_Timer = 7000; + DoCast(me, SpellIds.Divineshield); DivineShield_Timer = 31000; - - AcquireGUID(); - - base.Reset(); } + else DivineShield_Timer -= diff; - public override void UpdateAI(uint diff) + if (HolyLight_Timer <= diff) { - if (!UpdateVictim()) - return; + Unit target = SelectGuestTarget(); - base.UpdateAI(diff); - - if (DivineShield_Timer <= diff) - { - DoCast(me, SpellIds.Divineshield); - DivineShield_Timer = 31000; - } else DivineShield_Timer -= diff; - - if (HolyLight_Timer <= diff) - { - Unit target = SelectGuestTarget(); - - DoCast(target, SpellIds.Holylight); - HolyLight_Timer = 10000; - } else HolyLight_Timer -= diff; - - if (GreaterBless_Timer <= diff) - { - Unit target = SelectGuestTarget(); - - DoCast(target, SpellIds.Greaterblessofmight); - - GreaterBless_Timer = 50000; - } else GreaterBless_Timer -= diff; - - if (Cleanse_Timer <= diff) - { - Unit target = SelectGuestTarget(); - - DoCast(target, SpellIds.Cleanse); - - Cleanse_Timer = 10000; - } else Cleanse_Timer -= diff; + DoCast(target, SpellIds.Holylight); + HolyLight_Timer = 10000; } + else HolyLight_Timer -= diff; + + if (GreaterBless_Timer <= diff) + { + Unit target = SelectGuestTarget(); + + DoCast(target, SpellIds.Greaterblessofmight); + + GreaterBless_Timer = 50000; + } + else GreaterBless_Timer -= diff; + + if (Cleanse_Timer <= diff) + { + Unit target = SelectGuestTarget(); + + DoCast(target, SpellIds.Cleanse); + + Cleanse_Timer = 10000; + } + else Cleanse_Timer -= diff; } } [Script] - class boss_lord_robin_daris : CreatureScript + class boss_lord_robin_daris : boss_moroes_guestAI { - public boss_lord_robin_daris() : base("boss_lord_robin_daris") { } + //Arms Warr + public boss_lord_robin_daris(Creature creature) : base(creature) { } - public override CreatureAI GetAI(Creature creature) + uint Hamstring_Timer; + uint MortalStrike_Timer; + uint WhirlWind_Timer; + + public override void Reset() { - return GetInstanceAI(creature); + Hamstring_Timer = 7000; + MortalStrike_Timer = 10000; + WhirlWind_Timer = 21000; + + base.Reset(); } - class boss_lord_robin_darisAI : boss_moroes_guestAI + public override void UpdateAI(uint diff) { - //Arms Warr - public boss_lord_robin_darisAI(Creature creature) : base(creature) { } + if (!UpdateVictim()) + return; - uint Hamstring_Timer; - uint MortalStrike_Timer; - uint WhirlWind_Timer; + base.UpdateAI(diff); - public override void Reset() + if (Hamstring_Timer <= diff) { - Hamstring_Timer = 7000; - MortalStrike_Timer = 10000; + DoCastVictim(SpellIds.Hamstring); + Hamstring_Timer = 12000; + } + else Hamstring_Timer -= diff; + + if (MortalStrike_Timer <= diff) + { + DoCastVictim(SpellIds.Mortalstrike); + MortalStrike_Timer = 18000; + } + else MortalStrike_Timer -= diff; + + if (WhirlWind_Timer <= diff) + { + DoCast(me, SpellIds.Whirlwind); WhirlWind_Timer = 21000; - - base.Reset(); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - base.UpdateAI(diff); - - if (Hamstring_Timer <= diff) - { - DoCastVictim(SpellIds.Hamstring); - Hamstring_Timer = 12000; - } else Hamstring_Timer -= diff; - - if (MortalStrike_Timer <= diff) - { - DoCastVictim(SpellIds.Mortalstrike); - MortalStrike_Timer = 18000; - } else MortalStrike_Timer -= diff; - - if (WhirlWind_Timer <= diff) - { - DoCast(me, SpellIds.Whirlwind); - WhirlWind_Timer = 21000; - } else WhirlWind_Timer -= diff; } + else WhirlWind_Timer -= diff; } } [Script] - class boss_lord_crispin_ference : CreatureScript + class boss_lord_crispin_ference : boss_moroes_guestAI { - public boss_lord_crispin_ference() : base("boss_lord_crispin_ference") { } + //Arms Warr + public boss_lord_crispin_ference(Creature creature) : base(creature) { } - public override CreatureAI GetAI(Creature creature) + uint Disarm_Timer; + uint HeroicStrike_Timer; + uint ShieldBash_Timer; + uint ShieldWall_Timer; + + public override void Reset() { - return GetInstanceAI(creature); + Disarm_Timer = 6000; + HeroicStrike_Timer = 10000; + ShieldBash_Timer = 8000; + ShieldWall_Timer = 4000; + + base.Reset(); } - class boss_lord_crispin_ferenceAI : boss_moroes_guestAI + public override void UpdateAI(uint diff) { - //Arms Warr - public boss_lord_crispin_ferenceAI(Creature creature) : base(creature) { } + if (!UpdateVictim()) + return; - uint Disarm_Timer; - uint HeroicStrike_Timer; - uint ShieldBash_Timer; - uint ShieldWall_Timer; + base.UpdateAI(diff); - public override void Reset() + if (Disarm_Timer <= diff) { - Disarm_Timer = 6000; + DoCastVictim(SpellIds.Disarm); + Disarm_Timer = 12000; + } + else Disarm_Timer -= diff; + + if (HeroicStrike_Timer <= diff) + { + DoCastVictim(SpellIds.Heroicstrike); HeroicStrike_Timer = 10000; - ShieldBash_Timer = 8000; - ShieldWall_Timer = 4000; - - base.Reset(); } + else HeroicStrike_Timer -= diff; - public override void UpdateAI(uint diff) + if (ShieldBash_Timer <= diff) { - if (!UpdateVictim()) - return; - - base.UpdateAI(diff); - - if (Disarm_Timer <= diff) - { - DoCastVictim(SpellIds.Disarm); - Disarm_Timer = 12000; - } else Disarm_Timer -= diff; - - if (HeroicStrike_Timer <= diff) - { - DoCastVictim(SpellIds.Heroicstrike); - HeroicStrike_Timer = 10000; - } else HeroicStrike_Timer -= diff; - - if (ShieldBash_Timer <= diff) - { - DoCastVictim(SpellIds.Shieldbash); - ShieldBash_Timer = 13000; - } else ShieldBash_Timer -= diff; - - if (ShieldWall_Timer <= diff) - { - DoCast(me, SpellIds.Shieldwall); - ShieldWall_Timer = 21000; - } else ShieldWall_Timer -= diff; + DoCastVictim(SpellIds.Shieldbash); + ShieldBash_Timer = 13000; } + else ShieldBash_Timer -= diff; + + if (ShieldWall_Timer <= diff) + { + DoCast(me, SpellIds.Shieldwall); + ShieldWall_Timer = 21000; + } + else ShieldWall_Timer -= diff; } } } diff --git a/Scripts/EasternKingdoms/Karazhan/OperaEvent.cs b/Scripts/EasternKingdoms/Karazhan/OperaEvent.cs index 5b4d7edb8..63a68122e 100644 --- a/Scripts/EasternKingdoms/Karazhan/OperaEvent.cs +++ b/Scripts/EasternKingdoms/Karazhan/OperaEvent.cs @@ -84,7 +84,7 @@ namespace Scripts.EasternKingdoms.Karazhan.OperaEvent public const uint NpcCrone = 18168; } - class WizardofOzBase : ScriptedAI + public class WizardofOzBase : ScriptedAI { public WizardofOzBase(Creature creature) : base(creature) { } @@ -109,636 +109,567 @@ namespace Scripts.EasternKingdoms.Karazhan.OperaEvent } [Script] - class boss_dorothee : CreatureScript + public class boss_dorothee : WizardofOzBase { - public boss_dorothee() : base("boss_dorothee") { } - - public class boss_dorotheeAI : WizardofOzBase + public boss_dorothee(Creature creature) : base(creature) { - public boss_dorotheeAI(Creature creature) : base(creature) + instance = creature.GetInstanceScript(); + } + + public override void Reset() + { + AggroTimer = 500; + + WaterBoltTimer = 5000; + FearTimer = 15000; + SummonTitoTimer = 47500; + + SummonedTito = false; + TitoDied = false; + } + + public override void EnterCombat(Unit who) + { + Talk(WizardOfOz.SayDorotheeAggro); + } + + public override void JustReachedHome() + { + me.DespawnOrUnsummon(); + } + + public override void JustDied(Unit killer) + { + Talk(WizardOfOz.SayDorotheeDeath); + + SummonCroneIfReady(instance, me); + } + + public override void AttackStart(Unit who) + { + if (me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable)) + return; + + base.AttackStart(who); + } + + public override void MoveInLineOfSight(Unit who) + { + if (me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable)) + return; + + base.MoveInLineOfSight(who); + } + + public override void UpdateAI(uint diff) + { + if (AggroTimer != 0) { - instance = creature.GetInstanceScript(); + if (AggroTimer <= diff) + { + me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); + AggroTimer = 0; + } + else AggroTimer -= diff; } - public override void Reset() + if (!UpdateVictim()) + return; + + if (WaterBoltTimer <= diff) { - AggroTimer = 500; + DoCast(SelectTarget(SelectAggroTarget.Random, 0), WizardOfOz.SpellWaterbolt); + WaterBoltTimer = (uint)(TitoDied ? 1500 : 5000); + } + else WaterBoltTimer -= diff; - WaterBoltTimer = 5000; - FearTimer = 15000; - SummonTitoTimer = 47500; + if (FearTimer <= diff) + { + DoCastVictim(WizardOfOz.SpellScream); + FearTimer = 30000; + } + else FearTimer -= diff; - SummonedTito = false; + if (!SummonedTito) + { + if (SummonTitoTimer <= diff) + SummonTito(); + else SummonTitoTimer -= diff; + } + + DoMeleeAttackIfReady(); + } + + void SummonTito() + { + Creature pTito = me.SummonCreature(WizardOfOz.NpcTito, 0.0f, 0.0f, 0.0f, 0.0f, TempSummonType.TimedDespawnOOC, 30000); + if (pTito) + { + Talk(WizardOfOz.SayDorotheeSummon); + DorotheeGUID = me.GetGUID(); + pTito.GetAI().AttackStart(me.GetVictim()); + SummonedTito = true; TitoDied = false; } - - public override void EnterCombat(Unit who) - { - Talk(WizardOfOz.SayDorotheeAggro); - } - - public override void JustReachedHome() - { - me.DespawnOrUnsummon(); - } - - public override void JustDied(Unit killer) - { - Talk(WizardOfOz.SayDorotheeDeath); - - SummonCroneIfReady(instance, me); - } - - public override void AttackStart(Unit who) - { - if (me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable)) - return; - - base.AttackStart(who); - } - - public override void MoveInLineOfSight(Unit who) - { - if (me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable)) - return; - - base.MoveInLineOfSight(who); - } - - public override void UpdateAI(uint diff) - { - if (AggroTimer != 0) - { - if (AggroTimer <= diff) - { - me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); - AggroTimer = 0; - } - else AggroTimer -= diff; - } - - if (!UpdateVictim()) - return; - - if (WaterBoltTimer <= diff) - { - DoCast(SelectTarget(SelectAggroTarget.Random, 0), WizardOfOz.SpellWaterbolt); - WaterBoltTimer = (uint)(TitoDied ? 1500 : 5000); - } - else WaterBoltTimer -= diff; - - if (FearTimer <= diff) - { - DoCastVictim(WizardOfOz.SpellScream); - FearTimer = 30000; - } - else FearTimer -= diff; - - if (!SummonedTito) - { - if (SummonTitoTimer <= diff) - SummonTito(); - else SummonTitoTimer -= diff; - } - - DoMeleeAttackIfReady(); - } - - void SummonTito() - { - Creature pTito = me.SummonCreature(WizardOfOz.NpcTito, 0.0f, 0.0f, 0.0f, 0.0f, TempSummonType.TimedDespawnOOC, 30000); - if (pTito) - { - Talk(WizardOfOz.SayDorotheeSummon); - DorotheeGUID = me.GetGUID(); - pTito.GetAI().AttackStart(me.GetVictim()); - SummonedTito = true; - TitoDied = false; - } - } - - InstanceScript instance; - - uint WaterBoltTimer; - uint FearTimer; - uint SummonTitoTimer; - - bool SummonedTito; } - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } + InstanceScript instance; + + uint WaterBoltTimer; + uint FearTimer; + uint SummonTitoTimer; + + bool SummonedTito; } [Script] - class npc_tito : CreatureScript + public class npc_tito : WizardofOzBase { - public npc_tito() : base("npc_tito") { } + public npc_tito(Creature creature) : base(creature) { } - public class npc_titoAI : WizardofOzBase + public override void Reset() { - public npc_titoAI(Creature creature) : base(creature) { } + DorotheeGUID.Clear(); + YipTimer = 10000; + } - public override void Reset() + public override void EnterCombat(Unit who) { } + + public override void JustDied(Unit killer) + { + if (!DorotheeGUID.IsEmpty()) { - DorotheeGUID.Clear(); + Creature Dorothee = ObjectAccessor.GetCreature(me, DorotheeGUID); + if (Dorothee && Dorothee.IsAlive()) + { + TitoDied = true; + Talk(WizardOfOz.SayDorotheeTitoDeath, Dorothee); + } + } + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + if (YipTimer <= diff) + { + DoCastVictim(WizardOfOz.SpellYipping); YipTimer = 10000; } + else YipTimer -= diff; - public override void EnterCombat(Unit who) { } - - public override void JustDied(Unit killer) - { - if (!DorotheeGUID.IsEmpty()) - { - Creature Dorothee = ObjectAccessor.GetCreature(me, DorotheeGUID); - if (Dorothee && Dorothee.IsAlive()) - { - TitoDied = true; - Talk(WizardOfOz.SayDorotheeTitoDeath, Dorothee); - } - } - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - if (YipTimer <= diff) - { - DoCastVictim(WizardOfOz.SpellYipping); - YipTimer = 10000; - } - else YipTimer -= diff; - - DoMeleeAttackIfReady(); - } - - uint YipTimer; + DoMeleeAttackIfReady(); } - public override CreatureAI GetAI(Creature creature) - { - return new npc_titoAI(creature); - } + uint YipTimer; } [Script] - class boss_strawman : CreatureScript + class boss_strawman : WizardofOzBase { - public boss_strawman() : base("boss_strawman") { } - - class boss_strawmanAI : WizardofOzBase + public boss_strawman(Creature creature) : base(creature) { - public boss_strawmanAI(Creature creature) : base(creature) - { - instance = creature.GetInstanceScript(); - } - - public override void Reset() - { - AggroTimer = 13000; - BrainBashTimer = 5000; - BrainWipeTimer = 7000; - } - - public override void AttackStart(Unit who) - { - if (me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable)) - return; - - base.AttackStart(who); - } - - public override void MoveInLineOfSight(Unit who) - { - if (me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable)) - return; - - base.MoveInLineOfSight(who); - } - - public override void EnterCombat(Unit who) - { - Talk(WizardOfOz.SayStrawmanAggro); - } - - public override void SpellHit(Unit caster, SpellInfo Spell) - { - if ((Spell.SchoolMask == SpellSchoolMask.Fire) && ((RandomHelper.randChance() % 10) == 0)) - { - DoCast(me, WizardOfOz.SpellBurningStraw, true); - } - } - - public override void JustDied(Unit killer) - { - Talk(WizardOfOz.SayStrawmanDeath); - - SummonCroneIfReady(instance, me); - } - - public override void KilledUnit(Unit victim) - { - Talk(WizardOfOz.SayStrawmanSlay); - } - - public override void UpdateAI(uint diff) - { - if (AggroTimer != 0) - { - if (AggroTimer <= diff) - { - me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); - AggroTimer = 0; - } - else AggroTimer -= diff; - } - - if (!UpdateVictim()) - return; - - if (BrainBashTimer <= diff) - { - DoCastVictim(WizardOfOz.SpellBrainBash); - BrainBashTimer = 15000; - } - else BrainBashTimer -= diff; - - if (BrainWipeTimer <= diff) - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100, true); - if (target) - DoCast(target, WizardOfOz.SpellBrainWipe); - BrainWipeTimer = 20000; - } - else BrainWipeTimer -= diff; - - DoMeleeAttackIfReady(); - } - - InstanceScript instance; - - uint BrainBashTimer; - uint BrainWipeTimer; + instance = creature.GetInstanceScript(); } - public override CreatureAI GetAI(Creature creature) + public override void Reset() { - return GetInstanceAI(creature); - } - } - - [Script] - class boss_tinhead : CreatureScript - { - public boss_tinhead() : base("boss_tinhead") { } - - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); + AggroTimer = 13000; + BrainBashTimer = 5000; + BrainWipeTimer = 7000; } - class boss_tinheadAI : WizardofOzBase + public override void AttackStart(Unit who) { - public boss_tinheadAI(Creature creature) : base(creature) - { - instance = creature.GetInstanceScript(); - } + if (me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable)) + return; - public override void Reset() - { - AggroTimer = 15000; - CleaveTimer = 5000; - RustTimer = 30000; - - RustCount = 0; - } - - public override void EnterCombat(Unit who) - { - Talk(WizardOfOz.SayTinheadAggro); - } - - public override void JustReachedHome() - { - me.DespawnOrUnsummon(); - } - - public override void AttackStart(Unit who) - { - if (me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable)) - return; - - base.AttackStart(who); - } - - public override void MoveInLineOfSight(Unit who) - { - if (me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable)) - return; - - base.MoveInLineOfSight(who); - } - - public override void JustDied(Unit killer) - { - Talk(WizardOfOz.SayTinheadDeath); - - SummonCroneIfReady(instance, me); - } - - public override void KilledUnit(Unit victim) - { - Talk(WizardOfOz.SayTinheadSlay); - } - - public override void UpdateAI(uint diff) - { - if (AggroTimer != 0) - { - if (AggroTimer <= diff) - { - me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); - AggroTimer = 0; - } - else AggroTimer -= diff; - } - - if (!UpdateVictim()) - return; - - if (CleaveTimer <= diff) - { - DoCastVictim(WizardOfOz.SpellCleave); - CleaveTimer = 5000; - } - else CleaveTimer -= diff; - - if (RustCount < 8) - { - if (RustTimer <= diff) - { - ++RustCount; - Talk(WizardOfOz.EmoteRust); - DoCast(me, WizardOfOz.SpellRust); - RustTimer = 6000; - } - else RustTimer -= diff; - } - - DoMeleeAttackIfReady(); - } - - InstanceScript instance; - - uint CleaveTimer; - uint RustTimer; - - byte RustCount; - } - } - - [Script] - class boss_roar : CreatureScript - { - public boss_roar() : base("boss_roar") { } - - class boss_roarAI : WizardofOzBase - { - public boss_roarAI(Creature creature) : base(creature) - { - instance = creature.GetInstanceScript(); - } - - public override void Reset() - { - AggroTimer = 20000; - MangleTimer = 5000; - ShredTimer = 10000; - ScreamTimer = 15000; - } - - public override void MoveInLineOfSight(Unit who) - { - if (me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable)) - return; - - base.MoveInLineOfSight(who); - } - - public override void AttackStart(Unit who) - { - if (me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable)) - return; - - base.AttackStart(who); - } - - public override void EnterCombat(Unit who) - { - Talk(WizardOfOz.SayRoarAggro); - } - - public override void JustReachedHome() - { - me.DespawnOrUnsummon(); - } - - public override void JustDied(Unit killer) - { - Talk(WizardOfOz.SayRoarDeath); - - SummonCroneIfReady(instance, me); - } - - public override void KilledUnit(Unit victim) - { - Talk(WizardOfOz.SayRoarSlay); - } - - public override void UpdateAI(uint diff) - { - if (AggroTimer != 0) - { - if (AggroTimer <= diff) - { - me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); - AggroTimer = 0; - } - else AggroTimer -= diff; - } - - if (!UpdateVictim()) - return; - - if (MangleTimer <= diff) - { - DoCastVictim(WizardOfOz.SpellMangle); - MangleTimer = RandomHelper.URand(5000, 8000); - } - else MangleTimer -= diff; - - if (ShredTimer <= diff) - { - DoCastVictim(WizardOfOz.SpellShred); - ShredTimer = RandomHelper.URand(10000, 15000); - } - else ShredTimer -= diff; - - if (ScreamTimer <= diff) - { - DoCastVictim(WizardOfOz.SpellFrightenedScream); - ScreamTimer = RandomHelper.URand(20000, 30000); - } - else ScreamTimer -= diff; - - DoMeleeAttackIfReady(); - } - - InstanceScript instance; - - uint MangleTimer; - uint ShredTimer; - uint ScreamTimer; + base.AttackStart(who); } - public override CreatureAI GetAI(Creature creature) + public override void MoveInLineOfSight(Unit who) { - return GetInstanceAI(creature); + if (me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable)) + return; + + base.MoveInLineOfSight(who); } - } - [Script] - class boss_crone : CreatureScript - { - public boss_crone() : base("boss_crone") { } - - class boss_croneAI : WizardofOzBase + public override void EnterCombat(Unit who) { - public boss_croneAI(Creature creature) : base(creature) + Talk(WizardOfOz.SayStrawmanAggro); + } + + public override void SpellHit(Unit caster, SpellInfo Spell) + { + if ((Spell.SchoolMask == SpellSchoolMask.Fire) && ((RandomHelper.randChance() % 10) == 0)) { - instance = creature.GetInstanceScript(); + DoCast(me, WizardOfOz.SpellBurningStraw, true); } + } - public override void Reset() + public override void JustDied(Unit killer) + { + Talk(WizardOfOz.SayStrawmanDeath); + + SummonCroneIfReady(instance, me); + } + + public override void KilledUnit(Unit victim) + { + Talk(WizardOfOz.SayStrawmanSlay); + } + + public override void UpdateAI(uint diff) + { + if (AggroTimer != 0) { - CycloneTimer = 30000; - ChainLightningTimer = 10000; - } - - public override void JustReachedHome() - { - me.DespawnOrUnsummon(); - } - - public override void KilledUnit(Unit victim) - { - Talk(WizardOfOz.SayCroneSlay); - } - - public override void EnterCombat(Unit who) - { - Talk(WizardOfOz.SayCroneAggro); - me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); - me.RemoveFlag(UnitFields.Flags, UnitFlags.ImmuneToPc); - } - - public override void JustDied(Unit killer) - { - Talk(WizardOfOz.SayCroneDeath); - - instance.SetData(karazhanConst.BossOpera, (uint)EncounterState.Done); - instance.HandleGameObject(instance.GetGuidData(DataTypes.GoStagedoorleft), true); - instance.HandleGameObject(instance.GetGuidData(DataTypes.GoStagedoorright), true); - - GameObject pSideEntrance = instance.instance.GetGameObject(instance.GetGuidData(DataTypes.GoSideEntranceDoor)); - if (pSideEntrance) - pSideEntrance.RemoveFlag(GameObjectFields.Flags, GameObjectFlags.Locked); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - if (me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable)) + if (AggroTimer <= diff) + { me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); - - if (CycloneTimer <= diff) - { - Creature Cyclone = DoSpawnCreature(WizardOfOz.NpcCyclone, RandomHelper.FRand(0, 9), RandomHelper.FRand(0, 9), 0, 0, TempSummonType.TimedDespawn, 15000); - if (Cyclone) - Cyclone.CastSpell(Cyclone, WizardOfOz.SpellCycloneVisual, true); - CycloneTimer = 30000; + AggroTimer = 0; } - else CycloneTimer -= diff; - - if (ChainLightningTimer <= diff) - { - DoCastVictim(WizardOfOz.SpellChainLightning); - ChainLightningTimer = 15000; - } - else ChainLightningTimer -= diff; - - DoMeleeAttackIfReady(); + else AggroTimer -= diff; } - InstanceScript instance; + if (!UpdateVictim()) + return; - uint CycloneTimer; - uint ChainLightningTimer; + if (BrainBashTimer <= diff) + { + DoCastVictim(WizardOfOz.SpellBrainBash); + BrainBashTimer = 15000; + } + else BrainBashTimer -= diff; + + if (BrainWipeTimer <= diff) + { + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100, true); + if (target) + DoCast(target, WizardOfOz.SpellBrainWipe); + BrainWipeTimer = 20000; + } + else BrainWipeTimer -= diff; + + DoMeleeAttackIfReady(); } - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } + InstanceScript instance; + + uint BrainBashTimer; + uint BrainWipeTimer; } [Script] - class npc_cyclone : CreatureScript + class boss_tinhead : WizardofOzBase { - public npc_cyclone() : base("npc_cyclone") { } - - class npc_cycloneAI : ScriptedAI + public boss_tinhead(Creature creature) : base(creature) { - public npc_cycloneAI(Creature creature) : base(creature) { } + instance = creature.GetInstanceScript(); + } - public override void Reset() + public override void Reset() + { + AggroTimer = 15000; + CleaveTimer = 5000; + RustTimer = 30000; + + RustCount = 0; + } + + public override void EnterCombat(Unit who) + { + Talk(WizardOfOz.SayTinheadAggro); + } + + public override void JustReachedHome() + { + me.DespawnOrUnsummon(); + } + + public override void AttackStart(Unit who) + { + if (me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable)) + return; + + base.AttackStart(who); + } + + public override void MoveInLineOfSight(Unit who) + { + if (me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable)) + return; + + base.MoveInLineOfSight(who); + } + + public override void JustDied(Unit killer) + { + Talk(WizardOfOz.SayTinheadDeath); + + SummonCroneIfReady(instance, me); + } + + public override void KilledUnit(Unit victim) + { + Talk(WizardOfOz.SayTinheadSlay); + } + + public override void UpdateAI(uint diff) + { + if (AggroTimer != 0) { - MoveTimer = 1000; - } - - public override void EnterCombat(Unit who) { } - - public override void MoveInLineOfSight(Unit who) { } - - public override void UpdateAI(uint diff) - { - if (!me.HasAura(WizardOfOz.SpellKnockback)) - DoCast(me, WizardOfOz.SpellKnockback, true); - - if (MoveTimer <= diff) + if (AggroTimer <= diff) { - Position pos = me.GetRandomNearPosition(10); - me.GetMotionMaster().MovePoint(0, pos); - MoveTimer = RandomHelper.URand(5000, 8000); + me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); + AggroTimer = 0; } - else MoveTimer -= diff; + else AggroTimer -= diff; } - uint MoveTimer; + if (!UpdateVictim()) + return; + + if (CleaveTimer <= diff) + { + DoCastVictim(WizardOfOz.SpellCleave); + CleaveTimer = 5000; + } + else CleaveTimer -= diff; + + if (RustCount < 8) + { + if (RustTimer <= diff) + { + ++RustCount; + Talk(WizardOfOz.EmoteRust); + DoCast(me, WizardOfOz.SpellRust); + RustTimer = 6000; + } + else RustTimer -= diff; + } + + DoMeleeAttackIfReady(); } - public override CreatureAI GetAI(Creature creature) - { - return new npc_cycloneAI(creature); - } + InstanceScript instance; + + uint CleaveTimer; + uint RustTimer; + + byte RustCount; } + + [Script] + class boss_roar : WizardofOzBase + { + public boss_roar(Creature creature) : base(creature) + { + instance = creature.GetInstanceScript(); + } + + public override void Reset() + { + AggroTimer = 20000; + MangleTimer = 5000; + ShredTimer = 10000; + ScreamTimer = 15000; + } + + public override void MoveInLineOfSight(Unit who) + { + if (me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable)) + return; + + base.MoveInLineOfSight(who); + } + + public override void AttackStart(Unit who) + { + if (me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable)) + return; + + base.AttackStart(who); + } + + public override void EnterCombat(Unit who) + { + Talk(WizardOfOz.SayRoarAggro); + } + + public override void JustReachedHome() + { + me.DespawnOrUnsummon(); + } + + public override void JustDied(Unit killer) + { + Talk(WizardOfOz.SayRoarDeath); + + SummonCroneIfReady(instance, me); + } + + public override void KilledUnit(Unit victim) + { + Talk(WizardOfOz.SayRoarSlay); + } + + public override void UpdateAI(uint diff) + { + if (AggroTimer != 0) + { + if (AggroTimer <= diff) + { + me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); + AggroTimer = 0; + } + else AggroTimer -= diff; + } + + if (!UpdateVictim()) + return; + + if (MangleTimer <= diff) + { + DoCastVictim(WizardOfOz.SpellMangle); + MangleTimer = RandomHelper.URand(5000, 8000); + } + else MangleTimer -= diff; + + if (ShredTimer <= diff) + { + DoCastVictim(WizardOfOz.SpellShred); + ShredTimer = RandomHelper.URand(10000, 15000); + } + else ShredTimer -= diff; + + if (ScreamTimer <= diff) + { + DoCastVictim(WizardOfOz.SpellFrightenedScream); + ScreamTimer = RandomHelper.URand(20000, 30000); + } + else ScreamTimer -= diff; + + DoMeleeAttackIfReady(); + } + + InstanceScript instance; + + uint MangleTimer; + uint ShredTimer; + uint ScreamTimer; + } + + [Script] + class boss_crone : WizardofOzBase + { + public boss_crone(Creature creature) : base(creature) + { + instance = creature.GetInstanceScript(); + } + + public override void Reset() + { + CycloneTimer = 30000; + ChainLightningTimer = 10000; + } + + public override void JustReachedHome() + { + me.DespawnOrUnsummon(); + } + + public override void KilledUnit(Unit victim) + { + Talk(WizardOfOz.SayCroneSlay); + } + + public override void EnterCombat(Unit who) + { + Talk(WizardOfOz.SayCroneAggro); + me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); + me.RemoveFlag(UnitFields.Flags, UnitFlags.ImmuneToPc); + } + + public override void JustDied(Unit killer) + { + Talk(WizardOfOz.SayCroneDeath); + + instance.SetData(karazhanConst.BossOpera, (uint)EncounterState.Done); + instance.HandleGameObject(instance.GetGuidData(DataTypes.GoStagedoorleft), true); + instance.HandleGameObject(instance.GetGuidData(DataTypes.GoStagedoorright), true); + + GameObject pSideEntrance = instance.instance.GetGameObject(instance.GetGuidData(DataTypes.GoSideEntranceDoor)); + if (pSideEntrance) + pSideEntrance.RemoveFlag(GameObjectFields.Flags, GameObjectFlags.Locked); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + if (me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable)) + me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); + + if (CycloneTimer <= diff) + { + Creature Cyclone = DoSpawnCreature(WizardOfOz.NpcCyclone, RandomHelper.FRand(0, 9), RandomHelper.FRand(0, 9), 0, 0, TempSummonType.TimedDespawn, 15000); + if (Cyclone) + Cyclone.CastSpell(Cyclone, WizardOfOz.SpellCycloneVisual, true); + CycloneTimer = 30000; + } + else CycloneTimer -= diff; + + if (ChainLightningTimer <= diff) + { + DoCastVictim(WizardOfOz.SpellChainLightning); + ChainLightningTimer = 15000; + } + else ChainLightningTimer -= diff; + + DoMeleeAttackIfReady(); + } + + InstanceScript instance; + + uint CycloneTimer; + uint ChainLightningTimer; + } + + [Script] + class npc_cyclone : ScriptedAI + { + public npc_cyclone(Creature creature) : base(creature) { } + + public override void Reset() + { + MoveTimer = 1000; + } + + public override void EnterCombat(Unit who) { } + + public override void MoveInLineOfSight(Unit who) { } + + public override void UpdateAI(uint diff) + { + if (!me.HasAura(WizardOfOz.SpellKnockback)) + DoCast(me, WizardOfOz.SpellKnockback, true); + + if (MoveTimer <= diff) + { + Position pos = me.GetRandomNearPosition(10); + me.GetMotionMaster().MovePoint(0, pos); + MoveTimer = RandomHelper.URand(5000, 8000); + } + else MoveTimer -= diff; + } + + uint MoveTimer; + } + #endregion #region Red Riding Hood @@ -747,6 +678,7 @@ namespace Scripts.EasternKingdoms.Karazhan.OperaEvent public const uint SayWolfAggro = 0; public const uint SayWolfSlay = 1; public const uint SayWolfHood = 2; + public const uint OptionWhatPhatLewtsYouHave = 7443; public const uint SoundWolfDeath = 9275; public const uint SpellLittleRedRidingHood = 30768; @@ -757,164 +689,146 @@ namespace Scripts.EasternKingdoms.Karazhan.OperaEvent } [Script] - class npc_grandmother : CreatureScript + class npc_grandmother : ScriptedAI { - public npc_grandmother() : base("npc_grandmother") { } + public npc_grandmother(Creature creature) : base(creature) { } - public override bool OnGossipSelect(Player player, Creature creature, uint sender, uint action) + public override void sGossipSelect(Player player, uint menuId, uint gossipListId) { - player.PlayerTalkClass.ClearMenus(); - if (action == eTradeskill.GossipActionInfoDef) + if (menuId == RedRidingHood.OptionWhatPhatLewtsYouHave && gossipListId == 0) { - Creature pBigBadWolf = creature.SummonCreature(RedRidingHood.NpcBigBadWolf, 0.0f, 0.0f, 0.0f, 0.0f, TempSummonType.TimedOrDeadDespawn, Time.Hour * 2 * Time.InMilliseconds); + player.PlayerTalkClass.SendCloseGossip(); + + Creature pBigBadWolf = me.SummonCreature(RedRidingHood.NpcBigBadWolf, me.GetPositionX(), me.GetPositionY(), me.GetPositionZ(), me.GetOrientation(), TempSummonType.TimedOrDeadDespawn, Time.Hour * 2 * Time.InMilliseconds); if (pBigBadWolf) pBigBadWolf.GetAI().AttackStart(player); - creature.DespawnOrUnsummon(); + me.DespawnOrUnsummon(); } - - return true; - } - - public override bool OnGossipHello(Player player, Creature creature) - { - player.ADD_GOSSIP_ITEM(GossipOptionIcon.Chat, "What phat lewtz you have grandmother?", eTradeskill.GossipSenderMain, eTradeskill.GossipActionInfoDef); - player.SEND_GOSSIP_MENU(8990, creature.GetGUID()); - - return true; } } [Script] - class boss_bigbadwolf : CreatureScript + class boss_bigbadwolf : ScriptedAI { - public boss_bigbadwolf() : base("boss_bigbadwolf") { } - - class boss_bigbadwolfAI : ScriptedAI + public boss_bigbadwolf(Creature creature) : base(creature) { - public boss_bigbadwolfAI(Creature creature) : base(creature) - { - instance = creature.GetInstanceScript(); - } + instance = creature.GetInstanceScript(); + } - public override void Reset() + public override void Reset() + { + ChaseTimer = 30000; + FearTimer = RandomHelper.URand(25000, 35000); + SwipeTimer = 5000; + + HoodGUID.Clear(); + TempThreat = 0; + + IsChasing = false; + } + + public override void EnterCombat(Unit who) + { + Talk(RedRidingHood.SayWolfAggro); + } + + public override void KilledUnit(Unit victim) + { + Talk(RedRidingHood.SayWolfSlay); + } + + public override void JustReachedHome() + { + me.DespawnOrUnsummon(); + } + + public override void JustDied(Unit killer) + { + DoPlaySoundToSet(me, RedRidingHood.SoundWolfDeath); + + instance.SetData(karazhanConst.BossOpera, (uint)EncounterState.Done); + instance.HandleGameObject(instance.GetGuidData(DataTypes.GoStagedoorleft), true); + instance.HandleGameObject(instance.GetGuidData(DataTypes.GoStagedoorright), true); + + GameObject pSideEntrance = instance.instance.GetGameObject(instance.GetGuidData(DataTypes.GoSideEntranceDoor)); + if (pSideEntrance) + pSideEntrance.RemoveFlag(GameObjectFields.Flags, GameObjectFlags.Locked); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + DoMeleeAttackIfReady(); + + if (ChaseTimer <= diff) { - ChaseTimer = 30000; + if (!IsChasing) + { + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100, true); + if (target) + { + Talk(RedRidingHood.SayWolfHood); + DoCast(target, RedRidingHood.SpellLittleRedRidingHood, true); + TempThreat = DoGetThreat(target); + if (TempThreat != 0.0f) + DoModifyThreatPercent(target, -100); + HoodGUID = target.GetGUID(); + me.AddThreat(target, 1000000.0f); + ChaseTimer = 20000; + IsChasing = true; + } + } + else + { + IsChasing = false; + Unit target = Global.ObjAccessor.GetUnit(me, HoodGUID); + if (target) + { + HoodGUID.Clear(); + if (DoGetThreat(target) != 0f) + DoModifyThreatPercent(target, -100); + me.AddThreat(target, TempThreat); + TempThreat = 0; + } + + ChaseTimer = 40000; + } + } + else ChaseTimer -= diff; + + if (IsChasing) + return; + + if (FearTimer <= diff) + { + DoCastVictim(RedRidingHood.SpellTerrifyingHowl); FearTimer = RandomHelper.URand(25000, 35000); - SwipeTimer = 5000; - - HoodGUID.Clear(); - TempThreat = 0; - - IsChasing = false; } + else FearTimer -= diff; - public override void EnterCombat(Unit who) + if (SwipeTimer <= diff) { - Talk(RedRidingHood.SayWolfAggro); + DoCastVictim(RedRidingHood.SpellWideSwipe); + SwipeTimer = RandomHelper.URand(25000, 30000); } - - public override void KilledUnit(Unit victim) - { - Talk(RedRidingHood.SayWolfSlay); - } - - public override void JustReachedHome() - { - me.DespawnOrUnsummon(); - } - - public override void JustDied(Unit killer) - { - DoPlaySoundToSet(me, RedRidingHood.SoundWolfDeath); - - instance.SetData(karazhanConst.BossOpera, (uint)EncounterState.Done); - instance.HandleGameObject(instance.GetGuidData(DataTypes.GoStagedoorleft), true); - instance.HandleGameObject(instance.GetGuidData(DataTypes.GoStagedoorright), true); - - GameObject pSideEntrance = instance.instance.GetGameObject(instance.GetGuidData(DataTypes.GoSideEntranceDoor)); - if (pSideEntrance) - pSideEntrance.RemoveFlag(GameObjectFields.Flags, GameObjectFlags.Locked); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - DoMeleeAttackIfReady(); - - if (ChaseTimer <= diff) - { - if (!IsChasing) - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100, true); - if (target) - { - Talk(RedRidingHood.SayWolfHood); - DoCast(target, RedRidingHood.SpellLittleRedRidingHood, true); - TempThreat = DoGetThreat(target); - if (TempThreat != 0.0f) - DoModifyThreatPercent(target, -100); - HoodGUID = target.GetGUID(); - me.AddThreat(target, 1000000.0f); - ChaseTimer = 20000; - IsChasing = true; - } - } - else - { - IsChasing = false; - Unit target = Global.ObjAccessor.GetUnit(me, HoodGUID); - if (target) - { - HoodGUID.Clear(); - if (DoGetThreat(target) != 0f) - DoModifyThreatPercent(target, -100); - me.AddThreat(target, TempThreat); - TempThreat = 0; - } - - ChaseTimer = 40000; - } - } - else ChaseTimer -= diff; - - if (IsChasing) - return; - - if (FearTimer <= diff) - { - DoCastVictim(RedRidingHood.SpellTerrifyingHowl); - FearTimer = RandomHelper.URand(25000, 35000); - } - else FearTimer -= diff; - - if (SwipeTimer <= diff) - { - DoCastVictim(RedRidingHood.SpellWideSwipe); - SwipeTimer = RandomHelper.URand(25000, 30000); - } - else SwipeTimer -= diff; - } - - InstanceScript instance; - - uint ChaseTimer; - uint FearTimer; - uint SwipeTimer; - - ObjectGuid HoodGUID; - float TempThreat; - - bool IsChasing; + else SwipeTimer -= diff; } - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } + InstanceScript instance; + + uint ChaseTimer; + uint FearTimer; + uint SwipeTimer; + + ObjectGuid HoodGUID; + float TempThreat; + + bool IsChasing; } + #endregion #region Romeo & Juliet @@ -959,9 +873,9 @@ namespace Scripts.EasternKingdoms.Karazhan.OperaEvent Both = 2, } - public class julianne_romulobase : ScriptedAI + public class julianne_romuloAI : ScriptedAI { - public julianne_romulobase(Creature creature) : base(creature) { } + public julianne_romuloAI(Creature creature) : base(creature) { } public override void JustReachedHome() { @@ -1021,483 +935,464 @@ namespace Scripts.EasternKingdoms.Karazhan.OperaEvent } [Script] - class boss_julianne : CreatureScript + public class boss_julianne : julianne_romuloAI { - public boss_julianne() : base("boss_julianne") { } - - public class boss_julianneAI : julianne_romulobase + public boss_julianne(Creature creature) : base(creature) { - public boss_julianneAI(Creature creature) : base(creature) + instance = creature.GetInstanceScript(); + EntryYellTimer = 1000; + AggroYellTimer = 10000; + IsFakingDeath = false; + } + + public override void Reset() + { + RomuloGUID.Clear(); + Phase = RAJPhase.Julianne; + + BlindingPassionTimer = 30000; + DevotionTimer = 15000; + EternalAffectionTimer = 25000; + PowerfulAttractionTimer = 5000; + SummonRomuloTimer = 10000; + DrinkPoisonTimer = 0; + ResurrectSelfTimer = 0; + + if (IsFakingDeath) { - instance = creature.GetInstanceScript(); - EntryYellTimer = 1000; - AggroYellTimer = 10000; + Resurrect(me); IsFakingDeath = false; } - public override void Reset() + SummonedRomulo = false; + RomuloDead = false; + } + + public override void EnterCombat(Unit who) { } + + public override void AttackStart(Unit who) + { + if (me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable)) + return; + + base.AttackStart(who); + } + + public override void SpellHit(Unit caster, SpellInfo Spell) + { + if (Spell.Id == JulianneRomulo.SpellDrinkPoison) { - RomuloGUID.Clear(); - Phase = RAJPhase.Julianne; + Talk(JulianneRomulo.SayJulianneDeath01); + DrinkPoisonTimer = 2500; + } + } - BlindingPassionTimer = 30000; - DevotionTimer = 15000; - EternalAffectionTimer = 25000; - PowerfulAttractionTimer = 5000; - SummonRomuloTimer = 10000; - DrinkPoisonTimer = 0; - ResurrectSelfTimer = 0; + public override void DamageTaken(Unit done_by, ref uint damage) + { + if (damage < me.GetHealth()) + return; + //anything below only used if incoming damage will kill + + if (Phase == RAJPhase.Julianne) + { + damage = 0; + + //this means already drinking, so return if (IsFakingDeath) - { - Resurrect(me); - IsFakingDeath = false; - } + return; - SummonedRomulo = false; - RomuloDead = false; + me.InterruptNonMeleeSpells(true); + DoCast(me, JulianneRomulo.SpellDrinkPoison); + + IsFakingDeath = true; + //IS THIS USEFULL? Creature Julianne = (Global.ObjAccessor.GetCreature(me, JulianneGUID)); + return; } - public override void EnterCombat(Unit who) { } - - public override void AttackStart(Unit who) + if (Phase == RAJPhase.Romulo) { - if (me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable)) - return; - - base.AttackStart(who); + Log.outError(LogFilter.Scripts, "boss_julianneAI: cannot take damage in PHASE_ROMULO, why was i here?"); + damage = 0; + return; } - public override void SpellHit(Unit caster, SpellInfo Spell) + if (Phase == RAJPhase.Both) { - if (Spell.Id == JulianneRomulo.SpellDrinkPoison) + Creature Romulo; + //if this is true then we have to kill romulo too + if (RomuloDead) { - Talk(JulianneRomulo.SayJulianneDeath01); - DrinkPoisonTimer = 2500; - } - } - - public override void DamageTaken(Unit done_by, ref uint damage) - { - if (damage < me.GetHealth()) - return; - - //anything below only used if incoming damage will kill - - if (Phase == RAJPhase.Julianne) - { - damage = 0; - - //this means already drinking, so return - if (IsFakingDeath) - return; - - me.InterruptNonMeleeSpells(true); - DoCast(me, JulianneRomulo.SpellDrinkPoison); - - IsFakingDeath = true; - //IS THIS USEFULL? Creature Julianne = (Global.ObjAccessor.GetCreature(me, JulianneGUID)); - return; - } - - if (Phase == RAJPhase.Romulo) - { - Log.outError(LogFilter.Scripts, "boss_julianneAI: cannot take damage in PHASE_ROMULO, why was i here?"); - damage = 0; - return; - } - - if (Phase == RAJPhase.Both) - { - Creature Romulo; - //if this is true then we have to kill romulo too - if (RomuloDead) - { - Romulo = ObjectAccessor.GetCreature(me, RomuloGUID); - if (Romulo) - { - Romulo.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable); - Romulo.GetMotionMaster().Clear(); - Romulo.setDeathState(DeathState.JustDied); - Romulo.CombatStop(true); - Romulo.DeleteThreatList(); - Romulo.SetUInt32Value(ObjectFields.DynamicFlags, (uint)UnitDynFlags.Lootable); - } - - return; - } - - //if not already returned, then romulo is alive and we can pretend die Romulo = ObjectAccessor.GetCreature(me, RomuloGUID); if (Romulo) { - PretendToDie(); - IsFakingDeath = true; - ((julianne_romulobase)Romulo.GetAI()).ResurrectTimer = 10000; - ((julianne_romulobase)Romulo.GetAI()).JulianneDead = true; - damage = 0; - return; + Romulo.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable); + Romulo.GetMotionMaster().Clear(); + Romulo.setDeathState(DeathState.JustDied); + Romulo.CombatStop(true); + Romulo.DeleteThreatList(); + Romulo.SetUInt32Value(ObjectFields.DynamicFlags, (uint)UnitDynFlags.Lootable); } - } - Log.outError(LogFilter.Scripts, "boss_julianneAI: DamageTaken reach end of code, that should not happen."); - } - public override void JustDied(Unit killer) - { - Talk(JulianneRomulo.SayJulianneDeath02); - - instance.SetData(karazhanConst.BossOpera, (uint)EncounterState.Done); - instance.HandleGameObject(instance.GetGuidData(DataTypes.GoStagedoorleft), true); - instance.HandleGameObject(instance.GetGuidData(DataTypes.GoStagedoorright), true); - - GameObject pSideEntrance = instance.instance.GetGameObject(instance.GetGuidData(DataTypes.GoSideEntranceDoor)); - if (pSideEntrance) - pSideEntrance.RemoveFlag(GameObjectFields.Flags, GameObjectFlags.Locked); - } - - public override void KilledUnit(Unit victim) - { - Talk(JulianneRomulo.SayJulianneSlay); - } - - public override void UpdateAI(uint diff) - { - if (EntryYellTimer != 0) - { - if (EntryYellTimer <= diff) - { - Talk(JulianneRomulo.SayJulianneEnter); - EntryYellTimer = 0; - } - else EntryYellTimer -= diff; - } - - if (AggroYellTimer != 0) - { - if (AggroYellTimer <= diff) - { - Talk(JulianneRomulo.SayJulianneAggro); - me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); - me.SetFaction(16); - AggroYellTimer = 0; - } - else AggroYellTimer -= diff; - } - - if (DrinkPoisonTimer != 0) - { - //will do this 2secs after spell hit. this is time to display visual as expected - if (DrinkPoisonTimer <= diff) - { - PretendToDie(); - Phase = RAJPhase.Romulo; - SummonRomuloTimer = 10000; - DrinkPoisonTimer = 0; - } - else DrinkPoisonTimer -= diff; - } - - if (Phase == RAJPhase.Romulo && !SummonedRomulo) - { - if (SummonRomuloTimer <= diff) - { - Creature pRomulo = me.SummonCreature(JulianneRomulo.NpcRomulo, JulianneRomulo.RomuloX, JulianneRomulo.RomuloY, me.GetPositionZ(), 0, TempSummonType.TimedOrDeadDespawn, Time.Hour * 2 * Time.InMilliseconds); - if (pRomulo) - { - RomuloGUID = pRomulo.GetGUID(); - ((julianne_romulobase)pRomulo.GetAI()).JulianneGUID = me.GetGUID(); - ((julianne_romulobase)pRomulo.GetAI()).Phase = RAJPhase.Romulo; - DoZoneInCombat(pRomulo); - - pRomulo.SetFaction(16); - } - SummonedRomulo = true; - } - else SummonRomuloTimer -= diff; - } - - if (ResurrectSelfTimer != 0) - { - if (ResurrectSelfTimer <= diff) - { - Resurrect(me); - Phase = RAJPhase.Both; - IsFakingDeath = false; - - if (me.GetVictim()) - AttackStart(me.GetVictim()); - - ResurrectSelfTimer = 0; - ResurrectTimer = 1000; - } - else ResurrectSelfTimer -= diff; - } - - if (!UpdateVictim() || IsFakingDeath) return; - - if (RomuloDead) - { - if (ResurrectTimer <= diff) - { - Creature Romulo = ObjectAccessor.GetCreature(me, RomuloGUID); - if (Romulo && ((julianne_romulobase)Romulo.GetAI()).IsFakingDeath) - { - Talk(JulianneRomulo.SayJulianneResurrect); - Resurrect(Romulo); - ((julianne_romulobase)Romulo.GetAI()).IsFakingDeath = false; - RomuloDead = false; - ResurrectTimer = 10000; - } - } - else ResurrectTimer -= diff; } - if (BlindingPassionTimer <= diff) + //if not already returned, then romulo is alive and we can pretend die + Romulo = ObjectAccessor.GetCreature(me, RomuloGUID); + if (Romulo) { - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100, true); - if (target) - DoCast(target, JulianneRomulo.SpellBlindingPassion); - BlindingPassionTimer = RandomHelper.URand(30000, 45000); - } - else BlindingPassionTimer -= diff; - - if (DevotionTimer <= diff) - { - DoCast(me, JulianneRomulo.SpellDevotion); - DevotionTimer = RandomHelper.URand(15000, 45000); - } - else DevotionTimer -= diff; - - if (PowerfulAttractionTimer <= diff) - { - DoCast(SelectTarget(SelectAggroTarget.Random, 0), JulianneRomulo.SpellPowerfulAttraction); - PowerfulAttractionTimer = RandomHelper.URand(5000, 30000); - } - else PowerfulAttractionTimer -= diff; - - if (EternalAffectionTimer <= diff) - { - if (RandomHelper.URand(0, 1) != 0 && SummonedRomulo) - { - Creature Romulo = ObjectAccessor.GetCreature(me, RomuloGUID); - if (Romulo && Romulo.IsAlive() && !RomuloDead) - DoCast(Romulo, JulianneRomulo.SpellEternalAffection); - } - else DoCast(me, JulianneRomulo.SpellEternalAffection); - - EternalAffectionTimer = RandomHelper.URand(45000, 60000); - } - else EternalAffectionTimer -= diff; - - DoMeleeAttackIfReady(); - } - - uint BlindingPassionTimer; - uint DevotionTimer; - uint EternalAffectionTimer; - uint PowerfulAttractionTimer; - uint SummonRomuloTimer; - uint DrinkPoisonTimer; - - bool SummonedRomulo; - } - - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } - } - - [Script] - class boss_romulo : CreatureScript - { - public boss_romulo() : base("boss_romulo") { } - - public class boss_romuloAI : julianne_romulobase - { - public boss_romuloAI(Creature creature) : base(creature) - { - instance = creature.GetInstanceScript(); - EntryYellTimer = 8000; - AggroYellTimer = 15000; - } - - public override void Reset() - { - JulianneGUID.Clear(); - Phase = RAJPhase.Romulo; - - BackwardLungeTimer = 15000; - DaringTimer = 20000; - DeadlySwatheTimer = 25000; - PoisonThrustTimer = 10000; - ResurrectTimer = 10000; - - IsFakingDeath = false; - JulianneDead = false; - } - - public override void DamageTaken(Unit attacker, ref uint damage) - { - if (damage < me.GetHealth()) - return; - - //anything below only used if incoming damage will kill - - if (Phase == RAJPhase.Romulo) - { - Talk(JulianneRomulo.SayRomuloDeath); PretendToDie(); IsFakingDeath = true; - Phase = RAJPhase.Both; - - Creature Julianne = ObjectAccessor.GetCreature(me, JulianneGUID); - if (Julianne) - { - ((julianne_romulobase)Julianne.GetAI()).RomuloDead = true; - ((julianne_romulobase)Julianne.GetAI()).ResurrectSelfTimer = 10000; - } - + ((julianne_romuloAI)Romulo.GetAI()).ResurrectTimer = 10000; + ((julianne_romuloAI)Romulo.GetAI()).JulianneDead = true; damage = 0; return; } + } + Log.outError(LogFilter.Scripts, "boss_julianneAI: DamageTaken reach end of code, that should not happen."); + } - if (Phase == RAJPhase.Both) + public override void JustDied(Unit killer) + { + Talk(JulianneRomulo.SayJulianneDeath02); + + instance.SetData(karazhanConst.BossOpera, (uint)EncounterState.Done); + instance.HandleGameObject(instance.GetGuidData(DataTypes.GoStagedoorleft), true); + instance.HandleGameObject(instance.GetGuidData(DataTypes.GoStagedoorright), true); + + GameObject pSideEntrance = instance.instance.GetGameObject(instance.GetGuidData(DataTypes.GoSideEntranceDoor)); + if (pSideEntrance) + pSideEntrance.RemoveFlag(GameObjectFields.Flags, GameObjectFlags.Locked); + } + + public override void KilledUnit(Unit victim) + { + Talk(JulianneRomulo.SayJulianneSlay); + } + + public override void UpdateAI(uint diff) + { + if (EntryYellTimer != 0) + { + if (EntryYellTimer <= diff) { - Creature Julianne; - if (JulianneDead) - { - Julianne = ObjectAccessor.GetCreature(me, JulianneGUID); - if (Julianne) - { - Julianne.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable); - Julianne.GetMotionMaster().Clear(); - Julianne.setDeathState(DeathState.JustDied); - Julianne.CombatStop(true); - Julianne.DeleteThreatList(); - Julianne.SetUInt32Value(ObjectFields.DynamicFlags, (uint)UnitDynFlags.Lootable); - } - return; - } + Talk(JulianneRomulo.SayJulianneEnter); + EntryYellTimer = 0; + } + else EntryYellTimer -= diff; + } + if (AggroYellTimer != 0) + { + if (AggroYellTimer <= diff) + { + Talk(JulianneRomulo.SayJulianneAggro); + me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); + me.SetFaction(16); + AggroYellTimer = 0; + } + else AggroYellTimer -= diff; + } + + if (DrinkPoisonTimer != 0) + { + //will do this 2secs after spell hit. this is time to display visual as expected + if (DrinkPoisonTimer <= diff) + { + PretendToDie(); + Phase = RAJPhase.Romulo; + SummonRomuloTimer = 10000; + DrinkPoisonTimer = 0; + } + else DrinkPoisonTimer -= diff; + } + + if (Phase == RAJPhase.Romulo && !SummonedRomulo) + { + if (SummonRomuloTimer <= diff) + { + Creature pRomulo = me.SummonCreature(JulianneRomulo.NpcRomulo, JulianneRomulo.RomuloX, JulianneRomulo.RomuloY, me.GetPositionZ(), 0, TempSummonType.TimedOrDeadDespawn, Time.Hour * 2 * Time.InMilliseconds); + if (pRomulo) + { + RomuloGUID = pRomulo.GetGUID(); + ((julianne_romuloAI)pRomulo.GetAI()).JulianneGUID = me.GetGUID(); + ((julianne_romuloAI)pRomulo.GetAI()).Phase = RAJPhase.Romulo; + DoZoneInCombat(pRomulo); + + pRomulo.SetFaction(16); + } + SummonedRomulo = true; + } + else SummonRomuloTimer -= diff; + } + + if (ResurrectSelfTimer != 0) + { + if (ResurrectSelfTimer <= diff) + { + Resurrect(me); + Phase = RAJPhase.Both; + IsFakingDeath = false; + + if (me.GetVictim()) + AttackStart(me.GetVictim()); + + ResurrectSelfTimer = 0; + ResurrectTimer = 1000; + } + else ResurrectSelfTimer -= diff; + } + + if (!UpdateVictim() || IsFakingDeath) + return; + + if (RomuloDead) + { + if (ResurrectTimer <= diff) + { + Creature Romulo = ObjectAccessor.GetCreature(me, RomuloGUID); + if (Romulo && ((julianne_romuloAI)Romulo.GetAI()).IsFakingDeath) + { + Talk(JulianneRomulo.SayJulianneResurrect); + Resurrect(Romulo); + ((julianne_romuloAI)Romulo.GetAI()).IsFakingDeath = false; + RomuloDead = false; + ResurrectTimer = 10000; + } + } + else ResurrectTimer -= diff; + } + + if (BlindingPassionTimer <= diff) + { + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100, true); + if (target) + DoCast(target, JulianneRomulo.SpellBlindingPassion); + BlindingPassionTimer = RandomHelper.URand(30000, 45000); + } + else BlindingPassionTimer -= diff; + + if (DevotionTimer <= diff) + { + DoCast(me, JulianneRomulo.SpellDevotion); + DevotionTimer = RandomHelper.URand(15000, 45000); + } + else DevotionTimer -= diff; + + if (PowerfulAttractionTimer <= diff) + { + DoCast(SelectTarget(SelectAggroTarget.Random, 0), JulianneRomulo.SpellPowerfulAttraction); + PowerfulAttractionTimer = RandomHelper.URand(5000, 30000); + } + else PowerfulAttractionTimer -= diff; + + if (EternalAffectionTimer <= diff) + { + if (RandomHelper.URand(0, 1) != 0 && SummonedRomulo) + { + Creature Romulo = ObjectAccessor.GetCreature(me, RomuloGUID); + if (Romulo && Romulo.IsAlive() && !RomuloDead) + DoCast(Romulo, JulianneRomulo.SpellEternalAffection); + } + else DoCast(me, JulianneRomulo.SpellEternalAffection); + + EternalAffectionTimer = RandomHelper.URand(45000, 60000); + } + else EternalAffectionTimer -= diff; + + DoMeleeAttackIfReady(); + } + + uint BlindingPassionTimer; + uint DevotionTimer; + uint EternalAffectionTimer; + uint PowerfulAttractionTimer; + uint SummonRomuloTimer; + uint DrinkPoisonTimer; + + bool SummonedRomulo; + } + + [Script] + public class boss_romulo : julianne_romuloAI + { + public boss_romulo(Creature creature) : base(creature) + { + instance = creature.GetInstanceScript(); + EntryYellTimer = 8000; + AggroYellTimer = 15000; + } + + public override void Reset() + { + JulianneGUID.Clear(); + Phase = RAJPhase.Romulo; + + BackwardLungeTimer = 15000; + DaringTimer = 20000; + DeadlySwatheTimer = 25000; + PoisonThrustTimer = 10000; + ResurrectTimer = 10000; + + IsFakingDeath = false; + JulianneDead = false; + } + + public override void DamageTaken(Unit attacker, ref uint damage) + { + if (damage < me.GetHealth()) + return; + + //anything below only used if incoming damage will kill + + if (Phase == RAJPhase.Romulo) + { + Talk(JulianneRomulo.SayRomuloDeath); + PretendToDie(); + IsFakingDeath = true; + Phase = RAJPhase.Both; + + Creature Julianne = ObjectAccessor.GetCreature(me, JulianneGUID); + if (Julianne) + { + ((julianne_romuloAI)Julianne.GetAI()).RomuloDead = true; + ((julianne_romuloAI)Julianne.GetAI()).ResurrectSelfTimer = 10000; + } + + damage = 0; + return; + } + + if (Phase == RAJPhase.Both) + { + Creature Julianne; + if (JulianneDead) + { Julianne = ObjectAccessor.GetCreature(me, JulianneGUID); if (Julianne) { - PretendToDie(); - IsFakingDeath = true; - ((julianne_romulobase)Julianne.GetAI()).ResurrectTimer = 10000; - ((julianne_romulobase)Julianne.GetAI()).RomuloDead = true; - damage = 0; - return; + Julianne.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable); + Julianne.GetMotionMaster().Clear(); + Julianne.setDeathState(DeathState.JustDied); + Julianne.CombatStop(true); + Julianne.DeleteThreatList(); + Julianne.SetUInt32Value(ObjectFields.DynamicFlags, (uint)UnitDynFlags.Lootable); } + return; } - Log.outError(LogFilter.Scripts, "boss_romuloAI: DamageTaken reach end of code, that should not happen."); + Julianne = ObjectAccessor.GetCreature(me, JulianneGUID); + if (Julianne) + { + PretendToDie(); + IsFakingDeath = true; + ((julianne_romuloAI)Julianne.GetAI()).ResurrectTimer = 10000; + ((julianne_romuloAI)Julianne.GetAI()).RomuloDead = true; + damage = 0; + return; + } } - public override void EnterCombat(Unit who) + Log.outError(LogFilter.Scripts, "boss_romuloAI: DamageTaken reach end of code, that should not happen."); + } + + public override void EnterCombat(Unit who) + { + Talk(JulianneRomulo.SayRomuloAggro); + if (!JulianneGUID.IsEmpty()) { - Talk(JulianneRomulo.SayRomuloAggro); - if (!JulianneGUID.IsEmpty()) + Creature Julianne = (ObjectAccessor.GetCreature(me, JulianneGUID)); + if (Julianne && Julianne.GetVictim()) + { + me.AddThreat(Julianne.GetVictim(), 1.0f); + AttackStart(Julianne.GetVictim()); + } + } + } + + public override void JustDied(Unit killer) + { + Talk(JulianneRomulo.SayRomuloDeath); + + instance.SetData(karazhanConst.BossOpera, (uint)EncounterState.Done); + instance.HandleGameObject(instance.GetGuidData(DataTypes.GoStagedoorleft), true); + instance.HandleGameObject(instance.GetGuidData(DataTypes.GoStagedoorright), true); + + GameObject pSideEntrance = instance.instance.GetGameObject(instance.GetGuidData(DataTypes.GoSideEntranceDoor)); + if (pSideEntrance) + pSideEntrance.RemoveFlag(GameObjectFields.Flags, GameObjectFlags.Locked); + } + + public override void KilledUnit(Unit victim) + { + Talk(JulianneRomulo.SayRomuloSlay); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim() || IsFakingDeath) + return; + + if (JulianneDead) + { + if (ResurrectTimer <= diff) { Creature Julianne = (ObjectAccessor.GetCreature(me, JulianneGUID)); - if (Julianne && Julianne.GetVictim()) + if (Julianne && ((julianne_romuloAI)Julianne.GetAI()).IsFakingDeath) { - me.AddThreat(Julianne.GetVictim(), 1.0f); - AttackStart(Julianne.GetVictim()); + Talk(JulianneRomulo.SayRomuloResurrect); + Resurrect(Julianne); + ((julianne_romuloAI)Julianne.GetAI()).IsFakingDeath = false; + JulianneDead = false; + ResurrectTimer = 10000; } } + else ResurrectTimer -= diff; } - public override void JustDied(Unit killer) + if (BackwardLungeTimer <= diff) { - Talk(JulianneRomulo.SayRomuloDeath); - - instance.SetData(karazhanConst.BossOpera, (uint)EncounterState.Done); - instance.HandleGameObject(instance.GetGuidData(DataTypes.GoStagedoorleft), true); - instance.HandleGameObject(instance.GetGuidData(DataTypes.GoStagedoorright), true); - - GameObject pSideEntrance = instance.instance.GetGameObject(instance.GetGuidData(DataTypes.GoSideEntranceDoor)); - if (pSideEntrance) - pSideEntrance.RemoveFlag(GameObjectFields.Flags, GameObjectFlags.Locked); + Unit target = SelectTarget(SelectAggroTarget.Random, 1, 100, true); + if (target && !me.HasInArc(MathFunctions.PI, target)) + { + DoCast(target, JulianneRomulo.SpellBackwardLunge); + BackwardLungeTimer = RandomHelper.URand(15000, 30000); + } } + else BackwardLungeTimer -= diff; - public override void KilledUnit(Unit victim) + if (DaringTimer <= diff) { - Talk(JulianneRomulo.SayRomuloSlay); + DoCast(me, JulianneRomulo.SpellDaring); + DaringTimer = RandomHelper.URand(20000, 40000); } + else DaringTimer -= diff; - public override void UpdateAI(uint diff) + if (DeadlySwatheTimer <= diff) { - if (!UpdateVictim() || IsFakingDeath) - return; - - if (JulianneDead) - { - if (ResurrectTimer <= diff) - { - Creature Julianne = (ObjectAccessor.GetCreature(me, JulianneGUID)); - if (Julianne && ((julianne_romulobase)Julianne.GetAI()).IsFakingDeath) - { - Talk(JulianneRomulo.SayRomuloResurrect); - Resurrect(Julianne); - ((julianne_romulobase)Julianne.GetAI()).IsFakingDeath = false; - JulianneDead = false; - ResurrectTimer = 10000; - } - } - else ResurrectTimer -= diff; - } - - if (BackwardLungeTimer <= diff) - { - Unit target = SelectTarget(SelectAggroTarget.Random, 1, 100, true); - if (target && !me.HasInArc(MathFunctions.PI, target)) - { - DoCast(target, JulianneRomulo.SpellBackwardLunge); - BackwardLungeTimer = RandomHelper.URand(15000, 30000); - } - } - else BackwardLungeTimer -= diff; - - if (DaringTimer <= diff) - { - DoCast(me, JulianneRomulo.SpellDaring); - DaringTimer = RandomHelper.URand(20000, 40000); - } - else DaringTimer -= diff; - - if (DeadlySwatheTimer <= diff) - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100, true); - if (target) - DoCast(target, JulianneRomulo.SpellDeadlySwathe); - DeadlySwatheTimer = RandomHelper.URand(15000, 25000); - } - else DeadlySwatheTimer -= diff; - - if (PoisonThrustTimer <= diff) - { - DoCastVictim(JulianneRomulo.SpellPoisonThrust); - PoisonThrustTimer = RandomHelper.URand(10000, 20000); - } - else PoisonThrustTimer -= diff; - - DoMeleeAttackIfReady(); + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100, true); + if (target) + DoCast(target, JulianneRomulo.SpellDeadlySwathe); + DeadlySwatheTimer = RandomHelper.URand(15000, 25000); } + else DeadlySwatheTimer -= diff; - uint BackwardLungeTimer; - uint DaringTimer; - uint DeadlySwatheTimer; - uint PoisonThrustTimer; + if (PoisonThrustTimer <= diff) + { + DoCastVictim(JulianneRomulo.SpellPoisonThrust); + PoisonThrustTimer = RandomHelper.URand(10000, 20000); + } + else PoisonThrustTimer -= diff; + + DoMeleeAttackIfReady(); } - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } + uint BackwardLungeTimer; + uint DaringTimer; + uint DeadlySwatheTimer; + uint PoisonThrustTimer; } + #endregion [Script] @@ -1789,7 +1684,7 @@ namespace Scripts.EasternKingdoms.Karazhan.OperaEvent public override CreatureAI GetAI(Creature creature) { - return GetInstanceAI(creature); + return instance_karazhan.GetKarazhanAI(creature); } } } diff --git a/Scripts/EasternKingdoms/ScarletEnclave/Chapter1.cs b/Scripts/EasternKingdoms/ScarletEnclave/Chapter1.cs index b29ad70b2..90a8abfa1 100644 --- a/Scripts/EasternKingdoms/ScarletEnclave/Chapter1.cs +++ b/Scripts/EasternKingdoms/ScarletEnclave/Chapter1.cs @@ -33,240 +33,220 @@ namespace Scripts.EasternKingdoms } [Script] - class npc_unworthy_initiate : CreatureScript + public class npc_unworthy_initiate : ScriptedAI { - public npc_unworthy_initiate() : base("npc_unworthy_initiate") { } - - public class npc_unworthy_initiateAI : ScriptedAI + public npc_unworthy_initiate(Creature creature) : base(creature) { - public npc_unworthy_initiateAI(Creature creature) : base(creature) - { - me.SetReactState(ReactStates.Passive); - if (me.GetCurrentEquipmentId() == 0) - me.SetCurrentEquipmentId((byte)me.GetOriginalEquipmentId()); - } + me.SetReactState(ReactStates.Passive); + if (me.GetCurrentEquipmentId() == 0) + me.SetCurrentEquipmentId((byte)me.GetOriginalEquipmentId()); + } - public override void Reset() - { - anchorGUID.Clear(); - phase = UnworthyInitiatePhase.Chained; - _events.Reset(); - me.SetFaction(7); - me.SetFlag(UnitFields.Flags, UnitFlags.ImmuneToPc); - me.SetStandState(UnitStandStateType.Kneel); - me.LoadEquipment(0, true); - } + public override void Reset() + { + anchorGUID.Clear(); + phase = UnworthyInitiatePhase.Chained; + _events.Reset(); + me.SetFaction(7); + me.SetFlag(UnitFields.Flags, UnitFlags.ImmuneToPc); + me.SetStandState(UnitStandStateType.Kneel); + me.LoadEquipment(0, true); + } - public override void EnterCombat(Unit who) - { - _events.ScheduleEvent(EventIcyTouch, 1000, 1); - _events.ScheduleEvent(EventPlagueStrike, 3000, 1); - _events.ScheduleEvent(EventBloodStrike, 2000, 1); - _events.ScheduleEvent(EventDeathCoil, 5000, 1); - } + public override void EnterCombat(Unit who) + { + _events.ScheduleEvent(EventIcyTouch, 1000, 1); + _events.ScheduleEvent(EventPlagueStrike, 3000, 1); + _events.ScheduleEvent(EventBloodStrike, 2000, 1); + _events.ScheduleEvent(EventDeathCoil, 5000, 1); + } - public override void MovementInform(MovementGeneratorType type, uint id) - { - if (type != MovementGeneratorType.Point) - return; + public override void MovementInform(MovementGeneratorType type, uint id) + { + if (type != MovementGeneratorType.Point) + return; - if (id == 1) - { - wait_timer = 5000; - me.CastSpell(me, SpellDKInitateVisual, true); - - Player starter = Global.ObjAccessor.GetPlayer(me, playerGUID); - if (starter) - Global.CreatureTextMgr.SendChat(me, (byte)SayEventAttack, null, ChatMsg.Addon, Language.Addon, CreatureTextRange.Normal, 0, Team.Other, false, starter); - - phase = UnworthyInitiatePhase.ToAttack; - } - } - - public void EventStart(Creature anchor, Player target) + if (id == 1) { wait_timer = 5000; - phase = UnworthyInitiatePhase.ToEquip; + me.CastSpell(me, SpellDKInitateVisual, true); - me.SetStandState(UnitStandStateType.Stand); - me.RemoveAurasDueToSpell(SpellSoulPrisonChainSelf); - me.RemoveAurasDueToSpell(SpellSoulPrisonChain); + Player starter = Global.ObjAccessor.GetPlayer(me, playerGUID); + if (starter) + Global.CreatureTextMgr.SendChat(me, (byte)SayEventAttack, null, ChatMsg.Addon, Language.Addon, CreatureTextRange.Normal, 0, Team.Other, false, starter); - float z; - anchor.GetContactPoint(me, out anchorX, out anchorY, out z, 1.0f); - - playerGUID = target.GetGUID(); - Talk(SayEventStart); + phase = UnworthyInitiatePhase.ToAttack; } + } - public override void UpdateAI(uint diff) + public void EventStart(Creature anchor, Player target) + { + wait_timer = 5000; + phase = UnworthyInitiatePhase.ToEquip; + + me.SetStandState(UnitStandStateType.Stand); + me.RemoveAurasDueToSpell(SpellSoulPrisonChainSelf); + me.RemoveAurasDueToSpell(SpellSoulPrisonChain); + + float z; + anchor.GetContactPoint(me, out anchorX, out anchorY, out z, 1.0f); + + playerGUID = target.GetGUID(); + Talk(SayEventStart); + } + + public override void UpdateAI(uint diff) + { + switch (phase) { - switch (phase) - { - case UnworthyInitiatePhase.Chained: - if (anchorGUID.IsEmpty()) + case UnworthyInitiatePhase.Chained: + if (anchorGUID.IsEmpty()) + { + Creature anchor = me.FindNearestCreature(29521, 30); + if (anchor) { - Creature anchor = me.FindNearestCreature(29521, 30); - if (anchor) - { - anchor.GetAI().SetGUID(me.GetGUID()); - anchor.CastSpell(me, SpellSoulPrisonChain, true); - anchorGUID = anchor.GetGUID(); - } - else - Log.outError(LogFilter.Scripts, "npc_unworthy_initiateAI: unable to find anchor!"); + anchor.GetAI().SetGUID(me.GetGUID()); + anchor.CastSpell(me, SpellSoulPrisonChain, true); + anchorGUID = anchor.GetGUID(); + } + else + Log.outError(LogFilter.Scripts, "npc_unworthy_initiateAI: unable to find anchor!"); - float dist = 99.0f; - GameObject prison = null; + float dist = 99.0f; + GameObject prison = null; - for (byte i = 0; i < 12; ++i) + for (byte i = 0; i < 12; ++i) + { + GameObject temp_prison = me.FindNearestGameObject(acherus_soul_prison[i], 30); + if (temp_prison) { - GameObject temp_prison = me.FindNearestGameObject(acherus_soul_prison[i], 30); - if (temp_prison) + if (me.IsWithinDist(temp_prison, dist, false)) { - if (me.IsWithinDist(temp_prison, dist, false)) - { - dist = me.GetDistance2d(temp_prison); - prison = temp_prison; - } + dist = me.GetDistance2d(temp_prison); + prison = temp_prison; } } - - if (prison) - prison.ResetDoorOrButton(); - else - Log.outError(LogFilter.Scripts, "npc_unworthy_initiateAI: unable to find prison!"); } - break; - case UnworthyInitiatePhase.ToEquip: - if (wait_timer != 0) + + if (prison) + prison.ResetDoorOrButton(); + else + Log.outError(LogFilter.Scripts, "npc_unworthy_initiateAI: unable to find prison!"); + } + break; + case UnworthyInitiatePhase.ToEquip: + if (wait_timer != 0) + { + if (wait_timer > diff) + wait_timer -= diff; + else { - if (wait_timer > diff) - wait_timer -= diff; - else - { - me.GetMotionMaster().MovePoint(1, anchorX, anchorY, me.GetPositionZ()); - phase = UnworthyInitiatePhase.Equiping; - wait_timer = 0; - } + me.GetMotionMaster().MovePoint(1, anchorX, anchorY, me.GetPositionZ()); + phase = UnworthyInitiatePhase.Equiping; + wait_timer = 0; } - break; - case UnworthyInitiatePhase.ToAttack: - if (wait_timer != 0) + } + break; + case UnworthyInitiatePhase.ToAttack: + if (wait_timer != 0) + { + if (wait_timer > diff) + wait_timer -= diff; + else { - if (wait_timer > diff) - wait_timer -= diff; - else - { - me.SetFaction(14); - me.RemoveFlag(UnitFields.Flags, UnitFlags.ImmuneToPc); - phase = UnworthyInitiatePhase.Attacking; + me.SetFaction(14); + me.RemoveFlag(UnitFields.Flags, UnitFlags.ImmuneToPc); + phase = UnworthyInitiatePhase.Attacking; - Player target = Global.ObjAccessor.GetPlayer(me, playerGUID); - if (target) - AttackStart(target); - wait_timer = 0; - } + Player target = Global.ObjAccessor.GetPlayer(me, playerGUID); + if (target) + AttackStart(target); + wait_timer = 0; } - break; - case UnworthyInitiatePhase.Attacking: - if (!UpdateVictim()) - return; + } + break; + case UnworthyInitiatePhase.Attacking: + if (!UpdateVictim()) + return; - _events.Update(diff); - _events.ExecuteEvents(eventId => + _events.Update(diff); + _events.ExecuteEvents(eventId => + { + switch (eventId) { - switch (eventId) - { - case EventIcyTouch: - DoCastVictim(SpellIcyTouch); - _events.DelayEvents(1000, 1); - _events.ScheduleEvent(EventIcyTouch, 5000, 1); - break; - case EventPlagueStrike: - DoCastVictim(SpellPlagueStrike); - _events.DelayEvents(1000, 1); - _events.ScheduleEvent(EventPlagueStrike, 5000, 1); - break; - case EventBloodStrike: - DoCastVictim(SpellBloodStrike); - _events.DelayEvents(1000, 1); - _events.ScheduleEvent(EventBloodStrike, 5000, 1); - break; - case EventDeathCoil: - DoCastVictim(SpellDeathCoil); - _events.DelayEvents(1000, 1); - _events.ScheduleEvent(EventDeathCoil, 5000, 1); - break; - } - }); + case EventIcyTouch: + DoCastVictim(SpellIcyTouch); + _events.DelayEvents(1000, 1); + _events.ScheduleEvent(EventIcyTouch, 5000, 1); + break; + case EventPlagueStrike: + DoCastVictim(SpellPlagueStrike); + _events.DelayEvents(1000, 1); + _events.ScheduleEvent(EventPlagueStrike, 5000, 1); + break; + case EventBloodStrike: + DoCastVictim(SpellBloodStrike); + _events.DelayEvents(1000, 1); + _events.ScheduleEvent(EventBloodStrike, 5000, 1); + break; + case EventDeathCoil: + DoCastVictim(SpellDeathCoil); + _events.DelayEvents(1000, 1); + _events.ScheduleEvent(EventDeathCoil, 5000, 1); + break; + } + }); - DoMeleeAttackIfReady(); - break; - default: - break; - } + DoMeleeAttackIfReady(); + break; + default: + break; } - - ObjectGuid playerGUID; - UnworthyInitiatePhase phase; - uint wait_timer; - float anchorX, anchorY; - ObjectGuid anchorGUID; } - public const uint SpellSoulPrisonChainSelf = 54612; - public const uint SpellSoulPrisonChain = 54613; - public const uint SpellDKInitateVisual = 51519; + ObjectGuid playerGUID; + UnworthyInitiatePhase phase; + uint wait_timer; + float anchorX, anchorY; + ObjectGuid anchorGUID; - public const uint SpellIcyTouch = 52372; - public const uint SpellPlagueStrike = 52373; - public const uint SpellBloodStrike = 52374; - public const uint SpellDeathCoil = 52375; + const uint SpellSoulPrisonChainSelf = 54612; + const uint SpellSoulPrisonChain = 54613; + const uint SpellDKInitateVisual = 51519; - public const uint SayEventStart = 0; - public const uint SayEventAttack = 1; + const uint SpellIcyTouch = 52372; + const uint SpellPlagueStrike = 52373; + const uint SpellBloodStrike = 52374; + const uint SpellDeathCoil = 52375; - public const uint EventIcyTouch = 1; - public const uint EventPlagueStrike = 2; - public const uint EventBloodStrike = 3; - public const uint EventDeathCoil = 4; + const uint SayEventStart = 0; + const uint SayEventAttack = 1; - public static uint[] acherus_soul_prison = { 191577, 191580, 191581, 191582, 191583, 191584, 191585, 191586, 191587, 191588, 191589, 191590 }; + const uint EventIcyTouch = 1; + const uint EventPlagueStrike = 2; + const uint EventBloodStrike = 3; + const uint EventDeathCoil = 4; - public override CreatureAI GetAI(Creature creature) - { - return new npc_unworthy_initiateAI(creature); - } + static uint[] acherus_soul_prison = { 191577, 191580, 191581, 191582, 191583, 191584, 191585, 191586, 191587, 191588, 191589, 191590 }; } [Script] - class npc_unworthy_initiate_anchor : CreatureScript + class npc_unworthy_initiate_anchor : PassiveAI { - public npc_unworthy_initiate_anchor() : base("npc_unworthy_initiate_anchor") { } + public npc_unworthy_initiate_anchor(Creature creature) : base(creature) { } - class npc_unworthy_initiate_anchorAI : PassiveAI + public override void SetGUID(ObjectGuid guid, int id) { - public npc_unworthy_initiate_anchorAI(Creature creature) : base(creature) { } - - public override void SetGUID(ObjectGuid guid, int id) - { - if (prisonerGUID.IsEmpty()) - prisonerGUID = guid; - } - - public override ObjectGuid GetGUID(int id) - { - return prisonerGUID; - } - - ObjectGuid prisonerGUID; + if (prisonerGUID.IsEmpty()) + prisonerGUID = guid; } - public override CreatureAI GetAI(Creature creature) + public override ObjectGuid GetGUID(int id) { - return new npc_unworthy_initiate_anchorAI(creature); + return prisonerGUID; } + + ObjectGuid prisonerGUID; } [Script] @@ -284,13 +264,12 @@ namespace Scripts.EasternKingdoms { Creature prisoner = ObjectAccessor.GetCreature(player, prisonerGUID); if (prisoner) - ((npc_unworthy_initiate.npc_unworthy_initiateAI)prisoner.GetAI()).EventStart(anchor, player); + ((npc_unworthy_initiate)prisoner.GetAI()).EventStart(anchor, player); } } return false; } - } struct EyeOfAcherus @@ -311,74 +290,64 @@ namespace Scripts.EasternKingdoms } [Script] - class npc_eye_of_acherus : CreatureScript + class npc_eye_of_acherus : ScriptedAI { - public npc_eye_of_acherus() : base("npc_eye_of_acherus") { } - - class npc_eye_of_acherusAI : ScriptedAI + public npc_eye_of_acherus(Creature creature) : base(creature) { - public npc_eye_of_acherusAI(Creature creature) : base(creature) - { - Reset(); - } - - uint startTimer; - - public override void Reset() - { - startTimer = 2000; - } - - public override void AttackStart(Unit u) { } - - public override void MoveInLineOfSight(Unit u) { } - - public override void JustDied(Unit killer) - { - Unit charmer = me.GetCharmer(); - if (charmer) - charmer.RemoveAurasDueToSpell(EyeOfAcherus.SpellEyeControl); - } - - public override void UpdateAI(uint diff) - { - if (me.IsCharmed()) - { - if (startTimer <= diff) // fly to start point - { - me.CastSpell(me, EyeOfAcherus.SpellEyePhasemask, true); - me.CastSpell(me, EyeOfAcherus.SpellEyeVisual, true); - me.CastSpell(me, EyeOfAcherus.SpellEyeFlightBoost, true); - me.SetSpeedRate(UnitMoveType.Flight, 4f); - - me.GetMotionMaster().MovePoint(0, EyeOfAcherus.EyeDestination[0], EyeOfAcherus.EyeDestination[1], EyeOfAcherus.EyeDestination[2]); - return; - } - else - startTimer -= diff; - } - else - me.ForcedDespawn(); - } - - public override void MovementInform(MovementGeneratorType type, uint id) - { - if (type != MovementGeneratorType.Point || id != 0) - return; - - me.SetDisplayId(EyeOfAcherus.EyeSmallDisplayId); - - me.CastSpell(me, EyeOfAcherus.SpellEyeFlight, true); - me.Say(EyeOfAcherus.SayEyeUnderControl, Language.Universal); - - if (me.GetCharmer() && me.GetCharmer().IsTypeId(TypeId.Player)) - me.GetCharmer().ToPlayer().SetClientControl(me, true); - } + Reset(); } - public override CreatureAI GetAI(Creature creature) + uint startTimer; + + public override void Reset() { - return new npc_eye_of_acherusAI(creature); + startTimer = 2000; + } + + public override void AttackStart(Unit u) { } + + public override void MoveInLineOfSight(Unit u) { } + + public override void JustDied(Unit killer) + { + Unit charmer = me.GetCharmer(); + if (charmer) + charmer.RemoveAurasDueToSpell(EyeOfAcherus.SpellEyeControl); + } + + public override void UpdateAI(uint diff) + { + if (me.IsCharmed()) + { + if (startTimer <= diff) // fly to start point + { + me.CastSpell(me, EyeOfAcherus.SpellEyePhasemask, true); + me.CastSpell(me, EyeOfAcherus.SpellEyeVisual, true); + me.CastSpell(me, EyeOfAcherus.SpellEyeFlightBoost, true); + me.SetSpeedRate(UnitMoveType.Flight, 4f); + + me.GetMotionMaster().MovePoint(0, EyeOfAcherus.EyeDestination[0], EyeOfAcherus.EyeDestination[1], EyeOfAcherus.EyeDestination[2]); + return; + } + else + startTimer -= diff; + } + else + me.ForcedDespawn(); + } + + public override void MovementInform(MovementGeneratorType type, uint id) + { + if (type != MovementGeneratorType.Point || id != 0) + return; + + me.SetDisplayId(EyeOfAcherus.EyeSmallDisplayId); + + me.CastSpell(me, EyeOfAcherus.SpellEyeFlight, true); + me.Say(EyeOfAcherus.SayEyeUnderControl, Language.Universal); + + if (me.GetCharmer() && me.GetCharmer().IsTypeId(TypeId.Player)) + me.GetCharmer().ToPlayer().SetClientControl(me, true); } } } diff --git a/Scripts/EasternKingdoms/TheStockade/BossHogger.cs b/Scripts/EasternKingdoms/TheStockade/BossHogger.cs index 7438cb267..1603738b8 100644 --- a/Scripts/EasternKingdoms/TheStockade/BossHogger.cs +++ b/Scripts/EasternKingdoms/TheStockade/BossHogger.cs @@ -36,122 +36,102 @@ namespace Scripts.EasternKingdoms.TheStockade } [Script] - class boss_hogger : CreatureScript + class boss_hogger : BossAI { - public boss_hogger() : base("boss_hogger") { } + public boss_hogger(Creature creature) : base(creature, DataTypes.Hogger) { } - class boss_hoggerAI : BossAI + public override void EnterCombat(Unit who) { - public boss_hoggerAI(Creature creature) : base(creature, DataTypes.Hogger) { } + _EnterCombat(); + Talk(TextIds.SayPull); - public override void EnterCombat(Unit who) + _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); + + _scheduler.Schedule(TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(4), task => { - _EnterCombat(); - Talk(TextIds.SayPull); + DoCastVictim(SpellIds.ViciousSlice); + task.Repeat(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(14)); + }); - _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); - - _scheduler.Schedule(TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(4), task => - { - DoCastVictim(SpellIds.ViciousSlice); - task.Repeat(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(14)); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2), task => - { - DoCast(SpellIds.MaddeningCall); - task.Repeat(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(20)); - }); - } - - public override void JustDied(Unit killer) + _scheduler.Schedule(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2), task => { - Talk(TextIds.SayDeath); - _JustDied(); - me.SummonCreature(CreatureIds.WardenThelwater, Misc.WardenThelwaterPos); - } - - public override void JustSummoned(Creature summon) - { - base.JustSummoned(summon); - if (summon.GetEntry() == CreatureIds.WardenThelwater) - summon.GetMotionMaster().MovePoint(0, Misc.WardenThelwaterMovePos); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _scheduler.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - DoMeleeAttackIfReady(); - } - - public override void DamageTaken(Unit attacker, ref uint damage) - { - if (me.HealthBelowPctDamaged(30, damage) && !_hasEnraged) - { - _hasEnraged = true; - Talk(TextIds.SayEnrage); - DoCastSelf(SpellIds.Enrage); - } - } - - bool _hasEnraged; + DoCast(SpellIds.MaddeningCall); + task.Repeat(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(20)); + }); } - public override CreatureAI GetAI(Creature creature) + public override void JustDied(Unit killer) { - return GetInstanceAI(creature, nameof(instance_the_stockade)); + Talk(TextIds.SayDeath); + _JustDied(); + me.SummonCreature(CreatureIds.WardenThelwater, Misc.WardenThelwaterPos); } + + public override void JustSummoned(Creature summon) + { + base.JustSummoned(summon); + if (summon.GetEntry() == CreatureIds.WardenThelwater) + summon.GetMotionMaster().MovePoint(0, Misc.WardenThelwaterMovePos); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _scheduler.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + DoMeleeAttackIfReady(); + } + + public override void DamageTaken(Unit attacker, ref uint damage) + { + if (me.HealthBelowPctDamaged(30, damage) && !_hasEnraged) + { + _hasEnraged = true; + Talk(TextIds.SayEnrage); + DoCastSelf(SpellIds.Enrage); + } + } + + bool _hasEnraged; } [Script] - class npc_warden_thelwater : CreatureScript + class npc_warden_thelwater : ScriptedAI { - public npc_warden_thelwater() : base("npc_warden_thelwater") { } + public npc_warden_thelwater(Creature creature) : base(creature) { } - class npc_warden_thelwaterAI : ScriptedAI + public override void MovementInform(MovementGeneratorType type, uint id) { - public npc_warden_thelwaterAI(Creature creature) : base(creature) { } - - public override void MovementInform(MovementGeneratorType type, uint id) - { - if (type == MovementGeneratorType.Point && id == 0) - _events.ScheduleEvent(Events.SayWarden1, TimeSpan.FromSeconds(1)); - } - - public override void UpdateAI(uint diff) - { - _events.Update(diff); - - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case Events.SayWarden1: - Talk(TextIds.SayWarden1); - _events.ScheduleEvent(Events.SayWarden2, TimeSpan.FromSeconds(4)); - break; - case Events.SayWarden2: - Talk(TextIds.SayWarden2); - _events.ScheduleEvent(Events.SayWarden3, TimeSpan.FromSeconds(3)); - break; - case Events.SayWarden3: - Talk(TextIds.SayWarden3); - break; - } - }); - } + if (type == MovementGeneratorType.Point && id == 0) + _events.ScheduleEvent(Events.SayWarden1, TimeSpan.FromSeconds(1)); } - public override CreatureAI GetAI(Creature creature) + public override void UpdateAI(uint diff) { - return GetInstanceAI(creature, nameof(instance_the_stockade)); + _events.Update(diff); + + _events.ExecuteEvents(eventId => + { + switch (eventId) + { + case Events.SayWarden1: + Talk(TextIds.SayWarden1); + _events.ScheduleEvent(Events.SayWarden2, TimeSpan.FromSeconds(4)); + break; + case Events.SayWarden2: + Talk(TextIds.SayWarden2); + _events.ScheduleEvent(Events.SayWarden3, TimeSpan.FromSeconds(3)); + break; + case Events.SayWarden3: + Talk(TextIds.SayWarden3); + break; + } + }); } } } diff --git a/Scripts/Kalimdor/ZoneAshenvale.cs b/Scripts/Kalimdor/ZoneAshenvale.cs index ff9baed49..9ad99b609 100644 --- a/Scripts/Kalimdor/ZoneAshenvale.cs +++ b/Scripts/Kalimdor/ZoneAshenvale.cs @@ -35,7 +35,7 @@ namespace Scripts.Kalimdor.ZoneAshenvale public const uint Cage = 178147; //Muglash - public const uint NagaBrazier = 178247; + public const uint NagaBrazier = 178247; //KingoftheFoulweald public const uint Banner = 178205; @@ -46,7 +46,7 @@ namespace Scripts.Kalimdor.ZoneAshenvale //RuulSnowhoof public const uint FreedomToRuul = 6482; - //Muglash + //Muglash public const uint Vorsha = 6641; } @@ -98,232 +98,212 @@ namespace Scripts.Kalimdor.ZoneAshenvale [Script] - class npc_ruul_snowhoof : CreatureScript + class npc_ruul_snowhoof : npc_escortAI { - public npc_ruul_snowhoof() : base("npc_ruul_snowhoof") { } + public npc_ruul_snowhoof(Creature creature) : base(creature) { } - class npc_ruul_snowhoofAI : npc_escortAI + public override void Reset() { - public npc_ruul_snowhoofAI(Creature creature) : base(creature) { } + GameObject cage = me.FindNearestGameObject(GameObjectIds.Cage, 20); + if (cage) + cage.SetGoState(GameObjectState.Ready); + } - public override void Reset() + public override void EnterCombat(Unit who) { } + + public override void JustSummoned(Creature summoned) + { + summoned.GetAI().AttackStart(me); + } + + public override void sQuestAccept(Player player, Quest quest) + { + if (quest.Id == QuestIds.FreedomToRuul) { - GameObject cage = me.FindNearestGameObject(GameObjectIds.Cage, 20); - if (cage) - cage.SetGoState(GameObjectState.Ready); - } - - public override void EnterCombat(Unit who) { } - - public override void JustSummoned(Creature summoned) - { - summoned.GetAI().AttackStart(me); - } - - public override void sQuestAccept(Player player, Quest quest) - { - if (quest.Id == QuestIds.FreedomToRuul) - { - me.SetFaction(Misc.FactionQuest); - base.Start(true, false, player.GetGUID()); - } - } - - public override void WaypointReached(uint waypointId) - { - Player player = GetPlayerForEscort(); - if (!player) - return; - - switch (waypointId) - { - case 0: - me.SetUInt32Value(UnitFields.Bytes1, 0); - GameObject cage = me.FindNearestGameObject(GameObjectIds.Cage, 20); - if (cage) - cage.SetGoState(GameObjectState.Active); - break; - case 13: - me.SummonCreature(CreatureIds.ThistlefurTotemic, Misc.RuulSnowhoofSummonsCoord[0], TempSummonType.DeadDespawn, 60000); - me.SummonCreature(CreatureIds.ThistlefurUrsa, Misc.RuulSnowhoofSummonsCoord[1], TempSummonType.DeadDespawn, 60000); - me.SummonCreature(CreatureIds.ThistlefurPathfinder, Misc.RuulSnowhoofSummonsCoord[2], TempSummonType.DeadDespawn, 60000); - break; - case 19: - me.SummonCreature(CreatureIds.ThistlefurTotemic, Misc.RuulSnowhoofSummonsCoord[3], TempSummonType.DeadDespawn, 60000); - me.SummonCreature(CreatureIds.ThistlefurUrsa, Misc.RuulSnowhoofSummonsCoord[4], TempSummonType.DeadDespawn, 60000); - me.SummonCreature(CreatureIds.ThistlefurPathfinder, Misc.RuulSnowhoofSummonsCoord[5], TempSummonType.DeadDespawn, 60000); - break; - case 21: - player.GroupEventHappens(QuestIds.FreedomToRuul, me); - break; - } - } - - public override void UpdateAI(uint diff) - { - base.UpdateAI(diff); + me.SetFaction(Misc.FactionQuest); + base.Start(true, false, player.GetGUID()); } } - public override CreatureAI GetAI(Creature creature) + public override void WaypointReached(uint waypointId) { - return new npc_ruul_snowhoofAI(creature); + Player player = GetPlayerForEscort(); + if (!player) + return; + + switch (waypointId) + { + case 0: + me.SetUInt32Value(UnitFields.Bytes1, 0); + GameObject cage = me.FindNearestGameObject(GameObjectIds.Cage, 20); + if (cage) + cage.SetGoState(GameObjectState.Active); + break; + case 13: + me.SummonCreature(CreatureIds.ThistlefurTotemic, Misc.RuulSnowhoofSummonsCoord[0], TempSummonType.DeadDespawn, 60000); + me.SummonCreature(CreatureIds.ThistlefurUrsa, Misc.RuulSnowhoofSummonsCoord[1], TempSummonType.DeadDespawn, 60000); + me.SummonCreature(CreatureIds.ThistlefurPathfinder, Misc.RuulSnowhoofSummonsCoord[2], TempSummonType.DeadDespawn, 60000); + break; + case 19: + me.SummonCreature(CreatureIds.ThistlefurTotemic, Misc.RuulSnowhoofSummonsCoord[3], TempSummonType.DeadDespawn, 60000); + me.SummonCreature(CreatureIds.ThistlefurUrsa, Misc.RuulSnowhoofSummonsCoord[4], TempSummonType.DeadDespawn, 60000); + me.SummonCreature(CreatureIds.ThistlefurPathfinder, Misc.RuulSnowhoofSummonsCoord[5], TempSummonType.DeadDespawn, 60000); + break; + case 21: + player.GroupEventHappens(QuestIds.FreedomToRuul, me); + break; + } + } + + public override void UpdateAI(uint diff) + { + base.UpdateAI(diff); } } [Script] - class npc_muglash : CreatureScript + public class npc_muglash : npc_escortAI { - public npc_muglash() : base("npc_muglash") { } - - public class npc_muglashAI : npc_escortAI + public npc_muglash(Creature creature) : base(creature) { - public npc_muglashAI(Creature creature) : base(creature) - { - Initialize(); - } + Initialize(); + } - void Initialize() - { - eventTimer = 10000; - waveId = 0; - _isBrazierExtinguished = false; - } + void Initialize() + { + eventTimer = 10000; + waveId = 0; + _isBrazierExtinguished = false; + } - public override void Reset() - { - Initialize(); - } + public override void Reset() + { + Initialize(); + } - public override void EnterCombat(Unit who) + public override void EnterCombat(Unit who) + { + Player player = GetPlayerForEscort(); + if (player) { - Player player = GetPlayerForEscort(); - if (player) + if (HasEscortState(eEscortState.Paused)) { - if (HasEscortState(eEscortState.Paused)) - { - if (Convert.ToBoolean(RandomHelper.URand(0, 1))) - Talk(TextIds.SayMugOnGuard, player); - return; - } - } - } - - public override void JustDied(Unit killer) - { - if (HasEscortState(eEscortState.Escorting)) - { - Player player = GetPlayerForEscort(); - if (player) - player.FailQuest(QuestIds.Vorsha); - } - } - - public override void JustSummoned(Creature summoned) - { - summoned.GetAI().AttackStart(me); - } - - public override void sQuestAccept(Player player, Quest quest) - { - if (quest.Id == QuestIds.Vorsha) - { - Talk(TextIds.SayMugStart1); - me.SetFaction(Misc.FactionQuest); - base.Start(true, false, player.GetGUID()); - } - } - - public override void WaypointReached(uint waypointId) - { - Player player = GetPlayerForEscort(); - if (player) - { - switch (waypointId) - { - case 0: - Talk(TextIds.SayMugStart2, player); - break; - case 24: - Talk(TextIds.SayMugBrazier, player); - - GameObject go = GetClosestGameObjectWithEntry(me, GameObjectIds.NagaBrazier, SharedConst.InteractionDistance * 2); - if (go) - { - go.RemoveFlag(GameObjectFields.Flags, GameObjectFlags.NotSelectable); - SetEscortPaused(true); - } - break; - case 25: - Talk(TextIds.SayMugGratitude); - player.GroupEventHappens(QuestIds.Vorsha, me); - break; - case 26: - Talk(TextIds.SayMugPatrol); - break; - case 27: - Talk(TextIds.SayMugReturn); - break; - } - } - } - - void DoWaveSummon() - { - switch (waveId) - { - case 1: - me.SummonCreature(CreatureIds.WrathRider, Misc.FirstNagaCoord[0], TempSummonType.TimedDespawnOOC, 60000); - me.SummonCreature(CreatureIds.WrathSorceress, Misc.FirstNagaCoord[1], TempSummonType.TimedDespawnOOC, 60000); - me.SummonCreature(CreatureIds.WrathRazortail, Misc.FirstNagaCoord[2], TempSummonType.TimedDespawnOOC, 60000); - break; - case 2: - me.SummonCreature(CreatureIds.WrathPriestess, Misc.SecondNagaCoord[0], TempSummonType.TimedDespawnOOC, 60000); - me.SummonCreature(CreatureIds.WrathMyrmidon, Misc.SecondNagaCoord[1], TempSummonType.TimedDespawnOOC, 60000); - me.SummonCreature(CreatureIds.WrathSeawitch, Misc.SecondNagaCoord[2], TempSummonType.TimedDespawnOOC, 60000); - break; - case 3: - me.SummonCreature(CreatureIds.Vorsha, Misc.VorshaCoord, TempSummonType.TimedDespawnOOC, 60000); - break; - case 4: - SetEscortPaused(false); - Talk(TextIds.SayMugDone); - break; - } - } - - public override void UpdateAI(uint diff) - { - base.UpdateAI(diff); - - if (!me.GetVictim()) - { - if (HasEscortState(eEscortState.Paused) && _isBrazierExtinguished) - { - if (eventTimer < diff) - { - ++waveId; - DoWaveSummon(); - eventTimer = 10000; - } - else - eventTimer -= diff; - } + if (Convert.ToBoolean(RandomHelper.URand(0, 1))) + Talk(TextIds.SayMugOnGuard, player); return; } - DoMeleeAttackIfReady(); } - - uint eventTimer; - byte waveId; - - public bool _isBrazierExtinguished { get; set; } } - public override CreatureAI GetAI(Creature creature) + public override void JustDied(Unit killer) { - return new npc_muglashAI(creature); + if (HasEscortState(eEscortState.Escorting)) + { + Player player = GetPlayerForEscort(); + if (player) + player.FailQuest(QuestIds.Vorsha); + } } + + public override void JustSummoned(Creature summoned) + { + summoned.GetAI().AttackStart(me); + } + + public override void sQuestAccept(Player player, Quest quest) + { + if (quest.Id == QuestIds.Vorsha) + { + Talk(TextIds.SayMugStart1); + me.SetFaction(Misc.FactionQuest); + base.Start(true, false, player.GetGUID()); + } + } + + public override void WaypointReached(uint waypointId) + { + Player player = GetPlayerForEscort(); + if (player) + { + switch (waypointId) + { + case 0: + Talk(TextIds.SayMugStart2, player); + break; + case 24: + Talk(TextIds.SayMugBrazier, player); + + GameObject go = GetClosestGameObjectWithEntry(me, GameObjectIds.NagaBrazier, SharedConst.InteractionDistance * 2); + if (go) + { + go.RemoveFlag(GameObjectFields.Flags, GameObjectFlags.NotSelectable); + SetEscortPaused(true); + } + break; + case 25: + Talk(TextIds.SayMugGratitude); + player.GroupEventHappens(QuestIds.Vorsha, me); + break; + case 26: + Talk(TextIds.SayMugPatrol); + break; + case 27: + Talk(TextIds.SayMugReturn); + break; + } + } + } + + void DoWaveSummon() + { + switch (waveId) + { + case 1: + me.SummonCreature(CreatureIds.WrathRider, Misc.FirstNagaCoord[0], TempSummonType.TimedDespawnOOC, 60000); + me.SummonCreature(CreatureIds.WrathSorceress, Misc.FirstNagaCoord[1], TempSummonType.TimedDespawnOOC, 60000); + me.SummonCreature(CreatureIds.WrathRazortail, Misc.FirstNagaCoord[2], TempSummonType.TimedDespawnOOC, 60000); + break; + case 2: + me.SummonCreature(CreatureIds.WrathPriestess, Misc.SecondNagaCoord[0], TempSummonType.TimedDespawnOOC, 60000); + me.SummonCreature(CreatureIds.WrathMyrmidon, Misc.SecondNagaCoord[1], TempSummonType.TimedDespawnOOC, 60000); + me.SummonCreature(CreatureIds.WrathSeawitch, Misc.SecondNagaCoord[2], TempSummonType.TimedDespawnOOC, 60000); + break; + case 3: + me.SummonCreature(CreatureIds.Vorsha, Misc.VorshaCoord, TempSummonType.TimedDespawnOOC, 60000); + break; + case 4: + SetEscortPaused(false); + Talk(TextIds.SayMugDone); + break; + } + } + + public override void UpdateAI(uint diff) + { + base.UpdateAI(diff); + + if (!me.GetVictim()) + { + if (HasEscortState(eEscortState.Paused) && _isBrazierExtinguished) + { + if (eventTimer < diff) + { + ++waveId; + DoWaveSummon(); + eventTimer = 10000; + } + else + eventTimer -= diff; + } + return; + } + DoMeleeAttackIfReady(); + } + + uint eventTimer; + byte waveId; + + public bool _isBrazierExtinguished { get; set; } } [Script] @@ -336,7 +316,7 @@ namespace Scripts.Kalimdor.ZoneAshenvale Creature creature = ScriptedAI.GetClosestCreatureWithEntry(go, CreatureIds.Muglash, SharedConst.InteractionDistance * 2); if (creature) { - npc_muglash.npc_muglashAI pEscortAI = creature.GetAI(); + npc_muglash pEscortAI = creature.GetAI(); if (pEscortAI != null) { creature.GetAI().Talk(TextIds.SayMugBrazierWait); @@ -351,28 +331,18 @@ namespace Scripts.Kalimdor.ZoneAshenvale } [Script] - class spell_destroy_karangs_banner : SpellScriptLoader + class spell_destroy_karangs_banner : SpellScript { - public spell_destroy_karangs_banner() : base("spell_destroy_karangs_banner") { } - - class spell_destroy_karangs_banner_SpellScript : SpellScript + void HandleAfterCast() { - void HandleAfterCast() - { - GameObject banner = GetCaster().FindNearestGameObject(GameObjectIds.Banner, GetSpellInfo().GetMaxRange(true)); - if (banner) - banner.Delete(); - } - - public override void Register() - { - AfterCast.Add(new CastHandler(HandleAfterCast)); - } + GameObject banner = GetCaster().FindNearestGameObject(GameObjectIds.Banner, GetSpellInfo().GetMaxRange(true)); + if (banner) + banner.Delete(); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_destroy_karangs_banner_SpellScript(); + AfterCast.Add(new CastHandler(HandleAfterCast)); } } } diff --git a/Scripts/Kalimdor/ZoneDurotar.cs b/Scripts/Kalimdor/ZoneDurotar.cs index 2e7d2426d..fd29cb063 100644 --- a/Scripts/Kalimdor/ZoneDurotar.cs +++ b/Scripts/Kalimdor/ZoneDurotar.cs @@ -26,118 +26,98 @@ using System; namespace Scripts.Kalimdor { [Script] - class npc_lazy_peon : CreatureScript + class npc_lazy_peon : NullCreatureAI { - public npc_lazy_peon() : base("npc_lazy_peon") { } + public npc_lazy_peon(Creature creature) : base(creature) { } - class npc_lazy_peonAI : NullCreatureAI + public override void InitializeAI() { - public npc_lazy_peonAI(Creature creature) : base(creature) { } + me.SetWalk(true); - public override void InitializeAI() + scheduler.Schedule(TimeSpan.FromSeconds(1), TimeSpan.FromMilliseconds(120000), task => { - me.SetWalk(true); + GameObject Lumberpile = me.FindNearestGameObject(GoLumberpile, 20); + if (Lumberpile) + me.GetMotionMaster().MovePoint(1, Lumberpile.GetPositionX() - 1, Lumberpile.GetPositionY(), Lumberpile.GetPositionZ()); + task.Repeat(); + }); - scheduler.Schedule(TimeSpan.FromSeconds(1), TimeSpan.FromMilliseconds(120000), task => - { - GameObject Lumberpile = me.FindNearestGameObject(GoLumberpile, 20); - if (Lumberpile) - me.GetMotionMaster().MovePoint(1, Lumberpile.GetPositionX() - 1, Lumberpile.GetPositionY(), Lumberpile.GetPositionZ()); - task.Repeat(); - }); - - scheduler.Schedule(TimeSpan.FromMilliseconds(300000), task => - { - me.HandleEmoteCommand(Emote.StateNone); - me.GetMotionMaster().MovePoint(2, me.GetHomePosition()); - task.Repeat(); - }); - } - - public override void MovementInform(MovementGeneratorType type, uint id) + scheduler.Schedule(TimeSpan.FromMilliseconds(300000), task => { - switch (id) - { - case 1: - me.HandleEmoteCommand(Emote.StateWorkChopwood); - break; - case 2: - DoCast(me, SpellBuffSleep); - break; - } - } - - public override void SpellHit(Unit caster, SpellInfo spell) - { - if (spell.Id != SpellAwakenPeon) - return; - - Player player = caster.ToPlayer(); - if (player && player.GetQuestStatus(QuestLazyPeons) == QuestStatus.Incomplete) - { - player.KilledMonsterCredit(me.GetEntry(), me.GetGUID()); - Talk(SaySpellHit, caster); - me.RemoveAllAuras(); - GameObject Lumberpile = me.FindNearestGameObject(GoLumberpile, 20); - if (Lumberpile) - me.GetMotionMaster().MovePoint(1, Lumberpile.GetPositionX() - 1, Lumberpile.GetPositionY(), Lumberpile.GetPositionZ()); - } - } - - public override void UpdateAI(uint diff) - { - scheduler.Update(diff); - - //if (!UpdateVictim()) - //return; - - //DoMeleeAttackIfReady(); - } - - const int QuestLazyPeons = 37446; - const int GoLumberpile = 175784; - const uint SpellBuffSleep = 17743; - const int SpellAwakenPeon = 19938; - const int SaySpellHit = 0; - - TaskScheduler scheduler = new TaskScheduler(); + me.HandleEmoteCommand(Emote.StateNone); + me.GetMotionMaster().MovePoint(2, me.GetHomePosition()); + task.Repeat(); + }); } - public override CreatureAI GetAI(Creature creature) + public override void MovementInform(MovementGeneratorType type, uint id) { - return new npc_lazy_peonAI(creature); + switch (id) + { + case 1: + me.HandleEmoteCommand(Emote.StateWorkChopwood); + break; + case 2: + DoCast(me, SpellBuffSleep); + break; + } } + + public override void SpellHit(Unit caster, SpellInfo spell) + { + if (spell.Id != SpellAwakenPeon) + return; + + Player player = caster.ToPlayer(); + if (player && player.GetQuestStatus(QuestLazyPeons) == QuestStatus.Incomplete) + { + player.KilledMonsterCredit(me.GetEntry(), me.GetGUID()); + Talk(SaySpellHit, caster); + me.RemoveAllAuras(); + GameObject Lumberpile = me.FindNearestGameObject(GoLumberpile, 20); + if (Lumberpile) + me.GetMotionMaster().MovePoint(1, Lumberpile.GetPositionX() - 1, Lumberpile.GetPositionY(), Lumberpile.GetPositionZ()); + } + } + + public override void UpdateAI(uint diff) + { + scheduler.Update(diff); + + //if (!UpdateVictim()) + //return; + + //DoMeleeAttackIfReady(); + } + + const int QuestLazyPeons = 37446; + const int GoLumberpile = 175784; + const uint SpellBuffSleep = 17743; + const int SpellAwakenPeon = 19938; + const int SaySpellHit = 0; + + TaskScheduler scheduler = new TaskScheduler(); } [Script] - class spell_voodoo : SpellScriptLoader + class spell_voodoo : SpellScript { - public spell_voodoo() : base("spell_voodoo") { } - - class spell_voodoo_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellBrew, SpellGhostly, SpellHex1, SpellHex2, SpellHex3, SpellGrow, SpellLaunch); - } - - void HandleDummy(uint effIndex) - { - uint spellid = RandomHelper.RAND(SpellBrew, SpellGhostly, RandomHelper.RAND(SpellHex1, SpellHex2, SpellHex3), SpellGrow, SpellLaunch); - Unit target = GetHitUnit(); - if (target) - GetCaster().CastSpell(target, spellid, false); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellBrew, SpellGhostly, SpellHex1, SpellHex2, SpellHex3, SpellGrow, SpellLaunch); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_voodoo_SpellScript(); + uint spellid = RandomHelper.RAND(SpellBrew, SpellGhostly, RandomHelper.RAND(SpellHex1, SpellHex2, SpellHex3), SpellGrow, SpellLaunch); + Unit target = GetHitUnit(); + if (target) + GetCaster().CastSpell(target, spellid, false); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } const uint SpellBrew = 16712; // Special Brew diff --git a/Scripts/Northrend/AzjolNerub/Ahnkahet/BossAmanitar.cs b/Scripts/Northrend/AzjolNerub/Ahnkahet/BossAmanitar.cs index 0409766a0..9fff32548 100644 --- a/Scripts/Northrend/AzjolNerub/Ahnkahet/BossAmanitar.cs +++ b/Scripts/Northrend/AzjolNerub/Ahnkahet/BossAmanitar.cs @@ -45,165 +45,145 @@ namespace Scripts.Northrend.AzjolNerub.Ahnkahet.Amanitar } [Script] - class boss_amanitar : CreatureScript + class boss_amanitar : BossAI { - public boss_amanitar() : base("boss_amanitar") { } + public boss_amanitar(Creature creature) : base(creature, DataTypes.Amanitar) { } - class boss_amanitarAI : BossAI + public override void Reset() { - public boss_amanitarAI(Creature creature) : base(creature, DataTypes.Amanitar) { } + _Reset(); + me.SetMeleeDamageSchool(SpellSchools.Nature); + me.ApplySpellImmune(0, SpellImmunity.School, SpellSchoolMask.Nature, true); + } - public override void Reset() + public override void EnterCombat(Unit who) + { + _EnterCombat(); + + _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); + + _scheduler.Schedule(TimeSpan.FromSeconds(5), task => { - _Reset(); - me.SetMeleeDamageSchool(SpellSchools.Nature); - me.ApplySpellImmune(0, SpellImmunity.School, SpellSchoolMask.Nature, true); - } - - public override void EnterCombat(Unit who) + SpawnAdds(); + task.Repeat(TimeSpan.FromSeconds(20)); + }); + _scheduler.Schedule(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(9), task => { - _EnterCombat(); - - _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); - - _scheduler.Schedule(TimeSpan.FromSeconds(5), task => - { - SpawnAdds(); - task.Repeat(TimeSpan.FromSeconds(20)); - }); - _scheduler.Schedule(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(9), task => - { - DoCast(SelectTarget(SelectAggroTarget.Random, 0, 100, true), SpellIds.EntanglingRoots, true); - task.Repeat(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(15)); - }); - _scheduler.Schedule(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(14), task => - { - DoCastVictim(SpellIds.Bash); - task.Repeat(TimeSpan.FromSeconds(7), TimeSpan.FromSeconds(12)); - }); - _scheduler.Schedule(TimeSpan.FromSeconds(12), TimeSpan.FromSeconds(18), task => - { - DoCast(SpellIds.Mini); - task.Repeat(TimeSpan.FromSeconds(25), TimeSpan.FromSeconds(30)); - }); - _scheduler.Schedule(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(20), task => - { - DoCast(SelectTarget(SelectAggroTarget.Random, 0, 100, true), SpellIds.VenomBoltVolley, true); - task.Repeat(TimeSpan.FromSeconds(18), TimeSpan.FromSeconds(22)); - }); - } - - public override void JustDied(Unit killer) + DoCast(SelectTarget(SelectAggroTarget.Random, 0, 100, true), SpellIds.EntanglingRoots, true); + task.Repeat(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(15)); + }); + _scheduler.Schedule(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(14), task => { - _JustDied(); - instance.DoRemoveAurasDueToSpellOnPlayers(SpellIds.Mini); - } - - void SpawnAdds() + DoCastVictim(SpellIds.Bash); + task.Repeat(TimeSpan.FromSeconds(7), TimeSpan.FromSeconds(12)); + }); + _scheduler.Schedule(TimeSpan.FromSeconds(12), TimeSpan.FromSeconds(18), task => { - int u = 0; + DoCast(SpellIds.Mini); + task.Repeat(TimeSpan.FromSeconds(25), TimeSpan.FromSeconds(30)); + }); + _scheduler.Schedule(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(20), task => + { + DoCast(SelectTarget(SelectAggroTarget.Random, 0, 100, true), SpellIds.VenomBoltVolley, true); + task.Repeat(TimeSpan.FromSeconds(18), TimeSpan.FromSeconds(22)); + }); + } - for (byte i = 0; i < 30; ++i) + public override void JustDied(Unit killer) + { + _JustDied(); + instance.DoRemoveAurasDueToSpellOnPlayers(SpellIds.Mini); + } + + void SpawnAdds() + { + int u = 0; + + for (byte i = 0; i < 30; ++i) + { + Position pos = me.GetRandomNearPosition(30.0f); + pos.posZ = me.GetMap().GetHeight(pos.GetPositionX(), pos.GetPositionY(), MapConst.MaxHeight) + 2.0f; + + Creature trigger = me.SummonCreature(CreatureIds.Trigger, pos); + if (trigger) { - Position pos = me.GetRandomNearPosition(30.0f); - pos.posZ = me.GetMap().GetHeight(pos.GetPositionX(), pos.GetPositionY(), MapConst.MaxHeight) + 2.0f; - - Creature trigger = me.SummonCreature(CreatureIds.Trigger, pos); - if (trigger) + Creature temp1 = trigger.FindNearestCreature(CreatureIds.HealthyMushroom, 4.0f, true); + Creature temp2 = trigger.FindNearestCreature(CreatureIds.PoisonousMushroom, 4.0f, true); + if (temp1 || temp2) { - Creature temp1 = trigger.FindNearestCreature(CreatureIds.HealthyMushroom, 4.0f, true); - Creature temp2 = trigger.FindNearestCreature(CreatureIds.PoisonousMushroom, 4.0f, true); - if (temp1 || temp2) - { - trigger.DisappearAndDie(); - } - else - { - u = 1 - u; - trigger.DisappearAndDie(); - me.SummonCreature(u > 0 ? CreatureIds.PoisonousMushroom : CreatureIds.HealthyMushroom, pos, TempSummonType.TimedOrCorpseDespawn, 60 * Time.InMilliseconds); - } + trigger.DisappearAndDie(); + } + else + { + u = 1 - u; + trigger.DisappearAndDie(); + me.SummonCreature(u > 0 ? CreatureIds.PoisonousMushroom : CreatureIds.HealthyMushroom, pos, TempSummonType.TimedOrCorpseDespawn, 60 * Time.InMilliseconds); } } } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _scheduler.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - DoMeleeAttackIfReady(); - } } - public override CreatureAI GetAI(Creature creature) + public override void UpdateAI(uint diff) { - return GetInstanceAI(creature); + if (!UpdateVictim()) + return; + + _scheduler.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + DoMeleeAttackIfReady(); } } [Script] - class npc_amanitar_mushrooms : CreatureScript + class npc_amanitar_mushrooms : ScriptedAI { - public npc_amanitar_mushrooms() : base("npc_amanitar_mushrooms") { } + public npc_amanitar_mushrooms(Creature creature) : base(creature) { } - class npc_amanitar_mushroomsAI : ScriptedAI + public override void Reset() { - public npc_amanitar_mushroomsAI(Creature creature) : base(creature) { } + _scheduler.CancelAll(); + _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); - public override void Reset() + _scheduler.Schedule(TimeSpan.FromSeconds(1), task => { - _scheduler.CancelAll(); - _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); - - _scheduler.Schedule(TimeSpan.FromSeconds(1), task => - { - if (me.GetEntry() == CreatureIds.PoisonousMushroom) - { - DoCast(me, SpellIds.PoisonousMushroomVisualArea, true); - DoCast(me, SpellIds.PoisonousMushroomPoisonCloud); - } - task.Repeat(TimeSpan.FromSeconds(7)); - }); - - me.SetDisplayId(me.GetCreatureTemplate().ModelId2); - DoCast(SpellIds.PutridMushroom); - if (me.GetEntry() == CreatureIds.PoisonousMushroom) - DoCast(SpellIds.PoisonousMushroomVisualAura); - else - DoCast(SpellIds.PowerMushroomVisualAura); - } + { + DoCast(me, SpellIds.PoisonousMushroomVisualArea, true); + DoCast(me, SpellIds.PoisonousMushroomPoisonCloud); + } + task.Repeat(TimeSpan.FromSeconds(7)); + }); - public override void DamageTaken(Unit attacker, ref uint damage) - { - if (damage >= me.GetHealth() && me.GetEntry() == CreatureIds.HealthyMushroom) - DoCast(me, SpellIds.HealthyMushroomPotentFungus, true); - } + me.SetDisplayId(me.GetCreatureTemplate().ModelId2); + DoCast(SpellIds.PutridMushroom); - public override void EnterCombat(Unit who) { } - public override void AttackStart(Unit victim) { } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _scheduler.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - } + if (me.GetEntry() == CreatureIds.PoisonousMushroom) + DoCast(SpellIds.PoisonousMushroomVisualAura); + else + DoCast(SpellIds.PowerMushroomVisualAura); } - public override CreatureAI GetAI(Creature creature) + public override void DamageTaken(Unit attacker, ref uint damage) { - return new npc_amanitar_mushroomsAI(creature); + if (damage >= me.GetHealth() && me.GetEntry() == CreatureIds.HealthyMushroom) + DoCast(me, SpellIds.HealthyMushroomPotentFungus, true); + } + + public override void EnterCombat(Unit who) { } + public override void AttackStart(Unit victim) { } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _scheduler.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; } } } diff --git a/Scripts/Northrend/AzjolNerub/Ahnkahet/BossElderNadox.cs b/Scripts/Northrend/AzjolNerub/Ahnkahet/BossElderNadox.cs index de1e3acd5..b2c5fc662 100644 --- a/Scripts/Northrend/AzjolNerub/Ahnkahet/BossElderNadox.cs +++ b/Scripts/Northrend/AzjolNerub/Ahnkahet/BossElderNadox.cs @@ -54,213 +54,184 @@ namespace Scripts.Northrend.AzjolNerub.Ahnkahet.ElderNadox } [Script] - class boss_elder_nadox : CreatureScript + class boss_elder_nadox : BossAI { - public boss_elder_nadox() : base("boss_elder_nadox") { } - - class boss_elder_nadoxAI : BossAI + public boss_elder_nadox(Creature creature) : base(creature, DataTypes.ElderNadox) { - public boss_elder_nadoxAI(Creature creature) : base(creature, DataTypes.ElderNadox) - { - Initialize(); - } + Initialize(); + } - void Initialize() - { - GuardianSummoned = false; - GuardianDied = false; - } + void Initialize() + { + GuardianSummoned = false; + GuardianDied = false; + } - public override void Reset() - { - _Reset(); - Initialize(); - } + public override void Reset() + { + _Reset(); + Initialize(); + } - public override void EnterCombat(Unit who) - { - _EnterCombat(); - Talk(TextIds.SayAggro); + public override void EnterCombat(Unit who) + { + _EnterCombat(); + Talk(TextIds.SayAggro); - _scheduler.Schedule(TimeSpan.FromSeconds(13), task => + _scheduler.Schedule(TimeSpan.FromSeconds(13), task => + { + DoCast(SelectTarget(SelectAggroTarget.Random, 0, 100, true), SpellIds.BroodPlague, true); + task.Repeat(TimeSpan.FromSeconds(15)); + }); + + _scheduler.Schedule(TimeSpan.FromSeconds(10), task => + { + /// @todo: summoned by egg + DoCast(me, SpellIds.SummonSwarmers); + if (RandomHelper.URand(1, 3) == 3) // 33% chance of dialog + Talk(TextIds.SayEggSac); + task.Repeat(); + }); + + if (IsHeroic()) + { + _scheduler.Schedule(TimeSpan.FromSeconds(12), task => { - DoCast(SelectTarget(SelectAggroTarget.Random, 0, 100, true), SpellIds.BroodPlague, true); - task.Repeat(TimeSpan.FromSeconds(15)); + DoCast(SpellIds.HBroodRage); + task.Repeat(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(50)); }); - _scheduler.Schedule(TimeSpan.FromSeconds(10), task => + _scheduler.Schedule(TimeSpan.FromSeconds(5), task => { - /// @todo: summoned by egg - DoCast(me, SpellIds.SummonSwarmers); - if (RandomHelper.URand(1, 3) == 3) // 33% chance of dialog - Talk(TextIds.SayEggSac); + if (me.HasAura(SpellIds.Enrage)) + return; + if (me.GetPositionZ() < 24.0f) + DoCast(me, SpellIds.Enrage, true); task.Repeat(); }); - - if (IsHeroic()) - { - _scheduler.Schedule(TimeSpan.FromSeconds(12), task => - { - DoCast(SpellIds.HBroodRage); - task.Repeat(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(50)); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(5), task => - { - if (me.HasAura(SpellIds.Enrage)) - return; - if (me.GetPositionZ() < 24.0f) - DoCast(me, SpellIds.Enrage, true); - task.Repeat(); - }); - } } - - public override void SummonedCreatureDies(Creature summon, Unit killer) - { - if (summon.GetEntry() == AKCreatureIds.AhnkaharGuardian) - GuardianDied = true; - } - - public override uint GetData(uint type) - { - if (type == Misc.DataRespectYourElders) - return !GuardianDied ? 1 : 0u; - - return 0; - } - - public override void KilledUnit(Unit who) - { - if (who.IsTypeId(TypeId.Player)) - Talk(TextIds.SaySlay); - } - - public override void JustDied(Unit killer) - { - _JustDied(); - Talk(TextIds.SayDeath); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _scheduler.Update(diff); - - if (!GuardianSummoned && me.HealthBelowPct(50)) - { - /// @todo: summoned by egg - Talk(TextIds.EmoteHatches, me); - DoCast(me, SpellIds.SummonSwarmGuard); - GuardianSummoned = true; - } - - DoMeleeAttackIfReady(); - } - - bool GuardianSummoned; - bool GuardianDied; } - public override CreatureAI GetAI(Creature creature) + public override void SummonedCreatureDies(Creature summon, Unit killer) { - return GetInstanceAI(creature, "instance_ahnkahet"); + if (summon.GetEntry() == AKCreatureIds.AhnkaharGuardian) + GuardianDied = true; } + + public override uint GetData(uint type) + { + if (type == Misc.DataRespectYourElders) + return !GuardianDied ? 1 : 0u; + + return 0; + } + + public override void KilledUnit(Unit who) + { + if (who.IsTypeId(TypeId.Player)) + Talk(TextIds.SaySlay); + } + + public override void JustDied(Unit killer) + { + _JustDied(); + Talk(TextIds.SayDeath); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _scheduler.Update(diff); + + if (!GuardianSummoned && me.HealthBelowPct(50)) + { + /// @todo: summoned by egg + Talk(TextIds.EmoteHatches, me); + DoCast(me, SpellIds.SummonSwarmGuard); + GuardianSummoned = true; + } + + DoMeleeAttackIfReady(); + } + + bool GuardianSummoned; + bool GuardianDied; } [Script] - class npc_ahnkahar_nerubian : CreatureScript + class npc_ahnkahar_nerubian : ScriptedAI { - public npc_ahnkahar_nerubian() : base("npc_ahnkahar_nerubian") { } + public npc_ahnkahar_nerubian(Creature creature) : base(creature) { } - class npc_ahnkahar_nerubianAI : ScriptedAI + public override void Reset() { - public npc_ahnkahar_nerubianAI(Creature creature) : base(creature) { } - - public override void Reset() + _scheduler.CancelAll(); + _scheduler.Schedule(TimeSpan.FromSeconds(13), task => { - _scheduler.CancelAll(); - _scheduler.Schedule(TimeSpan.FromSeconds(13), task => - { - DoCast(me, SpellIds.Sprint); - task.Repeat(TimeSpan.FromSeconds(20)); - }); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - if (me.HasUnitState(UnitState.Casting)) - return; - - _scheduler.Update(diff); - - DoMeleeAttackIfReady(); - } + DoCast(me, SpellIds.Sprint); + task.Repeat(TimeSpan.FromSeconds(20)); + }); } - public override CreatureAI GetAI(Creature creature) + public override void UpdateAI(uint diff) { - return new npc_ahnkahar_nerubianAI(creature); + if (!UpdateVictim()) + return; + + if (me.HasUnitState(UnitState.Casting)) + return; + + _scheduler.Update(diff); + + DoMeleeAttackIfReady(); } } // 56159 - Swarm [Script] - class spell_ahn_kahet_swarm : SpellScriptLoader + class spell_ahn_kahet_swarm : SpellScript { - public spell_ahn_kahet_swarm() : base("spell_ahn_kahet_swarm") { } - - class spell_ahn_kahet_swarm_SpellScript : SpellScript + public spell_ahn_kahet_swarm() { - public spell_ahn_kahet_swarm_SpellScript() - { - _targetCount = 0; - } + _targetCount = 0; + } - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.SwarmBuff); - } + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.SwarmBuff); + } - void CountTargets(List targets) - { - _targetCount = targets.Count; - } + void CountTargets(List targets) + { + _targetCount = targets.Count; + } - void HandleDummy(uint effIndex) + void HandleDummy(uint effIndex) + { + if (_targetCount != 0) { - if (_targetCount != 0) - { Aura aura = GetCaster().GetAura(SpellIds.SwarmBuff); - if (aura != null) - { - aura.SetStackAmount((byte)_targetCount); - aura.RefreshDuration(); - } - else - GetCaster().CastCustomSpell(SpellIds.SwarmBuff, SpellValueMod.AuraStack, _targetCount, GetCaster(), TriggerCastFlags.FullMask); + Aura aura = GetCaster().GetAura(SpellIds.SwarmBuff); + if (aura != null) + { + aura.SetStackAmount((byte)_targetCount); + aura.RefreshDuration(); } else - GetCaster().RemoveAurasDueToSpell(SpellIds.SwarmBuff); + GetCaster().CastCustomSpell(SpellIds.SwarmBuff, SpellValueMod.AuraStack, _targetCount, GetCaster(), TriggerCastFlags.FullMask); } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(CountTargets, 0, Targets.UnitSrcAreaAlly)); - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } - - int _targetCount; + else + GetCaster().RemoveAurasDueToSpell(SpellIds.SwarmBuff); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_ahn_kahet_swarm_SpellScript(); + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(CountTargets, 0, Targets.UnitSrcAreaAlly)); + OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } + + int _targetCount; } [Script] diff --git a/Scripts/Northrend/AzjolNerub/Ahnkahet/BossHeraldVolazj.cs b/Scripts/Northrend/AzjolNerub/Ahnkahet/BossHeraldVolazj.cs index 7ccfa0c14..23465fd55 100644 --- a/Scripts/Northrend/AzjolNerub/Ahnkahet/BossHeraldVolazj.cs +++ b/Scripts/Northrend/AzjolNerub/Ahnkahet/BossHeraldVolazj.cs @@ -56,240 +56,233 @@ namespace Scripts.Northrend.AzjolNerub.Ahnkahet.HeraldVolazj } [Script] - class boss_volazj : CreatureScript + class boss_volazj : ScriptedAI { - public boss_volazj() : base("boss_volazj") { } - - class boss_volazjAI : ScriptedAI + public boss_volazj(Creature creature) : base(creature) { - public boss_volazjAI(Creature creature) : base(creature) - { - Summons = new SummonList(me); + Summons = new SummonList(me); - Initialize(); - instance = creature.GetInstanceScript(); + Initialize(); + instance = creature.GetInstanceScript(); + } + + void Initialize() + { + uiMindFlayTimer = 8 * Time.InMilliseconds; + uiShadowBoltVolleyTimer = 5 * Time.InMilliseconds; + uiShiverTimer = 15 * Time.InMilliseconds; + // Used for Insanity handling + insanityHandled = 0; + } + + // returns the percentage of health after taking the given damage. + uint GetHealthPct(uint damage) + { + if (damage > me.GetHealth()) + return 0; + return (uint)(100 * (me.GetHealth() - damage) / me.GetMaxHealth()); + } + + public override void DamageTaken(Unit pAttacker, ref uint damage) + { + if (me.HasFlag(UnitFields.Flags, UnitFlags.NotSelectable)) + damage = 0; + + if ((GetHealthPct(0) >= 66 && GetHealthPct(damage) < 66) || + (GetHealthPct(0) >= 33 && GetHealthPct(damage) < 33)) + { + me.InterruptNonMeleeSpells(false); + DoCast(me, SpellIds.Insanity, false); } + } - void Initialize() + public override void SpellHitTarget(Unit target, SpellInfo spell) + { + if (spell.Id == SpellIds.Insanity) { - uiMindFlayTimer = 8 * Time.InMilliseconds; - uiShadowBoltVolleyTimer = 5 * Time.InMilliseconds; - uiShiverTimer = 15 * Time.InMilliseconds; - // Used for Insanity handling - insanityHandled = 0; - } - - // returns the percentage of health after taking the given damage. - uint GetHealthPct(uint damage) - { - if (damage > me.GetHealth()) - return 0; - return (uint)(100 * (me.GetHealth() - damage) / me.GetMaxHealth()); - } - - public override void DamageTaken(Unit pAttacker, ref uint damage) - { - if (me.HasFlag(UnitFields.Flags, UnitFlags.NotSelectable)) - damage = 0; - - if ((GetHealthPct(0) >= 66 && GetHealthPct(damage) < 66) || - (GetHealthPct(0) >= 33 && GetHealthPct(damage) < 33)) + // Not good target or too many players + if (target.GetTypeId() != TypeId.Player || insanityHandled > 4) + return; + // First target - start channel visual and set self as unnattackable + if (insanityHandled == 0) { - me.InterruptNonMeleeSpells(false); - DoCast(me, SpellIds.Insanity, false); + // Channel visual + DoCast(me, SpellIds.InsanityVisual, true); + // Unattackable + me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable); + me.SetControlled(true, UnitState.Stunned); } - } - public override void SpellHitTarget(Unit target, SpellInfo spell) - { - if (spell.Id == SpellIds.Insanity) - { - // Not good target or too many players - if (target.GetTypeId() != TypeId.Player || insanityHandled > 4) - return; - // First target - start channel visual and set self as unnattackable - if (insanityHandled == 0) - { - // Channel visual - DoCast(me, SpellIds.InsanityVisual, true); - // Unattackable - me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable); - me.SetControlled(true, UnitState.Stunned); - } + // phase the player + target.CastSpell(target, SpellIds.InsanityTarget + insanityHandled, true); - // phase the player - target.CastSpell(target, SpellIds.InsanityTarget + insanityHandled, true); + SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.InsanityTarget + insanityHandled); + if (spellInfo == null) + return; - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.InsanityTarget + insanityHandled); - if (spellInfo == null) - return; - - // summon twisted party members for this target - var players = me.GetMap().GetPlayers(); - foreach (var player in players) - { - if (!player || !player.IsAlive()) - continue; - // Summon clone - Unit summon = me.SummonCreature(AKCreatureIds.TwistedVisage, me.GetPositionX(), me.GetPositionY(), me.GetPositionZ(), me.GetOrientation(), TempSummonType.CorpseDespawn, 0); - if (summon) - { - // clone - player.CastSpell(summon, SpellIds.ClonePlayer, true); - // phase the summon - summon.SetInPhase((uint)spellInfo.GetEffect(0).MiscValueB, true, true); - } - } - ++insanityHandled; - } - } - - void ResetPlayersPhase() - { + // summon twisted party members for this target var players = me.GetMap().GetPlayers(); foreach (var player in players) + { + if (!player || !player.IsAlive()) + continue; + // Summon clone + Unit summon = me.SummonCreature(AKCreatureIds.TwistedVisage, me.GetPositionX(), me.GetPositionY(), me.GetPositionZ(), me.GetOrientation(), TempSummonType.CorpseDespawn, 0); + if (summon) + { + // clone + player.CastSpell(summon, SpellIds.ClonePlayer, true); + // phase the summon + summon.SetInPhase((uint)spellInfo.GetEffect(0).MiscValueB, true, true); + } + } + ++insanityHandled; + } + } + + void ResetPlayersPhase() + { + var players = me.GetMap().GetPlayers(); + foreach (var player in players) + { + for (uint index = 0; index <= 4; ++index) + player.RemoveAurasDueToSpell(SpellIds.InsanityTarget + index); + } + } + + public override void Reset() + { + Initialize(); + + instance.SetBossState(DataTypes.HeraldVolazj, EncounterState.NotStarted); + instance.DoStopCriteriaTimer(CriteriaTimedTypes.Event, Misc.AchievQuickDemiseStartEvent); + + // Visible for all players in insanity + me.SetInPhase(169, true, true); + for (uint i = 173; i <= 177; ++i) + me.SetInPhase(i, true, true); + + ResetPlayersPhase(); + + // Cleanup + Summons.DespawnAll(); + me.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable); + me.SetControlled(false, UnitState.Stunned); + } + + public override void EnterCombat(Unit who) + { + Talk(TextIds.SayAggro); + + instance.SetBossState(DataTypes.HeraldVolazj, EncounterState.InProgress); + instance.DoStartCriteriaTimer(CriteriaTimedTypes.Event, Misc.AchievQuickDemiseStartEvent); + } + + public override void JustSummoned(Creature summon) + { + Summons.Summon(summon); + } + + public override void SummonedCreatureDespawn(Creature summon) + { + uint nextPhase = 0; + Summons.Despawn(summon); + + // Check if all summons in this phase killed + foreach (var guid in Summons) + { + Creature visage = ObjectAccessor.GetCreature(me, guid); + if (visage) + { + // Not all are dead + if (visage.IsInPhase(summon)) + return; + else + { + nextPhase = visage.GetPhases().First(); + break; + } + } + } + + // Roll Insanity + var players = me.GetMap().GetPlayers(); + foreach (var player in players) + { + if (player) { for (uint index = 0; index <= 4; ++index) player.RemoveAurasDueToSpell(SpellIds.InsanityTarget + index); + player.CastSpell(player, SpellIds.InsanityTarget + nextPhase - 173, true); } } + } - public override void Reset() + public override void UpdateAI(uint diff) + { + //Return since we have no target + if (!UpdateVictim()) + return; + + if (insanityHandled != 0) { - Initialize(); - - instance.SetBossState(DataTypes.HeraldVolazj, EncounterState.NotStarted); - instance.DoStopCriteriaTimer(CriteriaTimedTypes.Event, Misc.AchievQuickDemiseStartEvent); - - // Visible for all players in insanity - me.SetInPhase(169, true, true); - for (uint i = 173; i <= 177; ++i) - me.SetInPhase(i, true, true); - - ResetPlayersPhase(); - - // Cleanup - Summons.DespawnAll(); - me.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable); - me.SetControlled(false, UnitState.Stunned); - } - - public override void EnterCombat(Unit who) - { - Talk(TextIds.SayAggro); - - instance.SetBossState(DataTypes.HeraldVolazj, EncounterState.InProgress); - instance.DoStartCriteriaTimer(CriteriaTimedTypes.Event, Misc.AchievQuickDemiseStartEvent); - } - - public override void JustSummoned(Creature summon) - { - Summons.Summon(summon); - } - - public override void SummonedCreatureDespawn(Creature summon) - { - uint nextPhase = 0; - Summons.Despawn(summon); - - // Check if all summons in this phase killed - foreach (var guid in Summons) - { - Creature visage = ObjectAccessor.GetCreature(me, guid); - if (visage) - { - // Not all are dead - if (visage.IsInPhase(summon)) - return; - else - { - nextPhase = visage.GetPhases().First(); - break; - } - } - } - - // Roll Insanity - var players = me.GetMap().GetPlayers(); - foreach (var player in players) - { - if (player) - { - for (uint index = 0; index <= 4; ++index) - player.RemoveAurasDueToSpell(SpellIds.InsanityTarget + index); - player.CastSpell(player, SpellIds.InsanityTarget + nextPhase - 173, true); - } - } - } - - public override void UpdateAI(uint diff) - { - //Return since we have no target - if (!UpdateVictim()) + if (!Summons.Empty()) return; - if (insanityHandled != 0) - { - if (!Summons.Empty()) - return; - - insanityHandled = 0; - me.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable); - me.SetControlled(false, UnitState.Stunned); - me.RemoveAurasDueToSpell(SpellIds.InsanityVisual); - } - - if (uiMindFlayTimer <= diff) - { - DoCastVictim(SpellIds.MindFlay); - uiMindFlayTimer = 20 * Time.InMilliseconds; - } else uiMindFlayTimer -= diff; - - if (uiShadowBoltVolleyTimer <= diff) - { - DoCastVictim(SpellIds.ShadowBoltVolley); - uiShadowBoltVolleyTimer = 5 * Time.InMilliseconds; - } else uiShadowBoltVolleyTimer -= diff; - - if (uiShiverTimer <= diff) - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0); - if (target) - DoCast(target, SpellIds.Shiver); - uiShiverTimer = 15 * Time.InMilliseconds; - } else uiShiverTimer -= diff; - - DoMeleeAttackIfReady(); + insanityHandled = 0; + me.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable); + me.SetControlled(false, UnitState.Stunned); + me.RemoveAurasDueToSpell(SpellIds.InsanityVisual); } - public override void JustDied(Unit killer) + if (uiMindFlayTimer <= diff) { - Talk(TextIds.SayDeath); - - instance.SetBossState(DataTypes.HeraldVolazj, EncounterState.Done); - - Summons.DespawnAll(); - ResetPlayersPhase(); + DoCastVictim(SpellIds.MindFlay); + uiMindFlayTimer = 20 * Time.InMilliseconds; } + else uiMindFlayTimer -= diff; - public override void KilledUnit(Unit who) + if (uiShadowBoltVolleyTimer <= diff) { - if (who.IsTypeId(TypeId.Player)) - Talk(TextIds.SaySlay); + DoCastVictim(SpellIds.ShadowBoltVolley); + uiShadowBoltVolleyTimer = 5 * Time.InMilliseconds; } + else uiShadowBoltVolleyTimer -= diff; - InstanceScript instance; + if (uiShiverTimer <= diff) + { + Unit target = SelectTarget(SelectAggroTarget.Random, 0); + if (target) + DoCast(target, SpellIds.Shiver); + uiShiverTimer = 15 * Time.InMilliseconds; + } + else uiShiverTimer -= diff; - uint uiMindFlayTimer; - uint uiShadowBoltVolleyTimer; - uint uiShiverTimer; - uint insanityHandled; - SummonList Summons; + DoMeleeAttackIfReady(); } - public override CreatureAI GetAI(Creature creature) + public override void JustDied(Unit killer) { - return GetInstanceAI(creature); + Talk(TextIds.SayDeath); + + instance.SetBossState(DataTypes.HeraldVolazj, EncounterState.Done); + + Summons.DespawnAll(); + ResetPlayersPhase(); } + + public override void KilledUnit(Unit who) + { + if (who.IsTypeId(TypeId.Player)) + Talk(TextIds.SaySlay); + } + + InstanceScript instance; + + uint uiMindFlayTimer; + uint uiShadowBoltVolleyTimer; + uint uiShiverTimer; + uint insanityHandled; + SummonList Summons; } } diff --git a/Scripts/Northrend/AzjolNerub/Ahnkahet/BossJedogaShadowseeker.cs b/Scripts/Northrend/AzjolNerub/Ahnkahet/BossJedogaShadowseeker.cs index 9257514cd..cec4e48ba 100644 --- a/Scripts/Northrend/AzjolNerub/Ahnkahet/BossJedogaShadowseeker.cs +++ b/Scripts/Northrend/AzjolNerub/Ahnkahet/BossJedogaShadowseeker.cs @@ -58,527 +58,497 @@ namespace Scripts.Northrend.AzjolNerub.Ahnkahet.JedogaShadowseeker } [Script] - class boss_jedoga_shadowseeker : CreatureScript + public class boss_jedoga_shadowseeker : ScriptedAI { - public boss_jedoga_shadowseeker() : base("boss_jedoga_shadowseeker") { } - - public class boss_jedoga_shadowseekerAI : ScriptedAI + public boss_jedoga_shadowseeker(Creature creature) : base(creature) { - public boss_jedoga_shadowseekerAI(Creature creature) : base(creature) + instance = creature.GetInstanceScript(); + bFirstTime = true; + bPreDone = false; + } + + void Initialize() + { + uiOpFerTimer = RandomHelper.URand(15 * Time.InMilliseconds, 20 * Time.InMilliseconds); + + uiCycloneTimer = 3 * Time.InMilliseconds; + uiBoltTimer = 7 * Time.InMilliseconds; + uiThunderTimer = 12 * Time.InMilliseconds; + + bOpFerok = false; + bOpFerokFail = false; + bOnGround = false; + bCanDown = false; + volunteerWork = true; + } + + public override void Reset() + { + Initialize(); + + DoCast(SpellIds.RandomLightningVisual); + + if (!bFirstTime) + instance.SetBossState(DataTypes.JedogaShadowseeker, EncounterState.Fail); + + instance.SetGuidData(DataTypes.PlJedogaTarget, ObjectGuid.Empty); + instance.SetGuidData(DataTypes.AddJedogaVictim, ObjectGuid.Empty); + instance.SetData(DataTypes.JedogaResetInitiands, 0); + MoveUp(); + + bFirstTime = false; + } + + public override void EnterCombat(Unit who) + { + if (instance == null || (who.GetTypeId() == TypeId.Unit && who.GetEntry() == AKCreatureIds.JedogaController)) + return; + + Talk(TextIds.SayAggro); + me.SetInCombatWithZone(); + instance.SetBossState(DataTypes.JedogaShadowseeker, EncounterState.InProgress); + } + + public override void AttackStart(Unit who) + { + if (!who || (who.GetTypeId() == TypeId.Unit && who.GetEntry() == AKCreatureIds.JedogaController)) + return; + + base.AttackStart(who); + } + + public override void KilledUnit(Unit Victim) + { + if (!Victim || !Victim.IsTypeId(TypeId.Player)) + return; + + Talk(TextIds.SaySlay); + } + + public override void JustDied(Unit killer) + { + Talk(TextIds.SayDeath); + instance.SetBossState(DataTypes.JedogaShadowseeker, EncounterState.Done); + } + + public override void DoAction(int action) + { + if (action == Misc.ActionInitiateKilled) + volunteerWork = false; + } + + public override uint GetData(uint type) + { + if (type == Misc.DataVolunteerWork) + return volunteerWork ? 1 : 0u; + + return 0; + } + + public override void MoveInLineOfSight(Unit who) + { + if (instance == null || !who || (who.IsTypeId(TypeId.Unit) && who.GetEntry() == AKCreatureIds.JedogaController)) + return; + + if (!bPreDone && who.IsTypeId(TypeId.Player) && me.GetDistance(who) < 100.0f) { - instance = creature.GetInstanceScript(); - bFirstTime = true; - bPreDone = false; + Talk(TextIds.SayPreaching); + bPreDone = true; } - void Initialize() + if (instance.GetBossState(DataTypes.JedogaShadowseeker) != EncounterState.InProgress || !bOnGround) + return; + + if (!me.GetVictim() && me.CanCreatureAttack(who)) { - uiOpFerTimer = RandomHelper.URand(15 * Time.InMilliseconds, 20 * Time.InMilliseconds); - - uiCycloneTimer = 3 * Time.InMilliseconds; - uiBoltTimer = 7 * Time.InMilliseconds; - uiThunderTimer = 12 * Time.InMilliseconds; - - bOpFerok = false; - bOpFerokFail = false; - bOnGround = false; - bCanDown = false; - volunteerWork = true; - } - - public override void Reset() - { - Initialize(); - - DoCast(SpellIds.RandomLightningVisual); - - if (!bFirstTime) - instance.SetBossState(DataTypes.JedogaShadowseeker, EncounterState.Fail); - - instance.SetGuidData(DataTypes.PlJedogaTarget, ObjectGuid.Empty); - instance.SetGuidData(DataTypes.AddJedogaVictim, ObjectGuid.Empty); - instance.SetData(DataTypes.JedogaResetInitiands, 0); - MoveUp(); - - bFirstTime = false; - } - - public override void EnterCombat(Unit who) - { - if (instance == null || (who.GetTypeId() == TypeId.Unit && who.GetEntry() == AKCreatureIds.JedogaController)) - return; - - Talk(TextIds.SayAggro); - me.SetInCombatWithZone(); - instance.SetBossState(DataTypes.JedogaShadowseeker, EncounterState.InProgress); - } - - public override void AttackStart(Unit who) - { - if (!who || (who.GetTypeId() == TypeId.Unit && who.GetEntry() == AKCreatureIds.JedogaController)) - return; - - base.AttackStart(who); - } - - public override void KilledUnit(Unit Victim) - { - if (!Victim || !Victim.IsTypeId(TypeId.Player)) - return; - - Talk(TextIds.SaySlay); - } - - public override void JustDied(Unit killer) - { - Talk(TextIds.SayDeath); - instance.SetBossState(DataTypes.JedogaShadowseeker, EncounterState.Done); - } - - public override void DoAction(int action) - { - if (action == Misc.ActionInitiateKilled) - volunteerWork = false; - } - - public override uint GetData(uint type) - { - if (type == Misc.DataVolunteerWork) - return volunteerWork ? 1 : 0u; - - return 0; - } - - public override void MoveInLineOfSight(Unit who) - { - if (instance == null || !who || (who.IsTypeId(TypeId.Unit) && who.GetEntry() == AKCreatureIds.JedogaController)) - return; - - if (!bPreDone && who.IsTypeId(TypeId.Player) && me.GetDistance(who) < 100.0f) + float attackRadius = me.GetAttackDistance(who); + if (me.IsWithinDistInMap(who, attackRadius) && me.IsWithinLOSInMap(who)) { - Talk(TextIds.SayPreaching); - bPreDone = true; - } - - if (instance.GetBossState(DataTypes.JedogaShadowseeker) != EncounterState.InProgress || !bOnGround) - return; - - if (!me.GetVictim() && me.CanCreatureAttack(who)) - { - float attackRadius = me.GetAttackDistance(who); - if (me.IsWithinDistInMap(who, attackRadius) && me.IsWithinLOSInMap(who)) + if (!me.GetVictim()) { - if (!me.GetVictim()) - { - who.RemoveAurasByType(AuraType.ModStealth); - AttackStart(who); - } - else - { - who.SetInCombatWith(me); - me.AddThreat(who, 0.0f); - } + who.RemoveAurasByType(AuraType.ModStealth); + AttackStart(who); } - } - } - - void MoveDown() - { - bOpFerokFail = false; - - instance.SetData(DataTypes.JedogaTriggerSwitch, 0); - me.GetMotionMaster().MovePoint(1, Misc.JedogaPosition[1]); - me.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchoolMask.Normal, false); - me.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchoolMask.Magic, false); - me.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable | UnitFlags.NonAttackable); - - me.RemoveAurasDueToSpell(SpellIds.SphereVisual); - - bOnGround = true; - - if (UpdateVictim()) - { - AttackStart(me.GetVictim()); - me.GetMotionMaster().MoveChase(me.GetVictim()); - } - else - { - Unit target = Global.ObjAccessor.GetUnit(me, instance.GetGuidData(DataTypes.PlJedogaTarget)); - if (target) - { - AttackStart(target); - instance.SetData(DataTypes.JedogaResetInitiands, 0); - if (instance.GetBossState(DataTypes.JedogaShadowseeker) != EncounterState.InProgress) - EnterCombat(target); - } - else if (!me.IsInCombat()) - EnterEvadeMode(); - } - } - - void MoveUp() - { - me.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchoolMask.Normal, true); - me.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchoolMask.Magic, true); - me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable | UnitFlags.NonAttackable); - - me.AttackStop(); - me.RemoveAllAuras(); - me.LoadCreaturesAddon(); - me.GetMotionMaster().MovePoint(0, Misc.JedogaPosition[0]); - - instance.SetData(DataTypes.JedogaTriggerSwitch, 1); - if (instance.GetBossState(DataTypes.JedogaShadowseeker) == EncounterState.InProgress) - GetVictimForSacrifice(); - - bOnGround = false; - uiOpFerTimer = RandomHelper.URand(15 * Time.InMilliseconds, 30 * Time.InMilliseconds); - } - - void GetVictimForSacrifice() - { - ObjectGuid victim = instance.GetGuidData(DataTypes.AddJedogaInitiand); - if (!victim.IsEmpty()) - { - Talk(TextIds.SaySacrifice1); - instance.SetGuidData(DataTypes.AddJedogaVictim, victim); - } - else - bCanDown = true; - } - - void Sacrifice() - { - Talk(TextIds.SaySacrifice2); - - me.InterruptNonMeleeSpells(false); - DoCast(me, SpellIds.GiftOfTheHerald, false); - - bOpFerok = false; - bCanDown = true; - } - - public override void UpdateAI(uint diff) - { - if (instance.GetBossState(DataTypes.JedogaShadowseeker) != EncounterState.InProgress && instance.GetData(DataTypes.AllInitiandDead) != 0) - MoveDown(); - - if (bOpFerok && !bOnGround && !bCanDown) - Sacrifice(); - - if (bOpFerokFail && !bOnGround && !bCanDown) - bCanDown = true; - - if (bCanDown) - { - MoveDown(); - bCanDown = false; - } - - if (bOnGround) - { - if (!UpdateVictim()) - return; - - if (uiCycloneTimer <= diff) - { - DoCast(me, SpellIds.CycloneStrike, false); - uiCycloneTimer = RandomHelper.URand(15 * Time.InMilliseconds, 30 * Time.InMilliseconds); - } - else uiCycloneTimer -= diff; - - if (uiBoltTimer <= diff) - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100, true); - if (target) - me.CastSpell(target, SpellIds.LightningBolt, false); - - uiBoltTimer = RandomHelper.URand(15 * Time.InMilliseconds, 30 * Time.InMilliseconds); - } - else uiBoltTimer -= diff; - - if (uiThunderTimer <= diff) - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100, true); - if (target) - me.CastSpell(target, SpellIds.Thundershock, false); - - uiThunderTimer = RandomHelper.URand(15 * Time.InMilliseconds, 30 * Time.InMilliseconds); - } - else uiThunderTimer -= diff; - - if (uiOpFerTimer <= diff) - MoveUp(); else - uiOpFerTimer -= diff; - - DoMeleeAttackIfReady(); + { + who.SetInCombatWith(me); + me.AddThreat(who, 0.0f); + } } } - - InstanceScript instance; - - uint uiOpFerTimer; - uint uiCycloneTimer; - uint uiBoltTimer; - uint uiThunderTimer; - - bool bPreDone; - public bool bOpFerok; - bool bOnGround; - public bool bOpFerokFail; - bool bCanDown; - bool volunteerWork; - bool bFirstTime; } - public override CreatureAI GetAI(Creature creature) + void MoveDown() { - return GetInstanceAI(creature); + bOpFerokFail = false; + + instance.SetData(DataTypes.JedogaTriggerSwitch, 0); + me.GetMotionMaster().MovePoint(1, Misc.JedogaPosition[1]); + me.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchoolMask.Normal, false); + me.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchoolMask.Magic, false); + me.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable | UnitFlags.NonAttackable); + + me.RemoveAurasDueToSpell(SpellIds.SphereVisual); + + bOnGround = true; + + if (UpdateVictim()) + { + AttackStart(me.GetVictim()); + me.GetMotionMaster().MoveChase(me.GetVictim()); + } + else + { + Unit target = Global.ObjAccessor.GetUnit(me, instance.GetGuidData(DataTypes.PlJedogaTarget)); + if (target) + { + AttackStart(target); + instance.SetData(DataTypes.JedogaResetInitiands, 0); + if (instance.GetBossState(DataTypes.JedogaShadowseeker) != EncounterState.InProgress) + EnterCombat(target); + } + else if (!me.IsInCombat()) + EnterEvadeMode(); + } } + + void MoveUp() + { + me.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchoolMask.Normal, true); + me.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchoolMask.Magic, true); + me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable | UnitFlags.NonAttackable); + + me.AttackStop(); + me.RemoveAllAuras(); + me.LoadCreaturesAddon(); + me.GetMotionMaster().MovePoint(0, Misc.JedogaPosition[0]); + + instance.SetData(DataTypes.JedogaTriggerSwitch, 1); + if (instance.GetBossState(DataTypes.JedogaShadowseeker) == EncounterState.InProgress) + GetVictimForSacrifice(); + + bOnGround = false; + uiOpFerTimer = RandomHelper.URand(15 * Time.InMilliseconds, 30 * Time.InMilliseconds); + } + + void GetVictimForSacrifice() + { + ObjectGuid victim = instance.GetGuidData(DataTypes.AddJedogaInitiand); + if (!victim.IsEmpty()) + { + Talk(TextIds.SaySacrifice1); + instance.SetGuidData(DataTypes.AddJedogaVictim, victim); + } + else + bCanDown = true; + } + + void Sacrifice() + { + Talk(TextIds.SaySacrifice2); + + me.InterruptNonMeleeSpells(false); + DoCast(me, SpellIds.GiftOfTheHerald, false); + + bOpFerok = false; + bCanDown = true; + } + + public override void UpdateAI(uint diff) + { + if (instance.GetBossState(DataTypes.JedogaShadowseeker) != EncounterState.InProgress && instance.GetData(DataTypes.AllInitiandDead) != 0) + MoveDown(); + + if (bOpFerok && !bOnGround && !bCanDown) + Sacrifice(); + + if (bOpFerokFail && !bOnGround && !bCanDown) + bCanDown = true; + + if (bCanDown) + { + MoveDown(); + bCanDown = false; + } + + if (bOnGround) + { + if (!UpdateVictim()) + return; + + if (uiCycloneTimer <= diff) + { + DoCast(me, SpellIds.CycloneStrike, false); + uiCycloneTimer = RandomHelper.URand(15 * Time.InMilliseconds, 30 * Time.InMilliseconds); + } + else uiCycloneTimer -= diff; + + if (uiBoltTimer <= diff) + { + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100, true); + if (target) + me.CastSpell(target, SpellIds.LightningBolt, false); + + uiBoltTimer = RandomHelper.URand(15 * Time.InMilliseconds, 30 * Time.InMilliseconds); + } + else uiBoltTimer -= diff; + + if (uiThunderTimer <= diff) + { + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100, true); + if (target) + me.CastSpell(target, SpellIds.Thundershock, false); + + uiThunderTimer = RandomHelper.URand(15 * Time.InMilliseconds, 30 * Time.InMilliseconds); + } + else uiThunderTimer -= diff; + + if (uiOpFerTimer <= diff) + MoveUp(); + else + uiOpFerTimer -= diff; + + DoMeleeAttackIfReady(); + } + } + + InstanceScript instance; + + uint uiOpFerTimer; + uint uiCycloneTimer; + uint uiBoltTimer; + uint uiThunderTimer; + + bool bPreDone; + public bool bOpFerok; + bool bOnGround; + public bool bOpFerokFail; + bool bCanDown; + bool volunteerWork; + bool bFirstTime; } [Script] - class npc_jedoga_twilight_volunteer : CreatureScript + class npc_jedoga_twilight_volunteer : ScriptedAI { - public npc_jedoga_twilight_volunteer() : base("npc_jedoga_initiand") { } - - class npc_jedoga_twilight_volunteerAI : ScriptedAI + public npc_jedoga_twilight_volunteer(Creature creature) : base(creature) { - public npc_jedoga_twilight_volunteerAI(Creature creature) : base(creature) - { - Initialize(); - instance = creature.GetInstanceScript(); - } + Initialize(); + instance = creature.GetInstanceScript(); + } - void Initialize() + void Initialize() + { + bWalking = false; + bCheckTimer = 2 * Time.InMilliseconds; + } + + public override void Reset() + { + Initialize(); + + if (instance.GetBossState(DataTypes.JedogaShadowseeker) != EncounterState.InProgress) { + me.RemoveAurasDueToSpell(SpellIds.SphereVisual); + me.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchoolMask.Normal, false); + me.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchoolMask.Magic, false); + me.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable | UnitFlags.NonAttackable); + } + else + { + DoCast(me, SpellIds.SphereVisual, false); + me.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchoolMask.Normal, true); + me.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchoolMask.Magic, true); + me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable | UnitFlags.NonAttackable); + } + } + + public override void JustDied(Unit killer) + { + if (!killer || instance == null) + return; + + if (bWalking) + { + Creature boss = ObjectAccessor.GetCreature(me, instance.GetGuidData(DataTypes.JedogaShadowseeker)); + if (boss) + { + if (!boss.GetAI().bOpFerok) + boss.GetAI().bOpFerokFail = true; + + if (killer.IsTypeId(TypeId.Player)) + boss.GetAI().DoAction(Misc.ActionInitiateKilled); + } + + instance.SetGuidData(DataTypes.AddJedogaVictim, ObjectGuid.Empty); + bWalking = false; - bCheckTimer = 2 * Time.InMilliseconds; } + if (killer.IsTypeId(TypeId.Player)) + instance.SetGuidData(DataTypes.PlJedogaTarget, killer.GetGUID()); + } - public override void Reset() + public override void EnterCombat(Unit who) { } + + public override void AttackStart(Unit victim) + { + if ((instance.GetBossState(DataTypes.JedogaShadowseeker) == EncounterState.InProgress) || !victim) + return; + + base.AttackStart(victim); + } + + public override void MoveInLineOfSight(Unit who) + { + if ((instance.GetBossState(DataTypes.JedogaShadowseeker) == EncounterState.InProgress) || !who) + return; + + base.MoveInLineOfSight(who); + } + + public override void MovementInform(MovementGeneratorType uiType, uint uiPointId) + { + if (uiType != MovementGeneratorType.Point || instance == null) + return; + + switch (uiPointId) { - Initialize(); + case 1: + { + Creature boss = me.GetMap().GetCreature(instance.GetGuidData(DataTypes.JedogaShadowseeker)); + if (boss) + { + boss.GetAI().bOpFerok = true; + boss.GetAI().bOpFerokFail = false; + me.KillSelf(); + } + } + break; + } + } - if (instance.GetBossState(DataTypes.JedogaShadowseeker) != EncounterState.InProgress) + public override void UpdateAI(uint diff) + { + if (bCheckTimer <= diff) + { + if (me.GetGUID() == instance.GetGuidData(DataTypes.AddJedogaVictim) && !bWalking) { me.RemoveAurasDueToSpell(SpellIds.SphereVisual); me.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchoolMask.Normal, false); me.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchoolMask.Magic, false); me.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable | UnitFlags.NonAttackable); + + float distance = me.GetDistance(Misc.JedogaPosition[1]); + + if (distance < 9.0f) + me.SetSpeedRate(UnitMoveType.Walk, 0.5f); + else if (distance < 15.0f) + me.SetSpeedRate(UnitMoveType.Walk, 0.75f); + else if (distance < 20.0f) + me.SetSpeedRate(UnitMoveType.Walk, 1.0f); + + me.GetMotionMaster().Clear(false); + me.GetMotionMaster().MovePoint(1, Misc.JedogaPosition[1]); + bWalking = true; } - else + if (!bWalking) { - DoCast(me, SpellIds.SphereVisual, false); - me.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchoolMask.Normal, true); - me.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchoolMask.Magic, true); - me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable | UnitFlags.NonAttackable); - } - } - - public override void JustDied(Unit killer) - { - if (!killer || instance == null) - return; - - if (bWalking) - { - Creature boss = ObjectAccessor.GetCreature(me, instance.GetGuidData(DataTypes.JedogaShadowseeker)); - if (boss) - { - if (!boss.GetAI().bOpFerok) - boss.GetAI().bOpFerokFail = true; - - if (killer.IsTypeId(TypeId.Player)) - boss.GetAI().DoAction(Misc.ActionInitiateKilled); - } - - instance.SetGuidData(DataTypes.AddJedogaVictim, ObjectGuid.Empty); - - bWalking = false; - } - if (killer.IsTypeId(TypeId.Player)) - instance.SetGuidData(DataTypes.PlJedogaTarget, killer.GetGUID()); - } - - public override void EnterCombat(Unit who) { } - - public override void AttackStart(Unit victim) - { - if ((instance.GetBossState(DataTypes.JedogaShadowseeker) == EncounterState.InProgress) || !victim) - return; - - base.AttackStart(victim); - } - - public override void MoveInLineOfSight(Unit who) - { - if ((instance.GetBossState(DataTypes.JedogaShadowseeker) == EncounterState.InProgress) || !who) - return; - - base.MoveInLineOfSight(who); - } - - public override void MovementInform(MovementGeneratorType uiType, uint uiPointId) - { - if (uiType != MovementGeneratorType.Point || instance == null) - return; - - switch (uiPointId) - { - case 1: - { - Creature boss = me.GetMap().GetCreature(instance.GetGuidData(DataTypes.JedogaShadowseeker)); - if (boss) - { - boss.GetAI().bOpFerok = true; - boss.GetAI().bOpFerokFail = false; - me.KillSelf(); - } - } - break; - } - } - - public override void UpdateAI(uint diff) - { - if (bCheckTimer <= diff) - { - if (me.GetGUID() == instance.GetGuidData(DataTypes.AddJedogaVictim) && !bWalking) + if (instance.GetBossState(DataTypes.JedogaShadowseeker) != EncounterState.InProgress && me.HasAura(SpellIds.SphereVisual)) { me.RemoveAurasDueToSpell(SpellIds.SphereVisual); me.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchoolMask.Normal, false); me.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchoolMask.Magic, false); me.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable | UnitFlags.NonAttackable); - - float distance = me.GetDistance(Misc.JedogaPosition[1]); - - if (distance < 9.0f) - me.SetSpeedRate(UnitMoveType.Walk, 0.5f); - else if (distance < 15.0f) - me.SetSpeedRate(UnitMoveType.Walk, 0.75f); - else if (distance < 20.0f) - me.SetSpeedRate(UnitMoveType.Walk, 1.0f); - - me.GetMotionMaster().Clear(false); - me.GetMotionMaster().MovePoint(1, Misc.JedogaPosition[1]); - bWalking = true; } - if (!bWalking) + if (instance.GetBossState(DataTypes.JedogaShadowseeker) == EncounterState.InProgress && !me.HasAura(SpellIds.SphereVisual)) { - if (instance.GetBossState(DataTypes.JedogaShadowseeker) != EncounterState.InProgress && me.HasAura(SpellIds.SphereVisual)) - { - me.RemoveAurasDueToSpell(SpellIds.SphereVisual); - me.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchoolMask.Normal, false); - me.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchoolMask.Magic, false); - me.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable | UnitFlags.NonAttackable); - } - if (instance.GetBossState(DataTypes.JedogaShadowseeker) == EncounterState.InProgress && !me.HasAura(SpellIds.SphereVisual)) - { - DoCast(me, SpellIds.SphereVisual, false); - me.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchoolMask.Normal, true); - me.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchoolMask.Magic, true); - me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable | UnitFlags.NonAttackable); - } + DoCast(me, SpellIds.SphereVisual, false); + me.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchoolMask.Normal, true); + me.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchoolMask.Magic, true); + me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable | UnitFlags.NonAttackable); } - bCheckTimer = 2 * Time.InMilliseconds; } - else bCheckTimer -= diff; - - //Return since we have no target - if (!UpdateVictim()) - return; - - DoMeleeAttackIfReady(); + bCheckTimer = 2 * Time.InMilliseconds; } + else bCheckTimer -= diff; - InstanceScript instance; + //Return since we have no target + if (!UpdateVictim()) + return; - uint bCheckTimer; - bool bWalking; + DoMeleeAttackIfReady(); } - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } + InstanceScript instance; + + uint bCheckTimer; + bool bWalking; } [Script] - class npc_jedoga_controller : CreatureScript + class npc_jedoga_controller : ScriptedAI { - public npc_jedoga_controller() : base("npc_jedogas_aufseher_trigger") { } - - class npc_jedoga_controllerAI : ScriptedAI + public npc_jedoga_controller(Creature creature) : base(creature) { - public npc_jedoga_controllerAI(Creature creature) : base(creature) - { - instance = creature.GetInstanceScript(); - bRemoved = false; - bRemoved2 = false; - bCast = false; - bCast2 = false; + instance = creature.GetInstanceScript(); + bRemoved = false; + bRemoved2 = false; + bCast = false; + bCast2 = false; - SetCombatMovement(false); - } - - public override void Reset() { } - - public override void EnterCombat(Unit who) { } - - public override void AttackStart(Unit victim) { } - - public override void MoveInLineOfSight(Unit who) { } - - public override void UpdateAI(uint diff) - { - if (!bRemoved && me.GetPositionX() > 440.0f) - { - if (instance.GetBossState(DataTypes.PrinceTaldaram) == EncounterState.Done) - { - me.InterruptNonMeleeSpells(true); - bRemoved = true; - return; - } - if (!bCast) - { - //DoCast(me, JedogaShadowseekerConst.SpellBeamVisualJedogasAufseher1, false); - bCast = true; - } - } - if (!bRemoved2 && me.GetPositionX() < 440.0f) - { - if (!bCast2 && instance.GetData(DataTypes.JedogaTriggerSwitch) != 0) - { - //DoCast(me, JedogaShadowseekerConst.SpellBeamVisualJedogasAufseher2, false); - bCast2 = true; - } - if (bCast2 && instance.GetData(DataTypes.JedogaTriggerSwitch) == 0) - { - me.InterruptNonMeleeSpells(true); - bCast2 = false; - } - if (!bRemoved2 && instance.GetBossState(DataTypes.JedogaShadowseeker) == EncounterState.Done) - { - me.InterruptNonMeleeSpells(true); - bRemoved2 = true; - } - } - } - - InstanceScript instance; - - bool bRemoved; - bool bRemoved2; - bool bCast; - bool bCast2; + SetCombatMovement(false); } - public override CreatureAI GetAI(Creature creature) + public override void Reset() { } + + public override void EnterCombat(Unit who) { } + + public override void AttackStart(Unit victim) { } + + public override void MoveInLineOfSight(Unit who) { } + + public override void UpdateAI(uint diff) { - return GetInstanceAI(creature); + if (!bRemoved && me.GetPositionX() > 440.0f) + { + if (instance.GetBossState(DataTypes.PrinceTaldaram) == EncounterState.Done) + { + me.InterruptNonMeleeSpells(true); + bRemoved = true; + return; + } + if (!bCast) + { + //DoCast(me, JedogaShadowseekerConst.SpellBeamVisualJedogasAufseher1, false); + bCast = true; + } + } + if (!bRemoved2 && me.GetPositionX() < 440.0f) + { + if (!bCast2 && instance.GetData(DataTypes.JedogaTriggerSwitch) != 0) + { + //DoCast(me, JedogaShadowseekerConst.SpellBeamVisualJedogasAufseher2, false); + bCast2 = true; + } + if (bCast2 && instance.GetData(DataTypes.JedogaTriggerSwitch) == 0) + { + me.InterruptNonMeleeSpells(true); + bCast2 = false; + } + if (!bRemoved2 && instance.GetBossState(DataTypes.JedogaShadowseeker) == EncounterState.Done) + { + me.InterruptNonMeleeSpells(true); + bRemoved2 = true; + } + } } + + InstanceScript instance; + + bool bRemoved; + bool bRemoved2; + bool bCast; + bool bCast2; } [Script] diff --git a/Scripts/Northrend/AzjolNerub/Ahnkahet/BossPrinceTaldaram.cs b/Scripts/Northrend/AzjolNerub/Ahnkahet/BossPrinceTaldaram.cs index db1101c31..be83abe40 100644 --- a/Scripts/Northrend/AzjolNerub/Ahnkahet/BossPrinceTaldaram.cs +++ b/Scripts/Northrend/AzjolNerub/Ahnkahet/BossPrinceTaldaram.cs @@ -82,303 +82,283 @@ namespace Scripts.Northrend.AzjolNerub.Ahnkahet.PrinceTaldaram } [Script] - class boss_prince_taldaram : CreatureScript + public class boss_prince_taldaram : BossAI { - public boss_prince_taldaram() : base("boss_prince_taldaram") { } - - public class boss_prince_taldaramAI : BossAI + public boss_prince_taldaram(Creature creature) : base(creature, DataTypes.PrinceTaldaram) { - public boss_prince_taldaramAI(Creature creature) : base(creature, DataTypes.PrinceTaldaram) + me.SetDisableGravity(true); + _embraceTakenDamage = 0; + } + + public override void Reset() + { + _Reset(); + _flameSphereTargetGUID.Clear(); + _embraceTargetGUID.Clear(); + _embraceTakenDamage = 0; + } + + public override void EnterCombat(Unit who) + { + _EnterCombat(); + Talk(TextIds.SayAggro); + _events.ScheduleEvent(Misc.EventBloodthirst, 10000); + _events.ScheduleEvent(Misc.EventVanish, RandomHelper.URand(25000, 35000)); + _events.ScheduleEvent(Misc.EventConjureFlameSpheres, 5000); + } + + public override void JustSummoned(Creature summon) + { + base.JustSummoned(summon); + + switch (summon.GetEntry()) { - me.SetDisableGravity(true); - _embraceTakenDamage = 0; + case CreatureIds.FlameSphere1: + case CreatureIds.FlameSphere2: + case CreatureIds.FlameSphere3: + summon.GetAI().SetGUID(_flameSphereTargetGUID); + break; } + } - public override void Reset() + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _events.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + _events.ExecuteEvents(eventId => { - _Reset(); - _flameSphereTargetGUID.Clear(); - _embraceTargetGUID.Clear(); - _embraceTakenDamage = 0; - } - - public override void EnterCombat(Unit who) - { - _EnterCombat(); - Talk(TextIds.SayAggro); - _events.ScheduleEvent(Misc.EventBloodthirst, 10000); - _events.ScheduleEvent(Misc.EventVanish, RandomHelper.URand(25000, 35000)); - _events.ScheduleEvent(Misc.EventConjureFlameSpheres, 5000); - } - - public override void JustSummoned(Creature summon) - { - base.JustSummoned(summon); - - switch (summon.GetEntry()) + switch (eventId) { - case CreatureIds.FlameSphere1: - case CreatureIds.FlameSphere2: - case CreatureIds.FlameSphere3: - summon.GetAI().SetGUID(_flameSphereTargetGUID); + case Misc.EventBloodthirst: + DoCast(me, SpellIds.Bloodthirst); + _events.ScheduleEvent(Misc.EventBloodthirst, 10000); + break; + case Misc.EventConjureFlameSpheres: + // random target? + Unit victim = me.GetVictim(); + if (victim) + { + _flameSphereTargetGUID = victim.GetGUID(); + DoCast(victim, SpellIds.ConjureFlameSphere); + } + _events.ScheduleEvent(Misc.EventConjureFlameSpheres, 15000); + break; + case Misc.EventVanish: + { + var players = me.GetMap().GetPlayers(); + uint targets = 0; + foreach (var player in players) + { + if (player && player.IsAlive()) + ++targets; + } + + if (targets > 2) + { + Talk(TextIds.SayVanish); + DoCast(me, SpellIds.Vanish); + me.SetInCombatState(true); // Prevents the boss from resetting + _events.DelayEvents(500); + _events.ScheduleEvent(Misc.EventJustVanished, 500); + Unit embraceTarget = SelectTarget(SelectAggroTarget.Random, 0, 100.0f, true); + if (embraceTarget) + _embraceTargetGUID = embraceTarget.GetGUID(); + } + _events.ScheduleEvent(Misc.EventVanish, RandomHelper.URand(25000, 35000)); + break; + } + case Misc.EventJustVanished: + { + Unit embraceTarget = GetEmbraceTarget(); + if (embraceTarget) + { + me.GetMotionMaster().Clear(); + me.SetSpeedRate(UnitMoveType.Walk, 2.0f); + me.GetMotionMaster().MoveChase(embraceTarget); + } + _events.ScheduleEvent(Misc.EventVanished, 1300); + } + break; + case Misc.EventVanished: + { + Unit embraceTarget = GetEmbraceTarget(); + if (embraceTarget) + DoCast(embraceTarget, SpellIds.EmbraceOfTheVampyr); + Talk(TextIds.SayFeed); + me.GetMotionMaster().Clear(); + me.SetSpeedRate(UnitMoveType.Walk, 1.0f); + me.GetMotionMaster().MoveChase(me.GetVictim()); + _events.ScheduleEvent(Misc.EventFeeding, 20000); + } + break; + case Misc.EventFeeding: + _embraceTargetGUID.Clear(); + break; + default: break; } - } + }); - public override void UpdateAI(uint diff) + DoMeleeAttackIfReady(); + } + + public override void DamageTaken(Unit doneBy, ref uint damage) + { + Unit embraceTarget = GetEmbraceTarget(); + + if (embraceTarget && embraceTarget.IsAlive()) { - if (!UpdateVictim()) - return; - - _events.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - _events.ExecuteEvents(eventId => + _embraceTakenDamage += damage; + if (_embraceTakenDamage > DungeonMode(Misc.DataEmbraceDmg, Misc.DataEmbraceDmgH)) { - switch (eventId) - { - case Misc.EventBloodthirst: - DoCast(me, SpellIds.Bloodthirst); - _events.ScheduleEvent(Misc.EventBloodthirst, 10000); - break; - case Misc.EventConjureFlameSpheres: - // random target? - Unit victim = me.GetVictim(); - if (victim) - { - _flameSphereTargetGUID = victim.GetGUID(); - DoCast(victim, SpellIds.ConjureFlameSphere); - } - _events.ScheduleEvent(Misc.EventConjureFlameSpheres, 15000); - break; - case Misc.EventVanish: - { - var players = me.GetMap().GetPlayers(); - uint targets = 0; - foreach (var player in players) - { - if (player && player.IsAlive()) - ++targets; - } - - if (targets > 2) - { - Talk(TextIds.SayVanish); - DoCast(me, SpellIds.Vanish); - me.SetInCombatState(true); // Prevents the boss from resetting - _events.DelayEvents(500); - _events.ScheduleEvent(Misc.EventJustVanished, 500); - Unit embraceTarget = SelectTarget(SelectAggroTarget.Random, 0, 100.0f, true); - if (embraceTarget) - _embraceTargetGUID = embraceTarget.GetGUID(); - } - _events.ScheduleEvent(Misc.EventVanish, RandomHelper.URand(25000, 35000)); - break; - } - case Misc.EventJustVanished: - { - Unit embraceTarget = GetEmbraceTarget(); - if (embraceTarget) - { - me.GetMotionMaster().Clear(); - me.SetSpeedRate(UnitMoveType.Walk, 2.0f); - me.GetMotionMaster().MoveChase(embraceTarget); - } - _events.ScheduleEvent(Misc.EventVanished, 1300); - } - break; - case Misc.EventVanished: - { - Unit embraceTarget = GetEmbraceTarget(); - if (embraceTarget) - DoCast(embraceTarget, SpellIds.EmbraceOfTheVampyr); - Talk(TextIds.SayFeed); - me.GetMotionMaster().Clear(); - me.SetSpeedRate(UnitMoveType.Walk, 1.0f); - me.GetMotionMaster().MoveChase(me.GetVictim()); - _events.ScheduleEvent(Misc.EventFeeding, 20000); - } - break; - case Misc.EventFeeding: - _embraceTargetGUID.Clear(); - break; - default: - break; - } - }); - - DoMeleeAttackIfReady(); - } - - public override void DamageTaken(Unit doneBy, ref uint damage) - { - Unit embraceTarget = GetEmbraceTarget(); - - if (embraceTarget && embraceTarget.IsAlive()) - { - _embraceTakenDamage += damage; - if (_embraceTakenDamage > DungeonMode(Misc.DataEmbraceDmg, Misc.DataEmbraceDmgH)) - { - _embraceTargetGUID.Clear(); - me.CastStop(); - } - } - } - - public override void JustDied(Unit killer) - { - Talk(TextIds.SayDeath); - _JustDied(); - } - - public override void KilledUnit(Unit victim) - { - if (!victim.IsTypeId(TypeId.Player)) - return; - - if (victim.GetGUID() == _embraceTargetGUID) _embraceTargetGUID.Clear(); - - Talk(TextIds.SaySlay); - } - - public bool CheckSpheres() - { - for (byte i = 0; i < 2; ++i) - { - if (instance.GetData(DataTypes.Sphere1 + i) == 0) - return false; + me.CastStop(); } - - RemovePrison(); - return true; } - - Unit GetEmbraceTarget() - { - if (!_embraceTargetGUID.IsEmpty()) - return Global.ObjAccessor.GetUnit(me, _embraceTargetGUID); - - return null; - } - - void RemovePrison() - { - me.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable); - me.RemoveAurasDueToSpell(SpellIds.BeamVisual); - me.SetHomePosition(me.GetPositionX(), me.GetPositionY(), Misc.DataGroundPositionZ, me.GetOrientation()); - DoCast(SpellIds.HoverFall); - me.SetDisableGravity(false); - me.GetMotionMaster().MoveLand(0, me.GetHomePosition()); - Talk(TextIds.SayWarning); - instance.HandleGameObject(instance.GetGuidData(DataTypes.PrinceTaldaramPlatform), true); - } - - ObjectGuid _flameSphereTargetGUID; - ObjectGuid _embraceTargetGUID; - uint _embraceTakenDamage; } - public override CreatureAI GetAI(Creature creature) + public override void JustDied(Unit killer) { - return GetInstanceAI(creature); + Talk(TextIds.SayDeath); + _JustDied(); } + + public override void KilledUnit(Unit victim) + { + if (!victim.IsTypeId(TypeId.Player)) + return; + + if (victim.GetGUID() == _embraceTargetGUID) + _embraceTargetGUID.Clear(); + + Talk(TextIds.SaySlay); + } + + public bool CheckSpheres() + { + for (byte i = 0; i < 2; ++i) + { + if (instance.GetData(DataTypes.Sphere1 + i) == 0) + return false; + } + + RemovePrison(); + return true; + } + + Unit GetEmbraceTarget() + { + if (!_embraceTargetGUID.IsEmpty()) + return Global.ObjAccessor.GetUnit(me, _embraceTargetGUID); + + return null; + } + + void RemovePrison() + { + me.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable); + me.RemoveAurasDueToSpell(SpellIds.BeamVisual); + me.SetHomePosition(me.GetPositionX(), me.GetPositionY(), Misc.DataGroundPositionZ, me.GetOrientation()); + DoCast(SpellIds.HoverFall); + me.SetDisableGravity(false); + me.GetMotionMaster().MoveLand(0, me.GetHomePosition()); + Talk(TextIds.SayWarning); + instance.HandleGameObject(instance.GetGuidData(DataTypes.PrinceTaldaramPlatform), true); + } + + ObjectGuid _flameSphereTargetGUID; + ObjectGuid _embraceTargetGUID; + uint _embraceTakenDamage; } - + [Script] // 30106, 31686, 31687 - Flame Sphere - class npc_prince_taldaram_flame_sphere : CreatureScript + class npc_prince_taldaram_flame_sphere : ScriptedAI { - public npc_prince_taldaram_flame_sphere() : base("npc_prince_taldaram_flame_sphere") { } - - class npc_prince_taldaram_flame_sphereAI : ScriptedAI + public npc_prince_taldaram_flame_sphere(Creature creature) : base(creature) { - public npc_prince_taldaram_flame_sphereAI(Creature creature) : base(creature) + } + + public override void Reset() + { + DoCast(me, SpellIds.FlameSphereSpawnEffect, true); + DoCast(me, SpellIds.FlameSphereVisual, true); + + _flameSphereTargetGUID.Clear(); + _events.Reset(); + _events.ScheduleEvent(Misc.EventStartMove, 3 * Time.InMilliseconds); + _events.ScheduleEvent(Misc.EventDespawn, 13 * Time.InMilliseconds); + } + + public override void SetGUID(ObjectGuid guid, int id = 0) + { + _flameSphereTargetGUID = guid; + } + + public override void EnterCombat(Unit who) { } + + public override void MoveInLineOfSight(Unit who) { } + + public override void UpdateAI(uint diff) + { + _events.Update(diff); + + _events.ExecuteEvents(eventId => { - } - - public override void Reset() - { - DoCast(me, SpellIds.FlameSphereSpawnEffect, true); - DoCast(me, SpellIds.FlameSphereVisual, true); - - _flameSphereTargetGUID.Clear(); - _events.Reset(); - _events.ScheduleEvent(Misc.EventStartMove, 3 * Time.InMilliseconds); - _events.ScheduleEvent(Misc.EventDespawn, 13 * Time.InMilliseconds); - } - - public override void SetGUID(ObjectGuid guid, int id = 0) - { - _flameSphereTargetGUID = guid; - } - - public override void EnterCombat(Unit who) { } - - public override void MoveInLineOfSight(Unit who) { } - - public override void UpdateAI(uint diff) - { - _events.Update(diff); - - _events.ExecuteEvents(eventId => + switch (eventId) { - switch (eventId) - { - case Misc.EventStartMove: + case Misc.EventStartMove: + { + DoCast(me, SpellIds.FlameSpherePeriodic, true); + + /// @todo: find correct values + float angleOffset = 0.0f; + float distOffset = Misc.DataSphereDistance; + + switch (me.GetEntry()) { - DoCast(me, SpellIds.FlameSpherePeriodic, true); - - /// @todo: find correct values - float angleOffset = 0.0f; - float distOffset = Misc.DataSphereDistance; - - switch (me.GetEntry()) - { - case CreatureIds.FlameSphere1: - break; - case CreatureIds.FlameSphere2: - angleOffset = Misc.DataSphereAngleOffset; - break; - case CreatureIds.FlameSphere3: - angleOffset = -Misc.DataSphereAngleOffset; - break; - default: - return; - } - - Unit sphereTarget = Global.ObjAccessor.GetUnit(me, _flameSphereTargetGUID); - if (!sphereTarget) + case CreatureIds.FlameSphere1: + break; + case CreatureIds.FlameSphere2: + angleOffset = Misc.DataSphereAngleOffset; + break; + case CreatureIds.FlameSphere3: + angleOffset = -Misc.DataSphereAngleOffset; + break; + default: return; - - float angle = me.GetAngle(sphereTarget) + angleOffset; - float x = me.GetPositionX() + distOffset * (float)Math.Cos(angle); - float y = me.GetPositionY() + distOffset * (float)Math.Sin(angle); - - /// @todo: correct speed - me.GetMotionMaster().MovePoint(0, x, y, me.GetPositionZ()); - break; } - case Misc.EventDespawn: - DoCast(me, SpellIds.FlameSphereDeathEffect, true); - me.DespawnOrUnsummon(1000); - break; - default: - break; - } - }); - } - ObjectGuid _flameSphereTargetGUID; + Unit sphereTarget = Global.ObjAccessor.GetUnit(me, _flameSphereTargetGUID); + if (!sphereTarget) + return; + + float angle = me.GetAngle(sphereTarget) + angleOffset; + float x = me.GetPositionX() + distOffset * (float)Math.Cos(angle); + float y = me.GetPositionY() + distOffset * (float)Math.Sin(angle); + + /// @todo: correct speed + me.GetMotionMaster().MovePoint(0, x, y, me.GetPositionZ()); + break; + } + case Misc.EventDespawn: + DoCast(me, SpellIds.FlameSphereDeathEffect, true); + me.DespawnOrUnsummon(1000); + break; + default: + break; + } + }); } - public override CreatureAI GetAI(Creature creature) - { - return new npc_prince_taldaram_flame_sphereAI(creature); - } + ObjectGuid _flameSphereTargetGUID; } - + [Script] // 193093, 193094 - Ancient Nerubian Device class go_prince_taldaram_sphere : GameObjectScript { @@ -408,69 +388,49 @@ namespace Scripts.Northrend.AzjolNerub.Ahnkahet.PrinceTaldaram break; } - PrinceTaldaram.GetAI().CheckSpheres(); + PrinceTaldaram.GetAI().CheckSpheres(); } return true; } } - + [Script] // 55931 - Conjure Flame Sphere - class spell_prince_taldaram_conjure_flame_sphere : SpellScriptLoader + class spell_prince_taldaram_conjure_flame_sphere : SpellScript { - public spell_prince_taldaram_conjure_flame_sphere() : base("spell_prince_taldaram_conjure_flame_sphere") { } - - class spell_prince_taldaram_conjure_flame_sphere_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.FlameSphereSummon1, SpellIds.FlameSphereSummon2, SpellIds.FlameSphereSummon3); - } + return ValidateSpellInfo(SpellIds.FlameSphereSummon1, SpellIds.FlameSphereSummon2, SpellIds.FlameSphereSummon3); + } - void HandleScript(uint effIndex) - { - Unit caster = GetCaster(); - caster.CastSpell(caster, SpellIds.FlameSphereSummon1, true); + void HandleScript(uint effIndex) + { + Unit caster = GetCaster(); + caster.CastSpell(caster, SpellIds.FlameSphereSummon1, true); - if (caster.GetMap().IsHeroic()) - { - caster.CastSpell(caster, SpellIds.FlameSphereSummon2, true); - caster.CastSpell(caster, SpellIds.FlameSphereSummon3, true); - } - } - - public override void Register() + if (caster.GetMap().IsHeroic()) { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.Dummy)); + caster.CastSpell(caster, SpellIds.FlameSphereSummon2, true); + caster.CastSpell(caster, SpellIds.FlameSphereSummon3, true); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_prince_taldaram_conjure_flame_sphere_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.Dummy)); } } - + [Script] // 55895, 59511, 59512 - Flame Sphere Summon - class spell_prince_taldaram_flame_sphere_summon : SpellScriptLoader + class spell_prince_taldaram_flame_sphere_summon : SpellScript { - public spell_prince_taldaram_flame_sphere_summon() : base("spell_prince_taldaram_flame_sphere_summon") { } - - class spell_prince_taldaram_flame_sphere_summon_SpellScript : SpellScript + void SetDest(ref SpellDestination dest) { - void SetDest(ref SpellDestination dest) - { - dest.RelocateOffset(new Position(0.0f, 0.0f, 5.5f, 0.0f)); - } - - public override void Register() - { - OnDestinationTargetSelect.Add(new DestinationTargetSelectHandler(SetDest, 0, Targets.DestCaster)); - } + dest.RelocateOffset(new Position(0.0f, 0.0f, 5.5f, 0.0f)); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_prince_taldaram_flame_sphere_summon_SpellScript(); + OnDestinationTargetSelect.Add(new DestinationTargetSelectHandler(SetDest, 0, Targets.DestCaster)); } } } diff --git a/Scripts/Northrend/AzjolNerub/Ahnkahet/InstanceAhnahet.cs b/Scripts/Northrend/AzjolNerub/Ahnkahet/InstanceAhnahet.cs index 56635d705..d1273dc90 100644 --- a/Scripts/Northrend/AzjolNerub/Ahnkahet/InstanceAhnahet.cs +++ b/Scripts/Northrend/AzjolNerub/Ahnkahet/InstanceAhnahet.cs @@ -23,6 +23,59 @@ using System.Collections.Generic; namespace Scripts.Northrend.AzjolNerub.Ahnkahet { + struct DataTypes + { + // Encounter States/Boss GUIDs + public const uint ElderNadox = 0; + public const uint PrinceTaldaram = 1; + public const uint JedogaShadowseeker = 2; + public const uint Amanitar = 3; + public const uint HeraldVolazj = 4; + + // Additional Data + public const uint Sphere1 = 5; + public const uint Sphere2 = 6; + public const uint PrinceTaldaramPlatform = 7; + public const uint PlJedogaTarget = 8; + public const uint AddJedogaVictim = 9; + public const uint AddJedogaInitiand = 10; + public const uint JedogaTriggerSwitch = 11; + public const uint JedogaResetInitiands = 12; + public const uint AllInitiandDead = 13; + } + + struct AKCreatureIds + { + public const uint ElderNadox = 29309; + public const uint PrinceTaldaram = 29308; + public const uint JedogaShadowseeker = 29310; + public const uint Amanitar = 30258; + public const uint HeraldVolazj = 29311; + + // Elder Nadox + public const uint AhnkaharGuardian = 30176; + public const uint AhnkaharSwarmer = 30178; + + // Jedoga Shadowseeker + public const uint Initiand = 30114; + public const uint JedogaController = 30181; + + // Herald Volazj + //public const uint TwistedVisage1 = 30621, + //public const uint TwistedVisage2 = 30622, + //public const uint TwistedVisage3 = 30623, + //public const uint TwistedVisage4 = 30624, + public const uint TwistedVisage = 30625; + } + + struct GameObjectIds + { + public const uint PrinceTaldaramGate = 192236; + public const uint PrinceTaldaramPlatform = 193564; + public const uint Sphere1 = 193093; + public const uint Sphere2 = 193094; + } + [Script] class instance_ahnkahet : InstanceMapScript { @@ -151,7 +204,7 @@ namespace Scripts.Northrend.AzjolNerub.Ahnkahet case DataTypes.Sphere1: case DataTypes.Sphere2: return SpheresState[type - DataTypes.Sphere1]; - case DataTypes.AllInitiandDead: + case DataTypes.AllInitiandDead: foreach (ObjectGuid guid in InitiandGUIDs) { Creature cr = instance.GetCreature(guid); @@ -278,57 +331,4 @@ namespace Scripts.Northrend.AzjolNerub.Ahnkahet return new instance_ahnkahet_InstanceScript(map); } } - - struct DataTypes - { - // Encounter States/Boss GUIDs - public const uint ElderNadox = 0; - public const uint PrinceTaldaram = 1; - public const uint JedogaShadowseeker = 2; - public const uint Amanitar = 3; - public const uint HeraldVolazj = 4; - - // Additional Data - public const uint Sphere1 = 5; - public const uint Sphere2 = 6; - public const uint PrinceTaldaramPlatform = 7; - public const uint PlJedogaTarget = 8; - public const uint AddJedogaVictim = 9; - public const uint AddJedogaInitiand = 10; - public const uint JedogaTriggerSwitch = 11; - public const uint JedogaResetInitiands = 12; - public const uint AllInitiandDead = 13; - } - - struct AKCreatureIds - { - public const uint ElderNadox = 29309; - public const uint PrinceTaldaram = 29308; - public const uint JedogaShadowseeker = 29310; - public const uint Amanitar = 30258; - public const uint HeraldVolazj = 29311; - - // Elder Nadox - public const uint AhnkaharGuardian = 30176; - public const uint AhnkaharSwarmer = 30178; - - // Jedoga Shadowseeker - public const uint Initiand = 30114; - public const uint JedogaController = 30181; - - // Herald Volazj - //public const uint TwistedVisage1 = 30621, - //public const uint TwistedVisage2 = 30622, - //public const uint TwistedVisage3 = 30623, - //public const uint TwistedVisage4 = 30624, - public const uint TwistedVisage = 30625; - } - - struct GameObjectIds - { - public const uint PrinceTaldaramGate = 192236; - public const uint PrinceTaldaramPlatform = 193564; - public const uint Sphere1 = 193093; - public const uint Sphere2 = 193094; - } } diff --git a/Scripts/Northrend/AzjolNerub/AzjolNerub/BossAnubarak.cs b/Scripts/Northrend/AzjolNerub/AzjolNerub/BossAnubarak.cs index 937627ce5..8eea2a6f6 100644 --- a/Scripts/Northrend/AzjolNerub/AzjolNerub/BossAnubarak.cs +++ b/Scripts/Northrend/AzjolNerub/AzjolNerub/BossAnubarak.cs @@ -54,7 +54,7 @@ namespace Scripts.Northrend.AzjolNerub.AzjolNerub.Anubarak struct CreatureIds { - public const uint WorldTrigger = 22515; + public const uint WorldTrigger = 22515; } struct TextIds @@ -98,315 +98,305 @@ namespace Scripts.Northrend.AzjolNerub.AzjolNerub.Anubarak } [Script] - class boss_anub_arak : CreatureScript + class boss_anub_arak : BossAI { - public boss_anub_arak() : base("boss_anub_arak") { } + public boss_anub_arak(Creature creature) : base(creature, ANDataTypes.Anubarak) { } - class boss_anub_arakAI : BossAI + public override void Reset() { - public boss_anub_arakAI(Creature creature) : base(creature, ANDataTypes.Anubarak) { } + base.Reset(); + me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); + instance.DoStopCriteriaTimer(CriteriaTimedTypes.Event, Misc.AchievGottaGoStartEvent); + _nextSubmerge = 75; + _petCount = 0; + } - public override void Reset() + public override void EnterCombat(Unit who) + { + base.EnterCombat(who); + + GameObject door = instance.GetGameObject(ANDataTypes.AnubarakWall); + if (door) + door.SetGoState(GameObjectState.Active); // open door for now + + Talk(TextIds.SayAggro); + instance.DoStartCriteriaTimer(CriteriaTimedTypes.Event, Misc.AchievGottaGoStartEvent); + + _events.SetPhase(Misc.PhaseEmerge); + _events.ScheduleEvent(EventIds.CloseDoor, TimeSpan.FromSeconds(5)); + _events.ScheduleEvent(EventIds.Pound, TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(4), 0, Misc.PhaseEmerge); + _events.ScheduleEvent(EventIds.LeechingSwarm, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(7), 0, Misc.PhaseEmerge); + _events.ScheduleEvent(EventIds.CarrionBeetles, TimeSpan.FromSeconds(14), TimeSpan.FromSeconds(17), 0, Misc.PhaseEmerge); + + // set up world triggers + List summoned; + me.SummonCreatureGroup(Misc.SummonGroupWorldTriggerGuardian, out summoned); + if (summoned.Empty()) // something went wrong { - base.Reset(); - me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); - instance.DoStopCriteriaTimer(CriteriaTimedTypes.Event, Misc.AchievGottaGoStartEvent); - _nextSubmerge = 75; - _petCount = 0; + EnterEvadeMode(EvadeReason.Other); + return; } + _guardianTrigger = summoned.First().GetGUID(); - public override void EnterCombat(Unit who) + Creature trigger = DoSummon(CreatureIds.WorldTrigger, me.GetPosition(), 0u, TempSummonType.ManualDespawn); + if (trigger) + _assassinTrigger = trigger.GetGUID(); + else { - base.EnterCombat(who); + EnterEvadeMode(EvadeReason.Other); + return; + } + } - GameObject door = instance.GetGameObject(ANDataTypes.AnubarakWall); - if (door) - door.SetGoState(GameObjectState.Active); // open door for now + public override void EnterEvadeMode(EvadeReason why) + { + summons.DespawnAll(); + _DespawnAtEvade(); + } - Talk(TextIds.SayAggro); - instance.DoStartCriteriaTimer(CriteriaTimedTypes.Event, Misc.AchievGottaGoStartEvent); + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; - _events.SetPhase(Misc.PhaseEmerge); - _events.ScheduleEvent(EventIds.CloseDoor, TimeSpan.FromSeconds(5)); - _events.ScheduleEvent(EventIds.Pound, TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(4), 0, Misc.PhaseEmerge); - _events.ScheduleEvent(EventIds.LeechingSwarm, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(7), 0, Misc.PhaseEmerge); - _events.ScheduleEvent(EventIds.CarrionBeetles, TimeSpan.FromSeconds(14), TimeSpan.FromSeconds(17), 0, Misc.PhaseEmerge); + _events.Update(diff); - // set up world triggers - List summoned; - me.SummonCreatureGroup(Misc.SummonGroupWorldTriggerGuardian, out summoned); - if (summoned.Empty()) // something went wrong + if (me.HasUnitState(UnitState.Casting)) + return; + + _events.ExecuteEvents(eventId => + { + switch (eventId) { - EnterEvadeMode(EvadeReason.Other); - return; - } - _guardianTrigger = summoned.First().GetGUID(); - - Creature trigger = DoSummon(CreatureIds.WorldTrigger, me.GetPosition(), 0u, TempSummonType.ManualDespawn); - if (trigger) - _assassinTrigger = trigger.GetGUID(); - else - { - EnterEvadeMode(EvadeReason.Other); - return; - } - } - - public override void EnterEvadeMode(EvadeReason why) - { - summons.DespawnAll(); - _DespawnAtEvade(); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _events.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case EventIds.CloseDoor: - GameObject door = instance.GetGameObject(ANDataTypes.AnubarakWall); - if (door) - door.SetGoState(GameObjectState.Ready); - break; - case EventIds.Pound: - DoCastVictim(SpellIds.Pound); - _events.Repeat(TimeSpan.FromSeconds(26), TimeSpan.FromSeconds(32)); - break; - case EventIds.LeechingSwarm: - Talk(TextIds.SayLocust); - DoCastAOE(SpellIds.LeechingSwarm); - _events.Repeat(TimeSpan.FromSeconds(25), TimeSpan.FromSeconds(28)); - break; - case EventIds.CarrionBeetles: - DoCastAOE(SpellIds.CarrionBeetles); - _events.Repeat(TimeSpan.FromSeconds(24), TimeSpan.FromSeconds(27)); - break; - case EventIds.Impale: - Creature impaleTarget = ObjectAccessor.GetCreature(me, _impaleTarget); - if (impaleTarget) - DoCast(impaleTarget, SpellIds.ImpaleDamage, true); - break; - case EventIds.Submerge: - Talk(TextIds.SaySubmerge); - DoCastSelf(SpellIds.Submerge); - break; - case EventIds.Darter: - { - List triggers = new List(); - me.GetCreatureListWithEntryInGrid(triggers, CreatureIds.WorldTrigger); - if (!triggers.Empty()) - { - var it = triggers.SelectRandom(); - it.CastSpell(it, SpellIds.SummonDarter, true); - _events.Repeat(TimeSpan.FromSeconds(11)); - } - else - EnterEvadeMode(EvadeReason.Other); - break; - } - case EventIds.Assassin: - { - Creature trigger = ObjectAccessor.GetCreature(me, _assassinTrigger); - if (trigger) - { - trigger.CastSpell(trigger, SpellIds.SummonAssassin, true); - trigger.CastSpell(trigger, SpellIds.SummonAssassin, true); - if (_assassinCount > 2) - { - _assassinCount -= 2; - _events.Repeat(TimeSpan.FromSeconds(20)); - } - else - _assassinCount = 0; - } - else // something went wrong - EnterEvadeMode(EvadeReason.Other); - break; - } - case EventIds.Guardian: - { - Creature trigger = ObjectAccessor.GetCreature(me, _guardianTrigger); - if (trigger) - { - trigger.CastSpell(trigger, SpellIds.SummonGuardian, true); - trigger.CastSpell(trigger, SpellIds.SummonGuardian, true); - if (_guardianCount > 2) - { - _guardianCount -= 2; - _events.Repeat(TimeSpan.FromSeconds(20)); - } - else - _guardianCount = 0; - } - else - EnterEvadeMode(EvadeReason.Other); - } - break; - case EventIds.Venomancer: - { - Creature trigger = ObjectAccessor.GetCreature(me, _guardianTrigger); - if (trigger) - { - trigger.CastSpell(trigger, SpellIds.SummonVenomancer, true); - trigger.CastSpell(trigger, SpellIds.SummonVenomancer, true); - if (_venomancerCount > 2) - { - _venomancerCount -= 2; - _events.Repeat(TimeSpan.FromSeconds(20)); - } - else - _venomancerCount = 0; - } - else - EnterEvadeMode(EvadeReason.Other); - } - break; - default: - break; - } - - if (me.HasUnitState(UnitState.Casting)) - return; - }); - - - DoMeleeAttackIfReady(); - } - - public override void JustDied(Unit killer) - { - _JustDied(); - Talk(TextIds.SayDeath); - } - - public override void KilledUnit(Unit victim) - { - if (victim.IsTypeId(TypeId.Player)) - Talk(TextIds.SaySlay); - } - - public override void SetGUID(ObjectGuid guid, int type) - { - switch (type) - { - case Misc.GuidTypePet: + case EventIds.CloseDoor: + GameObject door = instance.GetGameObject(ANDataTypes.AnubarakWall); + if (door) + door.SetGoState(GameObjectState.Ready); + break; + case EventIds.Pound: + DoCastVictim(SpellIds.Pound); + _events.Repeat(TimeSpan.FromSeconds(26), TimeSpan.FromSeconds(32)); + break; + case EventIds.LeechingSwarm: + Talk(TextIds.SayLocust); + DoCastAOE(SpellIds.LeechingSwarm); + _events.Repeat(TimeSpan.FromSeconds(25), TimeSpan.FromSeconds(28)); + break; + case EventIds.CarrionBeetles: + DoCastAOE(SpellIds.CarrionBeetles); + _events.Repeat(TimeSpan.FromSeconds(24), TimeSpan.FromSeconds(27)); + break; + case EventIds.Impale: + Creature impaleTarget = ObjectAccessor.GetCreature(me, _impaleTarget); + if (impaleTarget) + DoCast(impaleTarget, SpellIds.ImpaleDamage, true); + break; + case EventIds.Submerge: + Talk(TextIds.SaySubmerge); + DoCastSelf(SpellIds.Submerge); + break; + case EventIds.Darter: { - Creature creature = ObjectAccessor.GetCreature(me, guid); - if (creature) - JustSummoned(creature); - else // something has gone horribly wrong + List triggers = new List(); + me.GetCreatureListWithEntryInGrid(triggers, CreatureIds.WorldTrigger); + if (!triggers.Empty()) + { + var it = triggers.SelectRandom(); + it.CastSpell(it, SpellIds.SummonDarter, true); + _events.Repeat(TimeSpan.FromSeconds(11)); + } + else EnterEvadeMode(EvadeReason.Other); break; } - case Misc.GuidTypeImpale: - _impaleTarget = guid; - _events.ScheduleEvent(EventIds.Impale, TimeSpan.FromSeconds(4)); - break; - } - } - - public override void DoAction(int action) - { - switch (action) - { - case Misc.ActionPetDied: - if (_petCount == 0) // underflow check - something has gone horribly wrong + case EventIds.Assassin: { - EnterEvadeMode(EvadeReason.Other); - return; + Creature trigger = ObjectAccessor.GetCreature(me, _assassinTrigger); + if (trigger) + { + trigger.CastSpell(trigger, SpellIds.SummonAssassin, true); + trigger.CastSpell(trigger, SpellIds.SummonAssassin, true); + if (_assassinCount > 2) + { + _assassinCount -= 2; + _events.Repeat(TimeSpan.FromSeconds(20)); + } + else + _assassinCount = 0; + } + else // something went wrong + EnterEvadeMode(EvadeReason.Other); + break; } - if (--_petCount == 0) // last pet died, emerge + case EventIds.Guardian: { - me.RemoveAurasDueToSpell(SpellIds.Submerge); - me.RemoveAurasDueToSpell(SpellIds.ImpaleAura); - me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); - DoCastSelf(SpellIds.Emerge); - _events.SetPhase(Misc.PhaseEmerge); - _events.ScheduleEvent(EventIds.Pound, TimeSpan.FromSeconds(13), TimeSpan.FromSeconds(18), 0, Misc.PhaseEmerge); - _events.ScheduleEvent(EventIds.LeechingSwarm, TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(7), 0, Misc.PhaseEmerge); - _events.ScheduleEvent(EventIds.CarrionBeetles, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(15), 0, Misc.PhaseEmerge); + Creature trigger = ObjectAccessor.GetCreature(me, _guardianTrigger); + if (trigger) + { + trigger.CastSpell(trigger, SpellIds.SummonGuardian, true); + trigger.CastSpell(trigger, SpellIds.SummonGuardian, true); + if (_guardianCount > 2) + { + _guardianCount -= 2; + _events.Repeat(TimeSpan.FromSeconds(20)); + } + else + _guardianCount = 0; + } + else + EnterEvadeMode(EvadeReason.Other); } break; - case Misc.ActionPetEvade: - EnterEvadeMode(EvadeReason.Other); + case EventIds.Venomancer: + { + Creature trigger = ObjectAccessor.GetCreature(me, _guardianTrigger); + if (trigger) + { + trigger.CastSpell(trigger, SpellIds.SummonVenomancer, true); + trigger.CastSpell(trigger, SpellIds.SummonVenomancer, true); + if (_venomancerCount > 2) + { + _venomancerCount -= 2; + _events.Repeat(TimeSpan.FromSeconds(20)); + } + else + _venomancerCount = 0; + } + else + EnterEvadeMode(EvadeReason.Other); + } + break; + default: break; } - } - public override void DamageTaken(Unit source, ref uint damage) - { - if (me.HasAura(SpellIds.Submerge)) - damage = 0; - else - if (_nextSubmerge != 0 && me.HealthBelowPctDamaged((int)_nextSubmerge, damage)) - { - _events.CancelEvent(EventIds.Submerge); - _events.ScheduleEvent(EventIds.Submerge, 0, 0, Misc.PhaseEmerge); - _nextSubmerge = _nextSubmerge - 25; - } - } + if (me.HasUnitState(UnitState.Casting)) + return; + }); - public override void SpellHit(Unit whose, SpellInfo spell) - { - if (spell.Id == SpellIds.Submerge) - { - me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); - me.RemoveAurasDueToSpell(SpellIds.LeechingSwarm); - DoCastSelf(SpellIds.ImpaleAura, true); - _events.SetPhase(Misc.PhaseSubmerge); - switch (_nextSubmerge) - { - case 50: // first submerge phase - _assassinCount = 4; - _guardianCount = 2; - _venomancerCount = 0; - break; - case 25: // second submerge phase - _assassinCount = 6; - _guardianCount = 2; - _venomancerCount = 2; - break; - case 0: // third submerge phase - _assassinCount = 6; - _guardianCount = 2; - _venomancerCount = 2; - _events.ScheduleEvent(EventIds.Darter, TimeSpan.FromSeconds(0), 0, Misc.PhaseSubmerge); - break; - } - _petCount = (uint)(_guardianCount + _venomancerCount); - if (_assassinCount != 0) - _events.ScheduleEvent(EventIds.Assassin, TimeSpan.FromSeconds(0), 0, Misc.PhaseSubmerge); - if (_guardianCount != 0) - _events.ScheduleEvent(EventIds.Guardian, TimeSpan.FromSeconds(4), 0, Misc.PhaseSubmerge); - if (_venomancerCount != 0) - _events.ScheduleEvent(EventIds.Venomancer, TimeSpan.FromSeconds(20), 0, Misc.PhaseSubmerge); - } - } - - ObjectGuid _impaleTarget; - uint _nextSubmerge; - uint _petCount; - ObjectGuid _guardianTrigger; - ObjectGuid _assassinTrigger; - byte _assassinCount; - byte _guardianCount; - byte _venomancerCount; + DoMeleeAttackIfReady(); } - public override CreatureAI GetAI(Creature creature) + public override void JustDied(Unit killer) { - return GetInstanceAI(creature); + _JustDied(); + Talk(TextIds.SayDeath); } + + public override void KilledUnit(Unit victim) + { + if (victim.IsTypeId(TypeId.Player)) + Talk(TextIds.SaySlay); + } + + public override void SetGUID(ObjectGuid guid, int type) + { + switch (type) + { + case Misc.GuidTypePet: + { + Creature creature = ObjectAccessor.GetCreature(me, guid); + if (creature) + JustSummoned(creature); + else // something has gone horribly wrong + EnterEvadeMode(EvadeReason.Other); + break; + } + case Misc.GuidTypeImpale: + _impaleTarget = guid; + _events.ScheduleEvent(EventIds.Impale, TimeSpan.FromSeconds(4)); + break; + } + } + + public override void DoAction(int action) + { + switch (action) + { + case Misc.ActionPetDied: + if (_petCount == 0) // underflow check - something has gone horribly wrong + { + EnterEvadeMode(EvadeReason.Other); + return; + } + if (--_petCount == 0) // last pet died, emerge + { + me.RemoveAurasDueToSpell(SpellIds.Submerge); + me.RemoveAurasDueToSpell(SpellIds.ImpaleAura); + me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); + DoCastSelf(SpellIds.Emerge); + _events.SetPhase(Misc.PhaseEmerge); + _events.ScheduleEvent(EventIds.Pound, TimeSpan.FromSeconds(13), TimeSpan.FromSeconds(18), 0, Misc.PhaseEmerge); + _events.ScheduleEvent(EventIds.LeechingSwarm, TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(7), 0, Misc.PhaseEmerge); + _events.ScheduleEvent(EventIds.CarrionBeetles, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(15), 0, Misc.PhaseEmerge); + } + break; + case Misc.ActionPetEvade: + EnterEvadeMode(EvadeReason.Other); + break; + } + } + + public override void DamageTaken(Unit source, ref uint damage) + { + if (me.HasAura(SpellIds.Submerge)) + damage = 0; + else + if (_nextSubmerge != 0 && me.HealthBelowPctDamaged((int)_nextSubmerge, damage)) + { + _events.CancelEvent(EventIds.Submerge); + _events.ScheduleEvent(EventIds.Submerge, 0, 0, Misc.PhaseEmerge); + _nextSubmerge = _nextSubmerge - 25; + } + } + + public override void SpellHit(Unit whose, SpellInfo spell) + { + if (spell.Id == SpellIds.Submerge) + { + me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); + me.RemoveAurasDueToSpell(SpellIds.LeechingSwarm); + DoCastSelf(SpellIds.ImpaleAura, true); + + _events.SetPhase(Misc.PhaseSubmerge); + switch (_nextSubmerge) + { + case 50: // first submerge phase + _assassinCount = 4; + _guardianCount = 2; + _venomancerCount = 0; + break; + case 25: // second submerge phase + _assassinCount = 6; + _guardianCount = 2; + _venomancerCount = 2; + break; + case 0: // third submerge phase + _assassinCount = 6; + _guardianCount = 2; + _venomancerCount = 2; + _events.ScheduleEvent(EventIds.Darter, TimeSpan.FromSeconds(0), 0, Misc.PhaseSubmerge); + break; + } + _petCount = (uint)(_guardianCount + _venomancerCount); + if (_assassinCount != 0) + _events.ScheduleEvent(EventIds.Assassin, TimeSpan.FromSeconds(0), 0, Misc.PhaseSubmerge); + if (_guardianCount != 0) + _events.ScheduleEvent(EventIds.Guardian, TimeSpan.FromSeconds(4), 0, Misc.PhaseSubmerge); + if (_venomancerCount != 0) + _events.ScheduleEvent(EventIds.Venomancer, TimeSpan.FromSeconds(20), 0, Misc.PhaseSubmerge); + } + } + + ObjectGuid _impaleTarget; + uint _nextSubmerge; + uint _petCount; + ObjectGuid _guardianTrigger; + ObjectGuid _assassinTrigger; + byte _assassinCount; + byte _guardianCount; + byte _venomancerCount; } class npc_anubarak_pet_template : ScriptedAI @@ -453,269 +443,199 @@ namespace Scripts.Northrend.AzjolNerub.AzjolNerub.Anubarak } [Script] - class npc_anubarak_anub_ar_darter : CreatureScript + class npc_anubarak_anub_ar_darter : npc_anubarak_pet_template { - public npc_anubarak_anub_ar_darter() : base("npc_anubarak_anub_ar_darter") { } + public npc_anubarak_anub_ar_darter(Creature creature) : base(creature, false) { } - class npc_anubarak_anub_ar_darterAI : npc_anubarak_pet_template + public override void InitializeAI() { - public npc_anubarak_anub_ar_darterAI(Creature creature) : base(creature, false) { } - - public override void InitializeAI() - { - base.InitializeAI(); - DoCastAOE(SpellIds.Dart); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); + base.InitializeAI(); + DoCastAOE(SpellIds.Dart); } } [Script] - class npc_anubarak_anub_ar_assassin : CreatureScript + class npc_anubarak_anub_ar_assassin : npc_anubarak_pet_template { - public npc_anubarak_anub_ar_assassin() : base("npc_anubarak_anub_ar_assassin") { } - - class npc_anubarak_anub_ar_assassinAI : npc_anubarak_pet_template + public npc_anubarak_anub_ar_assassin(Creature creature) : base(creature, false) { - public npc_anubarak_anub_ar_assassinAI(Creature creature) : base(creature, false) + _backstabTimer = 6 * Time.InMilliseconds; + } + + bool IsInBounds(Position jumpTo, List boundary) + { + if (boundary == null) + return true; + foreach (var it in boundary) + if (!it.IsWithinBoundary(jumpTo)) + return false; + return true; + } + + Position GetRandomPositionAround(Creature anubarak) + { + float DISTANCE_MIN = 10.0f; + float DISTANCE_MAX = 30.0f; + double angle = RandomHelper.NextDouble() * 2.0 * Math.PI; + return new Position(anubarak.GetPositionX() + (float)(RandomHelper.FRand(DISTANCE_MIN, DISTANCE_MAX) * Math.Sin(angle)), anubarak.GetPositionY() + (float)(RandomHelper.FRand(DISTANCE_MIN, DISTANCE_MAX) * Math.Cos(angle)), anubarak.GetPositionZ()); + } + + public override void InitializeAI() + { + base.InitializeAI(); + var boundary = _instance.GetBossBoundary(ANDataTypes.Anubarak); + Creature anubarak = _instance.GetCreature(ANDataTypes.Anubarak); + if (anubarak) { + Position jumpTo; + do + jumpTo = GetRandomPositionAround(anubarak); + while (!IsInBounds(jumpTo, boundary)); + me.GetMotionMaster().MoveJump(jumpTo, 40.0f, 40.0f); + DoCastSelf(SpellIds.AssassinVisual, true); + } + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + if (diff >= _backstabTimer) + { + if (me.GetVictim() && me.GetVictim().isInBack(me)) + DoCastVictim(SpellIds.Backstab); _backstabTimer = 6 * Time.InMilliseconds; } + else + _backstabTimer -= diff; - bool IsInBounds(Position jumpTo, List boundary) - { - if (boundary == null) - return true; - foreach (var it in boundary) - if (!it.IsWithinBoundary(jumpTo)) - return false; - return true; - } - - Position GetRandomPositionAround(Creature anubarak) - { - float DISTANCE_MIN = 10.0f; - float DISTANCE_MAX = 30.0f; - double angle = RandomHelper.NextDouble() * 2.0 * Math.PI; - return new Position(anubarak.GetPositionX() + (float)(RandomHelper.FRand(DISTANCE_MIN, DISTANCE_MAX) * Math.Sin(angle)), anubarak.GetPositionY() + (float)(RandomHelper.FRand(DISTANCE_MIN, DISTANCE_MAX) * Math.Cos(angle)), anubarak.GetPositionZ()); - } - - public override void InitializeAI() - { - base.InitializeAI(); - var boundary = _instance.GetBossBoundary(ANDataTypes.Anubarak); - Creature anubarak = _instance.GetCreature(ANDataTypes.Anubarak); - if (anubarak) - { - Position jumpTo; - do - jumpTo = GetRandomPositionAround(anubarak); - while (!IsInBounds(jumpTo, boundary)); - me.GetMotionMaster().MoveJump(jumpTo, 40.0f, 40.0f); - DoCastSelf(SpellIds.AssassinVisual, true); - } - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - if (diff >= _backstabTimer) - { - if (me.GetVictim() && me.GetVictim().isInBack(me)) - DoCastVictim(SpellIds.Backstab); - _backstabTimer = 6 * Time.InMilliseconds; - } - else - _backstabTimer -= diff; - - DoMeleeAttackIfReady(); - } - - public override void MovementInform(MovementGeneratorType type, uint id) - { - if (id == EventId.Jump) - { - me.RemoveAurasDueToSpell(SpellIds.AssassinVisual); - DoZoneInCombat(); - } - } - - uint _backstabTimer; + DoMeleeAttackIfReady(); } - public override CreatureAI GetAI(Creature creature) + public override void MovementInform(MovementGeneratorType type, uint id) { - return GetInstanceAI(creature); + if (id == EventId.Jump) + { + me.RemoveAurasDueToSpell(SpellIds.AssassinVisual); + DoZoneInCombat(); + } + } + + uint _backstabTimer; + } + + [Script] + class npc_anubarak_anub_ar_guardian : npc_anubarak_pet_template + { + public npc_anubarak_anub_ar_guardian(Creature creature) : base(creature, true) + { + _sunderTimer = 6 * Time.InMilliseconds; + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + if (diff >= _sunderTimer) + { + DoCastVictim(SpellIds.SunderArmor); + _sunderTimer = 12 * Time.InMilliseconds; + } + else + _sunderTimer -= diff; + + DoMeleeAttackIfReady(); + } + + uint _sunderTimer; + } + + [Script] + class npc_anubarak_anub_ar_venomancer : npc_anubarak_pet_template + { + public npc_anubarak_anub_ar_venomancer(Creature creature) : base(creature, true) + { + _boltTimer = 5 * Time.InMilliseconds; + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + if (diff >= _boltTimer) + { + DoCastVictim(SpellIds.PoisonBolt); + _boltTimer = RandomHelper.URand(2, 3) * Time.InMilliseconds; + } + else + _boltTimer -= diff; + + DoMeleeAttackIfReady(); + } + + uint _boltTimer; + } + + [Script] + class npc_anubarak_impale_target : NullCreatureAI + { + public npc_anubarak_impale_target(Creature creature) : base(creature) { } + + public override void InitializeAI() + { + Creature anubarak = me.GetInstanceScript().GetCreature(ANDataTypes.Anubarak); + if (anubarak) + { + DoCastSelf(SpellIds.ImpaleVisual); + me.DespawnOrUnsummon(TimeSpan.FromSeconds(6)); + anubarak.GetAI().SetGUID(me.GetGUID(), Misc.GuidTypeImpale); + } + else + me.DespawnOrUnsummon(); } } [Script] - class npc_anubarak_anub_ar_guardian : CreatureScript + class spell_anubarak_pound : SpellScript { - public npc_anubarak_anub_ar_guardian() : base("npc_anubarak_anub_ar_guardian") { } - - class npc_anubarak_anub_ar_guardianAI : npc_anubarak_pet_template + public override bool Validate(SpellInfo spell) { - public npc_anubarak_anub_ar_guardianAI(Creature creature) : base(creature, true) - { - _sunderTimer = 6 * Time.InMilliseconds; - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - if (diff >= _sunderTimer) - { - DoCastVictim(SpellIds.SunderArmor); - _sunderTimer = 12 * Time.InMilliseconds; - } - else - _sunderTimer -= diff; - - DoMeleeAttackIfReady(); - } - - uint _sunderTimer; + return ValidateSpellInfo(SpellIds.PoundDamage); } - public override CreatureAI GetAI(Creature creature) + void HandleDummy(uint effIndex) { - return GetInstanceAI(creature); + Unit target = GetHitUnit(); + if (target) + GetCaster().CastSpell(target, SpellIds.PoundDamage, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.ApplyAura)); } } [Script] - class npc_anubarak_anub_ar_venomancer : CreatureScript + class spell_anubarak_carrion_beetles : AuraScript { - public npc_anubarak_anub_ar_venomancer() : base("npc_anubarak_anub_ar_venomancer") { } - - class npc_anubarak_anub_ar_venomancerAI : npc_anubarak_pet_template + public override bool Validate(SpellInfo spell) { - public npc_anubarak_anub_ar_venomancerAI(Creature creature) : base(creature, true) - { - _boltTimer = 5 * Time.InMilliseconds; - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - if (diff >= _boltTimer) - { - DoCastVictim(SpellIds.PoisonBolt); - _boltTimer = RandomHelper.URand(2, 3) * Time.InMilliseconds; - } - else - _boltTimer -= diff; - - DoMeleeAttackIfReady(); - } - - uint _boltTimer; + return ValidateSpellInfo(SpellIds.CarrionBeetle); } - public override CreatureAI GetAI(Creature creature) + void HandlePeriodic(AuraEffect eff) { - return GetInstanceAI(creature); - } - } - - [Script] - class npc_anubarak_impale_target : CreatureScript - { - public npc_anubarak_impale_target() : base("npc_anubarak_impale_target") { } - - class npc_anubarak_impale_targetAI : NullCreatureAI - { - public npc_anubarak_impale_targetAI(Creature creature) : base(creature) { } - - public override void InitializeAI() - { - Creature anubarak = me.GetInstanceScript().GetCreature(ANDataTypes.Anubarak); - if (anubarak) - { - DoCastSelf(SpellIds.ImpaleVisual); - me.DespawnOrUnsummon(TimeSpan.FromSeconds(6)); - anubarak.GetAI().SetGUID(me.GetGUID(), Misc.GuidTypeImpale); - } - else - me.DespawnOrUnsummon(); - } + GetCaster().CastSpell(GetCaster(), SpellIds.CarrionBeetle, true); + GetCaster().CastSpell(GetCaster(), SpellIds.CarrionBeetle, true); } - public override CreatureAI GetAI(Creature creature) + public override void Register() { - return GetInstanceAI(creature); - } - } - - [Script] - class spell_anubarak_pound : SpellScriptLoader - { - public spell_anubarak_pound() : base("spell_anubarak_pound") { } - - class spell_anubarak_pound_SpellScript : SpellScript - { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.PoundDamage); - } - - void HandleDummy(uint effIndex) - { - Unit target = GetHitUnit(); - if (target) - GetCaster().CastSpell(target, SpellIds.PoundDamage, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.ApplyAura)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_anubarak_pound_SpellScript(); - } - } - - [Script] - class spell_anubarak_carrion_beetles : SpellScriptLoader - { - public spell_anubarak_carrion_beetles() : base("spell_anubarak_carrion_beetles") { } - - class spell_anubarak_carrion_beetles_AuraScript : AuraScript - { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.CarrionBeetle); - } - - void HandlePeriodic(AuraEffect eff) - { - GetCaster().CastSpell(GetCaster(), SpellIds.CarrionBeetle, true); - GetCaster().CastSpell(GetCaster(), SpellIds.CarrionBeetle, true); - } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandlePeriodic, 0, AuraType.PeriodicDummy)); - } - } - - public override AuraScript GetAuraScript() - { - return new spell_anubarak_carrion_beetles_AuraScript(); + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandlePeriodic, 0, AuraType.PeriodicDummy)); } } } diff --git a/Scripts/Northrend/AzjolNerub/AzjolNerub/BossKrikthirTheGatewatcher.cs b/Scripts/Northrend/AzjolNerub/AzjolNerub/BossKrikthirTheGatewatcher.cs index 5f48b16d2..375942333 100644 --- a/Scripts/Northrend/AzjolNerub/AzjolNerub/BossKrikthirTheGatewatcher.cs +++ b/Scripts/Northrend/AzjolNerub/AzjolNerub/BossKrikthirTheGatewatcher.cs @@ -98,200 +98,190 @@ namespace Scripts.Northrend.AzjolNerub.AzjolNerub.KrikthirTheGatewatcher } [Script] - class boss_krik_thir : CreatureScript + class boss_krik_thir : BossAI { - public boss_krik_thir() : base("boss_krik_thir") { } + public boss_krik_thir(Creature creature) : base(creature, ANDataTypes.KrikthirTheGatewatcher) { } - class boss_krik_thirAI : BossAI + void SummonAdds() { - public boss_krik_thirAI(Creature creature) : base(creature, ANDataTypes.KrikthirTheGatewatcher) { } + if (instance.GetBossState(ANDataTypes.KrikthirTheGatewatcher) == EncounterState.Done) + return; - void SummonAdds() + for (byte i = 1; i <= 3; ++i) { - if (instance.GetBossState(ANDataTypes.KrikthirTheGatewatcher) == EncounterState.Done) - return; + List summons; + me.SummonCreatureGroup(i, out summons); - for (byte i = 1; i <= 3; ++i) - { - List summons; - me.SummonCreatureGroup(i, out summons); + foreach (TempSummon summon in summons) + summon.GetAI().SetData(Misc.DataPetGroup, i); + } + } - foreach (TempSummon summon in summons) - summon.GetAI().SetData(Misc.DataPetGroup, i); - } + public override void Reset() + { + base.Reset(); + _hadFrenzy = false; + _petsInCombat = false; + _watchersActive = 0; + me.SetReactState(ReactStates.Passive); + } + + public override void InitializeAI() + { + base.InitializeAI(); + SummonAdds(); + } + + public override void JustRespawned() + { + base.JustRespawned(); + SummonAdds(); + } + + public override void KilledUnit(Unit victim) + { + if (victim.IsTypeId(TypeId.Player)) + Talk(TextIds.SaySlay); + } + + public override void JustDied(Unit killer) + { + summons.Clear(); + base.JustDied(killer); + Talk(TextIds.SayDeath); + } + + public override void EnterCombat(Unit who) + { + _petsInCombat = false; + me.SetReactState(ReactStates.Aggressive); + summons.DoZoneInCombat(); + + _events.CancelEvent(Misc.EventSendGroup); + _events.ScheduleEvent(Misc.EventSwarm, TimeSpan.FromSeconds(5)); + _events.ScheduleEvent(Misc.EventMindFlay, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(3)); + + base.EnterCombat(who); + } + + public override void MoveInLineOfSight(Unit who) + { + if (!me.HasReactState(ReactStates.Passive)) + { + base.MoveInLineOfSight(who); + return; } - public override void Reset() + if (me.CanStartAttack(who, false) && me.IsWithinDistInMap(who, me.GetAttackDistance(who) + me.m_CombatDistance)) + EnterCombat(who); + } + + public override void EnterEvadeMode(EvadeReason why) + { + summons.DespawnAll(); + _DespawnAtEvade(); + } + + public override void DoAction(int action) + { + switch (action) { - base.Reset(); - _hadFrenzy = false; - _petsInCombat = false; - _watchersActive = 0; - me.SetReactState(ReactStates.Passive); - } - - public override void InitializeAI() - { - base.InitializeAI(); - SummonAdds(); - } - - public override void JustRespawned() - { - base.JustRespawned(); - SummonAdds(); - } - - public override void KilledUnit(Unit victim) - { - if (victim.IsTypeId(TypeId.Player)) - Talk(TextIds.SaySlay); - } - - public override void JustDied(Unit killer) - { - summons.Clear(); - base.JustDied(killer); - Talk(TextIds.SayDeath); - } - - public override void EnterCombat(Unit who) - { - _petsInCombat = false; - me.SetReactState(ReactStates.Aggressive); - summons.DoZoneInCombat(); - - _events.CancelEvent(Misc.EventSendGroup); - _events.ScheduleEvent(Misc.EventSwarm, TimeSpan.FromSeconds(5)); - _events.ScheduleEvent(Misc.EventMindFlay, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(3)); - - base.EnterCombat(who); - } - - public override void MoveInLineOfSight(Unit who) - { - if (!me.HasReactState(ReactStates.Passive)) - { - base.MoveInLineOfSight(who); - return; - } - - if (me.CanStartAttack(who, false) && me.IsWithinDistInMap(who, me.GetAttackDistance(who) + me.m_CombatDistance)) - EnterCombat(who); - } - - public override void EnterEvadeMode(EvadeReason why) - { - summons.DespawnAll(); - _DespawnAtEvade(); - } - - public override void DoAction(int action) - { - switch (action) - { - case -ANInstanceMisc.ActionGatewatcherGreet: - if (!_hadGreet && me.IsAlive() && !me.IsInCombat() && !_petsInCombat) - { - _hadGreet = true; - Talk(TextIds.SayPrefight); - } - break; - case ActionIds.GashraDied: - case ActionIds.NarjilDied: - case ActionIds.SilthikDied: - if (_watchersActive == 0) // something is wrong - { - EnterEvadeMode(EvadeReason.Other); - return; - } - if ((--_watchersActive) == 0) // if there are no watchers currently in combat... - _events.RescheduleEvent(Misc.EventSendGroup, TimeSpan.FromSeconds(5)); // ...send the next watcher after the targets sooner - break; - case ActionIds.WatcherEngaged: - ++_watchersActive; - break; - case ActionIds.PetEngaged: - if (_petsInCombat || me.IsInCombat()) - break; - _petsInCombat = true; - Talk(TextIds.SayAggro); - _events.ScheduleEvent(Misc.EventSendGroup, TimeSpan.FromSeconds(70)); - break; - case ActionIds.PetEvade: + case -ANInstanceMisc.ActionGatewatcherGreet: + if (!_hadGreet && me.IsAlive() && !me.IsInCombat() && !_petsInCombat) + { + _hadGreet = true; + Talk(TextIds.SayPrefight); + } + break; + case ActionIds.GashraDied: + case ActionIds.NarjilDied: + case ActionIds.SilthikDied: + if (_watchersActive == 0) // something is wrong + { EnterEvadeMode(EvadeReason.Other); + return; + } + if ((--_watchersActive) == 0) // if there are no watchers currently in combat... + _events.RescheduleEvent(Misc.EventSendGroup, TimeSpan.FromSeconds(5)); // ...send the next watcher after the targets sooner + break; + case ActionIds.WatcherEngaged: + ++_watchersActive; + break; + case ActionIds.PetEngaged: + if (_petsInCombat || me.IsInCombat()) break; - } + _petsInCombat = true; + Talk(TextIds.SayAggro); + _events.ScheduleEvent(Misc.EventSendGroup, TimeSpan.FromSeconds(70)); + break; + case ActionIds.PetEvade: + EnterEvadeMode(EvadeReason.Other); + break; + } + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim() && !_petsInCombat) + return; + + _events.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + if (me.HealthBelowPct(10) && !_hadFrenzy) + { + _hadFrenzy = true; + _events.ScheduleEvent(Misc.EventFrenzy, TimeSpan.FromSeconds(1)); } - public override void UpdateAI(uint diff) + _events.ExecuteEvents(eventId => { - if (!UpdateVictim() && !_petsInCombat) - return; - - _events.Update(diff); + switch (eventId) + { + case Misc.EventSendGroup: + DoCastAOE(SpellIds.SubbossAggroTrigger, true); + _events.Repeat(TimeSpan.FromSeconds(70)); + break; + case Misc.EventSwarm: + DoCastAOE(SpellIds.Swarm); + Talk(TextIds.SaySwarm); + break; + case Misc.EventMindFlay: + DoCastVictim(SpellIds.MindFlay); + _events.Repeat(TimeSpan.FromSeconds(9), TimeSpan.FromSeconds(11)); + break; + case Misc.EventFrenzy: + DoCastSelf(SpellIds.Frenzy); + DoCastAOE(SpellIds.CurseOfFatigue); + _events.Repeat(TimeSpan.FromSeconds(15)); + break; + } if (me.HasUnitState(UnitState.Casting)) return; + }); - if (me.HealthBelowPct(10) && !_hadFrenzy) - { - _hadFrenzy = true; - _events.ScheduleEvent(Misc.EventFrenzy, TimeSpan.FromSeconds(1)); - } - - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case Misc.EventSendGroup: - DoCastAOE(SpellIds.SubbossAggroTrigger, true); - _events.Repeat(TimeSpan.FromSeconds(70)); - break; - case Misc.EventSwarm: - DoCastAOE(SpellIds.Swarm); - Talk(TextIds.SaySwarm); - break; - case Misc.EventMindFlay: - DoCastVictim(SpellIds.MindFlay); - _events.Repeat(TimeSpan.FromSeconds(9), TimeSpan.FromSeconds(11)); - break; - case Misc.EventFrenzy: - DoCastSelf(SpellIds.Frenzy); - DoCastAOE(SpellIds.CurseOfFatigue); - _events.Repeat(TimeSpan.FromSeconds(15)); - break; - } - - if (me.HasUnitState(UnitState.Casting)) - return; - }); - - DoMeleeAttackIfReady(); - } - - public override void SpellHit(Unit whose, SpellInfo spell) - { - if (spell.Id == SpellIds.SubbossAggroTrigger) - DoZoneInCombat(); - } - - public override void SpellHitTarget(Unit who, SpellInfo spell) - { - if (spell.Id == SpellIds.SubbossAggroTrigger) - Talk(TextIds.SaySendGroup); - } - - bool _hadGreet; - bool _hadFrenzy; - bool _petsInCombat; - byte _watchersActive; + DoMeleeAttackIfReady(); } - public override CreatureAI GetAI(Creature creature) + public override void SpellHit(Unit whose, SpellInfo spell) { - return GetInstanceAI(creature); + if (spell.Id == SpellIds.SubbossAggroTrigger) + DoZoneInCombat(); } + + public override void SpellHitTarget(Unit who, SpellInfo spell) + { + if (spell.Id == SpellIds.SubbossAggroTrigger) + Talk(TextIds.SaySendGroup); + } + + bool _hadGreet; + bool _hadFrenzy; + bool _petsInCombat; + byte _watchersActive; } class npc_gatewatcher_petAI : ScriptedAI @@ -399,578 +389,458 @@ namespace Scripts.Northrend.AzjolNerub.AzjolNerub.KrikthirTheGatewatcher } [Script] - class npc_watcher_gashra : CreatureScript + class npc_watcher_gashra : npc_gatewatcher_petAI { - public npc_watcher_gashra() : base("npc_watcher_gashra") { } - - class npc_watcher_gashraAI : npc_gatewatcher_petAI + public npc_watcher_gashra(Creature creature) : base(creature, true) { - public npc_watcher_gashraAI(Creature creature) : base(creature, true) - { - _instance = creature.GetInstanceScript(); - me.SetReactState(ReactStates.Passive); - } - - public override void Reset() - { - _scheduler.CancelAll(); - } - - public override void _EnterCombat() - { - _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); - - _scheduler.Schedule(TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(5), task => - { - DoCastSelf(SpellIds.Enrage); - task.Repeat(TimeSpan.FromSeconds(12), TimeSpan.FromSeconds(20)); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(16), TimeSpan.FromSeconds(19), task => - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100.0f); - if (target) - DoCast(target, SpellIds.WebWrap); - task.Repeat(TimeSpan.FromSeconds(13), TimeSpan.FromSeconds(19)); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(7), TimeSpan.FromSeconds(11), task => - { - DoCastVictim(SpellIds.InfectedBite); - task.Repeat(TimeSpan.FromSeconds(23), TimeSpan.FromSeconds(27)); - }); - } - - public override void JustDied(Unit killer) - { - Creature krikthir = _instance.GetCreature(ANDataTypes.KrikthirTheGatewatcher); - if (krikthir && krikthir.IsAlive()) - krikthir.GetAI().DoAction(ActionIds.GashraDied); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _scheduler.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - DoMeleeAttackIfReady(); - } + _instance = creature.GetInstanceScript(); + me.SetReactState(ReactStates.Passive); } - public override CreatureAI GetAI(Creature creature) + public override void Reset() { - return GetInstanceAI(creature); - } - } - - [Script] - class npc_watcher_narjil : CreatureScript - { - public npc_watcher_narjil() : base("npc_watcher_narjil") { } - - class npc_watcher_narjilAI : npc_gatewatcher_petAI - { - public npc_watcher_narjilAI(Creature creature) : base(creature, true) - { - _instance = creature.GetInstanceScript(); - } - - public override void Reset() - { - _scheduler.CancelAll(); - } - - public override void _EnterCombat() - { - _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); - - _scheduler.Schedule(TimeSpan.FromSeconds(13), TimeSpan.FromSeconds(18), task => - { - DoCastVictim(SpellIds.BlindingWebs); - task.Repeat(TimeSpan.FromSeconds(23), TimeSpan.FromSeconds(27)); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(5), task => - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100, true); - if (target) - DoCast(target, SpellIds.WebWrap); - task.Repeat(TimeSpan.FromSeconds(13), TimeSpan.FromSeconds(19)); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(7), TimeSpan.FromSeconds(11), task => - { - DoCastVictim(SpellIds.InfectedBite); - task.Repeat(TimeSpan.FromSeconds(20), TimeSpan.FromSeconds(25)); - }); - } - - public override void JustDied(Unit killer) - { - Creature krikthir = _instance.GetCreature(ANDataTypes.KrikthirTheGatewatcher); - if (krikthir && krikthir.IsAlive()) - krikthir.GetAI().DoAction(ActionIds.NarjilDied); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _scheduler.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - DoMeleeAttackIfReady(); - } + _scheduler.CancelAll(); } - public override CreatureAI GetAI(Creature creature) + public override void _EnterCombat() { - return GetInstanceAI(creature); - } - } + _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); - [Script] - class npc_watcher_silthik : CreatureScript - { - public npc_watcher_silthik() : base("npc_watcher_silthik") { } - - class npc_watcher_silthikAI : npc_gatewatcher_petAI - { - public npc_watcher_silthikAI(Creature creature) : base(creature, true) + _scheduler.Schedule(TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(5), task => { - _instance = creature.GetInstanceScript(); - } + DoCastSelf(SpellIds.Enrage); + task.Repeat(TimeSpan.FromSeconds(12), TimeSpan.FromSeconds(20)); + }); - public override void Reset() + _scheduler.Schedule(TimeSpan.FromSeconds(16), TimeSpan.FromSeconds(19), task => { - _scheduler.CancelAll(); - } - - public override void _EnterCombat() - { - _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); - - _scheduler.Schedule(TimeSpan.FromSeconds(16), TimeSpan.FromSeconds(19), task => - { - DoCastVictim(SpellIds.PoisonSpray); - task.Repeat(TimeSpan.FromSeconds(13), TimeSpan.FromSeconds(19)); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(7), TimeSpan.FromSeconds(11), task => - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100, true); - if (target) - DoCast(target, SpellIds.WebWrap); - task.Repeat(TimeSpan.FromSeconds(13), TimeSpan.FromSeconds(17)); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(5), task => - { - DoCastVictim(SpellIds.InfectedBite); - task.Repeat(TimeSpan.FromSeconds(20), TimeSpan.FromSeconds(24)); - }); - } - - public override void JustDied(Unit killer) - { - Creature krikthir = _instance.GetCreature(ANDataTypes.KrikthirTheGatewatcher); - if (krikthir && krikthir.IsAlive()) - krikthir.GetAI().DoAction(ActionIds.SilthikDied); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _scheduler.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - DoMeleeAttackIfReady(); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } - } - - [Script] - class npc_anub_ar_warrior : CreatureScript - { - public npc_anub_ar_warrior() : base("npc_anub_ar_warrior") { } - - class npc_anub_ar_warriorAI : npc_gatewatcher_petAI - { - public npc_anub_ar_warriorAI(Creature creature) : base(creature, false) { } - - public override void Reset() - { - _scheduler.CancelAll(); - } - - public override void _EnterCombat() - { - _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); - - _scheduler.Schedule(TimeSpan.FromSeconds(7), TimeSpan.FromSeconds(9), task => - { - DoCastVictim(SpellIds.Cleave); - task.Repeat(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(16)); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(10), task => - { - DoCastVictim(SpellIds.Strike); - task.Repeat(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(19)); - }); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _scheduler.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - DoMeleeAttackIfReady(); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } - } - - [Script] - class npc_anub_ar_skirmisher : CreatureScript - { - public npc_anub_ar_skirmisher() : base("npc_anub_ar_skirmisher") { } - - class npc_anub_ar_skirmisherAI : npc_gatewatcher_petAI - { - public npc_anub_ar_skirmisherAI(Creature creature) : base(creature, false) { } - - public override void Reset() - { - _scheduler.CancelAll(); - } - - public override void _EnterCombat() - { - _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); - - _scheduler.Schedule(TimeSpan.FromSeconds(6), TimeSpan.FromSeconds(8), task => - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100.0f, true); - if (target) - DoCast(target, SpellIds.Charge); - task.Repeat(TimeSpan.FromSeconds(20), TimeSpan.FromSeconds(25)); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(7), TimeSpan.FromSeconds(9), task => - { - if (me.GetVictim() && me.GetVictim().isInBack(me)) - DoCastVictim(SpellIds.Backstab); - task.Repeat(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(13)); - }); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _scheduler.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - DoMeleeAttackIfReady(); - } - - public override void SpellHitTarget(Unit target, SpellInfo spell) - { - if (spell.Id == SpellIds.Charge && target) - DoCast(target, SpellIds.FixtateTrigger); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } - } - - [Script] - class npc_anub_ar_shadowcaster : CreatureScript - { - public npc_anub_ar_shadowcaster() : base("npc_anub_ar_shadowcaster") { } - - class npc_anub_ar_shadowcasterAI : npc_gatewatcher_petAI - { - public npc_anub_ar_shadowcasterAI(Creature creature) : base(creature, false) { } - - public override void Reset() - { - _scheduler.CancelAll(); - } - - public override void _EnterCombat() - { - _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); - - _scheduler.Schedule(TimeSpan.FromSeconds(4), task => - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100.0f, true); - if (target) - DoCast(target, SpellIds.ShadowBolt); - task.Repeat(TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(4)); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(14), task => - { - DoCastVictim(SpellIds.ShadowNova); - task.Repeat(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(16)); - }); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _scheduler.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - DoMeleeAttackIfReady(); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } - } - - [Script] - class npc_skittering_swarmer : CreatureScript - { - public npc_skittering_swarmer() : base("npc_skittering_swarmer") { } - - class npc_skittering_swarmerAI : ScriptedAI - { - public npc_skittering_swarmerAI(Creature creature) : base(creature) { } - - public override void InitializeAI() - { - base.InitializeAI(); - Creature gatewatcher = me.GetInstanceScript().GetCreature(ANDataTypes.KrikthirTheGatewatcher); - if (gatewatcher) - { - Unit target = gatewatcher.getAttackerForHelper(); - if (target) - AttackStart(target); - gatewatcher.GetAI().JustSummoned(me); - } - } - } - - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } - } - - [Script] - class npc_skittering_infector : CreatureScript - { - public npc_skittering_infector() : base("npc_skittering_infector") { } - - class npc_skittering_infectorAI : ScriptedAI - { - public npc_skittering_infectorAI(Creature creature) : base(creature) { } - - public override void InitializeAI() - { - base.InitializeAI(); - Creature gatewatcher = me.GetInstanceScript().GetCreature(ANDataTypes.KrikthirTheGatewatcher); - if (gatewatcher) - { - Unit target = gatewatcher.getAttackerForHelper(); - if (target) - AttackStart(target); - gatewatcher.GetAI().JustSummoned(me); - } - } - - public override void JustDied(Unit killer) - { - DoCastAOE(SpellIds.AcidSplash); - base.JustDied(killer); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } - } - - [Script] - class npc_gatewatcher_web_wrap : CreatureScript - { - public npc_gatewatcher_web_wrap() : base("npc_gatewatcher_web_wrap") { } - - class npc_gatewatcher_web_wrapAI : NullCreatureAI - { - public npc_gatewatcher_web_wrapAI(Creature creature) : base(creature) { } - - public override void JustDied(Unit killer) - { - TempSummon meSummon = me.ToTempSummon(); - if (meSummon) - { - Unit summoner = meSummon.GetSummoner(); - if (summoner) - summoner.RemoveAurasDueToSpell(SpellIds.WebWrapWrapped); - } - } - } - - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } - } - - [Script] - class spell_gatewatcher_subboss_trigger : SpellScriptLoader - { - public spell_gatewatcher_subboss_trigger() : base("spell_gatewatcher_subboss_trigger") { } - - class spell_gatewatcher_subboss_trigger_SpellScript : SpellScript - { - void HandleTargets(List targetList) - { - // Remove any Watchers that are already in combat - foreach (var obj in targetList.ToList()) - { - Creature creature = obj.ToCreature(); - if (creature) - if (creature.IsAlive() && !creature.IsInCombat()) - continue; - - targetList.Remove(obj); - } - - // Default to Krik'thir himself if he isn't engaged - WorldObject target = null; - if (GetCaster() && !GetCaster().IsInCombat()) - target = GetCaster(); - // Unless there are Watchers that aren't engaged yet - if (!targetList.Empty()) - { - // If there are, pick one of them at random - target = targetList.SelectRandom(); - } - // And hit only that one - targetList.Clear(); + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100.0f); if (target) - targetList.Add(target); - } + DoCast(target, SpellIds.WebWrap); + task.Repeat(TimeSpan.FromSeconds(13), TimeSpan.FromSeconds(19)); + }); - public override void Register() + _scheduler.Schedule(TimeSpan.FromSeconds(7), TimeSpan.FromSeconds(11), task => { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(HandleTargets, 0, Targets.UnitSrcAreaEntry)); - } + DoCastVictim(SpellIds.InfectedBite); + task.Repeat(TimeSpan.FromSeconds(23), TimeSpan.FromSeconds(27)); + }); } - public override SpellScript GetSpellScript() + public override void JustDied(Unit killer) { - return new spell_gatewatcher_subboss_trigger_SpellScript(); + Creature krikthir = _instance.GetCreature(ANDataTypes.KrikthirTheGatewatcher); + if (krikthir && krikthir.IsAlive()) + krikthir.GetAI().DoAction(ActionIds.GashraDied); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _scheduler.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + DoMeleeAttackIfReady(); } } [Script] - class spell_anub_ar_skirmisher_fixtate : SpellScriptLoader + class npc_watcher_narjil : npc_gatewatcher_petAI { - public spell_anub_ar_skirmisher_fixtate() : base("spell_anub_ar_skirmisher_fixtate") { } - - class spell_anub_ar_skirmisher_fixtate_SpellScript : SpellScript + public npc_watcher_narjil(Creature creature) : base(creature, true) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.FixtateTriggered); - } - - void HandleScript(uint effIndex) - { - Unit target = GetHitUnit(); - if (target) - target.CastSpell(GetCaster(), SpellIds.FixtateTriggered, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } + _instance = creature.GetInstanceScript(); } - public override SpellScript GetSpellScript() + public override void Reset() { - return new spell_anub_ar_skirmisher_fixtate_SpellScript(); + _scheduler.CancelAll(); + } + + public override void _EnterCombat() + { + _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); + + _scheduler.Schedule(TimeSpan.FromSeconds(13), TimeSpan.FromSeconds(18), task => + { + DoCastVictim(SpellIds.BlindingWebs); + task.Repeat(TimeSpan.FromSeconds(23), TimeSpan.FromSeconds(27)); + }); + + _scheduler.Schedule(TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(5), task => + { + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100, true); + if (target) + DoCast(target, SpellIds.WebWrap); + task.Repeat(TimeSpan.FromSeconds(13), TimeSpan.FromSeconds(19)); + }); + + _scheduler.Schedule(TimeSpan.FromSeconds(7), TimeSpan.FromSeconds(11), task => + { + DoCastVictim(SpellIds.InfectedBite); + task.Repeat(TimeSpan.FromSeconds(20), TimeSpan.FromSeconds(25)); + }); + } + + public override void JustDied(Unit killer) + { + Creature krikthir = _instance.GetCreature(ANDataTypes.KrikthirTheGatewatcher); + if (krikthir && krikthir.IsAlive()) + krikthir.GetAI().DoAction(ActionIds.NarjilDied); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _scheduler.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + DoMeleeAttackIfReady(); } } [Script] - class spell_gatewatcher_web_wrap : SpellScriptLoader + class npc_watcher_silthik : npc_gatewatcher_petAI { - public spell_gatewatcher_web_wrap() : base("spell_gatewatcher_web_wrap") { } - - class spell_gatewatcher_web_wrap_AuraScript : AuraScript + public npc_watcher_silthik(Creature creature) : base(creature, true) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.WebWrapWrapped); - } + _instance = creature.GetInstanceScript(); + } - void HandleEffectRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - if (GetTargetApplication().GetRemoveMode() != AuraRemoveMode.Expire) - return; + public override void Reset() + { + _scheduler.CancelAll(); + } - Unit target = GetTarget(); + public override void _EnterCombat() + { + _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); + + _scheduler.Schedule(TimeSpan.FromSeconds(16), TimeSpan.FromSeconds(19), task => + { + DoCastVictim(SpellIds.PoisonSpray); + task.Repeat(TimeSpan.FromSeconds(13), TimeSpan.FromSeconds(19)); + }); + + _scheduler.Schedule(TimeSpan.FromSeconds(7), TimeSpan.FromSeconds(11), task => + { + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100, true); if (target) - target.CastSpell(target, SpellIds.WebWrapWrapped, true); - } + DoCast(target, SpellIds.WebWrap); + task.Repeat(TimeSpan.FromSeconds(13), TimeSpan.FromSeconds(17)); + }); - public override void Register() + _scheduler.Schedule(TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(5), task => { - OnEffectRemove.Add(new EffectApplyHandler(HandleEffectRemove, 0, AuraType.ModRoot, AuraEffectHandleModes.Real)); + DoCastVictim(SpellIds.InfectedBite); + task.Repeat(TimeSpan.FromSeconds(20), TimeSpan.FromSeconds(24)); + }); + } + + public override void JustDied(Unit killer) + { + Creature krikthir = _instance.GetCreature(ANDataTypes.KrikthirTheGatewatcher); + if (krikthir && krikthir.IsAlive()) + krikthir.GetAI().DoAction(ActionIds.SilthikDied); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _scheduler.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + DoMeleeAttackIfReady(); + } + } + + [Script] + class npc_anub_ar_warrior : npc_gatewatcher_petAI + { + public npc_anub_ar_warrior(Creature creature) : base(creature, false) { } + + public override void Reset() + { + _scheduler.CancelAll(); + } + + public override void _EnterCombat() + { + _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); + + _scheduler.Schedule(TimeSpan.FromSeconds(7), TimeSpan.FromSeconds(9), task => + { + DoCastVictim(SpellIds.Cleave); + task.Repeat(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(16)); + }); + + _scheduler.Schedule(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(10), task => + { + DoCastVictim(SpellIds.Strike); + task.Repeat(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(19)); + }); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _scheduler.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + DoMeleeAttackIfReady(); + } + } + + [Script] + class npc_anub_ar_skirmisher : npc_gatewatcher_petAI + { + public npc_anub_ar_skirmisher(Creature creature) : base(creature, false) { } + + public override void Reset() + { + _scheduler.CancelAll(); + } + + public override void _EnterCombat() + { + _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); + + _scheduler.Schedule(TimeSpan.FromSeconds(6), TimeSpan.FromSeconds(8), task => + { + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100.0f, true); + if (target) + DoCast(target, SpellIds.Charge); + task.Repeat(TimeSpan.FromSeconds(20), TimeSpan.FromSeconds(25)); + }); + + _scheduler.Schedule(TimeSpan.FromSeconds(7), TimeSpan.FromSeconds(9), task => + { + if (me.GetVictim() && me.GetVictim().isInBack(me)) + DoCastVictim(SpellIds.Backstab); + task.Repeat(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(13)); + }); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _scheduler.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + DoMeleeAttackIfReady(); + } + + public override void SpellHitTarget(Unit target, SpellInfo spell) + { + if (spell.Id == SpellIds.Charge && target) + DoCast(target, SpellIds.FixtateTrigger); + } + } + + [Script] + class npc_anub_ar_shadowcaster : npc_gatewatcher_petAI + { + public npc_anub_ar_shadowcaster(Creature creature) : base(creature, false) { } + + public override void Reset() + { + _scheduler.CancelAll(); + } + + public override void _EnterCombat() + { + _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); + + _scheduler.Schedule(TimeSpan.FromSeconds(4), task => + { + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100.0f, true); + if (target) + DoCast(target, SpellIds.ShadowBolt); + task.Repeat(TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(4)); + }); + + _scheduler.Schedule(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(14), task => + { + DoCastVictim(SpellIds.ShadowNova); + task.Repeat(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(16)); + }); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _scheduler.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + DoMeleeAttackIfReady(); + } + } + + [Script] + class npc_skittering_swarmer : ScriptedAI + { + public npc_skittering_swarmer(Creature creature) : base(creature) { } + + public override void InitializeAI() + { + base.InitializeAI(); + Creature gatewatcher = me.GetInstanceScript().GetCreature(ANDataTypes.KrikthirTheGatewatcher); + if (gatewatcher) + { + Unit target = gatewatcher.getAttackerForHelper(); + if (target) + AttackStart(target); + gatewatcher.GetAI().JustSummoned(me); + } + } + } + + [Script] + class npc_skittering_infector : ScriptedAI + { + public npc_skittering_infector(Creature creature) : base(creature) { } + + public override void InitializeAI() + { + base.InitializeAI(); + Creature gatewatcher = me.GetInstanceScript().GetCreature(ANDataTypes.KrikthirTheGatewatcher); + if (gatewatcher) + { + Unit target = gatewatcher.getAttackerForHelper(); + if (target) + AttackStart(target); + gatewatcher.GetAI().JustSummoned(me); } } - public override AuraScript GetAuraScript() + public override void JustDied(Unit killer) { - return new spell_gatewatcher_web_wrap_AuraScript(); + DoCastAOE(SpellIds.AcidSplash); + base.JustDied(killer); + } + } + + [Script] + class npc_gatewatcher_web_wrap : NullCreatureAI + { + public npc_gatewatcher_web_wrap(Creature creature) : base(creature) { } + + public override void JustDied(Unit killer) + { + TempSummon meSummon = me.ToTempSummon(); + if (meSummon) + { + Unit summoner = meSummon.GetSummoner(); + if (summoner) + summoner.RemoveAurasDueToSpell(SpellIds.WebWrapWrapped); + } + } + } + + [Script] + class spell_gatewatcher_subboss_trigger : SpellScript + { + void HandleTargets(List targetList) + { + // Remove any Watchers that are already in combat + foreach (var obj in targetList.ToList()) + { + Creature creature = obj.ToCreature(); + if (creature) + if (creature.IsAlive() && !creature.IsInCombat()) + continue; + + targetList.Remove(obj); + } + + // Default to Krik'thir himself if he isn't engaged + WorldObject target = null; + if (GetCaster() && !GetCaster().IsInCombat()) + target = GetCaster(); + // Unless there are Watchers that aren't engaged yet + if (!targetList.Empty()) + { + // If there are, pick one of them at random + target = targetList.SelectRandom(); + } + // And hit only that one + targetList.Clear(); + if (target) + targetList.Add(target); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(HandleTargets, 0, Targets.UnitSrcAreaEntry)); + } + } + + [Script] + class spell_anub_ar_skirmisher_fixtate : SpellScript + { + public override bool Validate(SpellInfo spell) + { + return ValidateSpellInfo(SpellIds.FixtateTriggered); + } + + void HandleScript(uint effIndex) + { + Unit target = GetHitUnit(); + if (target) + target.CastSpell(GetCaster(), SpellIds.FixtateTriggered, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + } + } + + [Script] + class spell_gatewatcher_web_wrap : AuraScript + { + public override bool Validate(SpellInfo spell) + { + return ValidateSpellInfo(SpellIds.WebWrapWrapped); + } + + void HandleEffectRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + if (GetTargetApplication().GetRemoveMode() != AuraRemoveMode.Expire) + return; + + Unit target = GetTarget(); + if (target) + target.CastSpell(target, SpellIds.WebWrapWrapped, true); + } + + public override void Register() + { + OnEffectRemove.Add(new EffectApplyHandler(HandleEffectRemove, 0, AuraType.ModRoot, AuraEffectHandleModes.Real)); } } diff --git a/Scripts/Northrend/AzjolNerub/AzjolNerub/BossNadronox.cs b/Scripts/Northrend/AzjolNerub/AzjolNerub/BossNadronox.cs index e8583e70e..eafe167c7 100644 --- a/Scripts/Northrend/AzjolNerub/AzjolNerub/BossNadronox.cs +++ b/Scripts/Northrend/AzjolNerub/AzjolNerub/BossNadronox.cs @@ -176,255 +176,245 @@ namespace Scripts.Northrend.AzjolNerub.AzjolNerub.Nadronox } [Script] - class boss_hadronox : CreatureScript + class boss_hadronox : BossAI { - public boss_hadronox() : base("boss_hadronox") { } + public boss_hadronox(Creature creature) : base(creature, ANDataTypes.Hadronox) { } - class boss_hadronoxAI : BossAI + bool IsInCombatWithPlayer() { - public boss_hadronoxAI(Creature creature) : base(creature, ANDataTypes.Hadronox) { } - - bool IsInCombatWithPlayer() + List refs = me.GetThreatManager().getThreatList(); + foreach (HostileReference hostileRef in refs) { - List refs = me.GetThreatManager().getThreatList(); - foreach (HostileReference hostileRef in refs) - { - Unit target = hostileRef.getTarget(); - if (target) - if (target.IsControlledByPlayer()) - return true; - } + Unit target = hostileRef.getTarget(); + if (target) + if (target.IsControlledByPlayer()) + return true; + } + return false; + } + + void SetStep(byte step) + { + if (_lastPlayerCombatState) + return; + + _step = step; + me.SetHomePosition(Misc.hadronoxStep[step]); + me.GetMotionMaster().Clear(); + me.AttackStop(); + SetCombatMovement(false); + me.GetMotionMaster().MovePoint(0, Misc.hadronoxStep[step]); + } + + void SummonCrusherPack(SummonGroups group) + { + List summoned; + me.SummonCreatureGroup((byte)group, out summoned); + foreach (TempSummon summon in summoned) + { + summon.GetAI().SetData(Data.CrusherPackId, (uint)group); + summon.GetAI().DoAction(ActionIds.PackWalk); + } + } + + public override void MovementInform(MovementGeneratorType type, uint id) + { + if (type != MovementGeneratorType.Point) + return; + SetCombatMovement(true); + AttackStart(me.GetVictim()); + if (_step < Misc.hadronoxStep.Length - 1) + return; + DoCastAOE(SpellIds.WebFrontDoors); + DoCastAOE(SpellIds.WebSideDoors); + _doorsWebbed = true; + DoZoneInCombat(); + } + + public override uint GetData(uint data) + { + if (data == Data.HadronoxEnteredCombat) + return _enteredCombat ? 1 : 0u; + if (data == Data.HadronoxWebbedDoors) + return _doorsWebbed ? 1 : 0u; + return 0; + } + + public override bool CanAIAttack(Unit target) + { + // Prevent Hadronox from going too far from her current home position + if (!target.IsControlledByPlayer() && target.GetDistance(me.GetHomePosition()) > 20.0f) return false; - } - - void SetStep(byte step) - { - if (_lastPlayerCombatState) - return; - - _step = step; - me.SetHomePosition(Misc.hadronoxStep[step]); - me.GetMotionMaster().Clear(); - me.AttackStop(); - SetCombatMovement(false); - me.GetMotionMaster().MovePoint(0, Misc.hadronoxStep[step]); - } - - void SummonCrusherPack(SummonGroups group) - { - List summoned; - me.SummonCreatureGroup((byte)group, out summoned); - foreach (TempSummon summon in summoned) - { - summon.GetAI().SetData(Data.CrusherPackId, (uint)group); - summon.GetAI().DoAction(ActionIds.PackWalk); - } - } - - public override void MovementInform(MovementGeneratorType type, uint id) - { - if (type != MovementGeneratorType.Point) - return; - SetCombatMovement(true); - AttackStart(me.GetVictim()); - if (_step < Misc.hadronoxStep.Length - 1) - return; - DoCastAOE(SpellIds.WebFrontDoors); - DoCastAOE(SpellIds.WebSideDoors); - _doorsWebbed = true; - DoZoneInCombat(); - } - - public override uint GetData(uint data) - { - if (data == Data.HadronoxEnteredCombat) - return _enteredCombat ? 1 : 0u; - if (data == Data.HadronoxWebbedDoors) - return _doorsWebbed ? 1 : 0u; - return 0; - } - - public override bool CanAIAttack(Unit target) - { - // Prevent Hadronox from going too far from her current home position - if (!target.IsControlledByPlayer() && target.GetDistance(me.GetHomePosition()) > 20.0f) - return false; - return base.CanAIAttack(target); - } - - public override void EnterCombat(Unit who) - { - _scheduler.CancelAll(); - _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); - - _scheduler.Schedule(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(7), task => - { - DoCastAOE(SpellIds.LeechPoison); - task.Repeat(TimeSpan.FromSeconds(7), TimeSpan.FromSeconds(9)); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(7), TimeSpan.FromSeconds(13), task => - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100.0f); - if (target) - DoCast(target, SpellIds.AcidCloud); - task.Repeat(TimeSpan.FromSeconds(16), TimeSpan.FromSeconds(23)); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(13), TimeSpan.FromSeconds(19), task => - { - DoCastAOE(SpellIds.WebGrab); - task.Repeat(TimeSpan.FromSeconds(20), TimeSpan.FromSeconds(25)); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(7), task => - { - DoCastVictim(SpellIds.PierceArmor); - task.Repeat(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(15)); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(1), task => - { - if (IsInCombatWithPlayer() != _lastPlayerCombatState) - { - _lastPlayerCombatState = !_lastPlayerCombatState; - if (_lastPlayerCombatState) // we are now in combat with players - { - if (!instance.CheckRequiredBosses(ANDataTypes.Hadronox)) - { - EnterEvadeMode(EvadeReason.SequenceBreak); - return; - } - // cancel current point movement if engaged by players - if (me.GetMotionMaster().GetCurrentMovementGeneratorType() == MovementGeneratorType.Point) - { - me.GetMotionMaster().Clear(); - SetCombatMovement(true); - AttackStart(me.GetVictim()); - } - } - else // we are no longer in combat with players - reset the encounter - EnterEvadeMode(EvadeReason.NoHostiles); - } - task.Repeat(TimeSpan.FromSeconds(1)); - }); - - me.setActive(true); - } - - public override void DoAction(int action) - { - switch (action) - { - case ActionIds.CrusherEngaged: - if (_enteredCombat) - break; - instance.SetBossState(ANDataTypes.Hadronox, EncounterState.InProgress); - _enteredCombat = true; - SummonCrusherPack(SummonGroups.Crusher2); - SummonCrusherPack(SummonGroups.Crusher3); - break; - case ActionIds.HadronoxMove: - if (_step < Misc.hadronoxStep.Length - 1) - { - SetStep((byte)(_step + 1)); - Talk(TextIds.EmoteHadronoxMove); - } - break; - } - } - - public override void EnterEvadeMode(EvadeReason why) - { - List triggers = new List(); - me.GetCreatureListWithEntryInGrid(triggers, CreatureIds.WorldtriggerLarge); - foreach (Creature trigger in triggers) - { - if (trigger.HasAura(SpellIds.SummonChampionPeriodic) || trigger.HasAura(SpellIds.WebFrontDoors) || trigger.HasAura(SpellIds.WebSideDoors)) - _DespawnAtEvade(25, trigger); - } - _DespawnAtEvade(25); - summons.DespawnAll(); - foreach (ObjectGuid gNerubian in _anubar) - { - Creature nerubian = ObjectAccessor.GetCreature(me, gNerubian); - if (nerubian) - nerubian.DespawnOrUnsummon(); - } - } - - public override void SetGUID(ObjectGuid guid, int what) - { - _anubar.Add(guid); - } - - public void Initialize() - { - me.SetFloatValue(UnitFields.BoundingRadius, 9.0f); - me.SetFloatValue(UnitFields.CombatReach, 9.0f); - _enteredCombat = false; - _doorsWebbed = false; - _lastPlayerCombatState = false; - SetStep(0); - SetCombatMovement(true); - SummonCrusherPack(SummonGroups.Crusher1); - } - - public override void InitializeAI() - { - base.InitializeAI(); - if (me.IsAlive()) - Initialize(); - } - - public override void JustRespawned() - { - base.JustRespawned(); - Initialize(); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _scheduler.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - DoMeleeAttackIfReady(); - } - - // Safeguard to prevent Hadronox dying to NPCs - public override void DamageTaken(Unit who, ref uint damage) - { - if (!who.IsControlledByPlayer() && me.HealthBelowPct(70)) - { - if (me.HealthBelowPctDamaged(5, damage)) - damage = 0; - else - damage *= (uint)((me.GetHealthPct() - 5.0f) / 65.0f); - } - } - - public override void JustSummoned(Creature summon) - { - summons.Summon(summon); - // Do not enter combat with zone - } - - bool _enteredCombat; // has a player entered combat with the first crusher pack? (talk and spawn two more packs) - bool _doorsWebbed; // obvious - have we reached the top and webbed the doors shut? (trigger for hadronox denied achievement) - bool _lastPlayerCombatState; // was there a player in our threat list the last time we checked (we check every second) - byte _step; - List _anubar = new List(); + return base.CanAIAttack(target); } - public override CreatureAI GetAI(Creature creature) + public override void EnterCombat(Unit who) { - return GetInstanceAI(creature); + _scheduler.CancelAll(); + _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); + + _scheduler.Schedule(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(7), task => + { + DoCastAOE(SpellIds.LeechPoison); + task.Repeat(TimeSpan.FromSeconds(7), TimeSpan.FromSeconds(9)); + }); + + _scheduler.Schedule(TimeSpan.FromSeconds(7), TimeSpan.FromSeconds(13), task => + { + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100.0f); + if (target) + DoCast(target, SpellIds.AcidCloud); + task.Repeat(TimeSpan.FromSeconds(16), TimeSpan.FromSeconds(23)); + }); + + _scheduler.Schedule(TimeSpan.FromSeconds(13), TimeSpan.FromSeconds(19), task => + { + DoCastAOE(SpellIds.WebGrab); + task.Repeat(TimeSpan.FromSeconds(20), TimeSpan.FromSeconds(25)); + }); + + _scheduler.Schedule(TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(7), task => + { + DoCastVictim(SpellIds.PierceArmor); + task.Repeat(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(15)); + }); + + _scheduler.Schedule(TimeSpan.FromSeconds(1), task => + { + if (IsInCombatWithPlayer() != _lastPlayerCombatState) + { + _lastPlayerCombatState = !_lastPlayerCombatState; + if (_lastPlayerCombatState) // we are now in combat with players + { + if (!instance.CheckRequiredBosses(ANDataTypes.Hadronox)) + { + EnterEvadeMode(EvadeReason.SequenceBreak); + return; + } + // cancel current point movement if engaged by players + if (me.GetMotionMaster().GetCurrentMovementGeneratorType() == MovementGeneratorType.Point) + { + me.GetMotionMaster().Clear(); + SetCombatMovement(true); + AttackStart(me.GetVictim()); + } + } + else // we are no longer in combat with players - reset the encounter + EnterEvadeMode(EvadeReason.NoHostiles); + } + task.Repeat(TimeSpan.FromSeconds(1)); + }); + + me.setActive(true); } + + public override void DoAction(int action) + { + switch (action) + { + case ActionIds.CrusherEngaged: + if (_enteredCombat) + break; + instance.SetBossState(ANDataTypes.Hadronox, EncounterState.InProgress); + _enteredCombat = true; + SummonCrusherPack(SummonGroups.Crusher2); + SummonCrusherPack(SummonGroups.Crusher3); + break; + case ActionIds.HadronoxMove: + if (_step < Misc.hadronoxStep.Length - 1) + { + SetStep((byte)(_step + 1)); + Talk(TextIds.EmoteHadronoxMove); + } + break; + } + } + + public override void EnterEvadeMode(EvadeReason why) + { + List triggers = new List(); + me.GetCreatureListWithEntryInGrid(triggers, CreatureIds.WorldtriggerLarge); + foreach (Creature trigger in triggers) + { + if (trigger.HasAura(SpellIds.SummonChampionPeriodic) || trigger.HasAura(SpellIds.WebFrontDoors) || trigger.HasAura(SpellIds.WebSideDoors)) + _DespawnAtEvade(25, trigger); + } + _DespawnAtEvade(25); + summons.DespawnAll(); + foreach (ObjectGuid gNerubian in _anubar) + { + Creature nerubian = ObjectAccessor.GetCreature(me, gNerubian); + if (nerubian) + nerubian.DespawnOrUnsummon(); + } + } + + public override void SetGUID(ObjectGuid guid, int what) + { + _anubar.Add(guid); + } + + public void Initialize() + { + me.SetFloatValue(UnitFields.BoundingRadius, 9.0f); + me.SetFloatValue(UnitFields.CombatReach, 9.0f); + _enteredCombat = false; + _doorsWebbed = false; + _lastPlayerCombatState = false; + SetStep(0); + SetCombatMovement(true); + SummonCrusherPack(SummonGroups.Crusher1); + } + + public override void InitializeAI() + { + base.InitializeAI(); + if (me.IsAlive()) + Initialize(); + } + + public override void JustRespawned() + { + base.JustRespawned(); + Initialize(); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _scheduler.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + DoMeleeAttackIfReady(); + } + + // Safeguard to prevent Hadronox dying to NPCs + public override void DamageTaken(Unit who, ref uint damage) + { + if (!who.IsControlledByPlayer() && me.HealthBelowPct(70)) + { + if (me.HealthBelowPctDamaged(5, damage)) + damage = 0; + else + damage *= (uint)((me.GetHealthPct() - 5.0f) / 65.0f); + } + } + + public override void JustSummoned(Creature summon) + { + summons.Summon(summon); + // Do not enter combat with zone + } + + bool _enteredCombat; // has a player entered combat with the first crusher pack? (talk and spawn two more packs) + bool _doorsWebbed; // obvious - have we reached the top and webbed the doors shut? (trigger for hadronox denied achievement) + bool _lastPlayerCombatState; // was there a player in our threat list the last time we checked (we check every second) + byte _step; + List _anubar = new List(); } class npc_hadronox_crusherPackAI : ScriptedAI @@ -539,152 +529,112 @@ namespace Scripts.Northrend.AzjolNerub.AzjolNerub.Nadronox } [Script] - class npc_anub_ar_crusher : CreatureScript + class npc_anub_ar_crusher : npc_hadronox_crusherPackAI { - public npc_anub_ar_crusher() : base("npc_anub_ar_crusher") { } + public npc_anub_ar_crusher(Creature creature) : base(creature, Misc.crusherWaypoints) { } - class npc_anub_ar_crusherAI : npc_hadronox_crusherPackAI + public override void _EnterCombat() { - public npc_anub_ar_crusherAI(Creature creature) : base(creature, Misc.crusherWaypoints) { } - - public override void _EnterCombat() + _scheduler.Schedule(TimeSpan.FromSeconds(8), TimeSpan.FromSeconds(12), task => { - _scheduler.Schedule(TimeSpan.FromSeconds(8), TimeSpan.FromSeconds(12), task => - { - DoCastVictim(SpellIds.Smash); - task.Repeat(TimeSpan.FromSeconds(13), TimeSpan.FromSeconds(21)); - }); + DoCastVictim(SpellIds.Smash); + task.Repeat(TimeSpan.FromSeconds(13), TimeSpan.FromSeconds(21)); + }); - if (_myPack != SummonGroups.Crusher1) + if (_myPack != SummonGroups.Crusher1) + return; + + Creature hadronox = _instance.GetCreature(ANDataTypes.Hadronox); + if (hadronox) + { + if (hadronox.GetAI().GetData(Data.HadronoxEnteredCombat) != 0) return; - - Creature hadronox = _instance.GetCreature(ANDataTypes.Hadronox); - if (hadronox) - { - if (hadronox.GetAI().GetData(Data.HadronoxEnteredCombat) != 0) - return; - hadronox.GetAI().DoAction(ActionIds.CrusherEngaged); - } - - Talk(TextIds.SayCrusherAggro); + hadronox.GetAI().DoAction(ActionIds.CrusherEngaged); } - public override void DamageTaken(Unit source, ref uint damage) - { - if (_hadFrenzy || !me.HealthBelowPctDamaged(25, damage)) - return; - _hadFrenzy = true; - Talk(TextIds.EmoteCrusherFrenzy); - DoCastSelf(SpellIds.Frenzy); - } - - public override void JustDied(Unit killer) - { - Creature hadronox = _instance.GetCreature(ANDataTypes.Hadronox); - if (hadronox) - hadronox.GetAI().DoAction(ActionIds.HadronoxMove); - base.JustDied(killer); - } - - bool _hadFrenzy; + Talk(TextIds.SayCrusherAggro); } - public override CreatureAI GetAI(Creature creature) + public override void DamageTaken(Unit source, ref uint damage) { - return GetInstanceAI(creature); + if (_hadFrenzy || !me.HealthBelowPctDamaged(25, damage)) + return; + _hadFrenzy = true; + Talk(TextIds.EmoteCrusherFrenzy); + DoCastSelf(SpellIds.Frenzy); + } + + public override void JustDied(Unit killer) + { + Creature hadronox = _instance.GetCreature(ANDataTypes.Hadronox); + if (hadronox) + hadronox.GetAI().DoAction(ActionIds.HadronoxMove); + base.JustDied(killer); + } + + bool _hadFrenzy; + } + + [Script] + class npc_anub_ar_crusher_champion : npc_hadronox_crusherPackAI + { + public npc_anub_ar_crusher_champion(Creature creature) : base(creature, Misc.championWaypoints) { } + + public override void _EnterCombat() + { + _scheduler.Schedule(TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(8), task => + { + DoCastVictim(SpellIds.Rend); + task.Repeat(TimeSpan.FromSeconds(12), TimeSpan.FromSeconds(16)); + }); + + _scheduler.Schedule(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(19), task => + { + DoCastVictim(SpellIds.Pummel); + task.Repeat(TimeSpan.FromSeconds(12), TimeSpan.FromSeconds(17)); + }); } } [Script] - class npc_anub_ar_crusher_champion : CreatureScript + class npc_anub_ar_crusher_crypt_fiend : npc_hadronox_crusherPackAI { - public npc_anub_ar_crusher_champion() : base("npc_anub_ar_crusher_champion") { } + public npc_anub_ar_crusher_crypt_fiend(Creature creature) : base(creature, Misc.cryptFiendWaypoints) { } - class npc_anub_ar_crusher_championAI : npc_hadronox_crusherPackAI + public override void _EnterCombat() { - public npc_anub_ar_crusher_championAI(Creature creature) : base(creature, Misc.championWaypoints) { } - - public override void _EnterCombat() + _scheduler.Schedule(TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(8), task => { - _scheduler.Schedule(TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(8), task => - { - DoCastVictim(SpellIds.Rend); - task.Repeat(TimeSpan.FromSeconds(12), TimeSpan.FromSeconds(16)); - }); + DoCastVictim(SpellIds.CrushingWebs); + task.Repeat(TimeSpan.FromSeconds(12), TimeSpan.FromSeconds(16)); + }); - _scheduler.Schedule(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(19), task => - { - DoCastVictim(SpellIds.Pummel); - task.Repeat(TimeSpan.FromSeconds(12), TimeSpan.FromSeconds(17)); - }); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); + _scheduler.Schedule(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(19), task => + { + DoCastVictim(SpellIds.InfectedWound); + task.Repeat(TimeSpan.FromSeconds(16), TimeSpan.FromSeconds(25)); + }); } } [Script] - class npc_anub_ar_crusher_crypt_fiend : CreatureScript + class npc_anub_ar_crusher_necromancer : npc_hadronox_crusherPackAI { - public npc_anub_ar_crusher_crypt_fiend() : base("npc_anub_ar_crusher_crypt_fiend") { } + public npc_anub_ar_crusher_necromancer(Creature creature) : base(creature, Misc.necromancerWaypoints) { } - class npc_anub_ar_crusher_crypt_fiendAI : npc_hadronox_crusherPackAI + public override void _EnterCombat() { - public npc_anub_ar_crusher_crypt_fiendAI(Creature creature) : base(creature, Misc.cryptFiendWaypoints) { } - - public override void _EnterCombat() + _scheduler.Schedule(TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(4), task => { - _scheduler.Schedule(TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(8), task => - { - DoCastVictim(SpellIds.CrushingWebs); - task.Repeat(TimeSpan.FromSeconds(12), TimeSpan.FromSeconds(16)); - }); + DoCastVictim(SpellIds.ShadowBolt); + task.Repeat(TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(5)); + }); - _scheduler.Schedule(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(19), task => - { - DoCastVictim(SpellIds.InfectedWound); - task.Repeat(TimeSpan.FromSeconds(16), TimeSpan.FromSeconds(25)); - }); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } - } - - [Script] - class npc_anub_ar_crusher_necromancer : CreatureScript - { - public npc_anub_ar_crusher_necromancer() : base("npc_anub_ar_crusher_necromancer") { } - - class npc_anub_ar_crusher_necromancerAI : npc_hadronox_crusherPackAI - { - public npc_anub_ar_crusher_necromancerAI(Creature creature) : base(creature, Misc.necromancerWaypoints) { } - - public override void _EnterCombat() + _scheduler.Schedule(TimeSpan.FromSeconds(37), TimeSpan.FromSeconds(45), task => { - _scheduler.Schedule(TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(4), task => - { - DoCastVictim(SpellIds.ShadowBolt); - task.Repeat(TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(5)); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(37), TimeSpan.FromSeconds(45), task => - { - DoCastVictim(RandomHelper.URand(0, 1) != 0 ? SpellIds.AnimateBones2 : SpellIds.AnimateBones1); - task.Repeat(TimeSpan.FromSeconds(35), TimeSpan.FromSeconds(50)); - }); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); + DoCastVictim(RandomHelper.URand(0, 1) != 0 ? SpellIds.AnimateBones2 : SpellIds.AnimateBones1); + task.Repeat(TimeSpan.FromSeconds(35), TimeSpan.FromSeconds(50)); + }); } } @@ -786,119 +736,92 @@ namespace Scripts.Northrend.AzjolNerub.AzjolNerub.Nadronox } [Script] - class npc_anub_ar_champion : CreatureScript + class npc_anub_ar_champion : npc_hadronox_foeAI { - public npc_anub_ar_champion() : base("npc_anub_ar_champion") { } + public npc_anub_ar_champion(Creature creature) : base(creature) { } - class npc_anub_ar_championAI : npc_hadronox_foeAI + public override void EnterCombat(Unit who) { - public npc_anub_ar_championAI(Creature creature) : base(creature) { } - - public override void EnterCombat(Unit who) + _scheduler.Schedule(TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(8), task => { - _scheduler.Schedule(TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(8), task => - { - DoCastVictim(SpellIds.Rend); - task.Repeat(TimeSpan.FromSeconds(12), TimeSpan.FromSeconds(16)); - }); + DoCastVictim(SpellIds.Rend); + task.Repeat(TimeSpan.FromSeconds(12), TimeSpan.FromSeconds(16)); + }); - _scheduler.Schedule(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(19), task => - { - DoCastVictim(SpellIds.Pummel); - task.Repeat(TimeSpan.FromSeconds(12), TimeSpan.FromSeconds(17)); - }); + _scheduler.Schedule(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(19), task => + { + DoCastVictim(SpellIds.Pummel); + task.Repeat(TimeSpan.FromSeconds(12), TimeSpan.FromSeconds(17)); + }); - _scheduler.Schedule(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(50), task => - { - DoCastVictim(SpellIds.Taunt); - task.Repeat(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(50)); - }); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); + _scheduler.Schedule(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(50), task => + { + DoCastVictim(SpellIds.Taunt); + task.Repeat(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(50)); + }); } } [Script] - class npc_anub_ar_crypt_fiend : CreatureScript + class npc_anub_ar_crypt_fiend : npc_hadronox_foeAI { - public npc_anub_ar_crypt_fiend() : base("npc_anub_ar_crypt_fiend") { } + public npc_anub_ar_crypt_fiend(Creature creature) : base(creature) { } - class npc_anub_ar_crypt_fiendAI : npc_hadronox_foeAI + public override void EnterCombat(Unit who) { - public npc_anub_ar_crypt_fiendAI(Creature creature) : base(creature) { } - - public override void EnterCombat(Unit who) + _scheduler.Schedule(TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(8), task => { - _scheduler.Schedule(TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(8), task => - { - DoCastVictim(SpellIds.CrushingWebs); - task.Repeat(TimeSpan.FromSeconds(12), TimeSpan.FromSeconds(16)); - }); + DoCastVictim(SpellIds.CrushingWebs); + task.Repeat(TimeSpan.FromSeconds(12), TimeSpan.FromSeconds(16)); + }); - _scheduler.Schedule(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(19), task => - { - DoCastVictim(SpellIds.InfectedWound); - task.Repeat(TimeSpan.FromSeconds(16), TimeSpan.FromSeconds(25)); - }); + _scheduler.Schedule(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(19), task => + { + DoCastVictim(SpellIds.InfectedWound); + task.Repeat(TimeSpan.FromSeconds(16), TimeSpan.FromSeconds(25)); + }); - _scheduler.Schedule(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(50), task => - { - DoCastVictim(SpellIds.Taunt); - task.Repeat(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(50)); - }); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); + _scheduler.Schedule(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(50), task => + { + DoCastVictim(SpellIds.Taunt); + task.Repeat(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(50)); + }); } } [Script] - class npc_anub_ar_necromancer : CreatureScript + class npc_anub_ar_necromancer : npc_hadronox_foeAI { - public npc_anub_ar_necromancer() : base("npc_anub_ar_necromancer") { } + public npc_anub_ar_necromancer(Creature creature) : base(creature) { } - class npc_anub_ar_necromancerAI : npc_hadronox_foeAI + public override void EnterCombat(Unit who) { - public npc_anub_ar_necromancerAI(Creature creature) : base(creature) { } - - public override void EnterCombat(Unit who) + _scheduler.Schedule(TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(4), task => { - _scheduler.Schedule(TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(4), task => - { - DoCastVictim(SpellIds.ShadowBolt); - task.Repeat(TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(5)); - }); + DoCastVictim(SpellIds.ShadowBolt); + task.Repeat(TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(5)); + }); - _scheduler.Schedule(TimeSpan.FromSeconds(37), TimeSpan.FromSeconds(45), task => - { - DoCastVictim(RandomHelper.URand(0, 1) != 0 ? SpellIds.AnimateBones2 : SpellIds.AnimateBones1); - task.Repeat(TimeSpan.FromSeconds(35), TimeSpan.FromSeconds(50)); - }); + _scheduler.Schedule(TimeSpan.FromSeconds(37), TimeSpan.FromSeconds(45), task => + { + DoCastVictim(RandomHelper.URand(0, 1) != 0 ? SpellIds.AnimateBones2 : SpellIds.AnimateBones1); + task.Repeat(TimeSpan.FromSeconds(35), TimeSpan.FromSeconds(50)); + }); - _scheduler.Schedule(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(50), task => - { - DoCastVictim(SpellIds.Taunt); - task.Repeat(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(50)); - }); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); + _scheduler.Schedule(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(50), task => + { + DoCastVictim(SpellIds.Taunt); + task.Repeat(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(50)); + }); } } - class spell_hadronox_periodic_summon_template_AuraScript : AuraScript + [Script("spell_hadronox_periodic_summon_champion", SpellIds.SummonChampionTop, SpellIds.SummonChampionBottom)] + [Script("spell_hadronox_periodic_summon_crypt_fiend", SpellIds.SummonCryptFiendTop, SpellIds.SummonCryptFiendBottom)] + [Script("spell_hadronox_periodic_summon_necromancer", SpellIds.SummonNecromancerTop, SpellIds.SummonNecromancerBottom)] + class spell_hadronox_periodic_summon_template : AuraScript { - public spell_hadronox_periodic_summon_template_AuraScript(uint topSpellId, uint bottomSpellId) : base() + public spell_hadronox_periodic_summon_template(uint topSpellId, uint bottomSpellId) : base() { _topSpellId = topSpellId; _bottomSpellId = bottomSpellId; @@ -946,122 +869,54 @@ namespace Scripts.Northrend.AzjolNerub.AzjolNerub.Nadronox } [Script] - class spell_hadronox_periodic_summon_champion : SpellScriptLoader + class spell_hadronox_leeching_poison : AuraScript { - public spell_hadronox_periodic_summon_champion() : base("spell_hadronox_periodic_summon_champion") { } - - class spell_hadronox_periodic_summon_champion_AuraScript : spell_hadronox_periodic_summon_template_AuraScript + public override bool Validate(SpellInfo spell) { - public spell_hadronox_periodic_summon_champion_AuraScript() : base(SpellIds.SummonChampionTop, SpellIds.SummonChampionBottom) { } + return ValidateSpellInfo(SpellIds.LeechPoisonHeal); } - public override AuraScript GetAuraScript() + void HandleEffectRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_hadronox_periodic_summon_champion_AuraScript(); + if (GetTargetApplication().GetRemoveMode() != AuraRemoveMode.ByDeath) + return; + + if (GetTarget().IsGuardian()) + return; + + Unit caster = GetCaster(); + if (caster) + caster.CastSpell(caster, SpellIds.LeechPoisonHeal, true); + } + + public override void Register() + { + OnEffectRemove.Add(new EffectApplyHandler(HandleEffectRemove, 0, AuraType.PeriodicLeech, AuraEffectHandleModes.Real)); } } [Script] - class spell_hadronox_periodic_summon_crypt_fiend : SpellScriptLoader + class spell_hadronox_web_doors : SpellScript { - public spell_hadronox_periodic_summon_crypt_fiend() : base("spell_hadronox_periodic_summon_crypt_fiend") { } - - class spell_hadronox_periodic_summon_crypt_fiend_AuraScript : spell_hadronox_periodic_summon_template_AuraScript + public override bool Validate(SpellInfo spell) { - public spell_hadronox_periodic_summon_crypt_fiend_AuraScript() : base(SpellIds.SummonCryptFiendTop, SpellIds.SummonCryptFiendBottom) { } + return ValidateSpellInfo(SpellIds.SummonChampionPeriodic, SpellIds.SummonCryptFiendPeriodic, SpellIds.SummonNecromancerPeriodic); } - public override AuraScript GetAuraScript() + void HandleDummy(uint effIndex) { - return new spell_hadronox_periodic_summon_crypt_fiend_AuraScript(); - } - } - - [Script] - class spell_hadronox_periodic_summon_necromancer : SpellScriptLoader - { - public spell_hadronox_periodic_summon_necromancer() : base("spell_hadronox_periodic_summon_necromancer") { } - - class spell_hadronox_periodic_summon_necromancer_AuraScript : spell_hadronox_periodic_summon_template_AuraScript - { - public spell_hadronox_periodic_summon_necromancer_AuraScript() : base(SpellIds.SummonNecromancerTop, SpellIds.SummonNecromancerBottom) { } - } - - public override AuraScript GetAuraScript() - { - return new spell_hadronox_periodic_summon_necromancer_AuraScript(); - } - } - - [Script] - class spell_hadronox_leeching_poison : SpellScriptLoader - { - public spell_hadronox_leeching_poison() : base("spell_hadronox_leeching_poison") { } - - class spell_hadronox_leeching_poison_AuraScript : AuraScript - { - public override bool Validate(SpellInfo spell) + Unit target = GetHitUnit(); + if (target) { - return ValidateSpellInfo(SpellIds.LeechPoisonHeal); - } - - void HandleEffectRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - if (GetTargetApplication().GetRemoveMode() != AuraRemoveMode.ByDeath) - return; - - if (GetTarget().IsGuardian()) - return; - - Unit caster = GetCaster(); - if (caster) - caster.CastSpell(caster, SpellIds.LeechPoisonHeal, true); - } - - public override void Register() - { - OnEffectRemove.Add(new EffectApplyHandler(HandleEffectRemove, 0, AuraType.PeriodicLeech, AuraEffectHandleModes.Real)); + target.RemoveAurasDueToSpell(SpellIds.SummonChampionPeriodic); + target.RemoveAurasDueToSpell(SpellIds.SummonCryptFiendPeriodic); + target.RemoveAurasDueToSpell(SpellIds.SummonNecromancerPeriodic); } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_hadronox_leeching_poison_AuraScript(); - } - } - - [Script] - class spell_hadronox_web_doors : SpellScriptLoader - { - public spell_hadronox_web_doors() : base("spell_hadronox_web_doors") { } - - class spell_hadronox_web_doors_SpellScript : SpellScript - { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.SummonChampionPeriodic, SpellIds.SummonCryptFiendPeriodic, SpellIds.SummonNecromancerPeriodic); - } - - void HandleDummy(uint effIndex) - { - Unit target = GetHitUnit(); - if (target) - { - target.RemoveAurasDueToSpell(SpellIds.SummonChampionPeriodic); - target.RemoveAurasDueToSpell(SpellIds.SummonCryptFiendPeriodic); - target.RemoveAurasDueToSpell(SpellIds.SummonNecromancerPeriodic); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.ApplyAura)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_hadronox_web_doors_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.ApplyAura)); } } diff --git a/Scripts/Northrend/AzjolNerub/AzjolNerub/InstanceAzjolNerub.cs b/Scripts/Northrend/AzjolNerub/AzjolNerub/InstanceAzjolNerub.cs index 8e39df5fa..336b15e4b 100644 --- a/Scripts/Northrend/AzjolNerub/AzjolNerub/InstanceAzjolNerub.cs +++ b/Scripts/Northrend/AzjolNerub/AzjolNerub/InstanceAzjolNerub.cs @@ -22,41 +22,6 @@ using Game.Scripting; namespace Scripts.Northrend.AzjolNerub.AzjolNerub { - [Script] - class instance_azjol_nerub : InstanceMapScript - { - public instance_azjol_nerub() : base(nameof(instance_azjol_nerub), 601) { } - - class instance_azjol_nerub_InstanceScript : InstanceScript - { - public instance_azjol_nerub_InstanceScript(Map map) : base(map) - { - SetHeaders(ANInstanceMisc.DataHeader); - SetBossNumber(ANInstanceMisc.EncounterCount); - LoadBossBoundaries(ANInstanceMisc.boundaries); - LoadDoorData(ANInstanceMisc.doorData); - LoadObjectData(ANInstanceMisc.creatureData, ANInstanceMisc.gameobjectData); - } - - public override void OnUnitDeath(Unit who) - { - base.OnUnitDeath(who); - Creature creature = who.ToCreature(); - if (!creature || creature.IsCritter() || creature.IsControlledByPlayer()) - return; - - Creature gatewatcher = GetCreature(ANDataTypes.KrikthirTheGatewatcher); - if (gatewatcher) - gatewatcher.GetAI().DoAction(-ANInstanceMisc.ActionGatewatcherGreet); - } - } - - public override InstanceScript GetInstanceScript(InstanceMap map) - { - return new instance_azjol_nerub_InstanceScript(map); - } - } - struct ANDataTypes { // Encounter States/Boss Guids @@ -128,4 +93,39 @@ namespace Scripts.Northrend.AzjolNerub.AzjolNerub new BossBoundaryEntry(ANDataTypes.Anubarak, new CircleBoundary(new Position(550.6178f, 253.5917f), 26.0f)) }; } + + [Script] + class instance_azjol_nerub : InstanceMapScript + { + public instance_azjol_nerub() : base(nameof(instance_azjol_nerub), 601) { } + + class instance_azjol_nerub_InstanceScript : InstanceScript + { + public instance_azjol_nerub_InstanceScript(Map map) : base(map) + { + SetHeaders(ANInstanceMisc.DataHeader); + SetBossNumber(ANInstanceMisc.EncounterCount); + LoadBossBoundaries(ANInstanceMisc.boundaries); + LoadDoorData(ANInstanceMisc.doorData); + LoadObjectData(ANInstanceMisc.creatureData, ANInstanceMisc.gameobjectData); + } + + public override void OnUnitDeath(Unit who) + { + base.OnUnitDeath(who); + Creature creature = who.ToCreature(); + if (!creature || creature.IsCritter() || creature.IsControlledByPlayer()) + return; + + Creature gatewatcher = GetCreature(ANDataTypes.KrikthirTheGatewatcher); + if (gatewatcher) + gatewatcher.GetAI().DoAction(-ANInstanceMisc.ActionGatewatcherGreet); + } + } + + public override InstanceScript GetInstanceScript(InstanceMap map) + { + return new instance_azjol_nerub_InstanceScript(map); + } + } } diff --git a/Scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/GrandChampions.cs b/Scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/GrandChampions.cs index 7b3fb0751..648b1b5b4 100644 --- a/Scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/GrandChampions.cs +++ b/Scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/GrandChampions.cs @@ -71,237 +71,160 @@ namespace Scripts.Northrend.CrusadersColiseum.TrialOfTheChampion public const uint POISON_BOTTLE = 67701; } - /* - struct Point - { - float x, y, z; - } - - const Point MovementPoint[] = - { - {746.84f, 623.15f, 411.41f}, - {747.96f, 620.29f, 411.09f}, - {750.23f, 618.35f, 411.09f} - } - */ - - /* - * Generic AI for vehicles used by npcs in ToC, it needs more improvements. * - * Script Complete: 25%. * - */ - [Script] - class generic_vehicleAI_toc5 : CreatureScript + class generic_vehicleAI_toc5 : npc_escortAI { - public generic_vehicleAI_toc5() : base("generic_vehicleAI_toc5") { } - - class generic_vehicleAI_toc5AI : npc_escortAI + public generic_vehicleAI_toc5(Creature creature) : base(creature) { - public generic_vehicleAI_toc5AI(Creature creature) : base(creature) - { - Initialize(); - SetDespawnAtEnd(false); - uiWaypointPath = 0; + Initialize(); + SetDespawnAtEnd(false); + uiWaypointPath = 0; - instance = creature.GetInstanceScript(); + instance = creature.GetInstanceScript(); + } + + void Initialize() + { + uiChargeTimer = 5000; + uiShieldBreakerTimer = 8000; + uiBuffTimer = RandomHelper.URand(30000, 60000); + } + + public override void Reset() + { + Initialize(); + } + + public override void SetData(uint uiType, uint uiData) + { + switch (uiType) + { + case 1: + AddWaypoint(0, 747.36f, 634.07f, 411.572f); + AddWaypoint(1, 780.43f, 607.15f, 411.82f); + AddWaypoint(2, 785.99f, 599.41f, 411.92f); + AddWaypoint(3, 778.44f, 601.64f, 411.79f); + uiWaypointPath = 1; + break; + case 2: + AddWaypoint(0, 747.35f, 634.07f, 411.57f); + AddWaypoint(1, 768.72f, 581.01f, 411.92f); + AddWaypoint(2, 763.55f, 590.52f, 411.71f); + uiWaypointPath = 2; + break; + case 3: + AddWaypoint(0, 747.35f, 634.07f, 411.57f); + AddWaypoint(1, 784.02f, 645.33f, 412.39f); + AddWaypoint(2, 775.67f, 641.91f, 411.91f); + uiWaypointPath = 3; + break; } - void Initialize() - { - uiChargeTimer = 5000; - uiShieldBreakerTimer = 8000; - uiBuffTimer = RandomHelper.URand(30000, 60000); - } + if (uiType <= 3) + Start(false, true); + } - public override void Reset() + public override void WaypointReached(uint waypointId) + { + switch (waypointId) { - Initialize(); - } - - public override void SetData(uint uiType, uint uiData) - { - switch (uiType) - { - case 1: - AddWaypoint(0, 747.36f, 634.07f, 411.572f); - AddWaypoint(1, 780.43f, 607.15f, 411.82f); - AddWaypoint(2, 785.99f, 599.41f, 411.92f); - AddWaypoint(3, 778.44f, 601.64f, 411.79f); - uiWaypointPath = 1; - break; - case 2: - AddWaypoint(0, 747.35f, 634.07f, 411.57f); - AddWaypoint(1, 768.72f, 581.01f, 411.92f); - AddWaypoint(2, 763.55f, 590.52f, 411.71f); - uiWaypointPath = 2; - break; - case 3: - AddWaypoint(0, 747.35f, 634.07f, 411.57f); - AddWaypoint(1, 784.02f, 645.33f, 412.39f); - AddWaypoint(2, 775.67f, 641.91f, 411.91f); - uiWaypointPath = 3; - break; - } - - if (uiType <= 3) - Start(false, true); - } - - public override void WaypointReached(uint waypointId) - { - switch (waypointId) - { - case 2: - if (uiWaypointPath == 3 || uiWaypointPath == 2) - instance.SetData((uint)Data.DATA_MOVEMENT_DONE, instance.GetData((uint)Data.DATA_MOVEMENT_DONE) + 1); - break; - case 3: + case 2: + if (uiWaypointPath == 3 || uiWaypointPath == 2) instance.SetData((uint)Data.DATA_MOVEMENT_DONE, instance.GetData((uint)Data.DATA_MOVEMENT_DONE) + 1); - break; + break; + case 3: + instance.SetData((uint)Data.DATA_MOVEMENT_DONE, instance.GetData((uint)Data.DATA_MOVEMENT_DONE) + 1); + break; + } + } + + public override void EnterCombat(Unit who) + { + DoCastSpellShield(); + } + + void DoCastSpellShield() + { + for (byte i = 0; i < 3; ++i) + DoCast(me, TrialOfChampionSpells.SHIELD, true); + } + + public override void UpdateAI(uint uiDiff) + { + base.UpdateAI(uiDiff); + + if (!UpdateVictim()) + return; + + if (uiBuffTimer <= uiDiff) + { + if (!me.HasAura(TrialOfChampionSpells.SHIELD)) + DoCastSpellShield(); + + uiBuffTimer = RandomHelper.URand(30000, 45000); + } + else + uiBuffTimer -= uiDiff; + + if (uiChargeTimer <= uiDiff) + { + var players = me.GetMap().GetPlayers(); + if (!players.Empty()) + { + foreach (var player in players) + { + if (player && !player.IsGameMaster() && me.IsInRange(player, 8.0f, 25.0f, false)) + { + DoResetThreat(); + me.AddThreat(player, 1.0f); + DoCast(player, TrialOfChampionSpells.CHARGE); + break; + } + } } + uiChargeTimer = 5000; } + else + uiChargeTimer -= uiDiff; - public override void EnterCombat(Unit who) + //dosen't work at all + if (uiShieldBreakerTimer <= uiDiff) { - DoCastSpellShield(); - } - - void DoCastSpellShield() - { - for (byte i = 0; i < 3; ++i) - DoCast(me, TrialOfChampionSpells.SHIELD, true); - } - - public override void UpdateAI(uint uiDiff) - { - base.UpdateAI(uiDiff); - - if (!UpdateVictim()) + Vehicle pVehicle = me.GetVehicleKit(); + if (!pVehicle) return; - if (uiBuffTimer <= uiDiff) - { - if (!me.HasAura(TrialOfChampionSpells.SHIELD)) - DoCastSpellShield(); - - uiBuffTimer = RandomHelper.URand(30000, 45000); - } - else - uiBuffTimer -= uiDiff; - - if (uiChargeTimer <= uiDiff) + Unit pPassenger = pVehicle.GetPassenger(0); + if (pPassenger) { var players = me.GetMap().GetPlayers(); if (!players.Empty()) { foreach (var player in players) { - if (player && !player.IsGameMaster() && me.IsInRange(player, 8.0f, 25.0f, false)) + if (player && !player.IsGameMaster() && me.IsInRange(player, 10.0f, 30.0f, false)) { - DoResetThreat(); - me.AddThreat(player, 1.0f); - DoCast(player, TrialOfChampionSpells.CHARGE); + pPassenger.CastSpell(player, TrialOfChampionSpells.SHIELD_BREAKER, true); break; } } } - uiChargeTimer = 5000; } - else - uiChargeTimer -= uiDiff; - - //dosen't work at all - if (uiShieldBreakerTimer <= uiDiff) - { - Vehicle pVehicle = me.GetVehicleKit(); - if (!pVehicle) - return; - - Unit pPassenger = pVehicle.GetPassenger(0); - if (pPassenger) - { - var players = me.GetMap().GetPlayers(); - if (!players.Empty()) - { - foreach (var player in players) - { - if (player && !player.IsGameMaster() && me.IsInRange(player, 10.0f, 30.0f, false)) - { - pPassenger.CastSpell(player, TrialOfChampionSpells.SHIELD_BREAKER, true); - break; - } - } - } - } - uiShieldBreakerTimer = 7000; - } - else - uiShieldBreakerTimer -= uiDiff; - - DoMeleeAttackIfReady(); + uiShieldBreakerTimer = 7000; } + else + uiShieldBreakerTimer -= uiDiff; - InstanceScript instance; - - uint uiChargeTimer; - uint uiShieldBreakerTimer; - uint uiBuffTimer; - - uint uiWaypointPath; + DoMeleeAttackIfReady(); } - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } + InstanceScript instance; - public static void AggroAllPlayers(Creature temp) - { - var PlList = temp.GetMap().GetPlayers(); + uint uiChargeTimer; + uint uiShieldBreakerTimer; + uint uiBuffTimer; - if (PlList.Empty()) - return; - - foreach (var player in PlList) - { - if (player) - { - if (player.IsGameMaster()) - continue; - - if (player.IsAlive()) - { - temp.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.ImmuneToPc); - temp.SetReactState(ReactStates.Aggressive); - temp.SetInCombatWith(player); - player.SetInCombatWith(temp); - temp.AddThreat(player, 0.0f); - } - } - } - } - - public static bool GrandChampionsOutVehicle(Creature me) - { - InstanceScript instance = me.GetInstanceScript(); - - if (instance == null) - return false; - - Creature pGrandChampion1 = ObjectAccessor.GetCreature(me, instance.GetGuidData((uint)Data64.DATA_GRAND_CHAMPION_1)); - Creature pGrandChampion2 = ObjectAccessor.GetCreature(me, instance.GetGuidData((uint)Data64.DATA_GRAND_CHAMPION_2)); - Creature pGrandChampion3 = ObjectAccessor.GetCreature(me, instance.GetGuidData((uint)Data64.DATA_GRAND_CHAMPION_3)); - - if (pGrandChampion1 && pGrandChampion2 && pGrandChampion3) - { - if (pGrandChampion1.m_movementInfo.transport.guid.IsEmpty() && - pGrandChampion2.m_movementInfo.transport.guid.IsEmpty() && - pGrandChampion3.m_movementInfo.transport.guid.IsEmpty()) - return true; - } - - return false; - } + uint uiWaypointPath; } abstract class boss_basic_toc5AI : ScriptedAI @@ -349,7 +272,7 @@ namespace Scripts.Northrend.CrusadersColiseum.TrialOfTheChampion public override void UpdateAI(uint diff) { - if (!bDone && generic_vehicleAI_toc5.GrandChampionsOutVehicle(me)) + if (!bDone && GrandChampionsOutVehicle(me)) { bDone = true; @@ -368,7 +291,7 @@ namespace Scripts.Northrend.CrusadersColiseum.TrialOfTheChampion { if (uiPhase == 1) { - generic_vehicleAI_toc5.AggroAllPlayers(me); + AggroAllPlayers(me); uiPhase = 0; } } @@ -381,6 +304,54 @@ namespace Scripts.Northrend.CrusadersColiseum.TrialOfTheChampion return !me.m_movementInfo.transport.guid.IsEmpty(); } + void AggroAllPlayers(Creature temp) + { + var PlList = temp.GetMap().GetPlayers(); + + if (PlList.Empty()) + return; + + foreach (var player in PlList) + { + if (player) + { + if (player.IsGameMaster()) + continue; + + if (player.IsAlive()) + { + temp.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.ImmuneToPc); + temp.SetReactState(ReactStates.Aggressive); + temp.SetInCombatWith(player); + player.SetInCombatWith(temp); + temp.AddThreat(player, 0.0f); + } + } + } + } + + bool GrandChampionsOutVehicle(Creature me) + { + InstanceScript instance = me.GetInstanceScript(); + + if (instance == null) + return false; + + Creature pGrandChampion1 = ObjectAccessor.GetCreature(me, instance.GetGuidData((uint)Data64.DATA_GRAND_CHAMPION_1)); + Creature pGrandChampion2 = ObjectAccessor.GetCreature(me, instance.GetGuidData((uint)Data64.DATA_GRAND_CHAMPION_2)); + Creature pGrandChampion3 = ObjectAccessor.GetCreature(me, instance.GetGuidData((uint)Data64.DATA_GRAND_CHAMPION_3)); + + if (pGrandChampion1 && pGrandChampion2 && pGrandChampion3) + { + if (pGrandChampion1.m_movementInfo.transport.guid.IsEmpty() && + pGrandChampion2.m_movementInfo.transport.guid.IsEmpty() && + pGrandChampion3.m_movementInfo.transport.guid.IsEmpty()) + return true; + } + + return false; + } + public TaskScheduler NonCombatEvents = new TaskScheduler(); public InstanceScript instance; @@ -393,337 +364,287 @@ namespace Scripts.Northrend.CrusadersColiseum.TrialOfTheChampion } [Script] - class boss_warrior_toc5 : CreatureScript + // Marshal Jacob Alerius && Mokra the Skullcrusher || Warrior + class boss_warrior_toc5 : boss_basic_toc5AI { - public boss_warrior_toc5() : base("boss_warrior_toc5") { } + public boss_warrior_toc5(Creature creature) : base(creature) { } - // Marshal Jacob Alerius && Mokra the Skullcrusher || Warrior - class boss_warrior_toc5AI : boss_basic_toc5AI + public override void Initialize() { - public boss_warrior_toc5AI(Creature creature) : base(creature) { } - - public override void Initialize() + _scheduler.Schedule(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(20), task => { - _scheduler.Schedule(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(20), task => - { - DoCastVictim(TrialOfChampionSpells.BLADESTORM); - task.Repeat(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(20)); - }); + DoCastVictim(TrialOfChampionSpells.BLADESTORM); + task.Repeat(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(20)); + }); - _scheduler.Schedule(TimeSpan.FromSeconds(7), task => + _scheduler.Schedule(TimeSpan.FromSeconds(7), task => + { + var players = me.GetMap().GetPlayers(); + if (!players.Empty()) { - var players = me.GetMap().GetPlayers(); - if (!players.Empty()) + foreach (var player in players) { - foreach (var player in players) + if (player && !player.IsGameMaster() && me.IsInRange(player, 8.0f, 25.0f, false)) { - if (player && !player.IsGameMaster() && me.IsInRange(player, 8.0f, 25.0f, false)) - { - DoResetThreat(); - me.AddThreat(player, 5.0f); - DoCast(player, TrialOfChampionSpells.INTERCEPT); - break; - } + DoResetThreat(); + me.AddThreat(player, 5.0f); + DoCast(player, TrialOfChampionSpells.INTERCEPT); + break; } } - task.Repeat(TimeSpan.FromSeconds(7)); - }); + } + task.Repeat(TimeSpan.FromSeconds(7)); + }); - _scheduler.Schedule(TimeSpan.FromSeconds(8), TimeSpan.FromSeconds(12), task => - { - DoCastVictim(TrialOfChampionSpells.MORTAL_STRIKE); - task.Repeat(TimeSpan.FromSeconds(8), TimeSpan.FromSeconds(12)); - }); - } - - public override void UpdateAI(uint diff) + _scheduler.Schedule(TimeSpan.FromSeconds(8), TimeSpan.FromSeconds(12), task => { - base.UpdateAI(diff); - - if (!UpdateVictim() || InVehicle()) - return; - - _scheduler.Update(diff); - - DoMeleeAttackIfReady(); - } - + DoCastVictim(TrialOfChampionSpells.MORTAL_STRIKE); + task.Repeat(TimeSpan.FromSeconds(8), TimeSpan.FromSeconds(12)); + }); } - public override CreatureAI GetAI(Creature creature) + public override void UpdateAI(uint diff) { - return GetInstanceAI(creature); + base.UpdateAI(diff); + + if (!UpdateVictim() || InVehicle()) + return; + + _scheduler.Update(diff); + + DoMeleeAttackIfReady(); + } + + } + + [Script] + // Ambrose Boltspark && Eressea Dawnsinger || Mage + class boss_mage_toc5 : boss_basic_toc5AI + { + public boss_mage_toc5(Creature creature) : base(creature) { } + + public override void Initialize() + { + _scheduler.Schedule(TimeSpan.FromSeconds(5), task => + { + DoCastVictim(TrialOfChampionSpells.FIREBALL); + task.Repeat(TimeSpan.FromSeconds(5)); + }); + + _scheduler.Schedule(TimeSpan.FromSeconds(8), task => + { + Unit target = SelectTarget(SelectAggroTarget.Random, 0); + if (target) + DoCast(target, TrialOfChampionSpells.POLYMORPH); + task.Repeat(TimeSpan.FromSeconds(8)); + }); + + _scheduler.Schedule(TimeSpan.FromSeconds(12), task => + { + DoCastAOE(TrialOfChampionSpells.BLAST_WAVE, false); + task.Repeat(TimeSpan.FromSeconds(13)); + }); + + _scheduler.Schedule(TimeSpan.FromSeconds(22), task => + { + me.InterruptNonMeleeSpells(true); + + DoCast(me, TrialOfChampionSpells.HASTE); + task.Repeat(TimeSpan.FromSeconds(22)); + }); + } + + public override void UpdateAI(uint diff) + { + base.UpdateAI(diff); + + if (!UpdateVictim() || InVehicle()) + return; + + _scheduler.Update(diff); + + DoMeleeAttackIfReady(); } } [Script] - class boss_mage_toc5 : CreatureScript + // Colosos && Runok Wildmane || Shaman + class boss_shaman_toc5 : boss_basic_toc5AI { - public boss_mage_toc5() : base("boss_mage_toc5") { } + public boss_shaman_toc5(Creature creature) : base(creature) { } - // Ambrose Boltspark && Eressea Dawnsinger || Mage - class boss_mage_toc5AI : boss_basic_toc5AI + public override void Initialize() { - public boss_mage_toc5AI(Creature creature) : base(creature) { } - - public override void Initialize() + _scheduler.Schedule(TimeSpan.FromSeconds(16), task => { - _scheduler.Schedule(TimeSpan.FromSeconds(5), task => - { - DoCastVictim(TrialOfChampionSpells.FIREBALL); - task.Repeat(TimeSpan.FromSeconds(5)); - }); + Unit target = SelectTarget(SelectAggroTarget.Random, 0); + if (target) + DoCast(target, TrialOfChampionSpells.CHAIN_LIGHTNING); - _scheduler.Schedule(TimeSpan.FromSeconds(8), task => - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0); - if (target) - DoCast(target, TrialOfChampionSpells.POLYMORPH); - task.Repeat(TimeSpan.FromSeconds(8)); - }); + task.Repeat(TimeSpan.FromSeconds(16)); + }); - _scheduler.Schedule(TimeSpan.FromSeconds(12), task => - { - DoCastAOE(TrialOfChampionSpells.BLAST_WAVE, false); - task.Repeat(TimeSpan.FromSeconds(13)); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(22), task => - { - me.InterruptNonMeleeSpells(true); - - DoCast(me, TrialOfChampionSpells.HASTE); - task.Repeat(TimeSpan.FromSeconds(22)); - }); - } - - public override void UpdateAI(uint diff) + _scheduler.Schedule(TimeSpan.FromSeconds(12), task => { - base.UpdateAI(diff); + bool bChance = RandomHelper.randChance(50); - if (!UpdateVictim() || InVehicle()) - return; - - _scheduler.Update(diff); - - DoMeleeAttackIfReady(); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } - } - - [Script] - class boss_shaman_toc5 : CreatureScript - { - public boss_shaman_toc5() : base("boss_shaman_toc5") { } - - // Colosos && Runok Wildmane || Shaman - class boss_shaman_toc5AI : boss_basic_toc5AI - { - public boss_shaman_toc5AI(Creature creature) : base(creature) { } - - public override void Initialize() - { - _scheduler.Schedule(TimeSpan.FromSeconds(16), task => + if (!bChance) { - Unit target = SelectTarget(SelectAggroTarget.Random, 0); - if (target) - DoCast(target, TrialOfChampionSpells.CHAIN_LIGHTNING); + Unit pFriend = DoSelectLowestHpFriendly(40); + if (pFriend) + DoCast(pFriend, TrialOfChampionSpells.HEALING_WAVE); + } + else + DoCast(me, TrialOfChampionSpells.HEALING_WAVE); - task.Repeat(TimeSpan.FromSeconds(16)); - }); + task.Repeat(TimeSpan.FromSeconds(12)); + }); - _scheduler.Schedule(TimeSpan.FromSeconds(12), task => - { - bool bChance = RandomHelper.randChance(50); - - if (!bChance) - { - Unit pFriend = DoSelectLowestHpFriendly(40); - if (pFriend) - DoCast(pFriend, TrialOfChampionSpells.HEALING_WAVE); - } - else - DoCast(me, TrialOfChampionSpells.HEALING_WAVE); - - task.Repeat(TimeSpan.FromSeconds(12)); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35), task => - { - DoCast(me, TrialOfChampionSpells.EARTH_SHIELD); - task.Repeat(TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35)); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(20), TimeSpan.FromSeconds(25), task => - { - DoCastVictim(TrialOfChampionSpells.HEX_OF_MENDING, true); - task.Repeat(TimeSpan.FromSeconds(20), TimeSpan.FromSeconds(25)); - }); - } - - public override void EnterCombat(Unit who) + _scheduler.Schedule(TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35), task => { DoCast(me, TrialOfChampionSpells.EARTH_SHIELD); - DoCast(who, TrialOfChampionSpells.HEX_OF_MENDING); - } + task.Repeat(TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35)); + }); - public override void UpdateAI(uint diff) + _scheduler.Schedule(TimeSpan.FromSeconds(20), TimeSpan.FromSeconds(25), task => { - base.UpdateAI(diff); - - if (!UpdateVictim() || InVehicle()) - return; - - _scheduler.Update(diff); - - DoMeleeAttackIfReady(); - } + DoCastVictim(TrialOfChampionSpells.HEX_OF_MENDING, true); + task.Repeat(TimeSpan.FromSeconds(20), TimeSpan.FromSeconds(25)); + }); } - public override CreatureAI GetAI(Creature creature) + public override void EnterCombat(Unit who) { - return GetInstanceAI(creature); + DoCast(me, TrialOfChampionSpells.EARTH_SHIELD); + DoCast(who, TrialOfChampionSpells.HEX_OF_MENDING); + } + + public override void UpdateAI(uint diff) + { + base.UpdateAI(diff); + + if (!UpdateVictim() || InVehicle()) + return; + + _scheduler.Update(diff); + + DoMeleeAttackIfReady(); } } [Script] - class boss_hunter_toc5 : CreatureScript + // Jaelyne Evensong && Zul'tore || Hunter + class boss_hunter_toc5 : boss_basic_toc5AI { - public boss_hunter_toc5() : base("boss_hunter_toc5") { } + public boss_hunter_toc5(Creature creature) : base(creature) { } - // Jaelyne Evensong && Zul'tore || Hunter - class boss_hunter_toc5AI : boss_basic_toc5AI + public override void Initialize() { - public boss_hunter_toc5AI(Creature creature) : base(creature) { } - - public override void Initialize() + _scheduler.Schedule(TimeSpan.FromSeconds(7), task => { - _scheduler.Schedule(TimeSpan.FromSeconds(7), task => - { - DoCastAOE(TrialOfChampionSpells.LIGHTNING_ARROWS, false); - task.Repeat(TimeSpan.FromSeconds(7)); - }); + DoCastAOE(TrialOfChampionSpells.LIGHTNING_ARROWS, false); + task.Repeat(TimeSpan.FromSeconds(7)); + }); - _scheduler.Schedule(TimeSpan.FromSeconds(12), task => + _scheduler.Schedule(TimeSpan.FromSeconds(12), task => + { + ObjectGuid uiTargetGUID = ObjectGuid.Empty; + Unit target = SelectTarget(SelectAggroTarget.Farthest, 0, 30.0f); + if (target) { - ObjectGuid uiTargetGUID = ObjectGuid.Empty; - Unit target = SelectTarget(SelectAggroTarget.Farthest, 0, 30.0f); - if (target) - { - uiTargetGUID = target.GetGUID(); - DoCast(target, TrialOfChampionSpells.SHOOT); - } + uiTargetGUID = target.GetGUID(); + DoCast(target, TrialOfChampionSpells.SHOOT); + } - bool bShoot = true; - task.Repeat(TimeSpan.FromSeconds(12)); - task.Schedule(TimeSpan.FromSeconds(3), task1 => + bool bShoot = true; + task.Repeat(TimeSpan.FromSeconds(12)); + task.Schedule(TimeSpan.FromSeconds(3), task1 => + { + if (bShoot) { - if (bShoot) + me.InterruptNonMeleeSpells(true); + + Unit target1 = Global.ObjAccessor.GetUnit(me, uiTargetGUID); + if (target1 && me.IsInRange(target1, 5.0f, 30.0f, false)) { - me.InterruptNonMeleeSpells(true); - - Unit target1 = Global.ObjAccessor.GetUnit(me, uiTargetGUID); - if (target1 && me.IsInRange(target1, 5.0f, 30.0f, false)) + DoCast(target1, TrialOfChampionSpells.MULTI_SHOT); + } + else + { + var players = me.GetMap().GetPlayers(); + if (!players.Empty()) { - DoCast(target1, TrialOfChampionSpells.MULTI_SHOT); - } - else - { - var players = me.GetMap().GetPlayers(); - if (!players.Empty()) + foreach (var player in players) { - foreach (var player in players) + if (player && !player.IsGameMaster() && me.IsInRange(player, 5.0f, 30.0f, false)) { - if (player && !player.IsGameMaster() && me.IsInRange(player, 5.0f, 30.0f, false)) - { - DoCast(player, TrialOfChampionSpells.MULTI_SHOT); - break; - } + DoCast(player, TrialOfChampionSpells.MULTI_SHOT); + break; } } } - bShoot = false; } - }); + bShoot = false; + } }); - } - - public override void UpdateAI(uint diff) - { - base.UpdateAI(diff); - - if (!UpdateVictim() || InVehicle()) - return; - - _scheduler.Update(diff); - - DoMeleeAttackIfReady(); - } + }); } - public override CreatureAI GetAI(Creature creature) + public override void UpdateAI(uint diff) { - return GetInstanceAI(creature); + base.UpdateAI(diff); + + if (!UpdateVictim() || InVehicle()) + return; + + _scheduler.Update(diff); + + DoMeleeAttackIfReady(); } } [Script] - class boss_rouge_toc5 : CreatureScript + // Lana Stouthammer Evensong && Deathstalker Visceri || Rouge + class boss_rouge_toc5 : boss_basic_toc5AI { - public boss_rouge_toc5() : base("boss_rouge_toc5") { } + public boss_rouge_toc5(Creature creature) : base(creature) { } - // Lana Stouthammer Evensong && Deathstalker Visceri || Rouge - class boss_rouge_toc5AI : boss_basic_toc5AI + public override void Initialize() { - public boss_rouge_toc5AI(Creature creature) : base(creature) { } - - public override void Initialize() + _scheduler.Schedule(TimeSpan.FromSeconds(8), task => { - _scheduler.Schedule(TimeSpan.FromSeconds(8), task => - { - DoCastVictim(TrialOfChampionSpells.EVISCERATE); + DoCastVictim(TrialOfChampionSpells.EVISCERATE); - task.Repeat(TimeSpan.FromSeconds(8)); - }); + task.Repeat(TimeSpan.FromSeconds(8)); + }); - _scheduler.Schedule(TimeSpan.FromSeconds(14), task => - { - DoCastAOE(TrialOfChampionSpells.FAN_OF_KNIVES, false); - - task.Repeat(TimeSpan.FromSeconds(14)); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(19), task => - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0); - if (target) - DoCast(target, TrialOfChampionSpells.POISON_BOTTLE); - - task.Repeat(TimeSpan.FromSeconds(19)); - }); - } - - public override void UpdateAI(uint diff) + _scheduler.Schedule(TimeSpan.FromSeconds(14), task => { - base.UpdateAI(diff); + DoCastAOE(TrialOfChampionSpells.FAN_OF_KNIVES, false); - if (!UpdateVictim() || !me.m_movementInfo.transport.guid.IsEmpty()) - return; + task.Repeat(TimeSpan.FromSeconds(14)); + }); - _scheduler.Update(diff); + _scheduler.Schedule(TimeSpan.FromSeconds(19), task => + { + Unit target = SelectTarget(SelectAggroTarget.Random, 0); + if (target) + DoCast(target, TrialOfChampionSpells.POISON_BOTTLE); - DoMeleeAttackIfReady(); - } + task.Repeat(TimeSpan.FromSeconds(19)); + }); } - public override CreatureAI GetAI(Creature creature) + public override void UpdateAI(uint diff) { - return GetInstanceAI(creature); + base.UpdateAI(diff); + + if (!UpdateVictim() || !me.m_movementInfo.transport.guid.IsEmpty()) + return; + + _scheduler.Update(diff); + + DoMeleeAttackIfReady(); } } } \ No newline at end of file diff --git a/Scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/InstanceTrialOfTheChampion.cs b/Scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/InstanceTrialOfTheChampion.cs index 925f2450b..cf6b1e893 100644 --- a/Scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/InstanceTrialOfTheChampion.cs +++ b/Scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/InstanceTrialOfTheChampion.cs @@ -24,6 +24,7 @@ using Game.Scripting; using System; using System.Collections.Generic; using System.Linq; +using Game.AI; namespace Scripts.Northrend.CrusadersColiseum.TrialOfTheChampion { @@ -32,11 +33,6 @@ namespace Scripts.Northrend.CrusadersColiseum.TrialOfTheChampion { public instance_trial_of_the_champion() : base("instance_trial_of_the_champion", 650) { } - public override InstanceScript GetInstanceScript(InstanceMap map) - { - return new instance_trial_of_the_champion_InstanceMapScript(map); - } - class instance_trial_of_the_champion_InstanceMapScript : InstanceScript { public instance_trial_of_the_champion_InstanceMapScript(Map map) : base(map) @@ -329,5 +325,15 @@ namespace Scripts.Northrend.CrusadersColiseum.TrialOfTheChampion //bool bDone; } + + public override InstanceScript GetInstanceScript(InstanceMap map) + { + return new instance_trial_of_the_champion_InstanceMapScript(map); + } + + public static T GetTrialOfTheChampionAI(Creature creature) where T : CreatureAI + { + return GetInstanceAI(creature, "instance_trial_of_the_champion"); + } } } diff --git a/Scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/TrialOfTheChampion.cs b/Scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/TrialOfTheChampion.cs index 71191fddd..3b2a02786 100644 --- a/Scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/TrialOfTheChampion.cs +++ b/Scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/TrialOfTheChampion.cs @@ -223,7 +223,8 @@ namespace Scripts.Northrend.CrusadersColiseum.TrialOfTheChampion if (summon) AggroAllPlayers(summon); } - } else if (uiLesserChampions == 9) + } + else if (uiLesserChampions == 9) StartGrandChampionsAttack(); break; @@ -542,11 +543,6 @@ namespace Scripts.Northrend.CrusadersColiseum.TrialOfTheChampion Position SpawnPosition = new Position(746.261f, 657.401f, 411.681f, 4.65f); } - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } - public override bool OnGossipHello(Player player, Creature creature) { InstanceScript instance = creature.GetInstanceScript(); @@ -583,5 +579,10 @@ namespace Scripts.Northrend.CrusadersColiseum.TrialOfTheChampion return true; } + + public override CreatureAI GetAI(Creature creature) + { + return instance_trial_of_the_champion.GetTrialOfTheChampionAI(creature); + } } } diff --git a/Scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/LordJaraxxus.cs b/Scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/LordJaraxxus.cs index b8335fb13..94ba06623 100644 --- a/Scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/LordJaraxxus.cs +++ b/Scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/LordJaraxxus.cs @@ -85,484 +85,403 @@ namespace Scripts.Northrend.CrusadersColiseum.TrialOfTheCrusader } [Script] - class boss_jaraxxus : CreatureScript + class boss_jaraxxus : BossAI { - public - boss_jaraxxus() : base("boss_jaraxxus") { } + public boss_jaraxxus(Creature creature) : base(creature, DataTypes.BossJaraxxus) { } - class boss_jaraxxusAI : BossAI + public override void Reset() { - public boss_jaraxxusAI(Creature creature) : base(creature, DataTypes.BossJaraxxus) { } + _Reset(); + _events.ScheduleEvent(Jaraxxus.EventFelFireball, 5 * Time.InMilliseconds); + _events.ScheduleEvent(Jaraxxus.EventFelLightning, RandomHelper.URand(10 * Time.InMilliseconds, 15 * Time.InMilliseconds)); + _events.ScheduleEvent(Jaraxxus.EventIncinerateFlesh, RandomHelper.URand(20 * Time.InMilliseconds, 25 * Time.InMilliseconds)); + _events.ScheduleEvent(Jaraxxus.EventNetherPower, 40 * Time.InMilliseconds); + _events.ScheduleEvent(Jaraxxus.EventLegionFlame, 30 * Time.InMilliseconds); + _events.ScheduleEvent(Jaraxxus.EventSummonoNetherPortal, 20 * Time.InMilliseconds); + _events.ScheduleEvent(Jaraxxus.EventSummonInfernalEruption, 80 * Time.InMilliseconds); + } - public override void Reset() + public override void JustReachedHome() + { + _JustReachedHome(); + instance.SetBossState(DataTypes.BossJaraxxus, EncounterState.Fail); + DoCast(me, Spells.JaraxxusChains); + me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable); + } + + public override void KilledUnit(Unit who) + { + if (who.IsTypeId(TypeId.Player)) { - _Reset(); - _events.ScheduleEvent(Jaraxxus.EventFelFireball, 5 * Time.InMilliseconds); - _events.ScheduleEvent(Jaraxxus.EventFelLightning, RandomHelper.URand(10 * Time.InMilliseconds, 15 * Time.InMilliseconds)); - _events.ScheduleEvent(Jaraxxus.EventIncinerateFlesh, RandomHelper.URand(20 * Time.InMilliseconds, 25 * Time.InMilliseconds)); - _events.ScheduleEvent(Jaraxxus.EventNetherPower, 40 * Time.InMilliseconds); - _events.ScheduleEvent(Jaraxxus.EventLegionFlame, 30 * Time.InMilliseconds); - _events.ScheduleEvent(Jaraxxus.EventSummonoNetherPortal, 20 * Time.InMilliseconds); - _events.ScheduleEvent(Jaraxxus.EventSummonInfernalEruption, 80 * Time.InMilliseconds); + Talk(Jaraxxus.SayKillPlayer); + instance.SetData(DataTypes.TributeToImmortalityEligible, 0); } + } - public override void JustReachedHome() - { - _JustReachedHome(); - instance.SetBossState(DataTypes.BossJaraxxus, EncounterState.Fail); - DoCast(me, Spells.JaraxxusChains); - me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable); - } + public override void JustDied(Unit killer) + { + _JustDied(); + Talk(Jaraxxus.SayDeath); + } - public override void KilledUnit(Unit who) + public override void JustSummoned(Creature summoned) + { + summons.Summon(summoned); + } + + public override void EnterCombat(Unit who) + { + _EnterCombat(); + Talk(Jaraxxus.SayAggro); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _events.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + _events.ExecuteEvents(eventId => { - if (who.IsTypeId(TypeId.Player)) + switch (eventId) { - Talk(Jaraxxus.SayKillPlayer); - instance.SetData(DataTypes.TributeToImmortalityEligible, 0); - } - } - - public override void JustDied(Unit killer) - { - _JustDied(); - Talk(Jaraxxus.SayDeath); - } - - public override void JustSummoned(Creature summoned) - { - summons.Summon(summoned); - } - - public override void EnterCombat(Unit who) - { - _EnterCombat(); - Talk(Jaraxxus.SayAggro); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _events.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case Jaraxxus.EventFelFireball: - DoCastVictim(Jaraxxus.SpellFelFireball); - _events.ScheduleEvent(Jaraxxus.EventFelFireball, RandomHelper.URand(10 * Time.InMilliseconds, 15 * Time.InMilliseconds)); - return; - case Jaraxxus.EventFelLightning: - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 0.0f, true, -Jaraxxus.SpellLordHittin); - if (target) - DoCast(target, Jaraxxus.SpellFelLighting); - _events.ScheduleEvent(Jaraxxus.EventFelLightning, RandomHelper.URand(10 * Time.InMilliseconds, 15 * Time.InMilliseconds)); - return; - } - case Jaraxxus.EventIncinerateFlesh: - { - Unit target = SelectTarget(SelectAggroTarget.Random, 1, 0.0f, true, -Jaraxxus.SpellLordHittin); - if (target) - { - Talk(Jaraxxus.EmoteIncinerate, target); - Talk(Jaraxxus.SayIncinerate); - DoCast(target, Jaraxxus.SpellInfernalEruption); - } - _events.ScheduleEvent(Jaraxxus.EventIncinerateFlesh, RandomHelper.URand(20 * Time.InMilliseconds, 25 * Time.InMilliseconds)); - return; - } - case Jaraxxus.EventNetherPower: - me.CastCustomSpell(Jaraxxus.SpellNetherPower, SpellValueMod.AuraStack, RaidMode(5, 10, 5, 10), me, true); - _events.ScheduleEvent(Jaraxxus.EventNetherPower, 40 * Time.InMilliseconds); - return; - case Jaraxxus.EventLegionFlame: - { - Unit target = SelectTarget(SelectAggroTarget.Random, 1, 0.0f, true, -Jaraxxus.SpellLordHittin); - if (target) - { - Talk(Jaraxxus.EmoteLegionFlame, target); - DoCast(target, Jaraxxus.SpellLegionFlame); - } - _events.ScheduleEvent(Jaraxxus.EventLegionFlame, 30 * Time.InMilliseconds); - return; - } - case Jaraxxus.EventSummonoNetherPortal: - Talk(Jaraxxus.EmoteNetherPortal); - Talk(Jaraxxus.SayMistressOfPain); - DoCast(Jaraxxus.SpellNetherPortal); - _events.ScheduleEvent(Jaraxxus.EventSummonoNetherPortal, 2 * Time.Minute * Time.InMilliseconds); - return; - case Jaraxxus.EventSummonInfernalEruption: - Talk(Jaraxxus.EmoteInfernalEruption); - Talk(Jaraxxus.SayInfernalEruption); - DoCast(Jaraxxus.SpellInfernalEruption); - _events.ScheduleEvent(Jaraxxus.EventSummonInfernalEruption, 2 * Time.Minute * Time.InMilliseconds); - return; - } - }); - - DoMeleeAttackIfReady(); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } - } - - [Script] - class npc_legion_flame : CreatureScript - { - public npc_legion_flame() : base("npc_legion_flame") { } - - class npc_legion_flameAI : ScriptedAI - { - public npc_legion_flameAI(Creature creature) : base(creature) - { - SetCombatMovement(false); - _instance = creature.GetInstanceScript(); - } - - public override void Reset() - { - me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); - me.SetInCombatWithZone(); - DoCast(Jaraxxus.SpellLegionFlameEffect); - } - - public override void UpdateAI(uint diff) - { - UpdateVictim(); - if (_instance.GetBossState(DataTypes.BossJaraxxus) != EncounterState.InProgress) - me.DespawnOrUnsummon(); - } - - InstanceScript _instance; - } - - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } - } - - [Script] - class npc_infernal_volcano : CreatureScript - { - public npc_infernal_volcano() : base("npc_infernal_volcano") { } - - class npc_infernal_volcanoAI : ScriptedAI - { - public npc_infernal_volcanoAI(Creature creature) : base(creature) - { - _summons = new SummonList(me); - SetCombatMovement(false); - } - - public override void Reset() - { - me.SetReactState(ReactStates.Passive); - - if (!IsHeroic()) - me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable | UnitFlags.Pacified); - else - me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable | UnitFlags.Pacified); - - _summons.DespawnAll(); - } - - public override void IsSummonedBy(Unit summoner) - { - DoCast(Jaraxxus.SpellInfernalEruptionEffect); - } - - public override void JustSummoned(Creature summoned) - { - _summons.Summon(summoned); - // makes immediate corpse despawn of summoned Felflame Infernals - summoned.SetCorpseDelay(0); - } - - public override void JustDied(Unit killer) - { - // used to despawn corpse immediately - me.DespawnOrUnsummon(); - } - - public override void UpdateAI(uint diff) { } - - SummonList _summons; - } - - public override CreatureAI GetAI(Creature creature) - { - return new npc_infernal_volcanoAI(creature); - } - } - - [Script] - class npc_fel_infernal : CreatureScript - { - public npc_fel_infernal() : base("npc_fel_infernal") { } - - class npc_fel_infernalAI : ScriptedAI - { - public npc_fel_infernalAI(Creature creature) : base(creature) - { - _instance = creature.GetInstanceScript(); - } - - public override void Reset() - { - _felStreakTimer = 30 * Time.InMilliseconds; - me.SetInCombatWithZone(); - } - - public override void UpdateAI(uint diff) - { - if (_instance.GetBossState(DataTypes.BossJaraxxus) != EncounterState.InProgress) - { - me.DespawnOrUnsummon(); - return; - } - - if (!UpdateVictim()) - return; - - if (_felStreakTimer <= diff) - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 0.0f, true); - if (target) - DoCast(target, Jaraxxus.SpellFelStreak); - _felStreakTimer = 30 * Time.InMilliseconds; - } - else - _felStreakTimer -= diff; - - DoMeleeAttackIfReady(); - } - - uint _felStreakTimer; - InstanceScript _instance; - } - - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } - } - - [Script] - class npc_nether_portal : CreatureScript - { - public npc_nether_portal() : base("npc_nether_portal") { } - - class npc_nether_portalAI : ScriptedAI - { - public npc_nether_portalAI(Creature creature) : base(creature) - { - _summons = new SummonList(me); - } - - public override void Reset() - { - me.SetReactState(ReactStates.Passive); - - if (!IsHeroic()) - me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable | UnitFlags.Pacified); - else - me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable | UnitFlags.Pacified); - - _summons.DespawnAll(); - } - - public override void IsSummonedBy(Unit summoner) - { - DoCast(Jaraxxus.SpellNetherPortalEffect); - } - - public override void JustSummoned(Creature summoned) - { - _summons.Summon(summoned); - // makes immediate corpse despawn of summoned Mistress of Pain - summoned.SetCorpseDelay(0); - } - - public override void JustDied(Unit killer) - { - // used to despawn corpse immediately - me.DespawnOrUnsummon(); - } - - public override void UpdateAI(uint diff) { } - - SummonList _summons; - } - - public override CreatureAI GetAI(Creature creature) - { - return new npc_nether_portalAI(creature); - } - } - - [Script] - class npc_mistress_of_pain : CreatureScript - { - public npc_mistress_of_pain() : base("npc_mistress_of_pain") { } - - class npc_mistress_of_painAI : ScriptedAI - { - public npc_mistress_of_painAI(Creature creature) : base(creature) - { - _instance = creature.GetInstanceScript(); - _instance.SetData(DataTypes.MistressOfPainCount, DataTypes.Increase); - } - - public override void Reset() - { - _events.ScheduleEvent(Jaraxxus.EventShivanSlash, 30 * Time.InMilliseconds); - _events.ScheduleEvent(Jaraxxus.EventSpinningStrike, 30 * Time.InMilliseconds); - if (IsHeroic()) - _events.ScheduleEvent(Jaraxxus.EventMistressKiss, 15 * Time.InMilliseconds); - me.SetInCombatWithZone(); - } - - public override void JustDied(Unit killer) - { - _instance.SetData(DataTypes.MistressOfPainCount, DataTypes.Decrease); - } - - public override void UpdateAI(uint diff) - { - if (_instance.GetBossState(DataTypes.BossJaraxxus) != EncounterState.InProgress) - { - me.DespawnOrUnsummon(); - return; - } - - if (!UpdateVictim()) - return; - - _events.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case Jaraxxus.EventShivanSlash: - DoCastVictim(Jaraxxus.SpellShivanSlash); - _events.ScheduleEvent(Jaraxxus.EventShivanSlash, 30 * Time.InMilliseconds); - return; - case Jaraxxus.EventSpinningStrike: - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 0.0f, true); + case Jaraxxus.EventFelFireball: + DoCastVictim(Jaraxxus.SpellFelFireball); + _events.ScheduleEvent(Jaraxxus.EventFelFireball, RandomHelper.URand(10 * Time.InMilliseconds, 15 * Time.InMilliseconds)); + return; + case Jaraxxus.EventFelLightning: + { + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 0.0f, true, -Jaraxxus.SpellLordHittin); if (target) - DoCast(target, Jaraxxus.SpellSpinningStrike); - _events.ScheduleEvent(Jaraxxus.EventSpinningStrike, 30 * Time.InMilliseconds); + DoCast(target, Jaraxxus.SpellFelLighting); + _events.ScheduleEvent(Jaraxxus.EventFelLightning, RandomHelper.URand(10 * Time.InMilliseconds, 15 * Time.InMilliseconds)); return; - case Jaraxxus.EventMistressKiss: - DoCast(me, Jaraxxus.SpellMistressKiss); - _events.ScheduleEvent(Jaraxxus.EventMistressKiss, 30 * Time.InMilliseconds); + } + case Jaraxxus.EventIncinerateFlesh: + { + Unit target = SelectTarget(SelectAggroTarget.Random, 1, 0.0f, true, -Jaraxxus.SpellLordHittin); + if (target) + { + Talk(Jaraxxus.EmoteIncinerate, target); + Talk(Jaraxxus.SayIncinerate); + DoCast(target, Jaraxxus.SpellInfernalEruption); + } + _events.ScheduleEvent(Jaraxxus.EventIncinerateFlesh, RandomHelper.URand(20 * Time.InMilliseconds, 25 * Time.InMilliseconds)); return; - default: - break; - } - }); + } + case Jaraxxus.EventNetherPower: + me.CastCustomSpell(Jaraxxus.SpellNetherPower, SpellValueMod.AuraStack, RaidMode(5, 10, 5, 10), me, true); + _events.ScheduleEvent(Jaraxxus.EventNetherPower, 40 * Time.InMilliseconds); + return; + case Jaraxxus.EventLegionFlame: + { + Unit target = SelectTarget(SelectAggroTarget.Random, 1, 0.0f, true, -Jaraxxus.SpellLordHittin); + if (target) + { + Talk(Jaraxxus.EmoteLegionFlame, target); + DoCast(target, Jaraxxus.SpellLegionFlame); + } + _events.ScheduleEvent(Jaraxxus.EventLegionFlame, 30 * Time.InMilliseconds); + return; + } + case Jaraxxus.EventSummonoNetherPortal: + Talk(Jaraxxus.EmoteNetherPortal); + Talk(Jaraxxus.SayMistressOfPain); + DoCast(Jaraxxus.SpellNetherPortal); + _events.ScheduleEvent(Jaraxxus.EventSummonoNetherPortal, 2 * Time.Minute * Time.InMilliseconds); + return; + case Jaraxxus.EventSummonInfernalEruption: + Talk(Jaraxxus.EmoteInfernalEruption); + Talk(Jaraxxus.SayInfernalEruption); + DoCast(Jaraxxus.SpellInfernalEruption); + _events.ScheduleEvent(Jaraxxus.EventSummonInfernalEruption, 2 * Time.Minute * Time.InMilliseconds); + return; + } + }); - DoMeleeAttackIfReady(); - } - - InstanceScript _instance; - } - - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); + DoMeleeAttackIfReady(); } } [Script] - class spell_mistress_kiss : SpellScriptLoader + class npc_legion_flame : ScriptedAI { - public spell_mistress_kiss() : base("spell_mistress_kiss") { } - - class spell_mistress_kiss_AuraScript : AuraScript + public npc_legion_flame(Creature creature) : base(creature) { - public override bool Load() + SetCombatMovement(false); + _instance = creature.GetInstanceScript(); + } + + public override void Reset() + { + me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); + me.SetInCombatWithZone(); + DoCast(Jaraxxus.SpellLegionFlameEffect); + } + + public override void UpdateAI(uint diff) + { + UpdateVictim(); + if (_instance.GetBossState(DataTypes.BossJaraxxus) != EncounterState.InProgress) + me.DespawnOrUnsummon(); + } + + InstanceScript _instance; + } + + [Script] + class npc_infernal_volcano : ScriptedAI + { + public npc_infernal_volcano(Creature creature) : base(creature) + { + _summons = new SummonList(me); + SetCombatMovement(false); + } + + public override void Reset() + { + me.SetReactState(ReactStates.Passive); + + if (!IsHeroic()) + me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable | UnitFlags.Pacified); + else + me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable | UnitFlags.Pacified); + + _summons.DespawnAll(); + } + + public override void IsSummonedBy(Unit summoner) + { + DoCast(Jaraxxus.SpellInfernalEruptionEffect); + } + + public override void JustSummoned(Creature summoned) + { + _summons.Summon(summoned); + // makes immediate corpse despawn of summoned Felflame Infernals + summoned.SetCorpseDelay(0); + } + + public override void JustDied(Unit killer) + { + // used to despawn corpse immediately + me.DespawnOrUnsummon(); + } + + public override void UpdateAI(uint diff) { } + + SummonList _summons; + } + + [Script] + class npc_fel_infernal : ScriptedAI + { + public npc_fel_infernal(Creature creature) : base(creature) + { + _instance = creature.GetInstanceScript(); + } + + public override void Reset() + { + _felStreakTimer = 30 * Time.InMilliseconds; + me.SetInCombatWithZone(); + } + + public override void UpdateAI(uint diff) + { + if (_instance.GetBossState(DataTypes.BossJaraxxus) != EncounterState.InProgress) { - return ValidateSpellInfo(Jaraxxus.SpellMistressKissDamageSilence); + me.DespawnOrUnsummon(); + return; } - void HandleDummyTick(AuraEffect aurEff) + if (!UpdateVictim()) + return; + + if (_felStreakTimer <= diff) { - Unit caster = GetCaster(); - Unit target = GetTarget(); - if (caster && target) + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 0.0f, true); + if (target) + DoCast(target, Jaraxxus.SpellFelStreak); + _felStreakTimer = 30 * Time.InMilliseconds; + } + else + _felStreakTimer -= diff; + + DoMeleeAttackIfReady(); + } + + uint _felStreakTimer; + InstanceScript _instance; + } + + [Script] + class npc_nether_portal : ScriptedAI + { + public npc_nether_portal(Creature creature) : base(creature) + { + _summons = new SummonList(me); + } + + public override void Reset() + { + me.SetReactState(ReactStates.Passive); + + if (!IsHeroic()) + me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable | UnitFlags.Pacified); + else + me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable | UnitFlags.Pacified); + + _summons.DespawnAll(); + } + + public override void IsSummonedBy(Unit summoner) + { + DoCast(Jaraxxus.SpellNetherPortalEffect); + } + + public override void JustSummoned(Creature summoned) + { + _summons.Summon(summoned); + // makes immediate corpse despawn of summoned Mistress of Pain + summoned.SetCorpseDelay(0); + } + + public override void JustDied(Unit killer) + { + // used to despawn corpse immediately + me.DespawnOrUnsummon(); + } + + public override void UpdateAI(uint diff) { } + + SummonList _summons; + } + + [Script] + class npc_mistress_of_pain : ScriptedAI + { + public npc_mistress_of_pain(Creature creature) : base(creature) + { + _instance = creature.GetInstanceScript(); + _instance.SetData(DataTypes.MistressOfPainCount, DataTypes.Increase); + } + + public override void Reset() + { + _events.ScheduleEvent(Jaraxxus.EventShivanSlash, 30 * Time.InMilliseconds); + _events.ScheduleEvent(Jaraxxus.EventSpinningStrike, 30 * Time.InMilliseconds); + if (IsHeroic()) + _events.ScheduleEvent(Jaraxxus.EventMistressKiss, 15 * Time.InMilliseconds); + me.SetInCombatWithZone(); + } + + public override void JustDied(Unit killer) + { + _instance.SetData(DataTypes.MistressOfPainCount, DataTypes.Decrease); + } + + public override void UpdateAI(uint diff) + { + if (_instance.GetBossState(DataTypes.BossJaraxxus) != EncounterState.InProgress) + { + me.DespawnOrUnsummon(); + return; + } + + if (!UpdateVictim()) + return; + + _events.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + _events.ExecuteEvents(eventId => + { + switch (eventId) { - if (target.HasUnitState(UnitState.Casting)) - { - caster.CastSpell(target, Jaraxxus.SpellMistressKissDamageSilence, true); - target.RemoveAurasDueToSpell(GetSpellInfo().Id); - } + case Jaraxxus.EventShivanSlash: + DoCastVictim(Jaraxxus.SpellShivanSlash); + _events.ScheduleEvent(Jaraxxus.EventShivanSlash, 30 * Time.InMilliseconds); + return; + case Jaraxxus.EventSpinningStrike: + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 0.0f, true); + if (target) + DoCast(target, Jaraxxus.SpellSpinningStrike); + _events.ScheduleEvent(Jaraxxus.EventSpinningStrike, 30 * Time.InMilliseconds); + return; + case Jaraxxus.EventMistressKiss: + DoCast(me, Jaraxxus.SpellMistressKiss); + _events.ScheduleEvent(Jaraxxus.EventMistressKiss, 30 * Time.InMilliseconds); + return; + default: + break; + } + }); + + DoMeleeAttackIfReady(); + } + + InstanceScript _instance; + } + + [Script] + class spell_mistress_kiss : AuraScript + { + public override bool Load() + { + return ValidateSpellInfo(Jaraxxus.SpellMistressKissDamageSilence); + } + + void HandleDummyTick(AuraEffect aurEff) + { + Unit caster = GetCaster(); + Unit target = GetTarget(); + if (caster && target) + { + if (target.HasUnitState(UnitState.Casting)) + { + caster.CastSpell(target, Jaraxxus.SpellMistressKissDamageSilence, true); + target.RemoveAurasDueToSpell(GetSpellInfo().Id); } } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleDummyTick, 0, AuraType.PeriodicDummy)); - } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_mistress_kiss_AuraScript(); + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleDummyTick, 0, AuraType.PeriodicDummy)); } } [Script] - class spell_mistress_kiss_area : SpellScriptLoader + class spell_mistress_kiss_area : SpellScript { - public spell_mistress_kiss_area() : base("spell_mistress_kiss_area") { } - - class spell_mistress_kiss_area_SpellScript : SpellScript + void FilterTargets(List targets) { - void FilterTargets(List targets) - { - // get a list of players with mana - targets.RemoveAll(unit => unit.IsTypeId(TypeId.Player) && unit.ToPlayer().getPowerType() == PowerType.Mana); - if (targets.Empty()) - return; + // get a list of players with mana + targets.RemoveAll(unit => unit.IsTypeId(TypeId.Player) && unit.ToPlayer().getPowerType() == PowerType.Mana); + if (targets.Empty()) + return; - WorldObject target = targets.SelectRandom(); - targets.Clear(); - targets.Add(target); - } - - void HandleScript(uint effIndex) - { - GetCaster().CastSpell(GetHitUnit(), (uint)GetEffectValue(), true); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEnemy)); - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } + WorldObject target = targets.SelectRandom(); + targets.Clear(); + targets.Add(target); } - public override SpellScript GetSpellScript() + void HandleScript(uint effIndex) { - return new spell_mistress_kiss_area_SpellScript(); + GetCaster().CastSpell(GetHitUnit(), (uint)GetEffectValue(), true); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEnemy)); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } } \ No newline at end of file diff --git a/Scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/NorthrendBeasts.cs b/Scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/NorthrendBeasts.cs index 889a81c70..e4af16b84 100644 --- a/Scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/NorthrendBeasts.cs +++ b/Scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/NorthrendBeasts.cs @@ -127,798 +127,718 @@ namespace Scripts.Northrend.CrusadersColiseum.TrialOfTheCrusader } [Script] - class boss_gormok : CreatureScript + class boss_gormok : BossAI { - public boss_gormok() : base("boss_gormok") { } + public boss_gormok(Creature creature) : base(creature, DataTypes.BossBeasts) { } - class boss_gormokAI : BossAI + public override void Reset() { - public boss_gormokAI(Creature creature) : base(creature, DataTypes.BossBeasts) { } + _events.ScheduleEvent(Beasts.EventImpale, RandomHelper.URand(8 * Time.InMilliseconds, 10 * Time.InMilliseconds)); + _events.ScheduleEvent(Beasts.EventStaggeringStomp, 15 * Time.InMilliseconds); + _events.ScheduleEvent(Beasts.EventThrow, RandomHelper.URand(15 * Time.InMilliseconds, 30 * Time.InMilliseconds)); - public override void Reset() + summons.DespawnAll(); + } + + public override void EnterEvadeMode(EvadeReason why) + { + instance.DoUseDoorOrButton(instance.GetGuidData(GameObjectIds.MainGateDoor)); + base.EnterEvadeMode(why); + } + + public override void MovementInform(MovementGeneratorType type, uint id) + { + if (type != MovementGeneratorType.Point) + return; + + switch (id) { - _events.ScheduleEvent(Beasts.EventImpale, RandomHelper.URand(8 * Time.InMilliseconds, 10 * Time.InMilliseconds)); - _events.ScheduleEvent(Beasts.EventStaggeringStomp, 15 * Time.InMilliseconds); - _events.ScheduleEvent(Beasts.EventThrow, RandomHelper.URand(15 * Time.InMilliseconds, 30 * Time.InMilliseconds)); - - summons.DespawnAll(); + case 0: + instance.DoUseDoorOrButton(instance.GetGuidData(GameObjectIds.MainGateDoor)); + me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); + me.SetReactState(ReactStates.Aggressive); + me.SetInCombatWithZone(); + break; + default: + break; } + } - public override void EnterEvadeMode(EvadeReason why) + public override void JustDied(Unit killer) + { + instance.SetData(DataTypes.TypeNorthrendBeasts, NorthrendBeasts.GormokDone); + } + + public override void JustReachedHome() + { + instance.DoUseDoorOrButton(instance.GetGuidData(GameObjectIds.MainGateDoor)); + instance.SetData(DataTypes.TypeNorthrendBeasts, (uint)EncounterState.Fail); + + me.DespawnOrUnsummon(); + } + + public override void EnterCombat(Unit who) + { + _EnterCombat(); + me.SetInCombatWithZone(); + instance.SetData(DataTypes.TypeNorthrendBeasts, NorthrendBeasts.GormokInProgress); + + for (sbyte i = 0; i < Beasts.MaxSnobolds; i++) { - instance.DoUseDoorOrButton(instance.GetGuidData(GameObjectIds.MainGateDoor)); - base.EnterEvadeMode(why); - } - - public override void MovementInform(MovementGeneratorType type, uint id) - { - if (type != MovementGeneratorType.Point) - return; - - switch (id) + Creature pSnobold = DoSpawnCreature(Beasts.NpcSnoboldVassal, 0, 0, 0, 0, TempSummonType.CorpseDespawn, 0); + if (pSnobold) { - case 0: - instance.DoUseDoorOrButton(instance.GetGuidData(GameObjectIds.MainGateDoor)); - me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); - me.SetReactState(ReactStates.Aggressive); - me.SetInCombatWithZone(); - break; - default: - break; + pSnobold.EnterVehicle(me, i); + pSnobold.SetInCombatWithZone(); + pSnobold.GetAI().DoAction(Beasts.ActionEnableFireBomb); } } + } - public override void JustDied(Unit killer) + public override void DamageTaken(Unit who, ref uint damage) + { + // despawn the remaining passengers on death + if (damage >= me.GetHealth()) { - instance.SetData(DataTypes.TypeNorthrendBeasts, NorthrendBeasts.GormokDone); - } - - public override void JustReachedHome() - { - instance.DoUseDoorOrButton(instance.GetGuidData(GameObjectIds.MainGateDoor)); - instance.SetData(DataTypes.TypeNorthrendBeasts, (uint)EncounterState.Fail); - - me.DespawnOrUnsummon(); - } - - public override void EnterCombat(Unit who) - { - _EnterCombat(); - me.SetInCombatWithZone(); - instance.SetData(DataTypes.TypeNorthrendBeasts, NorthrendBeasts.GormokInProgress); - - for (sbyte i = 0; i < Beasts.MaxSnobolds; i++) + for (sbyte i = 0; i < Beasts.MaxSnobolds; ++i) { - Creature pSnobold = DoSpawnCreature(Beasts.NpcSnoboldVassal, 0, 0, 0, 0, TempSummonType.CorpseDespawn, 0); + Unit pSnobold = me.GetVehicleKit().GetPassenger(i); if (pSnobold) - { - pSnobold.EnterVehicle(me, i); - pSnobold.SetInCombatWithZone(); - pSnobold.GetAI().DoAction(Beasts.ActionEnableFireBomb); - } + pSnobold.ToCreature().DespawnOrUnsummon(); } } + } - public override void DamageTaken(Unit who, ref uint damage) + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _events.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + _events.ExecuteEvents(eventId => { - // despawn the remaining passengers on death - if (damage >= me.GetHealth()) + switch (eventId) { - for (sbyte i = 0; i < Beasts.MaxSnobolds; ++i) - { - Unit pSnobold = me.GetVehicleKit().GetPassenger(i); - if (pSnobold) - pSnobold.ToCreature().DespawnOrUnsummon(); - } - } - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _events.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case Beasts.EventImpale: - DoCastVictim(Beasts.SpellImpale); - _events.ScheduleEvent(Beasts.EventImpale, RandomHelper.URand(8 * Time.InMilliseconds, 10 * Time.InMilliseconds)); - return; - case Beasts.EventStaggeringStomp: - DoCastVictim(Beasts.SpellStaggeringStomp); - _events.ScheduleEvent(Beasts.EventStaggeringStomp, 15 * Time.InMilliseconds); - return; - case Beasts.EventThrow: - for (sbyte i = 0; i < Beasts.MaxSnobolds; ++i) + case Beasts.EventImpale: + DoCastVictim(Beasts.SpellImpale); + _events.ScheduleEvent(Beasts.EventImpale, RandomHelper.URand(8 * Time.InMilliseconds, 10 * Time.InMilliseconds)); + return; + case Beasts.EventStaggeringStomp: + DoCastVictim(Beasts.SpellStaggeringStomp); + _events.ScheduleEvent(Beasts.EventStaggeringStomp, 15 * Time.InMilliseconds); + return; + case Beasts.EventThrow: + for (sbyte i = 0; i < Beasts.MaxSnobolds; ++i) + { + Unit pSnobold = me.GetVehicleKit().GetPassenger(i); + if (pSnobold) { - Unit pSnobold = me.GetVehicleKit().GetPassenger(i); - if (pSnobold) - { - pSnobold.ExitVehicle(); - pSnobold.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); - pSnobold.ToCreature().SetReactState(ReactStates.Aggressive); - pSnobold.ToCreature().GetAI().DoAction(Beasts.ActionDisableFireBomb); - pSnobold.CastSpell(me, Beasts.SpellRisingAnger, true); - Talk(Beasts.EmoteSnobolled); - break; - } + pSnobold.ExitVehicle(); + pSnobold.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); + pSnobold.ToCreature().SetReactState(ReactStates.Aggressive); + pSnobold.ToCreature().GetAI().DoAction(Beasts.ActionDisableFireBomb); + pSnobold.CastSpell(me, Beasts.SpellRisingAnger, true); + Talk(Beasts.EmoteSnobolled); + break; } - _events.ScheduleEvent(Beasts.EventThrow, RandomHelper.URand(15 * Time.InMilliseconds, 30 * Time.InMilliseconds)); - return; - default: - return; - } - }); + } + _events.ScheduleEvent(Beasts.EventThrow, RandomHelper.URand(15 * Time.InMilliseconds, 30 * Time.InMilliseconds)); + return; + default: + return; + } + }); + DoMeleeAttackIfReady(); + } + } + + [Script] + class npc_snobold_vassal : ScriptedAI + { + public npc_snobold_vassal(Creature creature) : base(creature) + { + _targetDied = false; + _instance = creature.GetInstanceScript(); + _instance.SetData(DataTypes.SnoboldCount, DataTypes.Increase); + } + + public override void Reset() + { + _events.ScheduleEvent(Beasts.EventBatter, 5 * Time.InMilliseconds); + _events.ScheduleEvent(Beasts.EventHeadCrack, 25 * Time.InMilliseconds); + + _targetGUID.Clear(); + _targetDied = false; + + //Workaround for Snobold + me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); + } + + public override void EnterCombat(Unit who) + { + _targetGUID = who.GetGUID(); + me.TauntApply(who); + DoCast(who, Beasts.SpellSnobolled); + } + + public override void DamageTaken(Unit pDoneBy, ref uint uiDamage) + { + if (pDoneBy.GetGUID() == _targetGUID) + uiDamage = 0; + } + + public override void MovementInform(MovementGeneratorType type, uint id) + { + if (type != MovementGeneratorType.Point) + return; + + switch (id) + { + case 0: + if (_targetDied) + me.DespawnOrUnsummon(); + break; + default: + break; + } + } + + public override void JustDied(Unit killer) + { + Unit target = Global.ObjAccessor.GetPlayer(me, _targetGUID); + if (target) + if (target.IsAlive()) + target.RemoveAurasDueToSpell(Beasts.SpellSnobolled); + _instance.SetData(DataTypes.SnoboldCount, DataTypes.Decrease); + } + + public override void DoAction(int action) + { + switch (action) + { + case Beasts.ActionEnableFireBomb: + _events.ScheduleEvent(Beasts.EventFireBomb, RandomHelper.URand(5 * Time.InMilliseconds, 30 * Time.InMilliseconds)); + break; + case Beasts.ActionDisableFireBomb: + _events.CancelEvent(Beasts.EventFireBomb); + break; + default: + break; + } + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim() || _targetDied) + return; + + Unit target = Global.ObjAccessor.GetPlayer(me, _targetGUID); + if (target) + { + if (!target.IsAlive()) + { + Unit gormok = ObjectAccessor.GetCreature(me, _instance.GetGuidData(CreatureIds.Gormok)); + if (gormok && gormok.IsAlive()) + { + SetCombatMovement(false); + _targetDied = true; + + // looping through Gormoks seats + for (sbyte i = 0; i < Beasts.MaxSnobolds; i++) + { + if (!gormok.GetVehicleKit().GetPassenger(i)) + { + me.EnterVehicle(gormok, i); + DoAction(Beasts.ActionEnableFireBomb); + break; + } + } + } + else if (target = SelectTarget(SelectAggroTarget.Random, 0, 0.0f, true)) + { + _targetGUID = target.GetGUID(); + me.GetMotionMaster().MoveJump(target, 15.0f, 15.0f); + } + } + } + + _events.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + _events.ExecuteEvents(eventId => + { + switch (eventId) + { + case Beasts.EventFireBomb: + { + if (me.GetVehicleBase()) + { + Unit fireTarget = SelectTarget(SelectAggroTarget.Random, 0, -me.GetVehicleBase().GetCombatReach(), true); + if (fireTarget) + me.CastSpell(fireTarget.GetPositionX(), fireTarget.GetPositionY(), fireTarget.GetPositionZ(), Beasts.SpellFireBomb, true); + } + _events.ScheduleEvent(Beasts.EventFireBomb, 20 * Time.InMilliseconds); + return; + } + case Beasts.EventHeadCrack: + // commented out while SPELL_SNOBOLLED gets fixed + //if (Unit target = Global.ObjAccessor.GetPlayer(me, m_uiTargetGUID)) + DoCastVictim(Beasts.SpellHeadCrack); + _events.ScheduleEvent(Beasts.EventHeadCrack, 30 * Time.InMilliseconds); + return; + case Beasts.EventBatter: + // commented out while SPELL_SNOBOLLED gets fixed + //if (Unit target = Global.ObjAccessor.GetPlayer(me, m_uiTargetGUID)) + DoCastVictim(Beasts.SpellBatter); + _events.ScheduleEvent(Beasts.EventBatter, 10 * Time.InMilliseconds); + return; + default: + return; + } + }); + + // do melee attack only when not on Gormoks back + if (!me.GetVehicleBase()) DoMeleeAttackIfReady(); - } } - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } + InstanceScript _instance; + ObjectGuid _targetGUID; + bool _targetDied; } [Script] - class npc_snobold_vassal : CreatureScript + class npc_firebomb : ScriptedAI { - public npc_snobold_vassal() : base("npc_snobold_vassal") { } - - class npc_snobold_vassalAI : ScriptedAI + public npc_firebomb(Creature creature) : base(creature) { - public npc_snobold_vassalAI(Creature creature) : base(creature) - { - _targetDied = false; - _instance = creature.GetInstanceScript(); - _instance.SetData(DataTypes.SnoboldCount, DataTypes.Increase); - } - - public override void Reset() - { - _events.ScheduleEvent(Beasts.EventBatter, 5 * Time.InMilliseconds); - _events.ScheduleEvent(Beasts.EventHeadCrack, 25 * Time.InMilliseconds); - - _targetGUID.Clear(); - _targetDied = false; - - //Workaround for Snobold - me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); - } - - public override void EnterCombat(Unit who) - { - _targetGUID = who.GetGUID(); - me.TauntApply(who); - DoCast(who, Beasts.SpellSnobolled); - } - - public override void DamageTaken(Unit pDoneBy, ref uint uiDamage) - { - if (pDoneBy.GetGUID() == _targetGUID) - uiDamage = 0; - } - - public override void MovementInform(MovementGeneratorType type, uint id) - { - if (type != MovementGeneratorType.Point) - return; - - switch (id) - { - case 0: - if (_targetDied) - me.DespawnOrUnsummon(); - break; - default: - break; - } - } - - public override void JustDied(Unit killer) - { - Unit target = Global.ObjAccessor.GetPlayer(me, _targetGUID); - if (target) - if (target.IsAlive()) - target.RemoveAurasDueToSpell(Beasts.SpellSnobolled); - _instance.SetData(DataTypes.SnoboldCount, DataTypes.Decrease); - } - - public override void DoAction(int action) - { - switch (action) - { - case Beasts.ActionEnableFireBomb: - _events.ScheduleEvent(Beasts.EventFireBomb, RandomHelper.URand(5 * Time.InMilliseconds, 30 * Time.InMilliseconds)); - break; - case Beasts.ActionDisableFireBomb: - _events.CancelEvent(Beasts.EventFireBomb); - break; - default: - break; - } - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim() || _targetDied) - return; - - Unit target = Global.ObjAccessor.GetPlayer(me, _targetGUID); - if (target) - { - if (!target.IsAlive()) - { - Unit gormok = ObjectAccessor.GetCreature(me, _instance.GetGuidData(CreatureIds.Gormok)); - if (gormok && gormok.IsAlive()) - { - SetCombatMovement(false); - _targetDied = true; - - // looping through Gormoks seats - for (sbyte i = 0; i < Beasts.MaxSnobolds; i++) - { - if (!gormok.GetVehicleKit().GetPassenger(i)) - { - me.EnterVehicle(gormok, i); - DoAction(Beasts.ActionEnableFireBomb); - break; - } - } - } - else if (target = SelectTarget(SelectAggroTarget.Random, 0, 0.0f, true)) - { - _targetGUID = target.GetGUID(); - me.GetMotionMaster().MoveJump(target, 15.0f, 15.0f); - } - } - } - - _events.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case Beasts.EventFireBomb: - { - if (me.GetVehicleBase()) - { - Unit fireTarget = SelectTarget(SelectAggroTarget.Random, 0, -me.GetVehicleBase().GetCombatReach(), true); - if (fireTarget) - me.CastSpell(fireTarget.GetPositionX(), fireTarget.GetPositionY(), fireTarget.GetPositionZ(), Beasts.SpellFireBomb, true); - } - _events.ScheduleEvent(Beasts.EventFireBomb, 20 * Time.InMilliseconds); - return; - } - case Beasts.EventHeadCrack: - // commented out while SPELL_SNOBOLLED gets fixed - //if (Unit target = Global.ObjAccessor.GetPlayer(me, m_uiTargetGUID)) - DoCastVictim(Beasts.SpellHeadCrack); - _events.ScheduleEvent(Beasts.EventHeadCrack, 30 * Time.InMilliseconds); - return; - case Beasts.EventBatter: - // commented out while SPELL_SNOBOLLED gets fixed - //if (Unit target = Global.ObjAccessor.GetPlayer(me, m_uiTargetGUID)) - DoCastVictim(Beasts.SpellBatter); - _events.ScheduleEvent(Beasts.EventBatter, 10 * Time.InMilliseconds); - return; - default: - return; - } - }); - - // do melee attack only when not on Gormoks back - if (!me.GetVehicleBase()) - DoMeleeAttackIfReady(); - } - - InstanceScript _instance; - ObjectGuid _targetGUID; - bool _targetDied; + _instance = creature.GetInstanceScript(); } - public override CreatureAI GetAI(Creature creature) + public override void Reset() { - return GetInstanceAI(creature); - } - } - - [Script] - class npc_firebomb : CreatureScript - { - public npc_firebomb() : base("npc_firebomb") { } - - class npc_firebombAI : ScriptedAI - { - public npc_firebombAI(Creature creature) : base(creature) - { - _instance = creature.GetInstanceScript(); - } - - public override void Reset() - { - DoCast(me, Beasts.SpellFireBombDot, true); - SetCombatMovement(false); - me.SetReactState(ReactStates.Passive); - me.SetDisplayId(me.GetCreatureTemplate().ModelId2); - } - - public override void UpdateAI(uint diff) - { - if (_instance.GetData(DataTypes.TypeNorthrendBeasts) != NorthrendBeasts.GormokInProgress) - me.DespawnOrUnsummon(); - } - - InstanceScript _instance; + DoCast(me, Beasts.SpellFireBombDot, true); + SetCombatMovement(false); + me.SetReactState(ReactStates.Passive); + me.SetDisplayId(me.GetCreatureTemplate().ModelId2); } - public override CreatureAI GetAI(Creature creature) + public override void UpdateAI(uint diff) { - return GetInstanceAI(creature); - } - } - - [Script] - class boss_acidmaw : CreatureScript - { - public boss_acidmaw() : base("boss_acidmaw") { } - - public class boss_acidmawAI : boss_jormungarAI - { - public boss_acidmawAI(Creature creature) : base(creature) { } - - public override void Reset() - { - base.Reset(); - BiteSpell = Beasts.SpellParalyticBite; - SpewSpell = Beasts.SpellAcidSpew; - SpitSpell = Beasts.SpellAcidSpit; - SpraySpell = Beasts.SpellParalyticSpray; - ModelStationary = Beasts.ModelAcidmawStationary; - ModelMobile = Beasts.ModelAcidmawMobile; - OtherWormEntry = CreatureIds.Dreadscale; - - WasMobile = true; - Emerge(); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } - } - - [Script] - class boss_dreadscale : CreatureScript - { - public boss_dreadscale() : base("boss_dreadscale") { } - - public class boss_dreadscaleAI : boss_jormungarAI - { - public boss_dreadscaleAI(Creature creature) : base(creature) - { - } - - public override void Reset() - { - base.Reset(); - BiteSpell = Beasts.SpellBurningBite; - SpewSpell = Beasts.SpellMoltenSpew; - SpitSpell = Beasts.SpellFireSpit; - SpraySpell = Beasts.SpellBurningSpray; - ModelStationary = Beasts.ModelDreadscaleStationary; - ModelMobile = Beasts.ModelDreadscaleMobile; - OtherWormEntry = CreatureIds.Acidmaw; - - _events.SetPhase(Beasts.PhaseMobile); - _events.ScheduleEvent(Beasts.EventSummonAcidmaw, 3 * Time.InMilliseconds); - _events.ScheduleEvent(Beasts.EventSubmerge, 45 * Time.InMilliseconds, 0, Beasts.PhaseMobile); - WasMobile = false; - } - - public override void MovementInform(MovementGeneratorType type, uint id) - { - if (type != MovementGeneratorType.Point) - return; - - switch (id) - { - case 0: - instance.DoUseDoorOrButton(instance.GetGuidData(GameObjectIds.MainGateDoor)); - me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); - me.SetReactState(ReactStates.Aggressive); - me.SetInCombatWithZone(); - break; - default: - break; - } - } - - public override void EnterEvadeMode(EvadeReason why) - { - instance.DoUseDoorOrButton(instance.GetGuidData(GameObjectIds.MainGateDoor)); - base.EnterEvadeMode(why); - } - - public override void JustReachedHome() - { - instance.DoUseDoorOrButton(instance.GetGuidData(GameObjectIds.MainGateDoor)); - - base.JustReachedHome(); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } - } - - [Script] - class npc_slime_pool : CreatureScript - { - public npc_slime_pool() : base("npc_slime_pool") { } - - class npc_slime_poolAI : ScriptedAI - { - public npc_slime_poolAI(Creature creature) : base(creature) - { - _instance = creature.GetInstanceScript(); - } - - public override void Reset() - { - _cast = false; - me.SetReactState(ReactStates.Passive); - } - - public override void UpdateAI(uint diff) - { - if (!_cast) - { - _cast = true; - DoCast(me, Beasts.SpellSlimePoolEffect); - } - - if (_instance.GetData(DataTypes.TypeNorthrendBeasts) != NorthrendBeasts.SnakesInProgress && _instance.GetData(DataTypes.TypeNorthrendBeasts) != NorthrendBeasts.SnakesSpecial) - me.DespawnOrUnsummon(); - } - - InstanceScript _instance; - bool _cast; - - } - - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } - } - - [Script] - class spell_gormok_fire_bomb : SpellScriptLoader - { - public spell_gormok_fire_bomb() : base("spell_gormok_fire_bomb") { } - - class spell_gormok_fire_bomb_SpellScript : SpellScript - { - void TriggerFireBomb(uint effIndex) - { - Position pos = GetExplTargetDest(); - if (pos != null) - { - Unit caster = GetCaster(); - if (caster) - caster.SummonCreature(Beasts.NpcFireBomb, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), 0, TempSummonType.TimedDespawn, 30 * Time.InMilliseconds); - } - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(TriggerFireBomb, 0, SpellEffectName.TriggerMissile)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_gormok_fire_bomb_SpellScript(); - } - } - - [Script] - class boss_icehowl : CreatureScript - { - public boss_icehowl() : base("boss_icehowl") { } - - class boss_icehowlAI : BossAI - { - public boss_icehowlAI(Creature creature) : base(creature, DataTypes.BossBeasts) { } - - public override void Reset() - { - _events.ScheduleEvent(Beasts.EventFerociousButt, RandomHelper.URand(15 * Time.InMilliseconds, 30 * Time.InMilliseconds)); - _events.ScheduleEvent(Beasts.EventArcticBreath, RandomHelper.URand(15 * Time.InMilliseconds, 25 * Time.InMilliseconds)); - _events.ScheduleEvent(Beasts.EventWhirl, RandomHelper.URand(15 * Time.InMilliseconds, 30 * Time.InMilliseconds)); - _events.ScheduleEvent(Beasts.EventMassiveCrash, 30 * Time.InMilliseconds); - _movementFinish = false; - _trampleCast = false; - _trampleTargetGUID.Clear(); - _trampleTargetX = 0; - _trampleTargetY = 0; - _trampleTargetZ = 0; - _stage = 0; - } - - public override void JustDied(Unit killer) - { - _JustDied(); - instance.SetData(DataTypes.TypeNorthrendBeasts, NorthrendBeasts.IcehowlDone); - } - - public override void MovementInform(MovementGeneratorType type, uint id) - { - if (type != MovementGeneratorType.Point && type != MovementGeneratorType.Effect) - return; - - switch (id) - { - case 0: - if (_stage != 0) - { - if (me.GetDistance2d(MiscData.ToCCommonLoc[1].GetPositionX(), MiscData.ToCCommonLoc[1].GetPositionY()) < 6.0f) - // Middle of the room - _stage = 1; - else - { - // Landed from Hop backwards (start trample) - if (Global.ObjAccessor.GetPlayer(me, _trampleTargetGUID)) - _stage = 4; - else - _stage = 6; - } - } - break; - case 1: // Finish trample - _movementFinish = true; - break; - case 2: - instance.DoUseDoorOrButton(instance.GetGuidData(GameObjectIds.MainGateDoor)); - me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); - me.SetReactState(ReactStates.Aggressive); - me.SetInCombatWithZone(); - break; - default: - break; - } - } - - public override void EnterEvadeMode(EvadeReason why) - { - instance.DoUseDoorOrButton(instance.GetGuidData(GameObjectIds.MainGateDoor)); - base.EnterEvadeMode(why); - } - - public override void JustReachedHome() - { - instance.DoUseDoorOrButton(instance.GetGuidData(GameObjectIds.MainGateDoor)); - instance.SetData(DataTypes.TypeNorthrendBeasts, (uint)EncounterState.Fail); + if (_instance.GetData(DataTypes.TypeNorthrendBeasts) != NorthrendBeasts.GormokInProgress) me.DespawnOrUnsummon(); + } + + InstanceScript _instance; + } + + [Script] + public class boss_acidmaw : boss_jormungarAI + { + public boss_acidmaw(Creature creature) : base(creature) { } + + public override void Reset() + { + base.Reset(); + BiteSpell = Beasts.SpellParalyticBite; + SpewSpell = Beasts.SpellAcidSpew; + SpitSpell = Beasts.SpellAcidSpit; + SpraySpell = Beasts.SpellParalyticSpray; + ModelStationary = Beasts.ModelAcidmawStationary; + ModelMobile = Beasts.ModelAcidmawMobile; + OtherWormEntry = CreatureIds.Dreadscale; + + WasMobile = true; + Emerge(); + } + } + + [Script] + public class boss_dreadscale : boss_jormungarAI + { + public boss_dreadscale(Creature creature) : base(creature) + { + } + + public override void Reset() + { + base.Reset(); + BiteSpell = Beasts.SpellBurningBite; + SpewSpell = Beasts.SpellMoltenSpew; + SpitSpell = Beasts.SpellFireSpit; + SpraySpell = Beasts.SpellBurningSpray; + ModelStationary = Beasts.ModelDreadscaleStationary; + ModelMobile = Beasts.ModelDreadscaleMobile; + OtherWormEntry = CreatureIds.Acidmaw; + + _events.SetPhase(Beasts.PhaseMobile); + _events.ScheduleEvent(Beasts.EventSummonAcidmaw, 3 * Time.InMilliseconds); + _events.ScheduleEvent(Beasts.EventSubmerge, 45 * Time.InMilliseconds, 0, Beasts.PhaseMobile); + WasMobile = false; + } + + public override void MovementInform(MovementGeneratorType type, uint id) + { + if (type != MovementGeneratorType.Point) + return; + + switch (id) + { + case 0: + instance.DoUseDoorOrButton(instance.GetGuidData(GameObjectIds.MainGateDoor)); + me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); + me.SetReactState(ReactStates.Aggressive); + me.SetInCombatWithZone(); + break; + default: + break; + } + } + + public override void EnterEvadeMode(EvadeReason why) + { + instance.DoUseDoorOrButton(instance.GetGuidData(GameObjectIds.MainGateDoor)); + base.EnterEvadeMode(why); + } + + public override void JustReachedHome() + { + instance.DoUseDoorOrButton(instance.GetGuidData(GameObjectIds.MainGateDoor)); + + base.JustReachedHome(); + } + } + + [Script] + class npc_slime_pool : ScriptedAI + { + public npc_slime_pool(Creature creature) : base(creature) + { + _instance = creature.GetInstanceScript(); + } + + public override void Reset() + { + _cast = false; + me.SetReactState(ReactStates.Passive); + } + + public override void UpdateAI(uint diff) + { + if (!_cast) + { + _cast = true; + DoCast(me, Beasts.SpellSlimePoolEffect); } - public override void KilledUnit(Unit who) - { - if (who.IsTypeId(TypeId.Player)) - instance.SetData(DataTypes.TributeToImmortalityEligible, 0); - } + if (_instance.GetData(DataTypes.TypeNorthrendBeasts) != NorthrendBeasts.SnakesInProgress && _instance.GetData(DataTypes.TypeNorthrendBeasts) != NorthrendBeasts.SnakesSpecial) + me.DespawnOrUnsummon(); + } - public override void EnterCombat(Unit who) - { - _EnterCombat(); - instance.SetData(DataTypes.TypeNorthrendBeasts, NorthrendBeasts.IcehowlInProgress); - } + InstanceScript _instance; + bool _cast; - public override void SpellHitTarget(Unit target, SpellInfo spell) + } + + [Script] + class spell_gormok_fire_bomb : SpellScript + { + void TriggerFireBomb(uint effIndex) + { + Position pos = GetExplTargetDest(); + if (pos != null) { - if (spell.Id == Beasts.SpellTrample && target.IsTypeId(TypeId.Player)) - { - if (!_trampleCast) + Unit caster = GetCaster(); + if (caster) + caster.SummonCreature(Beasts.NpcFireBomb, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), 0, TempSummonType.TimedDespawn, 30 * Time.InMilliseconds); + } + } + + public override void Register() + { + OnEffectHit.Add(new EffectHandler(TriggerFireBomb, 0, SpellEffectName.TriggerMissile)); + } + } + + [Script] + class boss_icehowl : BossAI + { + public boss_icehowl(Creature creature) : base(creature, DataTypes.BossBeasts) { } + + public override void Reset() + { + _events.ScheduleEvent(Beasts.EventFerociousButt, RandomHelper.URand(15 * Time.InMilliseconds, 30 * Time.InMilliseconds)); + _events.ScheduleEvent(Beasts.EventArcticBreath, RandomHelper.URand(15 * Time.InMilliseconds, 25 * Time.InMilliseconds)); + _events.ScheduleEvent(Beasts.EventWhirl, RandomHelper.URand(15 * Time.InMilliseconds, 30 * Time.InMilliseconds)); + _events.ScheduleEvent(Beasts.EventMassiveCrash, 30 * Time.InMilliseconds); + _movementFinish = false; + _trampleCast = false; + _trampleTargetGUID.Clear(); + _trampleTargetX = 0; + _trampleTargetY = 0; + _trampleTargetZ = 0; + _stage = 0; + } + + public override void JustDied(Unit killer) + { + _JustDied(); + instance.SetData(DataTypes.TypeNorthrendBeasts, NorthrendBeasts.IcehowlDone); + } + + public override void MovementInform(MovementGeneratorType type, uint id) + { + if (type != MovementGeneratorType.Point && type != MovementGeneratorType.Effect) + return; + + switch (id) + { + case 0: + if (_stage != 0) { - DoCast(me, Beasts.SpellFrothingRage, true); - _trampleCast = true; - } - } - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _events.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - switch (_stage) - { - case 0: + if (me.GetDistance2d(MiscData.ToCCommonLoc[1].GetPositionX(), MiscData.ToCCommonLoc[1].GetPositionY()) < 6.0f) + // Middle of the room + _stage = 1; + else { - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case Beasts.EventFerociousButt: - DoCastVictim(Beasts.SpellFerociousButt); - _events.ScheduleEvent(Beasts.EventFerociousButt, RandomHelper.URand(15 * Time.InMilliseconds, 30 * Time.InMilliseconds)); - return; - case Beasts.EventArcticBreath: - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 0.0f, true); - if (target) - DoCast(target, Beasts.SpellArcticBreath); - return; - case Beasts.EventWhirl: - DoCastAOE(Beasts.SpellWhirl); - _events.ScheduleEvent(Beasts.EventWhirl, RandomHelper.URand(15 * Time.InMilliseconds, 30 * Time.InMilliseconds)); - return; - case Beasts.EventMassiveCrash: - me.GetMotionMaster().MoveJump(MiscData.ToCCommonLoc[1], 20.0f, 20.0f, 0); // 1: Middle of the room - SetCombatMovement(false); - me.AttackStop(); - _stage = 7; //Invalid (Do nothing more than move) - return; - default: - break; - } - }); - DoMeleeAttackIfReady(); - break; - } - case 1: - DoCastAOE(Beasts.SpellMassiveCrash); - me.StopMoving(); - me.AttackStop(); - _stage = 2; - break; - case 2: - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 0.0f, true); - if (target) - { - me.StopMoving(); - me.AttackStop(); - _trampleTargetGUID = target.GetGUID(); - me.SetTarget(_trampleTargetGUID); - _trampleCast = false; - SetCombatMovement(false); - me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable); - me.SetControlled(true, UnitState.Root); - me.GetMotionMaster().Clear(); - me.GetMotionMaster().MoveIdle(); - _events.ScheduleEvent(Beasts.EventTrample, 4 * Time.InMilliseconds); - _stage = 3; - } + // Landed from Hop backwards (start trample) + if (Global.ObjAccessor.GetPlayer(me, _trampleTargetGUID)) + _stage = 4; else _stage = 6; - break; } - case 3: + } + break; + case 1: // Finish trample + _movementFinish = true; + break; + case 2: + instance.DoUseDoorOrButton(instance.GetGuidData(GameObjectIds.MainGateDoor)); + me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); + me.SetReactState(ReactStates.Aggressive); + me.SetInCombatWithZone(); + break; + default: + break; + } + } + + public override void EnterEvadeMode(EvadeReason why) + { + instance.DoUseDoorOrButton(instance.GetGuidData(GameObjectIds.MainGateDoor)); + base.EnterEvadeMode(why); + } + + public override void JustReachedHome() + { + instance.DoUseDoorOrButton(instance.GetGuidData(GameObjectIds.MainGateDoor)); + instance.SetData(DataTypes.TypeNorthrendBeasts, (uint)EncounterState.Fail); + me.DespawnOrUnsummon(); + } + + public override void KilledUnit(Unit who) + { + if (who.IsTypeId(TypeId.Player)) + instance.SetData(DataTypes.TributeToImmortalityEligible, 0); + } + + public override void EnterCombat(Unit who) + { + _EnterCombat(); + instance.SetData(DataTypes.TypeNorthrendBeasts, NorthrendBeasts.IcehowlInProgress); + } + + public override void SpellHitTarget(Unit target, SpellInfo spell) + { + if (spell.Id == Beasts.SpellTrample && target.IsTypeId(TypeId.Player)) + { + if (!_trampleCast) + { + DoCast(me, Beasts.SpellFrothingRage, true); + _trampleCast = true; + } + } + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _events.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + switch (_stage) + { + case 0: + { _events.ExecuteEvents(eventId => { switch (eventId) { - case Beasts.EventTrample: - { - Unit target = Global.ObjAccessor.GetPlayer(me, _trampleTargetGUID); - if (target) - { - me.StopMoving(); - me.AttackStop(); - _trampleCast = false; - _trampleTargetX = target.GetPositionX(); - _trampleTargetY = target.GetPositionY(); - _trampleTargetZ = target.GetPositionZ(); - // 2: Hop Backwards - me.GetMotionMaster().MoveJump(2 * me.GetPositionX() - _trampleTargetX, 2 * me.GetPositionY() - _trampleTargetY, me.GetPositionZ(), me.GetOrientation(), 30.0f, 20.0f, 0); - me.SetControlled(false, UnitState.Root); - _stage = 7; //Invalid (Do nothing more than move) - } - else - _stage = 6; - break; - } + case Beasts.EventFerociousButt: + DoCastVictim(Beasts.SpellFerociousButt); + _events.ScheduleEvent(Beasts.EventFerociousButt, RandomHelper.URand(15 * Time.InMilliseconds, 30 * Time.InMilliseconds)); + return; + case Beasts.EventArcticBreath: + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 0.0f, true); + if (target) + DoCast(target, Beasts.SpellArcticBreath); + return; + case Beasts.EventWhirl: + DoCastAOE(Beasts.SpellWhirl); + _events.ScheduleEvent(Beasts.EventWhirl, RandomHelper.URand(15 * Time.InMilliseconds, 30 * Time.InMilliseconds)); + return; + case Beasts.EventMassiveCrash: + me.GetMotionMaster().MoveJump(MiscData.ToCCommonLoc[1], 20.0f, 20.0f, 0); // 1: Middle of the room + SetCombatMovement(false); + me.AttackStop(); + _stage = 7; //Invalid (Do nothing more than move) + return; default: break; } }); + DoMeleeAttackIfReady(); break; - case 4: + } + case 1: + DoCastAOE(Beasts.SpellMassiveCrash); + me.StopMoving(); + me.AttackStop(); + _stage = 2; + break; + case 2: + { + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 0.0f, true); + if (target) { me.StopMoving(); me.AttackStop(); - - Player target = Global.ObjAccessor.GetPlayer(me, _trampleTargetGUID); - if (target) - Talk(Beasts.EmoteTrampleStart, target); - - me.GetMotionMaster().MoveCharge(_trampleTargetX, _trampleTargetY, _trampleTargetZ, 42, 1); - me.SetTarget(ObjectGuid.Empty); - _stage = 5; - break; - } - case 5: - if (_movementFinish) - { - DoCastAOE(Beasts.SpellTrample); - _movementFinish = false; - _stage = 6; - return; - } - if (_events.ExecuteEvent() == Beasts.EventTrample) - { - var lPlayers = me.GetMap().GetPlayers(); - foreach (var player in lPlayers) - { - if (player.IsAlive() && player.IsWithinDistInMap(me, 6.0f)) - { - DoCastAOE(Beasts.SpellTrample); - _events.ScheduleEvent(Beasts.EventTrample, 4 * Time.InMilliseconds); - break; - } - } - } - break; - case 6: - if (!_trampleCast) - { - DoCast(me, Beasts.SpellStaggeredDaze); - Talk(Beasts.EmoteTrampleCrash); + _trampleTargetGUID = target.GetGUID(); + me.SetTarget(_trampleTargetGUID); + _trampleCast = false; + SetCombatMovement(false); + me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable); + me.SetControlled(true, UnitState.Root); + me.GetMotionMaster().Clear(); + me.GetMotionMaster().MoveIdle(); + _events.ScheduleEvent(Beasts.EventTrample, 4 * Time.InMilliseconds); + _stage = 3; } else + _stage = 6; + break; + } + case 3: + _events.ExecuteEvents(eventId => + { + switch (eventId) { - DoCast(me, Beasts.SpellFrothingRage, true); - Talk(Beasts.EmoteTrampleFail); + case Beasts.EventTrample: + { + Unit target = Global.ObjAccessor.GetPlayer(me, _trampleTargetGUID); + if (target) + { + me.StopMoving(); + me.AttackStop(); + _trampleCast = false; + _trampleTargetX = target.GetPositionX(); + _trampleTargetY = target.GetPositionY(); + _trampleTargetZ = target.GetPositionZ(); + // 2: Hop Backwards + me.GetMotionMaster().MoveJump(2 * me.GetPositionX() - _trampleTargetX, 2 * me.GetPositionY() - _trampleTargetY, me.GetPositionZ(), me.GetOrientation(), 30.0f, 20.0f, 0); + me.SetControlled(false, UnitState.Root); + _stage = 7; //Invalid (Do nothing more than move) + } + else + _stage = 6; + break; + } + default: + break; } - me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); - SetCombatMovement(true); - me.GetMotionMaster().MovementExpired(); - me.GetMotionMaster().Clear(); - me.GetMotionMaster().MoveChase(me.GetVictim()); - AttackStart(me.GetVictim()); - _events.ScheduleEvent(Beasts.EventMassiveCrash, 40 * Time.InMilliseconds); - _events.ScheduleEvent(Beasts.EventArcticBreath, RandomHelper.URand(15 * Time.InMilliseconds, 25 * Time.InMilliseconds)); - _stage = 0; + }); + break; + case 4: + { + me.StopMoving(); + me.AttackStop(); + + Player target = Global.ObjAccessor.GetPlayer(me, _trampleTargetGUID); + if (target) + Talk(Beasts.EmoteTrampleStart, target); + + me.GetMotionMaster().MoveCharge(_trampleTargetX, _trampleTargetY, _trampleTargetZ, 42, 1); + me.SetTarget(ObjectGuid.Empty); + _stage = 5; break; - default: - break; - } + } + case 5: + if (_movementFinish) + { + DoCastAOE(Beasts.SpellTrample); + _movementFinish = false; + _stage = 6; + return; + } + if (_events.ExecuteEvent() == Beasts.EventTrample) + { + var lPlayers = me.GetMap().GetPlayers(); + foreach (var player in lPlayers) + { + if (player.IsAlive() && player.IsWithinDistInMap(me, 6.0f)) + { + DoCastAOE(Beasts.SpellTrample); + _events.ScheduleEvent(Beasts.EventTrample, 4 * Time.InMilliseconds); + break; + } + } + } + break; + case 6: + if (!_trampleCast) + { + DoCast(me, Beasts.SpellStaggeredDaze); + Talk(Beasts.EmoteTrampleCrash); + } + else + { + DoCast(me, Beasts.SpellFrothingRage, true); + Talk(Beasts.EmoteTrampleFail); + } + me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); + SetCombatMovement(true); + me.GetMotionMaster().MovementExpired(); + me.GetMotionMaster().Clear(); + me.GetMotionMaster().MoveChase(me.GetVictim()); + AttackStart(me.GetVictim()); + _events.ScheduleEvent(Beasts.EventMassiveCrash, 40 * Time.InMilliseconds); + _events.ScheduleEvent(Beasts.EventArcticBreath, RandomHelper.URand(15 * Time.InMilliseconds, 25 * Time.InMilliseconds)); + _stage = 0; + break; + default: + break; } - - float _trampleTargetX, _trampleTargetY, _trampleTargetZ; - ObjectGuid _trampleTargetGUID; - bool _movementFinish; - bool _trampleCast; - byte _stage; } - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } + float _trampleTargetX, _trampleTargetY, _trampleTargetZ; + ObjectGuid _trampleTargetGUID; + bool _movementFinish; + bool _trampleCast; + byte _stage; } - class boss_jormungarAI : BossAI + public class boss_jormungarAI : BossAI { public boss_jormungarAI(Creature creature) : base(creature, DataTypes.BossBeasts) { } diff --git a/Scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/TrialOfTheCrusader.cs b/Scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/TrialOfTheCrusader.cs index ed4142b1d..c7b7ac62f 100644 --- a/Scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/TrialOfTheCrusader.cs +++ b/Scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/TrialOfTheCrusader.cs @@ -770,6 +770,12 @@ namespace Scripts.Northrend.CrusadersColiseum.TrialOfTheCrusader { return new instance_trial_of_the_crusader_InstanceMapScript(map); } + + public static T GetTrialOfTheCrusaderAI(Creature creature) where T : CreatureAI + { + return GetInstanceAI(creature, "instance_trial_of_the_crusader"); + } + } [Script] @@ -779,9 +785,7 @@ namespace Scripts.Northrend.CrusadersColiseum.TrialOfTheCrusader class npc_announcer_toc10AI : ScriptedAI { - public npc_announcer_toc10AI(Creature creature) : base(creature) - { - } + public npc_announcer_toc10AI(Creature creature) : base(creature) { } public override void Reset() { @@ -895,825 +899,775 @@ namespace Scripts.Northrend.CrusadersColiseum.TrialOfTheCrusader public override CreatureAI GetAI(Creature creature) { - return new npc_announcer_toc10AI(creature); + return instance_trial_of_the_crusader.GetTrialOfTheCrusaderAI(creature); } } [Script] - class boss_lich_king_toc : CreatureScript + class boss_lich_king_toc : ScriptedAI { - public boss_lich_king_toc() : base("boss_lich_king_toc") { } - - class boss_lich_king_tocAI : ScriptedAI + public boss_lich_king_toc(Creature creature) : base(creature) { - public boss_lich_king_tocAI(Creature creature) : base(creature) + _instance = creature.GetInstanceScript(); + } + + public override void Reset() + { + _updateTimer = 0; + me.SetReactState(ReactStates.Passive); + Creature summoned = me.SummonCreature(CreatureIds.Trigger, MiscData.ToCCommonLoc[2].GetPositionX(), MiscData.ToCCommonLoc[2].GetPositionY(), MiscData.ToCCommonLoc[2].GetPositionZ(), 5, TempSummonType.TimedDespawn, 1 * Time.Minute * Time.InMilliseconds); + if (summoned) { - _instance = creature.GetInstanceScript(); + summoned.CastSpell(summoned, 51807, false); + summoned.SetDisplayId(summoned.GetCreatureTemplate().ModelId2); } - public override void Reset() - { - _updateTimer = 0; - me.SetReactState(ReactStates.Passive); - Creature summoned = me.SummonCreature(CreatureIds.Trigger, MiscData.ToCCommonLoc[2].GetPositionX(), MiscData.ToCCommonLoc[2].GetPositionY(), MiscData.ToCCommonLoc[2].GetPositionZ(), 5, TempSummonType.TimedDespawn, 1 * Time.Minute * Time.InMilliseconds); - if (summoned) - { - summoned.CastSpell(summoned, 51807, false); - summoned.SetDisplayId(summoned.GetCreatureTemplate().ModelId2); - } + _instance.SetBossState(DataTypes.BossLichKing, EncounterState.InProgress); + me.SetWalk(true); + } - _instance.SetBossState(DataTypes.BossLichKing, EncounterState.InProgress); - me.SetWalk(true); + public override void MovementInform(MovementGeneratorType type, uint id) + { + if (type != MovementGeneratorType.Point || _instance == null) + return; + + switch (id) + { + case 0: + _instance.SetData(DataTypes.TypeEvent, 5030); + break; + case 1: + _instance.SetData(DataTypes.TypeEvent, 5050); + break; + default: + break; } + } - public override void MovementInform(MovementGeneratorType type, uint id) + public override void UpdateAI(uint uiDiff) + { + if (_instance == null) + return; + + if (_instance.GetData(DataTypes.TypeEventNpc) != CreatureIds.LichKing) + return; + + _updateTimer = _instance.GetData(DataTypes.TypeEventTimer); + if (_updateTimer <= uiDiff) { - if (type != MovementGeneratorType.Point || _instance == null) - return; - - switch (id) + switch (_instance.GetData(DataTypes.TypeEvent)) { - case 0: - _instance.SetData(DataTypes.TypeEvent, 5030); + case 5010: + Talk(Texts.Stage_4_02); + _updateTimer = 3 * Time.InMilliseconds; + me.GetMotionMaster().MovePoint(0, MiscData.LichKingLoc[0]); + _instance.SetData(DataTypes.TypeEvent, 5020); break; - case 1: - _instance.SetData(DataTypes.TypeEvent, 5050); + case 5030: + Talk(Texts.Stage_4_04); + me.SetUInt32Value(UnitFields.NpcEmotestate, (uint)Emote.StateTalk); + _updateTimer = 10 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 5040); break; + case 5040: + me.SetUInt32Value(UnitFields.NpcEmotestate, (uint)Emote.OneshotNone); + me.GetMotionMaster().MovePoint(1, MiscData.LichKingLoc[1]); + _updateTimer = 1 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 0); + break; + case 5050: + me.HandleEmoteCommand(Emote.OneshotExclamation); + _updateTimer = 3 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 5060); + break; + case 5060: + Talk(Texts.Stage_4_05); + me.HandleEmoteCommand(Emote.OneshotKneel); + _updateTimer = (uint)(2.5 * Time.InMilliseconds); + _instance.SetData(DataTypes.TypeEvent, 5070); + break; + case 5070: + me.CastSpell(me, 68198, false); + _updateTimer = (uint)(1.5 * Time.InMilliseconds); + _instance.SetData(DataTypes.TypeEvent, 5080); + break; + case 5080: + { + GameObject go = ObjectAccessor.GetGameObject(me, _instance.GetGuidData(GameObjectIds.ArgentColiseumFloor)); + if (go) + { + go.SetDisplayId(MiscData.DisplayIdDestroyedFloor); + go.SetFlag(GameObjectFields.Flags, GameObjectFlags.Damaged | GameObjectFlags.NoDespawn); + go.SetGoState(GameObjectState.Active); + } + + me.CastSpell(me, Spells.CorpseTeleport, false); + me.CastSpell(me, Spells.DestroyFloorKnockup, false); + + _instance.SetBossState(DataTypes.BossLichKing, EncounterState.Done); + Creature temp = ObjectAccessor.GetCreature(me, _instance.GetGuidData(CreatureIds.Anubarak)); + if (!temp || !temp.IsAlive()) + temp = me.SummonCreature(CreatureIds.Anubarak, MiscData.AnubarakLoc[0].GetPositionX(), MiscData.AnubarakLoc[0].GetPositionY(), MiscData.AnubarakLoc[0].GetPositionZ(), 3, TempSummonType.CorpseTimedDespawn, MiscData.DespawnTime); + + _instance.SetData(DataTypes.TypeEvent, 0); + + me.DespawnOrUnsummon(); + _updateTimer = 20 * Time.InMilliseconds; + break; + } default: break; } } + else + _updateTimer -= uiDiff; - public override void UpdateAI(uint uiDiff) - { - if (_instance == null) - return; - - if (_instance.GetData(DataTypes.TypeEventNpc) != CreatureIds.LichKing) - return; - - _updateTimer = _instance.GetData(DataTypes.TypeEventTimer); - if (_updateTimer <= uiDiff) - { - switch (_instance.GetData(DataTypes.TypeEvent)) - { - case 5010: - Talk(Texts.Stage_4_02); - _updateTimer = 3 * Time.InMilliseconds; - me.GetMotionMaster().MovePoint(0, MiscData.LichKingLoc[0]); - _instance.SetData(DataTypes.TypeEvent, 5020); - break; - case 5030: - Talk(Texts.Stage_4_04); - me.SetUInt32Value(UnitFields.NpcEmotestate, (uint)Emote.StateTalk); - _updateTimer = 10 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 5040); - break; - case 5040: - me.SetUInt32Value(UnitFields.NpcEmotestate, (uint)Emote.OneshotNone); - me.GetMotionMaster().MovePoint(1, MiscData.LichKingLoc[1]); - _updateTimer = 1 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 0); - break; - case 5050: - me.HandleEmoteCommand(Emote.OneshotExclamation); - _updateTimer = 3 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 5060); - break; - case 5060: - Talk(Texts.Stage_4_05); - me.HandleEmoteCommand(Emote.OneshotKneel); - _updateTimer = (uint)(2.5 * Time.InMilliseconds); - _instance.SetData(DataTypes.TypeEvent, 5070); - break; - case 5070: - me.CastSpell(me, 68198, false); - _updateTimer = (uint)(1.5 * Time.InMilliseconds); - _instance.SetData(DataTypes.TypeEvent, 5080); - break; - case 5080: - { - GameObject go = ObjectAccessor.GetGameObject(me, _instance.GetGuidData(GameObjectIds.ArgentColiseumFloor)); - if (go) - { - go.SetDisplayId(MiscData.DisplayIdDestroyedFloor); - go.SetFlag(GameObjectFields.Flags, GameObjectFlags.Damaged | GameObjectFlags.NoDespawn); - go.SetGoState(GameObjectState.Active); - } - - me.CastSpell(me, Spells.CorpseTeleport, false); - me.CastSpell(me, Spells.DestroyFloorKnockup, false); - - _instance.SetBossState(DataTypes.BossLichKing, EncounterState.Done); - Creature temp = ObjectAccessor.GetCreature(me, _instance.GetGuidData(CreatureIds.Anubarak)); - if (!temp || !temp.IsAlive()) - temp = me.SummonCreature(CreatureIds.Anubarak, MiscData.AnubarakLoc[0].GetPositionX(), MiscData.AnubarakLoc[0].GetPositionY(), MiscData.AnubarakLoc[0].GetPositionZ(), 3, TempSummonType.CorpseTimedDespawn, MiscData.DespawnTime); - - _instance.SetData(DataTypes.TypeEvent, 0); - - me.DespawnOrUnsummon(); - _updateTimer = 20 * Time.InMilliseconds; - break; - } - default: - break; - } - } - else - _updateTimer -= uiDiff; - - _instance.SetData(DataTypes.TypeEventTimer, _updateTimer); - } - - InstanceScript _instance; - uint _updateTimer; + _instance.SetData(DataTypes.TypeEventTimer, _updateTimer); } - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } + InstanceScript _instance; + uint _updateTimer; } [Script] - class npc_fizzlebang_toc : CreatureScript + class npc_fizzlebang_toc : ScriptedAI { - public npc_fizzlebang_toc() : base("npc_fizzlebang_toc") { } - - class npc_fizzlebang_tocAI : ScriptedAI + public npc_fizzlebang_toc(Creature creature) : base(creature) { - public npc_fizzlebang_tocAI(Creature creature) : base(creature) - { - _summons = new SummonList(me); - _instance = me.GetInstanceScript(); - } + _summons = new SummonList(me); + _instance = me.GetInstanceScript(); + } - public override void JustDied(Unit killer) + public override void JustDied(Unit killer) + { + Talk(Texts.Stage_1_06, killer); + _instance.SetData(DataTypes.TypeEvent, 1180); + Creature temp = ObjectAccessor.GetCreature(me, _instance.GetGuidData(CreatureIds.Jaraxxus)); + if (temp) { - Talk(Texts.Stage_1_06, killer); - _instance.SetData(DataTypes.TypeEvent, 1180); - Creature temp = ObjectAccessor.GetCreature(me, _instance.GetGuidData(CreatureIds.Jaraxxus)); - if (temp) + temp.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); + temp.SetReactState(ReactStates.Aggressive); + temp.SetInCombatWithZone(); + } + } + + public override void Reset() + { + me.SetWalk(true); + _portalGUID.Clear(); + me.GetMotionMaster().MovePoint(1, MiscData.ToCCommonLoc[10].GetPositionX(), MiscData.ToCCommonLoc[10].GetPositionY() - 60, MiscData.ToCCommonLoc[10].GetPositionZ()); + } + + public override void MovementInform(MovementGeneratorType type, uint id) + { + if (type != MovementGeneratorType.Point) + return; + + switch (id) + { + case 1: + me.SetWalk(false); + _instance.DoUseDoorOrButton(_instance.GetGuidData(GameObjectIds.MainGateDoor)); + _instance.SetData(DataTypes.TypeEvent, 1120); + _instance.SetData(DataTypes.TypeEventTimer, 1 * Time.InMilliseconds); + break; + default: + break; + } + } + + public override void JustSummoned(Creature summoned) + { + _summons.Summon(summoned); + } + + public override void UpdateAI(uint uiDiff) + { + if (_instance == null) + return; + + if (_instance.GetData(DataTypes.TypeEventNpc) != CreatureIds.Fizzlebang) + return; + + _updateTimer = _instance.GetData(DataTypes.TypeEventTimer); + if (_updateTimer <= uiDiff) + { + switch (_instance.GetData(DataTypes.TypeEvent)) { - temp.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); - temp.SetReactState(ReactStates.Aggressive); - temp.SetInCombatWithZone(); - } - } - - public override void Reset() - { - me.SetWalk(true); - _portalGUID.Clear(); - me.GetMotionMaster().MovePoint(1, MiscData.ToCCommonLoc[10].GetPositionX(), MiscData.ToCCommonLoc[10].GetPositionY() - 60, MiscData.ToCCommonLoc[10].GetPositionZ()); - } - - public override void MovementInform(MovementGeneratorType type, uint id) - { - if (type != MovementGeneratorType.Point) - return; - - switch (id) - { - case 1: - me.SetWalk(false); - _instance.DoUseDoorOrButton(_instance.GetGuidData(GameObjectIds.MainGateDoor)); + case 1110: _instance.SetData(DataTypes.TypeEvent, 1120); - _instance.SetData(DataTypes.TypeEventTimer, 1 * Time.InMilliseconds); + _updateTimer = 4 * Time.InMilliseconds; break; - default: + case 1120: + Talk(Texts.Stage_1_02); + _instance.SetData(DataTypes.TypeEvent, 1130); + _updateTimer = 12 * Time.InMilliseconds; break; - } - } - - public override void JustSummoned(Creature summoned) - { - _summons.Summon(summoned); - } - - public override void UpdateAI(uint uiDiff) - { - if (_instance == null) - return; - - if (_instance.GetData(DataTypes.TypeEventNpc) != CreatureIds.Fizzlebang) - return; - - _updateTimer = _instance.GetData(DataTypes.TypeEventTimer); - if (_updateTimer <= uiDiff) - { - switch (_instance.GetData(DataTypes.TypeEvent)) - { - case 1110: - _instance.SetData(DataTypes.TypeEvent, 1120); - _updateTimer = 4 * Time.InMilliseconds; - break; - case 1120: - Talk(Texts.Stage_1_02); - _instance.SetData(DataTypes.TypeEvent, 1130); - _updateTimer = 12 * Time.InMilliseconds; - break; - case 1130: - { - me.GetMotionMaster().MovementExpired(); - Talk(Texts.Stage_1_03); - me.HandleEmoteCommand(Emote.OneshotSpellCastOmni); - Unit pTrigger = me.SummonCreature(CreatureIds.Trigger, MiscData.ToCCommonLoc[1].GetPositionX(), MiscData.ToCCommonLoc[1].GetPositionY(), MiscData.ToCCommonLoc[1].GetPositionZ(), 4.69494f, TempSummonType.ManualDespawn); - if (pTrigger) - { - _triggerGUID = pTrigger.GetGUID(); - pTrigger.SetObjectScale(2.0f); - pTrigger.SetDisplayId(pTrigger.ToCreature().GetCreatureTemplate().ModelId1); - pTrigger.CastSpell(pTrigger, Spells.WilfredPortal, false); - } - _instance.SetData(DataTypes.TypeEvent, 1132); - _updateTimer = 4 * Time.InMilliseconds; - break; - } - case 1132: + case 1130: + { me.GetMotionMaster().MovementExpired(); - _instance.SetData(DataTypes.TypeEvent, 1134); + Talk(Texts.Stage_1_03); + me.HandleEmoteCommand(Emote.OneshotSpellCastOmni); + Unit pTrigger = me.SummonCreature(CreatureIds.Trigger, MiscData.ToCCommonLoc[1].GetPositionX(), MiscData.ToCCommonLoc[1].GetPositionY(), MiscData.ToCCommonLoc[1].GetPositionZ(), 4.69494f, TempSummonType.ManualDespawn); + if (pTrigger) + { + _triggerGUID = pTrigger.GetGUID(); + pTrigger.SetObjectScale(2.0f); + pTrigger.SetDisplayId(pTrigger.ToCreature().GetCreatureTemplate().ModelId1); + pTrigger.CastSpell(pTrigger, Spells.WilfredPortal, false); + } + _instance.SetData(DataTypes.TypeEvent, 1132); _updateTimer = 4 * Time.InMilliseconds; break; - case 1134: + } + case 1132: + me.GetMotionMaster().MovementExpired(); + _instance.SetData(DataTypes.TypeEvent, 1134); + _updateTimer = 4 * Time.InMilliseconds; + break; + case 1134: + { + me.HandleEmoteCommand(Emote.OneshotSpellCastOmni); + Creature pPortal = me.SummonCreature(CreatureIds.WilfredPortal, MiscData.ToCCommonLoc[1].GetPositionX(), MiscData.ToCCommonLoc[1].GetPositionY(), MiscData.ToCCommonLoc[1].GetPositionZ(), 4.71239f, TempSummonType.ManualDespawn); + if (pPortal) { - me.HandleEmoteCommand(Emote.OneshotSpellCastOmni); - Creature pPortal = me.SummonCreature(CreatureIds.WilfredPortal, MiscData.ToCCommonLoc[1].GetPositionX(), MiscData.ToCCommonLoc[1].GetPositionY(), MiscData.ToCCommonLoc[1].GetPositionZ(), 4.71239f, TempSummonType.ManualDespawn); - if (pPortal) - { - pPortal.SetReactState(ReactStates.Passive); - pPortal.SetObjectScale(2.0f); - pPortal.CastSpell(pPortal, Spells.WilfredPortal, false); - _portalGUID = pPortal.GetGUID(); - } - _updateTimer = 4 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 1135); - break; + pPortal.SetReactState(ReactStates.Passive); + pPortal.SetObjectScale(2.0f); + pPortal.CastSpell(pPortal, Spells.WilfredPortal, false); + _portalGUID = pPortal.GetGUID(); } - case 1135: - _instance.SetData(DataTypes.TypeEvent, 1140); + _updateTimer = 4 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 1135); + break; + } + case 1135: + _instance.SetData(DataTypes.TypeEvent, 1140); + _updateTimer = 3 * Time.InMilliseconds; + break; + case 1140: + { + Talk(Texts.Stage_1_04); + Creature temp = me.SummonCreature(CreatureIds.Jaraxxus, MiscData.ToCCommonLoc[1].GetPositionX(), MiscData.ToCCommonLoc[1].GetPositionY(), MiscData.ToCCommonLoc[1].GetPositionZ(), 5.0f, TempSummonType.CorpseTimedDespawn, MiscData.DespawnTime); + if (temp) + { + temp.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable); + temp.SetReactState(ReactStates.Passive); + temp.GetMotionMaster().MovePoint(0, MiscData.ToCCommonLoc[1].GetPositionX(), MiscData.ToCCommonLoc[1].GetPositionY() - 10, MiscData.ToCCommonLoc[1].GetPositionZ()); + } + _instance.SetData(DataTypes.TypeEvent, 1142); + _updateTimer = 5 * Time.InMilliseconds; + break; + } + case 1142: + { + Creature temp = ObjectAccessor.GetCreature(me, _instance.GetGuidData(CreatureIds.Jaraxxus)); + if (temp) + temp.SetTarget(me.GetGUID()); + + Creature pTrigger = ObjectAccessor.GetCreature(me, _triggerGUID); + if (pTrigger) + pTrigger.DespawnOrUnsummon(); + + Creature pPortal = ObjectAccessor.GetCreature(me, _portalGUID); + if (pPortal) + pPortal.DespawnOrUnsummon(); + _instance.SetData(DataTypes.TypeEvent, 1144); + _updateTimer = 10 * Time.InMilliseconds; + break; + } + case 1144: + { + Creature temp = ObjectAccessor.GetCreature(me, _instance.GetGuidData(CreatureIds.Jaraxxus)); + if (temp) + temp.GetAI().Talk(Texts.Stage_1_05); + _instance.SetData(DataTypes.TypeEvent, 1150); + _updateTimer = 5 * Time.InMilliseconds; + break; + } + case 1150: + { + Creature temp = ObjectAccessor.GetCreature(me, _instance.GetGuidData(CreatureIds.Jaraxxus)); + if (temp) + { + //1-shot Fizzlebang + temp.CastSpell(me, 67888, false); + me.SetInCombatWith(temp); + temp.AddThreat(me, 1000.0f); + temp.GetAI().AttackStart(me); + } + _instance.SetData(DataTypes.TypeEvent, 1160); _updateTimer = 3 * Time.InMilliseconds; break; - case 1140: - { - Talk(Texts.Stage_1_04); - Creature temp = me.SummonCreature(CreatureIds.Jaraxxus, MiscData.ToCCommonLoc[1].GetPositionX(), MiscData.ToCCommonLoc[1].GetPositionY(), MiscData.ToCCommonLoc[1].GetPositionZ(), 5.0f, TempSummonType.CorpseTimedDespawn, MiscData.DespawnTime); - if (temp) - { - temp.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable); - temp.SetReactState(ReactStates.Passive); - temp.GetMotionMaster().MovePoint(0, MiscData.ToCCommonLoc[1].GetPositionX(), MiscData.ToCCommonLoc[1].GetPositionY() - 10, MiscData.ToCCommonLoc[1].GetPositionZ()); - } - _instance.SetData(DataTypes.TypeEvent, 1142); - _updateTimer = 5 * Time.InMilliseconds; - break; - } - case 1142: - { - Creature temp = ObjectAccessor.GetCreature(me, _instance.GetGuidData(CreatureIds.Jaraxxus)); - if (temp) - temp.SetTarget(me.GetGUID()); - - Creature pTrigger = ObjectAccessor.GetCreature(me, _triggerGUID); - if (pTrigger) - pTrigger.DespawnOrUnsummon(); - - Creature pPortal = ObjectAccessor.GetCreature(me, _portalGUID); - if (pPortal) - pPortal.DespawnOrUnsummon(); - _instance.SetData(DataTypes.TypeEvent, 1144); - _updateTimer = 10 * Time.InMilliseconds; - break; - } - case 1144: - { - Creature temp = ObjectAccessor.GetCreature(me, _instance.GetGuidData(CreatureIds.Jaraxxus)); - if (temp) - temp.GetAI().Talk(Texts.Stage_1_05); - _instance.SetData(DataTypes.TypeEvent, 1150); - _updateTimer = 5 * Time.InMilliseconds; - break; - } - case 1150: - { - Creature temp = ObjectAccessor.GetCreature(me, _instance.GetGuidData(CreatureIds.Jaraxxus)); - if (temp) - { - //1-shot Fizzlebang - temp.CastSpell(me, 67888, false); - me.SetInCombatWith(temp); - temp.AddThreat(me, 1000.0f); - temp.GetAI().AttackStart(me); - } - _instance.SetData(DataTypes.TypeEvent, 1160); - _updateTimer = 3 * Time.InMilliseconds; - break; - } - } + } } - else - _updateTimer -= uiDiff; - _instance.SetData(DataTypes.TypeEventTimer, _updateTimer); } - - InstanceScript _instance; - SummonList _summons; - uint _updateTimer; - ObjectGuid _portalGUID; - ObjectGuid _triggerGUID; + else + _updateTimer -= uiDiff; + _instance.SetData(DataTypes.TypeEventTimer, _updateTimer); } - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } + InstanceScript _instance; + SummonList _summons; + uint _updateTimer; + ObjectGuid _portalGUID; + ObjectGuid _triggerGUID; } [Script] - class npc_tirion_toc : CreatureScript + class npc_tirion_toc : ScriptedAI { - public npc_tirion_toc() : base("npc_tirion_toc") { } - - class npc_tirion_tocAI : ScriptedAI + public npc_tirion_toc(Creature creature) : base(creature) { - public npc_tirion_tocAI(Creature creature) : base(creature) + _instance = me.GetInstanceScript(); + } + + public override void Reset() { } + + public override void AttackStart(Unit who) { } + + public override void UpdateAI(uint uiDiff) + { + if (_instance == null) + return; + + if (_instance.GetData(DataTypes.TypeEventNpc) != CreatureIds.Tirion) + return; + + _updateTimer = _instance.GetData(DataTypes.TypeEventTimer); + if (_updateTimer <= uiDiff) { - _instance = me.GetInstanceScript(); - } - - public override void Reset() { } - - public override void AttackStart(Unit who) { } - - public override void UpdateAI(uint uiDiff) - { - if (_instance == null) - return; - - if (_instance.GetData(DataTypes.TypeEventNpc) != CreatureIds.Tirion) - return; - - _updateTimer = _instance.GetData(DataTypes.TypeEventTimer); - if (_updateTimer <= uiDiff) + switch (_instance.GetData(DataTypes.TypeEvent)) { - switch (_instance.GetData(DataTypes.TypeEvent)) - { - case 110: - me.SetUInt32Value(UnitFields.NpcEmotestate, (uint)Emote.OneshotTalk); - Talk(Texts.Stage_0_01); - _updateTimer = 22 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 120); - break; - case 140: - me.SetUInt32Value(UnitFields.NpcEmotestate, (uint)Emote.OneshotTalk); - Talk(Texts.Stage_0_02); - _updateTimer = 5 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 150); - break; - case 150: - { - me.SetUInt32Value(UnitFields.NpcEmotestate, (uint)Emote.OneshotNone); - if (_instance.GetBossState(DataTypes.BossBeasts) != EncounterState.Done) - { - _instance.DoUseDoorOrButton(_instance.GetGuidData(GameObjectIds.MainGateDoor)); - - Creature temp = me.SummonCreature(CreatureIds.Gormok, MiscData.ToCSpawnLoc[0].GetPositionX(), MiscData.ToCSpawnLoc[0].GetPositionY(), MiscData.ToCSpawnLoc[0].GetPositionZ(), 5, TempSummonType.CorpseTimedDespawn, 30 * Time.InMilliseconds); - if (temp) - { - temp.GetMotionMaster().MovePoint(0, MiscData.ToCCommonLoc[5].GetPositionX(), MiscData.ToCCommonLoc[5].GetPositionY(), MiscData.ToCCommonLoc[5].GetPositionZ()); - temp.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); - temp.SetReactState(ReactStates.Passive); - } - } - _updateTimer = 3 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 155); - break; - } - case 155: - // keep the raid in combat for the whole encounter, pauses included - me.SetInCombatWithZone(); - _updateTimer = 5 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 160); - break; - case 200: - { - Talk(Texts.Stage_0_04); - if (_instance.GetBossState(DataTypes.BossBeasts) != EncounterState.Done) - { - _instance.DoUseDoorOrButton(_instance.GetGuidData(GameObjectIds.MainGateDoor)); - Creature temp = me.SummonCreature(CreatureIds.Dreadscale, MiscData.ToCSpawnLoc[1].GetPositionX(), MiscData.ToCSpawnLoc[1].GetPositionY(), MiscData.ToCSpawnLoc[1].GetPositionZ(), 5, TempSummonType.ManualDespawn); - if (temp) - { - temp.GetMotionMaster().MovePoint(0, MiscData.ToCCommonLoc[5].GetPositionX(), MiscData.ToCCommonLoc[5].GetPositionY(), MiscData.ToCCommonLoc[5].GetPositionZ()); - temp.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); - temp.SetReactState(ReactStates.Passive); - } - } - _updateTimer = 5 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 220); - break; - } - case 220: - _instance.SetData(DataTypes.TypeEvent, 230); - break; - case 300: - { - Talk(Texts.Stage_0_05); - if (_instance.GetBossState(DataTypes.BossBeasts) != EncounterState.Done) - { - _instance.DoUseDoorOrButton(_instance.GetGuidData(GameObjectIds.MainGateDoor)); - Creature temp = me.SummonCreature(CreatureIds.Icehowl, MiscData.ToCSpawnLoc[0].GetPositionX(), MiscData.ToCSpawnLoc[0].GetPositionY(), MiscData.ToCSpawnLoc[0].GetPositionZ(), 5, TempSummonType.DeadDespawn); - if (temp) - { - temp.GetMotionMaster().MovePoint(2, MiscData.ToCCommonLoc[5].GetPositionX(), MiscData.ToCCommonLoc[5].GetPositionY(), MiscData.ToCCommonLoc[5].GetPositionZ()); - me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); - me.SetReactState(ReactStates.Passive); - } - } - _updateTimer = 5 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 315); - break; - } - case 315: - _instance.SetData(DataTypes.TypeEvent, 320); - break; - case 400: - Talk(Texts.Stage_0_06); - me.GetThreatManager().clearReferences(); - _updateTimer = 5 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 0); - break; - case 666: - Talk(Texts.Stage_0_Wipe); - _updateTimer = 5 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 0); - break; - case 1010: - Talk(Texts.Stage_1_01); - _updateTimer = 7 * Time.InMilliseconds; - _instance.DoUseDoorOrButton(_instance.GetGuidData(GameObjectIds.MainGateDoor)); - me.SummonCreature(CreatureIds.Fizzlebang, MiscData.ToCSpawnLoc[0].GetPositionX(), MiscData.ToCSpawnLoc[0].GetPositionY(), MiscData.ToCSpawnLoc[0].GetPositionZ(), 2, TempSummonType.CorpseTimedDespawn, MiscData.DespawnTime); - _instance.SetData(DataTypes.TypeEvent, 0); - break; - case 1180: - Talk(Texts.Stage_1_07); - _updateTimer = 3 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 0); - break; - case 2000: - Talk(Texts.Stage_1_08); - _updateTimer = 18 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 2010); - break; - case 2030: - Talk(Texts.Stage_1_11); - _updateTimer = 5 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 0); - break; - case 3000: - Talk(Texts.Stage_2_01); - _updateTimer = 12 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 3050); - break; - case 3001: - Talk(Texts.Stage_2_01); - _updateTimer = 10 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 3051); - break; - case 3060: - Talk(Texts.Stage_2_03); - _updateTimer = 5 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 3070); - break; - case 3061: - Talk(Texts.Stage_2_03); - _updateTimer = 5 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 3071); - break; - //Summoning crusaders - case 3091: - { - Creature pChampionController = me.SummonCreature(CreatureIds.ChampionsController, MiscData.ToCCommonLoc[1]); - if (pChampionController) - pChampionController.GetAI().SetData(0, (uint)Team.Horde); - _updateTimer = 3 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 3092); - break; - } - //Summoning crusaders - case 3090: - { - Creature pChampionController = me.SummonCreature(CreatureIds.ChampionsController, MiscData.ToCCommonLoc[1]); - if (pChampionController) - pChampionController.GetAI().SetData(0, (uint)Team.Alliance); - _updateTimer = 3 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 3092); - break; - } - case 3092: - { - Creature pChampionController = ObjectAccessor.GetCreature(me, _instance.GetGuidData(CreatureIds.ChampionsController)); - if (pChampionController) - pChampionController.GetAI().SetData(1, (uint)EncounterState.NotStarted); - _instance.SetData(DataTypes.TypeEvent, 3095); - break; - } - //Crusaders battle end - case 3100: - Talk(Texts.Stage_2_06); - _updateTimer = 5 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 0); - break; - case 4000: - Talk(Texts.Stage_3_01); - _updateTimer = 13 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 4010); - break; - case 4010: - { - Talk(Texts.Stage_3_02); - Creature temp = me.SummonCreature(CreatureIds.Lightbane, MiscData.ToCSpawnLoc[1].GetPositionX(), MiscData.ToCSpawnLoc[1].GetPositionY(), MiscData.ToCSpawnLoc[1].GetPositionZ(), 5, TempSummonType.CorpseTimedDespawn, MiscData.DespawnTime); - if (temp) - { - temp.SetVisible(false); - temp.SetReactState(ReactStates.Passive); - temp.SummonCreature(CreatureIds.LightEssence, MiscData.TwinValkyrsLoc[0].GetPositionX(), MiscData.TwinValkyrsLoc[0].GetPositionY(), MiscData.TwinValkyrsLoc[0].GetPositionZ()); - temp.SummonCreature(CreatureIds.LightEssence, MiscData.TwinValkyrsLoc[1].GetPositionX(), MiscData.TwinValkyrsLoc[1].GetPositionY(), MiscData.TwinValkyrsLoc[1].GetPositionZ()); - } - - temp = me.SummonCreature(CreatureIds.Darkbane, MiscData.ToCSpawnLoc[2].GetPositionX(), MiscData.ToCSpawnLoc[2].GetPositionY(), MiscData.ToCSpawnLoc[2].GetPositionZ(), 5, TempSummonType.CorpseTimedDespawn, MiscData.DespawnTime); - if (temp) - { - temp.SetVisible(false); - temp.SetReactState(ReactStates.Passive); - temp.SummonCreature(CreatureIds.DarkEssence, MiscData.TwinValkyrsLoc[2].GetPositionX(), MiscData.TwinValkyrsLoc[2].GetPositionY(), MiscData.TwinValkyrsLoc[2].GetPositionZ()); - temp.SummonCreature(CreatureIds.DarkEssence, MiscData.TwinValkyrsLoc[3].GetPositionX(), MiscData.TwinValkyrsLoc[3].GetPositionY(), MiscData.TwinValkyrsLoc[3].GetPositionZ()); - } - _updateTimer = 3 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 4015); - break; - } - case 4015: + case 110: + me.SetUInt32Value(UnitFields.NpcEmotestate, (uint)Emote.OneshotTalk); + Talk(Texts.Stage_0_01); + _updateTimer = 22 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 120); + break; + case 140: + me.SetUInt32Value(UnitFields.NpcEmotestate, (uint)Emote.OneshotTalk); + Talk(Texts.Stage_0_02); + _updateTimer = 5 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 150); + break; + case 150: + { + me.SetUInt32Value(UnitFields.NpcEmotestate, (uint)Emote.OneshotNone); + if (_instance.GetBossState(DataTypes.BossBeasts) != EncounterState.Done) { _instance.DoUseDoorOrButton(_instance.GetGuidData(GameObjectIds.MainGateDoor)); - Creature temp = ObjectAccessor.GetCreature(me, _instance.GetGuidData(CreatureIds.Lightbane)); - if (temp) - { - temp.GetMotionMaster().MovePoint(1, MiscData.ToCCommonLoc[8].GetPositionX(), MiscData.ToCCommonLoc[8].GetPositionY(), MiscData.ToCCommonLoc[8].GetPositionZ()); - temp.SetVisible(true); - } - temp = ObjectAccessor.GetCreature(me, _instance.GetGuidData(CreatureIds.Darkbane)); + Creature temp = me.SummonCreature(CreatureIds.Gormok, MiscData.ToCSpawnLoc[0].GetPositionX(), MiscData.ToCSpawnLoc[0].GetPositionY(), MiscData.ToCSpawnLoc[0].GetPositionZ(), 5, TempSummonType.CorpseTimedDespawn, 30 * Time.InMilliseconds); if (temp) { - temp.GetMotionMaster().MovePoint(1, MiscData.ToCCommonLoc[9].GetPositionX(), MiscData.ToCCommonLoc[9].GetPositionY(), MiscData.ToCCommonLoc[9].GetPositionZ()); - temp.SetVisible(true); + temp.GetMotionMaster().MovePoint(0, MiscData.ToCCommonLoc[5].GetPositionX(), MiscData.ToCCommonLoc[5].GetPositionY(), MiscData.ToCCommonLoc[5].GetPositionZ()); + temp.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); + temp.SetReactState(ReactStates.Passive); } - _updateTimer = 10 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 4016); - break; } - case 4016: + _updateTimer = 3 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 155); + break; + } + case 155: + // keep the raid in combat for the whole encounter, pauses included + me.SetInCombatWithZone(); + _updateTimer = 5 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 160); + break; + case 200: + { + Talk(Texts.Stage_0_04); + if (_instance.GetBossState(DataTypes.BossBeasts) != EncounterState.Done) + { + _instance.DoUseDoorOrButton(_instance.GetGuidData(GameObjectIds.MainGateDoor)); + Creature temp = me.SummonCreature(CreatureIds.Dreadscale, MiscData.ToCSpawnLoc[1].GetPositionX(), MiscData.ToCSpawnLoc[1].GetPositionY(), MiscData.ToCSpawnLoc[1].GetPositionZ(), 5, TempSummonType.ManualDespawn); + if (temp) + { + temp.GetMotionMaster().MovePoint(0, MiscData.ToCCommonLoc[5].GetPositionX(), MiscData.ToCCommonLoc[5].GetPositionY(), MiscData.ToCCommonLoc[5].GetPositionZ()); + temp.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); + temp.SetReactState(ReactStates.Passive); + } + } + _updateTimer = 5 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 220); + break; + } + case 220: + _instance.SetData(DataTypes.TypeEvent, 230); + break; + case 300: + { + Talk(Texts.Stage_0_05); + if (_instance.GetBossState(DataTypes.BossBeasts) != EncounterState.Done) + { + _instance.DoUseDoorOrButton(_instance.GetGuidData(GameObjectIds.MainGateDoor)); + Creature temp = me.SummonCreature(CreatureIds.Icehowl, MiscData.ToCSpawnLoc[0].GetPositionX(), MiscData.ToCSpawnLoc[0].GetPositionY(), MiscData.ToCSpawnLoc[0].GetPositionZ(), 5, TempSummonType.DeadDespawn); + if (temp) + { + temp.GetMotionMaster().MovePoint(2, MiscData.ToCCommonLoc[5].GetPositionX(), MiscData.ToCCommonLoc[5].GetPositionY(), MiscData.ToCCommonLoc[5].GetPositionZ()); + me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); + me.SetReactState(ReactStates.Passive); + } + } + _updateTimer = 5 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 315); + break; + } + case 315: + _instance.SetData(DataTypes.TypeEvent, 320); + break; + case 400: + Talk(Texts.Stage_0_06); + me.GetThreatManager().clearReferences(); + _updateTimer = 5 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 0); + break; + case 666: + Talk(Texts.Stage_0_Wipe); + _updateTimer = 5 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 0); + break; + case 1010: + Talk(Texts.Stage_1_01); + _updateTimer = 7 * Time.InMilliseconds; + _instance.DoUseDoorOrButton(_instance.GetGuidData(GameObjectIds.MainGateDoor)); + me.SummonCreature(CreatureIds.Fizzlebang, MiscData.ToCSpawnLoc[0].GetPositionX(), MiscData.ToCSpawnLoc[0].GetPositionY(), MiscData.ToCSpawnLoc[0].GetPositionZ(), 2, TempSummonType.CorpseTimedDespawn, MiscData.DespawnTime); + _instance.SetData(DataTypes.TypeEvent, 0); + break; + case 1180: + Talk(Texts.Stage_1_07); + _updateTimer = 3 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 0); + break; + case 2000: + Talk(Texts.Stage_1_08); + _updateTimer = 18 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 2010); + break; + case 2030: + Talk(Texts.Stage_1_11); + _updateTimer = 5 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 0); + break; + case 3000: + Talk(Texts.Stage_2_01); + _updateTimer = 12 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 3050); + break; + case 3001: + Talk(Texts.Stage_2_01); + _updateTimer = 10 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 3051); + break; + case 3060: + Talk(Texts.Stage_2_03); + _updateTimer = 5 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 3070); + break; + case 3061: + Talk(Texts.Stage_2_03); + _updateTimer = 5 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 3071); + break; + //Summoning crusaders + case 3091: + { + Creature pChampionController = me.SummonCreature(CreatureIds.ChampionsController, MiscData.ToCCommonLoc[1]); + if (pChampionController) + pChampionController.GetAI().SetData(0, (uint)Team.Horde); + _updateTimer = 3 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 3092); + break; + } + //Summoning crusaders + case 3090: + { + Creature pChampionController = me.SummonCreature(CreatureIds.ChampionsController, MiscData.ToCCommonLoc[1]); + if (pChampionController) + pChampionController.GetAI().SetData(0, (uint)Team.Alliance); + _updateTimer = 3 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 3092); + break; + } + case 3092: + { + Creature pChampionController = ObjectAccessor.GetCreature(me, _instance.GetGuidData(CreatureIds.ChampionsController)); + if (pChampionController) + pChampionController.GetAI().SetData(1, (uint)EncounterState.NotStarted); + _instance.SetData(DataTypes.TypeEvent, 3095); + break; + } + //Crusaders battle end + case 3100: + Talk(Texts.Stage_2_06); + _updateTimer = 5 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 0); + break; + case 4000: + Talk(Texts.Stage_3_01); + _updateTimer = 13 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 4010); + break; + case 4010: + { + Talk(Texts.Stage_3_02); + Creature temp = me.SummonCreature(CreatureIds.Lightbane, MiscData.ToCSpawnLoc[1].GetPositionX(), MiscData.ToCSpawnLoc[1].GetPositionY(), MiscData.ToCSpawnLoc[1].GetPositionZ(), 5, TempSummonType.CorpseTimedDespawn, MiscData.DespawnTime); + if (temp) + { + temp.SetVisible(false); + temp.SetReactState(ReactStates.Passive); + temp.SummonCreature(CreatureIds.LightEssence, MiscData.TwinValkyrsLoc[0].GetPositionX(), MiscData.TwinValkyrsLoc[0].GetPositionY(), MiscData.TwinValkyrsLoc[0].GetPositionZ()); + temp.SummonCreature(CreatureIds.LightEssence, MiscData.TwinValkyrsLoc[1].GetPositionX(), MiscData.TwinValkyrsLoc[1].GetPositionY(), MiscData.TwinValkyrsLoc[1].GetPositionZ()); + } + + temp = me.SummonCreature(CreatureIds.Darkbane, MiscData.ToCSpawnLoc[2].GetPositionX(), MiscData.ToCSpawnLoc[2].GetPositionY(), MiscData.ToCSpawnLoc[2].GetPositionZ(), 5, TempSummonType.CorpseTimedDespawn, MiscData.DespawnTime); + if (temp) + { + temp.SetVisible(false); + temp.SetReactState(ReactStates.Passive); + temp.SummonCreature(CreatureIds.DarkEssence, MiscData.TwinValkyrsLoc[2].GetPositionX(), MiscData.TwinValkyrsLoc[2].GetPositionY(), MiscData.TwinValkyrsLoc[2].GetPositionZ()); + temp.SummonCreature(CreatureIds.DarkEssence, MiscData.TwinValkyrsLoc[3].GetPositionX(), MiscData.TwinValkyrsLoc[3].GetPositionY(), MiscData.TwinValkyrsLoc[3].GetPositionZ()); + } + _updateTimer = 3 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 4015); + break; + } + case 4015: + { _instance.DoUseDoorOrButton(_instance.GetGuidData(GameObjectIds.MainGateDoor)); - _instance.SetData(DataTypes.TypeEvent, 4017); - break; - case 4040: - _updateTimer = 1 * Time.Minute * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 5000); - break; - case 5000: - Talk(Texts.Stage_4_01); + Creature temp = ObjectAccessor.GetCreature(me, _instance.GetGuidData(CreatureIds.Lightbane)); + if (temp) + { + temp.GetMotionMaster().MovePoint(1, MiscData.ToCCommonLoc[8].GetPositionX(), MiscData.ToCCommonLoc[8].GetPositionY(), MiscData.ToCCommonLoc[8].GetPositionZ()); + temp.SetVisible(true); + } + + temp = ObjectAccessor.GetCreature(me, _instance.GetGuidData(CreatureIds.Darkbane)); + if (temp) + { + temp.GetMotionMaster().MovePoint(1, MiscData.ToCCommonLoc[9].GetPositionX(), MiscData.ToCCommonLoc[9].GetPositionY(), MiscData.ToCCommonLoc[9].GetPositionZ()); + temp.SetVisible(true); + } _updateTimer = 10 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 5005); + _instance.SetData(DataTypes.TypeEvent, 4016); break; - case 5005: - _updateTimer = 8 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 5010); - me.SummonCreature(CreatureIds.LichKing, MiscData.ToCCommonLoc[2].GetPositionX(), MiscData.ToCCommonLoc[2].GetPositionY(), MiscData.ToCCommonLoc[2].GetPositionZ(), 5); - break; - case 5020: - Talk(Texts.Stage_4_03); - _updateTimer = 1 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 0); - break; - case 6000: - me.SummonCreature(CreatureIds.TirionFordring, MiscData.EndSpawnLoc[0]); - me.SummonCreature(CreatureIds.ArgentMage, MiscData.EndSpawnLoc[1]); - me.SummonGameObject(GameObjectIds.PortalToDalaran, MiscData.EndSpawnLoc[2], Quaternion.WAxis, 0); + } + case 4016: + _instance.DoUseDoorOrButton(_instance.GetGuidData(GameObjectIds.MainGateDoor)); + _instance.SetData(DataTypes.TypeEvent, 4017); + break; + case 4040: + _updateTimer = 1 * Time.Minute * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 5000); + break; + case 5000: + Talk(Texts.Stage_4_01); + _updateTimer = 10 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 5005); + break; + case 5005: + _updateTimer = 8 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 5010); + me.SummonCreature(CreatureIds.LichKing, MiscData.ToCCommonLoc[2].GetPositionX(), MiscData.ToCCommonLoc[2].GetPositionY(), MiscData.ToCCommonLoc[2].GetPositionZ(), 5); + break; + case 5020: + Talk(Texts.Stage_4_03); + _updateTimer = 1 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 0); + break; + case 6000: + me.SummonCreature(CreatureIds.TirionFordring, MiscData.EndSpawnLoc[0]); + me.SummonCreature(CreatureIds.ArgentMage, MiscData.EndSpawnLoc[1]); + me.SummonGameObject(GameObjectIds.PortalToDalaran, MiscData.EndSpawnLoc[2], Quaternion.WAxis, 0); + _updateTimer = 20 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 6005); + break; + case 6005: + { + Creature tirionFordring = ObjectAccessor.GetCreature(me, _instance.GetGuidData(CreatureIds.TirionFordring)); + if (tirionFordring) + tirionFordring.GetAI().Talk(Texts.Stage_4_06); _updateTimer = 20 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 6005); + _instance.SetData(DataTypes.TypeEvent, 6010); break; - case 6005: - { - Creature tirionFordring = ObjectAccessor.GetCreature(me, _instance.GetGuidData(CreatureIds.TirionFordring)); - if (tirionFordring) - tirionFordring.GetAI().Talk(Texts.Stage_4_06); - _updateTimer = 20 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 6010); - break; - } - case 6010: - if (IsHeroic()) - { - Creature tirionFordring = ObjectAccessor.GetCreature(me, _instance.GetGuidData(CreatureIds.TirionFordring)); - if (tirionFordring) - tirionFordring.GetAI().Talk(Texts.Stage_4_07); - _updateTimer = 1 * Time.Minute * Time.InMilliseconds; - _instance.SetBossState(DataTypes.BossAnubarak, EncounterState.Special); - _instance.SetData(DataTypes.TypeEvent, 6020); - } - else - _instance.SetData(DataTypes.TypeEvent, 6030); - break; - case 6020: - me.DespawnOrUnsummon(); - _updateTimer = 5 * Time.InMilliseconds; + } + case 6010: + if (IsHeroic()) + { + Creature tirionFordring = ObjectAccessor.GetCreature(me, _instance.GetGuidData(CreatureIds.TirionFordring)); + if (tirionFordring) + tirionFordring.GetAI().Talk(Texts.Stage_4_07); + _updateTimer = 1 * Time.Minute * Time.InMilliseconds; + _instance.SetBossState(DataTypes.BossAnubarak, EncounterState.Special); + _instance.SetData(DataTypes.TypeEvent, 6020); + } + else _instance.SetData(DataTypes.TypeEvent, 6030); - break; - default: - break; - } + break; + case 6020: + me.DespawnOrUnsummon(); + _updateTimer = 5 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 6030); + break; + default: + break; } - else - _updateTimer -= uiDiff; - _instance.SetData(DataTypes.TypeEventTimer, _updateTimer); } - - InstanceScript _instance; - uint _updateTimer; + else + _updateTimer -= uiDiff; + _instance.SetData(DataTypes.TypeEventTimer, _updateTimer); } - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } + InstanceScript _instance; + uint _updateTimer; } [Script] - class npc_garrosh_toc : CreatureScript + class npc_garrosh_toc : ScriptedAI { - public npc_garrosh_toc() : base("npc_garrosh_toc") { } - - class npc_garrosh_tocAI : ScriptedAI + public npc_garrosh_toc(Creature creature) : base(creature) { - public npc_garrosh_tocAI(Creature creature) : base(creature) + _instance = me.GetInstanceScript(); + } + + public override void Reset() { } + + public override void AttackStart(Unit who) { } + + public override void UpdateAI(uint uiDiff) + { + if (_instance == null) + return; + + if (_instance.GetData(DataTypes.TypeEventNpc) != CreatureIds.Garrosh) + return; + + _updateTimer = _instance.GetData(DataTypes.TypeEventTimer); + if (_updateTimer <= uiDiff) { - _instance = me.GetInstanceScript(); - } - - public override void Reset() { } - - public override void AttackStart(Unit who) { } - - public override void UpdateAI(uint uiDiff) - { - if (_instance == null) - return; - - if (_instance.GetData(DataTypes.TypeEventNpc) != CreatureIds.Garrosh) - return; - - _updateTimer = _instance.GetData(DataTypes.TypeEventTimer); - if (_updateTimer <= uiDiff) + switch (_instance.GetData(DataTypes.TypeEvent)) { - switch (_instance.GetData(DataTypes.TypeEvent)) - { - case 130: - me.SetUInt32Value(UnitFields.NpcEmotestate, (uint)Emote.OneshotTalk); - Talk(Texts.Stage_0_03h); - _updateTimer = 3 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 132); - break; - case 132: - me.SetUInt32Value(UnitFields.NpcEmotestate, (uint)Emote.OneshotNone); - _updateTimer = 5 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 140); - break; - case 2010: - Talk(Texts.Stage_1_09); - _updateTimer = 9 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 2020); - break; - case 3050: - Talk(Texts.Stage_2_02h); - _updateTimer = 15 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 3060); - break; - case 3070: - Talk(Texts.Stage_2_04h); - _updateTimer = 6 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 3080); - break; - case 3081: - Talk(Texts.Stage_2_05h); - _updateTimer = 3 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 3091); - break; - case 4030: - Talk(Texts.Stage_3_03h); - _updateTimer = 5 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 4040); - break; - default: - break; - } + case 130: + me.SetUInt32Value(UnitFields.NpcEmotestate, (uint)Emote.OneshotTalk); + Talk(Texts.Stage_0_03h); + _updateTimer = 3 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 132); + break; + case 132: + me.SetUInt32Value(UnitFields.NpcEmotestate, (uint)Emote.OneshotNone); + _updateTimer = 5 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 140); + break; + case 2010: + Talk(Texts.Stage_1_09); + _updateTimer = 9 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 2020); + break; + case 3050: + Talk(Texts.Stage_2_02h); + _updateTimer = 15 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 3060); + break; + case 3070: + Talk(Texts.Stage_2_04h); + _updateTimer = 6 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 3080); + break; + case 3081: + Talk(Texts.Stage_2_05h); + _updateTimer = 3 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 3091); + break; + case 4030: + Talk(Texts.Stage_3_03h); + _updateTimer = 5 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 4040); + break; + default: + break; } - else - _updateTimer -= uiDiff; - _instance.SetData(DataTypes.TypeEventTimer, _updateTimer); } - - InstanceScript _instance; - uint _updateTimer; + else + _updateTimer -= uiDiff; + _instance.SetData(DataTypes.TypeEventTimer, _updateTimer); } - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } + InstanceScript _instance; + uint _updateTimer; } [Script] - class npc_varian_toc : CreatureScript + class npc_varian_toc : ScriptedAI { - public npc_varian_toc() : base("npc_varian_toc") { } - - class npc_varian_tocAI : ScriptedAI + public npc_varian_toc(Creature creature) : base(creature) { - public npc_varian_tocAI(Creature creature) : base(creature) + _instance = me.GetInstanceScript(); + } + + public override void Reset() { } + + public override void AttackStart(Unit who) { } + + public override void UpdateAI(uint uiDiff) + { + if (_instance == null) + return; + + if (_instance.GetData(DataTypes.TypeEventNpc) != CreatureIds.Varian) + return; + + _updateTimer = _instance.GetData(DataTypes.TypeEventTimer); + if (_updateTimer <= uiDiff) { - _instance = me.GetInstanceScript(); - } - - public override void Reset() { } - - public override void AttackStart(Unit who) { } - - public override void UpdateAI(uint uiDiff) - { - if (_instance == null) - return; - - if (_instance.GetData(DataTypes.TypeEventNpc) != CreatureIds.Varian) - return; - - _updateTimer = _instance.GetData(DataTypes.TypeEventTimer); - if (_updateTimer <= uiDiff) + switch (_instance.GetData(DataTypes.TypeEvent)) { - switch (_instance.GetData(DataTypes.TypeEvent)) - { - case 120: - me.SetUInt32Value(UnitFields.NpcEmotestate, (uint)Emote.OneshotTalk); - Talk(Texts.Stage_0_03a); - _updateTimer = 2 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 122); - break; - case 122: - me.SetUInt32Value(UnitFields.NpcEmotestate, (uint)Emote.OneshotNone); - _updateTimer = 3 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 130); - break; - case 2020: - Talk(Texts.Stage_1_10); - _updateTimer = 5 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 2030); - break; - case 3051: - Talk(Texts.Stage_2_02a); - _updateTimer = 17 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 3061); - break; - case 3071: - Talk(Texts.Stage_2_04a); - _updateTimer = 5 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 3081); - break; - case 3080: - Talk(Texts.Stage_2_05a); - _updateTimer = 3 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 3090); - break; - case 4020: - Talk(Texts.Stage_3_03a); - _updateTimer = 5 * Time.InMilliseconds; - _instance.SetData(DataTypes.TypeEvent, 4040); - break; - default: - break; - } + case 120: + me.SetUInt32Value(UnitFields.NpcEmotestate, (uint)Emote.OneshotTalk); + Talk(Texts.Stage_0_03a); + _updateTimer = 2 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 122); + break; + case 122: + me.SetUInt32Value(UnitFields.NpcEmotestate, (uint)Emote.OneshotNone); + _updateTimer = 3 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 130); + break; + case 2020: + Talk(Texts.Stage_1_10); + _updateTimer = 5 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 2030); + break; + case 3051: + Talk(Texts.Stage_2_02a); + _updateTimer = 17 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 3061); + break; + case 3071: + Talk(Texts.Stage_2_04a); + _updateTimer = 5 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 3081); + break; + case 3080: + Talk(Texts.Stage_2_05a); + _updateTimer = 3 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 3090); + break; + case 4020: + Talk(Texts.Stage_3_03a); + _updateTimer = 5 * Time.InMilliseconds; + _instance.SetData(DataTypes.TypeEvent, 4040); + break; + default: + break; } - else - _updateTimer -= uiDiff; - _instance.SetData(DataTypes.TypeEventTimer, _updateTimer); } - - InstanceScript _instance; - uint _updateTimer; + else + _updateTimer -= uiDiff; + _instance.SetData(DataTypes.TypeEventTimer, _updateTimer); } - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } + InstanceScript _instance; + uint _updateTimer; } } diff --git a/Scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/TrialOfTheCrusaderConst.cs b/Scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/TrialOfTheCrusaderConst.cs index dc672aa6c..0dc981600 100644 --- a/Scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/TrialOfTheCrusaderConst.cs +++ b/Scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/TrialOfTheCrusaderConst.cs @@ -270,7 +270,7 @@ namespace Scripts.Northrend.CrusadersColiseum.TrialOfTheCrusader public const uint DisplayIdDestroyedFloor = 9060; - public static BossBoundaryEntry[] boundaries = + public static BossBoundaryEntry[] boundaries = { new BossBoundaryEntry(DataTypes.BossBeasts, new CircleBoundary(new Position(563.26f, 139.6f), 75.0)), new BossBoundaryEntry(DataTypes.BossJaraxxus, new CircleBoundary(new Position(563.26f, 139.6f), 75.0)), diff --git a/Scripts/Northrend/Dalaran.cs b/Scripts/Northrend/Dalaran.cs index 9bf54accf..64bdd4b12 100644 --- a/Scripts/Northrend/Dalaran.cs +++ b/Scripts/Northrend/Dalaran.cs @@ -42,7 +42,7 @@ namespace Scripts.Northrend //Minigob public const int SpellManabonked = 61834; public const int SpellTeleportVisual = 51347; - public const int SpellImprovedBlink = 61995; + public const int SpellImprovedBlink = 61995; public const int EventSelectTarget = 1; public const int EventBlink = 2; @@ -50,174 +50,154 @@ namespace Scripts.Northrend public const int EventDespawn = 4; public const int MailMinigobEntry = 264; - public const int MailDeliverDelayMin = 5 * Time.Minute; + public const int MailDeliverDelayMin = 5 * Time.Minute; public const int MailDeliverDelayMax = 15 * Time.Minute; } [Script] - class npc_mageguard_dalaran : CreatureScript + class npc_mageguard_dalaran : ScriptedAI { - public npc_mageguard_dalaran() : base("npc_mageguard_dalaran") { } - - class npc_mageguard_dalaranAI : ScriptedAI + public npc_mageguard_dalaran(Creature creature) : base(creature) { - public npc_mageguard_dalaranAI(Creature creature) : base(creature) - { - creature.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable); - creature.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchools.Normal, true); - creature.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchoolMask.Magic, true); - } + creature.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable); + creature.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchools.Normal, true); + creature.ApplySpellImmune(0, SpellImmunity.Damage, SpellSchoolMask.Magic, true); + } - public override void Reset() { } + public override void Reset() { } - public override void EnterCombat(Unit who) { } + public override void EnterCombat(Unit who) { } - public override void AttackStart(Unit who) { } + public override void AttackStart(Unit who) { } - public override void MoveInLineOfSight(Unit who) - { - if (!who || !who.IsInWorld || who.GetZoneId() != 4395) - return; - - if (!me.IsWithinDist(who, 65.0f, false)) - return; - - Player player = who.GetCharmerOrOwnerPlayerOrPlayerItself(); - - if (!player || player.IsGameMaster() || player.IsBeingTeleported() || - // If player has Disguise aura for quest A Meeting With The Magister or An Audience With The Arcanist, do not teleport it away but let it pass - player.HasAura(DalaranConst.SpellSunreaverDisguiseFemale) || player.HasAura(DalaranConst.SpellSunreaverDisguiseMale) || - player.HasAura(DalaranConst.SpellSilverConenantDisguiseFemale) || player.HasAura(DalaranConst.SpellSilverConenantDisguiseMale)) - return; - - switch (me.GetEntry()) - { - case 29254: - if (player.GetTeam() == Team.Horde) // Horde unit found in Alliance area - { - if (GetClosestCreatureWithEntry(me, DalaranConst.NpcAplleboughA, 32.0f)) - { - if (me.isInBackInMap(who, 12.0f)) // In my line of sight, "outdoors", and behind me - DoCast(who, DalaranConst.SpellTrespasserA); // Teleport the Horde unit out - } - else // In my line of sight, and "indoors" - DoCast(who, DalaranConst.SpellTrespasserA); // Teleport the Horde unit out - } - break; - case 29255: - if (player.GetTeam() == Team.Alliance) // Alliance unit found in Horde area - { - if (GetClosestCreatureWithEntry(me, DalaranConst.NpcSweetberryH, 32.0f)) - { - if (me.isInBackInMap(who, 12.0f)) // In my line of sight, "outdoors", and behind me - DoCast(who, DalaranConst.SpellTrespasserH); // Teleport the Alliance unit out - } - else // In my line of sight, and "indoors" - DoCast(who, DalaranConst.SpellTrespasserH); // Teleport the Alliance unit out - } - break; - } - me.SetOrientation(me.GetHomePosition().GetOrientation()); + public override void MoveInLineOfSight(Unit who) + { + if (!who || !who.IsInWorld || who.GetZoneId() != 4395) return; + + if (!me.IsWithinDist(who, 65.0f, false)) + return; + + Player player = who.GetCharmerOrOwnerPlayerOrPlayerItself(); + + if (!player || player.IsGameMaster() || player.IsBeingTeleported() || + // If player has Disguise aura for quest A Meeting With The Magister or An Audience With The Arcanist, do not teleport it away but let it pass + player.HasAura(DalaranConst.SpellSunreaverDisguiseFemale) || player.HasAura(DalaranConst.SpellSunreaverDisguiseMale) || + player.HasAura(DalaranConst.SpellSilverConenantDisguiseFemale) || player.HasAura(DalaranConst.SpellSilverConenantDisguiseMale)) + return; + + switch (me.GetEntry()) + { + case 29254: + if (player.GetTeam() == Team.Horde) // Horde unit found in Alliance area + { + if (GetClosestCreatureWithEntry(me, DalaranConst.NpcAplleboughA, 32.0f)) + { + if (me.isInBackInMap(who, 12.0f)) // In my line of sight, "outdoors", and behind me + DoCast(who, DalaranConst.SpellTrespasserA); // Teleport the Horde unit out + } + else // In my line of sight, and "indoors" + DoCast(who, DalaranConst.SpellTrespasserA); // Teleport the Horde unit out + } + break; + case 29255: + if (player.GetTeam() == Team.Alliance) // Alliance unit found in Horde area + { + if (GetClosestCreatureWithEntry(me, DalaranConst.NpcSweetberryH, 32.0f)) + { + if (me.isInBackInMap(who, 12.0f)) // In my line of sight, "outdoors", and behind me + DoCast(who, DalaranConst.SpellTrespasserH); // Teleport the Alliance unit out + } + else // In my line of sight, and "indoors" + DoCast(who, DalaranConst.SpellTrespasserH); // Teleport the Alliance unit out + } + break; } - - public override void UpdateAI(uint diff) { } + me.SetOrientation(me.GetHomePosition().GetOrientation()); + return; } - public override CreatureAI GetAI(Creature creature) - { - return new npc_mageguard_dalaranAI(creature); - } + public override void UpdateAI(uint diff) { } } [Script] - class npc_minigob_manabonk : CreatureScript + class npc_minigob_manabonk : ScriptedAI { - public npc_minigob_manabonk() : base("npc_minigob_manabonk") { } - - class npc_minigob_manabonkAI : ScriptedAI + public npc_minigob_manabonk(Creature creature) : base(creature) { - public npc_minigob_manabonkAI(Creature creature) : base(creature) - { - me.setActive(true); - } - - public override void Reset() - { - me.SetVisible(false); - _events.ScheduleEvent(DalaranConst.EventSelectTarget, Time.InMilliseconds); - } - - Player SelectTargetInDalaran() - { - List PlayerInDalaranList = new List(); - - var players = me.GetMap().GetPlayers(); - foreach (var player in players) - { - if (player.GetZoneId() == me.GetZoneId() && !player.IsFlying() && !player.IsMounted() && !player.IsGameMaster()) - PlayerInDalaranList.Add(player); - } - - if (PlayerInDalaranList.Empty()) - return null; - - return PlayerInDalaranList.SelectRandom(); - } - - void SendMailToPlayer(Player player) - { - SQLTransaction trans = new SQLTransaction(); - uint deliverDelay = RandomHelper.URand(DalaranConst.MailDeliverDelayMin, DalaranConst.MailDeliverDelayMax); - new MailDraft(DalaranConst.MailMinigobEntry, true).SendMailTo(trans, new MailReceiver(player), new MailSender(MailMessageType.Creature, me.GetEntry()), MailCheckMask.None, deliverDelay); - DB.Characters.CommitTransaction(trans); - } - - public override void UpdateAI(uint diff) - { - _events.Update(diff); - - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case DalaranConst.EventSelectTarget: - me.SetVisible(true); - DoCast(me, DalaranConst.SpellTeleportVisual); - Player player = SelectTargetInDalaran(); - if (player) - { - me.NearTeleportTo(player.GetPositionX(), player.GetPositionY(), player.GetPositionZ(), 0.0f); - DoCast(player, DalaranConst.SpellManabonked); - SendMailToPlayer(player); - } - _events.ScheduleEvent(DalaranConst.EventBlink, 3 * Time.InMilliseconds); - break; - case DalaranConst.EventBlink: - { - DoCast(me, DalaranConst.SpellImprovedBlink); - Position pos = me.GetRandomNearPosition(RandomHelper.FRand(15, 40)); - me.GetMotionMaster().MovePoint(0, pos.posX, pos.posY, pos.posZ); - _events.ScheduleEvent(DalaranConst.EventDespawn, 3 * Time.InMilliseconds); - _events.ScheduleEvent(DalaranConst.EventDespawnVisual, (uint)(2.5 * Time.InMilliseconds)); - break; - } - case DalaranConst.EventDespawnVisual: - DoCast(me, DalaranConst.SpellTeleportVisual); - break; - case DalaranConst.EventDespawn: - me.DespawnOrUnsummon(); - break; - default: - break; - } - }); - } + me.setActive(true); } - public override CreatureAI GetAI(Creature creature) + public override void Reset() { - return new npc_minigob_manabonkAI(creature); + me.SetVisible(false); + _events.ScheduleEvent(DalaranConst.EventSelectTarget, Time.InMilliseconds); + } + + Player SelectTargetInDalaran() + { + List PlayerInDalaranList = new List(); + + var players = me.GetMap().GetPlayers(); + foreach (var player in players) + { + if (player.GetZoneId() == me.GetZoneId() && !player.IsFlying() && !player.IsMounted() && !player.IsGameMaster()) + PlayerInDalaranList.Add(player); + } + + if (PlayerInDalaranList.Empty()) + return null; + + return PlayerInDalaranList.SelectRandom(); + } + + void SendMailToPlayer(Player player) + { + SQLTransaction trans = new SQLTransaction(); + uint deliverDelay = RandomHelper.URand(DalaranConst.MailDeliverDelayMin, DalaranConst.MailDeliverDelayMax); + new MailDraft(DalaranConst.MailMinigobEntry, true).SendMailTo(trans, new MailReceiver(player), new MailSender(MailMessageType.Creature, me.GetEntry()), MailCheckMask.None, deliverDelay); + DB.Characters.CommitTransaction(trans); + } + + public override void UpdateAI(uint diff) + { + _events.Update(diff); + + _events.ExecuteEvents(eventId => + { + switch (eventId) + { + case DalaranConst.EventSelectTarget: + me.SetVisible(true); + DoCast(me, DalaranConst.SpellTeleportVisual); + Player player = SelectTargetInDalaran(); + if (player) + { + me.NearTeleportTo(player.GetPositionX(), player.GetPositionY(), player.GetPositionZ(), 0.0f); + DoCast(player, DalaranConst.SpellManabonked); + SendMailToPlayer(player); + } + _events.ScheduleEvent(DalaranConst.EventBlink, 3 * Time.InMilliseconds); + break; + case DalaranConst.EventBlink: + { + DoCast(me, DalaranConst.SpellImprovedBlink); + Position pos = me.GetRandomNearPosition(RandomHelper.FRand(15, 40)); + me.GetMotionMaster().MovePoint(0, pos.posX, pos.posY, pos.posZ); + _events.ScheduleEvent(DalaranConst.EventDespawn, 3 * Time.InMilliseconds); + _events.ScheduleEvent(DalaranConst.EventDespawnVisual, (uint)(2.5 * Time.InMilliseconds)); + break; + } + case DalaranConst.EventDespawnVisual: + DoCast(me, DalaranConst.SpellTeleportVisual); + break; + case DalaranConst.EventDespawn: + me.DespawnOrUnsummon(); + break; + default: + break; + } + }); } } } diff --git a/Scripts/Northrend/DraktharonKeep/BossKingDred.cs b/Scripts/Northrend/DraktharonKeep/BossKingDred.cs index ecf251c70..93b9dead7 100644 --- a/Scripts/Northrend/DraktharonKeep/BossKingDred.cs +++ b/Scripts/Northrend/DraktharonKeep/BossKingDred.cs @@ -43,221 +43,191 @@ namespace Scripts.Northrend.DraktharonKeep.KingDred } [Script] - class boss_king_dred : CreatureScript + class boss_king_dred : BossAI { - public boss_king_dred() : base("boss_king_dred") { } - - class boss_king_dredAI : BossAI + public boss_king_dred(Creature creature) : base(creature, DTKDataTypes.KingDred) { - public boss_king_dredAI(Creature creature) : base(creature, DTKDataTypes.KingDred) - { - Initialize(); - } - - void Initialize() - { - raptorsKilled = 0; - } - - public override void Reset() - { - Initialize(); - _Reset(); - } - - public override void EnterCombat(Unit who) - { - _EnterCombat(); - - _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); - - _scheduler.Schedule(TimeSpan.FromSeconds(33), task => - { - DoCastAOE(SpellIds.BellowingRoar); - task.Repeat(); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(20), task => - { - DoCastVictim(SpellIds.GrievousBite); - task.Repeat(); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(18.5), task => - { - DoCastVictim(SpellIds.ManglingSlash); - task.Repeat(); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(20), task => - { - DoCastAOE(SpellIds.FearsomeRoar); - task.Repeat(); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(17), task => - { - DoCastVictim(SpellIds.PiercingSlash); - task.Repeat(); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(20), TimeSpan.FromSeconds(25), task => - { - DoCastVictim(SpellIds.RaptorCall); - - float x, y, z; - me.GetClosePoint(out x, out y, out z, me.GetObjectSize() / 3, 10.0f); - me.SummonCreature(RandomHelper.RAND(DTKCreatureIds.DrakkariGutripper, DTKCreatureIds.DrakkariScytheclaw), x, y, z, 0, TempSummonType.DeadDespawn, 1000); - task.Repeat(); - }); - } - - public override void DoAction(int action) - { - if (action == Misc.ActionRaptorKilled) - ++raptorsKilled; - } - - public override uint GetData(uint type) - { - if (type == Misc.DataRaptorsKilled) - return raptorsKilled; - - return 0; - } - - public override void JustDied(Unit killer) - { - _JustDied(); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _scheduler.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - DoMeleeAttackIfReady(); - } - - byte raptorsKilled; + Initialize(); } - public override CreatureAI GetAI(Creature creature) + void Initialize() { - return GetInstanceAI(creature); + raptorsKilled = 0; } + + public override void Reset() + { + Initialize(); + _Reset(); + } + + public override void EnterCombat(Unit who) + { + _EnterCombat(); + + _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); + + _scheduler.Schedule(TimeSpan.FromSeconds(33), task => + { + DoCastAOE(SpellIds.BellowingRoar); + task.Repeat(); + }); + + _scheduler.Schedule(TimeSpan.FromSeconds(20), task => + { + DoCastVictim(SpellIds.GrievousBite); + task.Repeat(); + }); + + _scheduler.Schedule(TimeSpan.FromSeconds(18.5), task => + { + DoCastVictim(SpellIds.ManglingSlash); + task.Repeat(); + }); + + _scheduler.Schedule(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(20), task => + { + DoCastAOE(SpellIds.FearsomeRoar); + task.Repeat(); + }); + + _scheduler.Schedule(TimeSpan.FromSeconds(17), task => + { + DoCastVictim(SpellIds.PiercingSlash); + task.Repeat(); + }); + + _scheduler.Schedule(TimeSpan.FromSeconds(20), TimeSpan.FromSeconds(25), task => + { + DoCastVictim(SpellIds.RaptorCall); + + float x, y, z; + me.GetClosePoint(out x, out y, out z, me.GetObjectSize() / 3, 10.0f); + me.SummonCreature(RandomHelper.RAND(DTKCreatureIds.DrakkariGutripper, DTKCreatureIds.DrakkariScytheclaw), x, y, z, 0, TempSummonType.DeadDespawn, 1000); + task.Repeat(); + }); + } + + public override void DoAction(int action) + { + if (action == Misc.ActionRaptorKilled) + ++raptorsKilled; + } + + public override uint GetData(uint type) + { + if (type == Misc.DataRaptorsKilled) + return raptorsKilled; + + return 0; + } + + public override void JustDied(Unit killer) + { + _JustDied(); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _scheduler.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + DoMeleeAttackIfReady(); + } + + byte raptorsKilled; } [Script] - class npc_drakkari_gutripper : CreatureScript + class npc_drakkari_gutripper : ScriptedAI { - public npc_drakkari_gutripper() : base("npc_drakkari_gutripper") { } - - class npc_drakkari_gutripperAI : ScriptedAI + public npc_drakkari_gutripper(Creature creature) : base(creature) { - public npc_drakkari_gutripperAI(Creature creature) : base(creature) - { - Initialize(); - instance = me.GetInstanceScript(); - } - - void Initialize() - { - _scheduler.Schedule(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(15), task => - { - DoCastVictim(SpellIds.GutRip, false); - task.Repeat(); - }); - } - - public override void Reset() - { - Initialize(); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _scheduler.Update(diff); - - DoMeleeAttackIfReady(); - } - - public override void JustDied(Unit killer) - { - Creature dred = ObjectAccessor.GetCreature(me, instance.GetGuidData(DTKDataTypes.KingDred)); - if (dred) - dred.GetAI().DoAction(Misc.ActionRaptorKilled); - } - - InstanceScript instance; + Initialize(); + instance = me.GetInstanceScript(); } - public override CreatureAI GetAI(Creature creature) + void Initialize() { - return GetInstanceAI(creature); + _scheduler.Schedule(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(15), task => + { + DoCastVictim(SpellIds.GutRip, false); + task.Repeat(); + }); } + + public override void Reset() + { + Initialize(); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _scheduler.Update(diff); + + DoMeleeAttackIfReady(); + } + + public override void JustDied(Unit killer) + { + Creature dred = ObjectAccessor.GetCreature(me, instance.GetGuidData(DTKDataTypes.KingDred)); + if (dred) + dred.GetAI().DoAction(Misc.ActionRaptorKilled); + } + + InstanceScript instance; } [Script] - class npc_drakkari_scytheclaw : CreatureScript + class npc_drakkari_scytheclaw : ScriptedAI { - public npc_drakkari_scytheclaw() : base("npc_drakkari_scytheclaw") { } - - class npc_drakkari_scytheclawAI : ScriptedAI + public npc_drakkari_scytheclaw(Creature creature) : base(creature) { - public npc_drakkari_scytheclawAI(Creature creature) : base(creature) - { - Initialize(); - instance = me.GetInstanceScript(); - } - - void Initialize() - { - _scheduler.Schedule(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(15), task => - { - DoCastVictim(SpellIds.Rend, false); - task.Repeat(); - }); - } - - public override void Reset() - { - _scheduler.CancelAll(); - Initialize(); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _scheduler.Update(diff); - - DoMeleeAttackIfReady(); - } - - public override void JustDied(Unit killer) - { - Creature dred = ObjectAccessor.GetCreature(me, instance.GetGuidData(DTKDataTypes.KingDred)); - if (dred) - dred.GetAI().DoAction(Misc.ActionRaptorKilled); - } - - InstanceScript instance; + Initialize(); + instance = me.GetInstanceScript(); } - public override CreatureAI GetAI(Creature creature) + void Initialize() { - return GetInstanceAI(creature); + _scheduler.Schedule(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(15), task => + { + DoCastVictim(SpellIds.Rend, false); + task.Repeat(); + }); } + + public override void Reset() + { + _scheduler.CancelAll(); + Initialize(); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _scheduler.Update(diff); + + DoMeleeAttackIfReady(); + } + + public override void JustDied(Unit killer) + { + Creature dred = ObjectAccessor.GetCreature(me, instance.GetGuidData(DTKDataTypes.KingDred)); + if (dred) + dred.GetAI().DoAction(Misc.ActionRaptorKilled); + } + + InstanceScript instance; } [Script] diff --git a/Scripts/Northrend/DraktharonKeep/BossNovos.cs b/Scripts/Northrend/DraktharonKeep/BossNovos.cs index b7ced944a..9e6056202 100644 --- a/Scripts/Northrend/DraktharonKeep/BossNovos.cs +++ b/Scripts/Northrend/DraktharonKeep/BossNovos.cs @@ -98,303 +98,283 @@ namespace Scripts.Northrend.DraktharonKeep.Novos } [Script] - class boss_novos : CreatureScript + class boss_novos : BossAI { - public boss_novos() : base("boss_novos") { } - - class boss_novosAI : BossAI + public boss_novos(Creature creature) : base(creature, DTKDataTypes.Novos) { - public boss_novosAI(Creature creature) : base(creature, DTKDataTypes.Novos) + Initialize(); + _bubbled = false; + } + + void Initialize() + { + _ohNovos = true; + } + + public override void Reset() + { + _Reset(); + + Initialize(); + SetCrystalsStatus(false); + SetSummonerStatus(false); + SetBubbled(false); + } + + public override void EnterCombat(Unit victim) + { + _EnterCombat(); + Talk(TextIds.SayAggro); + + SetCrystalsStatus(true); + SetSummonerStatus(true); + SetBubbled(true); + } + + public override void AttackStart(Unit target) + { + if (!target) + return; + + if (me.Attack(target, true)) + DoStartNoMovement(target); + } + + public override void KilledUnit(Unit who) + { + if (who.IsTypeId(TypeId.Player)) + Talk(TextIds.SayKill); + } + + public override void JustDied(Unit killer) + { + _JustDied(); + Talk(TextIds.SayDeath); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim() || _bubbled) + return; + + _events.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + _events.ExecuteEvents(eventId => { - Initialize(); - _bubbled = false; - } - - void Initialize() - { - _ohNovos = true; - } - - public override void Reset() - { - _Reset(); - - Initialize(); - SetCrystalsStatus(false); - SetSummonerStatus(false); - SetBubbled(false); - } - - public override void EnterCombat(Unit victim) - { - _EnterCombat(); - Talk(TextIds.SayAggro); - - SetCrystalsStatus(true); - SetSummonerStatus(true); - SetBubbled(true); - } - - public override void AttackStart(Unit target) - { - if (!target) - return; - - if (me.Attack(target, true)) - DoStartNoMovement(target); - } - - public override void KilledUnit(Unit who) - { - if (who.IsTypeId(TypeId.Player)) - Talk(TextIds.SayKill); - } - - public override void JustDied(Unit killer) - { - _JustDied(); - Talk(TextIds.SayDeath); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim() || _bubbled) - return; - - _events.Update(diff); + switch (eventId) + { + case Misc.EventSummonMinions: + DoCast(SpellIds.SummonMinions); + _events.ScheduleEvent(Misc.EventSummonMinions, 15000); + break; + case Misc.EventAttack: + Unit victim = SelectTarget(SelectAggroTarget.Random); + if (victim) + DoCast(victim, RandomHelper.RAND(SpellIds.ArcaneBlast, SpellIds.Blizzard, SpellIds.Frostbolt, SpellIds.WrathOfMisery)); + _events.ScheduleEvent(Misc.EventAttack, 3000); + break; + default: + break; + } if (me.HasUnitState(UnitState.Casting)) return; - - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case Misc.EventSummonMinions: - DoCast(SpellIds.SummonMinions); - _events.ScheduleEvent(Misc.EventSummonMinions, 15000); - break; - case Misc.EventAttack: - Unit victim = SelectTarget(SelectAggroTarget.Random); - if (victim) - DoCast(victim, RandomHelper.RAND(SpellIds.ArcaneBlast, SpellIds.Blizzard, SpellIds.Frostbolt, SpellIds.WrathOfMisery)); - _events.ScheduleEvent(Misc.EventAttack, 3000); - break; - default: - break; - } - - if (me.HasUnitState(UnitState.Casting)) - return; - }); - } - - public override void DoAction(int action) - { - if (action == DTKDataTypes.ActionCrystalHandlerDied) - { - Talk(TextIds.SayArcaneField); - SetSummonerStatus(false); - SetBubbled(false); - _events.ScheduleEvent(Misc.EventAttack, 3000); - if (IsHeroic()) - _events.ScheduleEvent(Misc.EventSummonMinions, 15000); - } - } - - public override void MoveInLineOfSight(Unit who) - { - base.MoveInLineOfSight(who); - - if (!_ohNovos || !who || !who.IsTypeId(TypeId.Player) || who.GetPositionY() > Misc.MaxYCoordOhNovosMAX) - return; - - uint entry = who.GetEntry(); - if (entry == DTKCreatureIds.HulkingCorpse || entry == DTKCreatureIds.RisenShadowcaster || entry == DTKCreatureIds.FetidTrollCorpse) - _ohNovos = false; - } - - public override uint GetData(uint type) - { - return type == Misc.DataNovosAchiev && _ohNovos ? 1 : 0u; - } - - public override void JustSummoned(Creature summon) - { - me.Yell(TextIds.SaySummoningAdds, summon); - me.TextEmote(TextIds.EmoteSummoningAdds, summon); - - summon.SelectNearestTargetInAttackDistance(50f); - summons.Summon(summon); - } - - void SetBubbled(bool state) - { - _bubbled = state; - if (!state) - { - if (me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable)) - me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); - if (me.HasUnitState(UnitState.Casting)) - me.CastStop(); - } - else - { - if (!me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable)) - me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable); - DoCast(SpellIds.ArcaneField); - } - } - - void SetSummonerStatus(bool active) - { - for (byte i = 0; i < 4; i++) - { - ObjectGuid guid = instance.GetGuidData(DTKDataTypes.NovosSummoner1 + i); - if (!guid.IsEmpty()) - { - Creature crystalChannelTarget = ObjectAccessor.GetCreature(me, guid); - if (crystalChannelTarget) - { - if (active) - crystalChannelTarget.GetAI().SetData(Misc.summoners[i].eventId, Misc.summoners[i].timer); - else - crystalChannelTarget.GetAI().Reset(); - } - } - } - } - - void SetCrystalsStatus(bool active) - { - for (byte i = 0; i < 4; i++) - { - ObjectGuid guid = instance.GetGuidData(DTKDataTypes.NovosCrystal1 + i); - if (!guid.IsEmpty()) - { - GameObject crystal = ObjectAccessor.GetGameObject(me, guid); - if (crystal) - SetCrystalStatus(crystal, active); - } - } - } - - void SetCrystalStatus(GameObject crystal, bool active) - { - crystal.SetGoState(active ? GameObjectState.Active : GameObjectState.Ready); - - Creature crystalChannelTarget = crystal.FindNearestCreature(DTKCreatureIds.CrystalChannelTarget, 5.0f); - if (crystalChannelTarget) - { - if (active) - crystalChannelTarget.CastSpell(null, SpellIds.BeamChannel); - else if (crystalChannelTarget.HasUnitState(UnitState.Casting)) - crystalChannelTarget.CastStop(); - } - } - - bool _ohNovos; - bool _bubbled; + }); } - public override CreatureAI GetAI(Creature creature) + public override void DoAction(int action) { - return GetInstanceAI(creature); + if (action == DTKDataTypes.ActionCrystalHandlerDied) + { + Talk(TextIds.SayArcaneField); + SetSummonerStatus(false); + SetBubbled(false); + _events.ScheduleEvent(Misc.EventAttack, 3000); + if (IsHeroic()) + _events.ScheduleEvent(Misc.EventSummonMinions, 15000); + } } + + public override void MoveInLineOfSight(Unit who) + { + base.MoveInLineOfSight(who); + + if (!_ohNovos || !who || !who.IsTypeId(TypeId.Player) || who.GetPositionY() > Misc.MaxYCoordOhNovosMAX) + return; + + uint entry = who.GetEntry(); + if (entry == DTKCreatureIds.HulkingCorpse || entry == DTKCreatureIds.RisenShadowcaster || entry == DTKCreatureIds.FetidTrollCorpse) + _ohNovos = false; + } + + public override uint GetData(uint type) + { + return type == Misc.DataNovosAchiev && _ohNovos ? 1 : 0u; + } + + public override void JustSummoned(Creature summon) + { + me.Yell(TextIds.SaySummoningAdds, summon); + me.TextEmote(TextIds.EmoteSummoningAdds, summon); + + summon.SelectNearestTargetInAttackDistance(50f); + summons.Summon(summon); + } + + void SetBubbled(bool state) + { + _bubbled = state; + if (!state) + { + if (me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable)) + me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); + if (me.HasUnitState(UnitState.Casting)) + me.CastStop(); + } + else + { + if (!me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable)) + me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable); + DoCast(SpellIds.ArcaneField); + } + } + + void SetSummonerStatus(bool active) + { + for (byte i = 0; i < 4; i++) + { + ObjectGuid guid = instance.GetGuidData(DTKDataTypes.NovosSummoner1 + i); + if (!guid.IsEmpty()) + { + Creature crystalChannelTarget = ObjectAccessor.GetCreature(me, guid); + if (crystalChannelTarget) + { + if (active) + crystalChannelTarget.GetAI().SetData(Misc.summoners[i].eventId, Misc.summoners[i].timer); + else + crystalChannelTarget.GetAI().Reset(); + } + } + } + } + + void SetCrystalsStatus(bool active) + { + for (byte i = 0; i < 4; i++) + { + ObjectGuid guid = instance.GetGuidData(DTKDataTypes.NovosCrystal1 + i); + if (!guid.IsEmpty()) + { + GameObject crystal = ObjectAccessor.GetGameObject(me, guid); + if (crystal) + SetCrystalStatus(crystal, active); + } + } + } + + void SetCrystalStatus(GameObject crystal, bool active) + { + crystal.SetGoState(active ? GameObjectState.Active : GameObjectState.Ready); + + Creature crystalChannelTarget = crystal.FindNearestCreature(DTKCreatureIds.CrystalChannelTarget, 5.0f); + if (crystalChannelTarget) + { + if (active) + crystalChannelTarget.CastSpell(null, SpellIds.BeamChannel); + else if (crystalChannelTarget.HasUnitState(UnitState.Casting)) + crystalChannelTarget.CastStop(); + } + } + + bool _ohNovos; + bool _bubbled; } [Script] - class npc_crystal_channel_target : CreatureScript + class npc_crystal_channel_target : ScriptedAI { - public npc_crystal_channel_target() : base("npc_crystal_channel_target") { } + public npc_crystal_channel_target(Creature creature) : base(creature) { } - class npc_crystal_channel_targetAI : ScriptedAI + public override void Reset() { - public npc_crystal_channel_targetAI(Creature creature) : base(creature) { } + _events.Reset(); + _crystalHandlerCount = 0; + } - public override void Reset() + public override void UpdateAI(uint diff) + { + _events.Update(diff); + + _events.ExecuteEvents(eventId => { - _events.Reset(); - _crystalHandlerCount = 0; - } - - public override void UpdateAI(uint diff) - { - _events.Update(diff); - - _events.ExecuteEvents(eventId => + switch (eventId) { - switch (eventId) - { - case Misc.EventSummonCrystalHandler: - me.SummonCreature(DTKCreatureIds.CrystalHandler, Misc.SummonPositions[_crystalHandlerCount++]); - if (_crystalHandlerCount < 4) - _events.Repeat(TimeSpan.FromSeconds(15)); - break; - case Misc.EventSummonRisenShadowcaster: - DoCast(SpellIds.SummonRisenShadowcaster); - _events.Repeat(TimeSpan.FromSeconds(7)); - break; - case Misc.EventSummonFetidTrollCorpse: - DoCast(SpellIds.SummonFetidTrollCorpse); - _events.Repeat(TimeSpan.FromSeconds(3)); - break; - case Misc.EventSummonHulkingCorpse: - DoCast(SpellIds.SummonHulkingCorpse); - _events.Repeat(TimeSpan.FromSeconds(30)); - break; - } - }); - } + case Misc.EventSummonCrystalHandler: + me.SummonCreature(DTKCreatureIds.CrystalHandler, Misc.SummonPositions[_crystalHandlerCount++]); + if (_crystalHandlerCount < 4) + _events.Repeat(TimeSpan.FromSeconds(15)); + break; + case Misc.EventSummonRisenShadowcaster: + DoCast(SpellIds.SummonRisenShadowcaster); + _events.Repeat(TimeSpan.FromSeconds(7)); + break; + case Misc.EventSummonFetidTrollCorpse: + DoCast(SpellIds.SummonFetidTrollCorpse); + _events.Repeat(TimeSpan.FromSeconds(3)); + break; + case Misc.EventSummonHulkingCorpse: + DoCast(SpellIds.SummonHulkingCorpse); + _events.Repeat(TimeSpan.FromSeconds(30)); + break; + } + }); + } - public override void SetData(uint id, uint value) + public override void SetData(uint id, uint value) + { + _events.ScheduleEvent(id, TimeSpan.FromSeconds(value)); + } + + public override void SummonedCreatureDies(Creature summon, Unit killer) + { + if (_crystalHandlerCount < 4) + return; + + InstanceScript instance = me.GetInstanceScript(); + if (instance != null) { - _events.ScheduleEvent(id, TimeSpan.FromSeconds(value)); - } - - public override void SummonedCreatureDies(Creature summon, Unit killer) - { - if (_crystalHandlerCount < 4) - return; - - InstanceScript instance = me.GetInstanceScript(); - if (instance != null) + ObjectGuid guid = instance.GetGuidData(DTKDataTypes.Novos); + if (!guid.IsEmpty()) { - ObjectGuid guid = instance.GetGuidData(DTKDataTypes.Novos); - if (!guid.IsEmpty()) - { - Creature novos = ObjectAccessor.GetCreature(me, guid); - if (novos) - novos.GetAI().DoAction(DTKDataTypes.ActionCrystalHandlerDied); - } + Creature novos = ObjectAccessor.GetCreature(me, guid); + if (novos) + novos.GetAI().DoAction(DTKDataTypes.ActionCrystalHandlerDied); + } + } + } + + public override void JustSummoned(Creature summon) + { + InstanceScript instance = me.GetInstanceScript(); + if (instance != null) + { + ObjectGuid guid = instance.GetGuidData(DTKDataTypes.Novos); + if (!guid.IsEmpty()) + { + Creature novos = ObjectAccessor.GetCreature(me, guid); + if (novos) + novos.GetAI().JustSummoned(summon); } } - public override void JustSummoned(Creature summon) - { - InstanceScript instance = me.GetInstanceScript(); - if (instance != null) - { - ObjectGuid guid = instance.GetGuidData(DTKDataTypes.Novos); - if (!guid.IsEmpty()) - { - Creature novos = ObjectAccessor.GetCreature(me, guid); - if (novos) - novos.GetAI().JustSummoned(summon); - } - } - - if (summon) - summon.GetMotionMaster().MovePath(summon.GetEntry() * 100, false); - } - - uint _crystalHandlerCount; + if (summon) + summon.GetMotionMaster().MovePath(summon.GetEntry() * 100, false); } - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } + uint _crystalHandlerCount; } [Script] @@ -409,32 +389,22 @@ namespace Scripts.Northrend.DraktharonKeep.Novos } [Script] - class spell_novos_summon_minions : SpellScriptLoader + class spell_novos_summon_minions : SpellScript { - public spell_novos_summon_minions() : base("spell_novos_summon_minions") { } - - class spell_novos_summon_minions_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.SummonCopyOfMinions); - } - - void HandleScript(uint effIndex) - { - for (byte i = 0; i < 2; ++i) - GetCaster().CastSpell((Unit)null, SpellIds.SummonCopyOfMinions, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } + return ValidateSpellInfo(SpellIds.SummonCopyOfMinions); } - public override SpellScript GetSpellScript() + void HandleScript(uint effIndex) { - return new spell_novos_summon_minions_SpellScript(); + for (byte i = 0; i < 2; ++i) + GetCaster().CastSpell((Unit)null, SpellIds.SummonCopyOfMinions, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } } diff --git a/Scripts/Northrend/DraktharonKeep/BossTharonJa.cs b/Scripts/Northrend/DraktharonKeep/BossTharonJa.cs index 3d10ed85e..b9cbd9d91 100644 --- a/Scripts/Northrend/DraktharonKeep/BossTharonJa.cs +++ b/Scripts/Northrend/DraktharonKeep/BossTharonJa.cs @@ -74,178 +74,158 @@ namespace Scripts.Northrend.DraktharonKeep.TharonJa } [Script] - class boss_tharon_ja : CreatureScript + class boss_tharon_ja : BossAI { - public boss_tharon_ja() : base("boss_tharon_ja") { } + public boss_tharon_ja(Creature creature) : base(creature, DTKDataTypes.TharonJa) { } - class boss_tharon_jaAI : BossAI + public override void Reset() { - public boss_tharon_jaAI(Creature creature) : base(creature, DTKDataTypes.TharonJa) { } + _Reset(); + me.RestoreDisplayId(); + } - public override void Reset() + public override void EnterCombat(Unit who) + { + Talk(TextIds.SayAggro); + _EnterCombat(); + + _events.ScheduleEvent(EventIds.DecayFlesh, TimeSpan.FromSeconds(20)); + _events.ScheduleEvent(EventIds.CurseOfLife, TimeSpan.FromSeconds(1)); + _events.ScheduleEvent(EventIds.RainOfFire, TimeSpan.FromSeconds(14), TimeSpan.FromSeconds(18)); + _events.ScheduleEvent(EventIds.ShadowVolley, TimeSpan.FromSeconds(8), TimeSpan.FromSeconds(10)); + } + + public override void KilledUnit(Unit who) + { + if (who.IsTypeId(TypeId.Player)) + Talk(TextIds.SayKill); + } + + public override void JustDied(Unit killer) + { + _JustDied(); + + Talk(TextIds.SayDeath); + DoCastAOE(SpellIds.ClearGiftOfTharonJa, true); + DoCastAOE(SpellIds.AchievementCheck, true); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _events.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + _events.ExecuteEvents(eventId => { - _Reset(); - me.RestoreDisplayId(); - } + switch (eventId) + { + case EventIds.CurseOfLife: + { + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100.0f, true); + if (target) + DoCast(target, SpellIds.CurseOfLife); + _events.ScheduleEvent(EventIds.CurseOfLife, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(15)); + } + return; + case EventIds.ShadowVolley: + DoCastVictim(SpellIds.ShadowVolley); + _events.ScheduleEvent(EventIds.ShadowVolley, TimeSpan.FromSeconds(8), TimeSpan.FromSeconds(10)); + return; + case EventIds.RainOfFire: + { + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100.0f, true); + if (target) + DoCast(target, SpellIds.RainOfFire); + _events.ScheduleEvent(EventIds.RainOfFire, TimeSpan.FromSeconds(14), TimeSpan.FromSeconds(18)); + } + return; + case EventIds.LightningBreath: + { + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100.0f, true); + if (target) + DoCast(target, SpellIds.LightningBreath); + _events.ScheduleEvent(EventIds.LightningBreath, TimeSpan.FromSeconds(6), TimeSpan.FromSeconds(7)); + } + return; + case EventIds.EyeBeam: + { + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100.0f, true); + if (target) + DoCast(target, SpellIds.EyeBeam); + _events.ScheduleEvent(EventIds.EyeBeam, TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(6)); + } + return; + case EventIds.PoisonCloud: + DoCastAOE(SpellIds.PoisonCloud); + _events.ScheduleEvent(EventIds.PoisonCloud, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12)); + return; + case EventIds.DecayFlesh: + DoCastAOE(SpellIds.DecayFlesh); + _events.ScheduleEvent(EventIds.GoingFlesh, TimeSpan.FromSeconds(6)); + return; + case EventIds.GoingFlesh: + Talk(TextIds.SayFlesh); + me.SetDisplayId(Misc.ModelFlesh); + DoCastAOE(SpellIds.GiftOfTharonJa, true); + DoCast(me, SpellIds.FleshVisual, true); + DoCast(me, SpellIds.Dummy, true); - public override void EnterCombat(Unit who) - { - Talk(TextIds.SayAggro); - _EnterCombat(); + _events.Reset(); + _events.ScheduleEvent(EventIds.ReturnFlesh, TimeSpan.FromSeconds(20)); + _events.ScheduleEvent(EventIds.LightningBreath, TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(4)); + _events.ScheduleEvent(EventIds.EyeBeam, TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(8)); + _events.ScheduleEvent(EventIds.PoisonCloud, TimeSpan.FromSeconds(6), TimeSpan.FromSeconds(7)); + break; + case EventIds.ReturnFlesh: + DoCastAOE(SpellIds.ReturnFlesh); + _events.ScheduleEvent(EventIds.GoingSkeletal, 6000); + return; + case EventIds.GoingSkeletal: + Talk(TextIds.SaySkeleton); + me.RestoreDisplayId(); + DoCastAOE(SpellIds.ClearGiftOfTharonJa, true); - _events.ScheduleEvent(EventIds.DecayFlesh, TimeSpan.FromSeconds(20)); - _events.ScheduleEvent(EventIds.CurseOfLife, TimeSpan.FromSeconds(1)); - _events.ScheduleEvent(EventIds.RainOfFire, TimeSpan.FromSeconds(14), TimeSpan.FromSeconds(18)); - _events.ScheduleEvent(EventIds.ShadowVolley, TimeSpan.FromSeconds(8), TimeSpan.FromSeconds(10)); - } - - public override void KilledUnit(Unit who) - { - if (who.IsTypeId(TypeId.Player)) - Talk(TextIds.SayKill); - } - - public override void JustDied(Unit killer) - { - _JustDied(); - - Talk(TextIds.SayDeath); - DoCastAOE(SpellIds.ClearGiftOfTharonJa, true); - DoCastAOE(SpellIds.AchievementCheck, true); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _events.Update(diff); + _events.Reset(); + _events.ScheduleEvent(EventIds.DecayFlesh, TimeSpan.FromSeconds(20)); + _events.ScheduleEvent(EventIds.CurseOfLife, TimeSpan.FromSeconds(1)); + _events.ScheduleEvent(EventIds.RainOfFire, TimeSpan.FromSeconds(14), TimeSpan.FromSeconds(18)); + _events.ScheduleEvent(EventIds.ShadowVolley, TimeSpan.FromSeconds(8), TimeSpan.FromSeconds(10)); + break; + default: + break; + } if (me.HasUnitState(UnitState.Casting)) return; + }); - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case EventIds.CurseOfLife: - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100.0f, true); - if (target) - DoCast(target, SpellIds.CurseOfLife); - _events.ScheduleEvent(EventIds.CurseOfLife, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(15)); - } - return; - case EventIds.ShadowVolley: - DoCastVictim(SpellIds.ShadowVolley); - _events.ScheduleEvent(EventIds.ShadowVolley, TimeSpan.FromSeconds(8), TimeSpan.FromSeconds(10)); - return; - case EventIds.RainOfFire: - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100.0f, true); - if (target) - DoCast(target, SpellIds.RainOfFire); - _events.ScheduleEvent(EventIds.RainOfFire, TimeSpan.FromSeconds(14), TimeSpan.FromSeconds(18)); - } - return; - case EventIds.LightningBreath: - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100.0f, true); - if (target) - DoCast(target, SpellIds.LightningBreath); - _events.ScheduleEvent(EventIds.LightningBreath, TimeSpan.FromSeconds(6), TimeSpan.FromSeconds(7)); - } - return; - case EventIds.EyeBeam: - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100.0f, true); - if (target) - DoCast(target, SpellIds.EyeBeam); - _events.ScheduleEvent(EventIds.EyeBeam, TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(6)); - } - return; - case EventIds.PoisonCloud: - DoCastAOE(SpellIds.PoisonCloud); - _events.ScheduleEvent(EventIds.PoisonCloud, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12)); - return; - case EventIds.DecayFlesh: - DoCastAOE(SpellIds.DecayFlesh); - _events.ScheduleEvent(EventIds.GoingFlesh, TimeSpan.FromSeconds(6)); - return; - case EventIds.GoingFlesh: - Talk(TextIds.SayFlesh); - me.SetDisplayId(Misc.ModelFlesh); - DoCastAOE(SpellIds.GiftOfTharonJa, true); - DoCast(me, SpellIds.FleshVisual, true); - DoCast(me, SpellIds.Dummy, true); - - _events.Reset(); - _events.ScheduleEvent(EventIds.ReturnFlesh, TimeSpan.FromSeconds(20)); - _events.ScheduleEvent(EventIds.LightningBreath, TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(4)); - _events.ScheduleEvent(EventIds.EyeBeam, TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(8)); - _events.ScheduleEvent(EventIds.PoisonCloud, TimeSpan.FromSeconds(6), TimeSpan.FromSeconds(7)); - break; - case EventIds.ReturnFlesh: - DoCastAOE(SpellIds.ReturnFlesh); - _events.ScheduleEvent(EventIds.GoingSkeletal, 6000); - return; - case EventIds.GoingSkeletal: - Talk(TextIds.SaySkeleton); - me.RestoreDisplayId(); - DoCastAOE(SpellIds.ClearGiftOfTharonJa, true); - - _events.Reset(); - _events.ScheduleEvent(EventIds.DecayFlesh, TimeSpan.FromSeconds(20)); - _events.ScheduleEvent(EventIds.CurseOfLife, TimeSpan.FromSeconds(1)); - _events.ScheduleEvent(EventIds.RainOfFire, TimeSpan.FromSeconds(14), TimeSpan.FromSeconds(18)); - _events.ScheduleEvent(EventIds.ShadowVolley, TimeSpan.FromSeconds(8), TimeSpan.FromSeconds(10)); - break; - default: - break; - } - - if (me.HasUnitState(UnitState.Casting)) - return; - }); - - DoMeleeAttackIfReady(); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); + DoMeleeAttackIfReady(); } } [Script] - class spell_tharon_ja_clear_gift_of_tharon_ja : SpellScriptLoader + class spell_tharon_ja_clear_gift_of_tharon_ja : SpellScript { - public spell_tharon_ja_clear_gift_of_tharon_ja() : base("spell_tharon_ja_clear_gift_of_tharon_ja") { } - - class spell_tharon_ja_clear_gift_of_tharon_ja_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.GiftOfTharonJa); - } - - void HandleScript(uint effIndex) - { - Unit target = GetHitUnit(); - if (target) - target.RemoveAura(SpellIds.GiftOfTharonJa); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } + return ValidateSpellInfo(SpellIds.GiftOfTharonJa); } - public override SpellScript GetSpellScript() + void HandleScript(uint effIndex) { - return new spell_tharon_ja_clear_gift_of_tharon_ja_SpellScript(); + Unit target = GetHitUnit(); + if (target) + target.RemoveAura(SpellIds.GiftOfTharonJa); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } } diff --git a/Scripts/Northrend/DraktharonKeep/BossTrollgore.cs b/Scripts/Northrend/DraktharonKeep/BossTrollgore.cs index 098cec1ff..737d8ef36 100644 --- a/Scripts/Northrend/DraktharonKeep/BossTrollgore.cs +++ b/Scripts/Northrend/DraktharonKeep/BossTrollgore.cs @@ -59,256 +59,206 @@ namespace Scripts.Northrend.DraktharonKeep.Trollgore } [Script] - class boss_trollgore : CreatureScript + class boss_trollgore : BossAI { - public boss_trollgore() : base("boss_trollgore") { } - - class boss_trollgoreAI : BossAI + public boss_trollgore(Creature creature) : base(creature, DTKDataTypes.Trollgore) { - public boss_trollgoreAI(Creature creature) : base(creature, DTKDataTypes.Trollgore) + Initialize(); + } + + void Initialize() + { + _consumptionJunction = true; + } + + public override void Reset() + { + _Reset(); + Initialize(); + } + + public override void EnterCombat(Unit who) + { + _EnterCombat(); + Talk(TextIds.SayAggro); + + _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); + + _scheduler.Schedule(TimeSpan.FromSeconds(15), task => + { + Talk(TextIds.SayConsume); + DoCastAOE(SpellIds.Consume); + task.Repeat(); + }); + + _scheduler.Schedule(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(5), task => { - Initialize(); - } + DoCastVictim(SpellIds.Crush); + task.Repeat(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(15)); + }); - void Initialize() + _scheduler.Schedule(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(60), task => { - _consumptionJunction = true; - } + DoCastVictim(SpellIds.InfectedWound); + task.Repeat(TimeSpan.FromSeconds(25), TimeSpan.FromSeconds(35)); + }); - public override void Reset() + _scheduler.Schedule(TimeSpan.FromSeconds(3), task => { - _Reset(); - Initialize(); - } + Talk(TextIds.SayExplode); + DoCastAOE(SpellIds.CorpseExplode); + task.Repeat(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(19)); + }); - public override void EnterCombat(Unit who) + _scheduler.Schedule(TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(40), task => { - _EnterCombat(); - Talk(TextIds.SayAggro); - - _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); - - _scheduler.Schedule(TimeSpan.FromSeconds(15), task => - { - Talk(TextIds.SayConsume); - DoCastAOE(SpellIds.Consume); - task.Repeat(); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(5), task => + for (byte i = 0; i < 3; ++i) { - DoCastVictim(SpellIds.Crush); - task.Repeat(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(15)); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(60), task => - { - DoCastVictim(SpellIds.InfectedWound); - task.Repeat(TimeSpan.FromSeconds(25), TimeSpan.FromSeconds(35)); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(3), task => - { - Talk(TextIds.SayExplode); - DoCastAOE(SpellIds.CorpseExplode); - task.Repeat(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(19)); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(40), task => - { - for (byte i = 0; i < 3; ++i) - { - Creature trigger = ObjectAccessor.GetCreature(me, instance.GetGuidData(DTKDataTypes.TrollgoreInvaderSummoner1 + i)); - if (trigger) - trigger.CastSpell(trigger, RandomHelper.RAND(SpellIds.SummonInvaderA, SpellIds.SummonInvaderB, SpellIds.SummonInvaderC), true, null, null, me.GetGUID()); - } - - task.Repeat(); - }); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _scheduler.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - if (_consumptionJunction) - { - Aura ConsumeAura = me.GetAura(DungeonMode(SpellIds.ConsumeBuff, SpellIds.ConsumeBuffH)); - if (ConsumeAura != null && ConsumeAura.GetStackAmount() > 9) - _consumptionJunction = false; + Creature trigger = ObjectAccessor.GetCreature(me, instance.GetGuidData(DTKDataTypes.TrollgoreInvaderSummoner1 + i)); + if (trigger) + trigger.CastSpell(trigger, RandomHelper.RAND(SpellIds.SummonInvaderA, SpellIds.SummonInvaderB, SpellIds.SummonInvaderC), true, null, null, me.GetGUID()); } - DoMeleeAttackIfReady(); - } - - public override void JustDied(Unit killer) - { - _JustDied(); - Talk(TextIds.SayDeath); - } - - public override uint GetData(uint type) - { - if (type == Misc.DataConsumptionJunction) - return _consumptionJunction ? 1 : 0u; - - return 0; - } - - public override void KilledUnit(Unit victim) - { - if (victim.IsTypeId(TypeId.Player)) - Talk(TextIds.SayKill); - } - - public override void JustSummoned(Creature summon) - { - summon.GetMotionMaster().MovePoint(Misc.PointLanding, Misc.Landing); - summons.Summon(summon); - } - - bool _consumptionJunction; + task.Repeat(); + }); } - public override CreatureAI GetAI(Creature creature) + public override void UpdateAI(uint diff) { - return GetInstanceAI(creature); + if (!UpdateVictim()) + return; + + _scheduler.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + if (_consumptionJunction) + { + Aura ConsumeAura = me.GetAura(DungeonMode(SpellIds.ConsumeBuff, SpellIds.ConsumeBuffH)); + if (ConsumeAura != null && ConsumeAura.GetStackAmount() > 9) + _consumptionJunction = false; + } + + DoMeleeAttackIfReady(); } + + public override void JustDied(Unit killer) + { + _JustDied(); + Talk(TextIds.SayDeath); + } + + public override uint GetData(uint type) + { + if (type == Misc.DataConsumptionJunction) + return _consumptionJunction ? 1 : 0u; + + return 0; + } + + public override void KilledUnit(Unit victim) + { + if (victim.IsTypeId(TypeId.Player)) + Talk(TextIds.SayKill); + } + + public override void JustSummoned(Creature summon) + { + summon.GetMotionMaster().MovePoint(Misc.PointLanding, Misc.Landing); + summons.Summon(summon); + } + + bool _consumptionJunction; } [Script] - class npc_drakkari_invader : CreatureScript + class npc_drakkari_invader : ScriptedAI { - public npc_drakkari_invader() : base("npc_drakkari_invader") { } + public npc_drakkari_invader(Creature creature) : base(creature) { } - class npc_drakkari_invaderAI : ScriptedAI + public override void MovementInform(MovementGeneratorType type, uint pointId) { - public npc_drakkari_invaderAI(Creature creature) : base(creature) { } - - public override void MovementInform(MovementGeneratorType type, uint pointId) + if (type == MovementGeneratorType.Point && pointId == Misc.PointLanding) { - if (type == MovementGeneratorType.Point && pointId == Misc.PointLanding) - { - me.Dismount(); - me.RemoveFlag(UnitFields.Flags, UnitFlags.ImmuneToPc | UnitFlags.ImmuneToNpc); - DoCastAOE(SpellIds.InvaderTaunt); - } + me.Dismount(); + me.RemoveFlag(UnitFields.Flags, UnitFlags.ImmuneToPc | UnitFlags.ImmuneToNpc); + DoCastAOE(SpellIds.InvaderTaunt); } } - - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } } [Script] // 49380, 59803 - Consume - class spell_trollgore_consume : SpellScriptLoader + class spell_trollgore_consume : SpellScript { - public spell_trollgore_consume() : base("spell_trollgore_consume") { } - - class spell_trollgore_consume_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ConsumeBuff); - } - - void HandleConsume(uint effIndex) - { - Unit target = GetHitUnit(); - if (target) - target.CastSpell(GetCaster(), SpellIds.ConsumeBuff, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleConsume, 1, SpellEffectName.ScriptEffect)); - } + return ValidateSpellInfo(SpellIds.ConsumeBuff); } - public override SpellScript GetSpellScript() + void HandleConsume(uint effIndex) { - return new spell_trollgore_consume_SpellScript(); + Unit target = GetHitUnit(); + if (target) + target.CastSpell(GetCaster(), SpellIds.ConsumeBuff, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleConsume, 1, SpellEffectName.ScriptEffect)); } } [Script] // 49555, 59807 - Corpse Explode - class spell_trollgore_corpse_explode : SpellScriptLoader + class spell_trollgore_corpse_explode : AuraScript { - public spell_trollgore_corpse_explode() : base("spell_trollgore_corpse_explode") { } - - class spell_trollgore_corpse_explode_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.CorpseExplodeDamage); - } + return ValidateSpellInfo(SpellIds.CorpseExplodeDamage); + } - void PeriodicTick(AuraEffect aurEff) + void PeriodicTick(AuraEffect aurEff) + { + if (aurEff.GetTickNumber() == 2) { - if (aurEff.GetTickNumber() == 2) - { - Unit caster = GetCaster(); - if (caster) - caster.CastSpell(GetTarget(), SpellIds.CorpseExplodeDamage, true, null, aurEff); - } - } - - void HandleRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Creature target = GetTarget().ToCreature(); - if (target) - target.DespawnOrUnsummon(); - } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(PeriodicTick, 0, AuraType.Dummy)); - AfterEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.Real)); + Unit caster = GetCaster(); + if (caster) + caster.CastSpell(GetTarget(), SpellIds.CorpseExplodeDamage, true, null, aurEff); } } - public override AuraScript GetAuraScript() + void HandleRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_trollgore_corpse_explode_AuraScript(); + Creature target = GetTarget().ToCreature(); + if (target) + target.DespawnOrUnsummon(); + } + + public override void Register() + { + OnEffectPeriodic.Add(new EffectPeriodicHandler(PeriodicTick, 0, AuraType.Dummy)); + AfterEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.Real)); } } [Script] // 49405 - Invader Taunt Trigger - class spell_trollgore_invader_taunt : SpellScriptLoader + class spell_trollgore_invader_taunt : SpellScript { - public spell_trollgore_invader_taunt() : base("spell_trollgore_invader_taunt") { } - - class spell_trollgore_invader_taunt_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo((uint)spellInfo.GetEffect(0).CalcValue()); - } - - void HandleTaunt(uint effIndex) - { - Unit target = GetHitUnit(); - if (target) - target.CastSpell(GetCaster(), (uint)GetEffectValue(), true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleTaunt, 0, SpellEffectName.ScriptEffect)); - } + return ValidateSpellInfo((uint)spellInfo.GetEffect(0).CalcValue()); } - public override SpellScript GetSpellScript() + void HandleTaunt(uint effIndex) { - return new spell_trollgore_invader_taunt_SpellScript(); + Unit target = GetHitUnit(); + if (target) + target.CastSpell(GetCaster(), (uint)GetEffectValue(), true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleTaunt, 0, SpellEffectName.ScriptEffect)); } } @@ -327,7 +277,7 @@ namespace Scripts.Northrend.DraktharonKeep.Trollgore Creature Trollgore = target.ToCreature(); if (Trollgore) if (Trollgore.GetAI().GetData(Misc.DataConsumptionJunction) != 0) - return true; + return true; return false; } diff --git a/Scripts/Northrend/Gundrak/BossDrakkariColossus.cs b/Scripts/Northrend/Gundrak/BossDrakkariColossus.cs index e34d2f878..7bba04566 100644 --- a/Scripts/Northrend/Gundrak/BossDrakkariColossus.cs +++ b/Scripts/Northrend/Gundrak/BossDrakkariColossus.cs @@ -66,379 +66,349 @@ namespace Scripts.Northrend.Gundrak.DrakkariColossus } [Script] - class boss_drakkari_colossus : CreatureScript + class boss_drakkari_colossus : BossAI { - public boss_drakkari_colossus() : base("boss_drakkari_colossus") { } - - class boss_drakkari_colossusAI : BossAI + public boss_drakkari_colossus(Creature creature) : base(creature, GDDataTypes.DrakkariColossus) { - public boss_drakkari_colossusAI(Creature creature) : base(creature, GDDataTypes.DrakkariColossus) + Initialize(); + me.SetReactState(ReactStates.Passive); + introDone = false; + } + + void Initialize() + { + phase = Misc.ColossusPhaseNormal; + } + + public override void Reset() + { + _Reset(); + + if (GetData(Misc.DataIntroDone) != 0) { - Initialize(); - me.SetReactState(ReactStates.Passive); - introDone = false; - } - - void Initialize() - { - phase = Misc.ColossusPhaseNormal; - } - - public override void Reset() - { - _Reset(); - - if (GetData(Misc.DataIntroDone) != 0) - { - me.SetReactState(ReactStates.Aggressive); - me.RemoveFlag(UnitFields.Flags, UnitFlags.ImmuneToPc); - me.RemoveAura(SpellIds.FreezeAnim); - } - - _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); - - _scheduler.Schedule(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(30), task => - { - DoCastVictim(SpellIds.MightyBlow); - task.Repeat(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(15)); - }); - - Initialize(); - } - - public override void EnterCombat(Unit who) - { - _EnterCombat(); + me.SetReactState(ReactStates.Aggressive); + me.RemoveFlag(UnitFields.Flags, UnitFlags.ImmuneToPc); me.RemoveAura(SpellIds.FreezeAnim); } - public override void JustDied(Unit killer) + _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); + + _scheduler.Schedule(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(30), task => { - _JustDied(); + DoCastVictim(SpellIds.MightyBlow); + task.Repeat(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(15)); + }); + + Initialize(); + } + + public override void EnterCombat(Unit who) + { + _EnterCombat(); + me.RemoveAura(SpellIds.FreezeAnim); + } + + public override void JustDied(Unit killer) + { + _JustDied(); + } + + public override void DoAction(int action) + { + switch (action) + { + case Misc.ActionSummonElemental: + DoCast(SpellIds.Emerge); + break; + case Misc.ActionFreezeColossus: + me.GetMotionMaster().Clear(); + me.GetMotionMaster().MoveIdle(); + + me.SetReactState(ReactStates.Passive); + me.SetFlag(UnitFields.Flags, UnitFlags.ImmuneToPc); + DoCast(me, SpellIds.FreezeAnim); + break; + case Misc.ActionUnfreezeColossus: + if (me.GetReactState() == ReactStates.Aggressive) + return; + + me.SetReactState(ReactStates.Aggressive); + me.RemoveFlag(UnitFields.Flags, UnitFlags.ImmuneToPc); + me.RemoveAura(SpellIds.FreezeAnim); + + me.SetInCombatWithZone(); + + if (me.GetVictim()) + me.GetMotionMaster().MoveChase(me.GetVictim(), 0, 0); + break; } + } - public override void DoAction(int action) + public override void DamageTaken(Unit attacker, ref uint damage) + { + if (me.HasFlag(UnitFields.Flags, UnitFlags.ImmuneToPc)) + damage = 0; + + if (phase == Misc.ColossusPhaseNormal || + phase == Misc.ColossusPhaseFirstElementalSummon) { - switch (action) + if (HealthBelowPct(phase == Misc.ColossusPhaseNormal ? 50 : 5)) { - case Misc.ActionSummonElemental: - DoCast(SpellIds.Emerge); - break; - case Misc.ActionFreezeColossus: - me.GetMotionMaster().Clear(); - me.GetMotionMaster().MoveIdle(); - - me.SetReactState(ReactStates.Passive); - me.SetFlag(UnitFields.Flags, UnitFlags.ImmuneToPc); - DoCast(me, SpellIds.FreezeAnim); - break; - case Misc.ActionUnfreezeColossus: - if (me.GetReactState() == ReactStates.Aggressive) - return; - - me.SetReactState(ReactStates.Aggressive); - me.RemoveFlag(UnitFields.Flags, UnitFlags.ImmuneToPc); - me.RemoveAura(SpellIds.FreezeAnim); - - me.SetInCombatWithZone(); - - if (me.GetVictim()) - me.GetMotionMaster().MoveChase(me.GetVictim(), 0, 0); - break; + damage = 0; + phase = (phase == Misc.ColossusPhaseNormal ? Misc.ColossusPhaseFirstElementalSummon : Misc.ColossusPhaseSecondElementalSummon); + DoAction(Misc.ActionFreezeColossus); + DoAction(Misc.ActionSummonElemental); } } + } - public override void DamageTaken(Unit attacker, ref uint damage) + public override uint GetData(uint data) + { + if (data == Misc.DataColossusPhase) + return phase; + else if (data == Misc.DataIntroDone) + return introDone ? 1 : 0u; + + return 0; + } + + public override void SetData(uint type, uint data) + { + if (type == Misc.DataIntroDone) + introDone = data != 0; + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _scheduler.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + if (me.GetReactState() == ReactStates.Aggressive) + DoMeleeAttackIfReady(); + } + + public override void JustSummoned(Creature summon) + { + summon.SetInCombatWithZone(); + + if (phase == Misc.ColossusPhaseSecondElementalSummon) + summon.SetHealth(summon.GetMaxHealth() / 2); + } + + byte phase; + bool introDone; + } + + [Script] + class boss_drakkari_elemental : ScriptedAI + { + public boss_drakkari_elemental(Creature creature) : base(creature) + { + DoCast(me, SpellIds.ElementalSpawnEffect); + instance = creature.GetInstanceScript(); + } + + public override void Reset() + { + _scheduler.CancelAll(); + _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); + + _scheduler.Schedule(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(15), task => { - if (me.HasFlag(UnitFields.Flags, UnitFlags.ImmuneToPc)) - damage = 0; + DoCast(SpellIds.SurgeVisual); + Unit target = SelectTarget(SelectAggroTarget.Random, 1, 0.0f, true); + if (target) + DoCast(target, SpellIds.Surge); + task.Repeat(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(15)); + }); - if (phase == Misc.ColossusPhaseNormal || - phase == Misc.ColossusPhaseFirstElementalSummon) + me.AddAura(SpellIds.MojoVolley, me); + } + + public override void JustDied(Unit killer) + { + Talk(TextIds.EmoteActivateAltar); + + Creature colossus = instance.GetCreature(GDDataTypes.DrakkariColossus); + if (colossus) + killer.Kill(colossus); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _scheduler.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + DoMeleeAttackIfReady(); + } + + public override void DoAction(int action) + { + switch (action) + { + case Misc.ActionReturnToColossus: + Talk(TextIds.EmoteMojo); + DoCast(SpellIds.SurgeVisual); + Creature colossus = instance.GetCreature(GDDataTypes.DrakkariColossus); + if (colossus) + // what if the elemental is more than 80 yards from drakkari colossus ? + DoCast(colossus, SpellIds.Merge, true); + break; + } + } + + public override void DamageTaken(Unit attacker, ref uint damage) + { + if (HealthBelowPct(50)) + { + Creature colossus = instance.GetCreature(GDDataTypes.DrakkariColossus); + if (colossus) { - if (HealthBelowPct(phase == Misc.ColossusPhaseNormal ? 50 : 5)) + if (colossus.GetAI().GetData(Misc.DataColossusPhase) == Misc.ColossusPhaseFirstElementalSummon) { damage = 0; - phase = (phase == Misc.ColossusPhaseNormal ? Misc.ColossusPhaseFirstElementalSummon : Misc.ColossusPhaseSecondElementalSummon); - DoAction(Misc.ActionFreezeColossus); - DoAction(Misc.ActionSummonElemental); - } - } - } - public override uint GetData(uint data) - { - if (data == Misc.DataColossusPhase) - return phase; - else if (data == Misc.DataIntroDone) - return introDone ? 1 : 0u; + // to prevent spell spaming + if (me.HasUnitState(UnitState.Charging)) + return; - return 0; - } - - public override void SetData(uint type, uint data) - { - if (type == Misc.DataIntroDone) - introDone = data != 0; - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _scheduler.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - if (me.GetReactState() == ReactStates.Aggressive) - DoMeleeAttackIfReady(); - } - - public override void JustSummoned(Creature summon) - { - summon.SetInCombatWithZone(); - - if (phase == Misc.ColossusPhaseSecondElementalSummon) - summon.SetHealth(summon.GetMaxHealth() / 2); - } - - byte phase; - bool introDone; - } - - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } - } - - [Script] - class boss_drakkari_elemental : CreatureScript - { - public boss_drakkari_elemental() : base("boss_drakkari_elemental") { } - - class boss_drakkari_elementalAI : ScriptedAI - { - public boss_drakkari_elementalAI(Creature creature) : base(creature) - { - DoCast(me, SpellIds.ElementalSpawnEffect); - instance = creature.GetInstanceScript(); - } - - public override void Reset() - { - _scheduler.CancelAll(); - _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); - - _scheduler.Schedule(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(15), task => - { - DoCast(SpellIds.SurgeVisual); - Unit target = SelectTarget(SelectAggroTarget.Random, 1, 0.0f, true); - if (target) - DoCast(target, SpellIds.Surge); - task.Repeat(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(15)); - }); - - me.AddAura(SpellIds.MojoVolley, me); - } - - public override void JustDied(Unit killer) - { - Talk(TextIds.EmoteActivateAltar); - - Creature colossus = instance.GetCreature(GDDataTypes.DrakkariColossus); - if (colossus) - killer.Kill(colossus); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _scheduler.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - DoMeleeAttackIfReady(); - } - - public override void DoAction(int action) - { - switch (action) - { - case Misc.ActionReturnToColossus: - Talk(TextIds.EmoteMojo); - DoCast(SpellIds.SurgeVisual); - Creature colossus = instance.GetCreature(GDDataTypes.DrakkariColossus); - if (colossus) - // what if the elemental is more than 80 yards from drakkari colossus ? - DoCast(colossus, SpellIds.Merge, true); - break; - } - } - - public override void DamageTaken(Unit attacker, ref uint damage) - { - if (HealthBelowPct(50)) - { - Creature colossus = instance.GetCreature(GDDataTypes.DrakkariColossus); - if (colossus) - { - if (colossus.GetAI().GetData(Misc.DataColossusPhase) == Misc.ColossusPhaseFirstElementalSummon) + // not sure about this, the idea of this code is to prevent bug the elemental + // if it is not in a acceptable distance to cast the charge spell. + if (me.GetDistance(colossus) > 80.0f) { - damage = 0; - - // to prevent spell spaming - if (me.HasUnitState(UnitState.Charging)) + if (me.GetMotionMaster().GetCurrentMovementGeneratorType() == MovementGeneratorType.Point) return; - // not sure about this, the idea of this code is to prevent bug the elemental - // if it is not in a acceptable distance to cast the charge spell. - if (me.GetDistance(colossus) > 80.0f) - { - if (me.GetMotionMaster().GetCurrentMovementGeneratorType() == MovementGeneratorType.Point) - return; - - me.GetMotionMaster().MovePoint(0, colossus.GetPositionX(), colossus.GetPositionY(), colossus.GetPositionZ()); - return; - } - DoAction(Misc.ActionReturnToColossus); + me.GetMotionMaster().MovePoint(0, colossus.GetPositionX(), colossus.GetPositionY(), colossus.GetPositionZ()); + return; } + DoAction(Misc.ActionReturnToColossus); } } } - - public override void EnterEvadeMode(EvadeReason why) - { - me.DespawnOrUnsummon(); - } - - public override void SpellHitTarget(Unit target, SpellInfo spell) - { - if (spell.Id == SpellIds.Merge) - { - Creature colossus = target.ToCreature(); - if (colossus) - { - colossus.GetAI().DoAction(Misc.ActionUnfreezeColossus); - me.DespawnOrUnsummon(); - } - } - } - - InstanceScript instance; } - public override CreatureAI GetAI(Creature creature) + public override void EnterEvadeMode(EvadeReason why) { - return GetInstanceAI(creature); + me.DespawnOrUnsummon(); } + + public override void SpellHitTarget(Unit target, SpellInfo spell) + { + if (spell.Id == SpellIds.Merge) + { + Creature colossus = target.ToCreature(); + if (colossus) + { + colossus.GetAI().DoAction(Misc.ActionUnfreezeColossus); + me.DespawnOrUnsummon(); + } + } + } + + InstanceScript instance; } [Script] - class npc_living_mojo : CreatureScript + class npc_living_mojo : ScriptedAI { - public npc_living_mojo() : base("npc_living_mojo") { } - - class npc_living_mojoAI : ScriptedAI + public npc_living_mojo(Creature creature) : base(creature) { - public npc_living_mojoAI(Creature creature) : base(creature) - { - instance = creature.GetInstanceScript(); - } + instance = creature.GetInstanceScript(); + } - public override void Reset() + public override void Reset() + { + _scheduler.Schedule(TimeSpan.FromSeconds(2), task => { - _scheduler.Schedule(TimeSpan.FromSeconds(2), task => - { - DoCastVictim(SpellIds.MojoWave); - task.Repeat(TimeSpan.FromSeconds(15)); - }); + DoCastVictim(SpellIds.MojoWave); + task.Repeat(TimeSpan.FromSeconds(15)); + }); - _scheduler.Schedule(TimeSpan.FromSeconds(7), task => - { - DoCastVictim(SpellIds.MojoPuddle); - task.Repeat(TimeSpan.FromSeconds(18)); - }); - } - - void MoveMojos(Creature boss) + _scheduler.Schedule(TimeSpan.FromSeconds(7), task => { - List mojosList = new List(); - boss.GetCreatureListWithEntryInGrid(mojosList, me.GetEntry(), 12.0f); - if (!mojosList.Empty()) + DoCastVictim(SpellIds.MojoPuddle); + task.Repeat(TimeSpan.FromSeconds(18)); + }); + } + + void MoveMojos(Creature boss) + { + List mojosList = new List(); + boss.GetCreatureListWithEntryInGrid(mojosList, me.GetEntry(), 12.0f); + if (!mojosList.Empty()) + { + foreach (var mojo in mojosList) { - foreach (var mojo in mojosList) - { - if (mojo) - mojo.GetMotionMaster().MovePoint(1, boss.GetHomePosition()); - } + if (mojo) + mojo.GetMotionMaster().MovePoint(1, boss.GetHomePosition()); } } + } - public override void MovementInform(MovementGeneratorType type, uint id) + public override void MovementInform(MovementGeneratorType type, uint id) + { + if (type != MovementGeneratorType.Point) + return; + + if (id == 1) { - if (type != MovementGeneratorType.Point) - return; - - if (id == 1) - { - Creature colossus = instance.GetCreature(GDDataTypes.DrakkariColossus); - if (colossus) - { - colossus.GetAI().DoAction(Misc.ActionUnfreezeColossus); - if (colossus.GetAI().GetData(Misc.DataIntroDone) == 0) - colossus.GetAI().SetData(Misc.DataIntroDone, 1); - colossus.SetInCombatWithZone(); - me.DespawnOrUnsummon(); - } - } - } - - public override void AttackStart(Unit attacker) - { - if (me.GetMotionMaster().GetCurrentMovementGeneratorType() == MovementGeneratorType.Point) - return; - - // we do this checks to see if the creature is one of the creatures that sorround the boss Creature colossus = instance.GetCreature(GDDataTypes.DrakkariColossus); if (colossus) { - Position homePosition = me.GetHomePosition(); - - float distance = homePosition.GetExactDist(colossus.GetHomePosition()); - - if (distance < 12.0f) - { - MoveMojos(colossus); - me.SetReactState(ReactStates.Passive); - } - else - base.AttackStart(attacker); + colossus.GetAI().DoAction(Misc.ActionUnfreezeColossus); + if (colossus.GetAI().GetData(Misc.DataIntroDone) == 0) + colossus.GetAI().SetData(Misc.DataIntroDone, 1); + colossus.SetInCombatWithZone(); + me.DespawnOrUnsummon(); } } - - public override void UpdateAI(uint diff) - { - //Return since we have no target - if (!UpdateVictim()) - return; - - _scheduler.Update(diff); - - DoMeleeAttackIfReady(); - } - - InstanceScript instance; } - public override CreatureAI GetAI(Creature creature) + public override void AttackStart(Unit attacker) { - return GetInstanceAI(creature); + if (me.GetMotionMaster().GetCurrentMovementGeneratorType() == MovementGeneratorType.Point) + return; + + // we do this checks to see if the creature is one of the creatures that sorround the boss + Creature colossus = instance.GetCreature(GDDataTypes.DrakkariColossus); + if (colossus) + { + Position homePosition = me.GetHomePosition(); + + float distance = homePosition.GetExactDist(colossus.GetHomePosition()); + + if (distance < 12.0f) + { + MoveMojos(colossus); + me.SetReactState(ReactStates.Passive); + } + else + base.AttackStart(attacker); + } } + + public override void UpdateAI(uint diff) + { + //Return since we have no target + if (!UpdateVictim()) + return; + + _scheduler.Update(diff); + + DoMeleeAttackIfReady(); + } + + InstanceScript instance; } } diff --git a/Scripts/Northrend/Gundrak/BossEck.cs b/Scripts/Northrend/Gundrak/BossEck.cs index 156bad60c..470527360 100644 --- a/Scripts/Northrend/Gundrak/BossEck.cs +++ b/Scripts/Northrend/Gundrak/BossEck.cs @@ -38,91 +38,81 @@ namespace Scripts.Northrend.Gundrak.EckTheFerocious } [Script] - class boss_eck : CreatureScript + class boss_eck : BossAI { - public boss_eck() : base("boss_eck") { } - - class boss_eckAI : BossAI + public boss_eck(Creature creature) : base(creature, GDDataTypes.EckTheFerocious) { - public boss_eckAI(Creature creature) : base(creature, GDDataTypes.EckTheFerocious) - { - Initialize(); - Talk(TextIds.EmoteSpawn); - } - - void Initialize() - { - _berserk = false; - } - - public override void Reset() - { - _Reset(); - Initialize(); - } - - public override void EnterCombat(Unit who) - { - _EnterCombat(); - - _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); - - _scheduler.Schedule(TimeSpan.FromSeconds(5), task => - { - DoCastVictim(SpellIds.Bite); - task.Repeat(TimeSpan.FromSeconds(8), TimeSpan.FromSeconds(12)); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(10), task => - { - DoCastVictim(SpellIds.Spit); - task.Repeat(TimeSpan.FromSeconds(6), TimeSpan.FromSeconds(14)); - }); - - _scheduler.Schedule(TimeSpan.FromSeconds(8), task => - { - Unit target = SelectTarget(SelectAggroTarget.Random, 1, 35.0f, true); - if (target) - DoCast(target, RandomHelper.RAND(SpellIds.Spring1, SpellIds.Spring2)); - task.Repeat(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(10)); - }); - - // 60-90 secs according to wowwiki - _scheduler.Schedule(TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(90), 1, task => - { - DoCast(me, SpellIds.Berserk); - _berserk = true; - }); - } - - public override void DamageTaken(Unit attacker, ref uint damage) - { - if (!_berserk && me.HealthBelowPctDamaged(20, damage)) - { - _scheduler.RescheduleGroup(1, TimeSpan.FromSeconds(1)); - _berserk = true; - } - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _scheduler.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - DoMeleeAttackIfReady(); - } - - bool _berserk; + Initialize(); + Talk(TextIds.EmoteSpawn); } - public override CreatureAI GetAI(Creature creature) + void Initialize() { - return GetInstanceAI(creature); + _berserk = false; } + + public override void Reset() + { + _Reset(); + Initialize(); + } + + public override void EnterCombat(Unit who) + { + _EnterCombat(); + + _scheduler.SetValidator(() => !me.HasUnitState(UnitState.Casting)); + + _scheduler.Schedule(TimeSpan.FromSeconds(5), task => + { + DoCastVictim(SpellIds.Bite); + task.Repeat(TimeSpan.FromSeconds(8), TimeSpan.FromSeconds(12)); + }); + + _scheduler.Schedule(TimeSpan.FromSeconds(10), task => + { + DoCastVictim(SpellIds.Spit); + task.Repeat(TimeSpan.FromSeconds(6), TimeSpan.FromSeconds(14)); + }); + + _scheduler.Schedule(TimeSpan.FromSeconds(8), task => + { + Unit target = SelectTarget(SelectAggroTarget.Random, 1, 35.0f, true); + if (target) + DoCast(target, RandomHelper.RAND(SpellIds.Spring1, SpellIds.Spring2)); + task.Repeat(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(10)); + }); + + // 60-90 secs according to wowwiki + _scheduler.Schedule(TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(90), 1, task => + { + DoCast(me, SpellIds.Berserk); + _berserk = true; + }); + } + + public override void DamageTaken(Unit attacker, ref uint damage) + { + if (!_berserk && me.HealthBelowPctDamaged(20, damage)) + { + _scheduler.RescheduleGroup(1, TimeSpan.FromSeconds(1)); + _berserk = true; + } + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _scheduler.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + DoMeleeAttackIfReady(); + } + + bool _berserk; } } \ No newline at end of file diff --git a/Scripts/Northrend/Gundrak/InstanceGundrak.cs b/Scripts/Northrend/Gundrak/InstanceGundrak.cs index 70e9c1350..8eb509986 100644 --- a/Scripts/Northrend/Gundrak/InstanceGundrak.cs +++ b/Scripts/Northrend/Gundrak/InstanceGundrak.cs @@ -322,7 +322,7 @@ namespace Scripts.Northrend.Gundrak public override void ReadSaveDataMore(StringArguments data) { - SladRanStatueState = (GameObjectState)data.NextUInt32(); + SladRanStatueState = (GameObjectState)data.NextUInt32(); DrakkariColossusStatueState = (GameObjectState)data.NextUInt32(); MoorabiStatueState = (GameObjectState)data.NextUInt32(); diff --git a/Scripts/Northrend/IcecrownCitadel/GunshipBattle.cs b/Scripts/Northrend/IcecrownCitadel/GunshipBattle.cs index 1a6a6810e..0dc48a510 100644 --- a/Scripts/Northrend/IcecrownCitadel/GunshipBattle.cs +++ b/Scripts/Northrend/IcecrownCitadel/GunshipBattle.cs @@ -235,7 +235,7 @@ namespace Scripts.Northrend.IcecrownCitadel new SlotInfo(CreatureIds.SkybreakerMarine, SkybreakerTeleportPortal, 0 ), new SlotInfo(CreatureIds.SkybreakerMarine, SkybreakerTeleportPortal, 0 ), - + new SlotInfo(CreatureIds.SkybreakerSergeant, SkybreakerTeleportPortal, 0 ), new SlotInfo(CreatureIds.SkybreakerSergeant, SkybreakerTeleportPortal, 0 ) @@ -246,7 +246,7 @@ namespace Scripts.Northrend.IcecrownCitadel new SlotInfo(CreatureIds.KorKronBattleMage, 47.29290f, -4.308941f, 37.55550f, 1.570796f, 0 ), new SlotInfo(CreatureIds.KorKronBattleMage, 47.34621f, 4.032004f, 37.70952f, 4.817109f, 0 ), - + new SlotInfo(CreatureIds.KorKronAxeThrower, -12.09280f, 27.65942f, 33.58557f, 1.53589f, 30 ), new SlotInfo(CreatureIds.KorKronAxeThrower, -3.170555f, 28.30652f, 34.21082f, 1.53589f, 30 ), new SlotInfo(CreatureIds.KorKronAxeThrower, 14.928040f, 26.18018f, 35.47803f, 1.53589f, 30 ), @@ -268,7 +268,7 @@ namespace Scripts.Northrend.IcecrownCitadel new SlotInfo(CreatureIds.KorKronReaver, OrgrimsHammerTeleportPortal, 0 ), new SlotInfo(CreatureIds.KorKronReaver, OrgrimsHammerTeleportPortal, 0 ), - + new SlotInfo(CreatureIds.KorKronSergeant, OrgrimsHammerTeleportPortal, 0 ), new SlotInfo(CreatureIds.KorKronSergeant, OrgrimsHammerTeleportPortal, 0 ) @@ -293,7 +293,7 @@ namespace Scripts.Northrend.IcecrownCitadel public static Vector3[] SaurfangExitPath = { new Vector3(30.43987f, 0.1475817f, 36.10674f ), - new Vector3(21.36141f, -3.056458f, 35.42970f ), + new Vector3(21.36141f, -3.056458f, 35.42970f ), new Vector3(19.11141f, -3.806458f, 35.42970f ), new Vector3(19.01736f, -3.299440f, 35.39428f ), new Vector3(18.6747f, -5.862823f, 35.66611f ), @@ -547,8 +547,7 @@ namespace Scripts.Northrend.IcecrownCitadel class gunship_npc_AI : ScriptedAI { - public gunship_npc_AI(Creature creature) - : base(creature) + public gunship_npc_AI(Creature creature) : base(creature) { Instance = creature.GetInstanceScript(); Slot = null; @@ -673,744 +672,701 @@ namespace Scripts.Northrend.IcecrownCitadel } [Script] - class npc_gunship : CreatureScript + class npc_gunship : NullCreatureAI { - public npc_gunship() : base("npc_gunship") { } - - class npc_gunshipAI : NullCreatureAI + public npc_gunship(Creature creature) : base(creature) { - public npc_gunshipAI(Creature creature) : base(creature) - { - _teamInInstance = (Team)creature.GetInstanceScript().GetData(DataTypes.TeamInInstance); - _summonedFirstMage = false; - _died = false; + _teamInInstance = (Team)creature.GetInstanceScript().GetData(DataTypes.TeamInInstance); + _summonedFirstMage = false; + _died = false; - me.setRegeneratingHealth(false); + me.setRegeneratingHealth(false); + } + + public override void DamageTaken(Unit source, ref uint damage) + { + if (damage >= me.GetHealth()) + { + JustDied(null); + damage = (uint)me.GetHealth() - 1; + return; } - public override void DamageTaken(Unit source, ref uint damage) + if (_summonedFirstMage) + return; + + if (me.GetTransport().GetEntry() != (_teamInInstance == Team.Horde ? GameObjectIds.TheSkybreaker_H : GameObjectIds.OrgrimsHammer_A)) + return; + + if (!me.HealthBelowPctDamaged(90, damage)) + return; + + _summonedFirstMage = true; + Creature captain = me.FindNearestCreature(_teamInInstance == Team.Horde ? CreatureIds.IGBMuradinBrozebeard : CreatureIds.IGBHighOverlordSaurfang, 100.0f); + if (captain) + captain.GetAI().DoAction(EncounterActions.SpawnMage); + } + + public override void JustDied(Unit killer) + { + if (_died) + return; + + _died = true; + + bool isVictory = me.GetTransport().GetEntry() == GameObjectIds.TheSkybreaker_H || me.GetTransport().GetEntry() == GameObjectIds.OrgrimsHammer_A; + InstanceScript instance = me.GetInstanceScript(); + instance.SetBossState(Bosses.GunshipBattle, isVictory ? EncounterState.Done : EncounterState.Fail); + Creature creature = me.FindNearestCreature(me.GetEntry() == CreatureIds.OrgrimsHammer ? CreatureIds.TheSkybreaker : CreatureIds.OrgrimsHammer, 200.0f); + if (creature) { - if (damage >= me.GetHealth()) - { - JustDied(null); - damage = (uint)me.GetHealth() - 1; - return; - } - - if (_summonedFirstMage) - return; - - if (me.GetTransport().GetEntry() != (_teamInInstance == Team.Horde ? GameObjectIds.TheSkybreaker_H : GameObjectIds.OrgrimsHammer_A)) - return; - - if (!me.HealthBelowPctDamaged(90, damage)) - return; - - _summonedFirstMage = true; - Creature captain = me.FindNearestCreature(_teamInInstance == Team.Horde ? CreatureIds.IGBMuradinBrozebeard : CreatureIds.IGBHighOverlordSaurfang, 100.0f); - if (captain) - captain.GetAI().DoAction(EncounterActions.SpawnMage); + instance.SendEncounterUnit(EncounterFrameType.Disengage, creature); + creature.RemoveAurasDueToSpell(GunshipSpells.CheckForPlayers); } - public override void JustDied(Unit killer) + instance.SendEncounterUnit(EncounterFrameType.Disengage, me); + me.RemoveAurasDueToSpell(GunshipSpells.CheckForPlayers); + + me.GetMap().SetZoneMusic(AreaIds.IcecrownCitadel, 0); + List creatures = new List(); + me.GetCreatureListWithEntryInGrid(creatures, CreatureIds.MartyrStalkerIGBSaurfang, MapConst.SizeofGrids); + foreach (var stalker in creatures) { - if (_died) - return; - - _died = true; - - bool isVictory = me.GetTransport().GetEntry() == GameObjectIds.TheSkybreaker_H || me.GetTransport().GetEntry() == GameObjectIds.OrgrimsHammer_A; - InstanceScript instance = me.GetInstanceScript(); - instance.SetBossState(Bosses.GunshipBattle, isVictory ? EncounterState.Done : EncounterState.Fail); - Creature creature = me.FindNearestCreature(me.GetEntry() == CreatureIds.OrgrimsHammer ? CreatureIds.TheSkybreaker : CreatureIds.OrgrimsHammer, 200.0f); - if (creature) - { - instance.SendEncounterUnit(EncounterFrameType.Disengage, creature); - creature.RemoveAurasDueToSpell(GunshipSpells.CheckForPlayers); - } - - instance.SendEncounterUnit(EncounterFrameType.Disengage, me); - me.RemoveAurasDueToSpell(GunshipSpells.CheckForPlayers); - - me.GetMap().SetZoneMusic(AreaIds.IcecrownCitadel, 0); - List creatures = new List(); - me.GetCreatureListWithEntryInGrid(creatures, CreatureIds.MartyrStalkerIGBSaurfang, MapConst.SizeofGrids); - foreach (var stalker in creatures) - { - stalker.RemoveAllAuras(); - stalker.DeleteThreatList(); - stalker.CombatStop(true); - } + stalker.RemoveAllAuras(); + stalker.DeleteThreatList(); + stalker.CombatStop(true); + } - uint explosionSpell = isVictory ? GunshipSpells.ExplosionVictory : GunshipSpells.ExplosionWipe; - creatures.Clear(); - me.GetCreatureListWithEntryInGrid(creatures, CreatureIds.GunshipHull, 200.0f); - foreach (var hull in creatures) - { - if (hull.GetTransport() != me.GetTransport()) - continue; + uint explosionSpell = isVictory ? GunshipSpells.ExplosionVictory : GunshipSpells.ExplosionWipe; + creatures.Clear(); + me.GetCreatureListWithEntryInGrid(creatures, CreatureIds.GunshipHull, 200.0f); + foreach (var hull in creatures) + { + if (hull.GetTransport() != me.GetTransport()) + continue; - hull.CastSpell(hull, explosionSpell, TriggerCastFlags.FullMask); - } - - creatures.Clear(); - me.GetCreatureListWithEntryInGrid(creatures, _teamInInstance == Team.Horde ? CreatureIds.HordeGunshipCannon : CreatureIds.AllianceGunshipCannon, 200.0f); - foreach (var cannon in creatures) - { - if (isVictory) - { - cannon.CastSpell(cannon, GunshipSpells.EjectAllPassengersBelowZero, TriggerCastFlags.FullMask); - cannon.RemoveVehicleKit(); - } - else - cannon.CastSpell(cannon, GunshipSpells.EjectAllPassengersWipe, TriggerCastFlags.FullMask); - } - - uint creatureEntry = CreatureIds.IGBMuradinBrozebeard; - byte textId = isVictory ? GunshipTexts.SayMuradinVictory : GunshipTexts.SayMuradinWipe; - if (_teamInInstance == Team.Horde) - { - creatureEntry = CreatureIds.IGBHighOverlordSaurfang; - textId = isVictory ? GunshipTexts.SaySaurfangVictory : GunshipTexts.SaySaurfangWipe; - } - creature = me.FindNearestCreature(creatureEntry, 100.0f); - if (creature) - creature.GetAI().Talk(textId); + hull.CastSpell(hull, explosionSpell, TriggerCastFlags.FullMask); + } + creatures.Clear(); + me.GetCreatureListWithEntryInGrid(creatures, _teamInInstance == Team.Horde ? CreatureIds.HordeGunshipCannon : CreatureIds.AllianceGunshipCannon, 200.0f); + foreach (var cannon in creatures) + { if (isVictory) { - Transport go = Global.ObjAccessor.FindTransport(instance.GetGuidData(Bosses.GunshipBattle)); - if (go) - go.EnableMovement(true); - - me.GetTransport().EnableMovement(true); - Creature ship = me.FindNearestCreature(_teamInInstance == Team.Horde ? CreatureIds.OrgrimsHammer : CreatureIds.TheSkybreaker, 200.0f); - if (ship) - { - ship.CastSpell(ship, GunshipSpells.TeleportPlayersOnVictory, TriggerCastFlags.FullMask); - ship.CastSpell(ship, GunshipSpells.Achievement, TriggerCastFlags.FullMask); - ship.CastSpell(ship, GunshipSpells.AwardReputationBossKill, TriggerCastFlags.FullMask); - } - - creatures.Clear(); - me.GetCreatureListWithEntryInGrid(creatures, CreatureIds.SkybreakerMarine, 200.0f); - me.GetCreatureListWithEntryInGrid(creatures, CreatureIds.SkybreakerSergeant, 200.0f); - me.GetCreatureListWithEntryInGrid(creatures, CreatureIds.KorKronReaver, 200.0f); - me.GetCreatureListWithEntryInGrid(creatures, CreatureIds.KorKronSergeant, 200.0f); - foreach (var obj in creatures) - obj.DespawnOrUnsummon(1); + cannon.CastSpell(cannon, GunshipSpells.EjectAllPassengersBelowZero, TriggerCastFlags.FullMask); + cannon.RemoveVehicleKit(); } else - { - uint teleportSpellId = _teamInInstance == Team.Horde ? GunshipSpells.TeleportPlayersOnResetH : GunshipSpells.TeleportPlayersOnResetA; - me.m_Events.AddEvent(new ResetEncounterEvent(me, teleportSpellId, me.GetInstanceScript().GetGuidData(DataTypes.EnemyGunship)), - me.m_Events.CalculateTime(8000)); - } - - instance.SetBossState(Bosses.GunshipBattle, isVictory ? EncounterState.Done : EncounterState.Fail); + cannon.CastSpell(cannon, GunshipSpells.EjectAllPassengersWipe, TriggerCastFlags.FullMask); } - public override void SetGUID(ObjectGuid guid, int id = 0) + uint creatureEntry = CreatureIds.IGBMuradinBrozebeard; + byte textId = isVictory ? GunshipTexts.SayMuradinVictory : GunshipTexts.SayMuradinWipe; + if (_teamInInstance == Team.Horde) { - if (id != EncounterActions.ShipVisits) - return; + creatureEntry = CreatureIds.IGBHighOverlordSaurfang; + textId = isVictory ? GunshipTexts.SaySaurfangVictory : GunshipTexts.SaySaurfangWipe; + } + creature = me.FindNearestCreature(creatureEntry, 100.0f); + if (creature) + creature.GetAI().Talk(textId); - if (!_shipVisits.ContainsKey(guid)) - _shipVisits[guid] = 1; + if (isVictory) + { + Transport go = Global.ObjAccessor.FindTransport(instance.GetGuidData(Bosses.GunshipBattle)); + if (go) + go.EnableMovement(true); + + me.GetTransport().EnableMovement(true); + Creature ship = me.FindNearestCreature(_teamInInstance == Team.Horde ? CreatureIds.OrgrimsHammer : CreatureIds.TheSkybreaker, 200.0f); + if (ship) + { + ship.CastSpell(ship, GunshipSpells.TeleportPlayersOnVictory, TriggerCastFlags.FullMask); + ship.CastSpell(ship, GunshipSpells.Achievement, TriggerCastFlags.FullMask); + ship.CastSpell(ship, GunshipSpells.AwardReputationBossKill, TriggerCastFlags.FullMask); + } + + creatures.Clear(); + me.GetCreatureListWithEntryInGrid(creatures, CreatureIds.SkybreakerMarine, 200.0f); + me.GetCreatureListWithEntryInGrid(creatures, CreatureIds.SkybreakerSergeant, 200.0f); + me.GetCreatureListWithEntryInGrid(creatures, CreatureIds.KorKronReaver, 200.0f); + me.GetCreatureListWithEntryInGrid(creatures, CreatureIds.KorKronSergeant, 200.0f); + foreach (var obj in creatures) + obj.DespawnOrUnsummon(1); + } + else + { + uint teleportSpellId = _teamInInstance == Team.Horde ? GunshipSpells.TeleportPlayersOnResetH : GunshipSpells.TeleportPlayersOnResetA; + me.m_Events.AddEvent(new ResetEncounterEvent(me, teleportSpellId, me.GetInstanceScript().GetGuidData(DataTypes.EnemyGunship)), + me.m_Events.CalculateTime(8000)); + } + + instance.SetBossState(Bosses.GunshipBattle, isVictory ? EncounterState.Done : EncounterState.Fail); + } + + public override void SetGUID(ObjectGuid guid, int id = 0) + { + if (id != EncounterActions.ShipVisits) + return; + + if (!_shipVisits.ContainsKey(guid)) + _shipVisits[guid] = 1; + else + ++_shipVisits[guid]; + } + + public override uint GetData(uint id) + { + if (id != EncounterActions.ShipVisits) + return 0; + + uint max = 0; + foreach (var count in _shipVisits.Values) + max = Math.Max(max, count); + + return max; + } + + Team _teamInInstance; + Dictionary _shipVisits = new Dictionary(); + bool _summonedFirstMage; + bool _died; + } + + [Script] + class npc_high_overlord_saurfang_igb : ScriptedAI + { + public npc_high_overlord_saurfang_igb(Creature creature) + : base(creature) + { + _instance = creature.GetInstanceScript(); + + _controller.ResetSlots(Team.Horde); + _controller.SetTransport(creature.GetTransport()); + me.setRegeneratingHealth(false); + me.m_CombatDistance = 70.0f; + } + + public override void InitializeAI() + { + base.InitializeAI(); + + _events.Reset(); + _firstMageCooldown = Time.UnixTime + 60; + _axethrowersYellCooldown = 0L; + _rocketeersYellCooldown = 0L; + } + + public override void EnterCombat(Unit target) + { + _events.SetPhase(GunshipMiscData.PhaseCombat); + DoCast(me, _instance.GetData(DataTypes.TeamInInstance) == (uint)Team.Horde ? GunshipSpells.FriendlyBossDamageMod : GunshipSpells.MeleeTargetingOnOrgrimsHammer, true); + DoCast(me, GunshipSpells.BattleFury, true); + _events.ScheduleEvent(GunshipEvents.Cleave, RandomHelper.URand(2000, 10000)); + } + + public override void EnterEvadeMode(EvadeReason why) + { + if (!me.IsAlive()) + return; + + me.DeleteThreatList(); + me.CombatStop(true); + me.GetMotionMaster().MoveTargetedHome(); + + Reset(); + } + + public override void DoAction(int action) + { + if (action == Actions.EnemyGunshipTalk) + { + Creature muradin = me.FindNearestCreature(CreatureIds.IGBMuradinBrozebeard, 100.0f); + if (muradin) + muradin.GetAI().DoAction(EncounterActions.SpawnAllAdds); + + Talk(GunshipTexts.SaySaurfangIntro5); + _events.ScheduleEvent(GunshipEvents.IntroH5, 4000); + _events.ScheduleEvent(GunshipEvents.IntroH6, 11000); + _events.ScheduleEvent(GunshipEvents.KeepPlayerInCombat, 1); + + _instance.SetBossState(Bosses.GunshipBattle, EncounterState.InProgress); + // Combat starts now + Creature skybreaker = me.FindNearestCreature(CreatureIds.TheSkybreaker, 100.0f); + if (skybreaker) + _instance.SendEncounterUnit(EncounterFrameType.Engage, skybreaker, 1); + + Creature orgrimsHammer = me.FindNearestCreature(CreatureIds.OrgrimsHammer, 100.0f); + if (orgrimsHammer) + { + _instance.SendEncounterUnit(EncounterFrameType.Engage, orgrimsHammer, 2); + orgrimsHammer.CastSpell(orgrimsHammer, GunshipSpells.CheckForPlayers, TriggerCastFlags.FullMask); + } + + me.GetMap().SetZoneMusic(AreaIds.IcecrownCitadel, GunshipMiscData.MusicEncounter); + } + else if (action == EncounterActions.SpawnMage) + { + long now = Time.UnixTime; + if (_firstMageCooldown > now) + _events.ScheduleEvent(GunshipEvents.SummonMage, (uint)(_firstMageCooldown - now) * Time.InMilliseconds); else - ++_shipVisits[guid]; + _events.ScheduleEvent(GunshipEvents.SummonMage, 1); } - - public override uint GetData(uint id) + else if (action == EncounterActions.SpawnAllAdds) { - if (id != EncounterActions.ShipVisits) - return 0; - - uint max = 0; - foreach (var count in _shipVisits.Values) - max = Math.Max(max, count); - - return max; + _events.ScheduleEvent(GunshipEvents.Adds, 12000); + _events.ScheduleEvent(GunshipEvents.CheckRifleman, 13000); + _events.ScheduleEvent(GunshipEvents.CheckMortar, 13000); + if (Is25ManRaid()) + _controller.SummonCreatures(PassengerSlots.Mage1, PassengerSlots.Mortar4); + else + { + _controller.SummonCreatures(PassengerSlots.Mage1, PassengerSlots.Mage2); + _controller.SummonCreatures(PassengerSlots.Mortar1, PassengerSlots.Mortar2); + _controller.SummonCreatures(PassengerSlots.Rifleman1, PassengerSlots.Rifleman4); + } } + else if (action == Actions.ExitShip) + { + Position pos = new Position(GunshipMiscData.SaurfangExitPath[GunshipMiscData.SaurfangExitPathSize - 1].X, GunshipMiscData.SaurfangExitPath[GunshipMiscData.SaurfangExitPathSize - 1].Y, GunshipMiscData.SaurfangExitPath[GunshipMiscData.SaurfangExitPathSize - 1].Z); + me.GetMotionMaster().MovePoint(EventId.ChargePrepath, pos, false); - Team _teamInInstance; - Dictionary _shipVisits = new Dictionary(); - bool _summonedFirstMage; - bool _died; + var path = GunshipMiscData.SaurfangExitPath;//, SaurfangExitPath + SaurfangExitPathSize); + + MoveSplineInit init = new MoveSplineInit(me); + init.DisableTransportPathTransformations(); + init.MovebyPath(path, 0); + init.Launch(); + + me.DespawnOrUnsummon(18000); + } } - public override CreatureAI GetAI(Creature creature) + public override void SetData(uint type, uint data) { - if (!creature.GetTransport()) - return null; - - return InstanceIcecrownCitadel.GetInstanceAI(creature); + if (type == EncounterActions.ClearSlot) + { + _controller.ClearSlot((PassengerSlots)data); + if (data == (uint)PassengerSlots.FreezeMage) + _events.ScheduleEvent(GunshipEvents.SummonMage, RandomHelper.URand(30000, 33500)); + } } - } - [Script] - class npc_high_overlord_saurfang_igb : CreatureScript - { - public npc_high_overlord_saurfang_igb() : base("npc_high_overlord_saurfang_igb") { } - - class npc_high_overlord_saurfang_igbAI : ScriptedAI + public override void sGossipSelect(Player player, uint menuId, uint gossipListId) { - public npc_high_overlord_saurfang_igbAI(Creature creature) - : base(creature) + me.RemoveFlag64(UnitFields.NpcFlags, NPCFlags.Gossip); + me.GetTransport().EnableMovement(true); + _events.SetPhase(GunshipMiscData.PhaseIntro); + _events.ScheduleEvent(GunshipEvents.IntroH1, 5000, 0, GunshipMiscData.PhaseIntro); + _events.ScheduleEvent(GunshipEvents.IntroH2, 16000, 0, GunshipMiscData.PhaseIntro); + _events.ScheduleEvent(GunshipEvents.IntroSummonSkybreaker, 24600, 0, GunshipMiscData.PhaseIntro); + _events.ScheduleEvent(GunshipEvents.IntroH3, 29600, 0, GunshipMiscData.PhaseIntro); + _events.ScheduleEvent(GunshipEvents.IntroH4, 39200, 0, GunshipMiscData.PhaseIntro); + } + + public override void DamageTaken(Unit u, ref uint damage) + { + if (me.HealthBelowPctDamaged(65, damage) && !me.HasAura(GunshipSpells.TasteOfBlood)) + DoCast(me, GunshipSpells.TasteOfBlood, true); + + if (damage > me.GetHealth()) + damage = (uint)me.GetHealth() - 1; + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim() && !_events.IsInPhase(GunshipMiscData.PhaseIntro) && _instance.GetBossState(Bosses.GunshipBattle) != EncounterState.InProgress) + return; + + _events.Update(diff); + + _events.ExecuteEvents(eventId => { - _instance = creature.GetInstanceScript(); - - _controller.ResetSlots(Team.Horde); - _controller.SetTransport(creature.GetTransport()); - me.setRegeneratingHealth(false); - me.m_CombatDistance = 70.0f; - } - - public override void InitializeAI() - { - base.InitializeAI(); - - _events.Reset(); - _firstMageCooldown = Time.UnixTime + 60; - _axethrowersYellCooldown = 0L; - _rocketeersYellCooldown = 0L; - } - - public override void EnterCombat(Unit target) - { - _events.SetPhase(GunshipMiscData.PhaseCombat); - DoCast(me, _instance.GetData(DataTypes.TeamInInstance) == (uint)Team.Horde ? GunshipSpells.FriendlyBossDamageMod : GunshipSpells.MeleeTargetingOnOrgrimsHammer, true); - DoCast(me, GunshipSpells.BattleFury, true); - _events.ScheduleEvent(GunshipEvents.Cleave, RandomHelper.URand(2000, 10000)); - } - - public override void EnterEvadeMode(EvadeReason why) - { - if (!me.IsAlive()) - return; - - me.DeleteThreatList(); - me.CombatStop(true); - me.GetMotionMaster().MoveTargetedHome(); - - Reset(); - } - - public override void DoAction(int action) - { - if (action == Actions.EnemyGunshipTalk) + switch (eventId) { - Creature muradin = me.FindNearestCreature(CreatureIds.IGBMuradinBrozebeard, 100.0f); - if (muradin) - muradin.GetAI().DoAction(EncounterActions.SpawnAllAdds); - - Talk(GunshipTexts.SaySaurfangIntro5); - _events.ScheduleEvent(GunshipEvents.IntroH5, 4000); - _events.ScheduleEvent(GunshipEvents.IntroH6, 11000); - _events.ScheduleEvent(GunshipEvents.KeepPlayerInCombat, 1); - - _instance.SetBossState(Bosses.GunshipBattle, EncounterState.InProgress); - // Combat starts now - Creature skybreaker = me.FindNearestCreature(CreatureIds.TheSkybreaker, 100.0f); - if (skybreaker) - _instance.SendEncounterUnit(EncounterFrameType.Engage, skybreaker, 1); - - Creature orgrimsHammer = me.FindNearestCreature(CreatureIds.OrgrimsHammer, 100.0f); - if (orgrimsHammer) - { - _instance.SendEncounterUnit(EncounterFrameType.Engage, orgrimsHammer, 2); - orgrimsHammer.CastSpell(orgrimsHammer, GunshipSpells.CheckForPlayers, TriggerCastFlags.FullMask); - } - - me.GetMap().SetZoneMusic(AreaIds.IcecrownCitadel, GunshipMiscData.MusicEncounter); - } - else if (action == EncounterActions.SpawnMage) - { - long now = Time.UnixTime; - if (_firstMageCooldown > now) - _events.ScheduleEvent(GunshipEvents.SummonMage, (uint)(_firstMageCooldown - now) * Time.InMilliseconds); - else - _events.ScheduleEvent(GunshipEvents.SummonMage, 1); - } - else if (action == EncounterActions.SpawnAllAdds) - { - _events.ScheduleEvent(GunshipEvents.Adds, 12000); - _events.ScheduleEvent(GunshipEvents.CheckRifleman, 13000); - _events.ScheduleEvent(GunshipEvents.CheckMortar, 13000); - if (Is25ManRaid()) - _controller.SummonCreatures(PassengerSlots.Mage1, PassengerSlots.Mortar4); - else - { + case GunshipEvents.IntroH1: + Talk(GunshipTexts.SaySaurfangIntro1); + break; + case GunshipEvents.IntroH2: + Talk(GunshipTexts.SaySaurfangIntro2); + break; + case GunshipEvents.IntroSummonSkybreaker: + Global.TransportMgr.CreateTransport(GameObjectIds.TheSkybreaker_H, 0, me.GetMap()); + break; + case GunshipEvents.IntroH3: + Talk(GunshipTexts.SaySaurfangIntro3); + break; + case GunshipEvents.IntroH4: + Talk(GunshipTexts.SaySaurfangIntro4); + break; + case GunshipEvents.IntroH5: + Creature muradin = me.FindNearestCreature(CreatureIds.IGBMuradinBrozebeard, 100.0f); + if (muradin) + muradin.GetAI().Talk(GunshipTexts.SayMuradinIntroH); + break; + case GunshipEvents.IntroH6: + Talk(GunshipTexts.SaySaurfangIntro6); + break; + case GunshipEvents.KeepPlayerInCombat: + if (_instance.GetBossState(Bosses.GunshipBattle) == EncounterState.InProgress) + { + _instance.DoCastSpellOnPlayers(GunshipSpells.LockPlayersAndTapChest); + _events.ScheduleEvent(GunshipEvents.KeepPlayerInCombat, RandomHelper.URand(5000, 8000)); + } + break; + case GunshipEvents.SummonMage: + Talk(GunshipTexts.SaySaurfangMages); + _controller.SummonCreatures(PassengerSlots.FreezeMage, PassengerSlots.FreezeMage); + break; + case GunshipEvents.Adds: + Talk(GunshipTexts.SaySaurfangEnterSkybreaker); _controller.SummonCreatures(PassengerSlots.Mage1, PassengerSlots.Mage2); - _controller.SummonCreatures(PassengerSlots.Mortar1, PassengerSlots.Mortar2); - _controller.SummonCreatures(PassengerSlots.Rifleman1, PassengerSlots.Rifleman4); - } - } - else if (action == Actions.ExitShip) - { - Position pos = new Position(GunshipMiscData.SaurfangExitPath[GunshipMiscData.SaurfangExitPathSize - 1].X, GunshipMiscData.SaurfangExitPath[GunshipMiscData.SaurfangExitPathSize - 1].Y, GunshipMiscData.SaurfangExitPath[GunshipMiscData.SaurfangExitPathSize - 1].Z); - me.GetMotionMaster().MovePoint(EventId.ChargePrepath, pos, false); + _controller.SummonCreatures(PassengerSlots.Marine1, Is25ManRaid() ? PassengerSlots.Marine4 : PassengerSlots.Marine2); + _controller.SummonCreatures(PassengerSlots.Sergeant1, Is25ManRaid() ? PassengerSlots.Sergeant2 : PassengerSlots.Sergeant1); + Transport orgrimsHammer = me.GetTransport(); + if (orgrimsHammer) + orgrimsHammer.SummonPassenger(CreatureIds.TeleportPortal, GunshipMiscData.OrgrimsHammerTeleportPortal, TempSummonType.TimedDespawn, null, 21000); - var path = GunshipMiscData.SaurfangExitPath;//, SaurfangExitPath + SaurfangExitPathSize); + Transport skybreaker = Global.ObjAccessor.FindTransport(_instance.GetGuidData(Bosses.GunshipBattle)); + if (skybreaker) + skybreaker.SummonPassenger(CreatureIds.TeleportExit, GunshipMiscData.SkybreakerTeleportExit, TempSummonType.TimedDespawn, null, 23000); - MoveSplineInit init = new MoveSplineInit(me); - init.DisableTransportPathTransformations(); - init.MovebyPath(path, 0); - init.Launch(); - - me.DespawnOrUnsummon(18000); - } - } - - public override void SetData(uint type, uint data) - { - if (type == EncounterActions.ClearSlot) - { - _controller.ClearSlot((PassengerSlots)data); - if (data == (uint)PassengerSlots.FreezeMage) - _events.ScheduleEvent(GunshipEvents.SummonMage, RandomHelper.URand(30000, 33500)); - } - } - - public override void sGossipSelect(Player player, uint menuId, uint gossipListId) - { - me.RemoveFlag64(UnitFields.NpcFlags, NPCFlags.Gossip); - me.GetTransport().EnableMovement(true); - _events.SetPhase(GunshipMiscData.PhaseIntro); - _events.ScheduleEvent(GunshipEvents.IntroH1, 5000, 0, GunshipMiscData.PhaseIntro); - _events.ScheduleEvent(GunshipEvents.IntroH2, 16000, 0, GunshipMiscData.PhaseIntro); - _events.ScheduleEvent(GunshipEvents.IntroSummonSkybreaker, 24600, 0, GunshipMiscData.PhaseIntro); - _events.ScheduleEvent(GunshipEvents.IntroH3, 29600, 0, GunshipMiscData.PhaseIntro); - _events.ScheduleEvent(GunshipEvents.IntroH4, 39200, 0, GunshipMiscData.PhaseIntro); - } - - public override void DamageTaken(Unit u, ref uint damage) - { - if (me.HealthBelowPctDamaged(65, damage) && !me.HasAura(GunshipSpells.TasteOfBlood)) - DoCast(me, GunshipSpells.TasteOfBlood, true); - - if (damage > me.GetHealth()) - damage = (uint)me.GetHealth() - 1; - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim() && !_events.IsInPhase(GunshipMiscData.PhaseIntro) && _instance.GetBossState(Bosses.GunshipBattle) != EncounterState.InProgress) - return; - - _events.Update(diff); - - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case GunshipEvents.IntroH1: - Talk(GunshipTexts.SaySaurfangIntro1); - break; - case GunshipEvents.IntroH2: - Talk(GunshipTexts.SaySaurfangIntro2); - break; - case GunshipEvents.IntroSummonSkybreaker: - Global.TransportMgr.CreateTransport(GameObjectIds.TheSkybreaker_H, 0, me.GetMap()); - break; - case GunshipEvents.IntroH3: - Talk(GunshipTexts.SaySaurfangIntro3); - break; - case GunshipEvents.IntroH4: - Talk(GunshipTexts.SaySaurfangIntro4); - break; - case GunshipEvents.IntroH5: - Creature muradin = me.FindNearestCreature(CreatureIds.IGBMuradinBrozebeard, 100.0f); - if (muradin) - muradin.GetAI().Talk(GunshipTexts.SayMuradinIntroH); - break; - case GunshipEvents.IntroH6: - Talk(GunshipTexts.SaySaurfangIntro6); - break; - case GunshipEvents.KeepPlayerInCombat: - if (_instance.GetBossState(Bosses.GunshipBattle) == EncounterState.InProgress) + _events.ScheduleEvent(GunshipEvents.AddsBoardYell, 6000); + _events.ScheduleEvent(GunshipEvents.Adds, 60000); + break; + case GunshipEvents.AddsBoardYell: + muradin = me.FindNearestCreature(CreatureIds.IGBMuradinBrozebeard, 200.0f); + if (muradin) + muradin.GetAI().Talk(GunshipTexts.SayMuradinBoard); + break; + case GunshipEvents.CheckRifleman: + if (_controller.SummonCreatures(PassengerSlots.Rifleman1, Is25ManRaid() ? PassengerSlots.Rifleman8 : PassengerSlots.Rifleman4)) + { + if (_axethrowersYellCooldown < Time.UnixTime) { - _instance.DoCastSpellOnPlayers(GunshipSpells.LockPlayersAndTapChest); - _events.ScheduleEvent(GunshipEvents.KeepPlayerInCombat, RandomHelper.URand(5000, 8000)); + Talk(GunshipTexts.SaySaurfangAxethrowers); + _axethrowersYellCooldown = Time.UnixTime + 5; } - break; - case GunshipEvents.SummonMage: - Talk(GunshipTexts.SaySaurfangMages); - _controller.SummonCreatures(PassengerSlots.FreezeMage, PassengerSlots.FreezeMage); - break; - case GunshipEvents.Adds: - Talk(GunshipTexts.SaySaurfangEnterSkybreaker); - _controller.SummonCreatures(PassengerSlots.Mage1, PassengerSlots.Mage2); - _controller.SummonCreatures(PassengerSlots.Marine1, Is25ManRaid() ? PassengerSlots.Marine4 : PassengerSlots.Marine2); - _controller.SummonCreatures(PassengerSlots.Sergeant1, Is25ManRaid() ? PassengerSlots.Sergeant2 : PassengerSlots.Sergeant1); - Transport orgrimsHammer = me.GetTransport(); - if (orgrimsHammer) - orgrimsHammer.SummonPassenger(CreatureIds.TeleportPortal, GunshipMiscData.OrgrimsHammerTeleportPortal, TempSummonType.TimedDespawn, null, 21000); - - Transport skybreaker = Global.ObjAccessor.FindTransport(_instance.GetGuidData(Bosses.GunshipBattle)); - if (skybreaker) - skybreaker.SummonPassenger(CreatureIds.TeleportExit, GunshipMiscData.SkybreakerTeleportExit, TempSummonType.TimedDespawn, null, 23000); - - _events.ScheduleEvent(GunshipEvents.AddsBoardYell, 6000); - _events.ScheduleEvent(GunshipEvents.Adds, 60000); - break; - case GunshipEvents.AddsBoardYell: - muradin = me.FindNearestCreature(CreatureIds.IGBMuradinBrozebeard, 200.0f); - if (muradin) - muradin.GetAI().Talk(GunshipTexts.SayMuradinBoard); - break; - case GunshipEvents.CheckRifleman: - if (_controller.SummonCreatures(PassengerSlots.Rifleman1, Is25ManRaid() ? PassengerSlots.Rifleman8 : PassengerSlots.Rifleman4)) + } + _events.ScheduleEvent(GunshipEvents.CheckRifleman, 1000); + break; + case GunshipEvents.CheckMortar: + if (_controller.SummonCreatures(PassengerSlots.Mortar1, Is25ManRaid() ? PassengerSlots.Mortar4 : PassengerSlots.Mortar2)) + { + if (_rocketeersYellCooldown < Time.UnixTime) { - if (_axethrowersYellCooldown < Time.UnixTime) - { - Talk(GunshipTexts.SaySaurfangAxethrowers); - _axethrowersYellCooldown = Time.UnixTime + 5; - } + Talk(GunshipTexts.SaySaurfangRocketeers); + _rocketeersYellCooldown = Time.UnixTime + 5; } - _events.ScheduleEvent(GunshipEvents.CheckRifleman, 1000); - break; - case GunshipEvents.CheckMortar: - if (_controller.SummonCreatures(PassengerSlots.Mortar1, Is25ManRaid() ? PassengerSlots.Mortar4 : PassengerSlots.Mortar2)) - { - if (_rocketeersYellCooldown < Time.UnixTime) - { - Talk(GunshipTexts.SaySaurfangRocketeers); - _rocketeersYellCooldown = Time.UnixTime + 5; - } - } - _events.ScheduleEvent(GunshipEvents.CheckMortar, 1000); - break; - case GunshipEvents.Cleave: - DoCastVictim(GunshipSpells.Cleave); - _events.ScheduleEvent(GunshipEvents.Cleave, RandomHelper.URand(2000, 10000)); - break; - default: - break; - } - }); - - if (me.IsWithinMeleeRange(me.GetVictim())) - DoMeleeAttackIfReady(); - else if (me.isAttackReady()) - { - DoCastVictim(GunshipSpells.RendingThrow); - me.resetAttackTimer(); + } + _events.ScheduleEvent(GunshipEvents.CheckMortar, 1000); + break; + case GunshipEvents.Cleave: + DoCastVictim(GunshipSpells.Cleave); + _events.ScheduleEvent(GunshipEvents.Cleave, RandomHelper.URand(2000, 10000)); + break; + default: + break; } - } + }); - public override bool CanAIAttack(Unit target) + if (me.IsWithinMeleeRange(me.GetVictim())) + DoMeleeAttackIfReady(); + else if (me.isAttackReady()) { - return target.HasAura(GunshipSpells.OnOrgrimsHammerDeck) || !target.IsControlledByPlayer(); + DoCastVictim(GunshipSpells.RendingThrow); + me.resetAttackTimer(); } - - PassengerController _controller = new PassengerController(); - InstanceScript _instance; - long _firstMageCooldown; - long _axethrowersYellCooldown; - long _rocketeersYellCooldown; } - public override CreatureAI GetAI(Creature creature) + public override bool CanAIAttack(Unit target) { - return InstanceIcecrownCitadel.GetInstanceAI(creature); + return target.HasAura(GunshipSpells.OnOrgrimsHammerDeck) || !target.IsControlledByPlayer(); } + + PassengerController _controller = new PassengerController(); + InstanceScript _instance; + long _firstMageCooldown; + long _axethrowersYellCooldown; + long _rocketeersYellCooldown; } [Script] - class npc_muradin_bronzebeard_igb : CreatureScript + class npc_muradin_bronzebeard_igb : ScriptedAI { - public npc_muradin_bronzebeard_igb() : base("npc_muradin_bronzebeard_igb") { } - - class npc_muradin_bronzebeard_igbAI : ScriptedAI + public npc_muradin_bronzebeard_igb(Creature creature) + : base(creature) { - public npc_muradin_bronzebeard_igbAI(Creature creature) - : base(creature) + _instance = creature.GetInstanceScript(); + + _controller.ResetSlots(Team.Alliance); + _controller.SetTransport(creature.GetTransport()); + me.setRegeneratingHealth(false); + me.m_CombatDistance = 70.0f; + } + + public override void InitializeAI() + { + base.InitializeAI(); + + _events.Reset(); + _firstMageCooldown = Time.UnixTime + 60; + _riflemanYellCooldown = 0L; + _mortarYellCooldown = 0L; + } + + public override void EnterCombat(Unit target) + { + _events.SetPhase(GunshipMiscData.PhaseCombat); + DoCast(me, _instance.GetData(DataTypes.TeamInInstance) == (uint)Team.Alliance ? GunshipSpells.FriendlyBossDamageMod : GunshipSpells.MeleeTargetingOnSkybreaker, true); + DoCast(me, GunshipSpells.BattleFury, true); + _events.ScheduleEvent(GunshipEvents.Cleave, RandomHelper.URand(2000, 10000)); + } + + public override void EnterEvadeMode(EvadeReason why) + { + if (!me.IsAlive()) + return; + + me.DeleteThreatList(); + me.CombatStop(true); + me.GetMotionMaster().MoveTargetedHome(); + + Reset(); + } + + public override void DoAction(int action) + { + if (action == Actions.EnemyGunshipTalk) { - _instance = creature.GetInstanceScript(); + Creature muradin = me.FindNearestCreature(CreatureIds.IGBHighOverlordSaurfang, 100.0f); + if (muradin) + muradin.GetAI().DoAction(EncounterActions.SpawnAllAdds); - _controller.ResetSlots(Team.Alliance); - _controller.SetTransport(creature.GetTransport()); - me.setRegeneratingHealth(false); - me.m_CombatDistance = 70.0f; - } + Talk(GunshipTexts.SayMuradinIntro6); + _events.ScheduleEvent(GunshipEvents.IntroA6, 5000); + _events.ScheduleEvent(GunshipEvents.IntroA7, 11000); + _events.ScheduleEvent(GunshipEvents.KeepPlayerInCombat, 1); - public override void InitializeAI() - { - base.InitializeAI(); + _instance.SetBossState(Bosses.GunshipBattle, EncounterState.InProgress); + // Combat starts now + Creature orgrimsHammer = me.FindNearestCreature(CreatureIds.OrgrimsHammer, 100.0f); + if (orgrimsHammer) + _instance.SendEncounterUnit(EncounterFrameType.Engage, orgrimsHammer, 1); - _events.Reset(); - _firstMageCooldown = Time.UnixTime + 60; - _riflemanYellCooldown = 0L; - _mortarYellCooldown = 0L; - } - - public override void EnterCombat(Unit target) - { - _events.SetPhase(GunshipMiscData.PhaseCombat); - DoCast(me, _instance.GetData(DataTypes.TeamInInstance) == (uint)Team.Alliance ? GunshipSpells.FriendlyBossDamageMod : GunshipSpells.MeleeTargetingOnSkybreaker, true); - DoCast(me, GunshipSpells.BattleFury, true); - _events.ScheduleEvent(GunshipEvents.Cleave, RandomHelper.URand(2000, 10000)); - } - - public override void EnterEvadeMode(EvadeReason why) - { - if (!me.IsAlive()) - return; - - me.DeleteThreatList(); - me.CombatStop(true); - me.GetMotionMaster().MoveTargetedHome(); - - Reset(); - } - - public override void DoAction(int action) - { - if (action == Actions.EnemyGunshipTalk) + Creature skybreaker = me.FindNearestCreature(CreatureIds.TheSkybreaker, 100.0f); + if (skybreaker) { - Creature muradin = me.FindNearestCreature(CreatureIds.IGBHighOverlordSaurfang, 100.0f); - if (muradin) - muradin.GetAI().DoAction(EncounterActions.SpawnAllAdds); - - Talk(GunshipTexts.SayMuradinIntro6); - _events.ScheduleEvent(GunshipEvents.IntroA6, 5000); - _events.ScheduleEvent(GunshipEvents.IntroA7, 11000); - _events.ScheduleEvent(GunshipEvents.KeepPlayerInCombat, 1); - - _instance.SetBossState(Bosses.GunshipBattle, EncounterState.InProgress); - // Combat starts now - Creature orgrimsHammer = me.FindNearestCreature(CreatureIds.OrgrimsHammer, 100.0f); - if (orgrimsHammer) - _instance.SendEncounterUnit(EncounterFrameType.Engage, orgrimsHammer, 1); - - Creature skybreaker = me.FindNearestCreature(CreatureIds.TheSkybreaker, 100.0f); - if (skybreaker) - { - _instance.SendEncounterUnit(EncounterFrameType.Engage, skybreaker, 2); - skybreaker.CastSpell(skybreaker, GunshipSpells.CheckForPlayers, TriggerCastFlags.FullMask); - } - - me.GetMap().SetZoneMusic(AreaIds.IcecrownCitadel, GunshipMiscData.MusicEncounter); + _instance.SendEncounterUnit(EncounterFrameType.Engage, skybreaker, 2); + skybreaker.CastSpell(skybreaker, GunshipSpells.CheckForPlayers, TriggerCastFlags.FullMask); } - else if (action == EncounterActions.SpawnMage) + + me.GetMap().SetZoneMusic(AreaIds.IcecrownCitadel, GunshipMiscData.MusicEncounter); + } + else if (action == EncounterActions.SpawnMage) + { + long now = Time.UnixTime; + if (_firstMageCooldown < now) + _events.ScheduleEvent(GunshipEvents.SummonMage, (uint)(now - _firstMageCooldown) * Time.InMilliseconds); + else + _events.ScheduleEvent(GunshipEvents.SummonMage, 1); + } + else if (action == EncounterActions.SpawnAllAdds) + { + _events.ScheduleEvent(GunshipEvents.Adds, 12000); + _events.ScheduleEvent(GunshipEvents.CheckRifleman, 13000); + _events.ScheduleEvent(GunshipEvents.CheckMortar, 13000); + if (Is25ManRaid()) + _controller.SummonCreatures(PassengerSlots.Mage1, PassengerSlots.Mortar4); + else { - long now = Time.UnixTime; - if (_firstMageCooldown < now) - _events.ScheduleEvent(GunshipEvents.SummonMage, (uint)(now - _firstMageCooldown) * Time.InMilliseconds); - else - _events.ScheduleEvent(GunshipEvents.SummonMage, 1); + _controller.SummonCreatures(PassengerSlots.Mage1, PassengerSlots.Mage2); + _controller.SummonCreatures(PassengerSlots.Mortar1, PassengerSlots.Mortar2); + _controller.SummonCreatures(PassengerSlots.Rifleman1, PassengerSlots.Rifleman4); } - else if (action == EncounterActions.SpawnAllAdds) + } + } + + public override void SetData(uint type, uint data) + { + if (type == EncounterActions.ClearSlot) + { + _controller.ClearSlot((PassengerSlots)data); + if (data == (uint)PassengerSlots.FreezeMage) + _events.ScheduleEvent(GunshipEvents.SummonMage, RandomHelper.URand(30000, 33500)); + } + } + + public override void sGossipSelect(Player player, uint menuId, uint gossipListId) + { + me.RemoveFlag64(UnitFields.NpcFlags, NPCFlags.Gossip); + me.GetTransport().EnableMovement(true); + _events.SetPhase(GunshipMiscData.PhaseIntro); + _events.ScheduleEvent(GunshipEvents.IntroA1, 5000); + _events.ScheduleEvent(GunshipEvents.IntroA2, 10000, 0, GunshipMiscData.PhaseIntro); + _events.ScheduleEvent(GunshipEvents.IntroSummonOrgrimsHammer, 28000, 0, GunshipMiscData.PhaseIntro); + _events.ScheduleEvent(GunshipEvents.IntroA3, 33000, 0, GunshipMiscData.PhaseIntro); + _events.ScheduleEvent(GunshipEvents.IntroA4, 39000, 0, GunshipMiscData.PhaseIntro); + _events.ScheduleEvent(GunshipEvents.IntroA5, 45000, 0, GunshipMiscData.PhaseIntro); + } + + public override void DamageTaken(Unit u, ref uint damage) + { + if (me.HealthBelowPctDamaged(65, damage) && me.HasAura(GunshipSpells.TasteOfBlood)) + DoCast(me, GunshipSpells.TasteOfBlood, true); + + if (damage >= me.GetHealth()) + damage = (uint)me.GetHealth() - 1; + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim() && !_events.IsInPhase(GunshipMiscData.PhaseIntro) && _instance.GetBossState(Bosses.GunshipBattle) != EncounterState.InProgress) + return; + + _events.Update(diff); + + _events.ExecuteEvents(eventId => + { + switch (eventId) { - _events.ScheduleEvent(GunshipEvents.Adds, 12000); - _events.ScheduleEvent(GunshipEvents.CheckRifleman, 13000); - _events.ScheduleEvent(GunshipEvents.CheckMortar, 13000); - if (Is25ManRaid()) - _controller.SummonCreatures(PassengerSlots.Mage1, PassengerSlots.Mortar4); - else - { + case GunshipEvents.IntroA1: + Talk(GunshipTexts.SayMuradinIntro1); + break; + case GunshipEvents.IntroA2: + Talk(GunshipTexts.SayMuradinIntro2); + break; + case GunshipEvents.IntroSummonOrgrimsHammer: + Global.TransportMgr.CreateTransport(GameObjectIds.OrgrimsHammer_A, 0, me.GetMap()); + break; + case GunshipEvents.IntroA3: + Talk(GunshipTexts.SayMuradinIntro3); + break; + case GunshipEvents.IntroA4: + Talk(GunshipTexts.SayMuradinIntro4); + break; + case GunshipEvents.IntroA5: + Talk(GunshipTexts.SayMuradinIntro5); + break; + case GunshipEvents.IntroA6: + Creature saurfang = me.FindNearestCreature(CreatureIds.IGBHighOverlordSaurfang, 100.0f); + if (saurfang) + saurfang.GetAI().Talk(GunshipTexts.SaySaurfangIntroA); + break; + case GunshipEvents.IntroA7: + Talk(GunshipTexts.SayMuradinIntro7); + break; + case GunshipEvents.KeepPlayerInCombat: + if (_instance.GetBossState(Bosses.GunshipBattle) == EncounterState.InProgress) + { + _instance.DoCastSpellOnPlayers(GunshipSpells.LockPlayersAndTapChest); + _events.ScheduleEvent(GunshipEvents.KeepPlayerInCombat, RandomHelper.URand(5000, 8000)); + } + break; + case GunshipEvents.SummonMage: + Talk(GunshipTexts.SayMuradinSorcerers); + _controller.SummonCreatures(PassengerSlots.FreezeMage, PassengerSlots.FreezeMage); + break; + case GunshipEvents.Adds: + Talk(GunshipTexts.SayMuradinEnterOrgrimmsHammer); _controller.SummonCreatures(PassengerSlots.Mage1, PassengerSlots.Mage2); - _controller.SummonCreatures(PassengerSlots.Mortar1, PassengerSlots.Mortar2); - _controller.SummonCreatures(PassengerSlots.Rifleman1, PassengerSlots.Rifleman4); - } - } - } + _controller.SummonCreatures(PassengerSlots.Marine1, Is25ManRaid() ? PassengerSlots.Marine4 : PassengerSlots.Marine2); + _controller.SummonCreatures(PassengerSlots.Sergeant1, Is25ManRaid() ? PassengerSlots.Sergeant2 : PassengerSlots.Sergeant1); - public override void SetData(uint type, uint data) - { - if (type == EncounterActions.ClearSlot) - { - _controller.ClearSlot((PassengerSlots)data); - if (data == (uint)PassengerSlots.FreezeMage) - _events.ScheduleEvent(GunshipEvents.SummonMage, RandomHelper.URand(30000, 33500)); - } - } + Transport skybreaker = me.GetTransport(); + if (skybreaker) + skybreaker.SummonPassenger(CreatureIds.TeleportPortal, GunshipMiscData.SkybreakerTeleportPortal, TempSummonType.TimedDespawn, null, 21000); - public override void sGossipSelect(Player player, uint menuId, uint gossipListId) - { - me.RemoveFlag64(UnitFields.NpcFlags, NPCFlags.Gossip); - me.GetTransport().EnableMovement(true); - _events.SetPhase(GunshipMiscData.PhaseIntro); - _events.ScheduleEvent(GunshipEvents.IntroA1, 5000); - _events.ScheduleEvent(GunshipEvents.IntroA2, 10000, 0, GunshipMiscData.PhaseIntro); - _events.ScheduleEvent(GunshipEvents.IntroSummonOrgrimsHammer, 28000, 0, GunshipMiscData.PhaseIntro); - _events.ScheduleEvent(GunshipEvents.IntroA3, 33000, 0, GunshipMiscData.PhaseIntro); - _events.ScheduleEvent(GunshipEvents.IntroA4, 39000, 0, GunshipMiscData.PhaseIntro); - _events.ScheduleEvent(GunshipEvents.IntroA5, 45000, 0, GunshipMiscData.PhaseIntro); - } + Transport go = Global.ObjAccessor.FindTransport(_instance.GetGuidData(Bosses.GunshipBattle)); + if (go) + go.SummonPassenger(CreatureIds.TeleportExit, GunshipMiscData.OrgrimsHammerTeleportExit, TempSummonType.TimedDespawn, null, 23000); - public override void DamageTaken(Unit u, ref uint damage) - { - if (me.HealthBelowPctDamaged(65, damage) && me.HasAura(GunshipSpells.TasteOfBlood)) - DoCast(me, GunshipSpells.TasteOfBlood, true); - - if (damage >= me.GetHealth()) - damage = (uint)me.GetHealth() - 1; - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim() && !_events.IsInPhase(GunshipMiscData.PhaseIntro) && _instance.GetBossState(Bosses.GunshipBattle) != EncounterState.InProgress) - return; - - _events.Update(diff); - - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case GunshipEvents.IntroA1: - Talk(GunshipTexts.SayMuradinIntro1); - break; - case GunshipEvents.IntroA2: - Talk(GunshipTexts.SayMuradinIntro2); - break; - case GunshipEvents.IntroSummonOrgrimsHammer: - Global.TransportMgr.CreateTransport(GameObjectIds.OrgrimsHammer_A, 0, me.GetMap()); - break; - case GunshipEvents.IntroA3: - Talk(GunshipTexts.SayMuradinIntro3); - break; - case GunshipEvents.IntroA4: - Talk(GunshipTexts.SayMuradinIntro4); - break; - case GunshipEvents.IntroA5: - Talk(GunshipTexts.SayMuradinIntro5); - break; - case GunshipEvents.IntroA6: - Creature saurfang = me.FindNearestCreature(CreatureIds.IGBHighOverlordSaurfang, 100.0f); - if (saurfang) - saurfang.GetAI().Talk(GunshipTexts.SaySaurfangIntroA); - break; - case GunshipEvents.IntroA7: - Talk(GunshipTexts.SayMuradinIntro7); - break; - case GunshipEvents.KeepPlayerInCombat: - if (_instance.GetBossState(Bosses.GunshipBattle) == EncounterState.InProgress) + _events.ScheduleEvent(GunshipEvents.AddsBoardYell, 6000); + _events.ScheduleEvent(GunshipEvents.Adds, 60000); + break; + case GunshipEvents.AddsBoardYell: + saurfang = me.FindNearestCreature(CreatureIds.IGBHighOverlordSaurfang, 200.0f); + if (saurfang) + saurfang.GetAI().Talk(GunshipTexts.SaySaurfangBoard); + break; + case GunshipEvents.CheckRifleman: + if (_controller.SummonCreatures(PassengerSlots.Rifleman1, Is25ManRaid() ? PassengerSlots.Rifleman8 : PassengerSlots.Rifleman4)) + { + if (_riflemanYellCooldown < Time.UnixTime) { - _instance.DoCastSpellOnPlayers(GunshipSpells.LockPlayersAndTapChest); - _events.ScheduleEvent(GunshipEvents.KeepPlayerInCombat, RandomHelper.URand(5000, 8000)); + Talk(GunshipTexts.SayMuradinRifleman); + _riflemanYellCooldown = Time.UnixTime + 5; } - break; - case GunshipEvents.SummonMage: - Talk(GunshipTexts.SayMuradinSorcerers); - _controller.SummonCreatures(PassengerSlots.FreezeMage, PassengerSlots.FreezeMage); - break; - case GunshipEvents.Adds: - Talk(GunshipTexts.SayMuradinEnterOrgrimmsHammer); - _controller.SummonCreatures(PassengerSlots.Mage1, PassengerSlots.Mage2); - _controller.SummonCreatures(PassengerSlots.Marine1, Is25ManRaid() ? PassengerSlots.Marine4 : PassengerSlots.Marine2); - _controller.SummonCreatures(PassengerSlots.Sergeant1, Is25ManRaid() ? PassengerSlots.Sergeant2 : PassengerSlots.Sergeant1); - - Transport skybreaker = me.GetTransport(); - if (skybreaker) - skybreaker.SummonPassenger(CreatureIds.TeleportPortal, GunshipMiscData.SkybreakerTeleportPortal, TempSummonType.TimedDespawn, null, 21000); - - Transport go = Global.ObjAccessor.FindTransport(_instance.GetGuidData(Bosses.GunshipBattle)); - if (go) - go.SummonPassenger(CreatureIds.TeleportExit, GunshipMiscData.OrgrimsHammerTeleportExit, TempSummonType.TimedDespawn, null, 23000); - - _events.ScheduleEvent(GunshipEvents.AddsBoardYell, 6000); - _events.ScheduleEvent(GunshipEvents.Adds, 60000); - break; - case GunshipEvents.AddsBoardYell: - saurfang = me.FindNearestCreature(CreatureIds.IGBHighOverlordSaurfang, 200.0f); - if (saurfang) - saurfang.GetAI().Talk(GunshipTexts.SaySaurfangBoard); - break; - case GunshipEvents.CheckRifleman: - if (_controller.SummonCreatures(PassengerSlots.Rifleman1, Is25ManRaid() ? PassengerSlots.Rifleman8 : PassengerSlots.Rifleman4)) + } + _events.ScheduleEvent(GunshipEvents.CheckRifleman, 1000); + break; + case GunshipEvents.CheckMortar: + if (_controller.SummonCreatures(PassengerSlots.Mortar1, Is25ManRaid() ? PassengerSlots.Mortar4 : PassengerSlots.Mortar2)) + { + if (_mortarYellCooldown < Time.UnixTime) { - if (_riflemanYellCooldown < Time.UnixTime) - { - Talk(GunshipTexts.SayMuradinRifleman); - _riflemanYellCooldown = Time.UnixTime + 5; - } + Talk(GunshipTexts.SayMuradinMortar); + _mortarYellCooldown = Time.UnixTime + 5; } - _events.ScheduleEvent(GunshipEvents.CheckRifleman, 1000); - break; - case GunshipEvents.CheckMortar: - if (_controller.SummonCreatures(PassengerSlots.Mortar1, Is25ManRaid() ? PassengerSlots.Mortar4 : PassengerSlots.Mortar2)) - { - if (_mortarYellCooldown < Time.UnixTime) - { - Talk(GunshipTexts.SayMuradinMortar); - _mortarYellCooldown = Time.UnixTime + 5; - } - } - _events.ScheduleEvent(GunshipEvents.CheckMortar, 1000); - break; - case GunshipEvents.Cleave: - DoCastVictim(GunshipSpells.Cleave); - _events.ScheduleEvent(GunshipEvents.Cleave, RandomHelper.URand(2000, 10000)); - break; - default: - break; - } - }); - - if (me.IsWithinMeleeRange(me.GetVictim())) - DoMeleeAttackIfReady(); - else if (me.isAttackReady()) - { - DoCastVictim(GunshipSpells.RendingThrow); - me.resetAttackTimer(); + } + _events.ScheduleEvent(GunshipEvents.CheckMortar, 1000); + break; + case GunshipEvents.Cleave: + DoCastVictim(GunshipSpells.Cleave); + _events.ScheduleEvent(GunshipEvents.Cleave, RandomHelper.URand(2000, 10000)); + break; + default: + break; } - } + }); - public override bool CanAIAttack(Unit target) + if (me.IsWithinMeleeRange(me.GetVictim())) + DoMeleeAttackIfReady(); + else if (me.isAttackReady()) { - if (_instance.GetBossState(Bosses.GunshipBattle) != EncounterState.InProgress) - return false; - - return target.HasAura(GunshipSpells.OnSkybreakerDeck) || !target.IsControlledByPlayer(); + DoCastVictim(GunshipSpells.RendingThrow); + me.resetAttackTimer(); } - - PassengerController _controller = new PassengerController(); - InstanceScript _instance; - long _firstMageCooldown; - long _riflemanYellCooldown; - long _mortarYellCooldown; } - public override CreatureAI GetAI(Creature creature) + public override bool CanAIAttack(Unit target) { - return InstanceIcecrownCitadel.GetInstanceAI(creature); + if (_instance.GetBossState(Bosses.GunshipBattle) != EncounterState.InProgress) + return false; + + return target.HasAura(GunshipSpells.OnSkybreakerDeck) || !target.IsControlledByPlayer(); } + + PassengerController _controller = new PassengerController(); + InstanceScript _instance; + long _firstMageCooldown; + long _riflemanYellCooldown; + long _mortarYellCooldown; } [Script] - class npc_zafod_boombox : CreatureScript + class npc_zafod_boombox : gunship_npc_AI { - public npc_zafod_boombox() : base("npc_zafod_boombox") { } + public npc_zafod_boombox(Creature creature) + : base(creature) { } - class npc_zafod_boomboxAI : gunship_npc_AI + public override void Reset() { - public npc_zafod_boomboxAI(Creature creature) - : base(creature) { } - - public override void Reset() - { - me.SetReactState(ReactStates.Passive); - } - - public override void sGossipSelect(Player player, uint menuId, uint gossipListId) - { - player.AddItem(GunshipMiscData.ItemGoblinRocketPack, 1); - player.PlayerTalkClass.SendCloseGossip(); - } - - public override void UpdateAI(uint diff) - { - UpdateVictim(); - } + me.SetReactState(ReactStates.Passive); } - public override CreatureAI GetAI(Creature creature) + public override void sGossipSelect(Player player, uint menuId, uint gossipListId) { - return InstanceIcecrownCitadel.GetInstanceAI(creature); + player.AddItem(GunshipMiscData.ItemGoblinRocketPack, 1); + player.PlayerTalkClass.SendCloseGossip(); + } + + public override void UpdateAI(uint diff) + { + UpdateVictim(); } } @@ -1546,899 +1502,667 @@ namespace Scripts.Northrend.IcecrownCitadel } [Script] - class npc_gunship_boarding_leader : CreatureScript + class npc_gunship_boarding_leader : npc_gunship_boarding_addAI { - public npc_gunship_boarding_leader() : base("npc_gunship_boarding_leader") { } + public npc_gunship_boarding_leader(Creature creature) + : base(creature) { } - class npc_gunship_boarding_leaderAI : npc_gunship_boarding_addAI + public override void EnterCombat(Unit target) { - public npc_gunship_boarding_leaderAI(Creature creature) - : base(creature) { } + base.EnterCombat(target); + _events.ScheduleEvent(GunshipEvents.Bladestorm, RandomHelper.URand(13000, 18000)); + _events.ScheduleEvent(GunshipEvents.WoundingStrike, RandomHelper.URand(8000, 10000)); + } - public override void EnterCombat(Unit target) + public override void UpdateAI(uint diff) + { + if (!SelectVictim()) { - base.EnterCombat(target); - _events.ScheduleEvent(GunshipEvents.Bladestorm, RandomHelper.URand(13000, 18000)); - _events.ScheduleEvent(GunshipEvents.WoundingStrike, RandomHelper.URand(8000, 10000)); + TriggerBurningPitch(); + return; } - public override void UpdateAI(uint diff) + _events.Update(diff); + + if (me.HasUnitState(UnitState.Casting) || me.HasAura(GunshipSpells.Bladestorm)) + return; + + if (!HasAttackablePlayerNearby()) + TriggerBurningPitch(); + + _events.ExecuteEvents(eventId => { - if (!SelectVictim()) + switch (eventId) { - TriggerBurningPitch(); - return; + case GunshipEvents.Bladestorm: + DoCastAOE(GunshipSpells.Bladestorm); + _events.ScheduleEvent(GunshipEvents.Bladestorm, RandomHelper.URand(25000, 30000)); + break; + case GunshipEvents.WoundingStrike: + DoCastVictim(GunshipSpells.WoundingStrike); + _events.ScheduleEvent(GunshipEvents.WoundingStrike, RandomHelper.URand(9000, 13000)); + break; + default: + break; + } + }); + + DoMeleeAttackIfReady(); + } + } + + [Script] + [Script] + class npc_gunship_gunner : gunship_npc_AI + { + public npc_gunship_gunner(Creature creature) + : base(creature) + { + creature.m_CombatDistance = 200.0f; + } + + public override void AttackStart(Unit target) + { + me.Attack(target, false); + } + + public override void MovementInform(MovementGeneratorType type, uint id) + { + base.MovementInform(type, id); + if (type == MovementGeneratorType.Point && id == EventId.ChargePrepath) + me.SetControlled(true, UnitState.Root); + } + + public override void UpdateAI(uint diff) + { + if (!SelectVictim()) + { + TriggerBurningPitch(); + return; + } + + DoSpellAttackIfReady(me.GetEntry() == CreatureIds.SkybreakerRifleman ? GunshipSpells.Shoot : GunshipSpells.HurlAxe); + } + } + + [Script] + class npc_gunship_rocketeer : gunship_npc_AI + { + public npc_gunship_rocketeer(Creature creature) : base(creature) + { + creature.m_CombatDistance = 200.0f; + } + + public override void MovementInform(MovementGeneratorType type, uint id) + { + base.MovementInform(type, id); + if (type == MovementGeneratorType.Point && id == EventId.ChargePrepath) + me.SetControlled(true, UnitState.Root); + } + + public override void UpdateAI(uint diff) + { + if (!SelectVictim()) + return; + + if (me.HasUnitState(UnitState.Casting)) + return; + + uint spellId = me.GetEntry() == CreatureIds.SkybreakerMortarSoldier ? GunshipSpells.RocketArtilleryA : GunshipSpells.RocketArtilleryH; + if (me.GetSpellHistory().HasCooldown(spellId)) + return; + + DoCastAOE(spellId, true); + me.GetSpellHistory().AddCooldown(spellId, 0, TimeSpan.FromSeconds(9)); + } + } + + [Script] + class npc_gunship_mage : gunship_npc_AI + { + public npc_gunship_mage(Creature creature) : base(creature) + { + me.SetReactState(ReactStates.Passive); + } + + public override void EnterEvadeMode(EvadeReason why) { } + + public override void MovementInform(MovementGeneratorType type, uint id) + { + if (type != MovementGeneratorType.Point) + return; + + if (id == EventId.ChargePrepath && Slot != null) + { + SlotInfo[] slots = Instance.GetData(DataTypes.TeamInInstance) == (uint)Team.Horde ? GunshipMiscData.SkybreakerSlotInfo : GunshipMiscData.OrgrimsHammerSlotInfo; + me.SetFacingTo(slots[Index].TargetPosition.GetOrientation()); + switch ((PassengerSlots)Index) + { + case PassengerSlots.FreezeMage: + DoCastAOE(GunshipSpells.BelowZero); + break; + case PassengerSlots.Mage1: + case PassengerSlots.Mage2: + DoCastAOE(GunshipSpells.ShadowChanneling); + break; + default: + break; } - _events.Update(diff); - - if (me.HasUnitState(UnitState.Casting) || me.HasAura(GunshipSpells.Bladestorm)) - return; - - if (!HasAttackablePlayerNearby()) - TriggerBurningPitch(); - - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case GunshipEvents.Bladestorm: - DoCastAOE(GunshipSpells.Bladestorm); - _events.ScheduleEvent(GunshipEvents.Bladestorm, RandomHelper.URand(25000, 30000)); - break; - case GunshipEvents.WoundingStrike: - DoCastVictim(GunshipSpells.WoundingStrike); - _events.ScheduleEvent(GunshipEvents.WoundingStrike, RandomHelper.URand(9000, 13000)); - break; - default: - break; - } - }); - - DoMeleeAttackIfReady(); + me.SetControlled(true, UnitState.Root); } } - public override CreatureAI GetAI(Creature creature) + public override void UpdateAI(uint diff) { - return InstanceIcecrownCitadel.GetInstanceAI(creature); - } - } - - [Script] - class npc_gunship_boarding_add : CreatureScript - { - public npc_gunship_boarding_add() : base("npc_gunship_boarding_add") { } - - public override CreatureAI GetAI(Creature creature) - { - return InstanceIcecrownCitadel.GetInstanceAI(creature); - } - } - - [Script] - class npc_gunship_gunner : CreatureScript - { - public npc_gunship_gunner() : base("npc_gunship_gunner") { } - - class npc_gunship_gunnerAI : gunship_npc_AI - { - public npc_gunship_gunnerAI(Creature creature) - : base(creature) - { - creature.m_CombatDistance = 200.0f; - } - - public override void AttackStart(Unit target) - { - me.Attack(target, false); - } - - public override void MovementInform(MovementGeneratorType type, uint id) - { - base.MovementInform(type, id); - if (type == MovementGeneratorType.Point && id == EventId.ChargePrepath) - me.SetControlled(true, UnitState.Root); - } - - public override void UpdateAI(uint diff) - { - if (!SelectVictim()) - { - TriggerBurningPitch(); - return; - } - - DoSpellAttackIfReady(me.GetEntry() == CreatureIds.SkybreakerRifleman ? GunshipSpells.Shoot : GunshipSpells.HurlAxe); - } + UpdateVictim(); } - public override CreatureAI GetAI(Creature creature) + public override bool CanAIAttack(Unit target) { - return InstanceIcecrownCitadel.GetInstanceAI(creature); - } - } - - [Script] - class npc_gunship_rocketeer : CreatureScript - { - public npc_gunship_rocketeer() : base("npc_gunship_rocketeer") { } - - class npc_gunship_rocketeerAI : gunship_npc_AI - { - public npc_gunship_rocketeerAI(Creature creature) - : base(creature) - { - creature.m_CombatDistance = 200.0f; - } - - public override void MovementInform(MovementGeneratorType type, uint id) - { - base.MovementInform(type, id); - if (type == MovementGeneratorType.Point && id == EventId.ChargePrepath) - me.SetControlled(true, UnitState.Root); - } - - public override void UpdateAI(uint diff) - { - if (!SelectVictim()) - return; - - if (me.HasUnitState(UnitState.Casting)) - return; - - uint spellId = me.GetEntry() == CreatureIds.SkybreakerMortarSoldier ? GunshipSpells.RocketArtilleryA : GunshipSpells.RocketArtilleryH; - if (me.GetSpellHistory().HasCooldown(spellId)) - return; - - DoCastAOE(spellId, true); - me.GetSpellHistory().AddCooldown(spellId, 0, TimeSpan.FromSeconds(9)); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return InstanceIcecrownCitadel.GetInstanceAI(creature); - } - } - - [Script] - class npc_gunship_mage : CreatureScript - { - public npc_gunship_mage() : base("npc_gunship_mage") { } - - class npc_gunship_mageAI : gunship_npc_AI - { - public npc_gunship_mageAI(Creature creature) : base(creature) - { - me.SetReactState(ReactStates.Passive); - } - - public override void EnterEvadeMode(EvadeReason why) { } - - public override void MovementInform(MovementGeneratorType type, uint id) - { - if (type != MovementGeneratorType.Point) - return; - - if (id == EventId.ChargePrepath && Slot != null) - { - SlotInfo[] slots = Instance.GetData(DataTypes.TeamInInstance) == (uint)Team.Horde ? GunshipMiscData.SkybreakerSlotInfo : GunshipMiscData.OrgrimsHammerSlotInfo; - me.SetFacingTo(slots[Index].TargetPosition.GetOrientation()); - switch ((PassengerSlots)Index) - { - case PassengerSlots.FreezeMage: - DoCastAOE(GunshipSpells.BelowZero); - break; - case PassengerSlots.Mage1: - case PassengerSlots.Mage2: - DoCastAOE(GunshipSpells.ShadowChanneling); - break; - default: - break; - } - - me.SetControlled(true, UnitState.Root); - } - } - - public override void UpdateAI(uint diff) - { - UpdateVictim(); - } - - public override bool CanAIAttack(Unit target) - { - return true; - } - } - - public override CreatureAI GetAI(Creature creature) - { - return InstanceIcecrownCitadel.GetInstanceAI(creature); + return true; } } /** @HACK This AI only resets MOVEMENTFLAG_ROOT on the vehicle. - Currently the core always removes MOVEMENTFLAG_ROOT sent from client packets to prevent cheaters from freezing clients of other players - but it actually is a valid flag - needs more research to fix both freezes and keep the flag as is (see WorldSession.ReadMovementInfo) + Currently the core always removes MOVEMENTFLAG_ROOT sent from client packets to prevent cheaters from freezing clients of other players + but it actually is a valid flag - needs more research to fix both freezes and keep the flag as is (see WorldSession.ReadMovementInfo) - Example packet: - ClientToServer: CMSG_FORCE_MOVE_ROOT_ACK (0x00E9) Length: 67 ConnectionIndex: 0 Time: 03/04/2010 03:57:55.000 Number: 471326 - Guid: - Movement Counter: 80 - Movement Flags: OnTransport, Root (2560) - Extra Movement Flags: None (0) - Time: 52291611 - Position: X: -396.0302 Y: 2482.906 Z: 249.86 - Orientation: 1.468665 - Transport GUID: Full: 0x1FC0000000000460 Type: MOTransport Low: 1120 - Transport Position: X: -6.152398 Y: -23.49037 Z: 21.64464 O: 4.827727 - Transport Time: 9926 - Transport Seat: 255 - Fall Time: 824 - */ +Example packet: +ClientToServer: CMSG_FORCE_MOVE_ROOT_ACK (0x00E9) Length: 67 ConnectionIndex: 0 Time: 03/04/2010 03:57:55.000 Number: 471326 +Guid: +Movement Counter: 80 +Movement Flags: OnTransport, Root (2560) +Extra Movement Flags: None (0) +Time: 52291611 +Position: X: -396.0302 Y: 2482.906 Z: 249.86 +Orientation: 1.468665 +Transport GUID: Full: 0x1FC0000000000460 Type: MOTransport Low: 1120 +Transport Position: X: -6.152398 Y: -23.49037 Z: 21.64464 O: 4.827727 +Transport Time: 9926 +Transport Seat: 255 +Fall Time: 824 +*/ [Script] - class npc_gunship_cannon : CreatureScript + class npc_gunship_cannon : PassiveAI { - public npc_gunship_cannon() : base("npc_gunship_cannon") { } + public npc_gunship_cannon(Creature creature) + : base(creature) { } - class npc_gunship_cannonAI : PassiveAI + public override void OnCharmed(bool apply) { } + + public override void PassengerBoarded(Unit passenger, sbyte seat, bool apply) { - public npc_gunship_cannonAI(Creature creature) - : base(creature) { } - - public override void OnCharmed(bool apply) { } - - public override void PassengerBoarded(Unit passenger, sbyte seat, bool apply) + if (!apply) { - if (!apply) - { - me.SetControlled(false, UnitState.Root); - me.SetControlled(true, UnitState.Root); - } + me.SetControlled(false, UnitState.Root); + me.SetControlled(true, UnitState.Root); } } - - public override CreatureAI GetAI(Creature creature) - { - return new npc_gunship_cannonAI(creature); - } } [Script] - class spell_igb_rocket_pack : SpellScriptLoader + class spell_igb_rocket_pack : AuraScript { - public spell_igb_rocket_pack() : base("spell_igb_rocket_pack") { } - - class spell_igb_rocket_pack_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(GunshipSpells.RocketPackDamage, GunshipSpells.RocketBurst); - } - - void HandlePeriodic(AuraEffect aurEff) - { - if (GetTarget().moveSpline.Finalized()) - Remove(AuraRemoveMode.Expire); - } - - void HandleRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - SpellInfo damageInfo = Global.SpellMgr.GetSpellInfo(GunshipSpells.RocketPackDamage); - GetTarget().CastCustomSpell(GunshipSpells.RocketPackDamage, SpellValueMod.BasePoint0, (int)(2 * (damageInfo.GetEffect(0).CalcValue() + aurEff.GetTickNumber() * aurEff.GetPeriod())), null, TriggerCastFlags.FullMask); - GetTarget().CastSpell(null, GunshipSpells.RocketBurst, TriggerCastFlags.FullMask); - } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandlePeriodic, 0, AuraType.PeriodicDummy)); - OnEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.Real)); - } + return ValidateSpellInfo(GunshipSpells.RocketPackDamage, GunshipSpells.RocketBurst); } - public override AuraScript GetAuraScript() + void HandlePeriodic(AuraEffect aurEff) { - return new spell_igb_rocket_pack_AuraScript(); + if (GetTarget().moveSpline.Finalized()) + Remove(AuraRemoveMode.Expire); + } + + void HandleRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + SpellInfo damageInfo = Global.SpellMgr.GetSpellInfo(GunshipSpells.RocketPackDamage); + GetTarget().CastCustomSpell(GunshipSpells.RocketPackDamage, SpellValueMod.BasePoint0, (int)(2 * (damageInfo.GetEffect(0).CalcValue() + aurEff.GetTickNumber() * aurEff.GetPeriod())), null, TriggerCastFlags.FullMask); + GetTarget().CastSpell(null, GunshipSpells.RocketBurst, TriggerCastFlags.FullMask); + } + + public override void Register() + { + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandlePeriodic, 0, AuraType.PeriodicDummy)); + OnEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.Real)); } } [Script] - class spell_igb_rocket_pack_useable : SpellScriptLoader + class spell_igb_rocket_pack_useable : AuraScript { - public spell_igb_rocket_pack_useable() : base("spell_igb_rocket_pack_useable") { } - - class spell_igb_rocket_pack_useable_AuraScript : AuraScript + public override bool Load() { - public override bool Load() - { - return GetOwner().GetInstanceScript() != null; - } + return GetOwner().GetInstanceScript() != null; + } - bool CheckAreaTarget(Unit target) - { - return target.IsTypeId(TypeId.Player) && GetOwner().GetInstanceScript().GetBossState(Bosses.GunshipBattle) != EncounterState.Done; - } + bool CheckAreaTarget(Unit target) + { + return target.IsTypeId(TypeId.Player) && GetOwner().GetInstanceScript().GetBossState(Bosses.GunshipBattle) != EncounterState.Done; + } - void HandleApply(AuraEffect aurEff, AuraEffectHandleModes mode) + void HandleApply(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Creature owner = GetOwner().ToCreature(); + if (owner) { - Creature owner = GetOwner().ToCreature(); - if (owner) - { - Player target = GetTarget().ToPlayer(); - if (target) - if (target.HasItemCount(GunshipMiscData.ItemGoblinRocketPack, 1)) - Global.CreatureTextMgr.SendChat(owner, GunshipTexts.SayZafodRocketPackActive, target, ChatMsg.Addon, Language.Addon, CreatureTextRange.Normal, 0, Team.Other, false, target); - } - } - - void HandleRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Creature owner = GetOwner().ToCreature(); - if (owner) - { - Player target = GetTarget().ToPlayer(); - if (target) - if (target.HasItemCount(GunshipMiscData.ItemGoblinRocketPack, 1)) - Global.CreatureTextMgr.SendChat(owner, GunshipTexts.SayZafodRocketPackDisabled, target, ChatMsg.Addon, Language.Addon, CreatureTextRange.Normal, 0, Team.Other, false, target); - } - } - - public override void Register() - { - DoCheckAreaTarget.Add(new CheckAreaTargetHandler(CheckAreaTarget)); - AfterEffectApply.Add(new EffectApplyHandler(HandleApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - AfterEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + Player target = GetTarget().ToPlayer(); + if (target) + if (target.HasItemCount(GunshipMiscData.ItemGoblinRocketPack, 1)) + Global.CreatureTextMgr.SendChat(owner, GunshipTexts.SayZafodRocketPackActive, target, ChatMsg.Addon, Language.Addon, CreatureTextRange.Normal, 0, Team.Other, false, target); } } - public override AuraScript GetAuraScript() + void HandleRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_igb_rocket_pack_useable_AuraScript(); + Creature owner = GetOwner().ToCreature(); + if (owner) + { + Player target = GetTarget().ToPlayer(); + if (target) + if (target.HasItemCount(GunshipMiscData.ItemGoblinRocketPack, 1)) + Global.CreatureTextMgr.SendChat(owner, GunshipTexts.SayZafodRocketPackDisabled, target, ChatMsg.Addon, Language.Addon, CreatureTextRange.Normal, 0, Team.Other, false, target); + } + } + + public override void Register() + { + DoCheckAreaTarget.Add(new CheckAreaTargetHandler(CheckAreaTarget)); + AfterEffectApply.Add(new EffectApplyHandler(HandleApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } [Script] - class spell_igb_on_gunship_deck : SpellScriptLoader + class spell_igb_on_gunship_deck : AuraScript { - public spell_igb_on_gunship_deck() : base("spell_igb_on_gunship_deck") { } - - class spell_igb_on_gunship_deck_AuraScript : AuraScript + public override bool Load() { - public override bool Load() - { - InstanceScript instance = GetOwner().GetInstanceScript(); - if (instance != null) - _teamInInstance = (Team)instance.GetData(DataTypes.TeamInInstance); - else - _teamInInstance = 0; - return true; - } - - bool CheckAreaTarget(Unit unit) - { - return unit.IsTypeId(TypeId.Player); - } - - void HandleApply(AuraEffect aurEff, AuraEffectHandleModes mode) - { - if (GetSpellInfo().Id == (_teamInInstance == Team.Horde ? GunshipSpells.OnSkybreakerDeck : GunshipSpells.OnOrgrimsHammerDeck)) - { - Creature gunship = GetOwner().FindNearestCreature(_teamInInstance == Team.Horde ? CreatureIds.OrgrimsHammer : CreatureIds.TheSkybreaker, 200.0f); - if (gunship) - gunship.GetAI().SetGUID(GetTarget().GetGUID(), EncounterActions.ShipVisits); - } - } - - public override void Register() - { - DoCheckAreaTarget.Add(new CheckAreaTargetHandler(CheckAreaTarget)); - AfterEffectApply.Add(new EffectApplyHandler(HandleApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - } - - Team _teamInInstance; + InstanceScript instance = GetOwner().GetInstanceScript(); + if (instance != null) + _teamInInstance = (Team)instance.GetData(DataTypes.TeamInInstance); + else + _teamInInstance = 0; + return true; } - public override AuraScript GetAuraScript() + bool CheckAreaTarget(Unit unit) { - return new spell_igb_on_gunship_deck_AuraScript(); + return unit.IsTypeId(TypeId.Player); + } + + void HandleApply(AuraEffect aurEff, AuraEffectHandleModes mode) + { + if (GetSpellInfo().Id == (_teamInInstance == Team.Horde ? GunshipSpells.OnSkybreakerDeck : GunshipSpells.OnOrgrimsHammerDeck)) + { + Creature gunship = GetOwner().FindNearestCreature(_teamInInstance == Team.Horde ? CreatureIds.OrgrimsHammer : CreatureIds.TheSkybreaker, 200.0f); + if (gunship) + gunship.GetAI().SetGUID(GetTarget().GetGUID(), EncounterActions.ShipVisits); + } + } + + public override void Register() + { + DoCheckAreaTarget.Add(new CheckAreaTargetHandler(CheckAreaTarget)); + AfterEffectApply.Add(new EffectApplyHandler(HandleApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + } + + Team _teamInInstance; + } + + [Script] + class spell_igb_periodic_trigger_with_power_cost : AuraScript + { + void HandlePeriodicTick(AuraEffect aurEff) + { + PreventDefaultAction(); + GetTarget().CastSpell(GetTarget(), GetSpellInfo().GetEffect(0).TriggerSpell, (TriggerCastFlags.FullMask & ~TriggerCastFlags.IgnorePowerAndReagentCost)); + } + + public override void Register() + { + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandlePeriodicTick, 0, AuraType.PeriodicTriggerSpell)); } } [Script] - class spell_igb_periodic_trigger_with_power_cost : SpellScriptLoader + class spell_igb_cannon_blast : SpellScript { - public spell_igb_periodic_trigger_with_power_cost() : base("spell_igb_periodic_trigger_with_power_cost") { } - - class spell_igb_periodic_trigger_with_power_cost_AuraScript : AuraScript + public override bool Load() { - void HandlePeriodicTick(AuraEffect aurEff) - { - PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), GetSpellInfo().GetEffect(0).TriggerSpell, (TriggerCastFlags.FullMask & ~TriggerCastFlags.IgnorePowerAndReagentCost)); - } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandlePeriodicTick, 0, AuraType.PeriodicTriggerSpell)); - } + return GetCaster().IsTypeId(TypeId.Unit); } - public override AuraScript GetAuraScript() + void CheckEnergy() { - return new spell_igb_periodic_trigger_with_power_cost_AuraScript(); - } - } - - [Script] - class spell_igb_cannon_blast : SpellScriptLoader - { - public spell_igb_cannon_blast() : base("spell_igb_cannon_blast") { } - - class spell_igb_cannon_blast_SpellScript : SpellScript - { - public override bool Load() + if (GetCaster().GetPower(PowerType.Energy) >= 100) { - return GetCaster().IsTypeId(TypeId.Unit); - } - - void CheckEnergy() - { - if (GetCaster().GetPower(PowerType.Energy) >= 100) - { - GetCaster().CastSpell(GetCaster(), GunshipSpells.Overheat, TriggerCastFlags.FullMask); - Vehicle vehicle = GetCaster().GetVehicleKit(); - if (vehicle) - { - Unit passenger = vehicle.GetPassenger(0); - if (passenger) - Global.CreatureTextMgr.SendChat(GetCaster().ToCreature(), GunshipTexts.SayOverheat, passenger); - } - } - } - - public override void Register() - { - AfterHit.Add(new HitHandler(CheckEnergy)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_igb_cannon_blast_SpellScript(); - } - } - - [Script] - class spell_igb_incinerating_blast : SpellScriptLoader - { - public spell_igb_incinerating_blast() : base("spell_igb_incinerating_blast") { } - - class spell_igb_incinerating_blast_SpellScript : SpellScript - { - void StoreEnergy() - { - _energyLeft = (uint)GetCaster().GetPower(PowerType.Energy) - 10; - } - - void RemoveEnergy() - { - GetCaster().SetPower(PowerType.Energy, 0); - } - - void CalculateDamage(uint effIndex) - { - SetEffectValue((int)(GetEffectValue() + _energyLeft * _energyLeft * 8)); - } - - public override void Register() - { - OnCast.Add(new CastHandler(StoreEnergy)); - AfterCast.Add(new CastHandler(RemoveEnergy)); - OnEffectLaunchTarget.Add(new EffectHandler(CalculateDamage, 1, SpellEffectName.SchoolDamage)); - } - - uint _energyLeft; - } - - public override SpellScript GetSpellScript() - { - return new spell_igb_incinerating_blast_SpellScript(); - } - } - - [Script] - class spell_igb_overheat : SpellScriptLoader - { - public spell_igb_overheat() : base("spell_igb_overheat") { } - - class spell_igb_overheat_AuraScript : AuraScript - { - public override bool Load() - { - if (GetAura().GetAuraType() != AuraObjectType.Unit) - return false; - return GetUnitOwner().IsVehicle(); - } - - void SendClientControl(bool value) - { - Vehicle vehicle = GetUnitOwner().GetVehicleKit(); + GetCaster().CastSpell(GetCaster(), GunshipSpells.Overheat, TriggerCastFlags.FullMask); + Vehicle vehicle = GetCaster().GetVehicleKit(); if (vehicle) { Unit passenger = vehicle.GetPassenger(0); if (passenger) + Global.CreatureTextMgr.SendChat(GetCaster().ToCreature(), GunshipTexts.SayOverheat, passenger); + } + } + } + + public override void Register() + { + AfterHit.Add(new HitHandler(CheckEnergy)); + } + } + + [Script] + class spell_igb_incinerating_blast : SpellScript + { + void StoreEnergy() + { + _energyLeft = (uint)GetCaster().GetPower(PowerType.Energy) - 10; + } + + void RemoveEnergy() + { + GetCaster().SetPower(PowerType.Energy, 0); + } + + void CalculateDamage(uint effIndex) + { + SetEffectValue((int)(GetEffectValue() + _energyLeft * _energyLeft * 8)); + } + + public override void Register() + { + OnCast.Add(new CastHandler(StoreEnergy)); + AfterCast.Add(new CastHandler(RemoveEnergy)); + OnEffectLaunchTarget.Add(new EffectHandler(CalculateDamage, 1, SpellEffectName.SchoolDamage)); + } + + uint _energyLeft; + } + + [Script] + class spell_igb_overheat : AuraScript + { + public override bool Load() + { + if (GetAura().GetAuraType() != AuraObjectType.Unit) + return false; + return GetUnitOwner().IsVehicle(); + } + + void SendClientControl(bool value) + { + Vehicle vehicle = GetUnitOwner().GetVehicleKit(); + if (vehicle) + { + Unit passenger = vehicle.GetPassenger(0); + if (passenger) + { + Player player = passenger.ToPlayer(); + if (player) { - Player player = passenger.ToPlayer(); - if (player) - { - ControlUpdate data = new ControlUpdate(); - data.Guid = GetUnitOwner().GetGUID(); - data.On = value; - player.SendPacket(data); - } + ControlUpdate data = new ControlUpdate(); + data.Guid = GetUnitOwner().GetGUID(); + data.On = value; + player.SendPacket(data); } } } - - void HandleApply(AuraEffect aurEff, AuraEffectHandleModes mode) - { - SendClientControl(false); - } - - void HandleRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - SendClientControl(true); - } - - public override void Register() - { - AfterEffectApply.Add(new EffectApplyHandler(HandleApply, 0, AuraType.PeriodicTriggerSpell, AuraEffectHandleModes.Real)); - AfterEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.PeriodicTriggerSpell, AuraEffectHandleModes.Real)); - } } - public override AuraScript GetAuraScript() + void HandleApply(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_igb_overheat_AuraScript(); + SendClientControl(false); + } + + void HandleRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + SendClientControl(true); + } + + public override void Register() + { + AfterEffectApply.Add(new EffectApplyHandler(HandleApply, 0, AuraType.PeriodicTriggerSpell, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.PeriodicTriggerSpell, AuraEffectHandleModes.Real)); } } [Script] - class spell_igb_below_zero : SpellScriptLoader + class spell_igb_below_zero : SpellScript { - public spell_igb_below_zero() : base("spell_igb_below_zero") { } - - class spell_igb_below_zero_SpellScript : SpellScript + void RemovePassengers(SpellMissInfo missInfo) { - void RemovePassengers(SpellMissInfo missInfo) - { - if (missInfo != SpellMissInfo.None) - return; + if (missInfo != SpellMissInfo.None) + return; - GetHitUnit().CastSpell(GetHitUnit(), GunshipSpells.EjectAllPassengersBelowZero, TriggerCastFlags.FullMask); - } - - public override void Register() - { - BeforeHit.Add(new BeforeHitHandler(RemovePassengers)); - } + GetHitUnit().CastSpell(GetHitUnit(), GunshipSpells.EjectAllPassengersBelowZero, TriggerCastFlags.FullMask); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_igb_below_zero_SpellScript(); + BeforeHit.Add(new BeforeHitHandler(RemovePassengers)); } } [Script] - class spell_igb_teleport_to_enemy_ship : SpellScriptLoader + class spell_igb_teleport_to_enemy_ship : SpellScript { - public spell_igb_teleport_to_enemy_ship() : base("spell_igb_teleport_to_enemy_ship") { } - - class spell_igb_teleport_to_enemy_ship_SpellScript : SpellScript + void RelocateTransportOffset(uint effIndex) { - void RelocateTransportOffset(uint effIndex) - { - Position dest = GetHitDest(); - Unit target = GetHitUnit(); - if (dest == null || !target || !target.GetTransport()) - return; + Position dest = GetHitDest(); + Unit target = GetHitUnit(); + if (dest == null || !target || !target.GetTransport()) + return; - float x, y, z, o; - dest.GetPosition(out x, out y, out z, out o); - target.GetTransport().CalculatePassengerOffset(ref x, ref y, ref z, ref o); - target.m_movementInfo.transport.pos.Relocate(x, y, z, o); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(RelocateTransportOffset, 0, SpellEffectName.TeleportUnitsOld)); - } + float x, y, z, o; + dest.GetPosition(out x, out y, out z, out o); + target.GetTransport().CalculatePassengerOffset(ref x, ref y, ref z, ref o); + target.m_movementInfo.transport.pos.Relocate(x, y, z, o); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_igb_teleport_to_enemy_ship_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(RelocateTransportOffset, 0, SpellEffectName.TeleportUnitsOld)); } } [Script] - class spell_igb_burning_pitch_selector : SpellScriptLoader + class spell_igb_burning_pitch_selector : SpellScript { - public spell_igb_burning_pitch_selector() : base("spell_igb_burning_pitch_selector") { } - - class spell_igb_burning_pitch_selector_SpellScript : SpellScript + void FilterTargets(List targets) { - void FilterTargets(List targets) + Team team = Team.Horde; + InstanceScript instance = GetCaster().GetInstanceScript(); + if (instance != null) + team = (Team)instance.GetData(DataTypes.TeamInInstance); + + targets.RemoveAll(target => { - Team team = Team.Horde; - InstanceScript instance = GetCaster().GetInstanceScript(); - if (instance != null) - team = (Team)instance.GetData(DataTypes.TeamInInstance); + Transport transport = target.GetTransport(); + if (transport) + return transport.GetEntry() != (team == Team.Horde ? GameObjectIds.OrgrimsHammer_H : GameObjectIds.TheSkybreaker_A); + return true; + }); - targets.RemoveAll(target => - { - Transport transport = target.GetTransport(); - if (transport) - return transport.GetEntry() != (team == Team.Horde ? GameObjectIds.OrgrimsHammer_H : GameObjectIds.TheSkybreaker_A); - return true; - }); - - if (!targets.Empty()) - { - WorldObject target = targets.SelectRandom(); - targets.Clear(); - targets.Add(target); - } - } - - void HandleDummy(uint effIndex) + if (!targets.Empty()) { - PreventHitDefaultEffect(effIndex); - GetCaster().CastSpell(GetHitUnit(), (uint)GetEffectValue(), TriggerCastFlags.None); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEntry)); - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + WorldObject target = targets.SelectRandom(); + targets.Clear(); + targets.Add(target); } } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_igb_burning_pitch_selector_SpellScript(); + PreventHitDefaultEffect(effIndex); + GetCaster().CastSpell(GetHitUnit(), (uint)GetEffectValue(), TriggerCastFlags.None); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEntry)); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] - class spell_igb_burning_pitch : SpellScriptLoader + class spell_igb_burning_pitch : SpellScript { - public spell_igb_burning_pitch() : base("spell_igb_burning_pitch") { } - - class spell_igb_burning_pitch_SpellScript : SpellScript + void HandleDummy(uint effIndex) { - void HandleDummy(uint effIndex) - { - PreventHitDefaultEffect(effIndex); - GetCaster().CastCustomSpell((uint)GetEffectValue(), SpellValueMod.BasePoint0, 8000, null, TriggerCastFlags.FullMask); - GetHitUnit().CastSpell(GetHitUnit(), GunshipSpells.BurningPitch, TriggerCastFlags.FullMask); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + PreventHitDefaultEffect(effIndex); + GetCaster().CastCustomSpell((uint)GetEffectValue(), SpellValueMod.BasePoint0, 8000, null, TriggerCastFlags.FullMask); + GetHitUnit().CastSpell(GetHitUnit(), GunshipSpells.BurningPitch, TriggerCastFlags.FullMask); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_igb_burning_pitch_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] - class spell_igb_rocket_artillery : SpellScriptLoader + class spell_igb_rocket_artillery : SpellScript { - public spell_igb_rocket_artillery() : base("spell_igb_rocket_artillery") { } - - class spell_igb_rocket_artillery_SpellScript : SpellScript + void SelectRandomTarget(List targets) { - void SelectRandomTarget(List targets) + if (!targets.Empty()) { - if (!targets.Empty()) - { - WorldObject target = targets.SelectRandom(); - targets.Clear(); - targets.Add(target); - } - } - - void HandleScript(uint effIndex) - { - PreventHitDefaultEffect(effIndex); - GetCaster().CastSpell(GetHitUnit(), (uint)GetEffectValue(), TriggerCastFlags.None); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(SelectRandomTarget, 0, Targets.UnitSrcAreaEntry)); - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + WorldObject target = targets.SelectRandom(); + targets.Clear(); + targets.Add(target); } } - public override SpellScript GetSpellScript() + void HandleScript(uint effIndex) { - return new spell_igb_rocket_artillery_SpellScript(); + PreventHitDefaultEffect(effIndex); + GetCaster().CastSpell(GetHitUnit(), (uint)GetEffectValue(), TriggerCastFlags.None); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(SelectRandomTarget, 0, Targets.UnitSrcAreaEntry)); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] - class spell_igb_rocket_artillery_explosion : SpellScriptLoader + class spell_igb_rocket_artillery_explosion : SpellScript { - public spell_igb_rocket_artillery_explosion() : base("spell_igb_rocket_artillery_explosion") { } - - class spell_igb_rocket_artillery_explosion_SpellScript : SpellScript + void DamageGunship(uint effIndex) { - void DamageGunship(uint effIndex) - { - InstanceScript instance = GetCaster().GetInstanceScript(); - if (instance != null) - GetCaster().CastCustomSpell(instance.GetData(DataTypes.TeamInInstance) == (uint)Team.Horde ? GunshipSpells.BurningPitchDamageH : GunshipSpells.BurningPitchDamageA, SpellValueMod.BasePoint0, 5000, null, TriggerCastFlags.FullMask); - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(DamageGunship, 0, SpellEffectName.TriggerMissile)); - } + InstanceScript instance = GetCaster().GetInstanceScript(); + if (instance != null) + GetCaster().CastCustomSpell(instance.GetData(DataTypes.TeamInInstance) == (uint)Team.Horde ? GunshipSpells.BurningPitchDamageH : GunshipSpells.BurningPitchDamageA, SpellValueMod.BasePoint0, 5000, null, TriggerCastFlags.FullMask); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_igb_rocket_artillery_explosion_SpellScript(); + OnEffectHit.Add(new EffectHandler(DamageGunship, 0, SpellEffectName.TriggerMissile)); } } [Script] - class spell_igb_gunship_fall_teleport : SpellScriptLoader + class spell_igb_gunship_fall_teleport : SpellScript { - public spell_igb_gunship_fall_teleport() : base("spell_igb_gunship_fall_teleport") { } - - class spell_igb_gunship_fall_teleport_SpellScript : SpellScript + public override bool Load() { - public override bool Load() - { - return GetCaster().GetInstanceScript() != null; - } - - void SelectTransport(ref WorldObject target) - { - InstanceScript instance = target.GetInstanceScript(); - if (instance != null) - target = Global.ObjAccessor.FindTransport(instance.GetGuidData(Bosses.GunshipBattle)); - } - - void RelocateDest(uint effIndex) - { - if (GetCaster().GetInstanceScript().GetData(DataTypes.TeamInInstance) == (uint)Team.Horde) - GetHitDest().RelocateOffset(new Position(0.0f, 0.0f, 36.0f, 0.0f)); - else - GetHitDest().RelocateOffset(new Position(0.0f, 0.0f, 21.0f, 0.0f)); - } - - public override void Register() - { - OnObjectTargetSelect.Add(new ObjectTargetSelectHandler(SelectTransport, 0, Targets.DestNearbyEntry)); - OnEffectLaunch.Add(new EffectHandler(RelocateDest, 0, SpellEffectName.TeleportUnitsOld)); - } + return GetCaster().GetInstanceScript() != null; } - public override SpellScript GetSpellScript() + void SelectTransport(ref WorldObject target) { - return new spell_igb_gunship_fall_teleport_SpellScript(); + InstanceScript instance = target.GetInstanceScript(); + if (instance != null) + target = Global.ObjAccessor.FindTransport(instance.GetGuidData(Bosses.GunshipBattle)); + } + + void RelocateDest(uint effIndex) + { + if (GetCaster().GetInstanceScript().GetData(DataTypes.TeamInInstance) == (uint)Team.Horde) + GetHitDest().RelocateOffset(new Position(0.0f, 0.0f, 36.0f, 0.0f)); + else + GetHitDest().RelocateOffset(new Position(0.0f, 0.0f, 21.0f, 0.0f)); + } + + public override void Register() + { + OnObjectTargetSelect.Add(new ObjectTargetSelectHandler(SelectTransport, 0, Targets.DestNearbyEntry)); + OnEffectLaunch.Add(new EffectHandler(RelocateDest, 0, SpellEffectName.TeleportUnitsOld)); } } [Script] - class spell_igb_check_for_players : SpellScriptLoader + class spell_igb_check_for_players : SpellScript { - public spell_igb_check_for_players() : base("spell_igb_check_for_players") { } - - class spell_igb_check_for_players_SpellScript : SpellScript + public override bool Load() { - public override bool Load() - { - _playerCount = 0; - return GetCaster().IsTypeId(TypeId.Unit); - } - - void CountTargets(List targets) - { - _playerCount = (uint)targets.Count; - } - - void TriggerWipe() - { - if (_playerCount == 0) - GetCaster().ToCreature().GetAI().JustDied(null); - } - - void TeleportPlayer(uint effIndex) - { - if (GetHitUnit().GetPositionZ() < GetCaster().GetPositionZ() - 10.0f) - GetHitUnit().CastSpell(GetHitUnit(), GunshipSpells.GunshipFallTeleport, TriggerCastFlags.FullMask); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(CountTargets, 0, Targets.UnitSrcAreaEntry)); - AfterCast.Add(new CastHandler(TriggerWipe)); - OnEffectHitTarget.Add(new EffectHandler(TeleportPlayer, 0, SpellEffectName.Dummy)); - } - - uint _playerCount; + _playerCount = 0; + return GetCaster().IsTypeId(TypeId.Unit); } - public override SpellScript GetSpellScript() + void CountTargets(List targets) { - return new spell_igb_check_for_players_SpellScript(); + _playerCount = (uint)targets.Count; } + + void TriggerWipe() + { + if (_playerCount == 0) + GetCaster().ToCreature().GetAI().JustDied(null); + } + + void TeleportPlayer(uint effIndex) + { + if (GetHitUnit().GetPositionZ() < GetCaster().GetPositionZ() - 10.0f) + GetHitUnit().CastSpell(GetHitUnit(), GunshipSpells.GunshipFallTeleport, TriggerCastFlags.FullMask); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(CountTargets, 0, Targets.UnitSrcAreaEntry)); + AfterCast.Add(new CastHandler(TriggerWipe)); + OnEffectHitTarget.Add(new EffectHandler(TeleportPlayer, 0, SpellEffectName.Dummy)); + } + + uint _playerCount; } [Script] - class spell_igb_teleport_players_on_victory : SpellScriptLoader + class spell_igb_teleport_players_on_victory : SpellScript { - public spell_igb_teleport_players_on_victory() : base("spell_igb_teleport_players_on_victory") { } - - class spell_igb_teleport_players_on_victory_SpellScript : SpellScript + public override bool Load() { - public override bool Load() - { - return GetCaster().GetInstanceScript() != null; - } - - void FilterTargets(List targets) - { - InstanceScript instance = GetCaster().GetInstanceScript(); - targets.RemoveAll(target => target.GetTransGUID() != instance.GetGuidData(DataTypes.EnemyGunship)); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 1, Targets.UnitDestAreaEntry)); - } + return GetCaster().GetInstanceScript() != null; } - public override SpellScript GetSpellScript() + void FilterTargets(List targets) { - return new spell_igb_teleport_players_on_victory_SpellScript(); + InstanceScript instance = GetCaster().GetInstanceScript(); + targets.RemoveAll(target => target.GetTransGUID() != instance.GetGuidData(DataTypes.EnemyGunship)); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 1, Targets.UnitDestAreaEntry)); } } [Script] // 71201 - Battle Experience - proc should never happen, handled in script - class spell_igb_battle_experience_check : SpellScriptLoader + class spell_igb_battle_experience_check : AuraScript { - public spell_igb_battle_experience_check() : base("spell_igb_battle_experience_check") { } - - class spell_igb_battle_experience_check_AuraScript : AuraScript + bool CheckProc(ProcEventInfo eventInfo) { - - bool CheckProc(ProcEventInfo eventInfo) - { - return false; - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - } + return false; } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_igb_battle_experience_check_AuraScript(); + DoCheckProc.Add(new CheckProcHandler(CheckProc)); } } diff --git a/Scripts/Northrend/IcecrownCitadel/IcecrownCitadel.cs b/Scripts/Northrend/IcecrownCitadel/IcecrownCitadel.cs index 051cc0543..3d1cbb107 100644 --- a/Scripts/Northrend/IcecrownCitadel/IcecrownCitadel.cs +++ b/Scripts/Northrend/IcecrownCitadel/IcecrownCitadel.cs @@ -123,347 +123,317 @@ namespace Scripts.Northrend.IcecrownCitadel // at Light's Hammer [Script] - class npc_highlord_tirion_fordring_lh : CreatureScript + class npc_highlord_tirion_fordring : ScriptedAI { - public npc_highlord_tirion_fordring_lh() : base("npc_highlord_tirion_fordring_lh") { } - - class npc_highlord_tirion_fordringAI : ScriptedAI + public npc_highlord_tirion_fordring(Creature creature) + : base(creature) { - public npc_highlord_tirion_fordringAI(Creature creature) - : base(creature) - { - _instance = creature.GetInstanceScript(); - } + _instance = creature.GetInstanceScript(); + } - public override void Reset() - { - _events.Reset(); - _theLichKing.Clear(); - _bolvarFordragon.Clear(); - _factionNPC.Clear(); - _damnedKills = 0; - } + public override void Reset() + { + _events.Reset(); + _theLichKing.Clear(); + _bolvarFordragon.Clear(); + _factionNPC.Clear(); + _damnedKills = 0; + } - // IMPORTANT NOTE: This is triggered from per-GUID scripts - // of The Damned SAI - public override void SetData(uint type, uint data) + // IMPORTANT NOTE: This is triggered from per-GUID scripts + // of The Damned SAI + public override void SetData(uint type, uint data) + { + if (type == 1 && data == 1) { - if (type == 1 && data == 1) + if (++_damnedKills == 2) { - if (++_damnedKills == 2) + Creature theLichKing = me.FindNearestCreature(CreatureIds.TheLichKingLh, 150.0f); + if (theLichKing) { - Creature theLichKing = me.FindNearestCreature(CreatureIds.TheLichKingLh, 150.0f); - if (theLichKing) + Creature bolvarFordragon = me.FindNearestCreature(CreatureIds.HighlordBolvarFordragonLh, 150.0f); + if (bolvarFordragon) { - Creature bolvarFordragon = me.FindNearestCreature(CreatureIds.HighlordBolvarFordragonLh, 150.0f); - if (bolvarFordragon) + Creature factionNPC = me.FindNearestCreature(_instance.GetData(DataTypes.TeamInInstance) == (uint)Team.Horde ? CreatureIds.SeHighOverlordSaurfang : CreatureIds.SeMuradinBronzebeard, 50.0f); + if (factionNPC) { - Creature factionNPC = me.FindNearestCreature(_instance.GetData(DataTypes.TeamInInstance) == (uint)Team.Horde ? CreatureIds.SeHighOverlordSaurfang : CreatureIds.SeMuradinBronzebeard, 50.0f); - if (factionNPC) - { - me.setActive(true); - _theLichKing = theLichKing.GetGUID(); - theLichKing.setActive(true); - _bolvarFordragon = bolvarFordragon.GetGUID(); - bolvarFordragon.setActive(true); - _factionNPC = factionNPC.GetGUID(); - factionNPC.setActive(true); - } + me.setActive(true); + _theLichKing = theLichKing.GetGUID(); + theLichKing.setActive(true); + _bolvarFordragon = bolvarFordragon.GetGUID(); + bolvarFordragon.setActive(true); + _factionNPC = factionNPC.GetGUID(); + factionNPC.setActive(true); } } + } - if (_bolvarFordragon.IsEmpty() || _theLichKing.IsEmpty() || _factionNPC.IsEmpty()) - return; + if (_bolvarFordragon.IsEmpty() || _theLichKing.IsEmpty() || _factionNPC.IsEmpty()) + return; - Talk(Texts.SayTirionIntro1); - _events.ScheduleEvent(EventTypes.TirionIntro2, 4000); - _events.ScheduleEvent(EventTypes.TirionIntro3, 14000); - _events.ScheduleEvent(EventTypes.TirionIntro4, 18000); - _events.ScheduleEvent(EventTypes.TirionIntro5, 31000); - _events.ScheduleEvent(EventTypes.LkIntro1, 35000); - _events.ScheduleEvent(EventTypes.TirionIntro6, 51000); - _events.ScheduleEvent(EventTypes.LkIntro2, 58000); - _events.ScheduleEvent(EventTypes.LkIntro3, 74000); - _events.ScheduleEvent(EventTypes.LkIntro4, 86000); - _events.ScheduleEvent(EventTypes.BolvarIntro1, 100000); - _events.ScheduleEvent(EventTypes.LkIntro5, 108000); + Talk(Texts.SayTirionIntro1); + _events.ScheduleEvent(EventTypes.TirionIntro2, 4000); + _events.ScheduleEvent(EventTypes.TirionIntro3, 14000); + _events.ScheduleEvent(EventTypes.TirionIntro4, 18000); + _events.ScheduleEvent(EventTypes.TirionIntro5, 31000); + _events.ScheduleEvent(EventTypes.LkIntro1, 35000); + _events.ScheduleEvent(EventTypes.TirionIntro6, 51000); + _events.ScheduleEvent(EventTypes.LkIntro2, 58000); + _events.ScheduleEvent(EventTypes.LkIntro3, 74000); + _events.ScheduleEvent(EventTypes.LkIntro4, 86000); + _events.ScheduleEvent(EventTypes.BolvarIntro1, 100000); + _events.ScheduleEvent(EventTypes.LkIntro5, 108000); - if (_instance.GetData(DataTypes.TeamInInstance) == (uint)Team.Horde) - { - _events.ScheduleEvent(EventTypes.SaurfangIntro1, 120000); - _events.ScheduleEvent(EventTypes.TirionIntroH7, 129000); - _events.ScheduleEvent(EventTypes.SaurfangIntro2, 139000); - _events.ScheduleEvent(EventTypes.SaurfangIntro3, 150000); - _events.ScheduleEvent(EventTypes.SaurfangIntro4, 162000); - _events.ScheduleEvent(EventTypes.SaurfangRun, 170000); - } - else - { - _events.ScheduleEvent(EventTypes.MuradinIntro1, 120000); - _events.ScheduleEvent(EventTypes.MuradinIntro2, 124000); - _events.ScheduleEvent(EventTypes.MuradinIntro3, 127000); - _events.ScheduleEvent(EventTypes.TirionIntroA7, 136000); - _events.ScheduleEvent(EventTypes.MuradinIntro4, 144000); - _events.ScheduleEvent(EventTypes.MuradinIntro5, 151000); - _events.ScheduleEvent(EventTypes.MuradinRun, 157000); - } + if (_instance.GetData(DataTypes.TeamInInstance) == (uint)Team.Horde) + { + _events.ScheduleEvent(EventTypes.SaurfangIntro1, 120000); + _events.ScheduleEvent(EventTypes.TirionIntroH7, 129000); + _events.ScheduleEvent(EventTypes.SaurfangIntro2, 139000); + _events.ScheduleEvent(EventTypes.SaurfangIntro3, 150000); + _events.ScheduleEvent(EventTypes.SaurfangIntro4, 162000); + _events.ScheduleEvent(EventTypes.SaurfangRun, 170000); + } + else + { + _events.ScheduleEvent(EventTypes.MuradinIntro1, 120000); + _events.ScheduleEvent(EventTypes.MuradinIntro2, 124000); + _events.ScheduleEvent(EventTypes.MuradinIntro3, 127000); + _events.ScheduleEvent(EventTypes.TirionIntroA7, 136000); + _events.ScheduleEvent(EventTypes.MuradinIntro4, 144000); + _events.ScheduleEvent(EventTypes.MuradinIntro5, 151000); + _events.ScheduleEvent(EventTypes.MuradinRun, 157000); } } } + } - public override void UpdateAI(uint diff) + public override void UpdateAI(uint diff) + { + if (_damnedKills != 2) + return; + + _events.Update(diff); + + _events.ExecuteEvents(eventId => { - if (_damnedKills != 2) - return; + Creature temp; - _events.Update(diff); - - _events.ExecuteEvents(eventId => + switch (eventId) { - Creature temp; - - switch (eventId) - { - case EventTypes.TirionIntro2: - me.HandleEmoteCommand(Emote.OneshotExclamation); - break; - case EventTypes.TirionIntro3: - Talk(Texts.SayTirionIntro2); - break; - case EventTypes.TirionIntro4: - me.HandleEmoteCommand(Emote.OneshotExclamation); - break; - case EventTypes.TirionIntro5: - Talk(Texts.SayTirionIntro3); - break; - case EventTypes.LkIntro1: - me.HandleEmoteCommand(Emote.StateDanceNosheathe); - temp = ObjectAccessor.GetCreature(me, _theLichKing); - if (temp) - temp.GetAI().Talk(Texts.SayLkIntro1); - break; - case EventTypes.TirionIntro6: - Talk(Texts.SayTirionIntro4); - break; - case EventTypes.LkIntro2: - temp = ObjectAccessor.GetCreature(me, _theLichKing); - if (temp) - temp.GetAI().Talk(Texts.SayLkIntro2); - break; - case EventTypes.LkIntro3: - temp = ObjectAccessor.GetCreature(me, _theLichKing); - if (temp) - temp.GetAI().Talk(Texts.SayLkIntro3); - break; - case EventTypes.LkIntro4: - temp = ObjectAccessor.GetCreature(me, _theLichKing); - if (temp) - temp.GetAI().Talk(Texts.SayLkIntro4); - break; - case EventTypes.BolvarIntro1: - temp = ObjectAccessor.GetCreature(me, _bolvarFordragon); - if (temp) - { - temp.GetAI().Talk(Texts.SayBolvarIntro1); - temp.setActive(false); - } - break; - case EventTypes.LkIntro5: - temp = ObjectAccessor.GetCreature(me, _theLichKing); - if (temp) - { - temp.GetAI().Talk(Texts.SayLkIntro5); - temp.setActive(false); - } - break; - case EventTypes.SaurfangIntro1: - temp = ObjectAccessor.GetCreature(me, _factionNPC); - if (temp) - temp.GetAI().Talk(Texts.SaySaurfangIntro1); - break; - case EventTypes.TirionIntroH7: - Talk(Texts.SayTirionIntroH5); - break; - case EventTypes.SaurfangIntro2: - temp = ObjectAccessor.GetCreature(me, _factionNPC); - if (temp) - temp.GetAI().Talk(Texts.SaySaurfangIntro2); - break; - case EventTypes.SaurfangIntro3: - temp = ObjectAccessor.GetCreature(me, _factionNPC); - if (temp) - temp.GetAI().Talk(Texts.SaySaurfangIntro3); - break; - case EventTypes.SaurfangIntro4: - temp = ObjectAccessor.GetCreature(me, _factionNPC); - if (temp) - temp.GetAI().Talk(Texts.SaySaurfangIntro4); - break; - case EventTypes.MuradinRun: - case EventTypes.SaurfangRun: - Creature factionNPC = ObjectAccessor.GetCreature(me, _factionNPC); - if (factionNPC) - factionNPC.GetMotionMaster().MovePath((uint)(factionNPC.GetSpawnId() * 10), false); - me.setActive(false); - _damnedKills = 3; - break; - case EventTypes.MuradinIntro1: - temp = ObjectAccessor.GetCreature(me, _factionNPC); - if (temp) - temp.GetAI().Talk(Texts.SayMuradinIntro1); - break; - case EventTypes.MuradinIntro2: - temp = ObjectAccessor.GetCreature(me, _factionNPC); - if (temp) - temp.HandleEmoteCommand(Emote.OneshotTalk); - break; - case EventTypes.MuradinIntro3: - temp = ObjectAccessor.GetCreature(me, _factionNPC); - if (temp) - temp.HandleEmoteCommand(Emote.OneshotExclamation); - break; - case EventTypes.TirionIntroA7: - Talk(Texts.SayTirionIntroA5); - break; - case EventTypes.MuradinIntro4: - temp = ObjectAccessor.GetCreature(me, _factionNPC); - if (temp) - temp.GetAI().Talk(Texts.SayMuradinIntro2); - break; - case EventTypes.MuradinIntro5: - temp = ObjectAccessor.GetCreature(me, _factionNPC); - if (temp) - temp.GetAI().Talk(Texts.SayMuradinIntro3); - break; - default: - break; - } - }); - } - - InstanceScript _instance; - ObjectGuid _theLichKing; - ObjectGuid _bolvarFordragon; - ObjectGuid _factionNPC; - ushort _damnedKills; - } - - public override CreatureAI GetAI(Creature creature) - { - return InstanceIcecrownCitadel.GetInstanceAI(creature); - } - } - - [Script] - class npc_rotting_frost_giant : CreatureScript - { - public npc_rotting_frost_giant() : base("npc_rotting_frost_giant") { } - - class npc_rotting_frost_giantAI : ScriptedAI - { - public npc_rotting_frost_giantAI(Creature creature) - : base(creature) { } - - public override void Reset() - { - _events.Reset(); - _events.ScheduleEvent(EventTypes.DeathPlague, 15000); - _events.ScheduleEvent(EventTypes.Stomp, RandomHelper.URand(5000, 8000)); - _events.ScheduleEvent(EventTypes.ArcticBreath, RandomHelper.URand(10000, 15000)); - } - - public override void JustDied(Unit killer) - { - _events.Reset(); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _events.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case EventTypes.DeathPlague: - Unit target = SelectTarget(SelectAggroTarget.Random, 1, 0.0f, true); - if (target) - { - Talk(Texts.EmoteDeathPlagueWarning, target); - DoCast(target, InstanceSpells.DeathPlague); - } - _events.ScheduleEvent(EventTypes.DeathPlague, 15000); - break; - case EventTypes.Stomp: - DoCastVictim(InstanceSpells.Stomp); - _events.ScheduleEvent(EventTypes.Stomp, RandomHelper.URand(15000, 18000)); - break; - case EventTypes.ArcticBreath: - DoCastVictim(InstanceSpells.ArcticBreath); - _events.ScheduleEvent(EventTypes.ArcticBreath, RandomHelper.URand(26000, 33000)); - break; - default: - break; - } - }); - - DoMeleeAttackIfReady(); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return InstanceIcecrownCitadel.GetInstanceAI(creature); - } - } - - [Script] - class npc_frost_freeze_trap : CreatureScript - { - public npc_frost_freeze_trap() : base("npc_frost_freeze_trap") { } - - class npc_frost_freeze_trapAI : ScriptedAI - { - public npc_frost_freeze_trapAI(Creature creature) - : base(creature) - { - SetCombatMovement(false); - } - - public override void DoAction(int action) - { - switch (action) - { - case 1000: - case 11000: - _events.ScheduleEvent(EventTypes.ActivateTrap, (uint)action); + case EventTypes.TirionIntro2: + me.HandleEmoteCommand(Emote.OneshotExclamation); + break; + case EventTypes.TirionIntro3: + Talk(Texts.SayTirionIntro2); + break; + case EventTypes.TirionIntro4: + me.HandleEmoteCommand(Emote.OneshotExclamation); + break; + case EventTypes.TirionIntro5: + Talk(Texts.SayTirionIntro3); + break; + case EventTypes.LkIntro1: + me.HandleEmoteCommand(Emote.StateDanceNosheathe); + temp = ObjectAccessor.GetCreature(me, _theLichKing); + if (temp) + temp.GetAI().Talk(Texts.SayLkIntro1); + break; + case EventTypes.TirionIntro6: + Talk(Texts.SayTirionIntro4); + break; + case EventTypes.LkIntro2: + temp = ObjectAccessor.GetCreature(me, _theLichKing); + if (temp) + temp.GetAI().Talk(Texts.SayLkIntro2); + break; + case EventTypes.LkIntro3: + temp = ObjectAccessor.GetCreature(me, _theLichKing); + if (temp) + temp.GetAI().Talk(Texts.SayLkIntro3); + break; + case EventTypes.LkIntro4: + temp = ObjectAccessor.GetCreature(me, _theLichKing); + if (temp) + temp.GetAI().Talk(Texts.SayLkIntro4); + break; + case EventTypes.BolvarIntro1: + temp = ObjectAccessor.GetCreature(me, _bolvarFordragon); + if (temp) + { + temp.GetAI().Talk(Texts.SayBolvarIntro1); + temp.setActive(false); + } + break; + case EventTypes.LkIntro5: + temp = ObjectAccessor.GetCreature(me, _theLichKing); + if (temp) + { + temp.GetAI().Talk(Texts.SayLkIntro5); + temp.setActive(false); + } + break; + case EventTypes.SaurfangIntro1: + temp = ObjectAccessor.GetCreature(me, _factionNPC); + if (temp) + temp.GetAI().Talk(Texts.SaySaurfangIntro1); + break; + case EventTypes.TirionIntroH7: + Talk(Texts.SayTirionIntroH5); + break; + case EventTypes.SaurfangIntro2: + temp = ObjectAccessor.GetCreature(me, _factionNPC); + if (temp) + temp.GetAI().Talk(Texts.SaySaurfangIntro2); + break; + case EventTypes.SaurfangIntro3: + temp = ObjectAccessor.GetCreature(me, _factionNPC); + if (temp) + temp.GetAI().Talk(Texts.SaySaurfangIntro3); + break; + case EventTypes.SaurfangIntro4: + temp = ObjectAccessor.GetCreature(me, _factionNPC); + if (temp) + temp.GetAI().Talk(Texts.SaySaurfangIntro4); + break; + case EventTypes.MuradinRun: + case EventTypes.SaurfangRun: + Creature factionNPC = ObjectAccessor.GetCreature(me, _factionNPC); + if (factionNPC) + factionNPC.GetMotionMaster().MovePath((uint)(factionNPC.GetSpawnId() * 10), false); + me.setActive(false); + _damnedKills = 3; + break; + case EventTypes.MuradinIntro1: + temp = ObjectAccessor.GetCreature(me, _factionNPC); + if (temp) + temp.GetAI().Talk(Texts.SayMuradinIntro1); + break; + case EventTypes.MuradinIntro2: + temp = ObjectAccessor.GetCreature(me, _factionNPC); + if (temp) + temp.HandleEmoteCommand(Emote.OneshotTalk); + break; + case EventTypes.MuradinIntro3: + temp = ObjectAccessor.GetCreature(me, _factionNPC); + if (temp) + temp.HandleEmoteCommand(Emote.OneshotExclamation); + break; + case EventTypes.TirionIntroA7: + Talk(Texts.SayTirionIntroA5); + break; + case EventTypes.MuradinIntro4: + temp = ObjectAccessor.GetCreature(me, _factionNPC); + if (temp) + temp.GetAI().Talk(Texts.SayMuradinIntro2); + break; + case EventTypes.MuradinIntro5: + temp = ObjectAccessor.GetCreature(me, _factionNPC); + if (temp) + temp.GetAI().Talk(Texts.SayMuradinIntro3); break; default: break; } - } + }); + } - public override void UpdateAI(uint diff) + InstanceScript _instance; + ObjectGuid _theLichKing; + ObjectGuid _bolvarFordragon; + ObjectGuid _factionNPC; + ushort _damnedKills; + } + + [Script] + class npc_rotting_frost_giant : ScriptedAI + { + public npc_rotting_frost_giant(Creature creature) + : base(creature) { } + + public override void Reset() + { + _events.Reset(); + _events.ScheduleEvent(EventTypes.DeathPlague, 15000); + _events.ScheduleEvent(EventTypes.Stomp, RandomHelper.URand(5000, 8000)); + _events.ScheduleEvent(EventTypes.ArcticBreath, RandomHelper.URand(10000, 15000)); + } + + public override void JustDied(Unit killer) + { + _events.Reset(); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _events.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + _events.ExecuteEvents(eventId => { - _events.Update(diff); - - if (_events.ExecuteEvent() == EventTypes.ActivateTrap) + switch (eventId) { - DoCast(me, InstanceSpells.ColdflameJets); - _events.ScheduleEvent(EventTypes.ActivateTrap, 22000); + case EventTypes.DeathPlague: + Unit target = SelectTarget(SelectAggroTarget.Random, 1, 0.0f, true); + if (target) + { + Talk(Texts.EmoteDeathPlagueWarning, target); + DoCast(target, InstanceSpells.DeathPlague); + } + _events.ScheduleEvent(EventTypes.DeathPlague, 15000); + break; + case EventTypes.Stomp: + DoCastVictim(InstanceSpells.Stomp); + _events.ScheduleEvent(EventTypes.Stomp, RandomHelper.URand(15000, 18000)); + break; + case EventTypes.ArcticBreath: + DoCastVictim(InstanceSpells.ArcticBreath); + _events.ScheduleEvent(EventTypes.ArcticBreath, RandomHelper.URand(26000, 33000)); + break; + default: + break; } + }); + + DoMeleeAttackIfReady(); + } + } + + [Script] + class npc_frost_freeze_trap : ScriptedAI + { + public npc_frost_freeze_trap(Creature creature) + : base(creature) + { + SetCombatMovement(false); + } + + public override void DoAction(int action) + { + switch (action) + { + case 1000: + case 11000: + _events.ScheduleEvent(EventTypes.ActivateTrap, (uint)action); + break; + default: + break; } } - public override CreatureAI GetAI(Creature creature) + public override void UpdateAI(uint diff) { - return InstanceIcecrownCitadel.GetInstanceAI(creature); + _events.Update(diff); + + if (_events.ExecuteEvent() == EventTypes.ActivateTrap) + { + DoCast(me, InstanceSpells.ColdflameJets); + _events.ScheduleEvent(EventTypes.ActivateTrap, 22000); + } } } @@ -482,509 +452,489 @@ namespace Scripts.Northrend.IcecrownCitadel } [Script] - class boss_sister_svalna : CreatureScript + class boss_sister_svalna : BossAI { - public boss_sister_svalna() : base("boss_sister_svalna") { } - - class boss_sister_svalnaAI : BossAI + public boss_sister_svalna(Creature creature) + : base(creature, Bosses.SisterSvalna) { - public boss_sister_svalnaAI(Creature creature) - : base(creature, Bosses.SisterSvalna) + _isEventInProgress = false; + + } + + public override void InitializeAI() + { + if (!me.IsDead()) + Reset(); + + me.SetReactState(ReactStates.Passive); + } + + public override void Reset() + { + _Reset(); + me.SetReactState(ReactStates.Defensive); + _isEventInProgress = false; + } + + public override void JustDied(Unit killer) + { + _JustDied(); + Talk(Texts.SaySvalnaDeath); + + ulong delay = 1; + for (uint i = 0; i < 4; ++i) { - _isEventInProgress = false; - - } - - public override void InitializeAI() - { - if (!me.IsDead()) - Reset(); - - me.SetReactState(ReactStates.Passive); - } - - public override void Reset() - { - _Reset(); - me.SetReactState(ReactStates.Defensive); - _isEventInProgress = false; - } - - public override void JustDied(Unit killer) - { - _JustDied(); - Talk(Texts.SaySvalnaDeath); - - ulong delay = 1; - for (uint i = 0; i < 4; ++i) + Creature crusader = ObjectAccessor.GetCreature(me, instance.GetGuidData(DataTypes.CaptainArnath + i)); + if (crusader) { - Creature crusader = ObjectAccessor.GetCreature(me, instance.GetGuidData(DataTypes.CaptainArnath + i)); - if (crusader) + if (crusader.IsAlive() && crusader.GetEntry() == crusader.GetCreatureData().id) { - if (crusader.IsAlive() && crusader.GetEntry() == crusader.GetCreatureData().id) - { - crusader.m_Events.AddEvent(new CaptainSurviveTalk(crusader), crusader.m_Events.CalculateTime(delay)); - delay += 6000; - } + crusader.m_Events.AddEvent(new CaptainSurviveTalk(crusader), crusader.m_Events.CalculateTime(delay)); + delay += 6000; } } } + } - public override void EnterCombat(Unit attacker) + public override void EnterCombat(Unit attacker) + { + _EnterCombat(); + Creature crok = ObjectAccessor.GetCreature(me, instance.GetGuidData(DataTypes.CrokScourgebane)); + if (crok) + crok.GetAI().Talk(Texts.SayCrokCombatSvalna); + _events.ScheduleEvent(EventTypes.SvalnaCombat, 9000); + _events.ScheduleEvent(EventTypes.ImpalingSpear, RandomHelper.URand(40000, 50000)); + _events.ScheduleEvent(EventTypes.AetherShield, RandomHelper.URand(100000, 110000)); + } + + public override void KilledUnit(Unit victim) + { + switch (victim.GetTypeId()) { - _EnterCombat(); - Creature crok = ObjectAccessor.GetCreature(me, instance.GetGuidData(DataTypes.CrokScourgebane)); - if (crok) - crok.GetAI().Talk(Texts.SayCrokCombatSvalna); - _events.ScheduleEvent(EventTypes.SvalnaCombat, 9000); - _events.ScheduleEvent(EventTypes.ImpalingSpear, RandomHelper.URand(40000, 50000)); - _events.ScheduleEvent(EventTypes.AetherShield, RandomHelper.URand(100000, 110000)); - } - - public override void KilledUnit(Unit victim) - { - switch (victim.GetTypeId()) - { - case TypeId.Player: - Talk(Texts.SaySvalnaKill); - break; - case TypeId.Unit: - switch (victim.GetEntry()) - { - case CreatureIds.CaptainArnath: - case CreatureIds.CaptainBrandon: - case CreatureIds.CaptainGrondel: - case CreatureIds.CaptainRupert: - Talk(Texts.SaySvalnaKillCaptain); - break; - default: - break; - } - break; - default: - break; - } - } - - public override void JustReachedHome() - { - _JustReachedHome(); - me.SetReactState(ReactStates.Passive); - me.SetDisableGravity(false); - me.SetHover(false); - } - - public override void DoAction(int action) - { - switch (action) - { - case Actions.KillCaptain: - me.CastCustomSpell(InstanceSpells.CaressOfDeath, SpellValueMod.MaxTargets, 1, me, true); - break; - case Actions.StartGauntlet: - me.setActive(true); - _isEventInProgress = true; - me.SetFlag(UnitFields.Flags, UnitFlags.ImmuneToPc | UnitFlags.ImmuneToNpc); - _events.ScheduleEvent(EventTypes.SvalnaStart, 25000); - break; - case Actions.ResurrectCaptains: - _events.ScheduleEvent(EventTypes.SvalnaResurrect, 7000); - break; - case Actions.CaptainDies: - Talk(Texts.SaySvalnaCaptainDeath); - break; - case Actions.ResetEvent: - me.setActive(false); - Reset(); - break; - default: - break; - } - } - - public override void SpellHit(Unit caster, SpellInfo spell) - { - if (spell.Id == InstanceSpells.HurlSpear && me.HasAura(InstanceSpells.AetherShield)) - { - me.RemoveAurasDueToSpell(InstanceSpells.AetherShield); - Talk(Texts.EmoteSvalnaBrokenShield, caster); - } - } - - public override void MovementInform(MovementGeneratorType type, uint id) - { - if (type != MovementGeneratorType.Effect || id != 1) - return; - - _isEventInProgress = false; - me.setActive(false); - me.RemoveFlag(UnitFields.Flags, UnitFlags.ImmuneToPc | UnitFlags.ImmuneToNpc); - me.SetDisableGravity(false); - me.SetHover(false); - } - - public override void SpellHitTarget(Unit target, SpellInfo spell) - { - switch (spell.Id) - { - case InstanceSpells.ImpalingSpearKill: - me.Kill(target); - break; - case InstanceSpells.ImpalingSpear: - TempSummon summon = target.SummonCreature(CreatureIds.ImpalingSpear, target); - if (summon) - { - Talk(Texts.EmoteSvalnaImpale, target); - summon.CastCustomSpell(SharedConst.VehicleSpellRideHardcoded, SpellValueMod.BasePoint0, 1, target, false); - summon.SetFlag(UnitFields.Flags2, UnitFlags2.Unk1 | UnitFlags2.AllowEnemyInteract); - } - break; - default: - break; - } - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim() && !_isEventInProgress) - return; - - _events.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - _events.ExecuteEvents(eventId => - { - switch (eventId) + case TypeId.Player: + Talk(Texts.SaySvalnaKill); + break; + case TypeId.Unit: + switch (victim.GetEntry()) { - case EventTypes.SvalnaStart: - Talk(Texts.SaySvalnaEventStart); - break; - case EventTypes.SvalnaResurrect: - Talk(Texts.SaySvalnaResurrectCaptains); - me.CastSpell(me, InstanceSpells.ReviveChampion, false); - break; - case EventTypes.SvalnaCombat: - me.SetReactState(ReactStates.Defensive); - Talk(Texts.SaySvalnaAggro); - break; - case EventTypes.ImpalingSpear: - Unit target = SelectTarget(SelectAggroTarget.Random, 1, 0.0f, true, -(int)InstanceSpells.ImpalingSpear); - if (target) - { - DoCast(me, InstanceSpells.AetherShield); - DoCast(target, InstanceSpells.ImpalingSpear); - } - _events.ScheduleEvent(EventTypes.ImpalingSpear, RandomHelper.URand(20000, 25000)); + case CreatureIds.CaptainArnath: + case CreatureIds.CaptainBrandon: + case CreatureIds.CaptainGrondel: + case CreatureIds.CaptainRupert: + Talk(Texts.SaySvalnaKillCaptain); break; default: break; } - }); - - DoMeleeAttackIfReady(); + break; + default: + break; } - - bool _isEventInProgress; } - public override CreatureAI GetAI(Creature creature) + public override void JustReachedHome() { - return InstanceIcecrownCitadel.GetInstanceAI(creature); + _JustReachedHome(); + me.SetReactState(ReactStates.Passive); + me.SetDisableGravity(false); + me.SetHover(false); } + + public override void DoAction(int action) + { + switch (action) + { + case Actions.KillCaptain: + me.CastCustomSpell(InstanceSpells.CaressOfDeath, SpellValueMod.MaxTargets, 1, me, true); + break; + case Actions.StartGauntlet: + me.setActive(true); + _isEventInProgress = true; + me.SetFlag(UnitFields.Flags, UnitFlags.ImmuneToPc | UnitFlags.ImmuneToNpc); + _events.ScheduleEvent(EventTypes.SvalnaStart, 25000); + break; + case Actions.ResurrectCaptains: + _events.ScheduleEvent(EventTypes.SvalnaResurrect, 7000); + break; + case Actions.CaptainDies: + Talk(Texts.SaySvalnaCaptainDeath); + break; + case Actions.ResetEvent: + me.setActive(false); + Reset(); + break; + default: + break; + } + } + + public override void SpellHit(Unit caster, SpellInfo spell) + { + if (spell.Id == InstanceSpells.HurlSpear && me.HasAura(InstanceSpells.AetherShield)) + { + me.RemoveAurasDueToSpell(InstanceSpells.AetherShield); + Talk(Texts.EmoteSvalnaBrokenShield, caster); + } + } + + public override void MovementInform(MovementGeneratorType type, uint id) + { + if (type != MovementGeneratorType.Effect || id != 1) + return; + + _isEventInProgress = false; + me.setActive(false); + me.RemoveFlag(UnitFields.Flags, UnitFlags.ImmuneToPc | UnitFlags.ImmuneToNpc); + me.SetDisableGravity(false); + me.SetHover(false); + } + + public override void SpellHitTarget(Unit target, SpellInfo spell) + { + switch (spell.Id) + { + case InstanceSpells.ImpalingSpearKill: + me.Kill(target); + break; + case InstanceSpells.ImpalingSpear: + TempSummon summon = target.SummonCreature(CreatureIds.ImpalingSpear, target); + if (summon) + { + Talk(Texts.EmoteSvalnaImpale, target); + summon.CastCustomSpell(SharedConst.VehicleSpellRideHardcoded, SpellValueMod.BasePoint0, 1, target, false); + summon.SetFlag(UnitFields.Flags2, UnitFlags2.Unk1 | UnitFlags2.AllowEnemyInteract); + } + break; + default: + break; + } + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim() && !_isEventInProgress) + return; + + _events.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + _events.ExecuteEvents(eventId => + { + switch (eventId) + { + case EventTypes.SvalnaStart: + Talk(Texts.SaySvalnaEventStart); + break; + case EventTypes.SvalnaResurrect: + Talk(Texts.SaySvalnaResurrectCaptains); + me.CastSpell(me, InstanceSpells.ReviveChampion, false); + break; + case EventTypes.SvalnaCombat: + me.SetReactState(ReactStates.Defensive); + Talk(Texts.SaySvalnaAggro); + break; + case EventTypes.ImpalingSpear: + Unit target = SelectTarget(SelectAggroTarget.Random, 1, 0.0f, true, -(int)InstanceSpells.ImpalingSpear); + if (target) + { + DoCast(me, InstanceSpells.AetherShield); + DoCast(target, InstanceSpells.ImpalingSpear); + } + _events.ScheduleEvent(EventTypes.ImpalingSpear, RandomHelper.URand(20000, 25000)); + break; + default: + break; + } + }); + + DoMeleeAttackIfReady(); + } + + bool _isEventInProgress; } [Script] - class npc_crok_scourgebane : CreatureScript + class npc_crok_scourgebane : npc_escortAI { - public npc_crok_scourgebane() : base("npc_crok_scourgebane") { } - - class npc_crok_scourgebaneAI : npc_escortAI + public npc_crok_scourgebane(Creature creature) : base(creature) { - public npc_crok_scourgebaneAI(Creature creature) : base(creature) - { - _instance = creature.GetInstanceScript(); - _respawnTime = creature.GetRespawnDelay(); - _corpseDelay = creature.GetCorpseDelay(); + _instance = creature.GetInstanceScript(); + _respawnTime = creature.GetRespawnDelay(); + _corpseDelay = creature.GetCorpseDelay(); - SetDespawnAtEnd(false); - SetDespawnAtFar(false); + SetDespawnAtEnd(false); + SetDespawnAtFar(false); + _isEventActive = false; + _isEventDone = _instance.GetBossState(Bosses.SisterSvalna) == EncounterState.Done; + _didUnderTenPercentText = false; + } + + public override void Reset() + { + _events.Reset(); + _events.ScheduleEvent(EventTypes.ScourgeStrike, RandomHelper.URand(7500, 12500)); + _events.ScheduleEvent(EventTypes.DeathStrike, RandomHelper.URand(25000, 30000)); + me.SetReactState(ReactStates.Defensive); + _didUnderTenPercentText = false; + _wipeCheckTimer = 1000; + } + + public override void DoAction(int action) + { + if (action == Actions.StartGauntlet) + { + if (_isEventDone || !me.IsAlive()) + return; + + _isEventActive = true; + _isEventDone = true; + // Load Grid with Sister Svalna + me.GetMap().LoadGrid(4356.71f, 2484.33f); + Creature svalna = ObjectAccessor.GetCreature(me, _instance.GetGuidData(Bosses.SisterSvalna)); + if (svalna) + svalna.GetAI().DoAction(Actions.StartGauntlet); + Talk(Texts.SayCrokIntro1); + _events.ScheduleEvent(EventTypes.ArnathIntro2, 7000); + _events.ScheduleEvent(EventTypes.CrokIntro3, 14000); + _events.ScheduleEvent(EventTypes.StartPathing, 37000); + me.setActive(true); + for (uint i = 0; i < 4; ++i) + { + Creature crusader = ObjectAccessor.GetCreature(me, _instance.GetGuidData(DataTypes.CaptainArnath + i)); + if (crusader) + crusader.GetAI().DoAction(Actions.StartGauntlet); + } + } + else if (action == Actions.ResetEvent) + { _isEventActive = false; _isEventDone = _instance.GetBossState(Bosses.SisterSvalna) == EncounterState.Done; - _didUnderTenPercentText = false; + me.setActive(false); + _aliveTrash.Clear(); + _currentWPid = 0; } - - public override void Reset() - { - _events.Reset(); - _events.ScheduleEvent(EventTypes.ScourgeStrike, RandomHelper.URand(7500, 12500)); - _events.ScheduleEvent(EventTypes.DeathStrike, RandomHelper.URand(25000, 30000)); - me.SetReactState(ReactStates.Defensive); - _didUnderTenPercentText = false; - _wipeCheckTimer = 1000; - } - - public override void DoAction(int action) - { - if (action == Actions.StartGauntlet) - { - if (_isEventDone || !me.IsAlive()) - return; - - _isEventActive = true; - _isEventDone = true; - // Load Grid with Sister Svalna - me.GetMap().LoadGrid(4356.71f, 2484.33f); - Creature svalna = ObjectAccessor.GetCreature(me, _instance.GetGuidData(Bosses.SisterSvalna)); - if (svalna) - svalna.GetAI().DoAction(Actions.StartGauntlet); - Talk(Texts.SayCrokIntro1); - _events.ScheduleEvent(EventTypes.ArnathIntro2, 7000); - _events.ScheduleEvent(EventTypes.CrokIntro3, 14000); - _events.ScheduleEvent(EventTypes.StartPathing, 37000); - me.setActive(true); - for (uint i = 0; i < 4; ++i) - { - Creature crusader = ObjectAccessor.GetCreature(me, _instance.GetGuidData(DataTypes.CaptainArnath + i)); - if (crusader) - crusader.GetAI().DoAction(Actions.StartGauntlet); - } - } - else if (action == Actions.ResetEvent) - { - _isEventActive = false; - _isEventDone = _instance.GetBossState(Bosses.SisterSvalna) == EncounterState.Done; - me.setActive(false); - _aliveTrash.Clear(); - _currentWPid = 0; - } - } - - public override void SetGUID(ObjectGuid guid, int type = 0) - { - if (type == Actions.VrykulDeath) - { - _aliveTrash.Remove(guid); - if (_aliveTrash.Empty()) - { - SetEscortPaused(false); - if (_currentWPid == 4 && _isEventActive) - { - _isEventActive = false; - me.setActive(false); - Talk(Texts.SayCrokFinalWp); - Creature svalna = ObjectAccessor.GetCreature(me, _instance.GetGuidData(Bosses.SisterSvalna)); - if (svalna) - svalna.GetAI().DoAction(Actions.ResurrectCaptains); - } - } - } - } - - public override void WaypointReached(uint waypointId) - { - switch (waypointId) - { - // pause pathing until trash pack is cleared - case 0: - Talk(Texts.SayCrokCombatWp0); - if (!_aliveTrash.Empty()) - SetEscortPaused(true); - break; - case 1: - Talk(Texts.SayCrokCombatWp1); - if (!_aliveTrash.Empty()) - SetEscortPaused(true); - break; - case 4: - if (_aliveTrash.Empty() && _isEventActive) - { - _isEventActive = false; - me.setActive(false); - Talk(Texts.SayCrokFinalWp); - Creature svalna = ObjectAccessor.GetCreature(me, _instance.GetGuidData(Bosses.SisterSvalna)); - if (svalna) - svalna.GetAI().DoAction(Actions.ResurrectCaptains); - } - break; - default: - break; - } - } - - public override void WaypointStart(uint waypointId) - { - _currentWPid = waypointId; - switch (waypointId) - { - case 0: - case 1: - case 4: - { - // get spawns by home position - float minY = 2600.0f; - float maxY = 2650.0f; - if (waypointId == 1) - { - minY -= 50.0f; - maxY -= 50.0f; - // at waypoints 1 and 2 she kills one captain - Creature svalna = ObjectAccessor.GetCreature(me, _instance.GetGuidData(Bosses.SisterSvalna)); - if (svalna) - svalna.GetAI().DoAction(Actions.KillCaptain); - } - else if (waypointId == 4) - { - minY -= 100.0f; - maxY -= 100.0f; - } - - // get all nearby vrykul - List temp = new List(); - var check = new FrostwingVrykulSearcher(me, 80.0f); - var searcher = new CreatureListSearcher(me, temp, check); - Cell.VisitGridObjects(me, searcher, 80.0f); - - _aliveTrash.Clear(); - foreach (var creature in temp) - if (creature.GetHomePosition().GetPositionY() < maxY && creature.GetHomePosition().GetPositionY() > minY) - _aliveTrash.Add(creature.GetGUID()); - break; - } - // at waypoints 1 and 2 she kills one captain - case 2: - Creature svalna1 = ObjectAccessor.GetCreature(me, _instance.GetGuidData(Bosses.SisterSvalna)); - if (svalna1) - svalna1.GetAI().DoAction(Actions.KillCaptain); - break; - default: - break; - } - } - - public override void DamageTaken(Unit attacker, ref uint damage) - { - // check wipe - if (_wipeCheckTimer == 0) - { - _wipeCheckTimer = 1000; - var check = new AnyPlayerInObjectRangeCheck(me, 60.0f); - var searcher = new PlayerSearcher(me, check); - Cell.VisitWorldObjects(me, searcher, 60.0f); - // wipe - if (!searcher.GetTarget()) - { - damage *= 100; - if (damage >= me.GetHealth()) - { - FrostwingGauntletRespawner respawner = new FrostwingGauntletRespawner(); - var worker = new CreatureWorker(me, respawner); - Cell.VisitGridObjects(me, worker, 333.0f); - Talk(Texts.SayCrokDeath); - } - return; - } - } - - if (HealthBelowPct(10)) - { - if (!_didUnderTenPercentText) - { - _didUnderTenPercentText = true; - if (_isEventActive) - Talk(Texts.SayCrokWeakeningGauntlet); - else - Talk(Texts.SayCrokWeakeningSvalna); - } - - damage = 0; - DoCast(me, InstanceSpells.IceboundArmor); - _events.ScheduleEvent(EventTypes.HealthCheck, 1000); - } - } - - void UpdateEscortAI(uint diff) - { - if (_wipeCheckTimer <= diff) - _wipeCheckTimer = 0; - else - _wipeCheckTimer -= diff; - - if (!UpdateVictim() && !_isEventActive) - return; - - _events.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case EventTypes.ArnathIntro2: - Creature arnath = ObjectAccessor.GetCreature(me, _instance.GetGuidData(DataTypes.CaptainArnath)); - if (arnath) - arnath.GetAI().Talk(Texts.SayArnathIntro2); - break; - case EventTypes.CrokIntro3: - Talk(Texts.SayCrokIntro3); - break; - case EventTypes.StartPathing: - Start(true, true); - break; - case EventTypes.ScourgeStrike: - DoCastVictim(InstanceSpells.ScourgeStrike); - _events.ScheduleEvent(EventTypes.ScourgeStrike, RandomHelper.URand(10000, 14000)); - break; - case EventTypes.DeathStrike: - if (HealthBelowPct(20)) - DoCastVictim(InstanceSpells.DeathStrike); - _events.ScheduleEvent(EventTypes.DeathStrike, RandomHelper.URand(5000, 10000)); - break; - case EventTypes.HealthCheck: - if (HealthAbovePct(15)) - { - me.RemoveAurasDueToSpell(InstanceSpells.IceboundArmor); - _didUnderTenPercentText = false; - } - else - { - // looks totally hacky to me - me.ModifyHealth((long)me.CountPctFromMaxHealth(5)); - _events.ScheduleEvent(EventTypes.HealthCheck, 1000); - } - break; - default: - break; - } - }); - - DoMeleeAttackIfReady(); - } - - public override bool CanAIAttack(Unit target) - { - // do not see targets inside Frostwing Halls when we are not there - return (me.GetPositionY() > 2660.0f) == (target.GetPositionY() > 2660.0f); - } - - List _aliveTrash = new List(); - InstanceScript _instance; - uint _currentWPid; - uint _wipeCheckTimer; - uint _respawnTime; - uint _corpseDelay; - bool _isEventActive; - bool _isEventDone; - bool _didUnderTenPercentText; } - public override CreatureAI GetAI(Creature creature) + public override void SetGUID(ObjectGuid guid, int type = 0) { - return InstanceIcecrownCitadel.GetInstanceAI(creature); + if (type == Actions.VrykulDeath) + { + _aliveTrash.Remove(guid); + if (_aliveTrash.Empty()) + { + SetEscortPaused(false); + if (_currentWPid == 4 && _isEventActive) + { + _isEventActive = false; + me.setActive(false); + Talk(Texts.SayCrokFinalWp); + Creature svalna = ObjectAccessor.GetCreature(me, _instance.GetGuidData(Bosses.SisterSvalna)); + if (svalna) + svalna.GetAI().DoAction(Actions.ResurrectCaptains); + } + } + } } + + public override void WaypointReached(uint waypointId) + { + switch (waypointId) + { + // pause pathing until trash pack is cleared + case 0: + Talk(Texts.SayCrokCombatWp0); + if (!_aliveTrash.Empty()) + SetEscortPaused(true); + break; + case 1: + Talk(Texts.SayCrokCombatWp1); + if (!_aliveTrash.Empty()) + SetEscortPaused(true); + break; + case 4: + if (_aliveTrash.Empty() && _isEventActive) + { + _isEventActive = false; + me.setActive(false); + Talk(Texts.SayCrokFinalWp); + Creature svalna = ObjectAccessor.GetCreature(me, _instance.GetGuidData(Bosses.SisterSvalna)); + if (svalna) + svalna.GetAI().DoAction(Actions.ResurrectCaptains); + } + break; + default: + break; + } + } + + public override void WaypointStart(uint waypointId) + { + _currentWPid = waypointId; + switch (waypointId) + { + case 0: + case 1: + case 4: + { + // get spawns by home position + float minY = 2600.0f; + float maxY = 2650.0f; + if (waypointId == 1) + { + minY -= 50.0f; + maxY -= 50.0f; + // at waypoints 1 and 2 she kills one captain + Creature svalna = ObjectAccessor.GetCreature(me, _instance.GetGuidData(Bosses.SisterSvalna)); + if (svalna) + svalna.GetAI().DoAction(Actions.KillCaptain); + } + else if (waypointId == 4) + { + minY -= 100.0f; + maxY -= 100.0f; + } + + // get all nearby vrykul + List temp = new List(); + var check = new FrostwingVrykulSearcher(me, 80.0f); + var searcher = new CreatureListSearcher(me, temp, check); + Cell.VisitGridObjects(me, searcher, 80.0f); + + _aliveTrash.Clear(); + foreach (var creature in temp) + if (creature.GetHomePosition().GetPositionY() < maxY && creature.GetHomePosition().GetPositionY() > minY) + _aliveTrash.Add(creature.GetGUID()); + break; + } + // at waypoints 1 and 2 she kills one captain + case 2: + Creature svalna1 = ObjectAccessor.GetCreature(me, _instance.GetGuidData(Bosses.SisterSvalna)); + if (svalna1) + svalna1.GetAI().DoAction(Actions.KillCaptain); + break; + default: + break; + } + } + + public override void DamageTaken(Unit attacker, ref uint damage) + { + // check wipe + if (_wipeCheckTimer == 0) + { + _wipeCheckTimer = 1000; + var check = new AnyPlayerInObjectRangeCheck(me, 60.0f); + var searcher = new PlayerSearcher(me, check); + Cell.VisitWorldObjects(me, searcher, 60.0f); + // wipe + if (!searcher.GetTarget()) + { + damage *= 100; + if (damage >= me.GetHealth()) + { + FrostwingGauntletRespawner respawner = new FrostwingGauntletRespawner(); + var worker = new CreatureWorker(me, respawner); + Cell.VisitGridObjects(me, worker, 333.0f); + Talk(Texts.SayCrokDeath); + } + return; + } + } + + if (HealthBelowPct(10)) + { + if (!_didUnderTenPercentText) + { + _didUnderTenPercentText = true; + if (_isEventActive) + Talk(Texts.SayCrokWeakeningGauntlet); + else + Talk(Texts.SayCrokWeakeningSvalna); + } + + damage = 0; + DoCast(me, InstanceSpells.IceboundArmor); + _events.ScheduleEvent(EventTypes.HealthCheck, 1000); + } + } + + void UpdateEscortAI(uint diff) + { + if (_wipeCheckTimer <= diff) + _wipeCheckTimer = 0; + else + _wipeCheckTimer -= diff; + + if (!UpdateVictim() && !_isEventActive) + return; + + _events.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + _events.ExecuteEvents(eventId => + { + switch (eventId) + { + case EventTypes.ArnathIntro2: + Creature arnath = ObjectAccessor.GetCreature(me, _instance.GetGuidData(DataTypes.CaptainArnath)); + if (arnath) + arnath.GetAI().Talk(Texts.SayArnathIntro2); + break; + case EventTypes.CrokIntro3: + Talk(Texts.SayCrokIntro3); + break; + case EventTypes.StartPathing: + Start(true, true); + break; + case EventTypes.ScourgeStrike: + DoCastVictim(InstanceSpells.ScourgeStrike); + _events.ScheduleEvent(EventTypes.ScourgeStrike, RandomHelper.URand(10000, 14000)); + break; + case EventTypes.DeathStrike: + if (HealthBelowPct(20)) + DoCastVictim(InstanceSpells.DeathStrike); + _events.ScheduleEvent(EventTypes.DeathStrike, RandomHelper.URand(5000, 10000)); + break; + case EventTypes.HealthCheck: + if (HealthAbovePct(15)) + { + me.RemoveAurasDueToSpell(InstanceSpells.IceboundArmor); + _didUnderTenPercentText = false; + } + else + { + // looks totally hacky to me + me.ModifyHealth((long)me.CountPctFromMaxHealth(5)); + _events.ScheduleEvent(EventTypes.HealthCheck, 1000); + } + break; + default: + break; + } + }); + + DoMeleeAttackIfReady(); + } + + public override bool CanAIAttack(Unit target) + { + // do not see targets inside Frostwing Halls when we are not there + return (me.GetPositionY() > 2660.0f) == (target.GetPositionY() > 2660.0f); + } + + List _aliveTrash = new List(); + InstanceScript _instance; + uint _currentWPid; + uint _wipeCheckTimer; + uint _respawnTime; + uint _corpseDelay; + bool _isEventActive; + bool _isEventDone; + bool _didUnderTenPercentText; } class npc_argent_captainAI : ScriptedAI @@ -1112,713 +1062,567 @@ namespace Scripts.Northrend.IcecrownCitadel } [Script] - class npc_captain_arnath : CreatureScript + class npc_captain_arnath : npc_argent_captainAI { - public npc_captain_arnath() : base("CreatureIds.CaptainArnath") { } + public npc_captain_arnath(Creature creature) + : base(creature) { } - class npc_captain_arnathAI : npc_argent_captainAI + public override void Reset() { - public npc_captain_arnathAI(Creature creature) - : base(creature) { } + _events.Reset(); + _events.ScheduleEvent(EventTypes.ArnathFlashHeal, RandomHelper.URand(4000, 7000)); + _events.ScheduleEvent(EventTypes.ArnathPwShield, RandomHelper.URand(8000, 14000)); + _events.ScheduleEvent(EventTypes.ArnathSmite, RandomHelper.URand(3000, 6000)); + if (Is25ManRaid() && IsUndead) + _events.ScheduleEvent(EventTypes.ArnathDominateMind, RandomHelper.URand(22000, 27000)); + } - public override void Reset() + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _events.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + _events.ExecuteEvents(eventId => { - _events.Reset(); - _events.ScheduleEvent(EventTypes.ArnathFlashHeal, RandomHelper.URand(4000, 7000)); - _events.ScheduleEvent(EventTypes.ArnathPwShield, RandomHelper.URand(8000, 14000)); - _events.ScheduleEvent(EventTypes.ArnathSmite, RandomHelper.URand(3000, 6000)); - if (Is25ManRaid() && IsUndead) - _events.ScheduleEvent(EventTypes.ArnathDominateMind, RandomHelper.URand(22000, 27000)); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _events.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - _events.ExecuteEvents(eventId => + switch (eventId) { - switch (eventId) - { - case EventTypes.ArnathFlashHeal: - Creature target = FindFriendlyCreature(); - if (target) - DoCast(target, InstanceSpells.SpellFlashHeal(IsUndead)); - _events.ScheduleEvent(EventTypes.ArnathFlashHeal, RandomHelper.URand(6000, 9000)); - break; - case EventTypes.ArnathPwShield: - { - List targets = DoFindFriendlyMissingBuff(40.0f, InstanceSpells.SpellPowerWordShield(IsUndead)); - DoCast(targets.SelectRandom(), InstanceSpells.SpellPowerWordShield(IsUndead)); - _events.ScheduleEvent(EventTypes.ArnathPwShield, RandomHelper.URand(15000, 20000)); - break; - } - case EventTypes.ArnathSmite: - DoCastVictim(InstanceSpells.SpellSmite(IsUndead)); - _events.ScheduleEvent(EventTypes.ArnathSmite, RandomHelper.URand(4000, 7000)); - break; - case EventTypes.ArnathDominateMind: - Unit target1 = SelectTarget(SelectAggroTarget.Random, 1, 0.0f, true); - if (target1) - DoCast(target1, InstanceSpells.DominateMind); - _events.ScheduleEvent(EventTypes.ArnathDominateMind, RandomHelper.URand(28000, 37000)); - break; - default: - break; - } - }); - - DoMeleeAttackIfReady(); - } - - Creature FindFriendlyCreature() - { - var u_check = new MostHPMissingInRange(me, 60.0f, 0); - var searcher = new CreatureLastSearcher(me, u_check); - Cell.VisitGridObjects(me, searcher, 60.0f); - return searcher.GetTarget(); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return InstanceIcecrownCitadel.GetInstanceAI(creature); - } - } - - [Script] - class npc_captain_brandon : CreatureScript - { - public npc_captain_brandon() : base("CreatureIds.CaptainBrandon") { } - - class npc_captain_brandonAI : npc_argent_captainAI - { - public npc_captain_brandonAI(Creature creature) - : base(creature) { } - - public override void Reset() - { - _events.Reset(); - _events.ScheduleEvent(EventTypes.BrandonCrusaderStrike, RandomHelper.URand(6000, 10000)); - _events.ScheduleEvent(EventTypes.BrandonDivineShield, 500); - _events.ScheduleEvent(EventTypes.BrandonJudgementOfCommand, RandomHelper.URand(8000, 13000)); - if (IsUndead) - _events.ScheduleEvent(EventTypes.BrandonHammerOfBetrayal, RandomHelper.URand(25000, 30000)); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _events.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case EventTypes.BrandonCrusaderStrike: - DoCastVictim(InstanceSpells.CrusaderStrike); - _events.ScheduleEvent(EventTypes.BrandonCrusaderStrike, RandomHelper.URand(6000, 12000)); - break; - case EventTypes.BrandonDivineShield: - if (HealthBelowPct(20)) - DoCast(me, InstanceSpells.DivineShield); - _events.ScheduleEvent(EventTypes.BrandonDivineShield, 500); - break; - case EventTypes.BrandonJudgementOfCommand: - DoCastVictim(InstanceSpells.JudgementOfCommand); - _events.ScheduleEvent(EventTypes.BrandonJudgementOfCommand, RandomHelper.URand(8000, 13000)); - break; - case EventTypes.BrandonHammerOfBetrayal: - Unit target = SelectTarget(SelectAggroTarget.Random, 1, 0.0f, true); - if (target) - DoCast(target, InstanceSpells.HammerOfBetrayal); - _events.ScheduleEvent(EventTypes.BrandonHammerOfBetrayal, RandomHelper.URand(45000, 60000)); - break; - default: - break; - } - }); - - DoMeleeAttackIfReady(); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return InstanceIcecrownCitadel.GetInstanceAI(creature); - } - } - - [Script] - class npc_captain_grondel : CreatureScript - { - public npc_captain_grondel() : base("CreatureIds.CaptainGrondel") { } - - class npc_captain_grondelAI : npc_argent_captainAI - { - public npc_captain_grondelAI(Creature creature) - : base(creature) { } - - public override void Reset() - { - _events.Reset(); - _events.ScheduleEvent(EventTypes.GrondelChargeCheck, 500); - _events.ScheduleEvent(EventTypes.GrondelMortalStrike, RandomHelper.URand(8000, 14000)); - _events.ScheduleEvent(EventTypes.GrondelSunderArmor, RandomHelper.URand(3000, 12000)); - if (IsUndead) - _events.ScheduleEvent(EventTypes.GrondelConflagration, RandomHelper.URand(12000, 17000)); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _events.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case EventTypes.GrondelChargeCheck: - DoCastVictim(InstanceSpells.Charge); - _events.ScheduleEvent(EventTypes.GrondelChargeCheck, 500); - break; - case EventTypes.GrondelMortalStrike: - DoCastVictim(InstanceSpells.MortalStrike); - _events.ScheduleEvent(EventTypes.GrondelMortalStrike, RandomHelper.URand(10000, 15000)); - break; - case EventTypes.GrondelSunderArmor: - DoCastVictim(InstanceSpells.SunderArmor); - _events.ScheduleEvent(EventTypes.GrondelSunderArmor, RandomHelper.URand(5000, 17000)); - break; - case EventTypes.GrondelConflagration: - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 0.0f, true); - if (target) - DoCast(target, InstanceSpells.Conflagration); - _events.ScheduleEvent(EventTypes.GrondelConflagration, RandomHelper.URand(10000, 15000)); - break; - default: - break; - } - }); - - DoMeleeAttackIfReady(); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return InstanceIcecrownCitadel.GetInstanceAI(creature); - } - } - - [Script] - class npc_captain_rupert : CreatureScript - { - public npc_captain_rupert() : base("CreatureIds.CaptainRupert") { } - - class npc_captain_rupertAI : npc_argent_captainAI - { - public npc_captain_rupertAI(Creature creature) - : base(creature) - { - } - - public override void Reset() - { - _events.Reset(); - _events.ScheduleEvent(EventTypes.RupertFelIronBomb, RandomHelper.URand(15000, 20000)); - _events.ScheduleEvent(EventTypes.RupertMachineGun, RandomHelper.URand(25000, 30000)); - _events.ScheduleEvent(EventTypes.RupertRocketLaunch, RandomHelper.URand(10000, 15000)); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _events.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - _events.ExecuteEvents(eventId => - { - Unit target; - switch (eventId) - { - case EventTypes.RupertFelIronBomb: - target = SelectTarget(SelectAggroTarget.Random, 0); - if (target) - DoCast(target, InstanceSpells.SpellFelIronBomb(IsUndead)); - _events.ScheduleEvent(EventTypes.RupertFelIronBomb, RandomHelper.URand(15000, 20000)); - break; - case EventTypes.RupertMachineGun: - target = SelectTarget(SelectAggroTarget.Random, 1); - if (target) - DoCast(target, InstanceSpells.SpellMachineGun(IsUndead)); - _events.ScheduleEvent(EventTypes.RupertMachineGun, RandomHelper.URand(25000, 30000)); - break; - case EventTypes.RupertRocketLaunch: - target = SelectTarget(SelectAggroTarget.Random, 1); - if (target) - DoCast(target, InstanceSpells.SpellRocketLaunch(IsUndead)); - _events.ScheduleEvent(EventTypes.RupertRocketLaunch, RandomHelper.URand(10000, 15000)); - break; - default: - break; - } - }); - - DoMeleeAttackIfReady(); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return InstanceIcecrownCitadel.GetInstanceAI(creature); - } - } - - [Script] - class npc_frostwing_vrykul : CreatureScript - { - public npc_frostwing_vrykul() : base("npc_frostwing_vrykul") { } - - class npc_frostwing_vrykulAI : SmartAI - { - public npc_frostwing_vrykulAI(Creature creature) - : base(creature) { } - - public override bool CanAIAttack(Unit target) - { - // do not see targets inside Frostwing Halls when we are not there - return (me.GetPositionY() > 2660.0f) == (target.GetPositionY() > 2660.0f) && base.CanAIAttack(target); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return new npc_frostwing_vrykulAI(creature); - } - } - - [Script] - class npc_impaling_spear : CreatureScript - { - public npc_impaling_spear() : base("npc_impaling_spear") { } - - class npc_impaling_spearAI : CreatureAI - { - public npc_impaling_spearAI(Creature creature) - : base(creature) - { - } - - public override void Reset() - { - me.SetReactState(ReactStates.Passive); - _vehicleCheckTimer = 500; - } - - public override void UpdateAI(uint diff) - { - if (_vehicleCheckTimer <= diff) - { - _vehicleCheckTimer = 500; - if (!me.GetVehicle()) - me.DespawnOrUnsummon(100); - } - else - _vehicleCheckTimer -= diff; - } - - uint _vehicleCheckTimer; - } - - public override CreatureAI GetAI(Creature creature) - { - return new npc_impaling_spearAI(creature); - } - } - - [Script] - class npc_arthas_teleport_visual : CreatureScript - { - public npc_arthas_teleport_visual() : base("npc_arthas_teleport_visual") { } - - class npc_arthas_teleport_visualAI : NullCreatureAI - { - public npc_arthas_teleport_visualAI(Creature creature) - : base(creature) - { - _instance = creature.GetInstanceScript(); - } - - public override void Reset() - { - _events.Reset(); - if (_instance.GetBossState(Bosses.ProfessorPutricide) == EncounterState.Done && - _instance.GetBossState(Bosses.BloodQueenLanaThel) == EncounterState.Done && - _instance.GetBossState(Bosses.Sindragosa) == EncounterState.Done) - _events.ScheduleEvent(EventTypes.SoulMissile, RandomHelper.URand(1000, 6000)); - } - - void Update(uint diff) - { - if (_events.Empty()) - return; - - _events.Update(diff); - - if (_events.ExecuteEvent() == EventTypes.SoulMissile) - { - DoCastAOE(InstanceSpells.SoulMissile); - _events.ScheduleEvent(EventTypes.SoulMissile, RandomHelper.URand(5000, 7000)); - } - } - - InstanceScript _instance; - } - - public override CreatureAI GetAI(Creature creature) - { - // Distance from the center of the spire - if (creature.GetExactDist2d(4357.052f, 2769.421f) < 100.0f && creature.GetHomePosition().GetPositionZ() < 315.0f) - return InstanceIcecrownCitadel.GetInstanceAI(creature); - - // Default to no script - return null; - } - } - - [Script] - class spell_icc_stoneform : SpellScriptLoader - { - public spell_icc_stoneform() : base("spell_icc_stoneform") { } - - class spell_icc_stoneform_AuraScript : AuraScript - { - void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Creature target = GetTarget().ToCreature(); - if (target) - { - target.SetReactState(ReactStates.Passive); - target.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable | UnitFlags.ImmuneToPc); - target.SetUInt32Value(UnitFields.NpcEmotestate, (uint)Emote.OneshotCustomSpell02); - } - } - - void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Creature target = GetTarget().ToCreature(); - if (target) - { - target.SetReactState(ReactStates.Aggressive); - target.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable | UnitFlags.ImmuneToPc); - target.SetUInt32Value(UnitFields.NpcEmotestate, 0); - } - } - - public override void Register() - { - OnEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - } - } - - public override AuraScript GetAuraScript() - { - return new spell_icc_stoneform_AuraScript(); - } - } - - [Script] - class spell_icc_sprit_alarm : SpellScriptLoader - { - public spell_icc_sprit_alarm() : base("spell_icc_sprit_alarm") { } - - class spell_icc_sprit_alarm_SpellScript : SpellScript - { - public const int AwakenWard1 = 22900; - public const int AwakenWard2 = 22907; - public const int AwakenWard3 = 22908; - public const int AwakenWard4 = 22909; - - void HandleEvent(uint effIndex) - { - PreventHitDefaultEffect(effIndex); - uint trapId = 0; - switch (GetSpellInfo().GetEffect(effIndex).MiscValue) - { - case AwakenWard1: - trapId = GameObjectIds.SpiritAlarm1; + case EventTypes.ArnathFlashHeal: + Creature target = FindFriendlyCreature(); + if (target) + DoCast(target, InstanceSpells.SpellFlashHeal(IsUndead)); + _events.ScheduleEvent(EventTypes.ArnathFlashHeal, RandomHelper.URand(6000, 9000)); break; - case AwakenWard2: - trapId = GameObjectIds.SpiritAlarm2; + case EventTypes.ArnathPwShield: + { + List targets = DoFindFriendlyMissingBuff(40.0f, InstanceSpells.SpellPowerWordShield(IsUndead)); + DoCast(targets.SelectRandom(), InstanceSpells.SpellPowerWordShield(IsUndead)); + _events.ScheduleEvent(EventTypes.ArnathPwShield, RandomHelper.URand(15000, 20000)); + break; + } + case EventTypes.ArnathSmite: + DoCastVictim(InstanceSpells.SpellSmite(IsUndead)); + _events.ScheduleEvent(EventTypes.ArnathSmite, RandomHelper.URand(4000, 7000)); break; - case AwakenWard3: - trapId = GameObjectIds.SpiritAlarm3; - break; - case AwakenWard4: - trapId = GameObjectIds.SpiritAlarm4; + case EventTypes.ArnathDominateMind: + Unit target1 = SelectTarget(SelectAggroTarget.Random, 1, 0.0f, true); + if (target1) + DoCast(target1, InstanceSpells.DominateMind); + _events.ScheduleEvent(EventTypes.ArnathDominateMind, RandomHelper.URand(28000, 37000)); break; default: - return; - } - - GameObject trap = GetCaster().FindNearestGameObject(trapId, 5.0f); - if (trap) - trap.SetRespawnTime((int)trap.GetGoInfo().GetAutoCloseTime()); - - List wards = new List(); - GetCaster().GetCreatureListWithEntryInGrid(wards, CreatureIds.DeathboundWard, 150.0f); - wards.Sort(new ObjectDistanceOrderPred(GetCaster())); - foreach (var creature in wards) - { - if (creature.IsAlive() && creature.HasAura(InstanceSpells.StoneForm)) - { - creature.GetAI().Talk(Texts.SayTrapActivate); - creature.RemoveAurasDueToSpell(InstanceSpells.StoneForm); - Unit target = creature.SelectNearestTarget(150.0f); - if (target) - creature.GetAI().AttackStart(target); - break; - } } - } + }); - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleEvent, 2, SpellEffectName.SendEvent)); - } + DoMeleeAttackIfReady(); } - public override SpellScript GetSpellScript() + Creature FindFriendlyCreature() { - return new spell_icc_sprit_alarm_SpellScript(); + var u_check = new MostHPMissingInRange(me, 60.0f, 0); + var searcher = new CreatureLastSearcher(me, u_check); + Cell.VisitGridObjects(me, searcher, 60.0f); + return searcher.GetTarget(); } } [Script] - class spell_frost_giant_death_plague : SpellScriptLoader + class npc_captain_brandon : npc_argent_captainAI { - public spell_frost_giant_death_plague() : base("spell_frost_giant_death_plague") { } + public npc_captain_brandon(Creature creature) + : base(creature) { } - class spell_frost_giant_death_plague_SpellScript : SpellScript + public override void Reset() { - public override bool Load() - { - _failed = false; - return true; - } + _events.Reset(); + _events.ScheduleEvent(EventTypes.BrandonCrusaderStrike, RandomHelper.URand(6000, 10000)); + _events.ScheduleEvent(EventTypes.BrandonDivineShield, 500); + _events.ScheduleEvent(EventTypes.BrandonJudgementOfCommand, RandomHelper.URand(8000, 13000)); + if (IsUndead) + _events.ScheduleEvent(EventTypes.BrandonHammerOfBetrayal, RandomHelper.URand(25000, 30000)); + } - // First effect - void CountTargets(List targets) - { - targets.Remove(GetCaster()); - _failed = targets.Empty(); - } + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; - // Second effect - void FilterTargets(List targets) + _events.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + _events.ExecuteEvents(eventId => { - // Select valid targets for jump - targets.RemoveAll(obj => + switch (eventId) { - if (obj == GetCaster()) - return true; - - if (!obj.IsTypeId(TypeId.Player)) - return true; - - if (obj.ToUnit().HasAura(InstanceSpells.RecentlyInfected) || obj.ToUnit().HasAura(InstanceSpells.DeathPlagueAura)) - return true; - - return false; - }); - - if (!targets.Empty()) - { - WorldObject target = targets.SelectRandom(); - targets.Clear(); - targets.Add(target); + case EventTypes.BrandonCrusaderStrike: + DoCastVictim(InstanceSpells.CrusaderStrike); + _events.ScheduleEvent(EventTypes.BrandonCrusaderStrike, RandomHelper.URand(6000, 12000)); + break; + case EventTypes.BrandonDivineShield: + if (HealthBelowPct(20)) + DoCast(me, InstanceSpells.DivineShield); + _events.ScheduleEvent(EventTypes.BrandonDivineShield, 500); + break; + case EventTypes.BrandonJudgementOfCommand: + DoCastVictim(InstanceSpells.JudgementOfCommand); + _events.ScheduleEvent(EventTypes.BrandonJudgementOfCommand, RandomHelper.URand(8000, 13000)); + break; + case EventTypes.BrandonHammerOfBetrayal: + Unit target = SelectTarget(SelectAggroTarget.Random, 1, 0.0f, true); + if (target) + DoCast(target, InstanceSpells.HammerOfBetrayal); + _events.ScheduleEvent(EventTypes.BrandonHammerOfBetrayal, RandomHelper.URand(45000, 60000)); + break; + default: + break; } + }); - targets.Add(GetCaster()); - } - - void HandleScript(uint effIndex) - { - PreventHitDefaultEffect(effIndex); - if (GetHitUnit() != GetCaster()) - GetCaster().CastSpell(GetHitUnit(), InstanceSpells.DeathPlagueAura, true); - else if (_failed) - GetCaster().CastSpell(GetCaster(), InstanceSpells.DeathPlagueKill, true); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(CountTargets, 0, Targets.UnitSrcAreaAlly)); - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 1, Targets.UnitSrcAreaAlly)); - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 1, SpellEffectName.ScriptEffect)); - } - - bool _failed; - } - - public override SpellScript GetSpellScript() - { - return new spell_frost_giant_death_plague_SpellScript(); + DoMeleeAttackIfReady(); } } [Script] - class spell_icc_harvest_blight_specimen : SpellScriptLoader + class npc_captain_grondel : npc_argent_captainAI { - public spell_icc_harvest_blight_specimen() : base("spell_icc_harvest_blight_specimen") { } + public npc_captain_grondel(Creature creature) : base(creature) { } - class spell_icc_harvest_blight_specimen_SpellScript : SpellScript + public override void Reset() { - void HandleScript(uint effIndex) - { - PreventHitDefaultEffect(effIndex); - GetHitUnit().RemoveAurasDueToSpell((uint)GetEffectValue()); - } - - void HandleQuestComplete(uint effIndex) - { - GetHitUnit().RemoveAurasDueToSpell((uint)GetEffectValue()); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - OnEffectHitTarget.Add(new EffectHandler(HandleQuestComplete, 1, SpellEffectName.QuestComplete)); - } + _events.Reset(); + _events.ScheduleEvent(EventTypes.GrondelChargeCheck, 500); + _events.ScheduleEvent(EventTypes.GrondelMortalStrike, RandomHelper.URand(8000, 14000)); + _events.ScheduleEvent(EventTypes.GrondelSunderArmor, RandomHelper.URand(3000, 12000)); + if (IsUndead) + _events.ScheduleEvent(EventTypes.GrondelConflagration, RandomHelper.URand(12000, 17000)); } - public override SpellScript GetSpellScript() + public override void UpdateAI(uint diff) { - return new spell_icc_harvest_blight_specimen_SpellScript(); - } - } + if (!UpdateVictim()) + return; - [Script] - class spell_svalna_revive_champion : SpellScriptLoader - { - public spell_svalna_revive_champion() : base("spell_svalna_revive_champion") { } + _events.Update(diff); - class spell_svalna_revive_champion_SpellScript : SpellScript - { - void RemoveAliveTarget(List targets) + if (me.HasUnitState(UnitState.Casting)) + return; + + _events.ExecuteEvents(eventId => { - targets.RemoveAll(obj => + switch (eventId) { - Unit unit = obj.ToUnit(); - if (unit) - return unit.IsAlive(); + case EventTypes.GrondelChargeCheck: + DoCastVictim(InstanceSpells.Charge); + _events.ScheduleEvent(EventTypes.GrondelChargeCheck, 500); + break; + case EventTypes.GrondelMortalStrike: + DoCastVictim(InstanceSpells.MortalStrike); + _events.ScheduleEvent(EventTypes.GrondelMortalStrike, RandomHelper.URand(10000, 15000)); + break; + case EventTypes.GrondelSunderArmor: + DoCastVictim(InstanceSpells.SunderArmor); + _events.ScheduleEvent(EventTypes.GrondelSunderArmor, RandomHelper.URand(5000, 17000)); + break; + case EventTypes.GrondelConflagration: + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 0.0f, true); + if (target) + DoCast(target, InstanceSpells.Conflagration); + _events.ScheduleEvent(EventTypes.GrondelConflagration, RandomHelper.URand(10000, 15000)); + break; + default: + break; + } + }); - return true; - }); - targets = targets.SelectRandom(2).ToList(); - } + DoMeleeAttackIfReady(); + } + } - void Land(uint effIndex) + [Script] + class npc_captain_rupert : npc_argent_captainAI + { + public npc_captain_rupert(Creature creature) + : base(creature) + { + } + + public override void Reset() + { + _events.Reset(); + _events.ScheduleEvent(EventTypes.RupertFelIronBomb, RandomHelper.URand(15000, 20000)); + _events.ScheduleEvent(EventTypes.RupertMachineGun, RandomHelper.URand(25000, 30000)); + _events.ScheduleEvent(EventTypes.RupertRocketLaunch, RandomHelper.URand(10000, 15000)); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _events.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + _events.ExecuteEvents(eventId => { - Creature caster = GetCaster().ToCreature(); - if (!caster) + Unit target; + switch (eventId) + { + case EventTypes.RupertFelIronBomb: + target = SelectTarget(SelectAggroTarget.Random, 0); + if (target) + DoCast(target, InstanceSpells.SpellFelIronBomb(IsUndead)); + _events.ScheduleEvent(EventTypes.RupertFelIronBomb, RandomHelper.URand(15000, 20000)); + break; + case EventTypes.RupertMachineGun: + target = SelectTarget(SelectAggroTarget.Random, 1); + if (target) + DoCast(target, InstanceSpells.SpellMachineGun(IsUndead)); + _events.ScheduleEvent(EventTypes.RupertMachineGun, RandomHelper.URand(25000, 30000)); + break; + case EventTypes.RupertRocketLaunch: + target = SelectTarget(SelectAggroTarget.Random, 1); + if (target) + DoCast(target, InstanceSpells.SpellRocketLaunch(IsUndead)); + _events.ScheduleEvent(EventTypes.RupertRocketLaunch, RandomHelper.URand(10000, 15000)); + break; + default: + break; + } + }); + + DoMeleeAttackIfReady(); + } + } + + [Script] + class npc_frostwing_vrykul : SmartAI + { + public npc_frostwing_vrykul(Creature creature) + : base(creature) { } + + public override bool CanAIAttack(Unit target) + { + // do not see targets inside Frostwing Halls when we are not there + return (me.GetPositionY() > 2660.0f) == (target.GetPositionY() > 2660.0f) && base.CanAIAttack(target); + } + } + + [Script] + class npc_impaling_spear : CreatureAI + { + public npc_impaling_spear(Creature creature) + : base(creature) + { + } + + public override void Reset() + { + me.SetReactState(ReactStates.Passive); + _vehicleCheckTimer = 500; + } + + public override void UpdateAI(uint diff) + { + if (_vehicleCheckTimer <= diff) + { + _vehicleCheckTimer = 500; + if (!me.GetVehicle()) + me.DespawnOrUnsummon(100); + } + else + _vehicleCheckTimer -= diff; + } + + uint _vehicleCheckTimer; + } + + [Script] + class npc_arthas_teleport_visual : NullCreatureAI + { + public npc_arthas_teleport_visual(Creature creature) + : base(creature) + { + _instance = creature.GetInstanceScript(); + } + + public override void Reset() + { + _events.Reset(); + if (_instance.GetBossState(Bosses.ProfessorPutricide) == EncounterState.Done && + _instance.GetBossState(Bosses.BloodQueenLanaThel) == EncounterState.Done && + _instance.GetBossState(Bosses.Sindragosa) == EncounterState.Done) + _events.ScheduleEvent(EventTypes.SoulMissile, RandomHelper.URand(1000, 6000)); + } + + void Update(uint diff) + { + if (_events.Empty()) + return; + + _events.Update(diff); + + if (_events.ExecuteEvent() == EventTypes.SoulMissile) + { + DoCastAOE(InstanceSpells.SoulMissile); + _events.ScheduleEvent(EventTypes.SoulMissile, RandomHelper.URand(5000, 7000)); + } + } + + InstanceScript _instance; + } + + [Script] + class spell_icc_stoneform : AuraScript + { + void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Creature target = GetTarget().ToCreature(); + if (target) + { + target.SetReactState(ReactStates.Passive); + target.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable | UnitFlags.ImmuneToPc); + target.SetUInt32Value(UnitFields.NpcEmotestate, (uint)Emote.OneshotCustomSpell02); + } + } + + void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Creature target = GetTarget().ToCreature(); + if (target) + { + target.SetReactState(ReactStates.Aggressive); + target.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable | UnitFlags.ImmuneToPc); + target.SetUInt32Value(UnitFields.NpcEmotestate, 0); + } + } + + public override void Register() + { + OnEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + } + } + + [Script] + class spell_icc_sprit_alarm : SpellScript + { + public const int AwakenWard1 = 22900; + public const int AwakenWard2 = 22907; + public const int AwakenWard3 = 22908; + public const int AwakenWard4 = 22909; + + void HandleEvent(uint effIndex) + { + PreventHitDefaultEffect(effIndex); + uint trapId = 0; + switch (GetSpellInfo().GetEffect(effIndex).MiscValue) + { + case AwakenWard1: + trapId = GameObjectIds.SpiritAlarm1; + break; + case AwakenWard2: + trapId = GameObjectIds.SpiritAlarm2; + break; + case AwakenWard3: + trapId = GameObjectIds.SpiritAlarm3; + break; + case AwakenWard4: + trapId = GameObjectIds.SpiritAlarm4; + break; + default: return; - - Position pos = caster.GetNearPosition(5.0f, 0.0f); - caster.SetHomePosition(pos); - caster.GetMotionMaster().MoveLand(1, pos); } - public override void Register() + GameObject trap = GetCaster().FindNearestGameObject(trapId, 5.0f); + if (trap) + trap.SetRespawnTime((int)trap.GetGoInfo().GetAutoCloseTime()); + + List wards = new List(); + GetCaster().GetCreatureListWithEntryInGrid(wards, CreatureIds.DeathboundWard, 150.0f); + wards.Sort(new ObjectDistanceOrderPred(GetCaster())); + foreach (var creature in wards) { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(RemoveAliveTarget, 0, Targets.UnitDestAreaEntry)); - OnEffectHit.Add(new EffectHandler(Land, 0, SpellEffectName.ScriptEffect)); + if (creature.IsAlive() && creature.HasAura(InstanceSpells.StoneForm)) + { + creature.GetAI().Talk(Texts.SayTrapActivate); + creature.RemoveAurasDueToSpell(InstanceSpells.StoneForm); + Unit target = creature.SelectNearestTarget(150.0f); + if (target) + creature.GetAI().AttackStart(target); + + break; + } } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_svalna_revive_champion_SpellScript(); + OnEffectHit.Add(new EffectHandler(HandleEvent, 2, SpellEffectName.SendEvent)); } } [Script] - class spell_svalna_remove_spear : SpellScriptLoader + class spell_frost_giant_death_plague : SpellScript { - public spell_svalna_remove_spear() : base("spell_svalna_remove_spear") { } - - class spell_svalna_remove_spear_SpellScript : SpellScript + public override bool Load() { - void HandleScript(uint effIndex) + _failed = false; + return true; + } + + // First effect + void CountTargets(List targets) + { + targets.Remove(GetCaster()); + _failed = targets.Empty(); + } + + // Second effect + void FilterTargets(List targets) + { + // Select valid targets for jump + targets.RemoveAll(obj => { - PreventHitDefaultEffect(effIndex); - Creature target = GetHitCreature(); - if (target) - { - Unit vehicle = target.GetVehicleBase(); - if (vehicle) - vehicle.RemoveAurasDueToSpell(InstanceSpells.ImpalingSpear); - target.DespawnOrUnsummon(1); - } + if (obj == GetCaster()) + return true; + + if (!obj.IsTypeId(TypeId.Player)) + return true; + + if (obj.ToUnit().HasAura(InstanceSpells.RecentlyInfected) || obj.ToUnit().HasAura(InstanceSpells.DeathPlagueAura)) + return true; + + return false; + }); + + if (!targets.Empty()) + { + WorldObject target = targets.SelectRandom(); + targets.Clear(); + targets.Add(target); } - public override void Register() + targets.Add(GetCaster()); + } + + void HandleScript(uint effIndex) + { + PreventHitDefaultEffect(effIndex); + if (GetHitUnit() != GetCaster()) + GetCaster().CastSpell(GetHitUnit(), InstanceSpells.DeathPlagueAura, true); + else if (_failed) + GetCaster().CastSpell(GetCaster(), InstanceSpells.DeathPlagueKill, true); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(CountTargets, 0, Targets.UnitSrcAreaAlly)); + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 1, Targets.UnitSrcAreaAlly)); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 1, SpellEffectName.ScriptEffect)); + } + + bool _failed; + } + + [Script] + class spell_icc_harvest_blight_specimen : SpellScript + { + void HandleScript(uint effIndex) + { + PreventHitDefaultEffect(effIndex); + GetHitUnit().RemoveAurasDueToSpell((uint)GetEffectValue()); + } + + void HandleQuestComplete(uint effIndex) + { + GetHitUnit().RemoveAurasDueToSpell((uint)GetEffectValue()); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new EffectHandler(HandleQuestComplete, 1, SpellEffectName.QuestComplete)); + } + } + + [Script] + class spell_svalna_revive_champion : SpellScript + { + void RemoveAliveTarget(List targets) + { + targets.RemoveAll(obj => { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + Unit unit = obj.ToUnit(); + if (unit) + return unit.IsAlive(); + + return true; + }); + targets = targets.SelectRandom(2).ToList(); + } + + void Land(uint effIndex) + { + Creature caster = GetCaster().ToCreature(); + if (!caster) + return; + + Position pos = caster.GetNearPosition(5.0f, 0.0f); + caster.SetHomePosition(pos); + caster.GetMotionMaster().MoveLand(1, pos); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(RemoveAliveTarget, 0, Targets.UnitDestAreaEntry)); + OnEffectHit.Add(new EffectHandler(Land, 0, SpellEffectName.ScriptEffect)); + } + } + + [Script] + class spell_svalna_remove_spear : SpellScript + { + void HandleScript(uint effIndex) + { + PreventHitDefaultEffect(effIndex); + Creature target = GetHitCreature(); + if (target) + { + Unit vehicle = target.GetVehicleBase(); + if (vehicle) + vehicle.RemoveAurasDueToSpell(InstanceSpells.ImpalingSpear); + target.DespawnOrUnsummon(1); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_svalna_remove_spear_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } // 72585 - Soul Missile [Script] - class spell_icc_soul_missile : SpellScriptLoader + class spell_icc_soul_missile : SpellScript { - public spell_icc_soul_missile() : base("spell_icc_soul_missile") { } - - class spell_icc_soul_missile_SpellScript : SpellScript + void RelocateDest(ref SpellDestination dest) { - void RelocateDest(ref SpellDestination dest) - { - Position offset = new Position(0.0f, 0.0f, 200.0f, 0.0f); - dest.RelocateOffset(offset); - } - - public override void Register() - { - OnDestinationTargetSelect.Add(new DestinationTargetSelectHandler(RelocateDest, 0, Targets.DestCaster)); - } + Position offset = new Position(0.0f, 0.0f, 200.0f, 0.0f); + dest.RelocateOffset(offset); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_icc_soul_missile_SpellScript(); + OnDestinationTargetSelect.Add(new DestinationTargetSelectHandler(RelocateDest, 0, Targets.DestCaster)); } } @@ -1905,43 +1709,27 @@ namespace Scripts.Northrend.IcecrownCitadel } [Script("spell_svalna_caress_of_death", 70196u)] - class spell_trigger_spell_from_caster : SpellScriptLoader + class spell_trigger_spell_from_caster : SpellScript { - public spell_trigger_spell_from_caster(string scriptName, uint triggerId) : base(scriptName) + public spell_trigger_spell_from_caster(uint triggerId) { _triggerId = triggerId; } - class spell_trigger_spell_from_caster_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - public spell_trigger_spell_from_caster_SpellScript(uint triggerId) - { - _triggerId = triggerId; - } - - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(_triggerId); - } - - void HandleTrigger() - { - GetCaster().CastSpell(GetHitUnit(), _triggerId, true); - } - - public override void Register() - { - AfterHit.Add(new HitHandler(HandleTrigger)); - } - - uint _triggerId; + return ValidateSpellInfo(_triggerId); } - public override SpellScript GetSpellScript() + void HandleTrigger() { - return new spell_trigger_spell_from_caster_SpellScript(_triggerId); + GetCaster().CastSpell(GetHitUnit(), _triggerId, true); } + public override void Register() + { + AfterHit.Add(new HitHandler(HandleTrigger)); + } uint _triggerId; } diff --git a/Scripts/Northrend/IcecrownCitadel/IcecrownCitadelConst.cs b/Scripts/Northrend/IcecrownCitadel/IcecrownCitadelConst.cs index 611cdf520..efa999a6c 100644 --- a/Scripts/Northrend/IcecrownCitadel/IcecrownCitadelConst.cs +++ b/Scripts/Northrend/IcecrownCitadel/IcecrownCitadelConst.cs @@ -38,7 +38,7 @@ namespace Scripts.Northrend.IcecrownCitadel public const uint Sindragosa = 11; public const uint TheLichKing = 12; - public const uint MaxEncounters = 13; + public const uint MaxEncounters = 13; } struct Texts diff --git a/Scripts/Northrend/IcecrownCitadel/LadyDeathwhisper.cs b/Scripts/Northrend/IcecrownCitadel/LadyDeathwhisper.cs index b0e3fb10a..8ef3fc444 100644 --- a/Scripts/Northrend/IcecrownCitadel/LadyDeathwhisper.cs +++ b/Scripts/Northrend/IcecrownCitadel/LadyDeathwhisper.cs @@ -212,874 +212,804 @@ namespace Scripts.Northrend.IcecrownCitadel } [Script] - class boss_lady_deathwhisper : CreatureScript + public class boss_lady_deathwhisper : BossAI { - public boss_lady_deathwhisper() : base("boss_lady_deathwhisper") { } - - public class boss_lady_deathwhisperAI : BossAI + public boss_lady_deathwhisper(Creature creature) + : base(creature, Bosses.LadyDeathwhisper) { - public boss_lady_deathwhisperAI(Creature creature) - : base(creature, Bosses.LadyDeathwhisper) - { - _dominateMindCount = RaidMode(0, 1, 1, 3); - _introDone = false; + _dominateMindCount = RaidMode(0, 1, 1, 3); + _introDone = false; + } + + public override void Reset() + { + _Reset(); + me.SetPower(PowerType.Mana, me.GetMaxPower(PowerType.Mana)); + _events.SetPhase(LadyConst.PhaseOne); + _waveCounter = 0; + _nextVengefulShadeTargetGUID.Clear(); + _darnavanGUID.Clear(); + DoCast(me, LadySpells.SHADOW_CHANNELING); + me.RemoveAurasDueToSpell(InstanceSpells.Berserk); + me.RemoveAurasDueToSpell(LadySpells.MANA_BARRIER); + me.ApplySpellImmune(0, SpellImmunity.State, AuraType.ModTaunt, false); + me.ApplySpellImmune(0, SpellImmunity.Effect, SpellEffectName.AttackMe, false); + } + + public override void MoveInLineOfSight(Unit who) + { + if (!_introDone && me.IsWithinDistInMap(who, 110.0f)) + { + _introDone = true; + Talk(LadyTexts.SAY_INTRO_1); + _events.SetPhase(LadyConst.PhaseIntro); + _events.ScheduleEvent(LadyEventTypes.INTRO_2, 11000, 0, LadyConst.PhaseIntro); + _events.ScheduleEvent(LadyEventTypes.INTRO_3, 21000, 0, LadyConst.PhaseIntro); + _events.ScheduleEvent(LadyEventTypes.INTRO_4, 31500, 0, LadyConst.PhaseIntro); + _events.ScheduleEvent(LadyEventTypes.INTRO_5, 39500, 0, LadyConst.PhaseIntro); + _events.ScheduleEvent(LadyEventTypes.INTRO_6, 48500, 0, LadyConst.PhaseIntro); + _events.ScheduleEvent(LadyEventTypes.INTRO_7, 58000, 0, LadyConst.PhaseIntro); + } + } + + public override void AttackStart(Unit victim) + { + if (me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable)) + return; + + if (victim && me.Attack(victim, true) && !_events.IsInPhase(LadyConst.PhaseOne)) + me.GetMotionMaster().MoveChase(victim); + } + + public override void EnterCombat(Unit who) + { + if (!instance.CheckRequiredBosses(Bosses.LadyDeathwhisper, who.ToPlayer())) + { + EnterEvadeMode(); + instance.DoCastSpellOnPlayers(TeleporterSpells.LIGHT_S_HAMMER_TELEPORT); + return; } - public override void Reset() + me.setActive(true); + DoZoneInCombat(); + + _events.Reset(); + _events.SetPhase(LadyConst.PhaseOne); + // phase-independent events + _events.ScheduleEvent(LadyEventTypes.BERSERK, 600000); + _events.ScheduleEvent(LadyEventTypes.DEATH_AND_DECAY, 10000); + // phase one only + _events.ScheduleEvent(LadyEventTypes.P1_SUMMON_WAVE, 5000, 0, LadyConst.PhaseOne); + _events.ScheduleEvent(LadyEventTypes.P1_SHADOW_BOLT, RandomHelper.URand(5500, 6000), 0, LadyConst.PhaseOne); + _events.ScheduleEvent(LadyEventTypes.P1_EMPOWER_CULTIST, RandomHelper.URand(20000, 30000), 0, LadyConst.PhaseOne); + _events.ScheduleEvent(LadyEventTypes.P1_REANIMATE_CULTIST, RandomHelper.URand(10000, 20000), 0, LadyConst.PhaseOne); + if (GetDifficulty() != Difficulty.Raid10N) + _events.ScheduleEvent(LadyEventTypes.DOMINATE_MIND_H, 27000); + + Talk(LadyTexts.SAY_AGGRO); + DoStartNoMovement(who); + me.RemoveAurasDueToSpell(LadySpells.SHADOW_CHANNELING); + DoCast(me, LadySpells.MANA_BARRIER, true); + + instance.SetBossState(Bosses.LadyDeathwhisper, EncounterState.InProgress); + } + + public override void JustDied(Unit killer) + { + Talk(LadyTexts.SAY_DEATH); + + List livingAddEntries = new List(); + // Full House achievement + foreach (var guid in summons) { - _Reset(); - me.SetPower(PowerType.Mana, me.GetMaxPower(PowerType.Mana)); - _events.SetPhase(LadyConst.PhaseOne); - _waveCounter = 0; - _nextVengefulShadeTargetGUID.Clear(); - _darnavanGUID.Clear(); - DoCast(me, LadySpells.SHADOW_CHANNELING); - me.RemoveAurasDueToSpell(InstanceSpells.Berserk); - me.RemoveAurasDueToSpell(LadySpells.MANA_BARRIER); - me.ApplySpellImmune(0, SpellImmunity.State, AuraType.ModTaunt, false); - me.ApplySpellImmune(0, SpellImmunity.Effect, SpellEffectName.AttackMe, false); + Unit unit = Global.ObjAccessor.GetUnit(me, guid); + if (unit) + if (unit.IsAlive() && unit.GetEntry() != CreatureIds.VengefulShade) + livingAddEntries.Add(unit.GetEntry()); } - public override void MoveInLineOfSight(Unit who) + if (livingAddEntries.Count >= 5) + instance.DoUpdateCriteria(CriteriaTypes.BeSpellTarget, LadySpells.FULL_HOUSE, 0, me); + + Creature darnavan = ObjectAccessor.GetCreature(me, _darnavanGUID); + if (darnavan) { - if (!_introDone && me.IsWithinDistInMap(who, 110.0f)) + if (darnavan.IsAlive()) { - _introDone = true; - Talk(LadyTexts.SAY_INTRO_1); - _events.SetPhase(LadyConst.PhaseIntro); - _events.ScheduleEvent(LadyEventTypes.INTRO_2, 11000, 0, LadyConst.PhaseIntro); - _events.ScheduleEvent(LadyEventTypes.INTRO_3, 21000, 0, LadyConst.PhaseIntro); - _events.ScheduleEvent(LadyEventTypes.INTRO_4, 31500, 0, LadyConst.PhaseIntro); - _events.ScheduleEvent(LadyEventTypes.INTRO_5, 39500, 0, LadyConst.PhaseIntro); - _events.ScheduleEvent(LadyEventTypes.INTRO_6, 48500, 0, LadyConst.PhaseIntro); - _events.ScheduleEvent(LadyEventTypes.INTRO_7, 58000, 0, LadyConst.PhaseIntro); - } - } - - public override void AttackStart(Unit victim) - { - if (me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable)) - return; - - if (victim && me.Attack(victim, true) && !_events.IsInPhase(LadyConst.PhaseOne)) - me.GetMotionMaster().MoveChase(victim); - } - - public override void EnterCombat(Unit who) - { - if (!instance.CheckRequiredBosses(Bosses.LadyDeathwhisper, who.ToPlayer())) - { - EnterEvadeMode(); - instance.DoCastSpellOnPlayers(TeleporterSpells.LIGHT_S_HAMMER_TELEPORT); - return; - } - - me.setActive(true); - DoZoneInCombat(); - - _events.Reset(); - _events.SetPhase(LadyConst.PhaseOne); - // phase-independent events - _events.ScheduleEvent(LadyEventTypes.BERSERK, 600000); - _events.ScheduleEvent(LadyEventTypes.DEATH_AND_DECAY, 10000); - // phase one only - _events.ScheduleEvent(LadyEventTypes.P1_SUMMON_WAVE, 5000, 0, LadyConst.PhaseOne); - _events.ScheduleEvent(LadyEventTypes.P1_SHADOW_BOLT, RandomHelper.URand(5500, 6000), 0, LadyConst.PhaseOne); - _events.ScheduleEvent(LadyEventTypes.P1_EMPOWER_CULTIST, RandomHelper.URand(20000, 30000), 0, LadyConst.PhaseOne); - _events.ScheduleEvent(LadyEventTypes.P1_REANIMATE_CULTIST, RandomHelper.URand(10000, 20000), 0, LadyConst.PhaseOne); - if (GetDifficulty() != Difficulty.Raid10N) - _events.ScheduleEvent(LadyEventTypes.DOMINATE_MIND_H, 27000); - - Talk(LadyTexts.SAY_AGGRO); - DoStartNoMovement(who); - me.RemoveAurasDueToSpell(LadySpells.SHADOW_CHANNELING); - DoCast(me, LadySpells.MANA_BARRIER, true); - - instance.SetBossState(Bosses.LadyDeathwhisper, EncounterState.InProgress); - } - - public override void JustDied(Unit killer) - { - Talk(LadyTexts.SAY_DEATH); - - List livingAddEntries = new List(); - // Full House achievement - foreach (var guid in summons) - { - Unit unit = Global.ObjAccessor.GetUnit(me, guid); - if (unit) - if (unit.IsAlive() && unit.GetEntry() != CreatureIds.VengefulShade) - livingAddEntries.Add(unit.GetEntry()); - } - - if (livingAddEntries.Count >= 5) - instance.DoUpdateCriteria(CriteriaTypes.BeSpellTarget, LadySpells.FULL_HOUSE, 0, me); - - Creature darnavan = ObjectAccessor.GetCreature(me, _darnavanGUID); - if (darnavan) - { - if (darnavan.IsAlive()) + darnavan.SetFaction(35); + darnavan.CombatStop(true); + darnavan.GetMotionMaster().MoveIdle(); + darnavan.SetReactState(ReactStates.Passive); + darnavan.m_Events.AddEvent(new DaranavanMoveEvent(darnavan), darnavan.m_Events.CalculateTime(10000)); + darnavan.GetAI().Talk(LadyTexts.SAY_DARNAVAN_RESCUED); + Player owner = killer.GetCharmerOrOwnerPlayerOrPlayerItself(); + if (owner) { - darnavan.SetFaction(35); - darnavan.CombatStop(true); - darnavan.GetMotionMaster().MoveIdle(); - darnavan.SetReactState(ReactStates.Passive); - darnavan.m_Events.AddEvent(new DaranavanMoveEvent(darnavan), darnavan.m_Events.CalculateTime(10000)); - darnavan.GetAI().Talk(LadyTexts.SAY_DARNAVAN_RESCUED); - Player owner = killer.GetCharmerOrOwnerPlayerOrPlayerItself(); - if (owner) + Group group = owner.GetGroup(); + if (group) { - Group group = owner.GetGroup(); - if (group) + for (GroupReference groupRefe = group.GetFirstMember(); groupRefe != null; groupRefe = groupRefe.next()) { - for (GroupReference groupRefe = group.GetFirstMember(); groupRefe != null; groupRefe = groupRefe.next()) - { - Player member = groupRefe.GetSource(); - if (member) - member.KilledMonsterCredit(NPC_DARNAVAN_CREDIT, ObjectGuid.Empty); - } + Player member = groupRefe.GetSource(); + if (member) + member.KilledMonsterCredit(NPC_DARNAVAN_CREDIT, ObjectGuid.Empty); } - else - owner.KilledMonsterCredit(NPC_DARNAVAN_CREDIT, ObjectGuid.Empty); } + else + owner.KilledMonsterCredit(NPC_DARNAVAN_CREDIT, ObjectGuid.Empty); } } - - _JustDied(); } - public override void JustReachedHome() - { - _JustReachedHome(); - instance.SetBossState(Bosses.LadyDeathwhisper, EncounterState.Fail); + _JustDied(); + } - summons.DespawnAll(); - Creature darnavan = ObjectAccessor.GetCreature(me, _darnavanGUID); - if (darnavan) + public override void JustReachedHome() + { + _JustReachedHome(); + instance.SetBossState(Bosses.LadyDeathwhisper, EncounterState.Fail); + + summons.DespawnAll(); + Creature darnavan = ObjectAccessor.GetCreature(me, _darnavanGUID); + if (darnavan) + { + darnavan.DespawnOrUnsummon(); + _darnavanGUID.Clear(); + } + } + + public override void KilledUnit(Unit victim) + { + if (victim.IsTypeId(TypeId.Player)) + Talk(LadyTexts.SAY_KILL); + } + + public override void DamageTaken(Unit damageDealer, ref uint damage) + { + // phase transition + if (_events.IsInPhase(LadyConst.PhaseOne) && damage > (uint)me.GetPower(PowerType.Mana)) + { + Talk(LadyTexts.SAY_PHASE_2); + Talk(LadyTexts.EMOTE_PHASE_2); + DoStartMovement(me.GetVictim()); + damage -= (uint)me.GetPower(PowerType.Mana); + me.SetPower(PowerType.Mana, 0); + me.RemoveAurasDueToSpell(LadySpells.MANA_BARRIER); + _events.SetPhase(LadyConst.PhaseTwo); + _events.ScheduleEvent(LadyEventTypes.P2_FROSTBOLT, RandomHelper.URand(10000, 12000), 0, LadyConst.PhaseTwo); + _events.ScheduleEvent(LadyEventTypes.P2_FROSTBOLT_VOLLEY, RandomHelper.URand(19000, 21000), 0, LadyConst.PhaseTwo); + _events.ScheduleEvent(LadyEventTypes.P2_TOUCH_OF_INSIGNIFICANCE, RandomHelper.URand(6000, 9000), 0, LadyConst.PhaseTwo); + _events.ScheduleEvent(LadyEventTypes.P2_SUMMON_SHADE, RandomHelper.URand(12000, 15000), 0, LadyConst.PhaseTwo); + // on heroic mode Lady Deathwhisper is immune to taunt effects in phase 2 and continues summoning adds + if (IsHeroic()) { - darnavan.DespawnOrUnsummon(); - _darnavanGUID.Clear(); + me.ApplySpellImmune(0, SpellImmunity.State, AuraType.ModTaunt, true); + me.ApplySpellImmune(0, SpellImmunity.Effect, SpellEffectName.AttackMe, true); + _events.ScheduleEvent(LadyEventTypes.P2_SUMMON_WAVE, 45000, 0, LadyConst.PhaseTwo); } } + } - public override void KilledUnit(Unit victim) + public override void JustSummoned(Creature summon) + { + if (summon.GetEntry() == NPC_DARNAVAN) + _darnavanGUID = summon.GetGUID(); + else + summons.Summon(summon); + + Unit target = null; + if (summon.GetEntry() == CreatureIds.VengefulShade) { - if (victim.IsTypeId(TypeId.Player)) - Talk(LadyTexts.SAY_KILL); + target = Global.ObjAccessor.GetUnit(me, _nextVengefulShadeTargetGUID); // Vengeful Shade + _nextVengefulShadeTargetGUID.Clear(); } + else + target = SelectTarget(SelectAggroTarget.Random); // Wave adds - public override void DamageTaken(Unit damageDealer, ref uint damage) + summon.GetAI().AttackStart(target); // CAN be NULL + } + + public override void UpdateAI(uint diff) + { + if ((!UpdateVictim() && !_events.IsInPhase(LadyConst.PhaseIntro))) + return; + + _events.Update(diff); + + if (me.HasUnitState(UnitState.Casting) && !_events.IsInPhase(LadyConst.PhaseIntro)) + return; + + Unit target; + + _events.ExecuteEvents(eventId => { - // phase transition - if (_events.IsInPhase(LadyConst.PhaseOne) && damage > (uint)me.GetPower(PowerType.Mana)) + + switch (eventId) { - Talk(LadyTexts.SAY_PHASE_2); - Talk(LadyTexts.EMOTE_PHASE_2); - DoStartMovement(me.GetVictim()); - damage -= (uint)me.GetPower(PowerType.Mana); - me.SetPower(PowerType.Mana, 0); - me.RemoveAurasDueToSpell(LadySpells.MANA_BARRIER); - _events.SetPhase(LadyConst.PhaseTwo); - _events.ScheduleEvent(LadyEventTypes.P2_FROSTBOLT, RandomHelper.URand(10000, 12000), 0, LadyConst.PhaseTwo); - _events.ScheduleEvent(LadyEventTypes.P2_FROSTBOLT_VOLLEY, RandomHelper.URand(19000, 21000), 0, LadyConst.PhaseTwo); - _events.ScheduleEvent(LadyEventTypes.P2_TOUCH_OF_INSIGNIFICANCE, RandomHelper.URand(6000, 9000), 0, LadyConst.PhaseTwo); - _events.ScheduleEvent(LadyEventTypes.P2_SUMMON_SHADE, RandomHelper.URand(12000, 15000), 0, LadyConst.PhaseTwo); - // on heroic mode Lady Deathwhisper is immune to taunt effects in phase 2 and continues summoning adds - if (IsHeroic()) - { - me.ApplySpellImmune(0, SpellImmunity.State, AuraType.ModTaunt, true); - me.ApplySpellImmune(0, SpellImmunity.Effect, SpellEffectName.AttackMe, true); + case LadyEventTypes.INTRO_2: + Talk(LadyTexts.SAY_INTRO_2); + break; + case LadyEventTypes.INTRO_3: + Talk(LadyTexts.SAY_INTRO_3); + break; + case LadyEventTypes.INTRO_4: + Talk(LadyTexts.SAY_INTRO_4); + break; + case LadyEventTypes.INTRO_5: + Talk(LadyTexts.SAY_INTRO_5); + break; + case LadyEventTypes.INTRO_6: + Talk(LadyTexts.SAY_INTRO_6); + break; + case LadyEventTypes.INTRO_7: + Talk(LadyTexts.SAY_INTRO_7); + break; + case LadyEventTypes.DEATH_AND_DECAY: + target = SelectTarget(SelectAggroTarget.Random); + if (target) + DoCast(target, LadySpells.DEATH_AND_DECAY); + _events.ScheduleEvent(LadyEventTypes.DEATH_AND_DECAY, RandomHelper.URand(22000, 30000)); + break; + case LadyEventTypes.DOMINATE_MIND_H: + Talk(LadyTexts.SAY_DOMINATE_MIND); + for (byte i = 0; i < _dominateMindCount; i++) + { + target = SelectTarget(SelectAggroTarget.Random, 1, 0.0f, true, -(int)LadySpells.DOMINATE_MIND_H); + if (target) + DoCast(target, LadySpells.DOMINATE_MIND_H); + } + _events.ScheduleEvent(LadyEventTypes.DOMINATE_MIND_H, RandomHelper.URand(40000, 45000)); + break; + case LadyEventTypes.P1_SUMMON_WAVE: + SummonWaveP1(); + _events.ScheduleEvent(LadyEventTypes.P1_SUMMON_WAVE, (uint)(IsHeroic() ? 45000 : 60000), 0, LadyConst.PhaseOne); + break; + case LadyEventTypes.P1_SHADOW_BOLT: + target = SelectTarget(SelectAggroTarget.Random); + if (target) + DoCast(target, LadySpells.SHADOW_BOLT); + _events.ScheduleEvent(LadyEventTypes.P1_SHADOW_BOLT, RandomHelper.URand(5000, 8000), 0, LadyConst.PhaseOne); + break; + case LadyEventTypes.P1_REANIMATE_CULTIST: + ReanimateCultist(); + _events.ScheduleEvent(LadyEventTypes.P1_REANIMATE_CULTIST, RandomHelper.URand(6000, 25000), 0, LadyConst.PhaseOne); + break; + case LadyEventTypes.P1_EMPOWER_CULTIST: + EmpowerCultist(); + _events.ScheduleEvent(LadyEventTypes.P1_EMPOWER_CULTIST, RandomHelper.URand(18000, 25000), 0, LadyConst.PhaseOne); + break; + case LadyEventTypes.P2_FROSTBOLT: + DoCastVictim(LadySpells.FROSTBOLT); + _events.ScheduleEvent(LadyEventTypes.P2_FROSTBOLT, RandomHelper.URand(10000, 11000), 0, LadyConst.PhaseTwo); + break; + case LadyEventTypes.P2_FROSTBOLT_VOLLEY: + DoCastAOE(LadySpells.FROSTBOLT_VOLLEY); + _events.ScheduleEvent(LadyEventTypes.P2_FROSTBOLT_VOLLEY, RandomHelper.URand(13000, 15000), 0, LadyConst.PhaseTwo); + break; + case LadyEventTypes.P2_TOUCH_OF_INSIGNIFICANCE: + DoCastVictim(LadySpells.TOUCH_OF_INSIGNIFICANCE); + _events.ScheduleEvent(LadyEventTypes.P2_TOUCH_OF_INSIGNIFICANCE, RandomHelper.URand(9000, 13000), 0, LadyConst.PhaseTwo); + break; + case LadyEventTypes.P2_SUMMON_SHADE: + Unit shadeTarget = SelectTarget(SelectAggroTarget.Random, 1); + if (shadeTarget) + { + _nextVengefulShadeTargetGUID = shadeTarget.GetGUID(); + DoCast(shadeTarget, LadySpells.SUMMON_SHADE); + } + _events.ScheduleEvent(LadyEventTypes.P2_SUMMON_SHADE, RandomHelper.URand(18000, 23000), 0, LadyConst.PhaseTwo); + break; + case LadyEventTypes.P2_SUMMON_WAVE: + SummonWaveP2(); _events.ScheduleEvent(LadyEventTypes.P2_SUMMON_WAVE, 45000, 0, LadyConst.PhaseTwo); - } + break; + case LadyEventTypes.BERSERK: + DoCast(me, InstanceSpells.Berserk); + Talk(LadyTexts.SAY_BERSERK); + break; } - } + }); - public override void JustSummoned(Creature summon) + // We should not melee attack when barrier is up + if (me.HasAura(LadySpells.MANA_BARRIER)) + return; + + DoMeleeAttackIfReady(); + } + + // summoning function for first phase + void SummonWaveP1() + { + byte addIndex = (byte)(_waveCounter & 1); + byte addIndexOther = (byte)(addIndex ^ 1); + + // Summon first add, replace it with Darnavan if weekly quest is active + if (_waveCounter != 0 || !Global.PoolMgr.IsSpawnedObject(QUEST_DEPROGRAMMING)) + Summon(LadyConst.SummonEntries[addIndex], LadyConst.SummonPositions[addIndex * 3]); + else + Summon(NPC_DARNAVAN, LadyConst.SummonPositions[addIndex * 3]); + + Summon(LadyConst.SummonEntries[addIndexOther], LadyConst.SummonPositions[addIndex * 3 + 1]); + Summon(LadyConst.SummonEntries[addIndex], LadyConst.SummonPositions[addIndex * 3 + 2]); + if (Is25ManRaid()) { - if (summon.GetEntry() == NPC_DARNAVAN) - _darnavanGUID = summon.GetGUID(); - else - summons.Summon(summon); - - Unit target = null; - if (summon.GetEntry() == CreatureIds.VengefulShade) - { - target = Global.ObjAccessor.GetUnit(me, _nextVengefulShadeTargetGUID); // Vengeful Shade - _nextVengefulShadeTargetGUID.Clear(); - } - else - target = SelectTarget(SelectAggroTarget.Random); // Wave adds - - summon.GetAI().AttackStart(target); // CAN be NULL + Summon(LadyConst.SummonEntries[addIndexOther], LadyConst.SummonPositions[addIndexOther * 3]); + Summon(LadyConst.SummonEntries[addIndex], LadyConst.SummonPositions[addIndexOther * 3 + 1]); + Summon(LadyConst.SummonEntries[addIndexOther], LadyConst.SummonPositions[addIndexOther * 3 + 2]); + Summon(LadyConst.SummonEntries[RandomHelper.IRand(0, 1)], LadyConst.SummonPositions[6]); } - public override void UpdateAI(uint diff) - { - if ((!UpdateVictim() && !_events.IsInPhase(LadyConst.PhaseIntro))) - return; + ++_waveCounter; + } - _events.Update(diff); - - if (me.HasUnitState(UnitState.Casting) && !_events.IsInPhase(LadyConst.PhaseIntro)) - return; - - Unit target; - - _events.ExecuteEvents(eventId => - { - - switch (eventId) - { - case LadyEventTypes.INTRO_2: - Talk(LadyTexts.SAY_INTRO_2); - break; - case LadyEventTypes.INTRO_3: - Talk(LadyTexts.SAY_INTRO_3); - break; - case LadyEventTypes.INTRO_4: - Talk(LadyTexts.SAY_INTRO_4); - break; - case LadyEventTypes.INTRO_5: - Talk(LadyTexts.SAY_INTRO_5); - break; - case LadyEventTypes.INTRO_6: - Talk(LadyTexts.SAY_INTRO_6); - break; - case LadyEventTypes.INTRO_7: - Talk(LadyTexts.SAY_INTRO_7); - break; - case LadyEventTypes.DEATH_AND_DECAY: - target = SelectTarget(SelectAggroTarget.Random); - if (target) - DoCast(target, LadySpells.DEATH_AND_DECAY); - _events.ScheduleEvent(LadyEventTypes.DEATH_AND_DECAY, RandomHelper.URand(22000, 30000)); - break; - case LadyEventTypes.DOMINATE_MIND_H: - Talk(LadyTexts.SAY_DOMINATE_MIND); - for (byte i = 0; i < _dominateMindCount; i++) - { - target = SelectTarget(SelectAggroTarget.Random, 1, 0.0f, true, -(int)LadySpells.DOMINATE_MIND_H); - if (target) - DoCast(target, LadySpells.DOMINATE_MIND_H); - } - _events.ScheduleEvent(LadyEventTypes.DOMINATE_MIND_H, RandomHelper.URand(40000, 45000)); - break; - case LadyEventTypes.P1_SUMMON_WAVE: - SummonWaveP1(); - _events.ScheduleEvent(LadyEventTypes.P1_SUMMON_WAVE, (uint)(IsHeroic() ? 45000 : 60000), 0, LadyConst.PhaseOne); - break; - case LadyEventTypes.P1_SHADOW_BOLT: - target = SelectTarget(SelectAggroTarget.Random); - if (target) - DoCast(target, LadySpells.SHADOW_BOLT); - _events.ScheduleEvent(LadyEventTypes.P1_SHADOW_BOLT, RandomHelper.URand(5000, 8000), 0, LadyConst.PhaseOne); - break; - case LadyEventTypes.P1_REANIMATE_CULTIST: - ReanimateCultist(); - _events.ScheduleEvent(LadyEventTypes.P1_REANIMATE_CULTIST, RandomHelper.URand(6000, 25000), 0, LadyConst.PhaseOne); - break; - case LadyEventTypes.P1_EMPOWER_CULTIST: - EmpowerCultist(); - _events.ScheduleEvent(LadyEventTypes.P1_EMPOWER_CULTIST, RandomHelper.URand(18000, 25000), 0, LadyConst.PhaseOne); - break; - case LadyEventTypes.P2_FROSTBOLT: - DoCastVictim(LadySpells.FROSTBOLT); - _events.ScheduleEvent(LadyEventTypes.P2_FROSTBOLT, RandomHelper.URand(10000, 11000), 0, LadyConst.PhaseTwo); - break; - case LadyEventTypes.P2_FROSTBOLT_VOLLEY: - DoCastAOE(LadySpells.FROSTBOLT_VOLLEY); - _events.ScheduleEvent(LadyEventTypes.P2_FROSTBOLT_VOLLEY, RandomHelper.URand(13000, 15000), 0, LadyConst.PhaseTwo); - break; - case LadyEventTypes.P2_TOUCH_OF_INSIGNIFICANCE: - DoCastVictim(LadySpells.TOUCH_OF_INSIGNIFICANCE); - _events.ScheduleEvent(LadyEventTypes.P2_TOUCH_OF_INSIGNIFICANCE, RandomHelper.URand(9000, 13000), 0, LadyConst.PhaseTwo); - break; - case LadyEventTypes.P2_SUMMON_SHADE: - Unit shadeTarget = SelectTarget(SelectAggroTarget.Random, 1); - if (shadeTarget) - { - _nextVengefulShadeTargetGUID = shadeTarget.GetGUID(); - DoCast(shadeTarget, LadySpells.SUMMON_SHADE); - } - _events.ScheduleEvent(LadyEventTypes.P2_SUMMON_SHADE, RandomHelper.URand(18000, 23000), 0, LadyConst.PhaseTwo); - break; - case LadyEventTypes.P2_SUMMON_WAVE: - SummonWaveP2(); - _events.ScheduleEvent(LadyEventTypes.P2_SUMMON_WAVE, 45000, 0, LadyConst.PhaseTwo); - break; - case LadyEventTypes.BERSERK: - DoCast(me, InstanceSpells.Berserk); - Talk(LadyTexts.SAY_BERSERK); - break; - } - }); - - // We should not melee attack when barrier is up - if (me.HasAura(LadySpells.MANA_BARRIER)) - return; - - DoMeleeAttackIfReady(); - } - - // summoning function for first phase - void SummonWaveP1() + // summoning function for second phase + void SummonWaveP2() + { + if (Is25ManRaid()) { byte addIndex = (byte)(_waveCounter & 1); - byte addIndexOther = (byte)(addIndex ^ 1); - - // Summon first add, replace it with Darnavan if weekly quest is active - if (_waveCounter != 0 || !Global.PoolMgr.IsSpawnedObject(QUEST_DEPROGRAMMING)) - Summon(LadyConst.SummonEntries[addIndex], LadyConst.SummonPositions[addIndex * 3]); - else - Summon(NPC_DARNAVAN, LadyConst.SummonPositions[addIndex * 3]); - - Summon(LadyConst.SummonEntries[addIndexOther], LadyConst.SummonPositions[addIndex * 3 + 1]); + Summon(LadyConst.SummonEntries[addIndex], LadyConst.SummonPositions[addIndex * 3]); + Summon(LadyConst.SummonEntries[addIndex ^ 1], LadyConst.SummonPositions[addIndex * 3 + 1]); Summon(LadyConst.SummonEntries[addIndex], LadyConst.SummonPositions[addIndex * 3 + 2]); - if (Is25ManRaid()) - { - Summon(LadyConst.SummonEntries[addIndexOther], LadyConst.SummonPositions[addIndexOther * 3]); - Summon(LadyConst.SummonEntries[addIndex], LadyConst.SummonPositions[addIndexOther * 3 + 1]); - Summon(LadyConst.SummonEntries[addIndexOther], LadyConst.SummonPositions[addIndexOther * 3 + 2]); - Summon(LadyConst.SummonEntries[RandomHelper.IRand(0, 1)], LadyConst.SummonPositions[6]); - } + } + else + Summon(LadyConst.SummonEntries[RandomHelper.IRand(0, 1)], LadyConst.SummonPositions[6]); - ++_waveCounter; + ++_waveCounter; + } + + // helper for summoning wave mobs + void Summon(uint entry, Position pos) + { + TempSummon summon = me.SummonCreature(entry, pos, TempSummonType.CorpseTimedDespawn, 10000); + if (summon) + summon.GetAI().DoCast(summon, LadySpells.TELEPORT_VISUAL); + } + + void ReanimateCultist() + { + if (summons.Empty()) + return; + + List temp = new List(); + foreach (var guid in summons.ToList()) + { + Creature cre = ObjectAccessor.GetCreature(me, guid); + if (cre) + if (cre.IsAlive() && (cre.GetEntry() == CreatureIds.CultFanatic || cre.GetEntry() == CreatureIds.CultAdherent)) + temp.Add(cre); } - // summoning function for second phase - void SummonWaveP2() + if (temp.Empty()) + return; + + Creature cultist = temp.SelectRandom(); + DoCast(cultist, LadySpells.DARK_MARTYRDOM_T, true); + } + + void EmpowerCultist() + { + if (summons.Empty()) + return; + + List temp = new List(); + foreach (var guid in summons) { - if (Is25ManRaid()) + Creature cre = ObjectAccessor.GetCreature(me, guid); + if (cre) + if (cre.IsAlive() && (cre.GetEntry() == CreatureIds.CultFanatic || cre.GetEntry() == CreatureIds.CultAdherent)) + temp.Add(cre); + } + + // noone to empower + if (temp.Empty()) + return; + + // select random cultist + Creature cultist = temp.SelectRandom(); + DoCast(cultist, cultist.GetEntry() == CreatureIds.CultFanatic ? LadySpells.DARK_TRANSFORMATION_T : LadySpells.DARK_EMPOWERMENT_T, true); + Talk(cultist.GetEntry() == CreatureIds.CultFanatic ? LadyTexts.SAY_DARK_TRANSFORMATION : LadyTexts.SAY_DARK_EMPOWERMENT); + } + + ObjectGuid _nextVengefulShadeTargetGUID; + ObjectGuid _darnavanGUID; + uint _waveCounter; + byte _dominateMindCount; + bool _introDone; + + uint NPC_DARNAVAN { get { return RaidMode(DeprogrammingData.NPC_DARNAVAN_10, DeprogrammingData.NPC_DARNAVAN_25, DeprogrammingData.NPC_DARNAVAN_10, DeprogrammingData.NPC_DARNAVAN_25); } } + uint NPC_DARNAVAN_CREDIT { get { return RaidMode(DeprogrammingData.NPC_DARNAVAN_CREDIT_10, DeprogrammingData.NPC_DARNAVAN_CREDIT_25, DeprogrammingData.NPC_DARNAVAN_CREDIT_10, DeprogrammingData.NPC_DARNAVAN_CREDIT_25); } } + uint QUEST_DEPROGRAMMING { get { return RaidMode(WeeklyQuestIds.Deprogramming10, WeeklyQuestIds.Deprogramming25, WeeklyQuestIds.Deprogramming10, WeeklyQuestIds.Deprogramming25); } } + } + + [Script] + class npc_cult_fanatic : ScriptedAI + { + public npc_cult_fanatic(Creature creature) : base(creature) { } + + public override void Reset() + { + _events.Reset(); + _events.ScheduleEvent(LadyEventTypes.FANATIC_NECROTIC_STRIKE, RandomHelper.URand(10000, 12000)); + _events.ScheduleEvent(LadyEventTypes.FANATIC_SHADOW_CLEAVE, RandomHelper.URand(14000, 16000)); + _events.ScheduleEvent(LadyEventTypes.FANATIC_VAMPIRIC_MIGHT, RandomHelper.URand(20000, 27000)); + } + + public override void SpellHit(Unit caster, SpellInfo spell) + { + switch (spell.Id) + { + case LadySpells.DARK_TRANSFORMATION: + me.UpdateEntry(CreatureIds.DeformedFanatic); + break; + case LadySpells.DARK_TRANSFORMATION_T: + if (me.HasFlag(ObjectFields.DynamicFlags, UnitDynFlags.Dead)) + break; + me.InterruptNonMeleeSpells(true); + DoCast(me, LadySpells.DARK_TRANSFORMATION); + break; + case LadySpells.DARK_MARTYRDOM_T: + me.InterruptNonMeleeSpells(true); + DoCast(me, LadySpells.DARK_MARTYRDOM_FANATIC); + break; + case LadySpells.DARK_MARTYRDOM_FANATIC: // 10nm + case 72495: // 25nm + case 72496: // 10hc + case 72497: // 25hc + me.SetFlag(UnitFields.Flags, UnitFlags.RemoveClientControl | UnitFlags.Pacified | UnitFlags.NonAttackable | UnitFlags.Unk29); + me.SetFlag(ObjectFields.DynamicFlags, UnitDynFlags.Dead); + me.SetFlag(UnitFields.Flags2, UnitFlags2.FeignDeath); + me.SetReactState(ReactStates.Passive); + me.AttackStop(); + _events.ScheduleEvent(LadyEventTypes.CULTIST_DARK_MARTYRDOM, 4000); + break; + default: + break; + + } + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _events.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + _events.ExecuteEvents(eventId => + { + switch (eventId) { - byte addIndex = (byte)(_waveCounter & 1); - Summon(LadyConst.SummonEntries[addIndex], LadyConst.SummonPositions[addIndex * 3]); - Summon(LadyConst.SummonEntries[addIndex ^ 1], LadyConst.SummonPositions[addIndex * 3 + 1]); - Summon(LadyConst.SummonEntries[addIndex], LadyConst.SummonPositions[addIndex * 3 + 2]); + case LadyEventTypes.FANATIC_NECROTIC_STRIKE: + DoCastVictim(LadySpells.NECROTIC_STRIKE); + _events.ScheduleEvent(LadyEventTypes.FANATIC_NECROTIC_STRIKE, RandomHelper.URand(11000, 13000)); + break; + case LadyEventTypes.FANATIC_SHADOW_CLEAVE: + DoCastVictim(LadySpells.SHADOW_CLEAVE); + _events.ScheduleEvent(LadyEventTypes.FANATIC_SHADOW_CLEAVE, RandomHelper.URand(9500, 11000)); + break; + case LadyEventTypes.FANATIC_VAMPIRIC_MIGHT: + DoCast(me, LadySpells.VAMPIRIC_MIGHT); + _events.ScheduleEvent(LadyEventTypes.FANATIC_VAMPIRIC_MIGHT, RandomHelper.URand(20000, 27000)); + break; + case LadyEventTypes.CULTIST_DARK_MARTYRDOM: + if (me.IsSummon()) + { + Unit owner = me.ToTempSummon().GetSummoner(); + if (owner) + if (owner.ToCreature()) + owner.ToCreature().GetAI().Talk(LadyTexts.SAY_ANIMATE_DEAD); + } + me.UpdateEntry(CreatureIds.ReanimatedFanatic); + me.RemoveFlag(UnitFields.Flags, UnitFlags.RemoveClientControl | UnitFlags.Pacified | UnitFlags.NonAttackable | UnitFlags.Unk29); + me.RemoveFlag(ObjectFields.DynamicFlags, UnitDynFlags.Dead); + me.RemoveFlag(UnitFields.Flags2, UnitFlags2.FeignDeath); + DoCast(me, LadySpells.FANATIC_S_DETERMINATION); + me.SetReactState(ReactStates.Aggressive); + AttackStart(SelectTarget(SelectAggroTarget.Random)); + break; + } + }); + + DoMeleeAttackIfReady(); + } + } + + [Script] + class npc_cult_adherent : ScriptedAI + { + public npc_cult_adherent(Creature creature) : base(creature) { } + + public override void Reset() + { + _events.Reset(); + _events.ScheduleEvent(LadyEventTypes.ADHERENT_FROST_FEVER, RandomHelper.URand(10000, 12000)); + _events.ScheduleEvent(LadyEventTypes.ADHERENT_DEATHCHILL, RandomHelper.URand(14000, 16000)); + _events.ScheduleEvent(LadyEventTypes.ADHERENT_CURSE_OF_TORPOR, RandomHelper.URand(14000, 16000)); + _events.ScheduleEvent(LadyEventTypes.ADHERENT_SHORUD_OF_THE_OCCULT, RandomHelper.URand(32000, 39000)); + } + + public override void SpellHit(Unit caster, SpellInfo spell) + { + switch (spell.Id) + { + case LadySpells.DARK_EMPOWERMENT: + me.UpdateEntry(CreatureIds.EmpoweredAdherent); + break; + case LadySpells.DARK_EMPOWERMENT_T: + if (me.HasFlag(ObjectFields.DynamicFlags, UnitDynFlags.Dead)) + break; + me.InterruptNonMeleeSpells(true); + DoCast(me, LadySpells.DARK_EMPOWERMENT); + break; + case LadySpells.DARK_MARTYRDOM_T: + me.InterruptNonMeleeSpells(true); + DoCast(me, LadySpells.DARK_MARTYRDOM_ADHERENT); + break; + case LadySpells.DARK_MARTYRDOM_ADHERENT: // 10nm + case 72498: // 25nm + case 72499: // 10hc + case 72500: // 25hc + me.SetFlag(UnitFields.Flags, UnitFlags.RemoveClientControl | UnitFlags.Pacified | UnitFlags.NonAttackable | UnitFlags.Unk29); + me.SetFlag(ObjectFields.DynamicFlags, UnitDynFlags.Dead); + me.SetFlag(UnitFields.Flags2, UnitFlags2.FeignDeath); + me.SetReactState(ReactStates.Passive); + me.AttackStop(); + _events.ScheduleEvent(LadyEventTypes.CULTIST_DARK_MARTYRDOM, 4000); + break; + default: + break; + } + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _events.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + _events.ExecuteEvents(eventId => + { + switch (eventId) + { + case LadyEventTypes.ADHERENT_FROST_FEVER: + DoCastVictim(LadySpells.FROST_FEVER); + _events.ScheduleEvent(LadyEventTypes.ADHERENT_FROST_FEVER, RandomHelper.URand(9000, 13000)); + break; + case LadyEventTypes.ADHERENT_DEATHCHILL: + if (me.GetEntry() == CreatureIds.EmpoweredAdherent) + DoCastVictim(LadySpells.DEATHCHILL_BLAST); + else + DoCastVictim(LadySpells.DEATHCHILL_BOLT); + _events.ScheduleEvent(LadyEventTypes.ADHERENT_DEATHCHILL, RandomHelper.URand(9000, 13000)); + break; + case LadyEventTypes.ADHERENT_CURSE_OF_TORPOR: + Unit target = SelectTarget(SelectAggroTarget.Random, 1); + if (target) + DoCast(target, LadySpells.CURSE_OF_TORPOR); + _events.ScheduleEvent(LadyEventTypes.ADHERENT_CURSE_OF_TORPOR, RandomHelper.URand(9000, 13000)); + break; + case LadyEventTypes.ADHERENT_SHORUD_OF_THE_OCCULT: + DoCast(me, LadySpells.SHORUD_OF_THE_OCCULT); + _events.ScheduleEvent(LadyEventTypes.ADHERENT_SHORUD_OF_THE_OCCULT, RandomHelper.URand(27000, 32000)); + break; + case LadyEventTypes.CULTIST_DARK_MARTYRDOM: + if (me.IsSummon()) + { + Unit owner = me.ToTempSummon().GetSummoner(); + if (owner) + if (owner.ToCreature()) + owner.ToCreature().GetAI().Talk(LadyTexts.SAY_ANIMATE_DEAD); + } + me.UpdateEntry(CreatureIds.ReanimatedAdherent); + me.RemoveFlag(UnitFields.Flags, UnitFlags.RemoveClientControl | UnitFlags.Pacified | UnitFlags.NonAttackable | UnitFlags.Unk29); + me.RemoveFlag(ObjectFields.DynamicFlags, UnitDynFlags.Dead); + me.RemoveFlag(UnitFields.Flags2, UnitFlags2.FeignDeath); + DoCast(me, LadySpells.FANATIC_S_DETERMINATION); + me.SetReactState(ReactStates.Aggressive); + AttackStart(SelectTarget(SelectAggroTarget.Random)); + break; + } + }); + + DoMeleeAttackIfReady(); + } + } + + [Script] + class npc_vengeful_shade : ScriptedAI + { + public npc_vengeful_shade(Creature creature) : base(creature) + { + me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); + } + + public override void Reset() + { + me.AddAura(LadySpells.VENGEFUL_BLAST_PASSIVE, me); + } + + public override void SpellHitTarget(Unit target, SpellInfo spell) + { + switch (spell.Id) + { + case LadySpells.VENGEFUL_BLAST: + case LadySpells.VENGEFUL_BLAST_25N: + case LadySpells.VENGEFUL_BLAST_10H: + case LadySpells.VENGEFUL_BLAST_25H: + me.KillSelf(); + break; + default: + break; + } + } + } + + [Script] + class npc_darnavan : ScriptedAI + { + public npc_darnavan(Creature creature) + : base(creature) + { + } + + public override void Reset() + { + _events.Reset(); + _events.ScheduleEvent(LadyEventTypes.DARNAVAN_BLADESTORM, 10000); + _events.ScheduleEvent(LadyEventTypes.DARNAVAN_INTIMIDATING_SHOUT, RandomHelper.URand(20000, 25000)); + _events.ScheduleEvent(LadyEventTypes.DARNAVAN_MORTAL_STRIKE, RandomHelper.URand(25000, 30000)); + _events.ScheduleEvent(LadyEventTypes.DARNAVAN_SUNDER_ARMOR, RandomHelper.URand(5000, 8000)); + _canCharge = true; + _canShatter = true; + } + + public override void JustDied(Unit killer) + { + _events.Reset(); + Player owner = killer.GetCharmerOrOwnerPlayerOrPlayerItself(); + if (owner) + { + Group group = owner.GetGroup(); + if (group) + { + for (GroupReference groupRefe = group.GetFirstMember(); groupRefe != null; groupRefe = groupRefe.next()) + { + Player member = groupRefe.GetSource(); + if (member) + member.FailQuest(QUEST_DEPROGRAMMING); + } } else - Summon(LadyConst.SummonEntries[RandomHelper.IRand(0, 1)], LadyConst.SummonPositions[6]); - - ++_waveCounter; + owner.FailQuest(QUEST_DEPROGRAMMING); } - - // helper for summoning wave mobs - void Summon(uint entry, Position pos) - { - TempSummon summon = me.SummonCreature(entry, pos, TempSummonType.CorpseTimedDespawn, 10000); - if (summon) - summon.GetAI().DoCast(summon, LadySpells.TELEPORT_VISUAL); - } - - void ReanimateCultist() - { - if (summons.Empty()) - return; - - List temp = new List(); - foreach (var guid in summons.ToList()) - { - Creature cre = ObjectAccessor.GetCreature(me, guid); - if (cre) - if (cre.IsAlive() && (cre.GetEntry() == CreatureIds.CultFanatic || cre.GetEntry() == CreatureIds.CultAdherent)) - temp.Add(cre); - } - - if (temp.Empty()) - return; - - Creature cultist = temp.SelectRandom(); - DoCast(cultist, LadySpells.DARK_MARTYRDOM_T, true); - } - - void EmpowerCultist() - { - if (summons.Empty()) - return; - - List temp = new List(); - foreach (var guid in summons) - { - Creature cre = ObjectAccessor.GetCreature(me, guid); - if (cre) - if (cre.IsAlive() && (cre.GetEntry() == CreatureIds.CultFanatic || cre.GetEntry() == CreatureIds.CultAdherent)) - temp.Add(cre); - } - - // noone to empower - if (temp.Empty()) - return; - - // select random cultist - Creature cultist = temp.SelectRandom(); - DoCast(cultist, cultist.GetEntry() == CreatureIds.CultFanatic ? LadySpells.DARK_TRANSFORMATION_T : LadySpells.DARK_EMPOWERMENT_T, true); - Talk(cultist.GetEntry() == CreatureIds.CultFanatic ? LadyTexts.SAY_DARK_TRANSFORMATION : LadyTexts.SAY_DARK_EMPOWERMENT); - } - - ObjectGuid _nextVengefulShadeTargetGUID; - ObjectGuid _darnavanGUID; - uint _waveCounter; - byte _dominateMindCount; - bool _introDone; - - uint NPC_DARNAVAN { get { return RaidMode(DeprogrammingData.NPC_DARNAVAN_10, DeprogrammingData.NPC_DARNAVAN_25, DeprogrammingData.NPC_DARNAVAN_10, DeprogrammingData.NPC_DARNAVAN_25); } } - uint NPC_DARNAVAN_CREDIT { get { return RaidMode(DeprogrammingData.NPC_DARNAVAN_CREDIT_10, DeprogrammingData.NPC_DARNAVAN_CREDIT_25, DeprogrammingData.NPC_DARNAVAN_CREDIT_10, DeprogrammingData.NPC_DARNAVAN_CREDIT_25); } } - uint QUEST_DEPROGRAMMING { get { return RaidMode(WeeklyQuestIds.Deprogramming10, WeeklyQuestIds.Deprogramming25, WeeklyQuestIds.Deprogramming10, WeeklyQuestIds.Deprogramming25); } } } - public override CreatureAI GetAI(Creature creature) + public override void MovementInform(MovementGeneratorType type, uint id) { - return InstanceIcecrownCitadel.GetInstanceAI(creature); + if (type != MovementGeneratorType.Point || id != DeprogrammingData.POINT_DESPAWN) + return; + + me.DespawnOrUnsummon(); + } + + public override void EnterCombat(Unit victim) + { + Talk(LadyTexts.SAY_DARNAVAN_AGGRO); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _events.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + if (_canShatter && me.GetVictim() && me.GetVictim().IsImmunedToDamage(SpellSchoolMask.Normal)) + { + DoCastVictim(LadySpells.SHATTERING_THROW); + _canShatter = false; + _events.ScheduleEvent(LadyEventTypes.DARNAVAN_SHATTERING_THROW, 30000); + return; + } + + if (_canCharge && !me.IsWithinMeleeRange(me.GetVictim())) + { + DoCastVictim(LadySpells.CHARGE); + _canCharge = false; + _events.ScheduleEvent(LadyEventTypes.DARNAVAN_CHARGE, 20000); + return; + } + + _events.ExecuteEvents(eventId => + { + switch (eventId) + { + case LadyEventTypes.DARNAVAN_BLADESTORM: + DoCast(LadySpells.BLADESTORM); + _events.ScheduleEvent(LadyEventTypes.DARNAVAN_BLADESTORM, RandomHelper.URand(90000, 100000)); + break; + case LadyEventTypes.DARNAVAN_CHARGE: + _canCharge = true; + break; + case LadyEventTypes.DARNAVAN_INTIMIDATING_SHOUT: + DoCast(LadySpells.INTIMIDATING_SHOUT); + _events.ScheduleEvent(LadyEventTypes.DARNAVAN_INTIMIDATING_SHOUT, RandomHelper.URand(90000, 120000)); + break; + case LadyEventTypes.DARNAVAN_MORTAL_STRIKE: + DoCastVictim(LadySpells.MORTAL_STRIKE); + _events.ScheduleEvent(LadyEventTypes.DARNAVAN_MORTAL_STRIKE, RandomHelper.URand(15000, 30000)); + break; + case LadyEventTypes.DARNAVAN_SHATTERING_THROW: + _canShatter = true; + break; + case LadyEventTypes.DARNAVAN_SUNDER_ARMOR: + DoCastVictim(LadySpells.SUNDER_ARMOR); + _events.ScheduleEvent(LadyEventTypes.DARNAVAN_SUNDER_ARMOR, RandomHelper.URand(3000, 7000)); + break; + } + }); + + DoMeleeAttackIfReady(); + } + + uint QUEST_DEPROGRAMMING { get { return RaidMode(WeeklyQuestIds.Deprogramming10, WeeklyQuestIds.Deprogramming25, WeeklyQuestIds.Deprogramming10, WeeklyQuestIds.Deprogramming25); } } + + bool _canCharge; + bool _canShatter; + } + + [Script] + class spell_deathwhisper_mana_barrier : AuraScript + { + void HandlePeriodicTick(AuraEffect aurEff) + { + PreventDefaultAction(); + Unit caster = GetCaster(); + if (caster) + { + int missingHealth = (int)(caster.GetMaxHealth() - caster.GetHealth()); + caster.ModifyHealth(missingHealth); + caster.ModifyPower(PowerType.Mana, -missingHealth); + } + } + + public override void Register() + { + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandlePeriodicTick, 0, AuraType.PeriodicTriggerSpell)); } } [Script] - class npc_cult_fanatic : CreatureScript + class spell_cultist_dark_martyrdom : SpellScript { - public npc_cult_fanatic() : base("npc_cult_fanatic") { } - - class npc_cult_fanaticAI : ScriptedAI + void HandleEffect(uint effIndex) { - public npc_cult_fanaticAI(Creature creature) : base(creature) { } - - public override void Reset() + if (GetCaster().IsSummon()) { - _events.Reset(); - _events.ScheduleEvent(LadyEventTypes.FANATIC_NECROTIC_STRIKE, RandomHelper.URand(10000, 12000)); - _events.ScheduleEvent(LadyEventTypes.FANATIC_SHADOW_CLEAVE, RandomHelper.URand(14000, 16000)); - _events.ScheduleEvent(LadyEventTypes.FANATIC_VAMPIRIC_MIGHT, RandomHelper.URand(20000, 27000)); - } - - public override void SpellHit(Unit caster, SpellInfo spell) - { - switch (spell.Id) - { - case LadySpells.DARK_TRANSFORMATION: - me.UpdateEntry(CreatureIds.DeformedFanatic); - break; - case LadySpells.DARK_TRANSFORMATION_T: - if (me.HasFlag(ObjectFields.DynamicFlags, UnitDynFlags.Dead)) - break; - me.InterruptNonMeleeSpells(true); - DoCast(me, LadySpells.DARK_TRANSFORMATION); - break; - case LadySpells.DARK_MARTYRDOM_T: - me.InterruptNonMeleeSpells(true); - DoCast(me, LadySpells.DARK_MARTYRDOM_FANATIC); - break; - case LadySpells.DARK_MARTYRDOM_FANATIC: // 10nm - case 72495: // 25nm - case 72496: // 10hc - case 72497: // 25hc - me.SetFlag(UnitFields.Flags, UnitFlags.RemoveClientControl | UnitFlags.Pacified | UnitFlags.NonAttackable | UnitFlags.Unk29); - me.SetFlag(ObjectFields.DynamicFlags, UnitDynFlags.Dead); - me.SetFlag(UnitFields.Flags2, UnitFlags2.FeignDeath); - me.SetReactState(ReactStates.Passive); - me.AttackStop(); - _events.ScheduleEvent(LadyEventTypes.CULTIST_DARK_MARTYRDOM, 4000); - break; - default: - break; - - } - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _events.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case LadyEventTypes.FANATIC_NECROTIC_STRIKE: - DoCastVictim(LadySpells.NECROTIC_STRIKE); - _events.ScheduleEvent(LadyEventTypes.FANATIC_NECROTIC_STRIKE, RandomHelper.URand(11000, 13000)); - break; - case LadyEventTypes.FANATIC_SHADOW_CLEAVE: - DoCastVictim(LadySpells.SHADOW_CLEAVE); - _events.ScheduleEvent(LadyEventTypes.FANATIC_SHADOW_CLEAVE, RandomHelper.URand(9500, 11000)); - break; - case LadyEventTypes.FANATIC_VAMPIRIC_MIGHT: - DoCast(me, LadySpells.VAMPIRIC_MIGHT); - _events.ScheduleEvent(LadyEventTypes.FANATIC_VAMPIRIC_MIGHT, RandomHelper.URand(20000, 27000)); - break; - case LadyEventTypes.CULTIST_DARK_MARTYRDOM: - if (me.IsSummon()) - { - Unit owner = me.ToTempSummon().GetSummoner(); - if (owner) - if (owner.ToCreature()) - owner.ToCreature().GetAI().Talk(LadyTexts.SAY_ANIMATE_DEAD); - } - me.UpdateEntry(CreatureIds.ReanimatedFanatic); - me.RemoveFlag(UnitFields.Flags, UnitFlags.RemoveClientControl | UnitFlags.Pacified | UnitFlags.NonAttackable | UnitFlags.Unk29); - me.RemoveFlag(ObjectFields.DynamicFlags, UnitDynFlags.Dead); - me.RemoveFlag(UnitFields.Flags2, UnitFlags2.FeignDeath); - DoCast(me, LadySpells.FANATIC_S_DETERMINATION); - me.SetReactState(ReactStates.Aggressive); - AttackStart(SelectTarget(SelectAggroTarget.Random)); - break; - } - }); - - DoMeleeAttackIfReady(); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return InstanceIcecrownCitadel.GetInstanceAI(creature); - } - } - - [Script] - class npc_cult_adherent : CreatureScript - { - public npc_cult_adherent() : base("npc_cult_adherent") { } - - class npc_cult_adherentAI : ScriptedAI - { - public npc_cult_adherentAI(Creature creature) : base(creature) { } - - public override void Reset() - { - _events.Reset(); - _events.ScheduleEvent(LadyEventTypes.ADHERENT_FROST_FEVER, RandomHelper.URand(10000, 12000)); - _events.ScheduleEvent(LadyEventTypes.ADHERENT_DEATHCHILL, RandomHelper.URand(14000, 16000)); - _events.ScheduleEvent(LadyEventTypes.ADHERENT_CURSE_OF_TORPOR, RandomHelper.URand(14000, 16000)); - _events.ScheduleEvent(LadyEventTypes.ADHERENT_SHORUD_OF_THE_OCCULT, RandomHelper.URand(32000, 39000)); - } - - public override void SpellHit(Unit caster, SpellInfo spell) - { - switch (spell.Id) - { - case LadySpells.DARK_EMPOWERMENT: - me.UpdateEntry(CreatureIds.EmpoweredAdherent); - break; - case LadySpells.DARK_EMPOWERMENT_T: - if (me.HasFlag(ObjectFields.DynamicFlags, UnitDynFlags.Dead)) - break; - me.InterruptNonMeleeSpells(true); - DoCast(me, LadySpells.DARK_EMPOWERMENT); - break; - case LadySpells.DARK_MARTYRDOM_T: - me.InterruptNonMeleeSpells(true); - DoCast(me, LadySpells.DARK_MARTYRDOM_ADHERENT); - break; - case LadySpells.DARK_MARTYRDOM_ADHERENT: // 10nm - case 72498: // 25nm - case 72499: // 10hc - case 72500: // 25hc - me.SetFlag(UnitFields.Flags, UnitFlags.RemoveClientControl | UnitFlags.Pacified | UnitFlags.NonAttackable | UnitFlags.Unk29); - me.SetFlag(ObjectFields.DynamicFlags, UnitDynFlags.Dead); - me.SetFlag(UnitFields.Flags2, UnitFlags2.FeignDeath); - me.SetReactState(ReactStates.Passive); - me.AttackStop(); - _events.ScheduleEvent(LadyEventTypes.CULTIST_DARK_MARTYRDOM, 4000); - break; - default: - break; - } - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _events.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case LadyEventTypes.ADHERENT_FROST_FEVER: - DoCastVictim(LadySpells.FROST_FEVER); - _events.ScheduleEvent(LadyEventTypes.ADHERENT_FROST_FEVER, RandomHelper.URand(9000, 13000)); - break; - case LadyEventTypes.ADHERENT_DEATHCHILL: - if (me.GetEntry() == CreatureIds.EmpoweredAdherent) - DoCastVictim(LadySpells.DEATHCHILL_BLAST); - else - DoCastVictim(LadySpells.DEATHCHILL_BOLT); - _events.ScheduleEvent(LadyEventTypes.ADHERENT_DEATHCHILL, RandomHelper.URand(9000, 13000)); - break; - case LadyEventTypes.ADHERENT_CURSE_OF_TORPOR: - Unit target = SelectTarget(SelectAggroTarget.Random, 1); - if (target) - DoCast(target, LadySpells.CURSE_OF_TORPOR); - _events.ScheduleEvent(LadyEventTypes.ADHERENT_CURSE_OF_TORPOR, RandomHelper.URand(9000, 13000)); - break; - case LadyEventTypes.ADHERENT_SHORUD_OF_THE_OCCULT: - DoCast(me, LadySpells.SHORUD_OF_THE_OCCULT); - _events.ScheduleEvent(LadyEventTypes.ADHERENT_SHORUD_OF_THE_OCCULT, RandomHelper.URand(27000, 32000)); - break; - case LadyEventTypes.CULTIST_DARK_MARTYRDOM: - if (me.IsSummon()) - { - Unit owner = me.ToTempSummon().GetSummoner(); - if (owner) - if (owner.ToCreature()) - owner.ToCreature().GetAI().Talk(LadyTexts.SAY_ANIMATE_DEAD); - } - me.UpdateEntry(CreatureIds.ReanimatedAdherent); - me.RemoveFlag(UnitFields.Flags, UnitFlags.RemoveClientControl | UnitFlags.Pacified | UnitFlags.NonAttackable | UnitFlags.Unk29); - me.RemoveFlag(ObjectFields.DynamicFlags, UnitDynFlags.Dead); - me.RemoveFlag(UnitFields.Flags2, UnitFlags2.FeignDeath); - DoCast(me, LadySpells.FANATIC_S_DETERMINATION); - me.SetReactState(ReactStates.Aggressive); - AttackStart(SelectTarget(SelectAggroTarget.Random)); - break; - } - }); - - DoMeleeAttackIfReady(); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return InstanceIcecrownCitadel.GetInstanceAI(creature); - } - } - - [Script] - class npc_vengeful_shade : CreatureScript - { - public npc_vengeful_shade() : base("npc_vengeful_shade") { } - - class npc_vengeful_shadeAI : ScriptedAI - { - public npc_vengeful_shadeAI(Creature creature) : base(creature) - { - me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); - } - - public override void Reset() - { - me.AddAura(LadySpells.VENGEFUL_BLAST_PASSIVE, me); - } - - public override void SpellHitTarget(Unit target, SpellInfo spell) - { - switch (spell.Id) - { - case LadySpells.VENGEFUL_BLAST: - case LadySpells.VENGEFUL_BLAST_25N: - case LadySpells.VENGEFUL_BLAST_10H: - case LadySpells.VENGEFUL_BLAST_25H: - me.KillSelf(); - break; - default: - break; - } - } - } - - public override CreatureAI GetAI(Creature creature) - { - return InstanceIcecrownCitadel.GetInstanceAI(creature); - } - } - - [Script] - class npc_darnavan : CreatureScript - { - public npc_darnavan() : base("npc_darnavan") { } - - class npc_darnavanAI : ScriptedAI - { - public npc_darnavanAI(Creature creature) - : base(creature) - { - } - - public override void Reset() - { - _events.Reset(); - _events.ScheduleEvent(LadyEventTypes.DARNAVAN_BLADESTORM, 10000); - _events.ScheduleEvent(LadyEventTypes.DARNAVAN_INTIMIDATING_SHOUT, RandomHelper.URand(20000, 25000)); - _events.ScheduleEvent(LadyEventTypes.DARNAVAN_MORTAL_STRIKE, RandomHelper.URand(25000, 30000)); - _events.ScheduleEvent(LadyEventTypes.DARNAVAN_SUNDER_ARMOR, RandomHelper.URand(5000, 8000)); - _canCharge = true; - _canShatter = true; - } - - public override void JustDied(Unit killer) - { - _events.Reset(); - Player owner = killer.GetCharmerOrOwnerPlayerOrPlayerItself(); + Unit owner = GetCaster().ToTempSummon().GetSummoner(); if (owner) - { - Group group = owner.GetGroup(); - if (group) - { - for (GroupReference groupRefe = group.GetFirstMember(); groupRefe != null; groupRefe = groupRefe.next()) - { - Player member = groupRefe.GetSource(); - if (member) - member.FailQuest(QUEST_DEPROGRAMMING); - } - } - else - owner.FailQuest(QUEST_DEPROGRAMMING); - } + owner.GetAI().SetGUID(GetCaster().GetGUID(), (int)LadyConst.GUIDCultist); } - public override void MovementInform(MovementGeneratorType type, uint id) - { - if (type != MovementGeneratorType.Point || id != DeprogrammingData.POINT_DESPAWN) - return; - - me.DespawnOrUnsummon(); - } - - public override void EnterCombat(Unit victim) - { - Talk(LadyTexts.SAY_DARNAVAN_AGGRO); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _events.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - if (_canShatter && me.GetVictim() && me.GetVictim().IsImmunedToDamage(SpellSchoolMask.Normal)) - { - DoCastVictim(LadySpells.SHATTERING_THROW); - _canShatter = false; - _events.ScheduleEvent(LadyEventTypes.DARNAVAN_SHATTERING_THROW, 30000); - return; - } - - if (_canCharge && !me.IsWithinMeleeRange(me.GetVictim())) - { - DoCastVictim(LadySpells.CHARGE); - _canCharge = false; - _events.ScheduleEvent(LadyEventTypes.DARNAVAN_CHARGE, 20000); - return; - } - - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case LadyEventTypes.DARNAVAN_BLADESTORM: - DoCast(LadySpells.BLADESTORM); - _events.ScheduleEvent(LadyEventTypes.DARNAVAN_BLADESTORM, RandomHelper.URand(90000, 100000)); - break; - case LadyEventTypes.DARNAVAN_CHARGE: - _canCharge = true; - break; - case LadyEventTypes.DARNAVAN_INTIMIDATING_SHOUT: - DoCast(LadySpells.INTIMIDATING_SHOUT); - _events.ScheduleEvent(LadyEventTypes.DARNAVAN_INTIMIDATING_SHOUT, RandomHelper.URand(90000, 120000)); - break; - case LadyEventTypes.DARNAVAN_MORTAL_STRIKE: - DoCastVictim(LadySpells.MORTAL_STRIKE); - _events.ScheduleEvent(LadyEventTypes.DARNAVAN_MORTAL_STRIKE, RandomHelper.URand(15000, 30000)); - break; - case LadyEventTypes.DARNAVAN_SHATTERING_THROW: - _canShatter = true; - break; - case LadyEventTypes.DARNAVAN_SUNDER_ARMOR: - DoCastVictim(LadySpells.SUNDER_ARMOR); - _events.ScheduleEvent(LadyEventTypes.DARNAVAN_SUNDER_ARMOR, RandomHelper.URand(3000, 7000)); - break; - } - }); - - DoMeleeAttackIfReady(); - } - - uint QUEST_DEPROGRAMMING { get { return RaidMode(WeeklyQuestIds.Deprogramming10, WeeklyQuestIds.Deprogramming25, WeeklyQuestIds.Deprogramming10, WeeklyQuestIds.Deprogramming25); } } - - bool _canCharge; - bool _canShatter; + GetCaster().KillSelf(); + GetCaster().SetDisplayId(GetCaster().GetEntry() == CreatureIds.CultFanatic ? 38009 : 38010u); } - public override CreatureAI GetAI(Creature creature) + public override void Register() { - return InstanceIcecrownCitadel.GetInstanceAI(creature); - } - } - - [Script] - class spell_deathwhisper_mana_barrier : SpellScriptLoader - { - public spell_deathwhisper_mana_barrier() : base("spell_deathwhisper_mana_barrier") { } - - class spell_deathwhisper_mana_barrier_AuraScript : AuraScript - { - void HandlePeriodicTick(AuraEffect aurEff) - { - PreventDefaultAction(); - Unit caster = GetCaster(); - if (caster) - { - int missingHealth = (int)(caster.GetMaxHealth() - caster.GetHealth()); - caster.ModifyHealth(missingHealth); - caster.ModifyPower(PowerType.Mana, -missingHealth); - } - } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandlePeriodicTick, 0, AuraType.PeriodicTriggerSpell)); - } - } - - public override AuraScript GetAuraScript() - { - return new spell_deathwhisper_mana_barrier_AuraScript(); - } - } - - [Script] - class spell_cultist_dark_martyrdom : SpellScriptLoader - { - public spell_cultist_dark_martyrdom() : base("spell_cultist_dark_martyrdom") { } - - class spell_cultist_dark_martyrdom_SpellScript : SpellScript - { - void HandleEffect(uint effIndex) - { - if (GetCaster().IsSummon()) - { - Unit owner = GetCaster().ToTempSummon().GetSummoner(); - if (owner) - owner.GetAI().SetGUID(GetCaster().GetGUID(), (int)LadyConst.GUIDCultist); - } - - GetCaster().KillSelf(); - GetCaster().SetDisplayId(GetCaster().GetEntry() == CreatureIds.CultFanatic ? 38009 : 38010u); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleEffect, 2, SpellEffectName.ForceDeselect)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_cultist_dark_martyrdom_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleEffect, 2, SpellEffectName.ForceDeselect)); } } diff --git a/Scripts/Northrend/IcecrownCitadel/LordMarrowgar.cs b/Scripts/Northrend/IcecrownCitadel/LordMarrowgar.cs index 7cecfdfc2..588497b4d 100644 --- a/Scripts/Northrend/IcecrownCitadel/LordMarrowgar.cs +++ b/Scripts/Northrend/IcecrownCitadel/LordMarrowgar.cs @@ -122,613 +122,524 @@ namespace Scripts.Northrend.IcecrownCitadel } [Script] - class boss_lord_marrowgar : CreatureScript + public class boss_lord_marrowgar : BossAI { - public boss_lord_marrowgar() : base("boss_lord_marrowgar") { } - - public class boss_lord_marrowgarAI : BossAI + public boss_lord_marrowgar(Creature creature) : base(creature, Bosses.LordMarrowgar) { - public boss_lord_marrowgarAI(Creature creature) : base(creature, Bosses.LordMarrowgar) + _boneStormDuration = RaidMode(20000, 30000, 20000, 30000); + _baseSpeed = creature.GetSpeedRate(UnitMoveType.Run); + _coldflameLastPos.Relocate(creature); + _introDone = false; + _boneSlice = false; + } + + public override void Reset() + { + _Reset(); + me.SetSpeedRate(UnitMoveType.Run, _baseSpeed); + me.RemoveAurasDueToSpell(Spells.BoneStorm); + me.RemoveAurasDueToSpell(InstanceSpells.Berserk); + + _events.ScheduleEvent(Misc.EventEnableBoneSlice, 10000); + _events.ScheduleEvent(Misc.EventBoneSpikeGraveyard, 15000, Misc.EventGroupSpecial); + _events.ScheduleEvent(Misc.EventColdflame, 5000, Misc.EventGroupSpecial); + _events.ScheduleEvent(Misc.EventWarnBoneStorm, RandomHelper.URand(45000, 50000)); + _events.ScheduleEvent(Misc.EventEnrage, 600000); + _boneSlice = false; + _boneSpikeImmune.Clear(); + } + + public override void EnterCombat(Unit who) + { + Talk(Texts.SayAggro); + + me.setActive(true); + DoZoneInCombat(); + instance.SetBossState(Bosses.LordMarrowgar, EncounterState.InProgress); + } + + public override void JustDied(Unit killer) + { + Talk(Texts.SayDeath); + + _JustDied(); + } + + public override void JustReachedHome() + { + _JustReachedHome(); + instance.SetBossState(Bosses.LordMarrowgar, EncounterState.Fail); + instance.SetData(DataTypes.BonedAchievement, 1); // reset + } + + public override void KilledUnit(Unit victim) + { + if (victim.IsTypeId(TypeId.Player)) + Talk(Texts.SayKill); + } + + public override void MoveInLineOfSight(Unit who) + { + if (!_introDone && me.IsWithinDistInMap(who, 70.0f)) { - _boneStormDuration = RaidMode(20000, 30000, 20000, 30000); - _baseSpeed = creature.GetSpeedRate(UnitMoveType.Run); - _coldflameLastPos.Relocate(creature); - _introDone = false; - _boneSlice = false; + Talk(Texts.SayEnterZone); + _introDone = true; } + } - public override void Reset() + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _events.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + _events.ExecuteEvents(eventId => { - _Reset(); - me.SetSpeedRate(UnitMoveType.Run, _baseSpeed); - me.RemoveAurasDueToSpell(Spells.BoneStorm); - me.RemoveAurasDueToSpell(InstanceSpells.Berserk); - - _events.ScheduleEvent(Misc.EventEnableBoneSlice, 10000); - _events.ScheduleEvent(Misc.EventBoneSpikeGraveyard, 15000, Misc.EventGroupSpecial); - _events.ScheduleEvent(Misc.EventColdflame, 5000, Misc.EventGroupSpecial); - _events.ScheduleEvent(Misc.EventWarnBoneStorm, RandomHelper.URand(45000, 50000)); - _events.ScheduleEvent(Misc.EventEnrage, 600000); - _boneSlice = false; - _boneSpikeImmune.Clear(); - } - - public override void EnterCombat(Unit who) - { - Talk(Texts.SayAggro); - - me.setActive(true); - DoZoneInCombat(); - instance.SetBossState(Bosses.LordMarrowgar, EncounterState.InProgress); - } - - public override void JustDied(Unit killer) - { - Talk(Texts.SayDeath); - - _JustDied(); - } - - public override void JustReachedHome() - { - _JustReachedHome(); - instance.SetBossState(Bosses.LordMarrowgar, EncounterState.Fail); - instance.SetData(DataTypes.BonedAchievement, 1); // reset - } - - public override void KilledUnit(Unit victim) - { - if (victim.IsTypeId(TypeId.Player)) - Talk(Texts.SayKill); - } - - public override void MoveInLineOfSight(Unit who) - { - if (!_introDone && me.IsWithinDistInMap(who, 70.0f)) + switch (eventId) { - Talk(Texts.SayEnterZone); - _introDone = true; - } - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _events.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case Misc.EventBoneSpikeGraveyard: - if (IsHeroic() || !me.HasAura(Spells.BoneStorm)) - DoCast(me, Spells.BoneSpikeGraveyard); - _events.ScheduleEvent(Misc.EventBoneSpikeGraveyard, RandomHelper.URand(15000, 20000), Misc.EventGroupSpecial); - break; - case Misc.EventColdflame: - _coldflameLastPos.Relocate(me); - _coldflameTarget.Clear(); - if (!me.HasAura(Spells.BoneStorm)) - DoCastAOE(Spells.ColdflameNormal); - else - DoCast(me, Spells.ColdflameBoneStorm); - _events.ScheduleEvent(Misc.EventColdflame, 5000, Misc.EventGroupSpecial); - break; - case Misc.EventWarnBoneStorm: - _boneSlice = false; - Talk(Texts.SayBoneStorm); - me.FinishSpell(CurrentSpellTypes.Melee, false); - DoCast(me, Spells.BoneStorm); - _events.DelayEvents(3000, Misc.EventGroupSpecial); - _events.ScheduleEvent(Misc.EventBoneStormBegin, 3050); - _events.ScheduleEvent(Misc.EventWarnBoneStorm, RandomHelper.URand(90000, 95000)); - break; - case Misc.EventBoneStormBegin: - Aura pStorm = me.GetAura(Spells.BoneStorm); - if (pStorm != null) - pStorm.SetDuration((int)_boneStormDuration); - me.SetSpeedRate(UnitMoveType.Run, _baseSpeed * 3.0f); - Talk(Texts.SayBoneStorm); - _events.ScheduleEvent(Misc.EventBoneStormEnd, _boneStormDuration + 1); - goto case Misc.EventBoneStormMove; - // no break here - case Misc.EventBoneStormMove: - { - _events.ScheduleEvent(Misc.EventBoneStormMove, _boneStormDuration / 3); - Unit unit = SelectTarget(SelectAggroTarget.Random, 0, new NonTankTargetSelector(me)); - if (!unit) - unit = SelectTarget(SelectAggroTarget.Random, 0, 0.0f, true); - if (unit) - me.GetMotionMaster().MovePoint(Misc.PointTargetBonestormPlayer, unit); - break; - } - case Misc.EventBoneStormEnd: - if (me.GetMotionMaster().GetCurrentMovementGeneratorType() == MovementGeneratorType.Point) - me.GetMotionMaster().MovementExpired(); - me.GetMotionMaster().MoveChase(me.GetVictim()); - me.SetSpeedRate(UnitMoveType.Run, _baseSpeed); - _events.CancelEvent(Misc.EventBoneStormMove); - _events.ScheduleEvent(Misc.EventEnableBoneSlice, 10000); - if (!IsHeroic()) - _events.RescheduleEvent(Misc.EventBoneSpikeGraveyard, 15000, Misc.EventGroupSpecial); - break; - case Misc.EventEnableBoneSlice: - _boneSlice = true; - break; - case Misc.EventEnrage: - DoCast(me, Texts.SayBerserk, true); - Talk(Texts.SayBerserk); - break; - } - }); - - // We should not melee attack when storming - if (me.HasAura(Spells.BoneStorm)) - return; - - // 10 seconds since encounter start Bone Slice replaces melee attacks - if (_boneSlice && !me.GetCurrentSpell(CurrentSpellTypes.Melee)) - DoCastVictim(Spells.BoneSlice); - - DoMeleeAttackIfReady(); - } - - public override void MovementInform(MovementGeneratorType type, uint id) - { - if (type != MovementGeneratorType.Point || id != Misc.PointTargetBonestormPlayer) - return; - - // lock movement - me.GetMotionMaster().MoveIdle(); - } - - public Position GetLastColdflamePosition() - { - return _coldflameLastPos; - } - - public override ObjectGuid GetGUID(int type = 0) - { - switch (type) - { - case Misc.DataColdflameGuid: - return _coldflameTarget; - case Misc.DataSpikeImmune + 0: - case Misc.DataSpikeImmune + 1: - case Misc.DataSpikeImmune + 2: + case Misc.EventBoneSpikeGraveyard: + if (IsHeroic() || !me.HasAura(Spells.BoneStorm)) + DoCast(me, Spells.BoneSpikeGraveyard); + _events.ScheduleEvent(Misc.EventBoneSpikeGraveyard, RandomHelper.URand(15000, 20000), Misc.EventGroupSpecial); + break; + case Misc.EventColdflame: + _coldflameLastPos.Relocate(me); + _coldflameTarget.Clear(); + if (!me.HasAura(Spells.BoneStorm)) + DoCastAOE(Spells.ColdflameNormal); + else + DoCast(me, Spells.ColdflameBoneStorm); + _events.ScheduleEvent(Misc.EventColdflame, 5000, Misc.EventGroupSpecial); + break; + case Misc.EventWarnBoneStorm: + _boneSlice = false; + Talk(Texts.SayBoneStorm); + me.FinishSpell(CurrentSpellTypes.Melee, false); + DoCast(me, Spells.BoneStorm); + _events.DelayEvents(3000, Misc.EventGroupSpecial); + _events.ScheduleEvent(Misc.EventBoneStormBegin, 3050); + _events.ScheduleEvent(Misc.EventWarnBoneStorm, RandomHelper.URand(90000, 95000)); + break; + case Misc.EventBoneStormBegin: + Aura pStorm = me.GetAura(Spells.BoneStorm); + if (pStorm != null) + pStorm.SetDuration((int)_boneStormDuration); + me.SetSpeedRate(UnitMoveType.Run, _baseSpeed * 3.0f); + Talk(Texts.SayBoneStorm); + _events.ScheduleEvent(Misc.EventBoneStormEnd, _boneStormDuration + 1); + goto case Misc.EventBoneStormMove; + // no break here + case Misc.EventBoneStormMove: { - int index = type - Misc.DataSpikeImmune; - if (index < _boneSpikeImmune.Count) - return _boneSpikeImmune[index]; - + _events.ScheduleEvent(Misc.EventBoneStormMove, _boneStormDuration / 3); + Unit unit = SelectTarget(SelectAggroTarget.Random, 0, new NonTankTargetSelector(me)); + if (!unit) + unit = SelectTarget(SelectAggroTarget.Random, 0, 0.0f, true); + if (unit) + me.GetMotionMaster().MovePoint(Misc.PointTargetBonestormPlayer, unit); break; } - } - - return ObjectGuid.Empty; - } - - public override void SetGUID(ObjectGuid guid, int type = 0) - { - switch (type) - { - case Misc.DataColdflameGuid: - _coldflameTarget = guid; + case Misc.EventBoneStormEnd: + if (me.GetMotionMaster().GetCurrentMovementGeneratorType() == MovementGeneratorType.Point) + me.GetMotionMaster().MovementExpired(); + me.GetMotionMaster().MoveChase(me.GetVictim()); + me.SetSpeedRate(UnitMoveType.Run, _baseSpeed); + _events.CancelEvent(Misc.EventBoneStormMove); + _events.ScheduleEvent(Misc.EventEnableBoneSlice, 10000); + if (!IsHeroic()) + _events.RescheduleEvent(Misc.EventBoneSpikeGraveyard, 15000, Misc.EventGroupSpecial); break; - case Misc.DataSpikeImmune: - _boneSpikeImmune.Add(guid); + case Misc.EventEnableBoneSlice: + _boneSlice = true; + break; + case Misc.EventEnrage: + DoCast(me, Texts.SayBerserk, true); + Talk(Texts.SayBerserk); break; } - } + }); - public override void DoAction(int action) - { - if (action != Misc.ActionClearSpikeImmunities) - return; + // We should not melee attack when storming + if (me.HasAura(Spells.BoneStorm)) + return; - _boneSpikeImmune.Clear(); - } + // 10 seconds since encounter start Bone Slice replaces melee attacks + if (_boneSlice && !me.GetCurrentSpell(CurrentSpellTypes.Melee)) + DoCastVictim(Spells.BoneSlice); - Position _coldflameLastPos = new Position(); - List _boneSpikeImmune = new List(); - ObjectGuid _coldflameTarget; - uint _boneStormDuration; - float _baseSpeed; - bool _introDone; - bool _boneSlice; + DoMeleeAttackIfReady(); } - public override CreatureAI GetAI(Creature creature) + public override void MovementInform(MovementGeneratorType type, uint id) { - return InstanceIcecrownCitadel.GetInstanceAI(creature); + if (type != MovementGeneratorType.Point || id != Misc.PointTargetBonestormPlayer) + return; + + // lock movement + me.GetMotionMaster().MoveIdle(); } + + public Position GetLastColdflamePosition() + { + return _coldflameLastPos; + } + + public override ObjectGuid GetGUID(int type = 0) + { + switch (type) + { + case Misc.DataColdflameGuid: + return _coldflameTarget; + case Misc.DataSpikeImmune + 0: + case Misc.DataSpikeImmune + 1: + case Misc.DataSpikeImmune + 2: + { + int index = type - Misc.DataSpikeImmune; + if (index < _boneSpikeImmune.Count) + return _boneSpikeImmune[index]; + + break; + } + } + + return ObjectGuid.Empty; + } + + public override void SetGUID(ObjectGuid guid, int type = 0) + { + switch (type) + { + case Misc.DataColdflameGuid: + _coldflameTarget = guid; + break; + case Misc.DataSpikeImmune: + _boneSpikeImmune.Add(guid); + break; + } + } + + public override void DoAction(int action) + { + if (action != Misc.ActionClearSpikeImmunities) + return; + + _boneSpikeImmune.Clear(); + } + + Position _coldflameLastPos = new Position(); + List _boneSpikeImmune = new List(); + ObjectGuid _coldflameTarget; + uint _boneStormDuration; + float _baseSpeed; + bool _introDone; + bool _boneSlice; } [Script] - class npc_coldflame : CreatureScript + class npc_coldflame : ScriptedAI { - public npc_coldflame() : base("npc_coldflame") { } + public npc_coldflame(Creature creature) : base(creature) { } - class npc_coldflameAI : ScriptedAI + public override void IsSummonedBy(Unit owner) { - public npc_coldflameAI(Creature creature) : base(creature) { } + if (!owner.IsTypeId(TypeId.Player)) + return; - public override void IsSummonedBy(Unit owner) + Position pos = new Position(); + var marrowgarAI = (boss_lord_marrowgar)owner.GetAI(); + if (marrowgarAI != null) + pos.Relocate(marrowgarAI.GetLastColdflamePosition()); + else + pos.Relocate(owner); + + if (owner.HasAura(Spells.BoneStorm)) { - if (!owner.IsTypeId(TypeId.Player)) + float ang = Position.NormalizeOrientation(pos.GetAngle(me)); + me.SetOrientation(ang); + owner.GetNearPoint2D(out pos.posX, out pos.posY, 5.0f - owner.GetObjectSize(), ang); + } + else + { + Player target = Global.ObjAccessor.GetPlayer(owner, owner.GetAI().GetGUID(Misc.DataColdflameGuid)); + if (!target) + { + me.DespawnOrUnsummon(); return; - - Position pos = new Position(); - var marrowgarAI = (boss_lord_marrowgar.boss_lord_marrowgarAI)owner.GetAI(); - if (marrowgarAI != null) - pos.Relocate(marrowgarAI.GetLastColdflamePosition()); - else - pos.Relocate(owner); - - if (owner.HasAura(Spells.BoneStorm)) - { - float ang = Position.NormalizeOrientation(pos.GetAngle(me)); - me.SetOrientation(ang); - owner.GetNearPoint2D(out pos.posX, out pos.posY, 5.0f - owner.GetObjectSize(), ang); - } - else - { - Player target = Global.ObjAccessor.GetPlayer(owner, owner.GetAI().GetGUID(Misc.DataColdflameGuid)); - if (!target) - { - me.DespawnOrUnsummon(); - return; - } - - float ang = Position.NormalizeOrientation(pos.GetAngle(target)); - me.SetOrientation(ang); - owner.GetNearPoint2D(out pos.posX, out pos.posY, 15.0f - owner.GetObjectSize(), ang); } - me.NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), me.GetPositionZ(), me.GetOrientation()); + float ang = Position.NormalizeOrientation(pos.GetAngle(target)); + me.SetOrientation(ang); + owner.GetNearPoint2D(out pos.posX, out pos.posY, 15.0f - owner.GetObjectSize(), ang); + } + + me.NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), me.GetPositionZ(), me.GetOrientation()); + DoCast(Spells.ColdflameSummon); + _events.ScheduleEvent(Misc.EventColdflameTrigger, 500); + } + + public override void UpdateAI(uint diff) + { + _events.Update(diff); + + if (_events.ExecuteEvent() == Misc.EventColdflameTrigger) + { + Position newPos = me.GetNearPosition(5.0f, 0.0f); + me.NearTeleportTo(newPos.GetPositionX(), newPos.GetPositionY(), me.GetPositionZ(), me.GetOrientation()); DoCast(Spells.ColdflameSummon); _events.ScheduleEvent(Misc.EventColdflameTrigger, 500); } - - public override void UpdateAI(uint diff) - { - _events.Update(diff); - - if (_events.ExecuteEvent() == Misc.EventColdflameTrigger) - { - Position newPos = me.GetNearPosition(5.0f, 0.0f); - me.NearTeleportTo(newPos.GetPositionX(), newPos.GetPositionY(), me.GetPositionZ(), me.GetOrientation()); - DoCast(Spells.ColdflameSummon); - _events.ScheduleEvent(Misc.EventColdflameTrigger, 500); - } - } - } - - public override CreatureAI GetAI(Creature creature) - { - return InstanceIcecrownCitadel.GetInstanceAI(creature); } } [Script] - class npc_bone_spike : CreatureScript + class npc_bone_spike : ScriptedAI { - public npc_bone_spike() : base("npc_bone_spike") { } - - class npc_bone_spikeAI : ScriptedAI + public npc_bone_spike(Creature creature) + : base(creature) { - public npc_bone_spikeAI(Creature creature) - : base(creature) - { - _hasTrappedUnit = false; - Contract.Assert(creature.GetVehicleKit()); + _hasTrappedUnit = false; + Contract.Assert(creature.GetVehicleKit()); - SetCombatMovement(false); - } - - public override void JustDied(Unit killer) - { - TempSummon summ = me.ToTempSummon(); - if (summ) - { - Unit trapped = summ.GetSummoner(); - if (trapped) - trapped.RemoveAurasDueToSpell(Spells.Impaled); - } - - me.DespawnOrUnsummon(); - } - - public override void KilledUnit(Unit victim) - { - me.DespawnOrUnsummon(); - victim.RemoveAurasDueToSpell(Spells.Impaled); - } - - public override void IsSummonedBy(Unit summoner) - { - DoCast(summoner, Spells.Impaled); - summoner.CastSpell(me, Spells.RideVehicle, true); - _events.ScheduleEvent(Misc.EventFailBoned, 8000); - _hasTrappedUnit = true; - } - - public override void PassengerBoarded(Unit passenger, sbyte seat, bool apply) - { - if (!apply) - return; - - // @HACK - Change passenger offset to the one taken directly from sniffs - // Remove this when proper calculations are implemented. - // This fixes healing spiked people - MoveSplineInit init = new MoveSplineInit(passenger); - init.DisableTransportPathTransformations(); - init.MoveTo(-0.02206125f, -0.02132235f, 5.514783f, false); - init.Launch(); - } - - public override void UpdateAI(uint diff) - { - if (!_hasTrappedUnit) - return; - - _events.Update(diff); - - if (_events.ExecuteEvent() == Misc.EventFailBoned) - { - InstanceScript instance = me.GetInstanceScript(); - if (instance != null) - instance.SetData(DataTypes.BonedAchievement, 0); - } - } - - bool _hasTrappedUnit; + SetCombatMovement(false); } - public override CreatureAI GetAI(Creature creature) + public override void JustDied(Unit killer) { - return InstanceIcecrownCitadel.GetInstanceAI(creature); + TempSummon summ = me.ToTempSummon(); + if (summ) + { + Unit trapped = summ.GetSummoner(); + if (trapped) + trapped.RemoveAurasDueToSpell(Spells.Impaled); + } + + me.DespawnOrUnsummon(); + } + + public override void KilledUnit(Unit victim) + { + me.DespawnOrUnsummon(); + victim.RemoveAurasDueToSpell(Spells.Impaled); + } + + public override void IsSummonedBy(Unit summoner) + { + DoCast(summoner, Spells.Impaled); + summoner.CastSpell(me, Spells.RideVehicle, true); + _events.ScheduleEvent(Misc.EventFailBoned, 8000); + _hasTrappedUnit = true; + } + + public override void PassengerBoarded(Unit passenger, sbyte seat, bool apply) + { + if (!apply) + return; + + // @HACK - Change passenger offset to the one taken directly from sniffs + // Remove this when proper calculations are implemented. + // This fixes healing spiked people + MoveSplineInit init = new MoveSplineInit(passenger); + init.DisableTransportPathTransformations(); + init.MoveTo(-0.02206125f, -0.02132235f, 5.514783f, false); + init.Launch(); + } + + public override void UpdateAI(uint diff) + { + if (!_hasTrappedUnit) + return; + + _events.Update(diff); + + if (_events.ExecuteEvent() == Misc.EventFailBoned) + { + InstanceScript instance = me.GetInstanceScript(); + if (instance != null) + instance.SetData(DataTypes.BonedAchievement, 0); + } + } + + bool _hasTrappedUnit; + } + + [Script] + class spell_marrowgar_coldflame : SpellScript + { + void SelectTarget(List targets) + { + targets.Clear(); + // select any unit but not the tank (by owners threatlist) + Unit target = GetCaster().GetAI().SelectTarget(SelectAggroTarget.Random, 1, -GetCaster().GetObjectSize(), true, -(int)Spells.Impaled); + if (!target) + target = GetCaster().GetAI().SelectTarget(SelectAggroTarget.Random, 0, 0.0f, true); // or the tank if its solo + if (!target) + return; + + GetCaster().GetAI().SetGUID(target.GetGUID(), Misc.DataColdflameGuid); + + targets.Add(target); + } + + void HandleScriptEffect(uint effIndex) + { + PreventHitDefaultEffect(effIndex); + GetCaster().CastSpell(GetHitUnit(), (uint)GetEffectValue(), true); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(SelectTarget, 0, Targets.UnitDestAreaEnemy)); + OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); } } [Script] - class spell_marrowgar_coldflame : SpellScriptLoader + class spell_marrowgar_coldflame_bonestorm : SpellScript { - public spell_marrowgar_coldflame() : base("spell_marrowgar_coldflame") { } - - class spell_marrowgar_coldflame_SpellScript : SpellScript + void HandleScriptEffect(uint effIndex) { - void SelectTarget(List targets) - { - targets.Clear(); - // select any unit but not the tank (by owners threatlist) - Unit target = GetCaster().GetAI().SelectTarget(SelectAggroTarget.Random, 1, -GetCaster().GetObjectSize(), true, -(int)Spells.Impaled); - if (!target) - target = GetCaster().GetAI().SelectTarget(SelectAggroTarget.Random, 0, 0.0f, true); // or the tank if its solo - if (!target) - return; - - GetCaster().GetAI().SetGUID(target.GetGUID(), Misc.DataColdflameGuid); - - targets.Add(target); - } - - void HandleScriptEffect(uint effIndex) - { - PreventHitDefaultEffect(effIndex); - GetCaster().CastSpell(GetHitUnit(), (uint)GetEffectValue(), true); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(SelectTarget, 0, Targets.UnitDestAreaEnemy)); - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); - } + PreventHitDefaultEffect(effIndex); + for (byte i = 0; i < 4; ++i) + GetCaster().CastSpell(GetHitUnit(), (uint)(GetEffectValue() + i), true); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_marrowgar_coldflame_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); } } [Script] - class spell_marrowgar_coldflame_bonestorm : SpellScriptLoader + class spell_marrowgar_coldflame_damage : AuraScript { - public spell_marrowgar_coldflame_bonestorm() : base("spell_marrowgar_coldflame_bonestorm") { } - - class spell_marrowgar_coldflame_SpellScript : SpellScript + bool CanBeAppliedOn(Unit target) { - void HandleScriptEffect(uint effIndex) - { - PreventHitDefaultEffect(effIndex); - for (byte i = 0; i < 4; ++i) - GetCaster().CastSpell(GetHitUnit(), (uint)(GetEffectValue() + i), true); - } + if (target.HasAura(Spells.Impaled)) + return false; - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); - } - } + if (target.GetExactDist2d(GetOwner()) > GetSpellInfo().GetEffect(target.GetMap().GetDifficultyID(), 0).CalcRadius()) + return false; - public override SpellScript GetSpellScript() - { - return new spell_marrowgar_coldflame_SpellScript(); - } - } - - [Script] - class spell_marrowgar_coldflame_damage : SpellScriptLoader - { - public spell_marrowgar_coldflame_damage() : base("spell_marrowgar_coldflame_damage") { } - - class spell_marrowgar_coldflame_damage_AuraScript : AuraScript - { - bool CanBeAppliedOn(Unit target) - { - if (target.HasAura(Spells.Impaled)) + Aura aur = target.GetAura(GetId()); + if (aur != null) + if (aur.GetOwner() != GetOwner()) return false; - if (target.GetExactDist2d(GetOwner()) > GetSpellInfo().GetEffect(target.GetMap().GetDifficultyID(), 0).CalcRadius()) - return false; - - Aura aur = target.GetAura(GetId()); - if (aur != null) - if (aur.GetOwner() != GetOwner()) - return false; - - return true; - } - - public override void Register() - { - DoCheckAreaTarget.Add(new CheckAreaTargetHandler(CanBeAppliedOn)); - } + return true; } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_marrowgar_coldflame_damage_AuraScript(); + DoCheckAreaTarget.Add(new CheckAreaTargetHandler(CanBeAppliedOn)); } } [Script] - class spell_marrowgar_bone_spike_graveyard : SpellScriptLoader + class spell_marrowgar_bone_spike_graveyard : SpellScript { - public spell_marrowgar_bone_spike_graveyard() : base("spell_marrowgar_bone_spike_graveyard") { } - - class spell_marrowgar_bone_spike_graveyard_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(Misc.BoneSpikeSummonId); - } + return ValidateSpellInfo(Misc.BoneSpikeSummonId); + } - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Unit) && GetCaster().IsAIEnabled; - } + public override bool Load() + { + return GetCaster().IsTypeId(TypeId.Unit) && GetCaster().IsAIEnabled; + } - SpellCastResult CheckCast() - { - return GetCaster().GetAI().SelectTarget(SelectAggroTarget.Random, 0, new BoneSpikeTargetSelector(GetCaster().GetAI())) ? SpellCastResult.SpellCastOk : SpellCastResult.NoValidTargets; - } + SpellCastResult CheckCast() + { + return GetCaster().GetAI().SelectTarget(SelectAggroTarget.Random, 0, new BoneSpikeTargetSelector(GetCaster().GetAI())) ? SpellCastResult.SpellCastOk : SpellCastResult.NoValidTargets; + } - void HandleSpikes(uint effIndex) + void HandleSpikes(uint effIndex) + { + PreventHitDefaultEffect(effIndex); + Creature marrowgar = GetCaster().ToCreature(); + if (marrowgar) { - PreventHitDefaultEffect(effIndex); - Creature marrowgar = GetCaster().ToCreature(); - if (marrowgar) + CreatureAI marrowgarAI = marrowgar.GetAI(); + byte boneSpikeCount = (byte)(Convert.ToBoolean((int)GetCaster().GetMap().GetSpawnMode() & 1) ? 3 : 1); + + List targets = marrowgarAI.SelectTargetList(new BoneSpikeTargetSelector(marrowgarAI), boneSpikeCount, SelectAggroTarget.Random); + if (targets.Empty()) + return; + + uint i = 0; + foreach (var target in targets) { - CreatureAI marrowgarAI = marrowgar.GetAI(); - byte boneSpikeCount = (byte)(Convert.ToBoolean((int)GetCaster().GetMap().GetSpawnMode() & 1) ? 3 : 1); - - List targets = marrowgarAI.SelectTargetList(new BoneSpikeTargetSelector(marrowgarAI), boneSpikeCount, SelectAggroTarget.Random); - if (targets.Empty()) - return; - - uint i = 0; - foreach (var target in targets) - { - target.CastSpell(target, Misc.BoneSpikeSummonId[i], true); - i++; - } - - marrowgarAI.Talk(Texts.SayBonespike); + target.CastSpell(target, Misc.BoneSpikeSummonId[i], true); + i++; } - } - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - OnEffectHitTarget.Add(new EffectHandler(HandleSpikes, 1, SpellEffectName.ApplyAura)); + marrowgarAI.Talk(Texts.SayBonespike); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_marrowgar_bone_spike_graveyard_SpellScript(); + OnCheckCast.Add(new CheckCastHandler(CheckCast)); + OnEffectHitTarget.Add(new EffectHandler(HandleSpikes, 1, SpellEffectName.ApplyAura)); } } [Script] - class spell_marrowgar_bone_storm : SpellScriptLoader + class spell_marrowgar_bone_storm : SpellScript { - public spell_marrowgar_bone_storm() : base("spell_marrowgar_bone_storm") { } - - class spell_marrowgar_bone_storm_SpellScript : SpellScript + void RecalculateDamage() { - void RecalculateDamage() - { - SetHitDamage((int)(GetHitDamage() / Math.Max(Math.Sqrt(GetHitUnit().GetExactDist2d(GetCaster())), 1.0f))); - } - - public override void Register() - { - OnHit.Add(new HitHandler(RecalculateDamage)); - } + SetHitDamage((int)(GetHitDamage() / Math.Max(Math.Sqrt(GetHitUnit().GetExactDist2d(GetCaster())), 1.0f))); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_marrowgar_bone_storm_SpellScript(); + OnHit.Add(new HitHandler(RecalculateDamage)); } } [Script] - class spell_marrowgar_bone_slice : SpellScriptLoader + class spell_marrowgar_bone_slice : SpellScript { - public spell_marrowgar_bone_slice() : base("spell_marrowgar_bone_slice") { } - - class spell_marrowgar_bone_slice_SpellScript : SpellScript + public override bool Load() { - public override bool Load() - { - _targetCount = 0; - return true; - } - - void ClearSpikeImmunities() - { - GetCaster().GetAI().DoAction(Misc.ActionClearSpikeImmunities); - } - - void CountTargets(List targets) - { - _targetCount = (uint)Math.Min(targets.Count, GetSpellInfo().MaxAffectedTargets); - } - - void SplitDamage() - { - // Mark the unit as hit, even if the spell missed or was dodged/parried - GetCaster().GetAI().SetGUID(GetHitUnit().GetGUID(), Misc.DataSpikeImmune); - - if (_targetCount == 0) - return; // This spell can miss all targets - - SetHitDamage((int)(GetHitDamage() / _targetCount)); - } - - public override void Register() - { - BeforeCast.Add(new CastHandler(ClearSpikeImmunities)); - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(CountTargets, 0, Targets.UnitDestAreaEnemy)); - OnHit.Add(new HitHandler(SplitDamage)); - } - - uint _targetCount; + _targetCount = 0; + return true; } - public override SpellScript GetSpellScript() + void ClearSpikeImmunities() { - return new spell_marrowgar_bone_slice_SpellScript(); + GetCaster().GetAI().DoAction(Misc.ActionClearSpikeImmunities); } + + void CountTargets(List targets) + { + _targetCount = (uint)Math.Min(targets.Count, GetSpellInfo().MaxAffectedTargets); + } + + void SplitDamage() + { + // Mark the unit as hit, even if the spell missed or was dodged/parried + GetCaster().GetAI().SetGUID(GetHitUnit().GetGUID(), Misc.DataSpikeImmune); + + if (_targetCount == 0) + return; // This spell can miss all targets + + SetHitDamage((int)(GetHitDamage() / _targetCount)); + } + + public override void Register() + { + BeforeCast.Add(new CastHandler(ClearSpikeImmunities)); + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(CountTargets, 0, Targets.UnitDestAreaEnemy)); + OnHit.Add(new HitHandler(SplitDamage)); + } + + uint _targetCount; } + } } diff --git a/Scripts/Northrend/IcecrownCitadel/ValithriaDreamwalker.cs b/Scripts/Northrend/IcecrownCitadel/ValithriaDreamwalker.cs index fab4cebb0..b737fe16c 100644 --- a/Scripts/Northrend/IcecrownCitadel/ValithriaDreamwalker.cs +++ b/Scripts/Northrend/IcecrownCitadel/ValithriaDreamwalker.cs @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - */ + */ using Game.Entities; diff --git a/Scripts/Northrend/Nexus/EyeOfEternity/EyeOfEternity.cs b/Scripts/Northrend/Nexus/EyeOfEternity/EyeOfEternity.cs index c33d24bf2..cbb35ebc6 100644 --- a/Scripts/Northrend/Nexus/EyeOfEternity/EyeOfEternity.cs +++ b/Scripts/Northrend/Nexus/EyeOfEternity/EyeOfEternity.cs @@ -87,7 +87,7 @@ namespace Scripts.Northrend.Nexus.EyeOfEternity public const uint IrisOpened = 61012; // Visual When Starting Encounter public const uint SummomRedDragonBuddy = 56070; } - + [Script] class instance_eye_of_eternity : InstanceMapScript { diff --git a/Scripts/Northrend/Nexus/Nexus/BossAnomalus.cs b/Scripts/Northrend/Nexus/Nexus/BossAnomalus.cs index 391e1c0fc..b254df916 100644 --- a/Scripts/Northrend/Nexus/Nexus/BossAnomalus.cs +++ b/Scripts/Northrend/Nexus/Nexus/BossAnomalus.cs @@ -25,7 +25,7 @@ using System; namespace Scripts.Northrend.Nexus.Nexus { struct AnomalusConst - { + { //Spells public const uint SpellSpark = 47751; public const uint SpellSparkHeroic = 57062; @@ -64,208 +64,188 @@ namespace Scripts.Northrend.Nexus.Nexus } [Script] - class boss_anomalus : CreatureScript + class boss_anomalus : ScriptedAI { - public boss_anomalus() : base("boss_anomalus") { } - - class boss_anomalusAI : ScriptedAI + public boss_anomalus(Creature creature) : base(creature) { - public boss_anomalusAI(Creature creature) : base(creature) + instance = me.GetInstanceScript(); + } + + void Initialize() + { + _scheduler.Schedule(TimeSpan.FromSeconds(5), task => { - instance = me.GetInstanceScript(); + Unit target = SelectTarget(SelectAggroTarget.Random, 0); + if (target) + DoCast(target, AnomalusConst.SpellSpark); + + task.Repeat(TimeSpan.FromSeconds(5)); + }); + + Phase = 0; + uiChaoticRiftGUID.Clear(); + chaosTheory = true; + } + + public override void Reset() + { + Initialize(); + + instance.SetBossState(DataTypes.Anomalus, EncounterState.NotStarted); + } + + public override void EnterCombat(Unit who) + { + Talk(AnomalusConst.SayAggro); + + instance.SetBossState(DataTypes.Anomalus, EncounterState.InProgress); + } + + public override void JustDied(Unit killer) + { + Talk(AnomalusConst.SayDeath); + + instance.SetBossState(DataTypes.Anomalus, EncounterState.Done); + } + + public override uint GetData(uint type) + { + if (type == AnomalusConst.DataChaosTheory) + return chaosTheory ? 1 : 0u; + + return 0; + } + + public override void SummonedCreatureDies(Creature summoned, Unit who) + { + if (summoned.GetEntry() == AnomalusConst.NpcChaoticRift) + chaosTheory = false; + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + if (me.GetDistance(me.GetHomePosition()) > 60.0f) + { + // Not blizzlike, hack to avoid an exploit + EnterEvadeMode(); + return; } - void Initialize() + if (me.HasAura(AnomalusConst.SpellRiftShield)) { - _scheduler.Schedule(TimeSpan.FromSeconds(5), task => + if (!uiChaoticRiftGUID.IsEmpty()) { + Creature Rift = ObjectAccessor.GetCreature(me, uiChaoticRiftGUID); + if (Rift && Rift.IsDead()) + { + me.RemoveAurasDueToSpell(AnomalusConst.SpellRiftShield); + uiChaoticRiftGUID.Clear(); + } + return; + } + } + else + uiChaoticRiftGUID.Clear(); + + if ((Phase == 0) && HealthBelowPct(50)) + { + Phase = 1; + Talk(AnomalusConst.SayShield); + DoCast(me, AnomalusConst.SpellRiftShield); + Creature Rift = me.SummonCreature(AnomalusConst.NpcChaoticRift, AnomalusConst.RiftLocation[RandomHelper.IRand(0, 5)], TempSummonType.TimedDespawnOOC, 1000); + if (Rift) + { + //DoCast(Rift, SPELL_CHARGE_RIFT); Unit target = SelectTarget(SelectAggroTarget.Random, 0); if (target) - DoCast(target, AnomalusConst.SpellSpark); - - task.Repeat(TimeSpan.FromSeconds(5)); - }); - - Phase = 0; - uiChaoticRiftGUID.Clear(); - chaosTheory = true; - } - - public override void Reset() - { - Initialize(); - - instance.SetBossState(DataTypes.Anomalus, EncounterState.NotStarted); - } - - public override void EnterCombat(Unit who) - { - Talk(AnomalusConst.SayAggro); - - instance.SetBossState(DataTypes.Anomalus, EncounterState.InProgress); - } - - public override void JustDied(Unit killer) - { - Talk(AnomalusConst.SayDeath); - - instance.SetBossState(DataTypes.Anomalus, EncounterState.Done); - } - - public override uint GetData(uint type) - { - if (type == AnomalusConst.DataChaosTheory) - return chaosTheory ? 1 : 0u; - - return 0; - } - - public override void SummonedCreatureDies(Creature summoned, Unit who) - { - if (summoned.GetEntry() == AnomalusConst.NpcChaoticRift) - chaosTheory = false; - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - if (me.GetDistance(me.GetHomePosition()) > 60.0f) - { - // Not blizzlike, hack to avoid an exploit - EnterEvadeMode(); - return; + Rift.GetAI().AttackStart(target); + uiChaoticRiftGUID = Rift.GetGUID(); + Talk(AnomalusConst.SayRift); } - - if (me.HasAura(AnomalusConst.SpellRiftShield)) - { - if (!uiChaoticRiftGUID.IsEmpty()) - { - Creature Rift = ObjectAccessor.GetCreature(me, uiChaoticRiftGUID); - if (Rift && Rift.IsDead()) - { - me.RemoveAurasDueToSpell(AnomalusConst.SpellRiftShield); - uiChaoticRiftGUID.Clear(); - } - return; - } - } - else - uiChaoticRiftGUID.Clear(); - - if ((Phase == 0) && HealthBelowPct(50)) - { - Phase = 1; - Talk(AnomalusConst.SayShield); - DoCast(me, AnomalusConst.SpellRiftShield); - Creature Rift = me.SummonCreature(AnomalusConst.NpcChaoticRift, AnomalusConst.RiftLocation[RandomHelper.IRand(0, 5)], TempSummonType.TimedDespawnOOC, 1000); - if (Rift) - { - //DoCast(Rift, SPELL_CHARGE_RIFT); - Unit target = SelectTarget(SelectAggroTarget.Random, 0); - if (target) - Rift.GetAI().AttackStart(target); - uiChaoticRiftGUID = Rift.GetGUID(); - Talk(AnomalusConst.SayRift); - } - } - - _scheduler.Update(diff); - - DoMeleeAttackIfReady(); } - InstanceScript instance; + _scheduler.Update(diff); - byte Phase; - ObjectGuid uiChaoticRiftGUID; - bool chaosTheory; + DoMeleeAttackIfReady(); } - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } + InstanceScript instance; + + byte Phase; + ObjectGuid uiChaoticRiftGUID; + bool chaosTheory; } [Script] - class npc_chaotic_rift : CreatureScript + class npc_chaotic_rift : ScriptedAI { - public npc_chaotic_rift() : base("npc_chaotic_rift") { } - - class npc_chaotic_riftAI : ScriptedAI + public npc_chaotic_rift(Creature creature) : base(creature) { - public npc_chaotic_riftAI(Creature creature) : base(creature) - { - Initialize(); - instance = me.GetInstanceScript(); - SetCombatMovement(false); - } + Initialize(); + instance = me.GetInstanceScript(); + SetCombatMovement(false); + } - void Initialize() - { - uiChaoticEnergyBurstTimer = 1000; - uiSummonCrazedManaWraithTimer = 5000; - } + void Initialize() + { + uiChaoticEnergyBurstTimer = 1000; + uiSummonCrazedManaWraithTimer = 5000; + } - public override void Reset() - { - Initialize(); - me.SetDisplayId(me.GetCreatureTemplate().ModelId2); - DoCast(me, AnomalusConst.SpellArcaneform, false); - } + public override void Reset() + { + Initialize(); + me.SetDisplayId(me.GetCreatureTemplate().ModelId2); + DoCast(me, AnomalusConst.SpellArcaneform, false); + } - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; - if (uiChaoticEnergyBurstTimer <= diff) + if (uiChaoticEnergyBurstTimer <= diff) + { + Creature Anomalus = ObjectAccessor.GetCreature(me, instance.GetGuidData(DataTypes.Anomalus)); + Unit target = SelectTarget(SelectAggroTarget.Random, 0); + if (target) + { + if (Anomalus && Anomalus.HasAura(AnomalusConst.SpellRiftShield)) + DoCast(target, AnomalusConst.SpellChargedChaoticEnergyBurst); + else + DoCast(target, AnomalusConst.SpellChaoticEnergyBurst); + } + uiChaoticEnergyBurstTimer = 1000; + } + else + uiChaoticEnergyBurstTimer -= diff; + + if (uiSummonCrazedManaWraithTimer <= diff) + { + Creature Wraith = me.SummonCreature(AnomalusConst.NpcCrazedManaWraith, me.GetPositionX() + 1, me.GetPositionY() + 1, me.GetPositionZ(), 0, TempSummonType.TimedDespawnOOC, 1000); + if (Wraith) { - Creature Anomalus = ObjectAccessor.GetCreature(me, instance.GetGuidData(DataTypes.Anomalus)); Unit target = SelectTarget(SelectAggroTarget.Random, 0); if (target) - { - if (Anomalus && Anomalus.HasAura(AnomalusConst.SpellRiftShield)) - DoCast(target, AnomalusConst.SpellChargedChaoticEnergyBurst); - else - DoCast(target, AnomalusConst.SpellChaoticEnergyBurst); - } - uiChaoticEnergyBurstTimer = 1000; + Wraith.GetAI().AttackStart(target); } + Creature Anomalus = ObjectAccessor.GetCreature(me, instance.GetGuidData(DataTypes.Anomalus)); + if (Anomalus && Anomalus.HasAura(AnomalusConst.SpellRiftShield)) + uiSummonCrazedManaWraithTimer = 5000; else - uiChaoticEnergyBurstTimer -= diff; - - if (uiSummonCrazedManaWraithTimer <= diff) - { - Creature Wraith = me.SummonCreature(AnomalusConst.NpcCrazedManaWraith, me.GetPositionX() + 1, me.GetPositionY() + 1, me.GetPositionZ(), 0, TempSummonType.TimedDespawnOOC, 1000); - if (Wraith) - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0); - if (target) - Wraith.GetAI().AttackStart(target); - } - Creature Anomalus = ObjectAccessor.GetCreature(me, instance.GetGuidData(DataTypes.Anomalus)); - if (Anomalus && Anomalus.HasAura(AnomalusConst.SpellRiftShield)) - uiSummonCrazedManaWraithTimer = 5000; - else - uiSummonCrazedManaWraithTimer = 10000; - } - else - uiSummonCrazedManaWraithTimer -= diff; + uiSummonCrazedManaWraithTimer = 10000; } - - InstanceScript instance; - - uint uiChaoticEnergyBurstTimer; - uint uiSummonCrazedManaWraithTimer; + else + uiSummonCrazedManaWraithTimer -= diff; } - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } + InstanceScript instance; + + uint uiChaoticEnergyBurstTimer; + uint uiSummonCrazedManaWraithTimer; } [Script] diff --git a/Scripts/Northrend/Nexus/Nexus/BossKeristrasza.cs b/Scripts/Northrend/Nexus/Nexus/BossKeristrasza.cs index 9c0b3d00a..ea83bdfd9 100644 --- a/Scripts/Northrend/Nexus/Nexus/BossKeristrasza.cs +++ b/Scripts/Northrend/Nexus/Nexus/BossKeristrasza.cs @@ -52,151 +52,141 @@ namespace Scripts.Northrend.Nexus.Nexus } [Script] - class boss_keristrasza : CreatureScript + public class boss_keristrasza : BossAI { - public boss_keristrasza() : base("boss_keristrasza") { } - - public class boss_keristraszaAI : BossAI + public boss_keristrasza(Creature creature) : base(creature, DataTypes.Keristrasza) { - public boss_keristraszaAI(Creature creature) : base(creature, DataTypes.Keristrasza) + Initialize(); + } + + void Initialize() + { + _enrage = false; + + //Crystal FireBreath + _scheduler.Schedule(TimeSpan.FromSeconds(14), task => { - Initialize(); - } + DoCastVictim(KeristraszaConst.SpellCrystalFireBreath); + task.Repeat(TimeSpan.FromSeconds(14)); + }); - void Initialize() + //CrystalChainsCrystalize + _scheduler.Schedule(TimeSpan.FromSeconds(DungeonMode(30, 11)), task => { - _enrage = false; - - //Crystal FireBreath - _scheduler.Schedule(TimeSpan.FromSeconds(14), task => - { - DoCastVictim(KeristraszaConst.SpellCrystalFireBreath); - task.Repeat(TimeSpan.FromSeconds(14)); - }); - - //CrystalChainsCrystalize - _scheduler.Schedule(TimeSpan.FromSeconds(DungeonMode(30, 11)), task => - { - Talk(KeristraszaConst.SayCrystalNova); - if (IsHeroic()) - DoCast(me, KeristraszaConst.SpellCrystalize); - else - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100.0f, true); - if (target) - DoCast(target, KeristraszaConst.SpellCrystalChains); - } - - task.Repeat(TimeSpan.FromSeconds(DungeonMode(30, 11))); - }); - - //TailSweep - _scheduler.Schedule(TimeSpan.FromSeconds(5), task => - { - DoCast(me, KeristraszaConst.SpellTailSweep); - task.Repeat(TimeSpan.FromSeconds(5)); - }); - } - - public override void Reset() - { - Initialize(); - _intenseColdList.Clear(); - - me.RemoveFlag(UnitFields.Flags, UnitFlags.Stunned); - - RemovePrison(CheckContainmentSpheres()); - _Reset(); - } - - public override void EnterCombat(Unit who) - { - Talk(KeristraszaConst.SayAggro); - DoCastAOE(KeristraszaConst.SpellIntenseCold); - _EnterCombat(); - } - - public override void JustDied(Unit killer) - { - Talk(KeristraszaConst.SayDeath); - _JustDied(); - } - - public override void KilledUnit(Unit who) - { - if (who.IsTypeId(TypeId.Player)) - Talk(KeristraszaConst.SaySlay); - } - - public bool CheckContainmentSpheres(bool removePrison = false) - { - for (uint i = DataTypes.AnomalusContainmetSphere; i < (DataTypes.AnomalusContainmetSphere + KeristraszaConst.DataContainmentSpheres); ++i) - { - GameObject containmentSpheres = ObjectAccessor.GetGameObject(me, instance.GetGuidData(i)); - if (!containmentSpheres || containmentSpheres.GetGoState() != GameObjectState.Active) - return false; - } - if (removePrison) - RemovePrison(true); - return true; - } - - void RemovePrison(bool remove) - { - if (remove) - { - me.RemoveFlag(UnitFields.Flags, UnitFlags.ImmuneToPc); - me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); - if (me.HasAura(KeristraszaConst.SpellFrozenPrison)) - me.RemoveAurasDueToSpell(KeristraszaConst.SpellFrozenPrison); - } + Talk(KeristraszaConst.SayCrystalNova); + if (IsHeroic()) + DoCast(me, KeristraszaConst.SpellCrystalize); else { - me.SetFlag(UnitFields.Flags, UnitFlags.ImmuneToPc); - me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable); - DoCast(me, KeristraszaConst.SpellFrozenPrison, false); + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100.0f, true); + if (target) + DoCast(target, KeristraszaConst.SpellCrystalChains); } - } - public override void SetGUID(ObjectGuid guid, int id = 0) + task.Repeat(TimeSpan.FromSeconds(DungeonMode(30, 11))); + }); + + //TailSweep + _scheduler.Schedule(TimeSpan.FromSeconds(5), task => { - if (id == KeristraszaConst.DataIntenseCold) - _intenseColdList.Add(guid); - } - - public override void DamageTaken(Unit attacker, ref uint damage) - { - if (!_enrage && me.HealthBelowPctDamaged(25, damage)) - { - Talk(KeristraszaConst.SayEnrage); - Talk(KeristraszaConst.SayFrenzy); - DoCast(me, KeristraszaConst.SpellEnrage); - _enrage = true; - } - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _scheduler.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - DoMeleeAttackIfReady(); - } - - bool _enrage; - - public List _intenseColdList = new List(); + DoCast(me, KeristraszaConst.SpellTailSweep); + task.Repeat(TimeSpan.FromSeconds(5)); + }); } - public override CreatureAI GetAI(Creature creature) + public override void Reset() { - return GetInstanceAI(creature); + Initialize(); + _intenseColdList.Clear(); + + me.RemoveFlag(UnitFields.Flags, UnitFlags.Stunned); + + RemovePrison(CheckContainmentSpheres()); + _Reset(); } + + public override void EnterCombat(Unit who) + { + Talk(KeristraszaConst.SayAggro); + DoCastAOE(KeristraszaConst.SpellIntenseCold); + _EnterCombat(); + } + + public override void JustDied(Unit killer) + { + Talk(KeristraszaConst.SayDeath); + _JustDied(); + } + + public override void KilledUnit(Unit who) + { + if (who.IsTypeId(TypeId.Player)) + Talk(KeristraszaConst.SaySlay); + } + + public bool CheckContainmentSpheres(bool removePrison = false) + { + for (uint i = DataTypes.AnomalusContainmetSphere; i < (DataTypes.AnomalusContainmetSphere + KeristraszaConst.DataContainmentSpheres); ++i) + { + GameObject containmentSpheres = ObjectAccessor.GetGameObject(me, instance.GetGuidData(i)); + if (!containmentSpheres || containmentSpheres.GetGoState() != GameObjectState.Active) + return false; + } + if (removePrison) + RemovePrison(true); + return true; + } + + void RemovePrison(bool remove) + { + if (remove) + { + me.RemoveFlag(UnitFields.Flags, UnitFlags.ImmuneToPc); + me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); + if (me.HasAura(KeristraszaConst.SpellFrozenPrison)) + me.RemoveAurasDueToSpell(KeristraszaConst.SpellFrozenPrison); + } + else + { + me.SetFlag(UnitFields.Flags, UnitFlags.ImmuneToPc); + me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable); + DoCast(me, KeristraszaConst.SpellFrozenPrison, false); + } + } + + public override void SetGUID(ObjectGuid guid, int id = 0) + { + if (id == KeristraszaConst.DataIntenseCold) + _intenseColdList.Add(guid); + } + + public override void DamageTaken(Unit attacker, ref uint damage) + { + if (!_enrage && me.HealthBelowPctDamaged(25, damage)) + { + Talk(KeristraszaConst.SayEnrage); + Talk(KeristraszaConst.SayFrenzy); + DoCast(me, KeristraszaConst.SpellEnrage); + _enrage = true; + } + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _scheduler.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + DoMeleeAttackIfReady(); + } + + bool _enrage; + + public List _intenseColdList = new List(); } [Script] @@ -215,7 +205,7 @@ namespace Scripts.Northrend.Nexus.Nexus go.SetFlag(GameObjectFields.Flags, GameObjectFlags.NotSelectable); go.SetGoState(GameObjectState.Active); - ((boss_keristrasza.boss_keristraszaAI)pKeristrasza.GetAI()).CheckContainmentSpheres(true); + ((boss_keristrasza)pKeristrasza.GetAI()).CheckContainmentSpheres(true); } return true; } @@ -223,33 +213,23 @@ namespace Scripts.Northrend.Nexus.Nexus } [Script] - class spell_intense_cold : SpellScriptLoader + class spell_intense_cold : AuraScript { - public spell_intense_cold() : base("spell_intense_cold") { } - - class spell_intense_cold_AuraScript : AuraScript + void HandlePeriodicTick(AuraEffect aurEff) { - void HandlePeriodicTick(AuraEffect aurEff) - { - if (aurEff.GetBase().GetStackAmount() < 2) - return; - Unit caster = GetCaster(); - /// @todo the caster should be boss but not the player - if (!caster || caster.GetAI() == null) - return; + if (aurEff.GetBase().GetStackAmount() < 2) + return; + Unit caster = GetCaster(); + /// @todo the caster should be boss but not the player + if (!caster || caster.GetAI() == null) + return; - caster.GetAI().SetGUID(GetTarget().GetGUID(), (int)KeristraszaConst.DataIntenseCold); - } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandlePeriodicTick, 1, AuraType.PeriodicDamage)); - } + caster.GetAI().SetGUID(GetTarget().GetGUID(), (int)KeristraszaConst.DataIntenseCold); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_intense_cold_AuraScript(); + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandlePeriodicTick, 1, AuraType.PeriodicDamage)); } } @@ -263,7 +243,7 @@ namespace Scripts.Northrend.Nexus.Nexus if (!target) return false; - var _intenseColdList = ((boss_keristrasza.boss_keristraszaAI)target.ToCreature().GetAI())._intenseColdList; + var _intenseColdList = ((boss_keristrasza)target.ToCreature().GetAI())._intenseColdList; if (!_intenseColdList.Empty()) { foreach (var guid in _intenseColdList) diff --git a/Scripts/Northrend/Nexus/Nexus/BossMagusTelestra.cs b/Scripts/Northrend/Nexus/Nexus/BossMagusTelestra.cs index 7e50fe346..cab6ddbc8 100644 --- a/Scripts/Northrend/Nexus/Nexus/BossMagusTelestra.cs +++ b/Scripts/Northrend/Nexus/Nexus/BossMagusTelestra.cs @@ -55,252 +55,242 @@ namespace Scripts.Northrend.Nexus.Nexus } [Script] - class boss_magus_telestra : CreatureScript + class boss_magus_telestra : ScriptedAI { - public boss_magus_telestra() : base("boss_magus_telestra") { } - - class boss_magus_telestraAI : ScriptedAI + public boss_magus_telestra(Creature creature) : base(creature) { - public boss_magus_telestraAI(Creature creature) : base(creature) + instance = creature.GetInstanceScript(); + bFireMagusDead = false; + bFrostMagusDead = false; + bArcaneMagusDead = false; + uiIsWaitingToAppearTimer = 0; + } + + void Initialize() + { + Phase = 0; + + uiIceNovaTimer = 7 * Time.InMilliseconds; + uiFireBombTimer = 0; + uiGravityWellTimer = 15 * Time.InMilliseconds; + uiCooldown = 0; + + for (byte n = 0; n < 3; ++n) + time[n] = 0; + + splitPersonality = 0; + bIsWaitingToAppear = false; + } + + public override void Reset() + { + Initialize(); + + me.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable); + + instance.SetBossState(DataTypes.MagusTelestra, EncounterState.NotStarted); + + if (IsHeroic() && Global.GameEventMgr.IsActiveEvent(MagusTelestraConst.GameEventWinterVeil) && !me.HasAura(MagusTelestraConst.SpellWearChristmasHat)) + me.AddAura(MagusTelestraConst.SpellWearChristmasHat, me); + } + + public override void EnterCombat(Unit who) + { + Talk(MagusTelestraConst.SayAggro); + + instance.SetBossState(DataTypes.MagusTelestra, EncounterState.InProgress); + } + + public override void JustDied(Unit killer) + { + Talk(MagusTelestraConst.SayDeath); + + instance.SetBossState(DataTypes.MagusTelestra, EncounterState.Done); + } + + public override void KilledUnit(Unit who) + { + if (who.IsTypeId(TypeId.Player)) + Talk(MagusTelestraConst.SayKill); + } + + public override uint GetData(uint type) + { + if (type == MagusTelestraConst.DataSplitPersonality) + return splitPersonality; + + return 0; + } + + public override void UpdateAI(uint diff) + { + //Return since we have no target + if (!UpdateVictim()) + return; + + if (bIsWaitingToAppear) { - instance = creature.GetInstanceScript(); + me.StopMoving(); + me.AttackStop(); + if (uiIsWaitingToAppearTimer <= diff) + { + me.CastSpell(me, 47714, true); + me.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable); + bIsWaitingToAppear = false; + InVanish = false; + me.SendAIReaction(AiReaction.Hostile); + } + else + uiIsWaitingToAppearTimer -= diff; + + return; + } + + if ((Phase == 1) || (Phase == 3)) + { + if (bFireMagusDead && bFrostMagusDead && bArcaneMagusDead) + { + for (byte n = 0; n < 3; ++n) + time[n] = 0; + + me.GetMotionMaster().Clear(); + DoCast(me, MagusTelestraConst.SpellTelestraBack); + if (Phase == 1) + Phase = 2; + if (Phase == 3) + Phase = 4; + bIsWaitingToAppear = true; + uiIsWaitingToAppearTimer = 4 * Time.InMilliseconds; + Talk(MagusTelestraConst.SayMerge); + } + else + return; + } + + if ((Phase == 0) && HealthBelowPct(50)) + { + InVanish = true; + Phase = 1; + me.CastStop(); + me.RemoveAllAuras(); + me.CastSpell(me, 47710, false); + me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable); bFireMagusDead = false; bFrostMagusDead = false; bArcaneMagusDead = false; - uiIsWaitingToAppearTimer = 0; + Talk(MagusTelestraConst.SaySplit); + return; } - void Initialize() + if (IsHeroic() && (Phase == 2) && HealthBelowPct(10)) { - Phase = 0; + InVanish = true; + Phase = 3; + me.CastStop(); + me.RemoveAllAuras(); + me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable); + bFireMagusDead = false; + bFrostMagusDead = false; + bArcaneMagusDead = false; + Talk(MagusTelestraConst.SaySplit); + return; + } - uiIceNovaTimer = 7 * Time.InMilliseconds; - uiFireBombTimer = 0; + if (uiCooldown != 0) + { + if (uiCooldown <= diff) + uiCooldown = 0; + else + { + uiCooldown -= diff; + return; + } + } + + if (uiIceNovaTimer <= diff) + { + Unit target = SelectTarget(SelectAggroTarget.Random, 0); + if (target) + { + DoCast(target, MagusTelestraConst.SpellIceNova, false); + uiCooldown = 1500; + } + uiIceNovaTimer = 15 * Time.InMilliseconds; + } + else uiIceNovaTimer -= diff; + + if (uiGravityWellTimer <= diff) + { + Unit target = me.GetVictim(); + if (target) + { + DoCast(target, MagusTelestraConst.SpellGravityWell); + uiCooldown = 6 * Time.InMilliseconds; + } uiGravityWellTimer = 15 * Time.InMilliseconds; - uiCooldown = 0; - - for (byte n = 0; n < 3; ++n) - time[n] = 0; - - splitPersonality = 0; - bIsWaitingToAppear = false; } + else uiGravityWellTimer -= diff; - public override void Reset() + if (uiFireBombTimer <= diff) { - Initialize(); - - me.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable); - - instance.SetBossState(DataTypes.MagusTelestra, EncounterState.NotStarted); - - if (IsHeroic() && Global.GameEventMgr.IsActiveEvent(MagusTelestraConst.GameEventWinterVeil) && !me.HasAura(MagusTelestraConst.SpellWearChristmasHat)) - me.AddAura(MagusTelestraConst.SpellWearChristmasHat, me); + Unit target = SelectTarget(SelectAggroTarget.Random, 0); + if (target) + { + DoCast(target, MagusTelestraConst.SpellFirebomb, false); + uiCooldown = 2 * Time.InMilliseconds; + } + uiFireBombTimer = 2 * Time.InMilliseconds; } + else uiFireBombTimer -= diff; - public override void EnterCombat(Unit who) - { - Talk(MagusTelestraConst.SayAggro); - - instance.SetBossState(DataTypes.MagusTelestra, EncounterState.InProgress); - } - - public override void JustDied(Unit killer) - { - Talk(MagusTelestraConst.SayDeath); - - instance.SetBossState(DataTypes.MagusTelestra, EncounterState.Done); - } - - public override void KilledUnit(Unit who) - { - if (who.IsTypeId(TypeId.Player)) - Talk(MagusTelestraConst.SayKill); - } - - public override uint GetData(uint type) - { - if (type == MagusTelestraConst.DataSplitPersonality) - return splitPersonality; - - return 0; - } - - public override void UpdateAI(uint diff) - { - //Return since we have no target - if (!UpdateVictim()) - return; - - if (bIsWaitingToAppear) - { - me.StopMoving(); - me.AttackStop(); - if (uiIsWaitingToAppearTimer <= diff) - { - me.CastSpell(me, 47714, true); - me.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable); - bIsWaitingToAppear = false; - InVanish = false; - me.SendAIReaction(AiReaction.Hostile); - } - else - uiIsWaitingToAppearTimer -= diff; - - return; - } - - if ((Phase == 1) || (Phase == 3)) - { - if (bFireMagusDead && bFrostMagusDead && bArcaneMagusDead) - { - for (byte n = 0; n < 3; ++n) - time[n] = 0; - - me.GetMotionMaster().Clear(); - DoCast(me, MagusTelestraConst.SpellTelestraBack); - if (Phase == 1) - Phase = 2; - if (Phase == 3) - Phase = 4; - bIsWaitingToAppear = true; - uiIsWaitingToAppearTimer = 4 * Time.InMilliseconds; - Talk(MagusTelestraConst.SayMerge); - } - else - return; - } - - if ((Phase == 0) && HealthBelowPct(50)) - { - InVanish = true; - Phase = 1; - me.CastStop(); - me.RemoveAllAuras(); - me.CastSpell(me, 47710, false); - me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable); - bFireMagusDead = false; - bFrostMagusDead = false; - bArcaneMagusDead = false; - Talk(MagusTelestraConst.SaySplit); - return; - } - - if (IsHeroic() && (Phase == 2) && HealthBelowPct(10)) - { - InVanish = true; - Phase = 3; - me.CastStop(); - me.RemoveAllAuras(); - me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable); - bFireMagusDead = false; - bFrostMagusDead = false; - bArcaneMagusDead = false; - Talk(MagusTelestraConst.SaySplit); - return; - } - - if (uiCooldown != 0) - { - if (uiCooldown <= diff) - uiCooldown = 0; - else - { - uiCooldown -= diff; - return; - } - } - - if (uiIceNovaTimer <= diff) - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0); - if (target) - { - DoCast(target, MagusTelestraConst.SpellIceNova, false); - uiCooldown = 1500; - } - uiIceNovaTimer = 15 * Time.InMilliseconds; - } - else uiIceNovaTimer -= diff; - - if (uiGravityWellTimer <= diff) - { - Unit target = me.GetVictim(); - if (target) - { - DoCast(target, MagusTelestraConst.SpellGravityWell); - uiCooldown = 6 * Time.InMilliseconds; - } - uiGravityWellTimer = 15 * Time.InMilliseconds; - } - else uiGravityWellTimer -= diff; - - if (uiFireBombTimer <= diff) - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0); - if (target) - { - DoCast(target, MagusTelestraConst.SpellFirebomb, false); - uiCooldown = 2 * Time.InMilliseconds; - } - uiFireBombTimer = 2 * Time.InMilliseconds; - } - else uiFireBombTimer -= diff; - - if (!InVanish) - DoMeleeAttackIfReady(); - } - - public override void SummonedCreatureDies(Creature summon, Unit killer) - { - if (summon.IsAlive()) - return; - - switch (summon.GetEntry()) - { - case MagusTelestraConst.NpcFireMagus: - bFireMagusDead = true; - break; - case MagusTelestraConst.NpcFrostMagus: - bFrostMagusDead = true; - break; - case MagusTelestraConst.NpcArcaneMagus: - bArcaneMagusDead = true; - break; - } - - byte i = 0; - while (time[i] != 0) - ++i; - - time[i] = Global.WorldMgr.GetGameTime(); - if (i == 2 && (time[2] - time[1] < 5) && (time[1] - time[0] < 5)) - ++splitPersonality; - } - - InstanceScript instance; - - bool bFireMagusDead; - bool bFrostMagusDead; - bool bArcaneMagusDead; - bool bIsWaitingToAppear; - bool InVanish; - - uint uiIsWaitingToAppearTimer; - uint uiIceNovaTimer; - uint uiFireBombTimer; - uint uiGravityWellTimer; - uint uiCooldown; - - byte Phase; - byte splitPersonality; - long[] time = new long[3]; + if (!InVanish) + DoMeleeAttackIfReady(); } - public override CreatureAI GetAI(Creature creature) + public override void SummonedCreatureDies(Creature summon, Unit killer) { - return GetInstanceAI(creature); + if (summon.IsAlive()) + return; + + switch (summon.GetEntry()) + { + case MagusTelestraConst.NpcFireMagus: + bFireMagusDead = true; + break; + case MagusTelestraConst.NpcFrostMagus: + bFrostMagusDead = true; + break; + case MagusTelestraConst.NpcArcaneMagus: + bArcaneMagusDead = true; + break; + } + + byte i = 0; + while (time[i] != 0) + ++i; + + time[i] = Global.WorldMgr.GetGameTime(); + if (i == 2 && (time[2] - time[1] < 5) && (time[1] - time[0] < 5)) + ++splitPersonality; } + + InstanceScript instance; + + bool bFireMagusDead; + bool bFrostMagusDead; + bool bArcaneMagusDead; + bool bIsWaitingToAppear; + bool InVanish; + + uint uiIsWaitingToAppearTimer; + uint uiIceNovaTimer; + uint uiFireBombTimer; + uint uiGravityWellTimer; + uint uiCooldown; + + byte Phase; + byte splitPersonality; + long[] time = new long[3]; } [Script] @@ -325,25 +315,15 @@ namespace Scripts.Northrend.Nexus.Nexus } [Script] - class spell_gravity_well_effect : SpellScriptLoader + class spell_gravity_well_effect : SpellScript { - public spell_gravity_well_effect() : base("spell_gravity_well_effect") { } - - class spell_gravity_well_effect_SpellScript : SpellScript + void HandleDummy(uint index) { - void HandleDummy(uint index) - { - } - - public override void Register() - { - } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_gravity_well_effect_SpellScript(); } } } diff --git a/Scripts/Northrend/Nexus/Nexus/BossNexusCommanders.cs b/Scripts/Northrend/Nexus/Nexus/BossNexusCommanders.cs index 3bac72f38..113003500 100644 --- a/Scripts/Northrend/Nexus/Nexus/BossNexusCommanders.cs +++ b/Scripts/Northrend/Nexus/Nexus/BossNexusCommanders.cs @@ -39,75 +39,65 @@ namespace Scripts.Northrend.Nexus.Nexus } [Script] - class boss_nexus_commanders : CreatureScript + class boss_nexus_commanders : BossAI { - public boss_nexus_commanders() : base("boss_nexus_commanders") { } + boss_nexus_commanders(Creature creature) : base(creature, DataTypes.Commander) { } - class boss_nexus_commandersAI : BossAI + public override void EnterCombat(Unit who) { - boss_nexus_commandersAI(Creature creature) : base(creature, DataTypes.Commander) { } + _EnterCombat(); + Talk(NexusCommandersConst.SayAggro); + me.RemoveAurasDueToSpell(NexusCommandersConst.SpellFrozenPrison); + DoCast(me, NexusCommandersConst.SpellBattleShout); - public override void EnterCombat(Unit who) + //Charge + _scheduler.Schedule(TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(4), task => { - _EnterCombat(); - Talk(NexusCommandersConst.SayAggro); - me.RemoveAurasDueToSpell(NexusCommandersConst.SpellFrozenPrison); - DoCast(me, NexusCommandersConst.SpellBattleShout); + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100.0f, true); + if (target) + DoCast(target, NexusCommandersConst.SpellCharge); - //Charge - _scheduler.Schedule(TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(4), task => - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 100.0f, true); - if (target) - DoCast(target, NexusCommandersConst.SpellCharge); + task.Repeat(TimeSpan.FromSeconds(11), TimeSpan.FromSeconds(15)); + }); - task.Repeat(TimeSpan.FromSeconds(11), TimeSpan.FromSeconds(15)); - }); - - //Whirlwind - _scheduler.Schedule(TimeSpan.FromSeconds(6), TimeSpan.FromSeconds(8), task => - { - DoCast(me, NexusCommandersConst.SpellWhirlwind); - task.Repeat(TimeSpan.FromSeconds(19.5), TimeSpan.FromSeconds(25)); - }); - - //Frightening Shout - _scheduler.Schedule(TimeSpan.FromSeconds(13), TimeSpan.FromSeconds(15), task => - { - DoCastAOE(NexusCommandersConst.SpellFrighteningShout); - task.Repeat(TimeSpan.FromSeconds(45), TimeSpan.FromSeconds(55)); - }); - } - - public override void JustDied(Unit killer) + //Whirlwind + _scheduler.Schedule(TimeSpan.FromSeconds(6), TimeSpan.FromSeconds(8), task => { - _JustDied(); - Talk(NexusCommandersConst.SayDeath); - } + DoCast(me, NexusCommandersConst.SpellWhirlwind); + task.Repeat(TimeSpan.FromSeconds(19.5), TimeSpan.FromSeconds(25)); + }); - public override void KilledUnit(Unit who) + //Frightening Shout + _scheduler.Schedule(TimeSpan.FromSeconds(13), TimeSpan.FromSeconds(15), task => { - if (who.IsTypeId(TypeId.Player)) - Talk(NexusCommandersConst.SayKill); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _scheduler.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - DoMeleeAttackIfReady(); - } + DoCastAOE(NexusCommandersConst.SpellFrighteningShout); + task.Repeat(TimeSpan.FromSeconds(45), TimeSpan.FromSeconds(55)); + }); } - public override CreatureAI GetAI(Creature creature) + public override void JustDied(Unit killer) { - return GetInstanceAI(creature); + _JustDied(); + Talk(NexusCommandersConst.SayDeath); + } + + public override void KilledUnit(Unit who) + { + if (who.IsTypeId(TypeId.Player)) + Talk(NexusCommandersConst.SayKill); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _scheduler.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + DoMeleeAttackIfReady(); } } } diff --git a/Scripts/Northrend/Nexus/Nexus/BossOrmorok.cs b/Scripts/Northrend/Nexus/Nexus/BossOrmorok.cs index 1c9ba3ed3..aa9bbadc3 100644 --- a/Scripts/Northrend/Nexus/Nexus/BossOrmorok.cs +++ b/Scripts/Northrend/Nexus/Nexus/BossOrmorok.cs @@ -43,113 +43,103 @@ namespace Scripts.Northrend.Nexus.Nexus } [Script] - class boss_ormorok : CreatureScript + class boss_ormorok : BossAI { - public boss_ormorok() : base("boss_ormorok") { } - - class boss_ormorokAI : BossAI + public boss_ormorok(Creature creature) : base(creature, DataTypes.Ormorok) { - public boss_ormorokAI(Creature creature) : base(creature, DataTypes.Ormorok) - { - Initialize(); - } - - void Initialize() - { - frenzy = false; - } - - public override void Reset() - { - base.Reset(); - Initialize(); - } - - public override void EnterCombat(Unit who) - { - _EnterCombat(); - - //Crystal Spikes - _scheduler.Schedule(TimeSpan.FromSeconds(12), task => - { - Talk(OrmorokConst.SayCrystalSpikes); - DoCast(OrmorokConst.SpellCrystalSpikes); - task.Repeat(TimeSpan.FromSeconds(12)); - }); - - //Trample - _scheduler.Schedule(TimeSpan.FromSeconds(10), task => - { - DoCast(me, OrmorokConst.SpellTrample); - task.Repeat(TimeSpan.FromSeconds(10)); - }); - - //Spell Reflection - _scheduler.Schedule(TimeSpan.FromSeconds(30), task => - { - Talk(OrmorokConst.SayReflect); - DoCast(me, OrmorokConst.SpellReflection); - task.Repeat(TimeSpan.FromSeconds(30)); - }); - - //Heroic Crystalline Tangler - if (IsHeroic()) - { - _scheduler.Schedule(TimeSpan.FromSeconds(17), task => - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0, new OrmorokTanglerPredicate(me)); - if (target) - DoCast(target, OrmorokConst.SpellSummonCrystallineTangler); - - task.Repeat(TimeSpan.FromSeconds(17)); - }); - } - - Talk(OrmorokConst.SayAggro); - } - - public override void DamageTaken(Unit attacker, ref uint damage) - { - if (!frenzy && HealthBelowPct(25)) - { - Talk(OrmorokConst.SayFrenzy); - DoCast(me, OrmorokConst.SpellFrenzy); - frenzy = true; - } - } - - public override void JustDied(Unit killer) - { - _JustDied(); - Talk(OrmorokConst.SayDeath); - } - - public override void KilledUnit(Unit who) - { - if (who.IsTypeId(TypeId.Player)) - Talk(OrmorokConst.SayKill); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _scheduler.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - DoMeleeAttackIfReady(); - } - - bool frenzy; + Initialize(); } - public override CreatureAI GetAI(Creature creature) + void Initialize() { - return GetInstanceAI(creature); + frenzy = false; } + + public override void Reset() + { + base.Reset(); + Initialize(); + } + + public override void EnterCombat(Unit who) + { + _EnterCombat(); + + //Crystal Spikes + _scheduler.Schedule(TimeSpan.FromSeconds(12), task => + { + Talk(OrmorokConst.SayCrystalSpikes); + DoCast(OrmorokConst.SpellCrystalSpikes); + task.Repeat(TimeSpan.FromSeconds(12)); + }); + + //Trample + _scheduler.Schedule(TimeSpan.FromSeconds(10), task => + { + DoCast(me, OrmorokConst.SpellTrample); + task.Repeat(TimeSpan.FromSeconds(10)); + }); + + //Spell Reflection + _scheduler.Schedule(TimeSpan.FromSeconds(30), task => + { + Talk(OrmorokConst.SayReflect); + DoCast(me, OrmorokConst.SpellReflection); + task.Repeat(TimeSpan.FromSeconds(30)); + }); + + //Heroic Crystalline Tangler + if (IsHeroic()) + { + _scheduler.Schedule(TimeSpan.FromSeconds(17), task => + { + Unit target = SelectTarget(SelectAggroTarget.Random, 0, new OrmorokTanglerPredicate(me)); + if (target) + DoCast(target, OrmorokConst.SpellSummonCrystallineTangler); + + task.Repeat(TimeSpan.FromSeconds(17)); + }); + } + + Talk(OrmorokConst.SayAggro); + } + + public override void DamageTaken(Unit attacker, ref uint damage) + { + if (!frenzy && HealthBelowPct(25)) + { + Talk(OrmorokConst.SayFrenzy); + DoCast(me, OrmorokConst.SpellFrenzy); + frenzy = true; + } + } + + public override void JustDied(Unit killer) + { + _JustDied(); + Talk(OrmorokConst.SayDeath); + } + + public override void KilledUnit(Unit who) + { + if (who.IsTypeId(TypeId.Player)) + Talk(OrmorokConst.SayKill); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _scheduler.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + DoMeleeAttackIfReady(); + } + + bool frenzy; } class OrmorokTanglerPredicate : ISelector @@ -189,103 +179,83 @@ namespace Scripts.Northrend.Nexus.Nexus } [Script] - class npc_crystal_spike_trigger : CreatureScript + class npc_crystal_spike_trigger : ScriptedAI { - public npc_crystal_spike_trigger() : base("npc_crystal_spike_trigger") { } + public npc_crystal_spike_trigger(Creature creature) : base(creature) { } - class npc_crystal_spike_triggerAI : ScriptedAI + public override void IsSummonedBy(Unit owner) { - public npc_crystal_spike_triggerAI(Creature creature) : base(creature) { } - - public override void IsSummonedBy(Unit owner) + switch (me.GetEntry()) { - switch (me.GetEntry()) - { - case CrystalSpikesConst.NpcCrystalSpikeInitial: - _count = 0; - me.SetFacingToObject(owner); - break; - case CrystalSpikesConst.NpcCrystalSpikeTrigger: - Creature trigger = owner.ToCreature(); - if (trigger) - _count = trigger.GetAI().GetData(CrystalSpikesConst.DataCount) + 1; - break; - default: - _count = CrystalSpikesConst.MaxCount; - break; - } + case CrystalSpikesConst.NpcCrystalSpikeInitial: + _count = 0; + me.SetFacingToObject(owner); + break; + case CrystalSpikesConst.NpcCrystalSpikeTrigger: + Creature trigger = owner.ToCreature(); + if (trigger) + _count = trigger.GetAI().GetData(CrystalSpikesConst.DataCount) + 1; + break; + default: + _count = CrystalSpikesConst.MaxCount; + break; + } + if (me.GetEntry() == CrystalSpikesConst.NpcCrystalSpikeTrigger) + { + GameObject trap = me.FindNearestGameObject(CrystalSpikesConst.GoCrystalSpikeTrap, 1.0f); + if (trap) + trap.Use(me); + } + + //Despawn + _scheduler.Schedule(TimeSpan.FromSeconds(2), task => + { if (me.GetEntry() == CrystalSpikesConst.NpcCrystalSpikeTrigger) { GameObject trap = me.FindNearestGameObject(CrystalSpikesConst.GoCrystalSpikeTrap, 1.0f); if (trap) - trap.Use(me); + trap.Delete(); } - //Despawn - _scheduler.Schedule(TimeSpan.FromSeconds(2), task => - { - if (me.GetEntry() == CrystalSpikesConst.NpcCrystalSpikeTrigger) - { - GameObject trap = me.FindNearestGameObject(CrystalSpikesConst.GoCrystalSpikeTrap, 1.0f); - if (trap) - trap.Delete(); - } - - me.DespawnOrUnsummon(); - }); - } - - public override uint GetData(uint type) - { - return type == CrystalSpikesConst.DataCount ? _count : 0; - } - - public override void UpdateAI(uint diff) - { - _scheduler.Update(diff); - } - - uint _count; + me.DespawnOrUnsummon(); + }); } - public override CreatureAI GetAI(Creature creature) + public override uint GetData(uint type) { - return new npc_crystal_spike_triggerAI(creature); + return type == CrystalSpikesConst.DataCount ? _count : 0; } + + public override void UpdateAI(uint diff) + { + _scheduler.Update(diff); + } + + uint _count; } [Script] - class spell_crystal_spike : SpellScriptLoader + class spell_crystal_spike : AuraScript { - public spell_crystal_spike() : base("spell_crystal_spike") { } - - class spell_crystal_spike_AuraScript : AuraScript + void HandlePeriodic(AuraEffect aurEff) { - void HandlePeriodic(AuraEffect aurEff) + Unit target = GetTarget(); + if (target.GetEntry() == CrystalSpikesConst.NpcCrystalSpikeInitial || target.GetEntry() == CrystalSpikesConst.NpcCrystalSpikeTrigger) { - Unit target = GetTarget(); - if (target.GetEntry() == CrystalSpikesConst.NpcCrystalSpikeInitial || target.GetEntry() == CrystalSpikesConst.NpcCrystalSpikeTrigger) + Creature trigger = target.ToCreature(); + if (trigger) { - Creature trigger = target.ToCreature(); - if (trigger) - { - uint spell = target.GetEntry() == CrystalSpikesConst.NpcCrystalSpikeInitial ? CrystalSpikesConst.CrystalSpikeSummon[0] : CrystalSpikesConst.CrystalSpikeSummon[RandomHelper.IRand(0, 2)]; - if (trigger.GetAI().GetData(CrystalSpikesConst.DataCount) < CrystalSpikesConst.MaxCount) - trigger.CastSpell(trigger, spell, true); - } + uint spell = target.GetEntry() == CrystalSpikesConst.NpcCrystalSpikeInitial ? CrystalSpikesConst.CrystalSpikeSummon[0] : CrystalSpikesConst.CrystalSpikeSummon[RandomHelper.IRand(0, 2)]; + if (trigger.GetAI().GetData(CrystalSpikesConst.DataCount) < CrystalSpikesConst.MaxCount) + trigger.CastSpell(trigger, spell, true); } } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandlePeriodic, 0, AuraType.PeriodicDummy)); - } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_crystal_spike_AuraScript(); + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandlePeriodic, 0, AuraType.PeriodicDummy)); } } } diff --git a/Scripts/Northrend/Nexus/Oculus/InstanceOculus.cs b/Scripts/Northrend/Nexus/Oculus/InstanceOculus.cs index 0ba0673e1..9db6f55ac 100644 --- a/Scripts/Northrend/Nexus/Oculus/InstanceOculus.cs +++ b/Scripts/Northrend/Nexus/Oculus/InstanceOculus.cs @@ -359,10 +359,5 @@ namespace Scripts.Northrend.Nexus.Oculus EventMap events = new EventMap(); } - public override InstanceScript GetInstanceScript(InstanceMap map) - { - return new instance_oculus_InstanceMapScript(map); - } - } - */ + */ } diff --git a/Scripts/Northrend/Ulduar/FlameLeviathan.cs b/Scripts/Northrend/Ulduar/FlameLeviathan.cs index 79e338908..63e05c250 100644 --- a/Scripts/Northrend/Ulduar/FlameLeviathan.cs +++ b/Scripts/Northrend/Ulduar/FlameLeviathan.cs @@ -25,130 +25,128 @@ using System; using System.Collections.Generic; using System.Diagnostics.Contracts; -namespace Scripts.Northrend.Ulduar +namespace Scripts.Northrend.Ulduar.FlameLeviathan { - namespace FlameLeviathan + struct Spells { - struct Spells + public const uint Pursued = 62374; + public const uint GatheringSpeed = 62375; + public const uint BatteringRam = 62376; + public const uint FlameVents = 62396; + public const uint MissileBarrage = 62400; + public const uint SystemsShutdown = 62475; + public const uint OverloadCircuit = 62399; + public const uint StartTheEngine = 62472; + public const uint SearingFlame = 62402; + public const uint Blaze = 62292; + public const uint TarPassive = 62288; + public const uint SmokeTrail = 63575; + public const uint Electroshock = 62522; + public const uint Napalm = 63666; + public const uint InvisAndStealthDetect = 18950; // Passive + //Tower Additional Spells + public const uint ThorimSHammer = 62911; // Tower Of Storms + public const uint MimironSInferno = 62909; // Tower Of Flames + public const uint HodirSFury = 62533; // Tower Of Frost + public const uint FreyaSWard = 62906; // Tower Of Nature + public const uint FreyaSummons = 62947; // Tower Of Nature + //Tower Ap & Health Spells + public const uint BuffTowerOfStorms = 65076; + public const uint BuffTowerOfFlames = 65075; + public const uint BuffTowerOfFrost = 65077; + public const uint BuffTowerOfLife = 64482; + //Additional Spells + public const uint Lash = 65062; + public const uint FreyaSWardEffect1 = 62947; + public const uint FreyaSWardEffect2 = 62907; + public const uint AutoRepair = 62705; + public const uint DummyBlue = 63294; + public const uint DummyGreen = 63295; + public const uint DummyYellow = 63292; + public const uint LiquidPyrite = 62494; + public const uint DustyExplosion = 63360; + public const uint DustCloudImpact = 54740; + public const uint StealthDetection = 18950; + public const uint RideVehicle = 46598; + } + + struct CreatureIds + { + public const uint Seat = 33114; + public const uint Mechanolift = 33214; + public const uint Liquid = 33189; + public const uint Container = 33218; + public const uint ThorimBeacon = 33365; + public const uint MimironBeacon = 33370; + public const uint HodirBeacon = 33212; + public const uint FreyaBeacon = 33367; + public const uint ThorimTargetBeacon = 33364; + public const uint MimironTargetBeacon = 33369; + public const uint HodirTargetBeacon = 33108; + public const uint FreyaTargetBeacon = 33366; + public const uint Lorekeeper = 33686; // Hard Mode Starter + public const uint BranzBronzbeard = 33579; + public const uint Delorah = 33701; + public const uint UlduarGauntletGenerator = 33571; // Trigger Tied To Towers + } + + struct Towers + { + public const uint ofStorms = 194377; + public const uint ofFlames = 194371; + public const uint ofFrost = 194370; + public const uint ofLife = 194375; + } + + struct Events + { + public const int Pursue = 1; + public const int Missile = 2; + public const int Vent = 3; + public const int Speed = 4; + public const int Summon = 5; + public const int Shutdown = 6; + public const int Repair = 7; + public const int ThorimSHammer = 8; // Tower Of Storms + public const int MimironSInferno = 9; // Tower Of Flames + public const int HodirSFury = 10; // Tower Of Frost + public const int FreyaSWard = 11; // Tower Of Nature + } + + struct Seats + { + public const int Player = 0; + public const int Turret = 1; + public const int Device = 2; + public const int Cannon = 7; + } + + struct Vehicles + { + public const uint Siege = 33060; + public const uint Chopper = 33062; + public const uint Demolisher = 33109; + } + + struct Leviathan + { + public const int DataShutout = 29112912; // 2911, 2912 are achievement IDs + public const int DataOrbitAchievements = 1; + public const int VehicleSpawns = 5; + public const int FreyaSpawns = 4; + + public const int ActionStartHardMode = 5; + public const int ActionSpawnVehicles = 6; + // Amount of seats depending on Raid mode + public const int TwoSeats = 2; + public const int FourSeats = 4; + + //Postions + public static Position Center = new Position(354.8771f, -12.90240f, 409.803650f); + public static Position InfernoStart = new Position(390.93f, -13.91f, 409.81f); + + public static Position[] PosSiege = { - public const uint Pursued = 62374; - public const uint GatheringSpeed = 62375; - public const uint BatteringRam = 62376; - public const uint FlameVents = 62396; - public const uint MissileBarrage = 62400; - public const uint SystemsShutdown = 62475; - public const uint OverloadCircuit = 62399; - public const uint StartTheEngine = 62472; - public const uint SearingFlame = 62402; - public const uint Blaze = 62292; - public const uint TarPassive = 62288; - public const uint SmokeTrail = 63575; - public const uint Electroshock = 62522; - public const uint Napalm = 63666; - public const uint InvisAndStealthDetect = 18950; // Passive - //Tower Additional Spells - public const uint ThorimSHammer = 62911; // Tower Of Storms - public const uint MimironSInferno = 62909; // Tower Of Flames - public const uint HodirSFury = 62533; // Tower Of Frost - public const uint FreyaSWard = 62906; // Tower Of Nature - public const uint FreyaSummons = 62947; // Tower Of Nature - //Tower Ap & Health Spells - public const uint BuffTowerOfStorms = 65076; - public const uint BuffTowerOfFlames = 65075; - public const uint BuffTowerOfFrost = 65077; - public const uint BuffTowerOfLife = 64482; - //Additional Spells - public const uint Lash = 65062; - public const uint FreyaSWardEffect1 = 62947; - public const uint FreyaSWardEffect2 = 62907; - public const uint AutoRepair = 62705; - public const uint DummyBlue = 63294; - public const uint DummyGreen = 63295; - public const uint DummyYellow = 63292; - public const uint LiquidPyrite = 62494; - public const uint DustyExplosion = 63360; - public const uint DustCloudImpact = 54740; - public const uint StealthDetection = 18950; - public const uint RideVehicle = 46598; - } - - struct CreatureIds - { - public const uint Seat = 33114; - public const uint Mechanolift = 33214; - public const uint Liquid = 33189; - public const uint Container = 33218; - public const uint ThorimBeacon = 33365; - public const uint MimironBeacon = 33370; - public const uint HodirBeacon = 33212; - public const uint FreyaBeacon = 33367; - public const uint ThorimTargetBeacon = 33364; - public const uint MimironTargetBeacon = 33369; - public const uint HodirTargetBeacon = 33108; - public const uint FreyaTargetBeacon = 33366; - public const uint Lorekeeper = 33686; // Hard Mode Starter - public const uint BranzBronzbeard = 33579; - public const uint Delorah = 33701; - public const uint UlduarGauntletGenerator = 33571; // Trigger Tied To Towers - } - - struct Towers - { - public const uint ofStorms = 194377; - public const uint ofFlames = 194371; - public const uint ofFrost = 194370; - public const uint ofLife = 194375; - } - - struct Events - { - public const int Pursue = 1; - public const int Missile = 2; - public const int Vent = 3; - public const int Speed = 4; - public const int Summon = 5; - public const int Shutdown = 6; - public const int Repair = 7; - public const int ThorimSHammer = 8; // Tower Of Storms - public const int MimironSInferno = 9; // Tower Of Flames - public const int HodirSFury = 10; // Tower Of Frost - public const int FreyaSWard = 11; // Tower Of Nature - } - - struct Seats - { - public const int Player = 0; - public const int Turret = 1; - public const int Device = 2; - public const int Cannon = 7; - } - - struct Vehicles - { - public const uint Siege = 33060; - public const uint Chopper = 33062; - public const uint Demolisher = 33109; - } - - struct Leviathan - { - public const int DataShutout = 29112912; // 2911, 2912 are achievement IDs - public const int DataOrbitAchievements = 1; - public const int VehicleSpawns = 5; - public const int FreyaSpawns = 4; - - public const int ActionStartHardMode = 5; - public const int ActionSpawnVehicles = 6; - // Amount of seats depending on Raid mode - public const int TwoSeats = 2; - public const int FourSeats = 4; - - //Postions - public static Position Center = new Position(354.8771f, -12.90240f, 409.803650f); - public static Position InfernoStart = new Position(390.93f, -13.91f, 409.81f); - - public static Position[] PosSiege = - { new Position(-814.59f, -64.54f, 429.92f, 5.969f), new Position(-784.37f, -33.31f, 429.92f, 5.096f), new Position(-808.99f, -52.10f, 429.92f, 5.668f), @@ -156,8 +154,8 @@ namespace Scripts.Northrend.Ulduar new Position(-812.83f, -77.71f, 429.92f, 0.046f), }; - public static Position[] PosChopper = - { + public static Position[] PosChopper = + { new Position(-717.83f, -106.56f, 430.02f, 0.122f), new Position(-717.83f, -114.23f, 430.44f, 0.122f), new Position(-717.83f, -109.70f, 430.22f, 0.122f), @@ -165,8 +163,8 @@ namespace Scripts.Northrend.Ulduar new Position(-718.45f, -123.58f, 430.41f, 0.085f), }; - public static Position[] PosDemolisher = - { + public static Position[] PosDemolisher = + { new Position(-724.12f, -176.64f, 430.03f, 2.543f), new Position(-766.70f, -225.03f, 430.50f, 1.710f), new Position(-729.54f, -186.26f, 430.12f, 1.902f), @@ -174,1595 +172,1374 @@ namespace Scripts.Northrend.Ulduar new Position(-798.01f, -227.24f, 429.84f, 1.446f), }; - public static Position[] FreyaBeacons = - { + public static Position[] FreyaBeacons = + { new Position(377.02f, -119.10f, 409.81f), new Position(185.62f, -119.10f, 409.81f), new Position(377.02f, 54.78f, 409.81f), new Position(185.62f, 54.78f, 409.81f), }; + } + + struct TextIds + { + public const uint Aggro = 0; + public const uint Slay = 1; + public const uint Death = 2; + public const uint Target = 3; + public const uint Hardmode = 4; + public const uint TowerNone = 5; + public const uint TowerFrost = 6; + public const uint TowerFlame = 7; + public const uint TowerNature = 8; + public const uint TowerStorm = 9; + public const uint PlayerRiding = 10; + public const uint Overload = 11; + public const uint EmotePursue = 12; + public const uint EmoteOverload = 13; + public const int EmoteRepair = 14; + } + + struct GossipIds + { + //LoreKeeperGossips + public const int MenuLoreKeeper = 10477; + public const int OptionLoreKeeper = 0; + } + + [Script] + class boss_flame_leviathan : BossAI + { + public boss_flame_leviathan(Creature creature) : base(creature, BossIds.Leviathan) + { + vehicle = creature.GetVehicleKit(); } - struct Says + public override void InitializeAI() { - public const uint Aggro = 0; - public const uint Slay = 1; - public const uint Death = 2; - public const uint Target = 3; - public const uint Hardmode = 4; - public const uint TowerNone = 5; - public const uint TowerFrost = 6; - public const uint TowerFlame = 7; - public const uint TowerNature = 8; - public const uint TowerStorm = 9; - public const uint PlayerRiding = 10; - public const uint Overload = 11; - public const uint EmotePursue = 12; - public const uint EmoteOverload = 13; - public const int EmoteRepair = 14; + Contract.Assert(vehicle); + if (!me.IsDead()) + Reset(); + + ActiveTowersCount = 4; + Shutdown = 0; + ActiveTowers = false; + towerOfStorms = false; + towerOfLife = false; + towerOfFlames = false; + towerOfFrost = false; + Shutout = true; + Unbroken = true; + + DoCast(Spells.InvisAndStealthDetect); + + me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable | UnitFlags.Stunned); + me.SetReactState(ReactStates.Passive); } - [Script] - class boss_flame_leviathan : CreatureScript + public override void Reset() { - public boss_flame_leviathan() : base("boss_flame_leviathan") { } + _Reset(); + //resets shutdown counter to 0. 2 or 4 depending on raid mode + Shutdown = 0; + _pursueTarget.Clear(); - class boss_flame_leviathanAI : BossAI - { - public boss_flame_leviathanAI(Creature creature) : base(creature, BossIds.Leviathan) - { - vehicle = creature.GetVehicleKit(); - } - - public override void InitializeAI() - { - Contract.Assert(vehicle); - if (!me.IsDead()) - Reset(); - - ActiveTowersCount = 4; - Shutdown = 0; - ActiveTowers = false; - towerOfStorms = false; - towerOfLife = false; - towerOfFlames = false; - towerOfFrost = false; - Shutout = true; - Unbroken = true; - - DoCast(Spells.InvisAndStealthDetect); - - me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable | UnitFlags.Stunned); - me.SetReactState(ReactStates.Passive); - } - - public override void Reset() - { - _Reset(); - //resets shutdown counter to 0. 2 or 4 depending on raid mode - Shutdown = 0; - _pursueTarget.Clear(); - - me.SetReactState(ReactStates.Defensive); - } - - public override void EnterCombat(Unit who) - { - _EnterCombat(); - me.SetReactState(ReactStates.Passive); - _events.ScheduleEvent(Events.Pursue, 1); - _events.ScheduleEvent(Events.Missile, RandomHelper.URand(1500, 4 * Time.InMilliseconds)); - _events.ScheduleEvent(Events.Vent, 20 * Time.InMilliseconds); - _events.ScheduleEvent(Events.Shutdown, 150 * Time.InMilliseconds); - _events.ScheduleEvent(Events.Speed, 15 * Time.InMilliseconds); - _events.ScheduleEvent(Events.Summon, 1 * Time.InMilliseconds); - ActiveTower(); //void ActiveTower - } - - void ActiveTower() - { - if (ActiveTowers) - { - if (towerOfStorms) - { - me.AddAura(Spells.BuffTowerOfStorms, me); - _events.ScheduleEvent(Events.ThorimSHammer, 35 * Time.InMilliseconds); - } - - if (towerOfFlames) - { - me.AddAura(Spells.BuffTowerOfFlames, me); - _events.ScheduleEvent(Events.MimironSInferno, 70 * Time.InMilliseconds); - } - - if (towerOfFrost) - { - me.AddAura(Spells.BuffTowerOfFrost, me); - _events.ScheduleEvent(Events.HodirSFury, 105 * Time.InMilliseconds); - } - - if (towerOfLife) - { - me.AddAura(Spells.BuffTowerOfLife, me); - _events.ScheduleEvent(Events.FreyaSWard, 140 * Time.InMilliseconds); - } - - if (!towerOfLife && !towerOfFrost && !towerOfFlames && !towerOfStorms) - Talk(Says.TowerNone); - else - Talk(Says.Hardmode); - } - else - Talk(Says.Aggro); - } - - public override void JustDied(Unit killer) - { - _JustDied(); - // Set Field Flags 67108928 = 64 | 67108864 = UNIT_FLAG_UNK_6 | UNIT_FLAG_SKINNABLE - // Set DynFlags 12 - // Set NPCFlags 0 - Talk(Says.Death); - } - - public override void SpellHit(Unit caster, SpellInfo spell) - { - if (spell.Id == Spells.StartTheEngine) - vehicle.InstallAllAccessories(false); - - if (spell.Id == Spells.Electroshock) - me.InterruptSpell(CurrentSpellTypes.Channeled); - - if (spell.Id == Spells.OverloadCircuit) - ++Shutdown; - } - - public override uint GetData(uint type) - { - switch (type) - { - case Leviathan.DataShutout: - return (uint)(Shutout ? 1 : 0); - case InstanceAchievementData.DataUnbroken: - return (uint)(Unbroken ? 1 : 0); - case Leviathan.DataOrbitAchievements: - if (ActiveTowers) // Only on HardMode - return ActiveTowersCount; - break; - default: - break; - } - - return 0; - } - - public override void SetData(uint id, uint data) - { - if (id == InstanceAchievementData.DataUnbroken) - Unbroken = data != 0 ? true : false; - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _events.Update(diff); - - if (Shutdown == RaidMode(Leviathan.TwoSeats, Leviathan.FourSeats)) - { - Shutdown = 0; - _events.ScheduleEvent(Events.Shutdown, 4000); - me.RemoveAurasDueToSpell(Spells.OverloadCircuit); - me.InterruptNonMeleeSpells(true); - return; - } - - if (me.HasUnitState(UnitState.Casting)) - return; - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case Events.Pursue: - Talk(Says.Target); - DoCast(Spells.Pursued); // Will select target in spellscript - _events.ScheduleEvent(Events.Pursue, 35 * Time.InMilliseconds); - break; - case Events.Missile: - DoCast(me, Spells.MissileBarrage, true); - _events.ScheduleEvent(Events.Missile, 2 * Time.InMilliseconds); - break; - case Events.Vent: - DoCastAOE(Spells.FlameVents); - _events.ScheduleEvent(Events.Vent, 20 * Time.InMilliseconds); - break; - case Events.Speed: - DoCastAOE(Spells.GatheringSpeed); - _events.ScheduleEvent(Events.Speed, 15 * Time.InMilliseconds); - break; - case Events.Summon: - if (summons.Count < 15) - { - Creature lift = DoSummonFlyer(CreatureIds.Mechanolift, me, 30.0f, 50.0f, 0); - if (lift) - lift.GetMotionMaster().MoveRandom(100); - } - _events.ScheduleEvent(Events.Summon, 2 * Time.InMilliseconds); - break; - case Events.Shutdown: - Talk(Says.Overload); - Talk(Says.EmoteOverload); - me.CastSpell(me, Spells.SystemsShutdown, true); - if (Shutout) - Shutout = false; - _events.ScheduleEvent(Events.Repair, 4000); - _events.DelayEvents(20 * Time.InMilliseconds, 0); - break; - case Events.Repair: - Talk(Says.EmoteRepair); - me.ClearUnitState(UnitState.Stunned | UnitState.Root); - _events.ScheduleEvent(Events.Shutdown, 150 * Time.InMilliseconds); - _events.CancelEvent(Events.Repair); - break; - case Events.ThorimSHammer: // Tower of Storms - for (byte i = 0; i < 7; ++i) - { - Creature thorim = DoSummon(CreatureIds.ThorimBeacon, me, RandomHelper.URand(20, 60), 20000, TempSummonType.TimedDespawn); - if (thorim) - thorim.GetMotionMaster().MoveRandom(100); - } - Talk(Says.TowerStorm); - _events.CancelEvent(Events.ThorimSHammer); - break; - case Events.MimironSInferno: // Tower of Flames - me.SummonCreature(CreatureIds.MimironBeacon, Leviathan.InfernoStart); - Talk(Says.TowerFlame); - _events.CancelEvent(Events.MimironSInferno); - break; - case Events.HodirSFury: // Tower of Frost - for (byte i = 0; i < 7; ++i) - { - Creature hodir = DoSummon(CreatureIds.HodirBeacon, me, 50f, 0); - if (hodir) - hodir.GetMotionMaster().MoveRandom(100); - } - Talk(Says.TowerFrost); - _events.CancelEvent(Events.HodirSFury); - break; - case Events.FreyaSWard: // Tower of Nature - Talk(Says.TowerNature); - for (int i = 0; i < 4; ++i) - me.SummonCreature(CreatureIds.FreyaBeacon, Leviathan.FreyaBeacons[i]); - - Unit target = SelectTarget(SelectAggroTarget.Random); - if (target) - DoCast(target, Spells.FreyaSWard); - _events.CancelEvent(Events.FreyaSWard); - break; - } - }); - - DoBatteringRamIfReady(); - } - - public override void SpellHitTarget(Unit target, SpellInfo spell) - { - if (spell.Id == Spells.Pursued) - _pursueTarget = target.GetGUID(); - } - - public override void DoAction(int action) - { - if (action != 0 && action <= 4) // Tower destruction, debuff leviathan loot and reduce active tower count - { - if (me.HasLootMode(LootModes.Default | LootModes.HardMode1 | LootModes.HardMode2 | LootModes.HardMode3 | LootModes.HardMode4) && ActiveTowersCount == 4) - me.RemoveLootMode(LootModes.HardMode4); - - if (me.HasLootMode(LootModes.Default | LootModes.HardMode1 | LootModes.HardMode2 | LootModes.HardMode3) && ActiveTowersCount == 3) - me.RemoveLootMode(LootModes.HardMode3); - - if (me.HasLootMode(LootModes.Default | LootModes.HardMode1 | LootModes.HardMode2) && ActiveTowersCount == 2) - me.RemoveLootMode(LootModes.HardMode2); - - if (me.HasLootMode(LootModes.Default | LootModes.HardMode1) && ActiveTowersCount == 1) - me.RemoveLootMode(LootModes.HardMode1); - } - - switch (action) - { - case LeviathanActions.TowerOfStormDestroyed: - if (towerOfStorms) - { - towerOfStorms = false; - --ActiveTowersCount; - } - break; - case LeviathanActions.TowerOfFrostDestroyed: - if (towerOfFrost) - { - towerOfFrost = false; - --ActiveTowersCount; - } - break; - case LeviathanActions.TowerOfFlamesDestroyed: - if (towerOfFlames) - { - towerOfFlames = false; - --ActiveTowersCount; - } - break; - case LeviathanActions.TowerOfLifeDestroyed: - if (towerOfLife) - { - towerOfLife = false; - --ActiveTowersCount; - } - break; - case Leviathan.ActionStartHardMode: // Activate hard-mode enable all towers, apply buffs on leviathan - ActiveTowers = true; - towerOfStorms = true; - towerOfLife = true; - towerOfFlames = true; - towerOfFrost = true; - me.SetLootMode(LootModes.Default | LootModes.HardMode1 | LootModes.HardMode2 | LootModes.HardMode3 | LootModes.HardMode4); - break; - case LeviathanActions.MoveToCenterPosition: // Triggered by 2 Collossus near door - if (!me.IsDead()) - { - me.SetHomePosition(Leviathan.Center); - me.GetMotionMaster().MoveCharge(Leviathan.Center.GetPositionX(), Leviathan.Center.GetPositionY(), Leviathan.Center.GetPositionZ()); // position center - me.SetReactState(ReactStates.Aggressive); - me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable | UnitFlags.Stunned); - return; - } - break; - default: - break; - } - } - - //! Copypasta from DoSpellAttackIfReady, only difference is the target - it cannot be selected trough GetVictim this way - - //! I also removed the spellInfo check - void DoBatteringRamIfReady() - { - if (me.isAttackReady()) - { - Unit target = Global.ObjAccessor.GetUnit(me, _pursueTarget); - if (me.IsWithinCombatRange(target, 30.0f)) - { - DoCast(target, Spells.BatteringRam); - me.resetAttackTimer(); - } - } - } - - Vehicle vehicle; - byte ActiveTowersCount; - byte Shutdown; - bool ActiveTowers; - bool towerOfStorms; - bool towerOfLife; - bool towerOfFlames; - bool towerOfFrost; - bool Shutout; - bool Unbroken; - ObjectGuid _pursueTarget; - } - - public override CreatureAI GetAI(Creature creature) - { - return instance_ulduar.GetUlduarInstanceAI(creature); - } + me.SetReactState(ReactStates.Defensive); } - [Script] - class boss_flame_leviathan_seat : CreatureScript + public override void EnterCombat(Unit who) { - public boss_flame_leviathan_seat() : base("boss_flame_leviathan_seat") { } - - class boss_flame_leviathan_seatAI : ScriptedAI - { - public boss_flame_leviathan_seatAI(Creature creature) - : base(creature) - { - vehicle = creature.GetVehicleKit(); - Contract.Assert(vehicle); - me.SetReactState(ReactStates.Passive); - me.SetDisplayId(me.GetCreatureTemplate().ModelId2); - instance = creature.GetInstanceScript(); - } - - InstanceScript instance; - Vehicle vehicle; - - public override void PassengerBoarded(Unit who, sbyte seatId, bool apply) - { - if (!me.GetVehicle()) - return; - - if (seatId == Seats.Player) - { - Creature leviathan = me.GetVehicleCreatureBase(); - if (!apply) - return; - else if (leviathan) - leviathan.GetAI().Talk(Says.PlayerRiding); - - Unit turretPassenger = me.GetVehicleKit().GetPassenger(Seats.Turret); - if (turretPassenger) - { - Creature turret = turretPassenger.ToCreature(); - if (turret) - { - turret.SetFaction(me.GetVehicleBase().getFaction()); - turret.SetUInt32Value(UnitFields.Flags, 0); // unselectable - turret.GetAI().AttackStart(who); - } - } - Unit devicePassenger = me.GetVehicleKit().GetPassenger(Seats.Device); - if (devicePassenger) - { - Creature device = devicePassenger.ToCreature(); - if (device) - { - device.SetFlag64(UnitFields.NpcFlags, NPCFlags.SpellClick); - device.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable); - } - } - - me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable); - } - else if (seatId == Seats.Turret) - { - if (apply) - return; - - Unit device = vehicle.GetPassenger(Seats.Device); - if (device) - { - device.SetFlag64(UnitFields.NpcFlags, NPCFlags.SpellClick); - device.SetUInt32Value(UnitFields.Flags, 0); // unselectable - } - } - } - } - - public override CreatureAI GetAI(Creature creature) - { - return instance_ulduar.GetUlduarInstanceAI(creature); - } + _EnterCombat(); + me.SetReactState(ReactStates.Passive); + _events.ScheduleEvent(Events.Pursue, 1); + _events.ScheduleEvent(Events.Missile, RandomHelper.URand(1500, 4 * Time.InMilliseconds)); + _events.ScheduleEvent(Events.Vent, 20 * Time.InMilliseconds); + _events.ScheduleEvent(Events.Shutdown, 150 * Time.InMilliseconds); + _events.ScheduleEvent(Events.Speed, 15 * Time.InMilliseconds); + _events.ScheduleEvent(Events.Summon, 1 * Time.InMilliseconds); + ActiveTower(); //void ActiveTower } - [Script] - class boss_flame_leviathan_defense_cannon : CreatureScript + void ActiveTower() { - public boss_flame_leviathan_defense_cannon() : base("boss_flame_leviathan_defense_cannon") { } - - class boss_flame_leviathan_defense_cannonAI : ScriptedAI + if (ActiveTowers) { - public boss_flame_leviathan_defense_cannonAI(Creature creature) - : base(creature) + if (towerOfStorms) { + me.AddAura(Spells.BuffTowerOfStorms, me); + _events.ScheduleEvent(Events.ThorimSHammer, 35 * Time.InMilliseconds); } - uint NapalmTimer; - - public override void Reset() + if (towerOfFlames) { - NapalmTimer = 5 * Time.InMilliseconds; - DoCast(me, Spells.StealthDetection); + me.AddAura(Spells.BuffTowerOfFlames, me); + _events.ScheduleEvent(Events.MimironSInferno, 70 * Time.InMilliseconds); } - public override void UpdateAI(uint diff) + if (towerOfFrost) { - if (!UpdateVictim()) - return; + me.AddAura(Spells.BuffTowerOfFrost, me); + _events.ScheduleEvent(Events.HodirSFury, 105 * Time.InMilliseconds); + } - if (NapalmTimer <= diff) - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0); + if (towerOfLife) + { + me.AddAura(Spells.BuffTowerOfLife, me); + _events.ScheduleEvent(Events.FreyaSWard, 140 * Time.InMilliseconds); + } + + if (!towerOfLife && !towerOfFrost && !towerOfFlames && !towerOfStorms) + Talk(TextIds.TowerNone); + else + Talk(TextIds.Hardmode); + } + else + Talk(TextIds.Aggro); + } + + public override void JustDied(Unit killer) + { + _JustDied(); + // Set Field Flags 67108928 = 64 | 67108864 = UNIT_FLAG_UNK_6 | UNIT_FLAG_SKINNABLE + // Set DynFlags 12 + // Set NPCFlags 0 + Talk(TextIds.Death); + } + + public override void SpellHit(Unit caster, SpellInfo spell) + { + if (spell.Id == Spells.StartTheEngine) + vehicle.InstallAllAccessories(false); + + if (spell.Id == Spells.Electroshock) + me.InterruptSpell(CurrentSpellTypes.Channeled); + + if (spell.Id == Spells.OverloadCircuit) + ++Shutdown; + } + + public override uint GetData(uint type) + { + switch (type) + { + case Leviathan.DataShutout: + return (uint)(Shutout ? 1 : 0); + case InstanceAchievementData.DataUnbroken: + return (uint)(Unbroken ? 1 : 0); + case Leviathan.DataOrbitAchievements: + if (ActiveTowers) // Only on HardMode + return ActiveTowersCount; + break; + default: + break; + } + + return 0; + } + + public override void SetData(uint id, uint data) + { + if (id == InstanceAchievementData.DataUnbroken) + Unbroken = data != 0 ? true : false; + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _events.Update(diff); + + if (Shutdown == RaidMode(Leviathan.TwoSeats, Leviathan.FourSeats)) + { + Shutdown = 0; + _events.ScheduleEvent(Events.Shutdown, 4000); + me.RemoveAurasDueToSpell(Spells.OverloadCircuit); + me.InterruptNonMeleeSpells(true); + return; + } + + if (me.HasUnitState(UnitState.Casting)) + return; + _events.ExecuteEvents(eventId => + { + switch (eventId) + { + case Events.Pursue: + Talk(TextIds.Target); + DoCast(Spells.Pursued); // Will select target in spellscript + _events.ScheduleEvent(Events.Pursue, 35 * Time.InMilliseconds); + break; + case Events.Missile: + DoCast(me, Spells.MissileBarrage, true); + _events.ScheduleEvent(Events.Missile, 2 * Time.InMilliseconds); + break; + case Events.Vent: + DoCastAOE(Spells.FlameVents); + _events.ScheduleEvent(Events.Vent, 20 * Time.InMilliseconds); + break; + case Events.Speed: + DoCastAOE(Spells.GatheringSpeed); + _events.ScheduleEvent(Events.Speed, 15 * Time.InMilliseconds); + break; + case Events.Summon: + if (summons.Count < 15) + { + Creature lift = DoSummonFlyer(CreatureIds.Mechanolift, me, 30.0f, 50.0f, 0); + if (lift) + lift.GetMotionMaster().MoveRandom(100); + } + _events.ScheduleEvent(Events.Summon, 2 * Time.InMilliseconds); + break; + case Events.Shutdown: + Talk(TextIds.Overload); + Talk(TextIds.EmoteOverload); + me.CastSpell(me, Spells.SystemsShutdown, true); + if (Shutout) + Shutout = false; + _events.ScheduleEvent(Events.Repair, 4000); + _events.DelayEvents(20 * Time.InMilliseconds, 0); + break; + case Events.Repair: + Talk(TextIds.EmoteRepair); + me.ClearUnitState(UnitState.Stunned | UnitState.Root); + _events.ScheduleEvent(Events.Shutdown, 150 * Time.InMilliseconds); + _events.CancelEvent(Events.Repair); + break; + case Events.ThorimSHammer: // Tower of Storms + for (byte i = 0; i < 7; ++i) + { + Creature thorim = DoSummon(CreatureIds.ThorimBeacon, me, RandomHelper.URand(20, 60), 20000, TempSummonType.TimedDespawn); + if (thorim) + thorim.GetMotionMaster().MoveRandom(100); + } + Talk(TextIds.TowerStorm); + _events.CancelEvent(Events.ThorimSHammer); + break; + case Events.MimironSInferno: // Tower of Flames + me.SummonCreature(CreatureIds.MimironBeacon, Leviathan.InfernoStart); + Talk(TextIds.TowerFlame); + _events.CancelEvent(Events.MimironSInferno); + break; + case Events.HodirSFury: // Tower of Frost + for (byte i = 0; i < 7; ++i) + { + Creature hodir = DoSummon(CreatureIds.HodirBeacon, me, 50f, 0); + if (hodir) + hodir.GetMotionMaster().MoveRandom(100); + } + Talk(TextIds.TowerFrost); + _events.CancelEvent(Events.HodirSFury); + break; + case Events.FreyaSWard: // Tower of Nature + Talk(TextIds.TowerNature); + for (int i = 0; i < 4; ++i) + me.SummonCreature(CreatureIds.FreyaBeacon, Leviathan.FreyaBeacons[i]); + + Unit target = SelectTarget(SelectAggroTarget.Random); if (target) - if (CanAIAttack(target)) - DoCast(target, Spells.Napalm, true); - - NapalmTimer = 5000; - } - else - NapalmTimer -= diff; - } - - public override bool CanAIAttack(Unit who) - { - if (!who.IsTypeId(TypeId.Player) || !who.GetVehicle() || who.GetVehicleBase().GetEntry() == CreatureIds.Seat) - return false; - return true; - } - } - - public override CreatureAI GetAI(Creature creature) - { - return new boss_flame_leviathan_defense_cannonAI(creature); - } - } - - [Script] - class boss_flame_leviathan_defense_turret : CreatureScript - { - public boss_flame_leviathan_defense_turret() : base("boss_flame_leviathan_defense_turret") { } - - class boss_flame_leviathan_defense_turretAI : TurretAI - { - public boss_flame_leviathan_defense_turretAI(Creature creature) : base(creature) { } - - public override void DamageTaken(Unit who, ref uint damage) - { - if (!CanAIAttack(who)) - damage = 0; - } - - public override bool CanAIAttack(Unit who) - { - if (!who.IsTypeId(TypeId.Player) || !who.GetVehicle() || who.GetVehicleBase().GetEntry() != CreatureIds.Seat) - return false; - return true; - } - } - - public override CreatureAI GetAI(Creature creature) - { - return new boss_flame_leviathan_defense_turretAI(creature); - } - } - - [Script] - class boss_flame_leviathan_overload_device : CreatureScript - { - public boss_flame_leviathan_overload_device() : base("boss_flame_leviathan_overload_device") { } - - class boss_flame_leviathan_overload_deviceAI : PassiveAI - { - public boss_flame_leviathan_overload_deviceAI(Creature creature) - : base(creature) - { - } - - public override void OnSpellClick(Unit clicker, ref bool result) - { - if (!result) - return; - - if (me.GetVehicle()) - { - me.RemoveFlag64(UnitFields.NpcFlags, NPCFlags.SpellClick); - me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable); - - Unit player = me.GetVehicle().GetPassenger(Seats.Player); - if (player) - { - me.GetVehicleBase().CastSpell(player, Spells.SmokeTrail, true); - player.GetMotionMaster().MoveKnockbackFrom(me.GetVehicleBase().GetPositionX(), me.GetVehicleBase().GetPositionY(), 30, 30); - player.ExitVehicle(); - } - } - } - } - - public override CreatureAI GetAI(Creature creature) - { - return new boss_flame_leviathan_overload_deviceAI(creature); - } - } - - [Script] - class boss_flame_leviathan_safety_container : CreatureScript - { - public boss_flame_leviathan_safety_container() : base("boss_flame_leviathan_safety_container") { } - - class boss_flame_leviathan_safety_containerAI : PassiveAI - { - public boss_flame_leviathan_safety_containerAI(Creature creature) - : base(creature) - { - } - - public override void JustDied(Unit killer) - { - float x, y, z; - me.GetPosition(out x, out y, out z); - z = me.GetMap().GetHeight(me.GetPhases(), x, y, z); - me.GetMotionMaster().MovePoint(0, x, y, z); - me.SetPosition(x, y, z, 0); - } - - public override void UpdateAI(uint diff) - { - } - } - - public override CreatureAI GetAI(Creature creature) - { - return new boss_flame_leviathan_safety_containerAI(creature); - } - } - - [Script] - class npc_mechanolift : CreatureScript - { - public npc_mechanolift() : base("npc_mechanolift") { } - - class npc_mechanoliftAI : PassiveAI - { - public npc_mechanoliftAI(Creature creature) : base(creature) - { - Contract.Assert(me.GetVehicleKit()); - } - - uint MoveTimer; - - public override void Reset() - { - MoveTimer = 0; - me.GetMotionMaster().MoveRandom(50); - } - - public override void JustDied(Unit killer) - { - me.GetMotionMaster().MoveTargetedHome(); - DoCast(Spells.DustyExplosion); - Creature liquid = DoSummon(CreatureIds.Liquid, me, 0f); - if (liquid) - { - liquid.CastSpell(liquid, Spells.LiquidPyrite, true); - liquid.CastSpell(liquid, Spells.DustCloudImpact, true); - } - } - - public override void MovementInform(MovementGeneratorType type, uint id) - { - if (type == MovementGeneratorType.Point && id == 1) - { - Creature container = me.FindNearestCreature(CreatureIds.Container, 5, true); - if (container) - container.EnterVehicle(me); - } - } - - public override void UpdateAI(uint diff) - { - if (MoveTimer <= diff) - { - if (me.GetVehicleKit().HasEmptySeat(-1)) - { - Creature container = me.FindNearestCreature(CreatureIds.Container, 50, true); - if (container && !container.GetVehicle()) - me.GetMotionMaster().MovePoint(1, container.GetPositionX(), container.GetPositionY(), container.GetPositionZ()); - } - - MoveTimer = 30000; //check next 30 seconds - } - else - MoveTimer -= diff; - } - } - - public override CreatureAI GetAI(Creature creature) - { - return new npc_mechanoliftAI(creature); - } - } - - [Script] - class npc_pool_of_tar : CreatureScript - { - public npc_pool_of_tar() : base("npc_pool_of_tar") { } - - class npc_pool_of_tarAI : ScriptedAI - { - public npc_pool_of_tarAI(Creature creature) - : base(creature) - { - me.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable); - me.SetReactState(ReactStates.Passive); - me.CastSpell(me, Spells.TarPassive, true); - } - - public override void DamageTaken(Unit who, ref uint damage) - { - damage = 0; - } - - public override void SpellHit(Unit caster, SpellInfo spell) - { - if (spell.SchoolMask.HasAnyFlag(SpellSchoolMask.Fire) && !me.HasAura(Spells.Blaze)) - me.CastSpell(me, Spells.Blaze, true); - } - - public override void UpdateAI(uint diff) { } - } - - public override CreatureAI GetAI(Creature creature) - { - return new npc_pool_of_tarAI(creature); - } - } - - [Script] - class npc_colossus : CreatureScript - { - public npc_colossus() : base("npc_colossus") { } - - class npc_colossusAI : ScriptedAI - { - public npc_colossusAI(Creature creature) - : base(creature) - { - instance = creature.GetInstanceScript(); - } - - InstanceScript instance; - - public override void JustDied(Unit killer) - { - if (me.GetHomePosition().IsInDist(Leviathan.Center, 50.0f)) - instance.SetData(InstanceData.Colossus, instance.GetData(InstanceData.Colossus) + 1); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - DoMeleeAttackIfReady(); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } - } - - [Script] - class npc_thorims_hammer : CreatureScript - { - public npc_thorims_hammer() : base("npc_thorims_hammer") { } - - class npc_thorims_hammerAI : ScriptedAI - { - public npc_thorims_hammerAI(Creature creature) - : base(creature) - { - me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable); - me.CastSpell(me, Spells.DummyBlue, true); - } - - public override void MoveInLineOfSight(Unit who) - { - if (who.IsTypeId(TypeId.Player) && who.IsVehicle() && me.IsInRange(who, 0, 10, false)) - { - Creature trigger = DoSummonFlyer(CreatureIds.ThorimTargetBeacon, me, 20, 0, 1000, TempSummonType.TimedDespawn); - if (trigger) - trigger.CastSpell(who, Spells.ThorimSHammer, true); - } - } - - public override void UpdateAI(uint diff) - { - if (!me.HasAura(Spells.DummyBlue)) - me.CastSpell(me, Spells.DummyBlue, true); - - UpdateVictim(); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return new npc_thorims_hammerAI(creature); - } - } - - [Script] - class npc_mimirons_inferno : CreatureScript - { - public npc_mimirons_inferno() : base("npc_mimirons_inferno") { } - - class npc_mimirons_infernoAI : npc_escortAI - { - public npc_mimirons_infernoAI(Creature creature) - : base(creature) - { - me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); - me.CastSpell(me, Spells.DummyYellow, true); - me.SetReactState(ReactStates.Passive); - } - - public override void WaypointReached(uint waypointId) - { - - } - - public override void Reset() - { - infernoTimer = 2000; - } - - uint infernoTimer; - - public override void UpdateAI(uint diff) - { - base.UpdateAI(diff); - - if (!HasEscortState(eEscortState.Escorting)) - Start(false, true, ObjectGuid.Empty, null, false, true); - else - { - if (infernoTimer <= diff) - { - Creature trigger = DoSummonFlyer(CreatureIds.MimironTargetBeacon, me, 20, 0, 1000, TempSummonType.TimedDespawn); - if (trigger) - { - trigger.CastSpell(me.GetPositionX(), me.GetPositionY(), me.GetPositionZ(), Spells.MimironSInferno, true); - infernoTimer = 2000; - } - } - else - infernoTimer -= diff; - - if (!me.HasAura(Spells.DummyYellow)) - me.CastSpell(me, Spells.DummyYellow, true); - } - } - } - - public override CreatureAI GetAI(Creature creature) - { - return new npc_mimirons_infernoAI(creature); - } - } - - [Script] - class npc_hodirs_fury : CreatureScript - { - public npc_hodirs_fury() : base("npc_hodirs_fury") { } - - class npc_hodirs_furyAI : ScriptedAI - { - public npc_hodirs_furyAI(Creature creature) - : base(creature) - { - me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable); - me.CastSpell(me, Spells.DummyGreen, true); - } - - public override void MoveInLineOfSight(Unit who) - { - if (who.IsTypeId(TypeId.Player) && who.IsVehicle() && me.IsInRange(who, 0, 5, false)) - { - Creature trigger = DoSummonFlyer(CreatureIds.HodirTargetBeacon, me, 20, 0, 1000, TempSummonType.TimedDespawn); - if (trigger) - trigger.CastSpell(who, Spells.HodirSFury, true); - } - } - - public override void UpdateAI(uint diff) - { - if (!me.HasAura(Spells.DummyGreen)) - me.CastSpell(me, Spells.DummyGreen, true); - - UpdateVictim(); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return new npc_hodirs_furyAI(creature); - } - } - - [Script] - class npc_freyas_ward : CreatureScript - { - public npc_freyas_ward() : base("npc_freyas_ward") { } - - class npc_freyas_wardAI : ScriptedAI - { - public npc_freyas_wardAI(Creature creature) - : base(creature) - { - me.CastSpell(me, Spells.DummyGreen, true); - } - - uint summonTimer; - - public override void Reset() - { - summonTimer = 5000; - } - - public override void UpdateAI(uint diff) - { - if (summonTimer <= diff) - { - DoCast(Spells.FreyaSWardEffect1); - DoCast(Spells.FreyaSWardEffect2); - summonTimer = 20000; - } - else - summonTimer -= diff; - - if (!me.HasAura(Spells.DummyGreen)) - me.CastSpell(me, Spells.DummyGreen, true); - - UpdateVictim(); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return new npc_freyas_wardAI(creature); - } - } - - [Script] - class npc_freya_ward_summon : CreatureScript - { - public npc_freya_ward_summon() : base("npc_freya_ward_summon") { } - - class npc_freya_ward_summonAI : ScriptedAI - { - public npc_freya_ward_summonAI(Creature creature) - : base(creature) - { - creature.GetMotionMaster().MoveRandom(100); - } - - uint lashTimer; - - public override void Reset() - { - lashTimer = 5000; - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - if (lashTimer <= diff) - { - DoCast(Spells.Lash); - lashTimer = 20000; - } - else - lashTimer -= diff; - - DoMeleeAttackIfReady(); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return new npc_freya_ward_summonAI(creature); - } - } - - [Script] - class npc_lorekeeper : CreatureScript - { - string GOSSIP_ITEM_1 = "Activate secondary defensive systems"; - string GOSSIP_ITEM_2 = "Confirmed"; - - public npc_lorekeeper() : base("npc_lorekeeper") { } - - class npc_lorekeeperAI : ScriptedAI - { - public npc_lorekeeperAI(Creature creature) - : base(creature) { } - - public override void DoAction(int action) - { - // Start encounter - if (action == Leviathan.ActionSpawnVehicles) - { - for (int i = 0; i < RaidMode(2, 5); ++i) - DoSummon(Vehicles.Siege, Leviathan.PosSiege[i], 3000, TempSummonType.CorpseTimedDespawn); - for (int i = 0; i < RaidMode(2, 5); ++i) - DoSummon(Vehicles.Chopper, Leviathan.PosChopper[i], 3000, TempSummonType.CorpseTimedDespawn); - for (int i = 0; i < RaidMode(2, 5); ++i) - DoSummon(Vehicles.Demolisher, Leviathan.PosDemolisher[i], 3000, TempSummonType.CorpseTimedDespawn); - return; - } - } - } - - public override bool OnGossipSelect(Player player, Creature creature, uint sender, uint action) - { - player.CLOSE_GOSSIP_MENU(); - InstanceScript instance = creature.GetInstanceScript(); - if (instance == null) - return true; - - switch (action) - { - case eTradeskill.GossipActionInfoDef + 1: - player.PrepareGossipMenu(creature); - instance.instance.LoadGrid(364, -16); //make sure leviathan is loaded - - player.ADD_GOSSIP_ITEM(GossipOptionIcon.Chat, GOSSIP_ITEM_2, eTradeskill.GossipSenderMain, eTradeskill.GossipActionInfoDef + 2); - player.SEND_GOSSIP_MENU(player.GetGossipTextId(creature), creature.GetGUID()); - break; - case eTradeskill.GossipActionInfoDef + 2: - Creature leviathan = instance.instance.GetCreature(instance.GetGuidData(BossIds.Leviathan)); - if (leviathan) - { - leviathan.GetAI().DoAction(Leviathan.ActionStartHardMode); - creature.SetVisible(false); - creature.GetAI().DoAction(Leviathan.ActionSpawnVehicles); // spawn the vehicles - Creature Delorah = creature.FindNearestCreature(CreatureIds.Delorah, 1000, true); - if (Delorah) - { - Creature Branz = creature.FindNearestCreature(CreatureIds.BranzBronzbeard, 1000, true); - if (Branz) - { - Delorah.GetMotionMaster().MovePoint(0, Branz.GetPositionX() - 4, Branz.GetPositionY(), Branz.GetPositionZ()); - // @todo Delorah.AI().Talk(xxxx, Branz); when reached at branz - } - } - } + DoCast(target, Spells.FreyaSWard); + _events.CancelEvent(Events.FreyaSWard); break; } + }); - return true; + DoBatteringRamIfReady(); + } + + public override void SpellHitTarget(Unit target, SpellInfo spell) + { + if (spell.Id == Spells.Pursued) + _pursueTarget = target.GetGUID(); + } + + public override void DoAction(int action) + { + if (action != 0 && action <= 4) // Tower destruction, debuff leviathan loot and reduce active tower count + { + if (me.HasLootMode(LootModes.Default | LootModes.HardMode1 | LootModes.HardMode2 | LootModes.HardMode3 | LootModes.HardMode4) && ActiveTowersCount == 4) + me.RemoveLootMode(LootModes.HardMode4); + + if (me.HasLootMode(LootModes.Default | LootModes.HardMode1 | LootModes.HardMode2 | LootModes.HardMode3) && ActiveTowersCount == 3) + me.RemoveLootMode(LootModes.HardMode3); + + if (me.HasLootMode(LootModes.Default | LootModes.HardMode1 | LootModes.HardMode2) && ActiveTowersCount == 2) + me.RemoveLootMode(LootModes.HardMode2); + + if (me.HasLootMode(LootModes.Default | LootModes.HardMode1) && ActiveTowersCount == 1) + me.RemoveLootMode(LootModes.HardMode1); } - public override bool OnGossipHello(Player player, Creature creature) + switch (action) { - InstanceScript instance = creature.GetInstanceScript(); - if (instance != null && instance.GetData(BossIds.Leviathan) != (uint)EncounterState.Done && player) - { - player.PrepareGossipMenu(creature); - - player.ADD_GOSSIP_ITEM(GossipOptionIcon.Chat, GOSSIP_ITEM_1, eTradeskill.GossipSenderMain, eTradeskill.GossipActionInfoDef + 1); - player.SEND_GOSSIP_MENU(player.GetGossipTextId(creature), creature.GetGUID()); - } - return true; - } - - public override CreatureAI GetAI(Creature creature) - { - return new npc_lorekeeperAI(creature); + case LeviathanActions.TowerOfStormDestroyed: + if (towerOfStorms) + { + towerOfStorms = false; + --ActiveTowersCount; + } + break; + case LeviathanActions.TowerOfFrostDestroyed: + if (towerOfFrost) + { + towerOfFrost = false; + --ActiveTowersCount; + } + break; + case LeviathanActions.TowerOfFlamesDestroyed: + if (towerOfFlames) + { + towerOfFlames = false; + --ActiveTowersCount; + } + break; + case LeviathanActions.TowerOfLifeDestroyed: + if (towerOfLife) + { + towerOfLife = false; + --ActiveTowersCount; + } + break; + case Leviathan.ActionStartHardMode: // Activate hard-mode enable all towers, apply buffs on leviathan + ActiveTowers = true; + towerOfStorms = true; + towerOfLife = true; + towerOfFlames = true; + towerOfFrost = true; + me.SetLootMode(LootModes.Default | LootModes.HardMode1 | LootModes.HardMode2 | LootModes.HardMode3 | LootModes.HardMode4); + break; + case LeviathanActions.MoveToCenterPosition: // Triggered by 2 Collossus near door + if (!me.IsDead()) + { + me.SetHomePosition(Leviathan.Center); + me.GetMotionMaster().MoveCharge(Leviathan.Center.GetPositionX(), Leviathan.Center.GetPositionY(), Leviathan.Center.GetPositionZ()); // position center + me.SetReactState(ReactStates.Aggressive); + me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable | UnitFlags.Stunned); + return; + } + break; + default: + break; } } - [Script] - class go_ulduar_tower : GameObjectScript + //! Copypasta from DoSpellAttackIfReady, only difference is the target - it cannot be selected trough GetVictim this way - + //! I also removed the spellInfo check + void DoBatteringRamIfReady() { - public go_ulduar_tower() : base("go_ulduar_tower") { } - - public override void OnDestroyed(GameObject go, Player player) + if (me.isAttackReady()) { - InstanceScript instance = go.GetInstanceScript(); - if (instance == null) + Unit target = Global.ObjAccessor.GetUnit(me, _pursueTarget); + if (me.IsWithinCombatRange(target, 30.0f)) + { + DoCast(target, Spells.BatteringRam); + me.resetAttackTimer(); + } + } + } + + Vehicle vehicle; + byte ActiveTowersCount; + byte Shutdown; + bool ActiveTowers; + bool towerOfStorms; + bool towerOfLife; + bool towerOfFlames; + bool towerOfFrost; + bool Shutout; + bool Unbroken; + ObjectGuid _pursueTarget; + } + + [Script] + class boss_flame_leviathan_seat : ScriptedAI + { + public boss_flame_leviathan_seat(Creature creature) + : base(creature) + { + vehicle = creature.GetVehicleKit(); + Contract.Assert(vehicle); + me.SetReactState(ReactStates.Passive); + me.SetDisplayId(me.GetCreatureTemplate().ModelId2); + instance = creature.GetInstanceScript(); + } + + InstanceScript instance; + Vehicle vehicle; + + public override void PassengerBoarded(Unit who, sbyte seatId, bool apply) + { + if (!me.GetVehicle()) + return; + + if (seatId == Seats.Player) + { + Creature leviathan = me.GetVehicleCreatureBase(); + if (!apply) + return; + else if (leviathan) + leviathan.GetAI().Talk(TextIds.PlayerRiding); + + Unit turretPassenger = me.GetVehicleKit().GetPassenger(Seats.Turret); + if (turretPassenger) + { + Creature turret = turretPassenger.ToCreature(); + if (turret) + { + turret.SetFaction(me.GetVehicleBase().getFaction()); + turret.SetUInt32Value(UnitFields.Flags, 0); // unselectable + turret.GetAI().AttackStart(who); + } + } + Unit devicePassenger = me.GetVehicleKit().GetPassenger(Seats.Device); + if (devicePassenger) + { + Creature device = devicePassenger.ToCreature(); + if (device) + { + device.SetFlag64(UnitFields.NpcFlags, NPCFlags.SpellClick); + device.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable); + } + } + + me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable); + } + else if (seatId == Seats.Turret) + { + if (apply) return; - switch (go.GetEntry()) + Unit device = vehicle.GetPassenger(Seats.Device); + if (device) { - case Towers.ofStorms: - instance.ProcessEvent(go, InstanceEventIds.TowerOfStormDestroyed); - break; - case Towers.ofFlames: - instance.ProcessEvent(go, InstanceEventIds.TowerOfFlamesDestroyed); - break; - case Towers.ofFrost: - instance.ProcessEvent(go, InstanceEventIds.TowerOfFrostDestroyed); - break; - case Towers.ofLife: - instance.ProcessEvent(go, InstanceEventIds.TowerOfLifeDestroyed); - break; + device.SetFlag64(UnitFields.NpcFlags, NPCFlags.SpellClick); + device.SetUInt32Value(UnitFields.Flags, 0); // unselectable } - - Creature trigger = go.FindNearestCreature(CreatureIds.UlduarGauntletGenerator, 15.0f, true); - if (trigger) - trigger.DisappearAndDie(); - } - } - - [Script] - class achievement_three_car_garage_demolisher : AchievementCriteriaScript - { - public achievement_three_car_garage_demolisher() : base("achievement_three_car_garage_demolisher") { } - - public override bool OnCheck(Player source, Unit target) - { - Creature vehicle = source.GetVehicleCreatureBase(); - if (vehicle) - { - if (vehicle.GetEntry() == Vehicles.Demolisher) - return true; - } - - return false; - } - } - - [Script] - class achievement_three_car_garage_chopper : AchievementCriteriaScript - { - public achievement_three_car_garage_chopper() : base("achievement_three_car_garage_chopper") { } - - public override bool OnCheck(Player source, Unit target) - { - Creature vehicle = source.GetVehicleCreatureBase(); - if (vehicle) - { - if (vehicle.GetEntry() == Vehicles.Chopper) - return true; - } - - return false; - } - } - - [Script] - class achievement_three_car_garage_siege : AchievementCriteriaScript - { - public achievement_three_car_garage_siege() : base("achievement_three_car_garage_siege") { } - - public override bool OnCheck(Player source, Unit target) - { - Creature vehicle = source.GetVehicleCreatureBase(); - if (vehicle) - { - if (vehicle.GetEntry() == Vehicles.Siege) - return true; - } - - return false; - } - } - - [Script] - class achievement_shutout : AchievementCriteriaScript - { - public achievement_shutout() : base("achievement_shutout") { } - - public override bool OnCheck(Player source, Unit target) - { - if (target) - { - Creature leviathan = target.ToCreature(); - if (leviathan) - if (leviathan.GetAI().GetData(Leviathan.DataShutout) != 0) - return true; - } - - return false; - } - } - - [Script] - class achievement_unbroken : AchievementCriteriaScript - { - public achievement_unbroken() : base("achievement_unbroken") { } - - public override bool OnCheck(Player source, Unit target) - { - if (target) - { - InstanceScript instance = target.GetInstanceScript(); - if (instance != null) - return instance.GetData(InstanceAchievementData.DataUnbroken) != 0; - } - - return false; - } - } - - [Script] - class achievement_orbital_bombardment : AchievementCriteriaScript - { - public achievement_orbital_bombardment() : base("achievement_orbital_bombardment") { } - - public override bool OnCheck(Player source, Unit target) - { - if (!target) - return false; - - Creature leviathan = target.ToCreature(); - if (leviathan) - if (leviathan.GetAI().GetData(Leviathan.DataOrbitAchievements) >= 1) - return true; - - return false; - } - } - - [Script] - class achievement_orbital_devastation : AchievementCriteriaScript - { - public achievement_orbital_devastation() : base("achievement_orbital_devastation") { } - - public override bool OnCheck(Player source, Unit target) - { - if (!target) - return false; - Creature leviathan = target.ToCreature(); - if (leviathan) - if (leviathan.GetAI().GetData(Leviathan.DataOrbitAchievements) >= 2) - return true; - - return false; - } - } - - [Script] - class achievement_nuked_from_orbit : AchievementCriteriaScript - { - public achievement_nuked_from_orbit() : base("achievement_nuked_from_orbit") { } - - public override bool OnCheck(Player source, Unit target) - { - if (!target) - return false; - - Creature leviathan = target.ToCreature(); - if (leviathan) - if (leviathan.GetAI().GetData(Leviathan.DataOrbitAchievements) >= 3) - return true; - - return false; - } - } - - [Script] - class achievement_orbit_uary : AchievementCriteriaScript - { - public achievement_orbit_uary() : base("achievement_orbit_uary") { } - - public override bool OnCheck(Player source, Unit target) - { - if (!target) - return false; - - Creature leviathan = target.ToCreature(); - if (leviathan) - if (leviathan.GetAI().GetData(Leviathan.DataOrbitAchievements) == 4) - return true; - - return false; - } - } - - [Script] - class spell_load_into_catapult : SpellScriptLoader - { - enum Spells - { - SPELL_PASSENGER_LOADED = 62340, - } - - public spell_load_into_catapult() : base("spell_load_into_catapult") { } - - class spell_load_into_catapult_AuraScript : AuraScript - { - void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Unit owner = GetOwner().ToUnit(); - if (!owner) - return; - - owner.CastSpell(owner, 62340, true); - } - - void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Unit owner = GetOwner().ToUnit(); - if (!owner) - return; - - owner.RemoveAurasDueToSpell(62340); - } - - public override void Register() - { - OnEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.ControlVehicle, AuraEffectHandleModes.Real)); - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ControlVehicle, AuraEffectHandleModes.RealOrReapplyMask)); - } - } - - public override AuraScript GetAuraScript() - { - return new spell_load_into_catapult_AuraScript(); - } - } - - [Script] - class spell_auto_repair : SpellScriptLoader - { - public spell_auto_repair() : base("spell_auto_repair") { } - - class spell_auto_repair_SpellScript : SpellScript - { - void CheckCooldownForTarget(SpellMissInfo missInfo) - { - if (missInfo != SpellMissInfo.None) - return; - - if (GetHitUnit().HasAuraEffect(62705, 2)) // Check presence of dummy aura indicating cooldown - { - PreventHitEffect(0); - PreventHitDefaultEffect(1); - PreventHitDefaultEffect(2); - //! Currently this doesn't work: if we call PreventHitAura(), the existing aura will be removed - //! because of recent aura refreshing changes. Since removing the existing aura negates the idea - //! of a cooldown marker, we just let the dummy aura refresh itself without executing the other SpellEffectName. - //! The spelleffects can be executed by letting the dummy aura expire naturally. - //! This is a temporary solution only. - } - } - - void HandleScript(uint eff) - { - Vehicle vehicle = GetHitUnit().GetVehicleKit(); - if (!vehicle) - return; - - Player driver = vehicle.GetPassenger(0) ? vehicle.GetPassenger(0).ToPlayer() : null; - if (!driver) - return; - - driver.TextEmote(Says.EmoteRepair, driver, true); - - InstanceScript instance = driver.GetInstanceScript(); - if (instance == null) - return; - - // Actually should/could use basepoints (100) for this spell effect as percentage of health, but oh well. - vehicle.GetBase().SetFullHealth(); - - // For achievement - instance.SetData(InstanceAchievementData.DataUnbroken, 0); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - BeforeHit.Add(new BeforeHitHandler(CheckCooldownForTarget)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_auto_repair_SpellScript(); - } - } - - [Script] - class spell_systems_shutdown : SpellScriptLoader - { - public spell_systems_shutdown() : base("spell_systems_shutdown") { } - - class spell_systems_shutdown_AuraScript : AuraScript - { - void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Creature owner = GetOwner().ToCreature(); - if (!owner) - return; - - //! This could probably in the SPELL_EFFECT_SEND_EVENT handler too: - owner.AddUnitState(UnitState.Stunned | UnitState.Root); - owner.SetFlag(UnitFields.Flags, UnitFlags.Stunned); - owner.RemoveAurasDueToSpell(Spells.GatheringSpeed); - } - - void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Creature owner = GetOwner().ToCreature(); - if (!owner) - return; - - owner.RemoveFlag(UnitFields.Flags, UnitFlags.Stunned); - } - - public override void Register() - { - OnEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.ModDamagePercentTaken, AuraEffectHandleModes.Real)); - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ModDamagePercentTaken, AuraEffectHandleModes.Real)); - } - } - - public override AuraScript GetAuraScript() - { - return new spell_systems_shutdown_AuraScript(); - } - } - - [Script] - class spell_pursue : SpellScriptLoader - { - public spell_pursue() : base("spell_pursue") { } - - const uint AREA_FORMATION_GROUNDS = 4652; - - class spell_pursue_SpellScript : SpellScript - { - public override bool Load() - { - _target = null; - return true; - } - - void FilterTargets(List targets) - { - targets.RemoveAll(new Predicate(target => - { - //! No players, only vehicles (@todo check if blizzlike) - Creature creatureTarget = target.ToCreature(); - if (!creatureTarget) - return true; - - //! NPC entries must match - if (creatureTarget.GetEntry() != Vehicles.Demolisher && creatureTarget.GetEntry() != Vehicles.Siege) - return true; - - //! NPC must be a valid vehicle installation - Vehicle vehicle = creatureTarget.GetVehicleKit(); - if (!vehicle) - return true; - - //! Entity needs to be in appropriate area - if (target.GetAreaId() != AREA_FORMATION_GROUNDS) - return true; - - //! Vehicle must be in use by player - bool playerFound = false; - foreach (var seat in vehicle.Seats.Values) - { - if (seat.Passenger.Guid.IsPlayer()) - { - playerFound = true; - break; - } - } - - return !playerFound; - })); - - if (targets.Empty()) - { - Creature caster = GetCaster().ToCreature(); - if (caster) - caster.GetAI().EnterEvadeMode(); - } - else - { - //! In the end, only one target should be selected - _target = targets.SelectRandom(); - FilterTargetsSubsequently(targets); - } - } - - void FilterTargetsSubsequently(List targets) - { - targets.Clear(); - if (_target) - targets.Add(_target); - } - - void HandleScript(uint eff) - { - Creature caster = GetCaster().ToCreature(); - if (!caster) - return; - - caster.GetAI().AttackStart(GetHitUnit()); // Chase target - - foreach (var seat in caster.GetVehicleKit().Seats.Values) - { - Player passenger = Global.ObjAccessor.GetPlayer(caster, seat.Passenger.Guid); - if (passenger) - { - caster.GetAI().Talk(Says.EmotePursue, passenger); - return; - } - } - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEnemy)); - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargetsSubsequently, 1, Targets.UnitSrcAreaEnemy)); - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ApplyAura)); - } - - WorldObject _target; - } - - public override SpellScript GetSpellScript() - { - return new spell_pursue_SpellScript(); - } - } - - [Script] - class spell_vehicle_throw_passenger : SpellScriptLoader - { - public spell_vehicle_throw_passenger() : base("spell_vehicle_throw_passenger") { } - - class spell_vehicle_throw_passenger_SpellScript : SpellScript - { - void HandleScript(uint effIndex) - { - Spell baseSpell = GetSpell(); - SpellCastTargets targets = baseSpell.m_targets; - int damage = GetEffectValue(); - if (targets.HasTraj()) - { - Vehicle vehicle = GetCaster().GetVehicleKit(); - if (vehicle) - { - Unit passenger = vehicle.GetPassenger((sbyte)(damage - 1)); - if (passenger) - { - // use 99 because it is 3d search - List targetList = new List(); - var check = new WorldObjectSpellAreaTargetCheck(99, GetExplTargetDest(), GetCaster(), GetCaster(), GetSpellInfo(), SpellTargetCheckTypes.Default, null); - var searcher = new WorldObjectListSearcher(GetCaster(), targetList, check); - Cell.VisitAllObjects(GetCaster(), searcher, 99.0f); - float minDist = 99 * 99; - Unit target = null; - foreach (var obj in targetList) - { - Unit unit = obj.ToUnit(); - if (unit) - { - if (unit.GetEntry() == CreatureIds.Seat) - { - Vehicle seat = unit.GetVehicleKit(); - if (seat) - { - if (!seat.GetPassenger(0)) - { - Unit device = seat.GetPassenger(2); - if (device) - if (!device.GetCurrentSpell(CurrentSpellTypes.Channeled)) - { - float dist = unit.GetExactDistSq(targets.GetDstPos()); - if (dist < minDist) - { - minDist = dist; - target = unit; - } - } - } - } - } - } - } - if (target && target.IsWithinDist2d(targets.GetDstPos(), GetSpellInfo().GetEffect(effIndex).CalcRadius() * 2)) // now we use *2 because the location of the seat is not correct - passenger.EnterVehicle(target, 0); - else - { - passenger.ExitVehicle(); - passenger.GetMotionMaster().MoveJump(targets.GetDstPos(), targets.GetSpeedXY(), targets.GetSpeedZ()); - } - } - } - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.Dummy)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_vehicle_throw_passenger_SpellScript(); } } } + + [Script] + class boss_flame_leviathan_defense_cannon : ScriptedAI + { + public boss_flame_leviathan_defense_cannon(Creature creature) + : base(creature) + { + } + + uint NapalmTimer; + + public override void Reset() + { + NapalmTimer = 5 * Time.InMilliseconds; + DoCast(me, Spells.StealthDetection); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + if (NapalmTimer <= diff) + { + Unit target = SelectTarget(SelectAggroTarget.Random, 0); + if (target) + if (CanAIAttack(target)) + DoCast(target, Spells.Napalm, true); + + NapalmTimer = 5000; + } + else + NapalmTimer -= diff; + } + + public override bool CanAIAttack(Unit who) + { + if (!who.IsTypeId(TypeId.Player) || !who.GetVehicle() || who.GetVehicleBase().GetEntry() == CreatureIds.Seat) + return false; + return true; + } + } + + [Script] + class boss_flame_leviathan_defense_turret : TurretAI + { + public boss_flame_leviathan_defense_turret(Creature creature) : base(creature) { } + + public override void DamageTaken(Unit who, ref uint damage) + { + if (!CanAIAttack(who)) + damage = 0; + } + + public override bool CanAIAttack(Unit who) + { + if (!who.IsTypeId(TypeId.Player) || !who.GetVehicle() || who.GetVehicleBase().GetEntry() != CreatureIds.Seat) + return false; + return true; + } + } + + [Script] + class boss_flame_leviathan_overload_device : PassiveAI + { + public boss_flame_leviathan_overload_device(Creature creature) + : base(creature) + { + } + + public override void OnSpellClick(Unit clicker, ref bool result) + { + if (!result) + return; + + if (me.GetVehicle()) + { + me.RemoveFlag64(UnitFields.NpcFlags, NPCFlags.SpellClick); + me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable); + + Unit player = me.GetVehicle().GetPassenger(Seats.Player); + if (player) + { + me.GetVehicleBase().CastSpell(player, Spells.SmokeTrail, true); + player.GetMotionMaster().MoveKnockbackFrom(me.GetVehicleBase().GetPositionX(), me.GetVehicleBase().GetPositionY(), 30, 30); + player.ExitVehicle(); + } + } + } + } + + [Script] + class boss_flame_leviathan_safety_container : PassiveAI + { + public boss_flame_leviathan_safety_container(Creature creature) + : base(creature) + { + } + + public override void JustDied(Unit killer) + { + float x, y, z; + me.GetPosition(out x, out y, out z); + z = me.GetMap().GetHeight(me.GetPhases(), x, y, z); + me.GetMotionMaster().MovePoint(0, x, y, z); + me.SetPosition(x, y, z, 0); + } + + public override void UpdateAI(uint diff) + { + } + } + + [Script] + class npc_mechanolift : PassiveAI + { + public npc_mechanolift(Creature creature) : base(creature) + { + Contract.Assert(me.GetVehicleKit()); + } + + uint MoveTimer; + + public override void Reset() + { + MoveTimer = 0; + me.GetMotionMaster().MoveRandom(50); + } + + public override void JustDied(Unit killer) + { + me.GetMotionMaster().MoveTargetedHome(); + DoCast(Spells.DustyExplosion); + Creature liquid = DoSummon(CreatureIds.Liquid, me, 0f); + if (liquid) + { + liquid.CastSpell(liquid, Spells.LiquidPyrite, true); + liquid.CastSpell(liquid, Spells.DustCloudImpact, true); + } + } + + public override void MovementInform(MovementGeneratorType type, uint id) + { + if (type == MovementGeneratorType.Point && id == 1) + { + Creature container = me.FindNearestCreature(CreatureIds.Container, 5, true); + if (container) + container.EnterVehicle(me); + } + } + + public override void UpdateAI(uint diff) + { + if (MoveTimer <= diff) + { + if (me.GetVehicleKit().HasEmptySeat(-1)) + { + Creature container = me.FindNearestCreature(CreatureIds.Container, 50, true); + if (container && !container.GetVehicle()) + me.GetMotionMaster().MovePoint(1, container.GetPositionX(), container.GetPositionY(), container.GetPositionZ()); + } + + MoveTimer = 30000; //check next 30 seconds + } + else + MoveTimer -= diff; + } + } + + [Script] + class npc_pool_of_tar : ScriptedAI + { + public npc_pool_of_tar(Creature creature) + : base(creature) + { + me.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable); + me.SetReactState(ReactStates.Passive); + me.CastSpell(me, Spells.TarPassive, true); + } + + public override void DamageTaken(Unit who, ref uint damage) + { + damage = 0; + } + + public override void SpellHit(Unit caster, SpellInfo spell) + { + if (spell.SchoolMask.HasAnyFlag(SpellSchoolMask.Fire) && !me.HasAura(Spells.Blaze)) + me.CastSpell(me, Spells.Blaze, true); + } + + public override void UpdateAI(uint diff) { } + } + + [Script] + class npc_colossus : ScriptedAI + { + public npc_colossus(Creature creature) + : base(creature) + { + instance = creature.GetInstanceScript(); + } + + InstanceScript instance; + + public override void JustDied(Unit killer) + { + if (me.GetHomePosition().IsInDist(Leviathan.Center, 50.0f)) + instance.SetData(InstanceData.Colossus, instance.GetData(InstanceData.Colossus) + 1); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + DoMeleeAttackIfReady(); + } + } + + [Script] + class npc_thorims_hammer : ScriptedAI + { + public npc_thorims_hammer(Creature creature) + : base(creature) + { + me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable); + me.CastSpell(me, Spells.DummyBlue, true); + } + + public override void MoveInLineOfSight(Unit who) + { + if (who.IsTypeId(TypeId.Player) && who.IsVehicle() && me.IsInRange(who, 0, 10, false)) + { + Creature trigger = DoSummonFlyer(CreatureIds.ThorimTargetBeacon, me, 20, 0, 1000, TempSummonType.TimedDespawn); + if (trigger) + trigger.CastSpell(who, Spells.ThorimSHammer, true); + } + } + + public override void UpdateAI(uint diff) + { + if (!me.HasAura(Spells.DummyBlue)) + me.CastSpell(me, Spells.DummyBlue, true); + + UpdateVictim(); + } + } + + [Script] + class npc_mimirons_inferno : npc_escortAI + { + public npc_mimirons_inferno(Creature creature) + : base(creature) + { + me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); + me.CastSpell(me, Spells.DummyYellow, true); + me.SetReactState(ReactStates.Passive); + } + + public override void WaypointReached(uint waypointId) + { + + } + + public override void Reset() + { + infernoTimer = 2000; + } + + uint infernoTimer; + + public override void UpdateAI(uint diff) + { + base.UpdateAI(diff); + + if (!HasEscortState(eEscortState.Escorting)) + Start(false, true, ObjectGuid.Empty, null, false, true); + else + { + if (infernoTimer <= diff) + { + Creature trigger = DoSummonFlyer(CreatureIds.MimironTargetBeacon, me, 20, 0, 1000, TempSummonType.TimedDespawn); + if (trigger) + { + trigger.CastSpell(me.GetPositionX(), me.GetPositionY(), me.GetPositionZ(), Spells.MimironSInferno, true); + infernoTimer = 2000; + } + } + else + infernoTimer -= diff; + + if (!me.HasAura(Spells.DummyYellow)) + me.CastSpell(me, Spells.DummyYellow, true); + } + } + } + + [Script] + class npc_hodirs_fury : ScriptedAI + { + public npc_hodirs_fury(Creature creature) + : base(creature) + { + me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable); + me.CastSpell(me, Spells.DummyGreen, true); + } + + public override void MoveInLineOfSight(Unit who) + { + if (who.IsTypeId(TypeId.Player) && who.IsVehicle() && me.IsInRange(who, 0, 5, false)) + { + Creature trigger = DoSummonFlyer(CreatureIds.HodirTargetBeacon, me, 20, 0, 1000, TempSummonType.TimedDespawn); + if (trigger) + trigger.CastSpell(who, Spells.HodirSFury, true); + } + } + + public override void UpdateAI(uint diff) + { + if (!me.HasAura(Spells.DummyGreen)) + me.CastSpell(me, Spells.DummyGreen, true); + + UpdateVictim(); + } + } + + [Script] + class npc_freyas_ward : ScriptedAI + { + public npc_freyas_ward(Creature creature) + : base(creature) + { + me.CastSpell(me, Spells.DummyGreen, true); + } + + uint summonTimer; + + public override void Reset() + { + summonTimer = 5000; + } + + public override void UpdateAI(uint diff) + { + if (summonTimer <= diff) + { + DoCast(Spells.FreyaSWardEffect1); + DoCast(Spells.FreyaSWardEffect2); + summonTimer = 20000; + } + else + summonTimer -= diff; + + if (!me.HasAura(Spells.DummyGreen)) + me.CastSpell(me, Spells.DummyGreen, true); + + UpdateVictim(); + } + } + + [Script] + class npc_freya_ward_summon : ScriptedAI + { + public npc_freya_ward_summon(Creature creature) + : base(creature) + { + creature.GetMotionMaster().MoveRandom(100); + } + + uint lashTimer; + + public override void Reset() + { + lashTimer = 5000; + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + if (lashTimer <= diff) + { + DoCast(Spells.Lash); + lashTimer = 20000; + } + else + lashTimer -= diff; + + DoMeleeAttackIfReady(); + } + } + + [Script] + class npc_lorekeeper : ScriptedAI + { + public npc_lorekeeper(Creature creature) : base(creature) + { + _instance = creature.GetInstanceScript(); + } + + public override void DoAction(int action) + { + // Start encounter + if (action == Leviathan.ActionSpawnVehicles) + { + for (int i = 0; i < RaidMode(2, 5); ++i) + DoSummon(Vehicles.Siege, Leviathan.PosSiege[i], 3000, TempSummonType.CorpseTimedDespawn); + for (int i = 0; i < RaidMode(2, 5); ++i) + DoSummon(Vehicles.Chopper, Leviathan.PosChopper[i], 3000, TempSummonType.CorpseTimedDespawn); + for (int i = 0; i < RaidMode(2, 5); ++i) + DoSummon(Vehicles.Demolisher, Leviathan.PosDemolisher[i], 3000, TempSummonType.CorpseTimedDespawn); + return; + } + } + + public override void sGossipSelect(Player player, uint menuId, uint gossipListId) + { + if (menuId == GossipIds.MenuLoreKeeper && gossipListId == GossipIds.OptionLoreKeeper) + { + me.RemoveFlag(UnitFields.NpcFlags, NPCFlags.Gossip); + player.PlayerTalkClass.SendCloseGossip(); + me.GetMap().LoadGrid(364, -16); // make sure leviathan is loaded + + Creature leviathan = ObjectAccessor.GetCreature(me, _instance.GetGuidData(BossIds.Leviathan)); + if (leviathan) + { + leviathan.GetAI().DoAction(Leviathan.ActionStartHardMode); + me.SetVisible(false); + DoAction(Leviathan.ActionSpawnVehicles); // spawn the vehicles + + Creature delorah = _instance.GetCreature(InstanceData.Dellorah); + if (delorah) + { + Creature brann = _instance.GetCreature(InstanceData.BrannBronzebeardIntro); + if (brann) + { + brann.RemoveFlag(UnitFields.NpcFlags, NPCFlags.Gossip); + delorah.GetMotionMaster().MovePoint(0, brann.GetPositionX() - 4, brann.GetPositionY(), brann.GetPositionZ()); + /// @todo delorah->AI()->Talk(xxxx, brann->GetGUID()); when reached at branz + } + } + } + } + } + + InstanceScript _instance; + } + + [Script] + class go_ulduar_tower : GameObjectScript + { + public go_ulduar_tower() : base("go_ulduar_tower") { } + + public override void OnDestroyed(GameObject go, Player player) + { + InstanceScript instance = go.GetInstanceScript(); + if (instance == null) + return; + + switch (go.GetEntry()) + { + case Towers.ofStorms: + instance.ProcessEvent(go, InstanceEventIds.TowerOfStormDestroyed); + break; + case Towers.ofFlames: + instance.ProcessEvent(go, InstanceEventIds.TowerOfFlamesDestroyed); + break; + case Towers.ofFrost: + instance.ProcessEvent(go, InstanceEventIds.TowerOfFrostDestroyed); + break; + case Towers.ofLife: + instance.ProcessEvent(go, InstanceEventIds.TowerOfLifeDestroyed); + break; + } + + Creature trigger = go.FindNearestCreature(CreatureIds.UlduarGauntletGenerator, 15.0f, true); + if (trigger) + trigger.DisappearAndDie(); + } + } + + [Script] + class achievement_three_car_garage_demolisher : AchievementCriteriaScript + { + public achievement_three_car_garage_demolisher() : base("achievement_three_car_garage_demolisher") { } + + public override bool OnCheck(Player source, Unit target) + { + Creature vehicle = source.GetVehicleCreatureBase(); + if (vehicle) + { + if (vehicle.GetEntry() == Vehicles.Demolisher) + return true; + } + + return false; + } + } + + [Script] + class achievement_three_car_garage_chopper : AchievementCriteriaScript + { + public achievement_three_car_garage_chopper() : base("achievement_three_car_garage_chopper") { } + + public override bool OnCheck(Player source, Unit target) + { + Creature vehicle = source.GetVehicleCreatureBase(); + if (vehicle) + { + if (vehicle.GetEntry() == Vehicles.Chopper) + return true; + } + + return false; + } + } + + [Script] + class achievement_three_car_garage_siege : AchievementCriteriaScript + { + public achievement_three_car_garage_siege() : base("achievement_three_car_garage_siege") { } + + public override bool OnCheck(Player source, Unit target) + { + Creature vehicle = source.GetVehicleCreatureBase(); + if (vehicle) + { + if (vehicle.GetEntry() == Vehicles.Siege) + return true; + } + + return false; + } + } + + [Script] + class achievement_shutout : AchievementCriteriaScript + { + public achievement_shutout() : base("achievement_shutout") { } + + public override bool OnCheck(Player source, Unit target) + { + if (target) + { + Creature leviathan = target.ToCreature(); + if (leviathan) + if (leviathan.GetAI().GetData(Leviathan.DataShutout) != 0) + return true; + } + + return false; + } + } + + [Script] + class achievement_unbroken : AchievementCriteriaScript + { + public achievement_unbroken() : base("achievement_unbroken") { } + + public override bool OnCheck(Player source, Unit target) + { + if (target) + { + InstanceScript instance = target.GetInstanceScript(); + if (instance != null) + return instance.GetData(InstanceAchievementData.DataUnbroken) != 0; + } + + return false; + } + } + + [Script] + class achievement_orbital_bombardment : AchievementCriteriaScript + { + public achievement_orbital_bombardment() : base("achievement_orbital_bombardment") { } + + public override bool OnCheck(Player source, Unit target) + { + if (!target) + return false; + + Creature leviathan = target.ToCreature(); + if (leviathan) + if (leviathan.GetAI().GetData(Leviathan.DataOrbitAchievements) >= 1) + return true; + + return false; + } + } + + [Script] + class achievement_orbital_devastation : AchievementCriteriaScript + { + public achievement_orbital_devastation() : base("achievement_orbital_devastation") { } + + public override bool OnCheck(Player source, Unit target) + { + if (!target) + return false; + Creature leviathan = target.ToCreature(); + if (leviathan) + if (leviathan.GetAI().GetData(Leviathan.DataOrbitAchievements) >= 2) + return true; + + return false; + } + } + + [Script] + class achievement_nuked_from_orbit : AchievementCriteriaScript + { + public achievement_nuked_from_orbit() : base("achievement_nuked_from_orbit") { } + + public override bool OnCheck(Player source, Unit target) + { + if (!target) + return false; + + Creature leviathan = target.ToCreature(); + if (leviathan) + if (leviathan.GetAI().GetData(Leviathan.DataOrbitAchievements) >= 3) + return true; + + return false; + } + } + + [Script] + class achievement_orbit_uary : AchievementCriteriaScript + { + public achievement_orbit_uary() : base("achievement_orbit_uary") { } + + public override bool OnCheck(Player source, Unit target) + { + if (!target) + return false; + + Creature leviathan = target.ToCreature(); + if (leviathan) + if (leviathan.GetAI().GetData(Leviathan.DataOrbitAchievements) == 4) + return true; + + return false; + } + } + + [Script] + class spell_load_into_catapult : AuraScript + { + void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit owner = GetOwner().ToUnit(); + if (!owner) + return; + + owner.CastSpell(owner, 62340, true); + } + + void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit owner = GetOwner().ToUnit(); + if (!owner) + return; + + owner.RemoveAurasDueToSpell(62340); + } + + public override void Register() + { + OnEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.ControlVehicle, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ControlVehicle, AuraEffectHandleModes.RealOrReapplyMask)); + } + } + + [Script] + class spell_auto_repair : SpellScript + { + void CheckCooldownForTarget(SpellMissInfo missInfo) + { + if (missInfo != SpellMissInfo.None) + return; + + if (GetHitUnit().HasAuraEffect(62705, 2)) // Check presence of dummy aura indicating cooldown + { + PreventHitEffect(0); + PreventHitDefaultEffect(1); + PreventHitDefaultEffect(2); + //! Currently this doesn't work: if we call PreventHitAura(), the existing aura will be removed + //! because of recent aura refreshing changes. Since removing the existing aura negates the idea + //! of a cooldown marker, we just let the dummy aura refresh itself without executing the other SpellEffectName. + //! The spelleffects can be executed by letting the dummy aura expire naturally. + //! This is a temporary solution only. + } + } + + void HandleScript(uint eff) + { + Vehicle vehicle = GetHitUnit().GetVehicleKit(); + if (!vehicle) + return; + + Player driver = vehicle.GetPassenger(0) ? vehicle.GetPassenger(0).ToPlayer() : null; + if (!driver) + return; + + driver.TextEmote(TextIds.EmoteRepair, driver, true); + + InstanceScript instance = driver.GetInstanceScript(); + if (instance == null) + return; + + // Actually should/could use basepoints (100) for this spell effect as percentage of health, but oh well. + vehicle.GetBase().SetFullHealth(); + + // For achievement + instance.SetData(InstanceAchievementData.DataUnbroken, 0); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + BeforeHit.Add(new BeforeHitHandler(CheckCooldownForTarget)); + } + } + + [Script] + class spell_systems_shutdown : AuraScript + { + void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Creature owner = GetOwner().ToCreature(); + if (!owner) + return; + + //! This could probably in the SPELL_EFFECT_SEND_EVENT handler too: + owner.AddUnitState(UnitState.Stunned | UnitState.Root); + owner.SetFlag(UnitFields.Flags, UnitFlags.Stunned); + owner.RemoveAurasDueToSpell(Spells.GatheringSpeed); + } + + void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Creature owner = GetOwner().ToCreature(); + if (!owner) + return; + + owner.RemoveFlag(UnitFields.Flags, UnitFlags.Stunned); + } + + public override void Register() + { + OnEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.ModDamagePercentTaken, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ModDamagePercentTaken, AuraEffectHandleModes.Real)); + } + } + + [Script] + class spell_pursue : SpellScript + { + public override bool Load() + { + _target = null; + return true; + } + + void FilterTargets(List targets) + { + targets.RemoveAll(new Predicate(target => + { + //! No players, only vehicles (@todo check if blizzlike) + Creature creatureTarget = target.ToCreature(); + if (!creatureTarget) + return true; + + //! NPC entries must match + if (creatureTarget.GetEntry() != Vehicles.Demolisher && creatureTarget.GetEntry() != Vehicles.Siege) + return true; + + //! NPC must be a valid vehicle installation + Vehicle vehicle = creatureTarget.GetVehicleKit(); + if (!vehicle) + return true; + + //! Entity needs to be in appropriate area + if (target.GetAreaId() != AREA_FORMATION_GROUNDS) + return true; + + //! Vehicle must be in use by player + bool playerFound = false; + foreach (var seat in vehicle.Seats.Values) + { + if (seat.Passenger.Guid.IsPlayer()) + { + playerFound = true; + break; + } + } + + return !playerFound; + })); + + if (targets.Empty()) + { + Creature caster = GetCaster().ToCreature(); + if (caster) + caster.GetAI().EnterEvadeMode(); + } + else + { + //! In the end, only one target should be selected + _target = targets.SelectRandom(); + FilterTargetsSubsequently(targets); + } + } + + void FilterTargetsSubsequently(List targets) + { + targets.Clear(); + if (_target) + targets.Add(_target); + } + + void HandleScript(uint eff) + { + Creature caster = GetCaster().ToCreature(); + if (!caster) + return; + + caster.GetAI().AttackStart(GetHitUnit()); // Chase target + + foreach (var seat in caster.GetVehicleKit().Seats.Values) + { + Player passenger = Global.ObjAccessor.GetPlayer(caster, seat.Passenger.Guid); + if (passenger) + { + caster.GetAI().Talk(TextIds.EmotePursue, passenger); + return; + } + } + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEnemy)); + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargetsSubsequently, 1, Targets.UnitSrcAreaEnemy)); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ApplyAura)); + } + + const uint AREA_FORMATION_GROUNDS = 4652; + + WorldObject _target; + } + + [Script] + class spell_vehicle_throw_passenger : SpellScript + { + void HandleScript(uint effIndex) + { + Spell baseSpell = GetSpell(); + SpellCastTargets targets = baseSpell.m_targets; + int damage = GetEffectValue(); + if (targets.HasTraj()) + { + Vehicle vehicle = GetCaster().GetVehicleKit(); + if (vehicle) + { + Unit passenger = vehicle.GetPassenger((sbyte)(damage - 1)); + if (passenger) + { + // use 99 because it is 3d search + List targetList = new List(); + var check = new WorldObjectSpellAreaTargetCheck(99, GetExplTargetDest(), GetCaster(), GetCaster(), GetSpellInfo(), SpellTargetCheckTypes.Default, null); + var searcher = new WorldObjectListSearcher(GetCaster(), targetList, check); + Cell.VisitAllObjects(GetCaster(), searcher, 99.0f); + float minDist = 99 * 99; + Unit target = null; + foreach (var obj in targetList) + { + Unit unit = obj.ToUnit(); + if (unit) + { + if (unit.GetEntry() == CreatureIds.Seat) + { + Vehicle seat = unit.GetVehicleKit(); + if (seat) + { + if (!seat.GetPassenger(0)) + { + Unit device = seat.GetPassenger(2); + if (device) + if (!device.GetCurrentSpell(CurrentSpellTypes.Channeled)) + { + float dist = unit.GetExactDistSq(targets.GetDstPos()); + if (dist < minDist) + { + minDist = dist; + target = unit; + } + } + } + } + } + } + } + if (target && target.IsWithinDist2d(targets.GetDstPos(), GetSpellInfo().GetEffect(effIndex).CalcRadius() * 2)) // now we use *2 because the location of the seat is not correct + passenger.EnterVehicle(target, 0); + else + { + passenger.ExitVehicle(); + passenger.GetMotionMaster().MoveJump(targets.GetDstPos(), targets.GetSpeedXY(), targets.GetSpeedZ()); + } + } + } + } + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.Dummy)); + } + } } diff --git a/Scripts/Northrend/Ulduar/Mimiron.cs b/Scripts/Northrend/Ulduar/Mimiron.cs index 57b4638c1..56559fb4e 100644 --- a/Scripts/Northrend/Ulduar/Mimiron.cs +++ b/Scripts/Northrend/Ulduar/Mimiron.cs @@ -372,1320 +372,1220 @@ namespace Scripts.Northrend.Ulduar } [Script] - class boss_mimiron : CreatureScript + class boss_mimiron : BossAI { - public boss_mimiron() : base("boss_mimiron") { } - - class boss_mimironAI : BossAI + public boss_mimiron(Creature creature) : base(creature, BossIds.Mimiron) { - public boss_mimironAI(Creature creature) : base(creature, BossIds.Mimiron) + me.SetReactState(ReactStates.Passive); + _fireFighter = false; + } + + public override void InitializeAI() + { + SetupEncounter(); + } + + void SetupEncounter() + { + _Reset(); + me.SetReactState(ReactStates.Passive); + me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); + + GameObject elevator = ObjectAccessor.GetGameObject(me, instance.GetGuidData(InstanceData.MimironElevator)); + if (elevator) + elevator.SetGoState(GameObjectState.Active); + + if (_fireFighter) { - me.SetReactState(ReactStates.Passive); - _fireFighter = false; + Creature computer = ObjectAccessor.GetCreature(me, instance.GetGuidData(InstanceData.Computer)); + if (computer) + computer.GetAI().DoAction(Actions.DeactivateComputer); } - public override void InitializeAI() + GameObject button = ObjectAccessor.GetGameObject(me, instance.GetGuidData(InstanceData.MimironButton)); + if (button) { - SetupEncounter(); + button.SetGoState(GameObjectState.Ready); + button.RemoveFlag(GameObjectFields.Flags, GameObjectFlags.NotSelectable); } - void SetupEncounter() + _fireFighter = false; + DoCast(me, Spells.Weld); + Unit mkii = Global.ObjAccessor.GetUnit(me, instance.GetGuidData(InstanceData.LeviathanMKII)); + if (mkii) + DoCast(mkii, Spells.Seat3); + + if (!_events.Empty()) { - _Reset(); - me.SetReactState(ReactStates.Passive); - me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); - GameObject elevator = ObjectAccessor.GetGameObject(me, instance.GetGuidData(InstanceData.MimironElevator)); - if (elevator) - elevator.SetGoState(GameObjectState.Active); - - if (_fireFighter) - { - Creature computer = ObjectAccessor.GetCreature(me, instance.GetGuidData(InstanceData.Computer)); - if (computer) - computer.GetAI().DoAction(Actions.DeactivateComputer); - } - - GameObject button = ObjectAccessor.GetGameObject(me, instance.GetGuidData(InstanceData.MimironButton)); - if (button) - { - button.SetGoState(GameObjectState.Ready); - button.RemoveFlag(GameObjectFields.Flags, GameObjectFlags.NotSelectable); - } - - _fireFighter = false; - DoCast(me, Spells.Weld); - Unit mkii = Global.ObjAccessor.GetUnit(me, instance.GetGuidData(InstanceData.LeviathanMKII)); - if (mkii) - DoCast(mkii, Spells.Seat3); - - if (!_events.Empty()) - { - - } } + } - public override void DoAction(int action) + public override void DoAction(int action) + { + switch (action) { - switch (action) + case Actions.ActivateVx001: + _events.ScheduleEvent(Events.Vx001Activation1, 1000); + break; + case Actions.ActivateAerial: + _events.ScheduleEvent(Events.AerialActivation1, 5000); + break; + case Actions.ActivateV0l7r0n1: + Talk(Yells.AerialDeath); + Creature mkii = ObjectAccessor.GetCreature(me, instance.GetGuidData(InstanceData.LeviathanMKII)); + if (mkii) + mkii.GetMotionMaster().MovePoint(Waypoints.MkiiP4Pos1, MimironConst.VehicleRelocation[Waypoints.MkiiP4Pos1]); + break; + case Actions.ActivateV0l7r0n2: + _events.ScheduleEvent(Events.Vol7ronActivation1, 1000); + break; + case Actions.ActivateHardMode: + _fireFighter = true; + DoZoneInCombat(me); + break; + default: + break; + } + } + + public override void EnterCombat(Unit who) + { + if (!me.GetVehicleBase()) + return; + + //PLay Sound number 15612 + + _EnterCombat(); + me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable); + me.RemoveAurasDueToSpell(Spells.Weld); + DoCast(me.GetVehicleBase(), Spells.Seat6); + + GameObject button = ObjectAccessor.GetGameObject(me, instance.GetGuidData(InstanceData.MimironButton)); + if (button) + button.SetFlag(GameObjectFields.Flags, GameObjectFlags.NotSelectable); + + if (_fireFighter) + _events.ScheduleEvent(Events.SummonFlames, 3000); + + _events.ScheduleEvent(Events.Intro1, 1500); + } + + public override void JustDied(Unit who) + { + instance.SetBossState(BossIds.Mimiron, EncounterState.Done); + _events.Reset(); + me.CombatStop(true); + me.SetDisableGravity(false); + DoCast(me, Spells.SleepVisual1); + DoCastAOE(Spells.DespawnAssaultBots); + me.ExitVehicle(); + // ExitVehicle() offset position is not implemented, so we make up for that with MoveJump()... + me.GetMotionMaster().MoveJump(me.GetPositionX() + (float)(10.0f * Math.Cos(me.GetOrientation())), me.GetPositionY() + (float)(10.0f * Math.Sin(me.GetOrientation())), me.GetPositionZ(), me.GetOrientation(), 10.0f, 5.0f); + _events.ScheduleEvent(Events.Outtro1, 7000); + } + + public override void JustRespawned() + { + //SetupEncounter(); + } + + public override void EnterEvadeMode(EvadeReason why = EvadeReason.Other) + { + _DespawnAtEvade(); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim() && instance.GetBossState(BossIds.Mimiron) != EncounterState.Done) + return; + + _events.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + _events.ExecuteEvents(eventId => + { + switch (eventId) { - case Actions.ActivateVx001: - _events.ScheduleEvent(Events.Vx001Activation1, 1000); + case Events.SummonFlames: + { + Unit worldtrigger = Global.ObjAccessor.GetUnit(me, instance.GetGuidData(InstanceData.MimironWorldTrigger)); + if (worldtrigger) + worldtrigger.CastCustomSpell(Spells.ScriptEffectSummonFlamesInitial, SpellValueMod.MaxTargets, 3, null, true, null, null, me.GetGUID()); + _events.RescheduleEvent(Events.SummonFlames, 28000); + } break; - case Actions.ActivateAerial: - _events.ScheduleEvent(Events.AerialActivation1, 5000); + case Events.Intro1: + Talk(_fireFighter ? Yells.HardmodeOn : Yells.MkiiActivate); + _events.ScheduleEvent(Events.Intro2, 5000); break; - case Actions.ActivateV0l7r0n1: - Talk(Yells.AerialDeath); - Creature mkii = ObjectAccessor.GetCreature(me, instance.GetGuidData(InstanceData.LeviathanMKII)); - if (mkii) - mkii.GetMotionMaster().MovePoint(Waypoints.MkiiP4Pos1, MimironConst.VehicleRelocation[Waypoints.MkiiP4Pos1]); + case Events.Intro2: + { + Unit mkii = me.GetVehicleBase(); + if (mkii) + { + DoCast(mkii, Spells.Seat7); + mkii.RemoveAurasDueToSpell(Spells.FreezeAnim); + mkii.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); + } + _events.ScheduleEvent(Events.Intro3, 2000); + } break; - case Actions.ActivateV0l7r0n2: - _events.ScheduleEvent(Events.Vol7ronActivation1, 1000); + case Events.Intro3: + { + Creature mkii = me.GetVehicleCreatureBase(); + if (mkii) + mkii.GetAI().DoAction(_fireFighter ? Actions.HardmodeMkii : Actions.StartMkii); + } break; - case Actions.ActivateHardMode: - _fireFighter = true; - DoZoneInCombat(me); + case Events.Vx001Activation1: + { + Unit mkii = me.GetVehicleBase(); + if (mkii) + DoCast(mkii, Spells.Seat6); + _events.ScheduleEvent(Events.Vx001Activation2, 1000); + } + break; + case Events.Vx001Activation2: + { + Talk(Yells.MkiiDeath); + _events.ScheduleEvent(Events.Vx001Activation3, 5000); + } + break; + case Events.Vx001Activation3: + { + GameObject elevator = ObjectAccessor.GetGameObject(me, instance.GetGuidData(InstanceData.MimironElevator)); + if (elevator) + elevator.SetGoState(GameObjectState.Ready); + Unit worldtrigger = Global.ObjAccessor.GetUnit(me, instance.GetGuidData(InstanceData.MimironWorldTrigger)); + if (worldtrigger) + worldtrigger.CastSpell(worldtrigger, Spells.ElevatorKnockback); + _events.ScheduleEvent(Events.Vx001Activation4, 6000); + } + break; + case Events.Vx001Activation4: + { + GameObject elevator = ObjectAccessor.GetGameObject(me, instance.GetGuidData(InstanceData.MimironElevator)); + if (elevator) + elevator.SetGoState(GameObjectState.ActiveAlternative); + Creature vx001 = me.SummonCreature(InstanceCreatureIds.Vx001, MimironConst.VX001SummonPos, TempSummonType.CorpseTimedDespawn, 120000); + if (vx001) + vx001.CastSpell(vx001, Spells.FreezeAnim); + _events.ScheduleEvent(Events.Vx001Activation5, 19000); + } + break; + case Events.Vx001Activation5: + { + Unit vx001 = Global.ObjAccessor.GetUnit(me, instance.GetGuidData(InstanceData.VX001)); + if (vx001) + DoCast(vx001, Spells.Seat1); + _events.ScheduleEvent(Events.Vx001Activation6, 3500); + } + break; + case Events.Vx001Activation6: + Talk(Yells.Vx001Activate); + _events.ScheduleEvent(Events.Vx001Activation7, 4000); + break; + case Events.Vx001Activation7: + { + Unit vx001 = me.GetVehicleBase(); + if (vx001) + DoCast(vx001, Spells.Seat2); + _events.ScheduleEvent(Events.Vx001Activation8, 3000); + } + break; + case Events.Vx001Activation8: + { + Creature vx001 = me.GetVehicleCreatureBase(); + if (vx001) + vx001.GetAI().DoAction(_fireFighter ? Actions.HardmodeVx001 : Actions.StartVx001); + } + break; + case Events.AerialActivation1: + { + Unit mkii = me.GetVehicleBase(); + if (mkii) + DoCast(mkii, Spells.Seat5); + _events.ScheduleEvent(Events.AerialActivation2, 2500); + } + break; + case Events.AerialActivation2: + Talk(Yells.Vx001Death); + _events.ScheduleEvent(Events.AerialActivation3, 5000); + break; + case Events.AerialActivation3: + me.SummonCreature(InstanceCreatureIds.AerialCommandUnit, MimironConst.ACUSummonPos, TempSummonType.ManualDespawn); + _events.ScheduleEvent(Events.AerialActivation4, 5000); + break; + case Events.AerialActivation4: + { + Unit aerial = Global.ObjAccessor.GetUnit(me, instance.GetGuidData(InstanceData.AerialCommandUnit)); + if (aerial) + me.CastSpell(aerial, Spells.Seat1); + _events.ScheduleEvent(Events.AerialActivation5, 2000); + } + break; + case Events.AerialActivation5: + Talk(Yells.AerialActivate); + _events.ScheduleEvent(Events.AerialActivation6, 8000); + break; + case Events.AerialActivation6: + Creature acu = me.GetVehicleCreatureBase(); + if (acu) + acu.GetAI().DoAction(_fireFighter ? Actions.HardmodeAerial : Actions.StartAerial); + break; + case Events.Vol7ronActivation1: + { + Creature mkii = ObjectAccessor.GetCreature(me, instance.GetGuidData(InstanceData.LeviathanMKII)); + if (mkii) + mkii.SetFacingTo((float)Math.PI); + _events.ScheduleEvent(Events.Vol7ronActivation2, 1000); + } + break; + case Events.Vol7ronActivation2: + { + Creature mkii = ObjectAccessor.GetCreature(me, instance.GetGuidData(InstanceData.LeviathanMKII)); + if (mkii) + { + Creature vx001 = ObjectAccessor.GetCreature(me, instance.GetGuidData(InstanceData.VX001)); + if (vx001) + { + vx001.RemoveAurasDueToSpell(Spells.TorsoDisabled); + vx001.CastSpell(mkii, Spells.MountMkii); + } + } + _events.ScheduleEvent(Events.Vol7ronActivation3, 4500); + } + break; + case Events.Vol7ronActivation3: + { + Creature mkii = ObjectAccessor.GetCreature(me, instance.GetGuidData(InstanceData.LeviathanMKII)); + if (mkii) + mkii.GetMotionMaster().MovePoint(Waypoints.MkiiP4Pos4, MimironConst.VehicleRelocation[Waypoints.MkiiP4Pos4]); + _events.ScheduleEvent(Events.Vol7ronActivation4, 5000); + } + break; + case Events.Vol7ronActivation4: + { + Creature vx001 = ObjectAccessor.GetCreature(me, instance.GetGuidData(InstanceData.VX001)); + if (vx001) + { + Creature aerial = ObjectAccessor.GetCreature(me, instance.GetGuidData(InstanceData.AerialCommandUnit)); + if (aerial) + { + aerial.GetMotionMaster().MoveLand(0, new Position(aerial.GetPositionX(), aerial.GetPositionY(), aerial.GetPositionZMinusOffset())); + aerial.SetByteValue(UnitFields.Bytes1, UnitBytes1Offsets.AnimTier, 0); + aerial.CastSpell(vx001, Spells.MountVx001); + aerial.CastSpell(aerial, Spells.HalfHeal); + } + } + _events.ScheduleEvent(Events.Vol7ronActivation5, 4000); + } + break; + case Events.Vol7ronActivation5: + Talk(Yells.V07tronActivate); + _events.ScheduleEvent(Events.Vol7ronActivation6, 3000); + break; + case Events.Vol7ronActivation6: + { + Creature vx001 = ObjectAccessor.GetCreature(me, instance.GetGuidData(InstanceData.VX001)); + if (vx001) + DoCast(vx001, Spells.Seat2); + _events.ScheduleEvent(Events.Vol7ronActivation7, 5000); + } + break; + case Events.Vol7ronActivation7: + for (uint data = InstanceData.LeviathanMKII; data <= InstanceData.AerialCommandUnit; ++data) + { + Creature mimironVehicle = ObjectAccessor.GetCreature(me, instance.GetGuidData(data)); + if (mimironVehicle) + mimironVehicle.GetAI().DoAction(Actions.AssembledCombat); + } + break; + case Events.Outtro1: + me.RemoveAurasDueToSpell(Spells.SleepVisual1); + DoCast(me, Spells.SleepVisual2); + me.SetFaction(35); + _events.ScheduleEvent(Events.Outtro2, 3000); + break; + case Events.Outtro2: + Talk(Yells.V07tronDeath); + if (_fireFighter) + { + Creature computer = ObjectAccessor.GetCreature(me, instance.GetGuidData(InstanceData.Computer)); + if (computer) + computer.GetAI().DoAction(Actions.DeactivateComputer); + me.SummonGameObject(RaidMode(InstanceGameObjectIds.CacheOfInnovationFirefighter, InstanceGameObjectIds.CacheOfInnovationFirefighterHero), 2744.040f, 2569.352f, 364.3135f, 3.124123f, new Quaternion(0.0f, 0.0f, 0.9999619f, 0.008734641f), 604800); + } + else + me.SummonGameObject(RaidMode(InstanceGameObjectIds.CacheOfInnovation, InstanceGameObjectIds.CacheOfInnovationHero), 2744.040f, 2569.352f, 364.3135f, 3.124123f, new Quaternion(0.0f, 0.0f, 0.9999619f, 0.008734641f), 604800); + _events.ScheduleEvent(Events.Outtro3, 11000); + break; + case Events.Outtro3: + DoCast(me, Spells.TeleportVisual); + me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable); + me.DespawnOrUnsummon(1000); // sniffs say 6 sec after, but it doesnt matter. break; default: break; } - } - - public override void EnterCombat(Unit who) - { - if (!me.GetVehicleBase()) - return; - - //PLay Sound number 15612 - - _EnterCombat(); - me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable); - me.RemoveAurasDueToSpell(Spells.Weld); - DoCast(me.GetVehicleBase(), Spells.Seat6); - - GameObject button = ObjectAccessor.GetGameObject(me, instance.GetGuidData(InstanceData.MimironButton)); - if (button) - button.SetFlag(GameObjectFields.Flags, GameObjectFlags.NotSelectable); - - if (_fireFighter) - _events.ScheduleEvent(Events.SummonFlames, 3000); - - _events.ScheduleEvent(Events.Intro1, 1500); - } - - public override void JustDied(Unit who) - { - instance.SetBossState(BossIds.Mimiron, EncounterState.Done); - _events.Reset(); - me.CombatStop(true); - me.SetDisableGravity(false); - DoCast(me, Spells.SleepVisual1); - DoCastAOE(Spells.DespawnAssaultBots); - me.ExitVehicle(); - // ExitVehicle() offset position is not implemented, so we make up for that with MoveJump()... - me.GetMotionMaster().MoveJump(me.GetPositionX() + (float)(10.0f * Math.Cos(me.GetOrientation())), me.GetPositionY() + (float)(10.0f * Math.Sin(me.GetOrientation())), me.GetPositionZ(), me.GetOrientation(), 10.0f, 5.0f); - _events.ScheduleEvent(Events.Outtro1, 7000); - } - - public override void JustRespawned() - { - //SetupEncounter(); - } - - public override void EnterEvadeMode(EvadeReason why = EvadeReason.Other) - { - _DespawnAtEvade(); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim() && instance.GetBossState(BossIds.Mimiron) != EncounterState.Done) - return; - - _events.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case Events.SummonFlames: - { - Unit worldtrigger = Global.ObjAccessor.GetUnit(me, instance.GetGuidData(InstanceData.MimironWorldTrigger)); - if (worldtrigger) - worldtrigger.CastCustomSpell(Spells.ScriptEffectSummonFlamesInitial, SpellValueMod.MaxTargets, 3, null, true, null, null, me.GetGUID()); - _events.RescheduleEvent(Events.SummonFlames, 28000); - } - break; - case Events.Intro1: - Talk(_fireFighter ? Yells.HardmodeOn : Yells.MkiiActivate); - _events.ScheduleEvent(Events.Intro2, 5000); - break; - case Events.Intro2: - { - Unit mkii = me.GetVehicleBase(); - if (mkii) - { - DoCast(mkii, Spells.Seat7); - mkii.RemoveAurasDueToSpell(Spells.FreezeAnim); - mkii.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); - } - _events.ScheduleEvent(Events.Intro3, 2000); - } - break; - case Events.Intro3: - { - Creature mkii = me.GetVehicleCreatureBase(); - if (mkii) - mkii.GetAI().DoAction(_fireFighter ? Actions.HardmodeMkii : Actions.StartMkii); - } - break; - case Events.Vx001Activation1: - { - Unit mkii = me.GetVehicleBase(); - if (mkii) - DoCast(mkii, Spells.Seat6); - _events.ScheduleEvent(Events.Vx001Activation2, 1000); - } - break; - case Events.Vx001Activation2: - { - Talk(Yells.MkiiDeath); - _events.ScheduleEvent(Events.Vx001Activation3, 5000); - } - break; - case Events.Vx001Activation3: - { - GameObject elevator = ObjectAccessor.GetGameObject(me, instance.GetGuidData(InstanceData.MimironElevator)); - if (elevator) - elevator.SetGoState(GameObjectState.Ready); - Unit worldtrigger = Global.ObjAccessor.GetUnit(me, instance.GetGuidData(InstanceData.MimironWorldTrigger)); - if (worldtrigger) - worldtrigger.CastSpell(worldtrigger, Spells.ElevatorKnockback); - _events.ScheduleEvent(Events.Vx001Activation4, 6000); - } - break; - case Events.Vx001Activation4: - { - GameObject elevator = ObjectAccessor.GetGameObject(me, instance.GetGuidData(InstanceData.MimironElevator)); - if (elevator) - elevator.SetGoState(GameObjectState.ActiveAlternative); - Creature vx001 = me.SummonCreature(InstanceCreatureIds.Vx001, MimironConst.VX001SummonPos, TempSummonType.CorpseTimedDespawn, 120000); - if (vx001) - vx001.CastSpell(vx001, Spells.FreezeAnim); - _events.ScheduleEvent(Events.Vx001Activation5, 19000); - } - break; - case Events.Vx001Activation5: - { - Unit vx001 = Global.ObjAccessor.GetUnit(me, instance.GetGuidData(InstanceData.VX001)); - if (vx001) - DoCast(vx001, Spells.Seat1); - _events.ScheduleEvent(Events.Vx001Activation6, 3500); - } - break; - case Events.Vx001Activation6: - Talk(Yells.Vx001Activate); - _events.ScheduleEvent(Events.Vx001Activation7, 4000); - break; - case Events.Vx001Activation7: - { - Unit vx001 = me.GetVehicleBase(); - if (vx001) - DoCast(vx001, Spells.Seat2); - _events.ScheduleEvent(Events.Vx001Activation8, 3000); - } - break; - case Events.Vx001Activation8: - { - Creature vx001 = me.GetVehicleCreatureBase(); - if (vx001) - vx001.GetAI().DoAction(_fireFighter ? Actions.HardmodeVx001 : Actions.StartVx001); - } - break; - case Events.AerialActivation1: - { - Unit mkii = me.GetVehicleBase(); - if (mkii) - DoCast(mkii, Spells.Seat5); - _events.ScheduleEvent(Events.AerialActivation2, 2500); - } - break; - case Events.AerialActivation2: - Talk(Yells.Vx001Death); - _events.ScheduleEvent(Events.AerialActivation3, 5000); - break; - case Events.AerialActivation3: - me.SummonCreature(InstanceCreatureIds.AerialCommandUnit, MimironConst.ACUSummonPos, TempSummonType.ManualDespawn); - _events.ScheduleEvent(Events.AerialActivation4, 5000); - break; - case Events.AerialActivation4: - { - Unit aerial = Global.ObjAccessor.GetUnit(me, instance.GetGuidData(InstanceData.AerialCommandUnit)); - if (aerial) - me.CastSpell(aerial, Spells.Seat1); - _events.ScheduleEvent(Events.AerialActivation5, 2000); - } - break; - case Events.AerialActivation5: - Talk(Yells.AerialActivate); - _events.ScheduleEvent(Events.AerialActivation6, 8000); - break; - case Events.AerialActivation6: - Creature acu = me.GetVehicleCreatureBase(); - if (acu) - acu.GetAI().DoAction(_fireFighter ? Actions.HardmodeAerial : Actions.StartAerial); - break; - case Events.Vol7ronActivation1: - { - Creature mkii = ObjectAccessor.GetCreature(me, instance.GetGuidData(InstanceData.LeviathanMKII)); - if (mkii) - mkii.SetFacingTo((float)Math.PI); - _events.ScheduleEvent(Events.Vol7ronActivation2, 1000); - } - break; - case Events.Vol7ronActivation2: - { - Creature mkii = ObjectAccessor.GetCreature(me, instance.GetGuidData(InstanceData.LeviathanMKII)); - if (mkii) - { - Creature vx001 = ObjectAccessor.GetCreature(me, instance.GetGuidData(InstanceData.VX001)); - if (vx001) - { - vx001.RemoveAurasDueToSpell(Spells.TorsoDisabled); - vx001.CastSpell(mkii, Spells.MountMkii); - } - } - _events.ScheduleEvent(Events.Vol7ronActivation3, 4500); - } - break; - case Events.Vol7ronActivation3: - { - Creature mkii = ObjectAccessor.GetCreature(me, instance.GetGuidData(InstanceData.LeviathanMKII)); - if (mkii) - mkii.GetMotionMaster().MovePoint(Waypoints.MkiiP4Pos4, MimironConst.VehicleRelocation[Waypoints.MkiiP4Pos4]); - _events.ScheduleEvent(Events.Vol7ronActivation4, 5000); - } - break; - case Events.Vol7ronActivation4: - { - Creature vx001 = ObjectAccessor.GetCreature(me, instance.GetGuidData(InstanceData.VX001)); - if (vx001) - { - Creature aerial = ObjectAccessor.GetCreature(me, instance.GetGuidData(InstanceData.AerialCommandUnit)); - if (aerial) - { - aerial.GetMotionMaster().MoveLand(0, new Position(aerial.GetPositionX(), aerial.GetPositionY(), aerial.GetPositionZMinusOffset())); - aerial.SetByteValue(UnitFields.Bytes1, UnitBytes1Offsets.AnimTier, 0); - aerial.CastSpell(vx001, Spells.MountVx001); - aerial.CastSpell(aerial, Spells.HalfHeal); - } - } - _events.ScheduleEvent(Events.Vol7ronActivation5, 4000); - } - break; - case Events.Vol7ronActivation5: - Talk(Yells.V07tronActivate); - _events.ScheduleEvent(Events.Vol7ronActivation6, 3000); - break; - case Events.Vol7ronActivation6: - { - Creature vx001 = ObjectAccessor.GetCreature(me, instance.GetGuidData(InstanceData.VX001)); - if (vx001) - DoCast(vx001, Spells.Seat2); - _events.ScheduleEvent(Events.Vol7ronActivation7, 5000); - } - break; - case Events.Vol7ronActivation7: - for (uint data = InstanceData.LeviathanMKII; data <= InstanceData.AerialCommandUnit; ++data) - { - Creature mimironVehicle = ObjectAccessor.GetCreature(me, instance.GetGuidData(data)); - if (mimironVehicle) - mimironVehicle.GetAI().DoAction(Actions.AssembledCombat); - } - break; - case Events.Outtro1: - me.RemoveAurasDueToSpell(Spells.SleepVisual1); - DoCast(me, Spells.SleepVisual2); - me.SetFaction(35); - _events.ScheduleEvent(Events.Outtro2, 3000); - break; - case Events.Outtro2: - Talk(Yells.V07tronDeath); - if (_fireFighter) - { - Creature computer = ObjectAccessor.GetCreature(me, instance.GetGuidData(InstanceData.Computer)); - if (computer) - computer.GetAI().DoAction(Actions.DeactivateComputer); - me.SummonGameObject(RaidMode(InstanceGameObjectIds.CacheOfInnovationFirefighter, InstanceGameObjectIds.CacheOfInnovationFirefighterHero), 2744.040f, 2569.352f, 364.3135f, 3.124123f, new Quaternion(0.0f, 0.0f, 0.9999619f, 0.008734641f), 604800); - } - else - me.SummonGameObject(RaidMode(InstanceGameObjectIds.CacheOfInnovation, InstanceGameObjectIds.CacheOfInnovationHero), 2744.040f, 2569.352f, 364.3135f, 3.124123f, new Quaternion(0.0f, 0.0f, 0.9999619f, 0.008734641f), 604800); - _events.ScheduleEvent(Events.Outtro3, 11000); - break; - case Events.Outtro3: - DoCast(me, Spells.TeleportVisual); - me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable); - me.DespawnOrUnsummon(1000); // sniffs say 6 sec after, but it doesnt matter. - break; - default: - break; - } - }); - } - - bool _fireFighter; + }); } - public override CreatureAI GetAI(Creature creature) - { - return instance_ulduar.GetUlduarInstanceAI(creature); - } + bool _fireFighter; } [Script] - class boss_leviathan_mk_ii : CreatureScript + class boss_leviathan_mk_ii : BossAI { - public boss_leviathan_mk_ii() : base("boss_leviathan_mk_ii") { } - - class boss_leviathan_mk_iiAI : BossAI + public boss_leviathan_mk_ii(Creature creature) : base(creature, BossIds.Mimiron) { - public boss_leviathan_mk_iiAI(Creature creature) : base(creature, BossIds.Mimiron) - { - _fireFighter = false; - _setupMine = true; - _setupBomb = true; - _setupRocket = true; - } + _fireFighter = false; + _setupMine = true; + _setupBomb = true; + _setupRocket = true; + } - public override void InitializeAI() - { - SetupEncounter(); - } + public override void InitializeAI() + { + SetupEncounter(); + } - void SetupEncounter() + void SetupEncounter() + { + _Reset(); + me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); + me.SetReactState(ReactStates.Passive); + _fireFighter = false; + _setupMine = true; + _setupBomb = true; + _setupRocket = true; + DoCast(me, Spells.FreezeAnim); + } + + public override void DamageTaken(Unit who, ref uint damage) + { + if (damage >= me.GetHealth()) { - _Reset(); - me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); + damage = (uint)(me.GetHealth() - 1); // Let creature fall to 1 hp, but do not let it die or damage itself with SetHealth(). + me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable); + DoCast(me, Spells.VehicleDamaged, true); + me.AttackStop(); me.SetReactState(ReactStates.Passive); - _fireFighter = false; - _setupMine = true; - _setupBomb = true; - _setupRocket = true; - DoCast(me, Spells.FreezeAnim); - } + me.RemoveAllAurasExceptType(AuraType.ControlVehicle, AuraType.ModIncreaseHealthPercent); - public override void DamageTaken(Unit who, ref uint damage) - { - if (damage >= me.GetHealth()) + if (_events.IsInPhase(Phases.LeviathanMkII)) { - damage = (uint)(me.GetHealth() - 1); // Let creature fall to 1 hp, but do not let it die or damage itself with SetHealth(). - me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable); - DoCast(me, Spells.VehicleDamaged, true); - me.AttackStop(); - me.SetReactState(ReactStates.Passive); - me.RemoveAllAurasExceptType(AuraType.ControlVehicle, AuraType.ModIncreaseHealthPercent); + me.CastStop(); + Unit turret = me.GetVehicleKit().GetPassenger(3); + if (turret) + turret.KillSelf(); - if (_events.IsInPhase(Phases.LeviathanMkII)) - { - me.CastStop(); - Unit turret = me.GetVehicleKit().GetPassenger(3); - if (turret) - turret.KillSelf(); - - me.SetSpeedRate(UnitMoveType.Run, 1.5f); - me.GetMotionMaster().MovePoint(Waypoints.MkiiP1Idle, MimironConst.VehicleRelocation[Waypoints.MkiiP1Idle]); - } - else if (_events.IsInPhase(Phases.Vol7ron)) - { - me.SetStandState(UnitStandStateType.Dead); - - if (MimironConst.IsEncounterFinished(who)) - return; - - me.CastStop(); - DoCast(me, Spells.SelfRepair); - } - _events.Reset(); + me.SetSpeedRate(UnitMoveType.Run, 1.5f); + me.GetMotionMaster().MovePoint(Waypoints.MkiiP1Idle, MimironConst.VehicleRelocation[Waypoints.MkiiP1Idle]); } - } - - public override void DoAction(int action) - { - switch (action) + else if (_events.IsInPhase(Phases.Vol7ron)) { - case Actions.HardmodeMkii: - _fireFighter = true; - DoCast(me, Spells.EmergencyMode); - DoCastAOE(Spells.EmergencyModeTurret); - _events.ScheduleEvent(Events.FlameSuppressantVx, 60000, 0, Phases.LeviathanMkII); - goto case Actions.StartMkii; - case Actions.StartMkii: - me.SetReactState(ReactStates.Aggressive); - _events.SetPhase(Phases.LeviathanMkII); + me.SetStandState(UnitStandStateType.Dead); - _events.ScheduleEvent(Events.NapalmShell, 3000, 0, Phases.LeviathanMkII); - _events.ScheduleEvent(Events.PlasmaBlast, 15000, 0, Phases.LeviathanMkII); - _events.ScheduleEvent(Events.ProximityMine, 5000); - _events.ScheduleEvent(Events.ShockBlast, 18000); - break; - case Actions.AssembledCombat: - me.SetStandState(UnitStandStateType.Stand); - me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); - me.SetReactState(ReactStates.Aggressive); + if (MimironConst.IsEncounterFinished(who)) + return; - _events.SetPhase(Phases.Vol7ron); - _events.ScheduleEvent(Events.ProximityMine, 15000); - _events.ScheduleEvent(Events.ShockBlast, 45000); - break; - default: - break; + me.CastStop(); + DoCast(me, Spells.SelfRepair); } + _events.Reset(); } - - public override uint GetData(uint type) - { - switch (type) - { - case Data.SetupMine: - return _setupMine ? 1 : 0u; - case Data.SetupBomb: - return _setupBomb ? 1 : 0u; - case Data.SetupRocket: - return _setupRocket ? 1 : 0u; - case Data.Firefighter: - return _fireFighter ? 1 : 0u; - default: - return 0; - } - } - - public override void JustSummoned(Creature summon) - { - summons.Summon(summon); - } - - public override void KilledUnit(Unit victim) - { - if (victim.IsTypeId(TypeId.Player)) - { - Creature mimiron = ObjectAccessor.GetCreature(me, instance.GetGuidData(BossIds.Mimiron)); - if (mimiron) - mimiron.GetAI().Talk(_events.IsInPhase(Phases.LeviathanMkII) ? Yells.MkiiSlay : Yells.V07tronSlay); - } - } - - public override void MovementInform(MovementGeneratorType type, uint point) - { - if (type != MovementGeneratorType.Point) - return; - - switch (point) - { - case Waypoints.MkiiP1Idle: - { - me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable); - DoCast(me, Spells.HalfHeal); - - Creature mimiron = ObjectAccessor.GetCreature(me, instance.GetGuidData(BossIds.Mimiron)); - if (mimiron) - mimiron.GetAI().DoAction(Actions.ActivateVx001); - } - break; - case Waypoints.MkiiP4Pos1: - _events.ScheduleEvent(Events.MovePoint2, 1); - break; - case Waypoints.MkiiP4Pos2: - _events.ScheduleEvent(Events.MovePoint3, 1); - break; - case Waypoints.MkiiP4Pos3: - { - Creature mimiron = ObjectAccessor.GetCreature(me, instance.GetGuidData(BossIds.Mimiron)); - if (mimiron) - mimiron.GetAI().DoAction(Actions.ActivateV0l7r0n2); - } - break; - case Waypoints.MkiiP4Pos4: - _events.ScheduleEvent(Events.MovePoint5, 1); - break; - default: - break; - } - } - - public override void SetData(uint id, uint data) - { - switch (id) - { - case Data.SetupMine: - _setupMine = data != 0; - break; - case Data.SetupBomb: - _setupBomb = data != 0; - break; - case Data.SetupRocket: - _setupRocket = data != 0; - break; - default: - break; - } - } - - public override void JustRespawned() - { - SetupEncounter(); - } - - public override void EnterEvadeMode(EvadeReason why = EvadeReason.Other) - { - _DespawnAtEvade(); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _events.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case Events.ProximityMine: - DoCastAOE(Spells.ProximityMines); - _events.RescheduleEvent(Events.ProximityMine, 35000); - break; - case Events.PlasmaBlast: - DoCastVictim(Spells.ScriptEffectPlasmaBlast); - _events.RescheduleEvent(Events.PlasmaBlast, RandomHelper.URand(30000, 45000), 0, Phases.LeviathanMkII); - - if (_events.GetTimeUntilEvent(Events.NapalmShell) < 9000) - _events.RescheduleEvent(Events.NapalmShell, 9000, 0, Phases.LeviathanMkII); // The actual spell is cast by the turret, we should not let it interrupt itself. - break; - case Events.ShockBlast: - DoCastAOE(Spells.ShockBlast); - _events.RescheduleEvent(Events.ShockBlast, RandomHelper.URand(34000, 36000)); - break; - case Events.FlameSuppressantMk: - DoCastAOE(Spells.FlameSuppressantMk); - _events.RescheduleEvent(Events.FlameSuppressantMk, 60000, 0, Phases.LeviathanMkII); - break; - case Events.NapalmShell: - DoCastAOE(Spells.ForceCastNapalmShell); - _events.RescheduleEvent(Events.NapalmShell, RandomHelper.URand(6000, 15000), 0, Phases.LeviathanMkII); - - if (_events.GetTimeUntilEvent(Events.PlasmaBlast) < 2000) - _events.RescheduleEvent(Events.PlasmaBlast, 2000, 0, Phases.LeviathanMkII); // The actual spell is cast by the turret, we should not let it interrupt itself. - break; - case Events.MovePoint2: - me.GetMotionMaster().MovePoint(Waypoints.MkiiP4Pos2, MimironConst.VehicleRelocation[Waypoints.MkiiP4Pos2]); - break; - case Events.MovePoint3: - me.GetMotionMaster().MovePoint(Waypoints.MkiiP4Pos3, MimironConst.VehicleRelocation[Waypoints.MkiiP4Pos3]); - break; - case Events.MovePoint5: - me.GetMotionMaster().MovePoint(Waypoints.MkiiP4Pos5, MimironConst.VehicleRelocation[Waypoints.MkiiP4Pos5]); - break; - default: - break; - } - }); - DoMeleeAttackIfReady(); - } - - bool _fireFighter; - bool _setupMine; - bool _setupBomb; - bool _setupRocket; } - public override CreatureAI GetAI(Creature creature) + public override void DoAction(int action) { - return instance_ulduar.GetUlduarInstanceAI(creature); + switch (action) + { + case Actions.HardmodeMkii: + _fireFighter = true; + DoCast(me, Spells.EmergencyMode); + DoCastAOE(Spells.EmergencyModeTurret); + _events.ScheduleEvent(Events.FlameSuppressantVx, 60000, 0, Phases.LeviathanMkII); + goto case Actions.StartMkii; + case Actions.StartMkii: + me.SetReactState(ReactStates.Aggressive); + _events.SetPhase(Phases.LeviathanMkII); + + _events.ScheduleEvent(Events.NapalmShell, 3000, 0, Phases.LeviathanMkII); + _events.ScheduleEvent(Events.PlasmaBlast, 15000, 0, Phases.LeviathanMkII); + _events.ScheduleEvent(Events.ProximityMine, 5000); + _events.ScheduleEvent(Events.ShockBlast, 18000); + break; + case Actions.AssembledCombat: + me.SetStandState(UnitStandStateType.Stand); + me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); + me.SetReactState(ReactStates.Aggressive); + + _events.SetPhase(Phases.Vol7ron); + _events.ScheduleEvent(Events.ProximityMine, 15000); + _events.ScheduleEvent(Events.ShockBlast, 45000); + break; + default: + break; + } } + + public override uint GetData(uint type) + { + switch (type) + { + case Data.SetupMine: + return _setupMine ? 1 : 0u; + case Data.SetupBomb: + return _setupBomb ? 1 : 0u; + case Data.SetupRocket: + return _setupRocket ? 1 : 0u; + case Data.Firefighter: + return _fireFighter ? 1 : 0u; + default: + return 0; + } + } + + public override void JustSummoned(Creature summon) + { + summons.Summon(summon); + } + + public override void KilledUnit(Unit victim) + { + if (victim.IsTypeId(TypeId.Player)) + { + Creature mimiron = ObjectAccessor.GetCreature(me, instance.GetGuidData(BossIds.Mimiron)); + if (mimiron) + mimiron.GetAI().Talk(_events.IsInPhase(Phases.LeviathanMkII) ? Yells.MkiiSlay : Yells.V07tronSlay); + } + } + + public override void MovementInform(MovementGeneratorType type, uint point) + { + if (type != MovementGeneratorType.Point) + return; + + switch (point) + { + case Waypoints.MkiiP1Idle: + { + me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable); + DoCast(me, Spells.HalfHeal); + + Creature mimiron = ObjectAccessor.GetCreature(me, instance.GetGuidData(BossIds.Mimiron)); + if (mimiron) + mimiron.GetAI().DoAction(Actions.ActivateVx001); + } + break; + case Waypoints.MkiiP4Pos1: + _events.ScheduleEvent(Events.MovePoint2, 1); + break; + case Waypoints.MkiiP4Pos2: + _events.ScheduleEvent(Events.MovePoint3, 1); + break; + case Waypoints.MkiiP4Pos3: + { + Creature mimiron = ObjectAccessor.GetCreature(me, instance.GetGuidData(BossIds.Mimiron)); + if (mimiron) + mimiron.GetAI().DoAction(Actions.ActivateV0l7r0n2); + } + break; + case Waypoints.MkiiP4Pos4: + _events.ScheduleEvent(Events.MovePoint5, 1); + break; + default: + break; + } + } + + public override void SetData(uint id, uint data) + { + switch (id) + { + case Data.SetupMine: + _setupMine = data != 0; + break; + case Data.SetupBomb: + _setupBomb = data != 0; + break; + case Data.SetupRocket: + _setupRocket = data != 0; + break; + default: + break; + } + } + + public override void JustRespawned() + { + SetupEncounter(); + } + + public override void EnterEvadeMode(EvadeReason why = EvadeReason.Other) + { + _DespawnAtEvade(); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _events.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + _events.ExecuteEvents(eventId => + { + switch (eventId) + { + case Events.ProximityMine: + DoCastAOE(Spells.ProximityMines); + _events.RescheduleEvent(Events.ProximityMine, 35000); + break; + case Events.PlasmaBlast: + DoCastVictim(Spells.ScriptEffectPlasmaBlast); + _events.RescheduleEvent(Events.PlasmaBlast, RandomHelper.URand(30000, 45000), 0, Phases.LeviathanMkII); + + if (_events.GetTimeUntilEvent(Events.NapalmShell) < 9000) + _events.RescheduleEvent(Events.NapalmShell, 9000, 0, Phases.LeviathanMkII); // The actual spell is cast by the turret, we should not let it interrupt itself. + break; + case Events.ShockBlast: + DoCastAOE(Spells.ShockBlast); + _events.RescheduleEvent(Events.ShockBlast, RandomHelper.URand(34000, 36000)); + break; + case Events.FlameSuppressantMk: + DoCastAOE(Spells.FlameSuppressantMk); + _events.RescheduleEvent(Events.FlameSuppressantMk, 60000, 0, Phases.LeviathanMkII); + break; + case Events.NapalmShell: + DoCastAOE(Spells.ForceCastNapalmShell); + _events.RescheduleEvent(Events.NapalmShell, RandomHelper.URand(6000, 15000), 0, Phases.LeviathanMkII); + + if (_events.GetTimeUntilEvent(Events.PlasmaBlast) < 2000) + _events.RescheduleEvent(Events.PlasmaBlast, 2000, 0, Phases.LeviathanMkII); // The actual spell is cast by the turret, we should not let it interrupt itself. + break; + case Events.MovePoint2: + me.GetMotionMaster().MovePoint(Waypoints.MkiiP4Pos2, MimironConst.VehicleRelocation[Waypoints.MkiiP4Pos2]); + break; + case Events.MovePoint3: + me.GetMotionMaster().MovePoint(Waypoints.MkiiP4Pos3, MimironConst.VehicleRelocation[Waypoints.MkiiP4Pos3]); + break; + case Events.MovePoint5: + me.GetMotionMaster().MovePoint(Waypoints.MkiiP4Pos5, MimironConst.VehicleRelocation[Waypoints.MkiiP4Pos5]); + break; + default: + break; + } + }); + DoMeleeAttackIfReady(); + } + + bool _fireFighter; + bool _setupMine; + bool _setupBomb; + bool _setupRocket; } [Script] //todo check for both rockets - class boss_vx_001 : CreatureScript + class boss_vx_001 : BossAI { - public boss_vx_001() : base("boss_vx_001") { } - - class boss_vx_001AI : BossAI + public boss_vx_001(Creature creature) : base(creature, BossIds.Mimiron) { - public boss_vx_001AI(Creature creature) : base(creature, BossIds.Mimiron) - { - me.SetDisableGravity(true); // This is the unfold visual state of VX-001, it has to be set on create as it requires an objectupdate if set later. - me.SetUInt32Value(UnitFields.NpcEmotestate, (uint)Emote.StateSpecialUnarmed); // This is a hack to force the yet to be unfolded visual state. - me.SetReactState(ReactStates.Passive); - _fireFighter = false; - } + me.SetDisableGravity(true); // This is the unfold visual state of VX-001, it has to be set on create as it requires an objectupdate if set later. + me.SetUInt32Value(UnitFields.NpcEmotestate, (uint)Emote.StateSpecialUnarmed); // This is a hack to force the yet to be unfolded visual state. + me.SetReactState(ReactStates.Passive); + _fireFighter = false; + } - public override void DamageTaken(Unit who, ref uint damage) + public override void DamageTaken(Unit who, ref uint damage) + { + if (damage >= me.GetHealth()) { - if (damage >= me.GetHealth()) + //play sound 15615 + damage = (uint)(me.GetHealth() - 1); // Let creature fall to 1 hp, but do not let it die or damage itself with SetHealth(). + me.AttackStop(); + DoCast(me, Spells.VehicleDamaged, true); + me.RemoveAllAurasExceptType(AuraType.ControlVehicle, AuraType.ModIncreaseHealthPercent); + + if (_events.IsInPhase(Phases.Vx001)) { - //play sound 15615 - damage = (uint)(me.GetHealth() - 1); // Let creature fall to 1 hp, but do not let it die or damage itself with SetHealth(). - me.AttackStop(); - DoCast(me, Spells.VehicleDamaged, true); - me.RemoveAllAurasExceptType(AuraType.ControlVehicle, AuraType.ModIncreaseHealthPercent); - - if (_events.IsInPhase(Phases.Vx001)) - { - me.CastStop(); - me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); - DoCast(me, Spells.HalfHeal); // has no effect, wat - DoCast(me, Spells.TorsoDisabled); - Creature mimiron = ObjectAccessor.GetCreature(me, instance.GetGuidData(BossIds.Mimiron)); - if (mimiron) - mimiron.GetAI().DoAction(Actions.ActivateAerial); - } - else if (_events.IsInPhase(Phases.Vol7ron)) - { - me.SetStandState(UnitStandStateType.Dead); - me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable); - - if (MimironConst.IsEncounterFinished(who)) - return; - - me.CastStop(); - DoCast(me, Spells.SelfRepair); - } - _events.Reset(); + me.CastStop(); + me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); + DoCast(me, Spells.HalfHeal); // has no effect, wat + DoCast(me, Spells.TorsoDisabled); + Creature mimiron = ObjectAccessor.GetCreature(me, instance.GetGuidData(BossIds.Mimiron)); + if (mimiron) + mimiron.GetAI().DoAction(Actions.ActivateAerial); } + else if (_events.IsInPhase(Phases.Vol7ron)) + { + me.SetStandState(UnitStandStateType.Dead); + me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable); + + if (MimironConst.IsEncounterFinished(who)) + return; + + me.CastStop(); + DoCast(me, Spells.SelfRepair); + } + _events.Reset(); + } + } + + public override void DoAction(int action) + { + switch (action) + { + case Actions.HardmodeVx001: + _fireFighter = true; + DoCast(me, Spells.EmergencyMode); + _events.ScheduleEvent(Events.FrostBomb, 1000); + _events.ScheduleEvent(Events.FlameSuppressantVx, 6000); + goto case Actions.StartVx001; + case Actions.StartVx001: + me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); + me.RemoveAurasDueToSpell(Spells.FreezeAnim); + me.SetUInt32Value(UnitFields.NpcEmotestate, (uint)Emote.OneshotNone); // Remove emotestate. + //me.SetuintValue(UnitFields.Bytes1, UnitBytes1Offsets.AnimTier, UnitBytes1Flags.AlwaysStand | UnitBytes1Flags.Hover); Blizzard handles hover animation like this it seems. + DoCast(me, Spells.HeatWaveAura); + + _events.SetPhase(Phases.Vx001); + _events.ScheduleEvent(Events.RocketStrike, 20000); + _events.ScheduleEvent(Events.SpinningUp, RandomHelper.URand(30000, 35000)); + _events.ScheduleEvent(Events.RapidBurst, 500, 0, Phases.Vx001); + break; + case Actions.AssembledCombat: + me.SetStandState(UnitStandStateType.Stand); + me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); + + _events.SetPhase(Phases.Vol7ron); + _events.ScheduleEvent(Events.RocketStrike, 20000); + _events.ScheduleEvent(Events.SpinningUp, RandomHelper.URand(30000, 35000)); + _events.ScheduleEvent(Events.HandPulse, 500, 0, Phases.Vol7ron); + if (_fireFighter) + _events.ScheduleEvent(Events.FrostBomb, 1000); + break; + default: + break; + } + } + + public override void EnterEvadeMode(EvadeReason why) + { + summons.DespawnAll(); + } + + public override void JustSummoned(Creature summon) + { + summons.Summon(summon); + if (summon.GetEntry() == InstanceCreatureIds.BurstTarget) + summon.CastSpell(me, Spells.RapidBurstTargetMe); + } + + public override void KilledUnit(Unit victim) + { + if (victim.IsTypeId(TypeId.Player)) + { + Creature mimiron = ObjectAccessor.GetCreature(me, instance.GetGuidData(BossIds.Mimiron)); + if (mimiron) + mimiron.GetAI().Talk(_events.IsInPhase(Phases.Vx001) ? Yells.Vx001Slay : Yells.V07tronSlay); + } + } + + public override void SpellHit(Unit caster, SpellInfo spellProto) + { + if (caster.GetEntry() == InstanceCreatureIds.BurstTarget && !me.HasUnitState(UnitState.Casting)) + DoCast(caster, Spells.RapidBurst); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _events.Update(diff); + + // Handle rotation during SPELL_SPINNING_UP, SPELL_P3WX2_LASER_BARRAGE, SPELL_RAPID_BURST, and SPELL_HAND_PULSE_LEFT/RIGHT + if (me.HasUnitState(UnitState.Casting)) + { + List channelObjects = me.GetChannelObjects(); + Unit channelTarget = (channelObjects.Count == 1 ? Global.ObjAccessor.GetUnit(me, channelObjects[0]) : null); + if (channelTarget) + me.SetFacingToObject(channelTarget); + return; } - public override void DoAction(int action) + _events.ExecuteEvents(eventId => { - switch (action) + switch (eventId) { - case Actions.HardmodeVx001: - _fireFighter = true; - DoCast(me, Spells.EmergencyMode); - _events.ScheduleEvent(Events.FrostBomb, 1000); - _events.ScheduleEvent(Events.FlameSuppressantVx, 6000); - goto case Actions.StartVx001; - case Actions.StartVx001: - me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); - me.RemoveAurasDueToSpell(Spells.FreezeAnim); - me.SetUInt32Value(UnitFields.NpcEmotestate, (uint)Emote.OneshotNone); // Remove emotestate. - //me.SetuintValue(UnitFields.Bytes1, UnitBytes1Offsets.AnimTier, UnitBytes1Flags.AlwaysStand | UnitBytes1Flags.Hover); Blizzard handles hover animation like this it seems. - DoCast(me, Spells.HeatWaveAura); - - _events.SetPhase(Phases.Vx001); - _events.ScheduleEvent(Events.RocketStrike, 20000); - _events.ScheduleEvent(Events.SpinningUp, RandomHelper.URand(30000, 35000)); - _events.ScheduleEvent(Events.RapidBurst, 500, 0, Phases.Vx001); + case Events.RapidBurst: + { + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 120, true); + if (target) + DoCast(target, Spells.SummonBurstTarget); + _events.RescheduleEvent(Events.RapidBurst, 3000, 0, Phases.Vx001); + } break; - case Actions.AssembledCombat: - me.SetStandState(UnitStandStateType.Stand); - me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); - - _events.SetPhase(Phases.Vol7ron); - _events.ScheduleEvent(Events.RocketStrike, 20000); - _events.ScheduleEvent(Events.SpinningUp, RandomHelper.URand(30000, 35000)); - _events.ScheduleEvent(Events.HandPulse, 500, 0, Phases.Vol7ron); - if (_fireFighter) - _events.ScheduleEvent(Events.FrostBomb, 1000); + case Events.RocketStrike: + DoCastAOE(_events.IsInPhase(Phases.Vx001) ? Spells.RocketStrikeSingle : Spells.RocketStrikeBoth); + _events.ScheduleEvent(Events.Reload, 10000); + _events.RescheduleEvent(Events.RocketStrike, RandomHelper.URand(20000, 25000)); + break; + case Events.Reload: + for (sbyte seat = (sbyte)SeatIds.RocketLeft; seat <= SeatIds.RocketRight; ++seat) + { + Unit rocket = me.GetVehicleKit().GetPassenger(seat); + if (rocket) + rocket.SetDisplayId(rocket.GetNativeDisplayId()); + } + break; + case Events.HandPulse: + { + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 120, true); + if (target) + DoCast(target, RandomHelper.RAND(Spells.HandPulseLeft, Spells.HandPulseRight)); + _events.RescheduleEvent(Events.HandPulse, RandomHelper.URand(1500, 3000), 0, Phases.Vol7ron); + } + break; + case Events.FrostBomb: + DoCastAOE(Spells.ScriptEffectFrostBomb); + _events.RescheduleEvent(Events.FrostBomb, 45000); + break; + case Events.SpinningUp: + DoCastAOE(Spells.SpinningUp); + _events.DelayEvents(14000); + _events.RescheduleEvent(Events.SpinningUp, RandomHelper.URand(55000, 65000)); + break; + case Events.FlameSuppressantVx: + DoCastAOE(Spells.FlameSuppressantVx); + _events.RescheduleEvent(Events.FlameSuppressantVx, RandomHelper.URand(10000, 12000), 0, Phases.Vx001); break; default: break; } - } - - public override void EnterEvadeMode(EvadeReason why) - { - summons.DespawnAll(); - } - - public override void JustSummoned(Creature summon) - { - summons.Summon(summon); - if (summon.GetEntry() == InstanceCreatureIds.BurstTarget) - summon.CastSpell(me, Spells.RapidBurstTargetMe); - } - - public override void KilledUnit(Unit victim) - { - if (victim.IsTypeId(TypeId.Player)) - { - Creature mimiron = ObjectAccessor.GetCreature(me, instance.GetGuidData(BossIds.Mimiron)); - if (mimiron) - mimiron.GetAI().Talk(_events.IsInPhase(Phases.Vx001) ? Yells.Vx001Slay : Yells.V07tronSlay); - } - } - - public override void SpellHit(Unit caster, SpellInfo spellProto) - { - if (caster.GetEntry() == InstanceCreatureIds.BurstTarget && !me.HasUnitState(UnitState.Casting)) - DoCast(caster, Spells.RapidBurst); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _events.Update(diff); - - // Handle rotation during SPELL_SPINNING_UP, SPELL_P3WX2_LASER_BARRAGE, SPELL_RAPID_BURST, and SPELL_HAND_PULSE_LEFT/RIGHT - if (me.HasUnitState(UnitState.Casting)) - { - List channelObjects = me.GetChannelObjects(); - Unit channelTarget = (channelObjects.Count == 1 ? Global.ObjAccessor.GetUnit(me, channelObjects[0]) : null); - if (channelTarget) - me.SetFacingToObject(channelTarget); - return; - } - - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case Events.RapidBurst: - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 120, true); - if (target) - DoCast(target, Spells.SummonBurstTarget); - _events.RescheduleEvent(Events.RapidBurst, 3000, 0, Phases.Vx001); - } - break; - case Events.RocketStrike: - DoCastAOE(_events.IsInPhase(Phases.Vx001) ? Spells.RocketStrikeSingle : Spells.RocketStrikeBoth); - _events.ScheduleEvent(Events.Reload, 10000); - _events.RescheduleEvent(Events.RocketStrike, RandomHelper.URand(20000, 25000)); - break; - case Events.Reload: - for (sbyte seat = (sbyte)SeatIds.RocketLeft; seat <= SeatIds.RocketRight; ++seat) - { - Unit rocket = me.GetVehicleKit().GetPassenger(seat); - if (rocket) - rocket.SetDisplayId(rocket.GetNativeDisplayId()); - } - break; - case Events.HandPulse: - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 120, true); - if (target) - DoCast(target, RandomHelper.RAND(Spells.HandPulseLeft, Spells.HandPulseRight)); - _events.RescheduleEvent(Events.HandPulse, RandomHelper.URand(1500, 3000), 0, Phases.Vol7ron); - } - break; - case Events.FrostBomb: - DoCastAOE(Spells.ScriptEffectFrostBomb); - _events.RescheduleEvent(Events.FrostBomb, 45000); - break; - case Events.SpinningUp: - DoCastAOE(Spells.SpinningUp); - _events.DelayEvents(14000); - _events.RescheduleEvent(Events.SpinningUp, RandomHelper.URand(55000, 65000)); - break; - case Events.FlameSuppressantVx: - DoCastAOE(Spells.FlameSuppressantVx); - _events.RescheduleEvent(Events.FlameSuppressantVx, RandomHelper.URand(10000, 12000), 0, Phases.Vx001); - break; - default: - break; - } - }); - } - - bool _fireFighter; + }); } - public override CreatureAI GetAI(Creature creature) - { - return instance_ulduar.GetUlduarInstanceAI(creature); - } + bool _fireFighter; } [Script] - class boss_aerial_command_unit : CreatureScript + class boss_aerial_command_unit : BossAI { - public boss_aerial_command_unit() : base("boss_aerial_command_unit") { } - - class boss_aerial_command_unitAI : BossAI + public boss_aerial_command_unit(Creature creature) : base(creature, BossIds.Mimiron) { - public boss_aerial_command_unitAI(Creature creature) : base(creature, BossIds.Mimiron) - { - me.SetReactState(ReactStates.Passive); - fireFigther = false; - } + me.SetReactState(ReactStates.Passive); + fireFigther = false; + } - public override void DamageTaken(Unit who, ref uint damage) + public override void DamageTaken(Unit who, ref uint damage) + { + if (damage >= me.GetHealth()) { - if (damage >= me.GetHealth()) + damage = (uint)(me.GetHealth() - 1); // Let creature fall to 1 hp, but do not let it die or damage itself with SetHealth(). + me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable); + me.AttackStop(); + me.SetReactState(ReactStates.Passive); + DoCast(me, Spells.VehicleDamaged, true); + me.RemoveAllAurasExceptType(AuraType.ControlVehicle, AuraType.ModIncreaseHealthPercent); + + if (_events.IsInPhase(Phases.AerialCommandUnit)) { - damage = (uint)(me.GetHealth() - 1); // Let creature fall to 1 hp, but do not let it die or damage itself with SetHealth(). - me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable); + me.GetMotionMaster().Clear(true); + me.GetMotionMaster().MovePoint(Waypoints.AerialP4Pos, MimironConst.VehicleRelocation[Waypoints.AerialP4Pos]); + } + else if (_events.IsInPhase(Phases.Vol7ron)) + { + me.SetStandState(UnitStandStateType.Dead); + + if (MimironConst.IsEncounterFinished(who)) + return; + + me.CastStop(); + DoCast(me, Spells.SelfRepair); + } + _events.Reset(); + } + } + + public override void DoAction(int action) + { + switch (action) + { + case Actions.HardmodeAerial: + fireFigther = true; + DoCast(me, Spells.EmergencyMode); + _events.ScheduleEvent(Events.SummonFireBots, 1000, 0, Phases.AerialCommandUnit); + goto case Actions.StartAerial; + case Actions.StartAerial: + me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); + me.SetReactState(ReactStates.Aggressive); + + _events.SetPhase(Phases.AerialCommandUnit); + _events.ScheduleEvent(Events.SummonJunkBot, 5000, 0, Phases.AerialCommandUnit); + _events.ScheduleEvent(Events.SummonAssaultBot, 9000, 0, Phases.AerialCommandUnit); + _events.ScheduleEvent(Events.SummonBombBot, 9000, 0, Phases.AerialCommandUnit); + break; + case Actions.DisableAerial: + me.CastStop(); me.AttackStop(); me.SetReactState(ReactStates.Passive); - DoCast(me, Spells.VehicleDamaged, true); - me.RemoveAllAurasExceptType(AuraType.ControlVehicle, AuraType.ModIncreaseHealthPercent); + me.GetMotionMaster().MoveFall(); + _events.DelayEvents(23000); + break; + case Actions.EnableAerial: + me.SetReactState(ReactStates.Aggressive); + break; + case Actions.AssembledCombat: + me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); + me.SetReactState(ReactStates.Aggressive); + me.SetStandState(UnitStandStateType.Stand); + _events.SetPhase(Phases.Vol7ron); + break; + default: + break; + } + } - if (_events.IsInPhase(Phases.AerialCommandUnit)) - { - me.GetMotionMaster().Clear(true); - me.GetMotionMaster().MovePoint(Waypoints.AerialP4Pos, MimironConst.VehicleRelocation[Waypoints.AerialP4Pos]); - } - else if (_events.IsInPhase(Phases.Vol7ron)) - { - me.SetStandState(UnitStandStateType.Dead); + public override void EnterEvadeMode(EvadeReason why) + { + summons.DespawnAll(); + } - if (MimironConst.IsEncounterFinished(who)) - return; + public override void JustSummoned(Creature summon) + { + if (fireFigther && (summon.GetEntry() == InstanceCreatureIds.AssaultBot || summon.GetEntry() == InstanceCreatureIds.JunkBot)) + summon.CastSpell(summon, Spells.EmergencyMode); + base.JustSummoned(summon); + } - me.CastStop(); - DoCast(me, Spells.SelfRepair); - } + public override void KilledUnit(Unit victim) + { + if (victim.IsTypeId(TypeId.Player)) + { + Creature mimiron = ObjectAccessor.GetCreature(me, instance.GetGuidData(BossIds.Mimiron)); + if (mimiron) + mimiron.GetAI().Talk(_events.IsInPhase(Phases.AerialCommandUnit) ? Yells.AerialSlay : Yells.V07tronSlay); + } + } + + public override void MovementInform(MovementGeneratorType type, uint point) + { + if (type == MovementGeneratorType.Point && point == Waypoints.AerialP4Pos) + { + me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable); + + Creature mimiron = ObjectAccessor.GetCreature(me, instance.GetGuidData(BossIds.Mimiron)); + if (mimiron) + mimiron.GetAI().DoAction(Actions.ActivateV0l7r0n1); + } + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _events.Update(diff); + + if (me.HasUnitState(UnitState.Casting)) + return; + + _events.ExecuteEvents(eventId => + { + switch (eventId) + { + case Events.SummonFireBots: + me.CastCustomSpell(Spells.SummonFireBotTrigger, SpellValueMod.MaxTargets, 3, null, true); + _events.RescheduleEvent(Events.SummonFireBots, 45000, 0, Phases.AerialCommandUnit); + break; + case Events.SummonJunkBot: + me.CastCustomSpell(Spells.SummonJunkBotTrigger, SpellValueMod.MaxTargets, 1, null, true); + _events.RescheduleEvent(Events.SummonJunkBot, RandomHelper.URand(11000, 12000), 0, Phases.AerialCommandUnit); + break; + case Events.SummonAssaultBot: + me.CastCustomSpell(Spells.SummonAssaultBotTrigger, SpellValueMod.MaxTargets, 1, null, true); + _events.RescheduleEvent(Events.SummonAssaultBot, 30000, 0, Phases.AerialCommandUnit); + break; + case Events.SummonBombBot: + DoCast(me, Spells.SummonBombBot); + _events.RescheduleEvent(Events.SummonBombBot, RandomHelper.URand(15000, 20000), 0, Phases.AerialCommandUnit); + break; + default: + break; + } + }); + DoSpellAttackIfReady(_events.IsInPhase(Phases.AerialCommandUnit) ? Spells.PlasmaBallP1 : Spells.PlasmaBallP2); + } + + bool fireFigther; + } + + [Script] + class npc_mimiron_assault_bot : ScriptedAI + { + public npc_mimiron_assault_bot(Creature creature) : base(creature) { } + + public override void EnterCombat(Unit who) + { + _scheduler.Schedule(TimeSpan.FromSeconds(14), task => + { + DoCastVictim(Spells.MagneticField); + me.ClearUnitState(UnitState.Casting); + task.Repeat(TimeSpan.FromSeconds(30)); + }); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + if (me.HasUnitState(UnitState.Root)) + { + Unit newTarget = SelectTarget(SelectAggroTarget.Nearest, 0, 30.0f, true); + if (newTarget) + { + me.DeleteThreatList(); + AttackStart(newTarget); + } + } + + _scheduler.Update(diff, DoMeleeAttackIfReady); + } + } + + [Script] + class npc_mimiron_emergency_fire_bot : ScriptedAI + { + public npc_mimiron_emergency_fire_bot(Creature creature) : base(creature) + { + me.SetReactState(ReactStates.Passive); + isWaterSprayReady = true; + moveNew = true; + } + + public override uint GetData(uint id) + { + if (id == Data.Waterspray) + return isWaterSprayReady ? 1 : 0u; + if (id == Data.MoveNew) + return moveNew ? 1 : 0u; + return 0; + } + + public override void SetData(uint id, uint data) + { + if (id == Data.Waterspray) + isWaterSprayReady = false; + else if (id == Data.MoveNew) + moveNew = data == 1; + } + + public override void Reset() + { + _scheduler.Schedule(TimeSpan.FromSeconds(7), task => + { + isWaterSprayReady = true; + task.Repeat(TimeSpan.FromSeconds(7), TimeSpan.FromSeconds(9)); + }); + + isWaterSprayReady = true; + moveNew = true; + } + + public override void UpdateAI(uint diff) + { + if (!isWaterSprayReady) + _scheduler.Update(diff); + } + + bool isWaterSprayReady; + bool moveNew; + } + + [Script] + class npc_mimiron_computer : ScriptedAI + { + public npc_mimiron_computer(Creature creature) : base(creature) + { + instance = me.GetInstanceScript(); + } + + public override void DoAction(int action) + { + switch (action) + { + case Actions.ActivateComputer: + Talk(ComputerYells.SelfDestructInitiated); + _events.ScheduleEvent(Events.SelfDestruct10, 3000); + break; + case Actions.DeactivateComputer: + Talk(ComputerYells.SelfDestructTerminated); + me.RemoveAurasDueToSpell(Spells.SelfDestructionAura); + me.RemoveAurasDueToSpell(Spells.SelfDestructionVisual); _events.Reset(); - } + break; + default: + break; } + } - public override void DoAction(int action) + public override void UpdateAI(uint diff) + { + _events.Update(diff); + _events.ExecuteEvents(eventId => { - switch (action) + switch (eventId) { - case Actions.HardmodeAerial: - fireFigther = true; - DoCast(me, Spells.EmergencyMode); - _events.ScheduleEvent(Events.SummonFireBots, 1000, 0, Phases.AerialCommandUnit); - goto case Actions.StartAerial; - case Actions.StartAerial: - me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); - me.SetReactState(ReactStates.Aggressive); - - _events.SetPhase(Phases.AerialCommandUnit); - _events.ScheduleEvent(Events.SummonJunkBot, 5000, 0, Phases.AerialCommandUnit); - _events.ScheduleEvent(Events.SummonAssaultBot, 9000, 0, Phases.AerialCommandUnit); - _events.ScheduleEvent(Events.SummonBombBot, 9000, 0, Phases.AerialCommandUnit); + case Events.SelfDestruct10: + { + Talk(ComputerYells.SelfDestruct10); + Creature mimiron = ObjectAccessor.GetCreature(me, instance.GetGuidData(BossIds.Mimiron)); + if (mimiron) + mimiron.GetAI().DoAction(Actions.ActivateHardMode); + _events.ScheduleEvent(Events.SelfDestruct9, 60000); + } break; - case Actions.DisableAerial: - me.CastStop(); - me.AttackStop(); - me.SetReactState(ReactStates.Passive); - me.GetMotionMaster().MoveFall(); - _events.DelayEvents(23000); + case Events.SelfDestruct9: + Talk(ComputerYells.SelfDestruct9); + _events.ScheduleEvent(Events.SelfDestruct8, 60000); break; - case Actions.EnableAerial: - me.SetReactState(ReactStates.Aggressive); + case Events.SelfDestruct8: + Talk(ComputerYells.SelfDestruct8); + _events.ScheduleEvent(Events.SelfDestruct7, 60000); break; - case Actions.AssembledCombat: - me.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable); - me.SetReactState(ReactStates.Aggressive); - me.SetStandState(UnitStandStateType.Stand); - _events.SetPhase(Phases.Vol7ron); + case Events.SelfDestruct7: + Talk(ComputerYells.SelfDestruct7); + _events.ScheduleEvent(Events.SelfDestruct6, 60000); + break; + case Events.SelfDestruct6: + Talk(ComputerYells.SelfDestruct6); + _events.ScheduleEvent(Events.SelfDestruct5, 60000); + break; + case Events.SelfDestruct5: + Talk(ComputerYells.SelfDestruct5); + _events.ScheduleEvent(Events.SelfDestruct4, 60000); + break; + case Events.SelfDestruct4: + Talk(ComputerYells.SelfDestruct4); + _events.ScheduleEvent(Events.SelfDestruct3, 60000); + break; + case Events.SelfDestruct3: + Talk(ComputerYells.SelfDestruct3); + _events.ScheduleEvent(Events.SelfDestruct2, 60000); + break; + case Events.SelfDestruct2: + Talk(ComputerYells.SelfDestruct2); + _events.ScheduleEvent(Events.SelfDestruct1, 60000); + break; + case Events.SelfDestruct1: + Talk(ComputerYells.SelfDestruct1); + _events.ScheduleEvent(Events.SelfDestructFinalized, 60000); + break; + case Events.SelfDestructFinalized: + { + Talk(ComputerYells.SelfDestructFinalized); + Creature mimiron = ObjectAccessor.GetCreature(me, instance.GetGuidData(BossIds.Mimiron)); + if (mimiron) + mimiron.GetAI().DoAction(Actions.ActivateSelfDestruct); + DoCast(me, Spells.SelfDestructionAura); + DoCast(me, Spells.SelfDestructionVisual); + } break; default: break; } - } - - public override void EnterEvadeMode(EvadeReason why) - { - summons.DespawnAll(); - } - - public override void JustSummoned(Creature summon) - { - if (fireFigther && (summon.GetEntry() == InstanceCreatureIds.AssaultBot || summon.GetEntry() == InstanceCreatureIds.JunkBot)) - summon.CastSpell(summon, Spells.EmergencyMode); - base.JustSummoned(summon); - } - - public override void KilledUnit(Unit victim) - { - if (victim.IsTypeId(TypeId.Player)) - { - Creature mimiron = ObjectAccessor.GetCreature(me, instance.GetGuidData(BossIds.Mimiron)); - if (mimiron) - mimiron.GetAI().Talk(_events.IsInPhase(Phases.AerialCommandUnit) ? Yells.AerialSlay : Yells.V07tronSlay); - } - } - - public override void MovementInform(MovementGeneratorType type, uint point) - { - if (type == MovementGeneratorType.Point && point == Waypoints.AerialP4Pos) - { - me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable); - - Creature mimiron = ObjectAccessor.GetCreature(me, instance.GetGuidData(BossIds.Mimiron)); - if (mimiron) - mimiron.GetAI().DoAction(Actions.ActivateV0l7r0n1); - } - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _events.Update(diff); - - if (me.HasUnitState(UnitState.Casting)) - return; - - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case Events.SummonFireBots: - me.CastCustomSpell(Spells.SummonFireBotTrigger, SpellValueMod.MaxTargets, 3, null, true); - _events.RescheduleEvent(Events.SummonFireBots, 45000, 0, Phases.AerialCommandUnit); - break; - case Events.SummonJunkBot: - me.CastCustomSpell(Spells.SummonJunkBotTrigger, SpellValueMod.MaxTargets, 1, null, true); - _events.RescheduleEvent(Events.SummonJunkBot, RandomHelper.URand(11000, 12000), 0, Phases.AerialCommandUnit); - break; - case Events.SummonAssaultBot: - me.CastCustomSpell(Spells.SummonAssaultBotTrigger, SpellValueMod.MaxTargets, 1, null, true); - _events.RescheduleEvent(Events.SummonAssaultBot, 30000, 0, Phases.AerialCommandUnit); - break; - case Events.SummonBombBot: - DoCast(me, Spells.SummonBombBot); - _events.RescheduleEvent(Events.SummonBombBot, RandomHelper.URand(15000, 20000), 0, Phases.AerialCommandUnit); - break; - default: - break; - } - }); - DoSpellAttackIfReady(_events.IsInPhase(Phases.AerialCommandUnit) ? Spells.PlasmaBallP1 : Spells.PlasmaBallP2); - } - - bool fireFigther; + }); } - public override CreatureAI GetAI(Creature creature) + InstanceScript instance; + } + + [Script] + class npc_mimiron_flames : ScriptedAI + { + public npc_mimiron_flames(Creature creature) : base(creature) { - return instance_ulduar.GetUlduarInstanceAI(creature); + instance = me.GetInstanceScript(); + } + + public override void Reset() // Reset is possibly more suitable for this case. + { + _scheduler.Schedule(TimeSpan.FromSeconds(4), task => + { + DoCastAOE(Spells.SummonFlamesSpreadTrigger); + }); + } + + public override void UpdateAI(uint diff) + { + if (instance.GetBossState(BossIds.Mimiron) != EncounterState.InProgress) + me.DespawnOrUnsummon(); + + _scheduler.Update(diff); + } + + InstanceScript instance; + } + + [Script] + class npc_mimiron_frost_bomb : ScriptedAI + { + public npc_mimiron_frost_bomb(Creature creature) : base(creature) { } + + public override void Reset() + { + _scheduler.Schedule(TimeSpan.FromSeconds(10), task => + { + DoCastAOE(Spells.FrostBombExplosion); + + task.Schedule(TimeSpan.FromSeconds(3), () => + { + DoCastAOE(Spells.ClearFires); + me.DespawnOrUnsummon(3000); + }); + }); + } + + public override void UpdateAI(uint diff) + { + _scheduler.Update(diff); } } [Script] - class npc_mimiron_assault_bot : CreatureScript + class npc_mimiron_proximity_mine : ScriptedAI { - public npc_mimiron_assault_bot() : base("npc_mimiron_assault_bot") { } + public npc_mimiron_proximity_mine(Creature creature) : base(creature) { } - class npc_mimiron_assault_botAI : ScriptedAI + public override void Reset() { - public npc_mimiron_assault_botAI(Creature creature) : base(creature) { } - - public override void EnterCombat(Unit who) + _scheduler.Schedule(TimeSpan.FromSeconds(1.5), task => { - _scheduler.Schedule(TimeSpan.FromSeconds(14), task => + DoCast(me, Spells.ProximityMinePeriodicTrigger); + + task.Schedule(TimeSpan.FromSeconds(33.5), () => { - DoCastVictim(Spells.MagneticField); - me.ClearUnitState(UnitState.Casting); - task.Repeat(TimeSpan.FromSeconds(30)); + if (me.HasAura(Spells.ProximityMinePeriodicTrigger)) + DoCastAOE(Spells.ProximityMineExplosion); + me.DespawnOrUnsummon(1000); }); - } + }); - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - if (me.HasUnitState(UnitState.Root)) - { - Unit newTarget = SelectTarget(SelectAggroTarget.Nearest, 0, 30.0f, true); - if (newTarget) - { - me.DeleteThreatList(); - AttackStart(newTarget); - } - } - - _scheduler.Update(diff, DoMeleeAttackIfReady); - } } - public override CreatureAI GetAI(Creature creature) + public override void UpdateAI(uint diff) { - return instance_ulduar.GetUlduarInstanceAI(creature); - } - } - - [Script] - class npc_mimiron_emergency_fire_bot : CreatureScript - { - public npc_mimiron_emergency_fire_bot() : base("npc_mimiron_emergency_fire_bot") { } - - class npc_mimiron_emergency_fire_botAI : ScriptedAI - { - public npc_mimiron_emergency_fire_botAI(Creature creature) : base(creature) - { - me.SetReactState(ReactStates.Passive); - isWaterSprayReady = true; - moveNew = true; - } - - public override uint GetData(uint id) - { - if (id == Data.Waterspray) - return isWaterSprayReady ? 1 : 0u; - if (id == Data.MoveNew) - return moveNew ? 1 : 0u; - return 0; - } - - public override void SetData(uint id, uint data) - { - if (id == Data.Waterspray) - isWaterSprayReady = false; - else if (id == Data.MoveNew) - moveNew = data == 1; - } - - public override void Reset() - { - _scheduler.Schedule(TimeSpan.FromSeconds(7), task => - { - isWaterSprayReady = true; - task.Repeat(TimeSpan.FromSeconds(7), TimeSpan.FromSeconds(9)); - }); - - isWaterSprayReady = true; - moveNew = true; - } - - public override void UpdateAI(uint diff) - { - if (!isWaterSprayReady) - _scheduler.Update(diff); - } - - bool isWaterSprayReady; - bool moveNew; - } - - public override CreatureAI GetAI(Creature creature) - { - return instance_ulduar.GetUlduarInstanceAI(creature); - } - } - - [Script] - class npc_mimiron_computer : CreatureScript - { - public npc_mimiron_computer() : base("npc_mimiron_computer") { } - - class npc_mimiron_computerAI : ScriptedAI - { - public npc_mimiron_computerAI(Creature creature) : base(creature) - { - instance = me.GetInstanceScript(); - } - - public override void DoAction(int action) - { - switch (action) - { - case Actions.ActivateComputer: - Talk(ComputerYells.SelfDestructInitiated); - _events.ScheduleEvent(Events.SelfDestruct10, 3000); - break; - case Actions.DeactivateComputer: - Talk(ComputerYells.SelfDestructTerminated); - me.RemoveAurasDueToSpell(Spells.SelfDestructionAura); - me.RemoveAurasDueToSpell(Spells.SelfDestructionVisual); - _events.Reset(); - break; - default: - break; - } - } - - public override void UpdateAI(uint diff) - { - _events.Update(diff); - _events.ExecuteEvents(eventId => - { - switch (eventId) - { - case Events.SelfDestruct10: - { - Talk(ComputerYells.SelfDestruct10); - Creature mimiron = ObjectAccessor.GetCreature(me, instance.GetGuidData(BossIds.Mimiron)); - if (mimiron) - mimiron.GetAI().DoAction(Actions.ActivateHardMode); - _events.ScheduleEvent(Events.SelfDestruct9, 60000); - } - break; - case Events.SelfDestruct9: - Talk(ComputerYells.SelfDestruct9); - _events.ScheduleEvent(Events.SelfDestruct8, 60000); - break; - case Events.SelfDestruct8: - Talk(ComputerYells.SelfDestruct8); - _events.ScheduleEvent(Events.SelfDestruct7, 60000); - break; - case Events.SelfDestruct7: - Talk(ComputerYells.SelfDestruct7); - _events.ScheduleEvent(Events.SelfDestruct6, 60000); - break; - case Events.SelfDestruct6: - Talk(ComputerYells.SelfDestruct6); - _events.ScheduleEvent(Events.SelfDestruct5, 60000); - break; - case Events.SelfDestruct5: - Talk(ComputerYells.SelfDestruct5); - _events.ScheduleEvent(Events.SelfDestruct4, 60000); - break; - case Events.SelfDestruct4: - Talk(ComputerYells.SelfDestruct4); - _events.ScheduleEvent(Events.SelfDestruct3, 60000); - break; - case Events.SelfDestruct3: - Talk(ComputerYells.SelfDestruct3); - _events.ScheduleEvent(Events.SelfDestruct2, 60000); - break; - case Events.SelfDestruct2: - Talk(ComputerYells.SelfDestruct2); - _events.ScheduleEvent(Events.SelfDestruct1, 60000); - break; - case Events.SelfDestruct1: - Talk(ComputerYells.SelfDestruct1); - _events.ScheduleEvent(Events.SelfDestructFinalized, 60000); - break; - case Events.SelfDestructFinalized: - { - Talk(ComputerYells.SelfDestructFinalized); - Creature mimiron = ObjectAccessor.GetCreature(me, instance.GetGuidData(BossIds.Mimiron)); - if (mimiron) - mimiron.GetAI().DoAction(Actions.ActivateSelfDestruct); - DoCast(me, Spells.SelfDestructionAura); - DoCast(me, Spells.SelfDestructionVisual); - } - break; - default: - break; - } - }); - } - - InstanceScript instance; - } - - public override CreatureAI GetAI(Creature creature) - { - return instance_ulduar.GetUlduarInstanceAI(creature); - } - } - - [Script] - class npc_mimiron_flames : CreatureScript - { - public npc_mimiron_flames() : base("npc_mimiron_flames") { } - - class npc_mimiron_flamesAI : ScriptedAI - { - public npc_mimiron_flamesAI(Creature creature) : base(creature) - { - instance = me.GetInstanceScript(); - } - - public override void Reset() // Reset is possibly more suitable for this case. - { - _scheduler.Schedule(TimeSpan.FromSeconds(4), task => - { - DoCastAOE(Spells.SummonFlamesSpreadTrigger); - }); - } - - public override void UpdateAI(uint diff) - { - if (instance.GetBossState(BossIds.Mimiron) != EncounterState.InProgress) - me.DespawnOrUnsummon(); - - _scheduler.Update(diff); - } - - InstanceScript instance; - } - - public override CreatureAI GetAI(Creature creature) - { - return instance_ulduar.GetUlduarInstanceAI(creature); - } - } - - [Script] - class npc_mimiron_frost_bomb : CreatureScript - { - public npc_mimiron_frost_bomb() : base("npc_mimiron_frost_bomb") { } - - class npc_mimiron_frost_bombAI : ScriptedAI - { - public npc_mimiron_frost_bombAI(Creature creature) : base(creature) { } - - public override void Reset() - { - _scheduler.Schedule(TimeSpan.FromSeconds(10), task => - { - DoCastAOE(Spells.FrostBombExplosion); - - task.Schedule(TimeSpan.FromSeconds(3), () => - { - DoCastAOE(Spells.ClearFires); - me.DespawnOrUnsummon(3000); - }); - }); - } - - public override void UpdateAI(uint diff) - { - _scheduler.Update(diff); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return instance_ulduar.GetUlduarInstanceAI(creature); - } - } - - [Script] - class npc_mimiron_proximity_mine : CreatureScript - { - public npc_mimiron_proximity_mine() : base("npc_mimiron_proximity_mine") { } - - class npc_mimiron_proximity_mineAI : ScriptedAI - { - public npc_mimiron_proximity_mineAI(Creature creature) : base(creature) { } - - public override void Reset() - { - _scheduler.Schedule(TimeSpan.FromSeconds(1.5), task => - { - DoCast(me, Spells.ProximityMinePeriodicTrigger); - - task.Schedule(TimeSpan.FromSeconds(33.5), () => - { - if (me.HasAura(Spells.ProximityMinePeriodicTrigger)) - DoCastAOE(Spells.ProximityMineExplosion); - me.DespawnOrUnsummon(1000); - }); - }); - - } - - public override void UpdateAI(uint diff) - { - _scheduler.Update(diff); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return instance_ulduar.GetUlduarInstanceAI(creature); + _scheduler.Update(diff); } } @@ -1713,977 +1613,728 @@ namespace Scripts.Northrend.Ulduar } [Script] // 63801 - Bomb Bot - class spell_mimiron_bomb_bot : SpellScriptLoader + class spell_mimiron_bomb_bot : SpellScript { - public spell_mimiron_bomb_bot() : base("spell_mimiron_bomb_bot") { } - - class spell_mimiron_bomb_bot_SpellScript : SpellScript + void HandleScript(uint effIndex) { - void HandleScript(uint effIndex) + if (GetHitPlayer()) { - if (GetHitPlayer()) + InstanceScript instance = GetCaster().GetInstanceScript(); + if (instance != null) { - InstanceScript instance = GetCaster().GetInstanceScript(); - if (instance != null) - { - Creature mkii = ObjectAccessor.GetCreature(GetCaster(), instance.GetGuidData(InstanceData.LeviathanMKII)); - if (mkii) - mkii.GetAI().SetData(Data.SetupBomb, 0); - } + Creature mkii = ObjectAccessor.GetCreature(GetCaster(), instance.GetGuidData(InstanceData.LeviathanMKII)); + if (mkii) + mkii.GetAI().SetData(Data.SetupBomb, 0); } } - - void HandleDespawn(uint effIndex) - { - Creature target = GetHitCreature(); - if (target) - { - target.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable | UnitFlags.Pacified); - target.DespawnOrUnsummon(1000); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.SchoolDamage)); - OnEffectHitTarget.Add(new EffectHandler(HandleDespawn, 1, SpellEffectName.ApplyAura)); - } } - public override SpellScript GetSpellScript() + void HandleDespawn(uint effIndex) { - return new spell_mimiron_bomb_bot_SpellScript(); + Creature target = GetHitCreature(); + if (target) + { + target.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable | UnitFlags.Pacified); + target.DespawnOrUnsummon(1000); + } + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.SchoolDamage)); + OnEffectHitTarget.Add(new EffectHandler(HandleDespawn, 1, SpellEffectName.ApplyAura)); } } [Script] // 65192 - Flame Suppressant, 65224 - Clear Fires, 65354 - Clear Fires, 64619 - Water Spray - class spell_mimiron_clear_fires : SpellScriptLoader + class spell_mimiron_clear_fires : SpellScript { - public spell_mimiron_clear_fires() : base("spell_mimiron_clear_fires") { } - - class spell_mimiron_clear_fires_SpellScript : SpellScript + void HandleDummy(uint effIndex) { - void HandleDummy(uint effIndex) - { - if (GetHitCreature()) - GetHitCreature().DespawnOrUnsummon(); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + if (GetHitCreature()) + GetHitCreature().DespawnOrUnsummon(); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_mimiron_clear_fires_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 64463 - Despawn Assault Bots - class spell_mimiron_despawn_assault_bots : SpellScriptLoader + class spell_mimiron_despawn_assault_bots : SpellScript { - public spell_mimiron_despawn_assault_bots() : base("spell_mimiron_despawn_assault_bots") { } - - class spell_mimiron_despawn_assault_bots_SpellScript : SpellScript + void HandleScript(uint effIndex) { - void HandleScript(uint effIndex) - { - if (GetHitCreature()) - GetHitCreature().DespawnOrUnsummon(); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } + if (GetHitCreature()) + GetHitCreature().DespawnOrUnsummon(); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_mimiron_despawn_assault_bots_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] // 64618 - Fire Search - class spell_mimiron_fire_search : SpellScriptLoader + class spell_mimiron_fire_search : SpellScript { - public spell_mimiron_fire_search() : base("spell_mimiron_fire_search") { } - - class spell_mimiron_fire_search_SpellScript : SpellScript + public spell_mimiron_fire_search() { - public spell_mimiron_fire_search_SpellScript() - { - _noTarget = false; - } + _noTarget = false; + } - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(Spells.WaterSpray); - } + public override bool Validate(SpellInfo spell) + { + return ValidateSpellInfo(Spells.WaterSpray); + } - void FilterTargets(List targets) - { - _noTarget = targets.Empty(); - if (_noTarget) - return; + void FilterTargets(List targets) + { + _noTarget = targets.Empty(); + if (_noTarget) + return; - WorldObject target = targets.SelectRandom(); - targets.Clear(); - targets.Add(target); - } + WorldObject target = targets.SelectRandom(); + targets.Clear(); + targets.Add(target); + } - void HandleAftercast() - { - if (_noTarget) - GetCaster().GetMotionMaster().MoveRandom(15.0f); - } + void HandleAftercast() + { + if (_noTarget) + GetCaster().GetMotionMaster().MoveRandom(15.0f); + } - void HandleScript(uint effIndex) + void HandleScript(uint effIndex) + { + Unit caster = GetCaster(); + UnitAI ai = caster.GetAI(); + if (ai != null) { - Unit caster = GetCaster(); - UnitAI ai = caster.GetAI(); - if (ai != null) + if (caster.GetDistance2d(GetHitUnit()) <= 15.0f && ai.GetData(Data.Waterspray) != 0) { - if (caster.GetDistance2d(GetHitUnit()) <= 15.0f && ai.GetData(Data.Waterspray) != 0) - { - caster.CastSpell(GetHitUnit(), Spells.WaterSpray, true); - ai.SetData(Data.Waterspray, 0); - ai.SetData(Data.MoveNew, 1); - } - else if (caster.GetAI().GetData(Data.MoveNew) != 0) - { - caster.GetMotionMaster().MoveChase(GetHitUnit()); - ai.SetData(Data.MoveNew, 0); - } + caster.CastSpell(GetHitUnit(), Spells.WaterSpray, true); + ai.SetData(Data.Waterspray, 0); + ai.SetData(Data.MoveNew, 1); + } + else if (caster.GetAI().GetData(Data.MoveNew) != 0) + { + caster.GetMotionMaster().MoveChase(GetHitUnit()); + ai.SetData(Data.MoveNew, 0); } } - - public override void Register() - { - AfterCast.Add(new CastHandler(HandleAftercast)); - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEntry)); - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } - - bool _noTarget; } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_mimiron_fire_search_SpellScript(); + AfterCast.Add(new CastHandler(HandleAftercast)); + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEntry)); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } + + bool _noTarget; } [Script] // 64436 - Magnetic Core - class spell_mimiron_magnetic_core : SpellScriptLoader + class spell_mimiron_magnetic_core : SpellScript { - public spell_mimiron_magnetic_core() : base("spell_mimiron_magnetic_core") { } - - class spell_mimiron_magnetic_core_SpellScript : SpellScript + void FilterTargets(List targets) { - void FilterTargets(List targets) - { - targets.RemoveAll(obj => { return obj.ToUnit() && (obj.ToUnit().GetVehicleBase() || obj.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable)); }); - } + targets.RemoveAll(obj => { return obj.ToUnit() && (obj.ToUnit().GetVehicleBase() || obj.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable)); }); + } - public override void Register() + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 1, Targets.UnitSrcAreaEntry)); + } + } + + [Script] + class spell_mimiron_magnetic_core_AuraScript : AuraScript + { + public override bool Validate(SpellInfo spell) + { + return ValidateSpellInfo(Spells.MagneticCoreVisual); + } + + void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Creature target = GetTarget().ToCreature(); + if (target) { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 1, Targets.UnitSrcAreaEntry)); + target.GetAI().DoAction(Actions.DisableAerial); + target.CastSpell(target, Spells.MagneticCoreVisual, true); } } - public override SpellScript GetSpellScript() + void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_mimiron_magnetic_core_SpellScript(); - } - - class spell_mimiron_magnetic_core_AuraScript : AuraScript - { - public override bool Validate(SpellInfo spell) + Creature target = GetTarget().ToCreature(); + if (target) { - return ValidateSpellInfo(Spells.MagneticCoreVisual); - } - - void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Creature target = GetTarget().ToCreature(); - if (target) - { - target.GetAI().DoAction(Actions.DisableAerial); - target.CastSpell(target, Spells.MagneticCoreVisual, true); - } - } - - void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Creature target = GetTarget().ToCreature(); - if (target) - { - target.GetAI().DoAction(Actions.EnableAerial); - target.RemoveAurasDueToSpell(Spells.MagneticCoreVisual); - } - } - - void OnRemoveSelf(AuraEffect aurEff, AuraEffectHandleModes mode) - { - TempSummon summ = GetTarget().ToTempSummon(); - if (summ) - summ.DespawnOrUnsummon(); - } - - public override void Register() - { - AfterEffectApply.Add(new EffectApplyHandler(OnApply, 1, AuraType.ModDamagePercentTaken, AuraEffectHandleModes.Real)); - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 1, AuraType.ModDamagePercentTaken, AuraEffectHandleModes.Real)); - AfterEffectRemove.Add(new EffectApplyHandler(OnRemoveSelf, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + target.GetAI().DoAction(Actions.EnableAerial); + target.RemoveAurasDueToSpell(Spells.MagneticCoreVisual); } } - public override AuraScript GetAuraScript() + void OnRemoveSelf(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_mimiron_magnetic_core_AuraScript(); + TempSummon summ = GetTarget().ToTempSummon(); + if (summ) + summ.DespawnOrUnsummon(); + } + + public override void Register() + { + AfterEffectApply.Add(new EffectApplyHandler(OnApply, 1, AuraType.ModDamagePercentTaken, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 1, AuraType.ModDamagePercentTaken, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new EffectApplyHandler(OnRemoveSelf, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } [Script] // 63667 - Napalm Shell - class spell_mimiron_napalm_shell : SpellScriptLoader + class spell_mimiron_napalm_shell : SpellScript { - public spell_mimiron_napalm_shell() : base("spell_mimiron_napalm_shell") { } - - class spell_mimiron_napalm_shell_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(Spells.NapalmShell); - } - - void FilterTargets(List targets) - { - if (targets.Empty()) - return; - - WorldObject target = targets.SelectRandom(); - - targets.RemoveAll(new AllWorldObjectsInRange(GetCaster(), 15.0f).Invoke); - - if (!targets.Empty()) - target = targets.SelectRandom(); - - targets.Clear(); - targets.Add(target); - } - - void HandleScript(uint effIndex) - { - GetCaster().CastSpell(GetHitUnit(), Spells.NapalmShell); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEnemy)); - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } + return ValidateSpellInfo(Spells.NapalmShell); } - public override SpellScript GetSpellScript() + void FilterTargets(List targets) { - return new spell_mimiron_napalm_shell_SpellScript(); + if (targets.Empty()) + return; + + WorldObject target = targets.SelectRandom(); + + targets.RemoveAll(new AllWorldObjectsInRange(GetCaster(), 15.0f).Invoke); + + if (!targets.Empty()) + target = targets.SelectRandom(); + + targets.Clear(); + targets.Add(target); + } + + void HandleScript(uint effIndex) + { + GetCaster().CastSpell(GetHitUnit(), Spells.NapalmShell); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEnemy)); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] // 64542 - Plasma Blast - class spell_mimiron_plasma_blast : SpellScriptLoader + class spell_mimiron_plasma_blast : SpellScript { - public spell_mimiron_plasma_blast() : base("spell_mimiron_plasma_blast") { } - - class spell_mimiron_plasma_blast_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(Spells.PlasmaBlast); - } - - public override bool Load() - { - return GetCaster().GetVehicleKit() != null; - } - - void HandleScript(uint effIndex) - { - Unit caster = GetCaster().GetVehicleKit().GetPassenger(3); - if (caster) - caster.CastSpell(GetHitUnit(), Spells.PlasmaBlast); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } + return ValidateSpellInfo(Spells.PlasmaBlast); } - public override SpellScript GetSpellScript() + public override bool Load() { - return new spell_mimiron_plasma_blast_SpellScript(); + return GetCaster().GetVehicleKit() != null; + } + + void HandleScript(uint effIndex) + { + Unit caster = GetCaster().GetVehicleKit().GetPassenger(3); + if (caster) + caster.CastSpell(GetHitUnit(), Spells.PlasmaBlast); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] // 66351 - Explosion - class spell_mimiron_proximity_explosion : SpellScriptLoader + class spell_mimiron_proximity_explosion : SpellScript { - public spell_mimiron_proximity_explosion() : base("spell_mimiron_proximity_explosion") { } - - class spell_mimiron_proximity_explosion_SpellScript : SpellScript + public void onHit(uint effIndex) { - public void onHit(uint effIndex) + if (GetHitPlayer()) { - if (GetHitPlayer()) + InstanceScript instance = GetCaster().GetInstanceScript(); + if (instance != null) { - InstanceScript instance = GetCaster().GetInstanceScript(); - if (instance != null) - { - Creature mkII = ObjectAccessor.GetCreature(GetCaster(), instance.GetGuidData(InstanceData.LeviathanMKII)); - if (mkII) - mkII.GetAI().SetData(Data.SetupMine, 0); - } + Creature mkII = ObjectAccessor.GetCreature(GetCaster(), instance.GetGuidData(InstanceData.LeviathanMKII)); + if (mkII) + mkII.GetAI().SetData(Data.SetupMine, 0); } } - - void HandleAura(uint effIndex) - { - GetCaster().RemoveAurasDueToSpell(Spells.ProximityMinePeriodicTrigger); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(onHit, 0, SpellEffectName.SchoolDamage)); - OnEffectHitTarget.Add(new EffectHandler(HandleAura, 1, SpellEffectName.ApplyAura)); - } } - public override SpellScript GetSpellScript() + void HandleAura(uint effIndex) { - return new spell_mimiron_proximity_explosion_SpellScript(); + GetCaster().RemoveAurasDueToSpell(Spells.ProximityMinePeriodicTrigger); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(onHit, 0, SpellEffectName.SchoolDamage)); + OnEffectHitTarget.Add(new EffectHandler(HandleAura, 1, SpellEffectName.ApplyAura)); } } [Script] // 63027 - Proximity Mines - class spell_mimiron_proximity_mines : SpellScriptLoader + class spell_mimiron_proximity_mines : SpellScript { - public spell_mimiron_proximity_mines() : base("spell_mimiron_proximity_mines") { } - - class spell_mimiron_proximity_mines_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(Spells.SummonProximityMine); - } - - void HandleScript(uint effIndex) - { - for (byte i = 0; i < 10; ++i) - GetCaster().CastSpell(GetCaster(), Spells.SummonProximityMine, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } + return ValidateSpellInfo(Spells.SummonProximityMine); } - public override SpellScript GetSpellScript() + void HandleScript(uint effIndex) { - return new spell_mimiron_proximity_mines_SpellScript(); + for (byte i = 0; i < 10; ++i) + GetCaster().CastSpell(GetCaster(), Spells.SummonProximityMine, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] // 65346 - Proximity Mine - class spell_mimiron_proximity_trigger : SpellScriptLoader + class spell_mimiron_proximity_trigger : SpellScript { - public spell_mimiron_proximity_trigger() : base("spell_mimiron_proximity_trigger") { } - - class spell_mimiron_proximity_trigger_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(Spells.ProximityMineExplosion); - } - - void FilterTargets(List targets) - { - targets.Remove(GetExplTargetWorldObject()); - - if (targets.Empty()) - FinishCast(SpellCastResult.NoValidTargets); - } - - void HandleDummy(uint effIndex) - { - GetCaster().CastSpell((Unit)null, Spells.ProximityMineExplosion, true); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEntry)); - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(Spells.ProximityMineExplosion); } - public override SpellScript GetSpellScript() + void FilterTargets(List targets) { - return new spell_mimiron_proximity_trigger_SpellScript(); + targets.Remove(GetExplTargetWorldObject()); + + if (targets.Empty()) + FinishCast(SpellCastResult.NoValidTargets); + } + + void HandleDummy(uint effIndex) + { + GetCaster().CastSpell((Unit)null, Spells.ProximityMineExplosion, true); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEntry)); + OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 63382 - Rapid Burst - class spell_mimiron_rapid_burst : SpellScriptLoader + class spell_mimiron_rapid_burst : AuraScript { - public spell_mimiron_rapid_burst() : base("spell_mimiron_rapid_burst") { } - - class spell_mimiron_rapid_burst_AuraScript : AuraScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(Spells.RapidBurstLeft, Spells.RapidBurstRight); - } - - void AfterRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - TempSummon summ = GetTarget().ToTempSummon(); - if (summ) - summ.DespawnOrUnsummon(); - } - - void HandleDummyTick(AuraEffect aurEff) - { - if (GetCaster()) - GetCaster().CastSpell(GetTarget(), aurEff.GetTickNumber() % 2 == 0 ? Spells.RapidBurstRight : Spells.RapidBurstLeft, true, null, aurEff); - } - - public override void Register() - { - AfterEffectRemove.Add(new EffectApplyHandler(AfterRemove, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.Real)); - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleDummyTick, 1, AuraType.PeriodicDummy)); - } + return ValidateSpellInfo(Spells.RapidBurstLeft, Spells.RapidBurstRight); } - public override AuraScript GetAuraScript() + void AfterRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_mimiron_rapid_burst_AuraScript(); + TempSummon summ = GetTarget().ToTempSummon(); + if (summ) + summ.DespawnOrUnsummon(); + } + + void HandleDummyTick(AuraEffect aurEff) + { + if (GetCaster()) + GetCaster().CastSpell(GetTarget(), aurEff.GetTickNumber() % 2 == 0 ? Spells.RapidBurstRight : Spells.RapidBurstLeft, true, null, aurEff); + } + + public override void Register() + { + AfterEffectRemove.Add(new EffectApplyHandler(AfterRemove, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.Real)); + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleDummyTick, 1, AuraType.PeriodicDummy)); } } [Script] // 64402 - Rocket Strike, 65034 - Rocket Strike - class spell_mimiron_rocket_strike : SpellScriptLoader + class spell_mimiron_rocket_strike : SpellScript { - public spell_mimiron_rocket_strike() : base("spell_mimiron_rocket_strike") { } - - class spell_mimiron_rocket_strike_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(Spells.ScriptEffectRocketStrike); - } + return ValidateSpellInfo(Spells.ScriptEffectRocketStrike); + } - void FilterTargets(List targets) - { - if (targets.Empty()) - return; + void FilterTargets(List targets) + { + if (targets.Empty()) + return; - if (m_scriptSpellId == Spells.RocketStrikeSingle && GetCaster().IsVehicle()) + if (m_scriptSpellId == Spells.RocketStrikeSingle && GetCaster().IsVehicle()) + { + WorldObject target = GetCaster().GetVehicleKit().GetPassenger(RandomHelper.RAND(SeatIds.RocketLeft, SeatIds.RocketRight)); + if (target) { - WorldObject target = GetCaster().GetVehicleKit().GetPassenger(RandomHelper.RAND(SeatIds.RocketLeft, SeatIds.RocketRight)); - if (target) - { - targets.Clear(); - targets.Add(target); - } + targets.Clear(); + targets.Add(target); } } - - void HandleDummy(uint effIndex) - { - GetHitUnit().CastSpell((Unit)null, Spells.ScriptEffectRocketStrike, true, null, null, GetCaster().GetGUID()); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEntry)); - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_mimiron_rocket_strike_SpellScript(); + GetHitUnit().CastSpell((Unit)null, Spells.ScriptEffectRocketStrike, true, null, null, GetCaster().GetGUID()); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEntry)); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 63041 - Rocket Strike - class spell_mimiron_rocket_strike_damage : SpellScriptLoader + class spell_mimiron_rocket_strike_damage : SpellScript { - public spell_mimiron_rocket_strike_damage() : base("spell_mimiron_rocket_strike_damage") { } - - class spell_mimiron_rocket_strike_damage_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(Spells.NotSoFriendlyFire); - } + return ValidateSpellInfo(Spells.NotSoFriendlyFire); + } - void HandleAfterCast() - { - TempSummon summ = GetCaster().ToTempSummon(); - if (summ) - summ.DespawnOrUnsummon(); - } + void HandleAfterCast() + { + TempSummon summ = GetCaster().ToTempSummon(); + if (summ) + summ.DespawnOrUnsummon(); + } - void HandleScript(uint effIndex) + void HandleScript(uint effIndex) + { + if (GetHitPlayer()) { - if (GetHitPlayer()) + InstanceScript instance = GetCaster().GetInstanceScript(); + if (instance != null) { - InstanceScript instance = GetCaster().GetInstanceScript(); - if (instance != null) - { - Creature mkii = ObjectAccessor.GetCreature(GetCaster(), instance.GetGuidData(InstanceData.LeviathanMKII)); - if (mkii) - mkii.GetAI().SetData(Data.SetupRocket, 0); - } + Creature mkii = ObjectAccessor.GetCreature(GetCaster(), instance.GetGuidData(InstanceData.LeviathanMKII)); + if (mkii) + mkii.GetAI().SetData(Data.SetupRocket, 0); } } - - void HandleFriendlyFire(uint effIndex) - { - GetHitUnit().CastSpell((Unit)null, Spells.NotSoFriendlyFire, true); - } - - public override void Register() - { - AfterCast.Add(new CastHandler(HandleAfterCast)); - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.SchoolDamage)); - OnEffectHitTarget.Add(new EffectHandler(HandleFriendlyFire, 1, SpellEffectName.SchoolDamage)); - } } - public override SpellScript GetSpellScript() + void HandleFriendlyFire(uint effIndex) { - return new spell_mimiron_rocket_strike_damage_SpellScript(); + GetHitUnit().CastSpell((Unit)null, Spells.NotSoFriendlyFire, true); + } + + public override void Register() + { + AfterCast.Add(new CastHandler(HandleAfterCast)); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.SchoolDamage)); + OnEffectHitTarget.Add(new EffectHandler(HandleFriendlyFire, 1, SpellEffectName.SchoolDamage)); } } [Script] // 63681 - Rocket Strike - class spell_mimiron_rocket_strike_target_select : SpellScriptLoader + class spell_mimiron_rocket_strike_target_select : SpellScript { - public spell_mimiron_rocket_strike_target_select() : base("spell_mimiron_rocket_strike_target_select") { } - - class spell_mimiron_rocket_strike_target_select_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(Spells.SummonRocketStrike); - } - - void FilterTargets(List targets) - { - if (targets.Empty()) - return; - - WorldObject target = targets.SelectRandom(); - - targets.RemoveAll(new AllWorldObjectsInRange(GetCaster(), 15.0f).Invoke); - - if (!targets.Empty()) - target = targets.SelectRandom(); - - targets.Clear(); - targets.Add(target); - } - - void HandleScript(uint effIndex) - { - InstanceScript instance = GetCaster().GetInstanceScript(); - if (instance != null) - GetCaster().CastSpell(GetHitUnit(), Spells.SummonRocketStrike, true, null, null, instance.GetGuidData(InstanceData.VX001)); - GetCaster().SetDisplayId(11686); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEnemy)); - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } + return ValidateSpellInfo(Spells.SummonRocketStrike); } - public override SpellScript GetSpellScript() + void FilterTargets(List targets) { - return new spell_mimiron_rocket_strike_target_select_SpellScript(); + if (targets.Empty()) + return; + + WorldObject target = targets.SelectRandom(); + + targets.RemoveAll(new AllWorldObjectsInRange(GetCaster(), 15.0f).Invoke); + + if (!targets.Empty()) + target = targets.SelectRandom(); + + targets.Clear(); + targets.Add(target); + } + + void HandleScript(uint effIndex) + { + InstanceScript instance = GetCaster().GetInstanceScript(); + if (instance != null) + GetCaster().CastSpell(GetHitUnit(), Spells.SummonRocketStrike, true, null, null, instance.GetGuidData(InstanceData.VX001)); + GetCaster().SetDisplayId(11686); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEnemy)); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] // 64383 - Self Repair - class spell_mimiron_self_repair : SpellScriptLoader + class spell_mimiron_self_repair : SpellScript { - public spell_mimiron_self_repair() : base("spell_mimiron_self_repair") { } - - class spell_mimiron_self_repair_SpellScript : SpellScript + void HandleScript() { - void HandleScript() - { - if (GetCaster().GetAI() != null) - GetCaster().GetAI().DoAction(Actions.AssembledCombat); - } - - public override void Register() - { - AfterHit.Add(new HitHandler(HandleScript)); - } + if (GetCaster().GetAI() != null) + GetCaster().GetAI().DoAction(Actions.AssembledCombat); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_mimiron_self_repair_SpellScript(); + AfterHit.Add(new HitHandler(HandleScript)); } } [Script] // 64426 - Summon Scrap Bot - class spell_mimiron_summon_assault_bot : SpellScriptLoader + class spell_mimiron_summon_assault_bot : AuraScript { - public spell_mimiron_summon_assault_bot() : base("spell_mimiron_summon_assault_bot") { } - - class spell_mimiron_summon_assault_bot_AuraScript : AuraScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(Spells.SummonAssaultBot); - } + return ValidateSpellInfo(Spells.SummonAssaultBot); + } - void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit caster = GetCaster(); + if (caster) { - Unit caster = GetCaster(); - if (caster) - { - InstanceScript instance = caster.GetInstanceScript(); - if (instance != null) - if (instance.GetBossState(BossIds.Mimiron) == EncounterState.InProgress) - caster.CastSpell(caster, Spells.SummonAssaultBot, false, null, aurEff, instance.GetGuidData(InstanceData.AerialCommandUnit)); - } - } - - public override void Register() - { - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + InstanceScript instance = caster.GetInstanceScript(); + if (instance != null) + if (instance.GetBossState(BossIds.Mimiron) == EncounterState.InProgress) + caster.CastSpell(caster, Spells.SummonAssaultBot, false, null, aurEff, instance.GetGuidData(InstanceData.AerialCommandUnit)); } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_mimiron_summon_assault_bot_AuraScript(); + OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } [Script] // 64425 - Summon Scrap Bot Trigger - class spell_mimiron_summon_assault_bot_target : SpellScriptLoader + class spell_mimiron_summon_assault_bot_target : SpellScript { - public spell_mimiron_summon_assault_bot_target() : base("spell_mimiron_summon_assault_bot_target") { } - - class spell_mimiron_summon_assault_bot_target_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(Spells.SummonAssaultBotDummy); - } - - void HandleDummy(uint effIndex) - { - GetHitUnit().CastSpell(GetHitUnit(), Spells.SummonAssaultBotDummy, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(Spells.SummonAssaultBotDummy); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_mimiron_summon_assault_bot_target_SpellScript(); + GetHitUnit().CastSpell(GetHitUnit(), Spells.SummonAssaultBotDummy, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 64621 - Summon Fire Bot - class spell_mimiron_summon_fire_bot : SpellScriptLoader + class spell_mimiron_summon_fire_bot : AuraScript { - public spell_mimiron_summon_fire_bot() : base("spell_mimiron_summon_fire_bot") { } - - class spell_mimiron_summon_fire_bot_AuraScript : AuraScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(Spells.SummonFireBot); - } + return ValidateSpellInfo(Spells.SummonFireBot); + } - void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit caster = GetCaster(); + if (caster) { - Unit caster = GetCaster(); - if (caster) - { - InstanceScript instance = caster.GetInstanceScript(); - if (instance != null) - if (instance.GetBossState(BossIds.Mimiron) == EncounterState.InProgress) - caster.CastSpell(caster, Spells.SummonFireBot, false, null, aurEff, instance.GetGuidData(InstanceData.AerialCommandUnit)); - } - } - - public override void Register() - { - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)) - ; + InstanceScript instance = caster.GetInstanceScript(); + if (instance != null) + if (instance.GetBossState(BossIds.Mimiron) == EncounterState.InProgress) + caster.CastSpell(caster, Spells.SummonFireBot, false, null, aurEff, instance.GetGuidData(InstanceData.AerialCommandUnit)); } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_mimiron_summon_fire_bot_AuraScript(); + OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)) + ; } } [Script] // 64620 - Summon Fire Bot Trigger - class spell_mimiron_summon_fire_bot_target : SpellScriptLoader + class spell_mimiron_summon_fire_bot_target : SpellScript { - public spell_mimiron_summon_fire_bot_target() : base("spell_mimiron_summon_fire_bot_target") { } - - class spell_mimiron_summon_fire_bot_target_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(Spells.SummonFireBotDummy); - } - - void HandleDummy(uint effIndex) - { - GetHitUnit().CastSpell(GetHitUnit(), Spells.SummonFireBotDummy, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(Spells.SummonFireBotDummy); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_mimiron_summon_fire_bot_target_SpellScript(); + GetHitUnit().CastSpell(GetHitUnit(), Spells.SummonFireBotDummy, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 64562 - Summon Flames Spread Trigger - class spell_mimiron_summon_flames_spread : SpellScriptLoader + class spell_mimiron_summon_flames_spread : SpellScript { - public spell_mimiron_summon_flames_spread() : base("spell_mimiron_summon_flames_spread") { } - - class spell_mimiron_summon_flames_spread_SpellScript : SpellScript + void FilterTargets(List targets) { - void FilterTargets(List targets) - { - if (targets.Empty()) - return; + if (targets.Empty()) + return; - // Flames must chase the closest player - WorldObject target = targets.First(); + // Flames must chase the closest player + WorldObject target = targets.First(); - foreach (var iter in targets) - if (GetCaster().GetDistance2d(iter) < GetCaster().GetDistance2d(target)) - target = iter; + foreach (var iter in targets) + if (GetCaster().GetDistance2d(iter) < GetCaster().GetDistance2d(target)) + target = iter; - targets.Clear(); - targets.Add(target); - } - - public void onHit(uint effIndex) - { - GetCaster().SetInFront(GetHitUnit()); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEnemy)); - OnEffectHitTarget.Add(new EffectHandler(onHit, 0, SpellEffectName.ApplyAura)); - } + targets.Clear(); + targets.Add(target); } - public override SpellScript GetSpellScript() + public void onHit(uint effIndex) { - return new spell_mimiron_summon_flames_spread_SpellScript(); + GetCaster().SetInFront(GetHitUnit()); } - class spell_mimiron_summon_flames_spread_AuraScript : AuraScript + public override void Register() { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(Spells.SummonFlamesSpread); - } + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEnemy)); + OnEffectHitTarget.Add(new EffectHandler(onHit, 0, SpellEffectName.ApplyAura)); + } + } - void HandleTick(AuraEffect aurEff) - { - PreventDefaultAction(); - Unit caster = GetCaster(); - if (caster) - if (caster.HasAura(Spells.FlamesPeriodicTrigger)) - caster.CastSpell(GetTarget(), Spells.SummonFlamesSpread, true); - } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleTick, 0, AuraType.PeriodicTriggerSpell)); - } + class spell_mimiron_summon_flames_spread_AuraScript : AuraScript + { + public override bool Validate(SpellInfo spell) + { + return ValidateSpellInfo(Spells.SummonFlamesSpread); } - public override AuraScript GetAuraScript() + void HandleTick(AuraEffect aurEff) { - return new spell_mimiron_summon_flames_spread_AuraScript(); + PreventDefaultAction(); + Unit caster = GetCaster(); + if (caster) + if (caster.HasAura(Spells.FlamesPeriodicTrigger)) + caster.CastSpell(GetTarget(), Spells.SummonFlamesSpread, true); + } + + public override void Register() + { + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleTick, 0, AuraType.PeriodicTriggerSpell)); } } [Script] // 64623 - Frost Bomb - class spell_mimiron_summon_frost_bomb_target : SpellScriptLoader + class spell_mimiron_summon_frost_bomb_target : SpellScript { - public spell_mimiron_summon_frost_bomb_target() : base("spell_mimiron_summon_frost_bomb_target") { } - - class spell_mimiron_summon_frost_bomb_target_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(Spells.SummonFrostBomb); - } - - void FilterTargets(List targets) - { - if (targets.Empty()) - return; - - targets.RemoveAll(new AllWorldObjectsInRange(GetCaster(), 15.0f).Invoke); - - if (targets.Empty()) - return; - - WorldObject target = targets.SelectRandom(); - - targets.Clear(); - targets.Add(target); - } - - void HandleScript(uint effIndex) - { - GetCaster().CastSpell(GetHitUnit(), Spells.SummonFrostBomb, true); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEntry)); - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } + return ValidateSpellInfo(Spells.SummonFrostBomb); } - public override SpellScript GetSpellScript() + void FilterTargets(List targets) { - return new spell_mimiron_summon_frost_bomb_target_SpellScript(); + if (targets.Empty()) + return; + + targets.RemoveAll(new AllWorldObjectsInRange(GetCaster(), 15.0f).Invoke); + + if (targets.Empty()) + return; + + WorldObject target = targets.SelectRandom(); + + targets.Clear(); + targets.Add(target); + } + + void HandleScript(uint effIndex) + { + GetCaster().CastSpell(GetHitUnit(), Spells.SummonFrostBomb, true); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEntry)); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] // 64398 - Summon Scrap Bot - class spell_mimiron_summon_junk_bot : SpellScriptLoader + class spell_mimiron_summon_junk_bot : AuraScript { - public spell_mimiron_summon_junk_bot() : base("spell_mimiron_summon_junk_bot") { } - - class spell_mimiron_summon_junk_bot_AuraScript : AuraScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(Spells.SummonJunkBot); - } + return ValidateSpellInfo(Spells.SummonJunkBot); + } - void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit caster = GetCaster(); + if (caster) { - Unit caster = GetCaster(); - if (caster) - { - InstanceScript instance = caster.GetInstanceScript(); - if (instance != null) - if (instance.GetBossState(BossIds.Mimiron) == EncounterState.InProgress) - caster.CastSpell(caster, Spells.SummonJunkBot, false, null, aurEff, instance.GetGuidData(InstanceData.AerialCommandUnit)); - } - } - - public override void Register() - { - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + InstanceScript instance = caster.GetInstanceScript(); + if (instance != null) + if (instance.GetBossState(BossIds.Mimiron) == EncounterState.InProgress) + caster.CastSpell(caster, Spells.SummonJunkBot, false, null, aurEff, instance.GetGuidData(InstanceData.AerialCommandUnit)); } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_mimiron_summon_junk_bot_AuraScript(); + OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } [Script] // 63820 - Summon Scrap Bot Trigger - class spell_mimiron_summon_junk_bot_target : SpellScriptLoader + class spell_mimiron_summon_junk_bot_target : SpellScript { - public spell_mimiron_summon_junk_bot_target() : base("spell_mimiron_summon_junk_bot_target") { } - - class spell_mimiron_summon_junk_bot_target_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(Spells.SummonJunkBotDummy); - } - - void HandleDummy(uint effIndex) - { - GetHitUnit().CastSpell(GetHitUnit(), Spells.SummonJunkBotDummy, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(Spells.SummonJunkBotDummy); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_mimiron_summon_junk_bot_target_SpellScript(); + GetHitUnit().CastSpell(GetHitUnit(), Spells.SummonJunkBotDummy, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 63339 - Weld - class spell_mimiron_weld : SpellScriptLoader + class spell_mimiron_weld : AuraScript { - public spell_mimiron_weld() : base("spell_mimiron_weld") { } - - class spell_mimiron_weld_AuraScript : AuraScript + void HandleTick(AuraEffect aurEff) { - void HandleTick(AuraEffect aurEff) + Unit caster = GetTarget(); + Unit vehicle = caster.GetVehicleBase(); + if (vehicle) { - Unit caster = GetTarget(); - Unit vehicle = caster.GetVehicleBase(); - if (vehicle) - { - if (aurEff.GetTickNumber() % 5 == 0) - caster.CastSpell(vehicle, MimironConst.RepairSpells[RandomHelper.IRand(0, 3)]); - //caster.SetFacingToObject(vehicle); - } - } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleTick, 0, AuraType.PeriodicTriggerSpell)); + if (aurEff.GetTickNumber() % 5 == 0) + caster.CastSpell(vehicle, MimironConst.RepairSpells[RandomHelper.IRand(0, 3)]); + //caster.SetFacingToObject(vehicle); } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_mimiron_weld_AuraScript(); + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleTick, 0, AuraType.PeriodicTriggerSpell)); } } diff --git a/Scripts/Northrend/Ulduar/Razorscale.cs b/Scripts/Northrend/Ulduar/Razorscale.cs index 946b5b366..038fd2d31 100644 --- a/Scripts/Northrend/Ulduar/Razorscale.cs +++ b/Scripts/Northrend/Ulduar/Razorscale.cs @@ -30,13 +30,9 @@ namespace Scripts.Northrend.Ulduar { namespace Razorscale { - /*class boss_razorscale_controller : CreatureScript - { - public boss_razorscale_controller() : base("boss_razorscale_controller") { } - - class boss_razorscale_controllerAI : BossAI + /*class boss_razorscale_controller : BossAI { - public boss_razorscale_controllerAI(Creature creature) : base(creature, InstanceData.RazorscaleControl) + public boss_razorscale_controller(Creature creature) : base(creature, InstanceData.RazorscaleControl) { me.SetDisplayId(me.GetCreatureTemplate().ModelId2); } @@ -152,7 +148,7 @@ namespace Scripts.Northrend.Ulduar } } - public override CreatureAI GetAI(Creature creature) + public override CreatureAI Get(Creature creature) { return GetInstanceAI(creature); } diff --git a/Scripts/Northrend/Ulduar/UlduarConst.cs b/Scripts/Northrend/Ulduar/UlduarConst.cs index 7974e0b3a..c7912feed 100644 --- a/Scripts/Northrend/Ulduar/UlduarConst.cs +++ b/Scripts/Northrend/Ulduar/UlduarConst.cs @@ -377,6 +377,12 @@ namespace Scripts.Northrend.Ulduar public const uint UniverseGlobe = 55; public const uint AlgalonTrapdoor = 56; public const uint BrannBronzebeardAlg = 57; + + // Misc + public const uint BrannBronzebeardIntro = 58; + public const uint LoreKeeperOfNorgannon = 59; + public const uint Dellorah = 60; + public const uint BronzebeardRadio = 61; } struct InstanceWorldStates diff --git a/Scripts/Northrend/Ulduar/Xt002.cs b/Scripts/Northrend/Ulduar/Xt002.cs index 6b24186f2..129cfb4c2 100644 --- a/Scripts/Northrend/Ulduar/Xt002.cs +++ b/Scripts/Northrend/Ulduar/Xt002.cs @@ -122,407 +122,367 @@ namespace Scripts.Northrend.Ulduar.Xt002 } [Script] - class boss_xt002 : CreatureScript + class boss_xt002_ : BossAI { - public boss_xt002() : base("boss_xt002") { } - - class boss_xt002_AI : BossAI + public boss_xt002_(Creature creature) : base(creature, BossIds.Xt002) { - public boss_xt002_AI(Creature creature) : base(creature, BossIds.Xt002) - { - Initialize(); - _transferHealth = 0; - } - - void Initialize() - { - _healthRecovered = false; - _gravityBombCasualty = false; - _hardMode = false; - - _heartExposed = 0; - } - - public override void Reset() - { - _Reset(); - - me.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable); - me.SetReactState(ReactStates.Aggressive); - DoCastSelf(SpellIds.Stand); - - Initialize(); - - instance.DoStopCriteriaTimer(CriteriaTimedTypes.Event, Misc.AchievMustDeconstructFaster); - } - - public override void EnterCombat(Unit who) - { - Talk(Texts.Aggro); - _EnterCombat(); - - //Enrage - _scheduler.Schedule(TimeSpan.FromMinutes(10), task => - { - Talk(Texts.Berserk); - DoCastSelf(SpellIds.Enrage); - }); - - //Gavity Bomb - _scheduler.Schedule(TimeSpan.FromSeconds(20), Misc.PhaseOneGroup, task => - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0); - if (target) - DoCast(target, SpellIds.GravityBomb); - - task.Repeat(TimeSpan.FromSeconds(20)); - }); - - //Searing Light - _scheduler.Schedule(TimeSpan.FromSeconds(20), Misc.PhaseOneGroup, task => - { - Unit target = SelectTarget(SelectAggroTarget.Random, 0); - if (target) - DoCast(target, SpellIds.SearingLight); - - task.Repeat(TimeSpan.FromSeconds(20)); - }); - - //Tympanic Tantrum - _scheduler.Schedule(TimeSpan.FromSeconds(30), Misc.PhaseOneGroup, task => - { - Talk(Texts.TympanicTantrum); - Talk(Texts.EmoteTympanicTantrum); - DoCast(SpellIds.TympanicTantrum); - task.Repeat(TimeSpan.FromSeconds(30)); - }); - - instance.DoStartCriteriaTimer(CriteriaTimedTypes.Event, Misc.AchievMustDeconstructFaster); - } - - public override void DoAction(int action) - { - switch (action) - { - case Misc.ActionHardMode: - _scheduler.Schedule(TimeSpan.FromMilliseconds(1), task => - { - SetPhaseOne(true); - }); - break; - } - } - - public override void KilledUnit(Unit who) - { - if (who.GetTypeId() == TypeId.Player) - Talk(Texts.Slay); - } - - public override void JustDied(Unit killer) - { - Talk(Texts.Death); - _JustDied(); - me.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable); - } - - public override void DamageTaken(Unit attacker, ref uint damage) - { - if (!_hardMode && !me.HasReactState(ReactStates.Passive) && !HealthAbovePct(100 - 25 * (_heartExposed + 1))) - ExposeHeart(); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _scheduler.Update(diff); - - if (!me.HasReactState(ReactStates.Passive)) - DoMeleeAttackIfReady(); - } - - public override void PassengerBoarded(Unit who, sbyte seatId, bool apply) - { - if (apply && who.GetEntry() == InstanceCreatureIds.XS013Scrapbot) - { - // Need this so we can properly determine when to expose heart again in damagetaken hook - if (me.GetHealthPct() > (25 * (4 - _heartExposed))) - ++_heartExposed; - - Talk(Texts.EmoteScrapbot); - DoCast(who, SpellIds.ScrapRepair, true); - _healthRecovered = true; - } - - if (apply && seatId == Misc.SeatHeartExposed) - who.CastSpell(who, SpellIds.ExposedHeart); // Channeled - } - - public override uint GetData(uint type) - { - switch (type) - { - case XT002Data.HardMode: - return _hardMode ? 1 : 0u; - case XT002Data.HealthRecovered: - return _healthRecovered ? 1 : 0u; - case XT002Data.GravityBombCasualty: - return _gravityBombCasualty ? 1 : 0u; - } - - return 0; - } - - public override void SetData(uint type, uint data) - { - switch (type) - { - case XT002Data.TransferedHealth: - _transferHealth = data; - break; - case XT002Data.GravityBombCasualty: - _gravityBombCasualty = (data > 0) ? true : false; - break; - } - } - - void ExposeHeart() - { - Talk(Texts.HeartOpened); - Talk(Texts.EmoteHeartOpened); - - DoCastSelf(SpellIds.Submerge); // WIll make creature untargetable - me.AttackStop(); - me.SetReactState(ReactStates.Passive); - - Unit heart = me.GetVehicleKit() ? me.GetVehicleKit().GetPassenger(Misc.SeatHeartNormal) : null; - if (heart) - { - heart.CastSpell(heart, SpellIds.HeartOverload); - heart.CastSpell(me, SpellIds.HeartLightningTether); - heart.CastSpell(heart, SpellIds.HeartHealToFull, true); - heart.CastSpell(me, SpellIds.RideVehicleExposed, true); - heart.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable); - heart.SetFlag(UnitFields.Flags, UnitFlags.Unk29); - } - _scheduler.DelayGroup(Misc.PhaseOneGroup, TimeSpan.FromSeconds(30)); - - // Start "end of phase 2 timer" - _scheduler.Schedule(TimeSpan.FromSeconds(30), task => { SetPhaseOne(false); }); - - _heartExposed++; - } - - void SetPhaseOne(bool isHardMode) - { - if (isHardMode) - { - me.SetFullHealth(); - DoCastSelf(SpellIds.Heartbreak, true); - me.AddLootMode(LootModes.HardMode1); - _hardMode = true; - } - - Talk(Texts.HeartClosed); - Talk(Texts.EmoteHeartClosed); - - me.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable); - me.SetReactState(ReactStates.Aggressive); - DoCastSelf(SpellIds.Stand); - - //_events.RescheduleEvent(EVENT_SEARING_LIGHT, TIMER_SEARING_LIGHT / 2); - //_events.RescheduleEvent(EVENT_GRAVITY_BOMB, TIMER_GRAVITY_BOMB); - //_events.RescheduleEvent(EVENT_TYMPANIC_TANTRUM, RandomHelper.URand(TIMER_TYMPANIC_TANTRUM_MIN, TIMER_TYMPANIC_TANTRUM_MAX)); - - Unit heart = me.GetVehicleKit() ? me.GetVehicleKit().GetPassenger(Misc.SeatHeartExposed) : null; - if (!heart) - return; - - heart.CastSpell(me, SpellIds.HeartRideVehicle, true); - heart.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable); - heart.RemoveFlag(UnitFields.Flags, UnitFlags.Unk29); - heart.RemoveAurasDueToSpell(SpellIds.ExposedHeart); - - if (!_hardMode) - { - if (_transferHealth == 0) - _transferHealth = (uint)(heart.GetMaxHealth() - heart.GetHealth()); - - if (_transferHealth >= me.GetHealth()) - _transferHealth = (uint)me.GetHealth() - 1; - - me.ModifyHealth(-(int)_transferHealth); - me.LowerPlayerDamageReq(_transferHealth); - } - } - - // Achievement related - bool _healthRecovered; // Did a scrapbot recover XT-002's health during the encounter? - bool _hardMode; // Are we in hard mode? Or: was the heart killed during phase 2? - bool _gravityBombCasualty; // Did someone die because of Gravity Bomb damage? - - byte _heartExposed; - uint _transferHealth; + Initialize(); + _transferHealth = 0; } - public override CreatureAI GetAI(Creature creature) + void Initialize() { - return instance_ulduar.GetUlduarInstanceAI(creature); - } - } + _healthRecovered = false; + _gravityBombCasualty = false; + _hardMode = false; - [Script] - class npc_xt002_heart : CreatureScript - { - public npc_xt002_heart() : base("npc_xt002_heart") { } - - class npc_xt002_heartAI : ScriptedAI - { - public npc_xt002_heartAI(Creature creature) : base(creature) - { - _instance = creature.GetInstanceScript(); - - SetCombatMovement(false); - } - - public override void UpdateAI(uint diff) { } - - public override void JustDied(Unit killer) - { - Creature xt002 = _instance != null ? ObjectAccessor.GetCreature(me, _instance.GetGuidData(BossIds.Xt002)) : null; - if (!xt002 || xt002.GetAI() == null) - return; - - xt002.GetAI().SetData(XT002Data.TransferedHealth, (uint)me.GetHealth()); - xt002.GetAI().DoAction(Misc.ActionHardMode); - } - - InstanceScript _instance; + _heartExposed = 0; } - public override CreatureAI GetAI(Creature creature) + public override void Reset() { - return GetInstanceAI(creature); + _Reset(); + + me.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable); + me.SetReactState(ReactStates.Aggressive); + DoCastSelf(SpellIds.Stand); + + Initialize(); + + instance.DoStopCriteriaTimer(CriteriaTimedTypes.Event, Misc.AchievMustDeconstructFaster); } - } - [Script] - class npc_scrapbot : CreatureScript - { - public npc_scrapbot() : base("npc_scrapbot") { } - - class npc_scrapbotAI : ScriptedAI + public override void EnterCombat(Unit who) { - public npc_scrapbotAI(Creature creature) : base(creature) - { - _instance = me.GetInstanceScript(); - } + Talk(Texts.Aggro); + _EnterCombat(); - public override void Reset() + //Enrage + _scheduler.Schedule(TimeSpan.FromMinutes(10), task => { - me.SetReactState(ReactStates.Passive); - Creature pXT002 = ObjectAccessor.GetCreature(me, _instance.GetGuidData(BossIds.Xt002)); - if (pXT002) - me.GetMotionMaster().MoveFollow(pXT002, 0.0f, 0.0f); - } + Talk(Texts.Berserk); + DoCastSelf(SpellIds.Enrage); + }); - public override void MovementInform(MovementGeneratorType type, uint id) + //Gavity Bomb + _scheduler.Schedule(TimeSpan.FromSeconds(20), Misc.PhaseOneGroup, task => { - ObjectGuid guid = _instance.GetGuidData(BossIds.Xt002); - if (type == MovementGeneratorType.Follow && id == guid.GetCounter()) - { - Creature xt002 = ObjectAccessor.GetCreature(me, guid); - if (xt002) + Unit target = SelectTarget(SelectAggroTarget.Random, 0); + if (target) + DoCast(target, SpellIds.GravityBomb); + + task.Repeat(TimeSpan.FromSeconds(20)); + }); + + //Searing Light + _scheduler.Schedule(TimeSpan.FromSeconds(20), Misc.PhaseOneGroup, task => + { + Unit target = SelectTarget(SelectAggroTarget.Random, 0); + if (target) + DoCast(target, SpellIds.SearingLight); + + task.Repeat(TimeSpan.FromSeconds(20)); + }); + + //Tympanic Tantrum + _scheduler.Schedule(TimeSpan.FromSeconds(30), Misc.PhaseOneGroup, task => + { + Talk(Texts.TympanicTantrum); + Talk(Texts.EmoteTympanicTantrum); + DoCast(SpellIds.TympanicTantrum); + task.Repeat(TimeSpan.FromSeconds(30)); + }); + + instance.DoStartCriteriaTimer(CriteriaTimedTypes.Event, Misc.AchievMustDeconstructFaster); + } + + public override void DoAction(int action) + { + switch (action) + { + case Misc.ActionHardMode: + _scheduler.Schedule(TimeSpan.FromMilliseconds(1), task => { - if (me.IsWithinMeleeRange(xt002)) - { - DoCast(xt002, SpellIds.ScrapbotRideVehicle); - // Unapply vehicle aura again - xt002.RemoveAurasDueToSpell(SpellIds.ScrapbotRideVehicle); - me.DespawnOrUnsummon(); - } + SetPhaseOne(true); + }); + break; + } + } + + public override void KilledUnit(Unit who) + { + if (who.GetTypeId() == TypeId.Player) + Talk(Texts.Slay); + } + + public override void JustDied(Unit killer) + { + Talk(Texts.Death); + _JustDied(); + me.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable); + } + + public override void DamageTaken(Unit attacker, ref uint damage) + { + if (!_hardMode && !me.HasReactState(ReactStates.Passive) && !HealthAbovePct(100 - 25 * (_heartExposed + 1))) + ExposeHeart(); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _scheduler.Update(diff); + + if (!me.HasReactState(ReactStates.Passive)) + DoMeleeAttackIfReady(); + } + + public override void PassengerBoarded(Unit who, sbyte seatId, bool apply) + { + if (apply && who.GetEntry() == InstanceCreatureIds.XS013Scrapbot) + { + // Need this so we can properly determine when to expose heart again in damagetaken hook + if (me.GetHealthPct() > (25 * (4 - _heartExposed))) + ++_heartExposed; + + Talk(Texts.EmoteScrapbot); + DoCast(who, SpellIds.ScrapRepair, true); + _healthRecovered = true; + } + + if (apply && seatId == Misc.SeatHeartExposed) + who.CastSpell(who, SpellIds.ExposedHeart); // Channeled + } + + public override uint GetData(uint type) + { + switch (type) + { + case XT002Data.HardMode: + return _hardMode ? 1 : 0u; + case XT002Data.HealthRecovered: + return _healthRecovered ? 1 : 0u; + case XT002Data.GravityBombCasualty: + return _gravityBombCasualty ? 1 : 0u; + } + + return 0; + } + + public override void SetData(uint type, uint data) + { + switch (type) + { + case XT002Data.TransferedHealth: + _transferHealth = data; + break; + case XT002Data.GravityBombCasualty: + _gravityBombCasualty = (data > 0) ? true : false; + break; + } + } + + void ExposeHeart() + { + Talk(Texts.HeartOpened); + Talk(Texts.EmoteHeartOpened); + + DoCastSelf(SpellIds.Submerge); // WIll make creature untargetable + me.AttackStop(); + me.SetReactState(ReactStates.Passive); + + Unit heart = me.GetVehicleKit() ? me.GetVehicleKit().GetPassenger(Misc.SeatHeartNormal) : null; + if (heart) + { + heart.CastSpell(heart, SpellIds.HeartOverload); + heart.CastSpell(me, SpellIds.HeartLightningTether); + heart.CastSpell(heart, SpellIds.HeartHealToFull, true); + heart.CastSpell(me, SpellIds.RideVehicleExposed, true); + heart.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable); + heart.SetFlag(UnitFields.Flags, UnitFlags.Unk29); + } + _scheduler.DelayGroup(Misc.PhaseOneGroup, TimeSpan.FromSeconds(30)); + + // Start "end of phase 2 timer" + _scheduler.Schedule(TimeSpan.FromSeconds(30), task => { SetPhaseOne(false); }); + + _heartExposed++; + } + + void SetPhaseOne(bool isHardMode) + { + if (isHardMode) + { + me.SetFullHealth(); + DoCastSelf(SpellIds.Heartbreak, true); + me.AddLootMode(LootModes.HardMode1); + _hardMode = true; + } + + Talk(Texts.HeartClosed); + Talk(Texts.EmoteHeartClosed); + + me.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable); + me.SetReactState(ReactStates.Aggressive); + DoCastSelf(SpellIds.Stand); + + //_events.RescheduleEvent(EVENT_SEARING_LIGHT, TIMER_SEARING_LIGHT / 2); + //_events.RescheduleEvent(EVENT_GRAVITY_BOMB, TIMER_GRAVITY_BOMB); + //_events.RescheduleEvent(EVENT_TYMPANIC_TANTRUM, RandomHelper.URand(TIMER_TYMPANIC_TANTRUM_MIN, TIMER_TYMPANIC_TANTRUM_MAX)); + + Unit heart = me.GetVehicleKit() ? me.GetVehicleKit().GetPassenger(Misc.SeatHeartExposed) : null; + if (!heart) + return; + + heart.CastSpell(me, SpellIds.HeartRideVehicle, true); + heart.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable); + heart.RemoveFlag(UnitFields.Flags, UnitFlags.Unk29); + heart.RemoveAurasDueToSpell(SpellIds.ExposedHeart); + + if (!_hardMode) + { + if (_transferHealth == 0) + _transferHealth = (uint)(heart.GetMaxHealth() - heart.GetHealth()); + + if (_transferHealth >= me.GetHealth()) + _transferHealth = (uint)me.GetHealth() - 1; + + me.ModifyHealth(-(int)_transferHealth); + me.LowerPlayerDamageReq(_transferHealth); + } + } + + // Achievement related + bool _healthRecovered; // Did a scrapbot recover XT-002's health during the encounter? + bool _hardMode; // Are we in hard mode? Or: was the heart killed during phase 2? + bool _gravityBombCasualty; // Did someone die because of Gravity Bomb damage? + + byte _heartExposed; + uint _transferHealth; + } + + [Script] + class npc_xt002_heart : ScriptedAI + { + public npc_xt002_heart(Creature creature) : base(creature) + { + _instance = creature.GetInstanceScript(); + + SetCombatMovement(false); + } + + public override void UpdateAI(uint diff) { } + + public override void JustDied(Unit killer) + { + Creature xt002 = _instance != null ? ObjectAccessor.GetCreature(me, _instance.GetGuidData(BossIds.Xt002)) : null; + if (!xt002 || xt002.GetAI() == null) + return; + + xt002.GetAI().SetData(XT002Data.TransferedHealth, (uint)me.GetHealth()); + xt002.GetAI().DoAction(Misc.ActionHardMode); + } + + InstanceScript _instance; + } + + [Script] + class npc_scrapbot : ScriptedAI + { + public npc_scrapbot(Creature creature) : base(creature) + { + _instance = me.GetInstanceScript(); + } + + public override void Reset() + { + me.SetReactState(ReactStates.Passive); + Creature pXT002 = ObjectAccessor.GetCreature(me, _instance.GetGuidData(BossIds.Xt002)); + if (pXT002) + me.GetMotionMaster().MoveFollow(pXT002, 0.0f, 0.0f); + } + + public override void MovementInform(MovementGeneratorType type, uint id) + { + ObjectGuid guid = _instance.GetGuidData(BossIds.Xt002); + if (type == MovementGeneratorType.Follow && id == guid.GetCounter()) + { + Creature xt002 = ObjectAccessor.GetCreature(me, guid); + if (xt002) + { + if (me.IsWithinMeleeRange(xt002)) + { + DoCast(xt002, SpellIds.ScrapbotRideVehicle); + // Unapply vehicle aura again + xt002.RemoveAurasDueToSpell(SpellIds.ScrapbotRideVehicle); + me.DespawnOrUnsummon(); } } } - - InstanceScript _instance; } - public override CreatureAI GetAI(Creature creature) - { - return GetInstanceAI(creature); - } + InstanceScript _instance; } [Script] - class npc_pummeller : CreatureScript + class npc_pummeller : ScriptedAI { - public npc_pummeller() : base("npc_pummeller") { } - - class npc_pummellerAI : ScriptedAI + public npc_pummeller(Creature creature) : base(creature) { - public npc_pummellerAI(Creature creature) : base(creature) - { - Initialize(); - _instance = creature.GetInstanceScript(); - } - - void Initialize() - { - _scheduler.SetValidator(() => me.IsWithinMeleeRange(me.GetVictim())); - - //Arcing Smash - _scheduler.Schedule(TimeSpan.FromSeconds(27), task => - { - DoCastVictim(SpellIds.ArcingSmash); - task.Repeat(TimeSpan.FromSeconds(27)); - }); - - //Trample - _scheduler.Schedule(TimeSpan.FromSeconds(22), task => - { - DoCastVictim(SpellIds.Trample); - task.Repeat(TimeSpan.FromSeconds(22)); - }); - - //Uppercut - _scheduler.Schedule(TimeSpan.FromSeconds(17), task => - { - DoCastVictim(SpellIds.Uppercut); - task.Repeat(TimeSpan.FromSeconds(17)); - }); - } - - public override void Reset() - { - Initialize(); - Creature xt002 = ObjectAccessor.GetCreature(me, _instance.GetGuidData(BossIds.Xt002)); - if (xt002) - { - Position pos = xt002.GetPosition(); - me.GetMotionMaster().MovePoint(0, pos); - } - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _scheduler.Update(diff); - - DoMeleeAttackIfReady(); - } - - InstanceScript _instance; + Initialize(); + _instance = creature.GetInstanceScript(); } - public override CreatureAI GetAI(Creature creature) + void Initialize() { - return GetInstanceAI(creature); + _scheduler.SetValidator(() => me.IsWithinMeleeRange(me.GetVictim())); + + //Arcing Smash + _scheduler.Schedule(TimeSpan.FromSeconds(27), task => + { + DoCastVictim(SpellIds.ArcingSmash); + task.Repeat(TimeSpan.FromSeconds(27)); + }); + + //Trample + _scheduler.Schedule(TimeSpan.FromSeconds(22), task => + { + DoCastVictim(SpellIds.Trample); + task.Repeat(TimeSpan.FromSeconds(22)); + }); + + //Uppercut + _scheduler.Schedule(TimeSpan.FromSeconds(17), task => + { + DoCastVictim(SpellIds.Uppercut); + task.Repeat(TimeSpan.FromSeconds(17)); + }); } + + public override void Reset() + { + Initialize(); + Creature xt002 = ObjectAccessor.GetCreature(me, _instance.GetGuidData(BossIds.Xt002)); + if (xt002) + { + Position pos = xt002.GetPosition(); + me.GetMotionMaster().MovePoint(0, pos); + } + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + _scheduler.Update(diff); + + DoMeleeAttackIfReady(); + } + + InstanceScript _instance; } class BoomEvent : BasicEvent @@ -548,435 +508,335 @@ namespace Scripts.Northrend.Ulduar.Xt002 } [Script] - class npc_boombot : CreatureScript + class npc_boombot : ScriptedAI { - public npc_boombot() : base("npc_boombot") { } - - class npc_boombotAI : ScriptedAI + public npc_boombot(Creature creature) : base(creature) { - public npc_boombotAI(Creature creature) : base(creature) - { - Initialize(); - _instance = creature.GetInstanceScript(); - } - - void Initialize() - { - _boomed = false; - } - - public override void Reset() - { - Initialize(); - - DoCast(SpellIds.AuraBoombot); // For achievement - - // HACK/workaround: - // these values aren't confirmed - lack of data - and the values in DB are incorrect - // these values are needed for correct damage of Boom spell - me.SetFloatValue(UnitFields.MinDamage, 15000.0f); - me.SetFloatValue(UnitFields.MaxDamage, 18000.0f); - - // @todo proper waypoints? - Creature pXT002 = ObjectAccessor.GetCreature(me, _instance.GetGuidData(BossIds.Xt002)); - if (pXT002) - me.GetMotionMaster().MoveFollow(pXT002, 0.0f, 0.0f); - } - - public override void DamageTaken(Unit who, ref uint damage) - { - if (damage >= (me.GetHealth() - me.GetMaxHealth() * 0.5f) && !_boomed) - { - _boomed = true; // Prevent recursive calls - - //me.SendSpellInstakillLog(Spells.Boom, me); - - //me.DealDamage(me, me.GetHealth(), null, DamageEffectType.NoDamage, SpellSchoolMask.Normal, null, false); - - damage = 0; - - me.CastSpell(me, SpellIds.Boom, false); - - // Visual only seems to work if the instant kill event is delayed or the spell itself is delayed - // Casting done from player and caster source has the same targetinfo flags, - // so that can't be the issue - // See BoomEvent class - // Schedule 1s delayed - //me.m_Events.AddEvent(new BoomEvent(me), me.m_Events.CalculateTime(1 * Time.InMilliseconds)); - } - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - // No melee attack - } - - InstanceScript _instance; - bool _boomed; + Initialize(); + _instance = creature.GetInstanceScript(); } - public override CreatureAI GetAI(Creature creature) + void Initialize() { - return GetInstanceAI(creature); + _boomed = false; + } + + public override void Reset() + { + Initialize(); + + DoCast(SpellIds.AuraBoombot); // For achievement + + // HACK/workaround: + // these values aren't confirmed - lack of data - and the values in DB are incorrect + // these values are needed for correct damage of Boom spell + me.SetFloatValue(UnitFields.MinDamage, 15000.0f); + me.SetFloatValue(UnitFields.MaxDamage, 18000.0f); + + // @todo proper waypoints? + Creature pXT002 = ObjectAccessor.GetCreature(me, _instance.GetGuidData(BossIds.Xt002)); + if (pXT002) + me.GetMotionMaster().MoveFollow(pXT002, 0.0f, 0.0f); + } + + public override void DamageTaken(Unit who, ref uint damage) + { + if (damage >= (me.GetHealth() - me.GetMaxHealth() * 0.5f) && !_boomed) + { + _boomed = true; // Prevent recursive calls + + //me.SendSpellInstakillLog(Spells.Boom, me); + + //me.DealDamage(me, me.GetHealth(), null, DamageEffectType.NoDamage, SpellSchoolMask.Normal, null, false); + + damage = 0; + + me.CastSpell(me, SpellIds.Boom, false); + + // Visual only seems to work if the instant kill event is delayed or the spell itself is delayed + // Casting done from player and caster source has the same targetinfo flags, + // so that can't be the issue + // See BoomEvent class + // Schedule 1s delayed + //me.m_Events.AddEvent(new BoomEvent(me), me.m_Events.CalculateTime(1 * Time.InMilliseconds)); + } + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + // No melee attack + } + + InstanceScript _instance; + bool _boomed; + } + + [Script] + class npc_life_spark : ScriptedAI + { + public npc_life_spark(Creature creature) : base(creature) { } + + void Initialize() + { + _scheduler.Schedule(TimeSpan.FromMilliseconds(1), task => + { + DoCastVictim(SpellIds.Shock); + task.Repeat(TimeSpan.FromSeconds(12)); + }); + } + + public override void Reset() + { + DoCastSelf(SpellIds.ArcanePowerState); + _scheduler.CancelAll(); + } + + public override void EnterCombat(Unit victim) + { + DoCastSelf(SpellIds.StaticCharged); + _scheduler.Schedule(TimeSpan.FromSeconds(12), task => + { + DoCastVictim(SpellIds.Shock); + task.Repeat(); + }); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + if (me.HasUnitState(UnitState.Casting)) + return; + + _scheduler.Update(diff, DoMeleeAttackIfReady); } } [Script] - class npc_life_spark : CreatureScript + class npc_xt_void_zone : PassiveAI { - public npc_life_spark() : base("npc_life_spark") { } + public npc_xt_void_zone(Creature creature) : base(creature) { } - class npc_life_sparkAI : ScriptedAI + public override void Reset() { - public npc_life_sparkAI(Creature creature) : base(creature) { } - - void Initialize() + _scheduler.Schedule(TimeSpan.FromSeconds(1), consumption => { - _scheduler.Schedule(TimeSpan.FromMilliseconds(1), task => - { - DoCastVictim(SpellIds.Shock); - task.Repeat(TimeSpan.FromSeconds(12)); - }); - } - - public override void Reset() - { - DoCastSelf(SpellIds.ArcanePowerState); - _scheduler.CancelAll(); - } - - public override void EnterCombat(Unit victim) - { - DoCastSelf(SpellIds.StaticCharged); - _scheduler.Schedule(TimeSpan.FromSeconds(12), task => - { - DoCastVictim(SpellIds.Shock); - task.Repeat(); - }); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - if (me.HasUnitState(UnitState.Casting)) - return; - - _scheduler.Update(diff, DoMeleeAttackIfReady); - } + DoCastSelf(SpellIds.Consumption); + consumption.Repeat(); + }); } - public override CreatureAI GetAI(Creature creature) + public override void UpdateAI(uint diff) { - return new npc_life_sparkAI(creature); + _scheduler.Update(diff); } } [Script] - class npc_xt_void_zone : CreatureScript + class spell_xt002_searing_light_spawn_life_spark : AuraScript { - public npc_xt_void_zone() : base("npc_xt_void_zone") { } - - class npc_xt_void_zoneAI : PassiveAI + public override bool Validate(SpellInfo spell) { - public npc_xt_void_zoneAI(Creature creature) : base(creature) { } - - public override void Reset() - { - _scheduler.Schedule(TimeSpan.FromSeconds(1), consumption => - { - DoCastSelf(SpellIds.Consumption); - consumption.Repeat(); - }); - } - - public override void UpdateAI(uint diff) - { - _scheduler.Update(diff); - } + return ValidateSpellInfo(SpellIds.SummonLifeSpark); } - public override CreatureAI GetAI(Creature creature) + void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new npc_xt_void_zoneAI(creature); - } - } - - [Script] - class spell_xt002_searing_light_spawn_life_spark : SpellScriptLoader - { - public spell_xt002_searing_light_spawn_life_spark() : base("spell_xt002_searing_light_spawn_life_spark") { } - - class spell_xt002_searing_light_spawn_life_spark_AuraScript : AuraScript - { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.SummonLifeSpark); - } - - void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Player player = GetOwner().ToPlayer(); - if (player) - { - Unit xt002 = GetCaster(); - if (xt002) - if (xt002.HasAura((uint)aurEff.GetAmount())) // Heartbreak aura indicating hard mode - xt002.CastSpell(player, SpellIds.SummonLifeSpark, true); - } - } - - public override void Register() - { - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.PeriodicTriggerSpell, AuraEffectHandleModes.Real)); - } - } - - public override AuraScript GetAuraScript() - { - return new spell_xt002_searing_light_spawn_life_spark_AuraScript(); - } - } - - [Script] - class spell_xt002_gravity_bomb_aura : SpellScriptLoader - { - public spell_xt002_gravity_bomb_aura() : base("spell_xt002_gravity_bomb_aura") { } - - class spell_xt002_gravity_bomb_aura_AuraScript : AuraScript - { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.SummonVoidZone); - } - - void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Player player = GetOwner().ToPlayer(); - if (player) - { - Unit xt002 = GetCaster(); - if (xt002) - if (xt002.HasAura((uint)aurEff.GetAmount())) // Heartbreak aura indicating hard mode - xt002.CastSpell(player, SpellIds.SummonVoidZone, true); - } - } - - void OnPeriodic(AuraEffect aurEff) + Player player = GetOwner().ToPlayer(); + if (player) { Unit xt002 = GetCaster(); - if (!xt002) - return; - - Unit owner = GetOwner().ToUnit(); - if (!owner) - return; - - if ((uint)aurEff.GetAmount() >= owner.GetHealth()) - if (xt002.GetAI() != null) - xt002.GetAI().SetData(XT002Data.GravityBombCasualty, 1); - } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(OnPeriodic, 2, AuraType.PeriodicDamage)); - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.PeriodicTriggerSpell, AuraEffectHandleModes.Real)); + if (xt002) + if (xt002.HasAura((uint)aurEff.GetAmount())) // Heartbreak aura indicating hard mode + xt002.CastSpell(player, SpellIds.SummonLifeSpark, true); } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_xt002_gravity_bomb_aura_AuraScript(); + AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.PeriodicTriggerSpell, AuraEffectHandleModes.Real)); } } [Script] - class spell_xt002_gravity_bomb_damage : SpellScriptLoader + class spell_xt002_gravity_bomb_aura : AuraScript { - public spell_xt002_gravity_bomb_damage() : base("spell_xt002_gravity_bomb_damage") { } - - class spell_xt002_gravity_bomb_damage_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - void HandleScript(uint eff) - { - Unit caster = GetCaster(); - if (!caster) - return; + return ValidateSpellInfo(SpellIds.SummonVoidZone); + } - if ((uint)GetHitDamage() >= GetHitUnit().GetHealth()) - if (caster.GetAI() != null) - caster.GetAI().SetData(XT002Data.GravityBombCasualty, 1); - } - - public override void Register() + void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Player player = GetOwner().ToPlayer(); + if (player) { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.SchoolDamage)); + Unit xt002 = GetCaster(); + if (xt002) + if (xt002.HasAura((uint)aurEff.GetAmount())) // Heartbreak aura indicating hard mode + xt002.CastSpell(player, SpellIds.SummonVoidZone, true); } } - public override SpellScript GetSpellScript() + void OnPeriodic(AuraEffect aurEff) { - return new spell_xt002_gravity_bomb_damage_SpellScript(); + Unit xt002 = GetCaster(); + if (!xt002) + return; + + Unit owner = GetOwner().ToUnit(); + if (!owner) + return; + + if ((uint)aurEff.GetAmount() >= owner.GetHealth()) + if (xt002.GetAI() != null) + xt002.GetAI().SetData(XT002Data.GravityBombCasualty, 1); + } + + public override void Register() + { + OnEffectPeriodic.Add(new EffectPeriodicHandler(OnPeriodic, 2, AuraType.PeriodicDamage)); + AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.PeriodicTriggerSpell, AuraEffectHandleModes.Real)); } } [Script] - class spell_xt002_heart_overload_periodic : SpellScriptLoader + class spell_xt002_gravity_bomb_damage : SpellScript { - public spell_xt002_heart_overload_periodic() : base("spell_xt002_heart_overload_periodic") { } - - class spell_xt002_heart_overload_periodic_SpellScript : SpellScript + void HandleScript(uint eff) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.EnergyOrb, SpellIds.RechargeBoombot, SpellIds.RechargePummeler, SpellIds.RechargeScrapbot); - } + Unit caster = GetCaster(); + if (!caster) + return; - void HandleScript(uint effIndex) + if ((uint)GetHitDamage() >= GetHitUnit().GetHealth()) + if (caster.GetAI() != null) + caster.GetAI().SetData(XT002Data.GravityBombCasualty, 1); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.SchoolDamage)); + } + } + + [Script] + class spell_xt002_heart_overload_periodic : SpellScript + { + public override bool Validate(SpellInfo spell) + { + return ValidateSpellInfo(SpellIds.EnergyOrb, SpellIds.RechargeBoombot, SpellIds.RechargePummeler, SpellIds.RechargeScrapbot); + } + + void HandleScript(uint effIndex) + { + Unit caster = GetCaster(); + if (caster) { - Unit caster = GetCaster(); - if (caster) + InstanceScript instance = caster.GetInstanceScript(); + if (instance != null) { - InstanceScript instance = caster.GetInstanceScript(); - if (instance != null) + Unit toyPile = Global.ObjAccessor.GetUnit(caster, instance.GetGuidData(InstanceData.ToyPile0 + RandomHelper.URand(0, 3))); + if (toyPile) { - Unit toyPile = Global.ObjAccessor.GetUnit(caster, instance.GetGuidData(InstanceData.ToyPile0 + RandomHelper.URand(0, 3))); - if (toyPile) + caster.CastSpell(toyPile, SpellIds.EnergyOrb, true); + + // This should probably be incorporated in a dummy effect handler, but I've had trouble getting the correct target + // Weighed randomization (approximation) + uint[] spells = { SpellIds.RechargeScrapbot, SpellIds.RechargeScrapbot, SpellIds.RechargeScrapbot, SpellIds.RechargePummeler, SpellIds.RechargeBoombot }; + + for (byte i = 0; i < 5; ++i) { - caster.CastSpell(toyPile, SpellIds.EnergyOrb, true); - - // This should probably be incorporated in a dummy effect handler, but I've had trouble getting the correct target - // Weighed randomization (approximation) - uint[] spells = { SpellIds.RechargeScrapbot, SpellIds.RechargeScrapbot, SpellIds.RechargeScrapbot, SpellIds.RechargePummeler, SpellIds.RechargeBoombot }; - - for (byte i = 0; i < 5; ++i) - { - uint spellId = spells[RandomHelper.IRand(0, 4)]; - toyPile.CastSpell(toyPile, spellId, true, null, null, instance.GetGuidData(BossIds.Xt002)); - } + uint spellId = spells[RandomHelper.IRand(0, 4)]; + toyPile.CastSpell(toyPile, spellId, true, null, null, instance.GetGuidData(BossIds.Xt002)); } } - - Creature creatureBase = caster.GetVehicleCreatureBase(); - if (creatureBase) - creatureBase.GetAI().Talk(Texts.Summon); } - } - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleScript, 0, SpellEffectName.Dummy)); + Creature creatureBase = caster.GetVehicleCreatureBase(); + if (creatureBase) + creatureBase.GetAI().Talk(Texts.Summon); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_xt002_heart_overload_periodic_SpellScript(); + OnEffectHit.Add(new EffectHandler(HandleScript, 0, SpellEffectName.Dummy)); } } [Script] - class spell_xt002_tympanic_tantrum : SpellScriptLoader + class spell_xt002_tympanic_tantrum : SpellScript { - public spell_xt002_tympanic_tantrum() : base("spell_xt002_tympanic_tantrum") { } - - class spell_xt002_tympanic_tantrum_SpellScript : SpellScript + void FilterTargets(List targets) { - void FilterTargets(List targets) - { - targets.RemoveAll(new PlayerOrPetCheck()); - } - - void RecalculateDamage() - { - SetHitDamage((int)GetHitUnit().CountPctFromMaxHealth(GetHitDamage())); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEnemy)); - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 1, Targets.UnitSrcAreaEnemy)); - OnHit.Add(new HitHandler(RecalculateDamage)); - } + targets.RemoveAll(new PlayerOrPetCheck()); } - public override SpellScript GetSpellScript() + void RecalculateDamage() { - return new spell_xt002_tympanic_tantrum_SpellScript(); + SetHitDamage((int)GetHitUnit().CountPctFromMaxHealth(GetHitDamage())); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEnemy)); + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 1, Targets.UnitSrcAreaEnemy)); + OnHit.Add(new HitHandler(RecalculateDamage)); } } [Script] - class spell_xt002_submerged : SpellScriptLoader + class spell_xt002_submerged : SpellScript { - public spell_xt002_submerged() : base("spell_xt002_submerged") { } - - class spell_xt002_submerged_SpellScript : SpellScript + void HandleScript(uint eff) { - void HandleScript(uint eff) - { - Creature target = GetHitCreature(); - if (!target) - return; + Creature target = GetHitCreature(); + if (!target) + return; - target.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable); - target.SetStandState(UnitStandStateType.Submerged); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } + target.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable); + target.SetStandState(UnitStandStateType.Submerged); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_xt002_submerged_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] - class spell_xt002_321_boombot_aura : SpellScriptLoader + class spell_xt002_321_boombot_aura : AuraScript { - public spell_xt002_321_boombot_aura() : base("spell_xt002_321_boombot_aura") { } - - class spell_xt002_321_boombot_aura_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.AchievementCreditNerfScrapbots); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - if (eventInfo.GetActionTarget().GetEntry() != InstanceCreatureIds.XS013Scrapbot) - return false; - return true; - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - InstanceScript instance = eventInfo.GetActor().GetInstanceScript(); - if (instance == null) - return; - - instance.DoCastSpellOnPlayers(SpellIds.AchievementCreditNerfScrapbots); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.AchievementCreditNerfScrapbots); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_xt002_321_boombot_aura_AuraScript(); + if (eventInfo.GetActionTarget().GetEntry() != InstanceCreatureIds.XS013Scrapbot) + return false; + return true; + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + InstanceScript instance = eventInfo.GetActor().GetInstanceScript(); + if (instance == null) + return; + + instance.DoCastSpellOnPlayers(SpellIds.AchievementCreditNerfScrapbots); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } diff --git a/Scripts/Northrend/Ulduar/YoggSaron.cs b/Scripts/Northrend/Ulduar/YoggSaron.cs index 6a6fe0097..ae7c6cd29 100644 --- a/Scripts/Northrend/Ulduar/YoggSaron.cs +++ b/Scripts/Northrend/Ulduar/YoggSaron.cs @@ -29,7 +29,7 @@ namespace Scripts.Northrend.Ulduar new Position(2028.766f, 17.42014f, 411.4446f, 3.857178f), // Mimiron }; public static Position[] YSKeepersPos = - { + { new Position(2036.873f, 25.42513f, 338.4984f, 3.909538f), // Freya new Position(1939.045f, -90.87457f, 338.5426f, 0.994837f), // Hodir new Position(1939.148f, 42.49035f, 338.5427f, 5.235988f), // Thorim diff --git a/Scripts/Northrend/WinterGrasp.cs b/Scripts/Northrend/WinterGrasp.cs index 5c5ac0898..8719232b6 100644 --- a/Scripts/Northrend/WinterGrasp.cs +++ b/Scripts/Northrend/WinterGrasp.cs @@ -24,65 +24,45 @@ using Game.Scripting; namespace Scripts.Northrend { [Script] - class spell_wintergrasp_defender_teleport : SpellScriptLoader + class spell_wintergrasp_defender_teleport : SpellScript { - public spell_wintergrasp_defender_teleport() : base("spell_wintergrasp_defender_teleport") { } - - class spell_wintergrasp_defender_teleport_SpellScript : SpellScript + SpellCastResult CheckCast() { - SpellCastResult CheckCast() + BattleField wg = Global.BattleFieldMgr.GetBattlefieldByBattleId(1); + if (wg != null) { - BattleField wg = Global.BattleFieldMgr.GetBattlefieldByBattleId(1); - if (wg != null) - { - Player target = GetExplTargetUnit().ToPlayer(); - if (target) - // check if we are in Wintergrasp at all, SotA uses same teleport spells - if ((target.GetZoneId() == 4197 && target.GetTeamId() != wg.GetDefenderTeam()) || target.HasAura(54643)) - return SpellCastResult.BadTargets; - } - - return SpellCastResult.SpellCastOk; + Player target = GetExplTargetUnit().ToPlayer(); + if (target) + // check if we are in Wintergrasp at all, SotA uses same teleport spells + if ((target.GetZoneId() == 4197 && target.GetTeamId() != wg.GetDefenderTeam()) || target.HasAura(54643)) + return SpellCastResult.BadTargets; } - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - } + return SpellCastResult.SpellCastOk; } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_wintergrasp_defender_teleport_SpellScript(); + OnCheckCast.Add(new CheckCastHandler(CheckCast)); } } [Script] - class spell_wintergrasp_defender_teleport_trigger : SpellScriptLoader + class spell_wintergrasp_defender_teleport_trigger : SpellScript { - public spell_wintergrasp_defender_teleport_trigger() : base("spell_wintergrasp_defender_teleport_trigger") { } - - class spell_wintergrasp_defender_teleport_trigger_SpellScript : SpellScript + void HandleDummy(uint effindex) { - void HandleDummy(uint effindex) + Unit target = GetHitUnit(); + if (target) { - Unit target = GetHitUnit(); - if (target) - { - WorldLocation loc = target.GetWorldLocation(); - SetExplTargetDest(loc); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + WorldLocation loc = target.GetWorldLocation(); + SetExplTargetDest(loc); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_wintergrasp_defender_teleport_trigger_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } diff --git a/Scripts/Outlands/HellfirePeninsula.cs b/Scripts/Outlands/HellfirePeninsula.cs index 67f39f602..3d1f96959 100644 --- a/Scripts/Outlands/HellfirePeninsula.cs +++ b/Scripts/Outlands/HellfirePeninsula.cs @@ -36,81 +36,71 @@ namespace Scripts.Outlands } [Script] - class npc_aeranas : CreatureScript + class npc_aeranas : ScriptedAI { - public npc_aeranas() : base("npc_aeranas") { } + public npc_aeranas(Creature creature) : base(creature) { } - class npc_aeranasAI : ScriptedAI + public override void Reset() { - public npc_aeranasAI(Creature creature) : base(creature) { } + faction_Timer = 8000; + envelopingWinds_Timer = 9000; + shock_Timer = 5000; - public override void Reset() + me.RemoveFlag64(UnitFields.NpcFlags, NPCFlags.QuestGiver); + me.SetFaction(Aeranas.FactionFriendly); + + Talk(Aeranas.SaySummon); + } + + public override void UpdateAI(uint diff) + { + if (faction_Timer != 0) { - faction_Timer = 8000; - envelopingWinds_Timer = 9000; - shock_Timer = 5000; + if (faction_Timer <= diff) + { + me.SetFaction(Aeranas.FactionHostile); + faction_Timer = 0; + } + else + faction_Timer -= diff; + } - me.RemoveFlag64(UnitFields.NpcFlags, NPCFlags.QuestGiver); + if (!UpdateVictim()) + return; + + if (HealthBelowPct(30)) + { me.SetFaction(Aeranas.FactionFriendly); - - Talk(Aeranas.SaySummon); + me.SetFlag64(UnitFields.NpcFlags, NPCFlags.QuestGiver); + me.RemoveAllAuras(); + me.DeleteThreatList(); + me.CombatStop(true); + Talk(Aeranas.SayFree); + return; } - public override void UpdateAI(uint diff) + if (shock_Timer <= diff) { - if (faction_Timer != 0) - { - if (faction_Timer <= diff) - { - me.SetFaction(Aeranas.FactionHostile); - faction_Timer = 0; - } - else - faction_Timer -= diff; - } - - if (!UpdateVictim()) - return; - - if (HealthBelowPct(30)) - { - me.SetFaction(Aeranas.FactionFriendly); - me.SetFlag64(UnitFields.NpcFlags, NPCFlags.QuestGiver); - me.RemoveAllAuras(); - me.DeleteThreatList(); - me.CombatStop(true); - Talk(Aeranas.SayFree); - return; - } - - if (shock_Timer <= diff) - { - DoCastVictim(Aeranas.SpellShock); - shock_Timer = 10000; - } - else - shock_Timer -= diff; - - if (envelopingWinds_Timer <= diff) - { - DoCastVictim(Aeranas.SpellEncelopingWinds); - envelopingWinds_Timer = 25000; - } - else - envelopingWinds_Timer -= diff; - - DoMeleeAttackIfReady(); + DoCastVictim(Aeranas.SpellShock); + shock_Timer = 10000; } + else + shock_Timer -= diff; - uint faction_Timer; - uint envelopingWinds_Timer; - uint shock_Timer; + if (envelopingWinds_Timer <= diff) + { + DoCastVictim(Aeranas.SpellEncelopingWinds); + envelopingWinds_Timer = 25000; + } + else + envelopingWinds_Timer -= diff; + + DoMeleeAttackIfReady(); } - public override CreatureAI GetAI(Creature creature) - { - return new npc_aeranasAI(creature); - } + uint faction_Timer; + uint envelopingWinds_Timer; + uint shock_Timer; } struct AncestralWolf @@ -125,70 +115,118 @@ namespace Scripts.Outlands } [Script] - class npc_ancestral_wolf : CreatureScript + class npc_ancestral_wolf : npc_escortAI { - public npc_ancestral_wolf() : base("npc_ancestral_wolf") { } - - class npc_ancestral_wolfAI : npc_escortAI + public npc_ancestral_wolf(Creature creature) : base(creature) { - public npc_ancestral_wolfAI(Creature creature) : base(creature) - { - if (creature.GetOwner() && creature.GetOwner().IsTypeId(TypeId.Player)) - Start(false, false, creature.GetOwner().GetGUID()); - else - Log.outError(LogFilter.Scripts, "Scripts: npc_ancestral_wolf can not obtain owner or owner is not a player."); + if (creature.GetOwner() && creature.GetOwner().IsTypeId(TypeId.Player)) + Start(false, false, creature.GetOwner().GetGUID()); + else + Log.outError(LogFilter.Scripts, "Scripts: npc_ancestral_wolf can not obtain owner or owner is not a player."); - creature.SetSpeed(UnitMoveType.Walk, 1.5f); - Reset(); - } - - public override void Reset() - { - ryga = null; - DoCast(me, AncestralWolf.SpellAncestralWoldBuff, true); - } - - public override void MoveInLineOfSight(Unit who) - { - if (!ryga && who.GetEntry() == AncestralWolf.NpcRyga && me.IsWithinDistInMap(who, 15.0f)) - { - Creature temp = who.ToCreature(); - if (temp) - ryga = temp; - } - - base.MoveInLineOfSight(who); - } - - public override void WaypointReached(uint waypointId) - { - switch (waypointId) - { - case 0: - Talk(AncestralWolf.EmoteWoldLiftHead); - break; - case 2: - Talk(AncestralWolf.EmoteWolfHowl); - break; - case 50: - if (ryga && ryga.IsAlive() && !ryga.IsInCombat()) - ryga.GetAI().Talk(AncestralWolf.SayWolfWelcome); - break; - } - } - - Creature ryga; + creature.SetSpeed(UnitMoveType.Walk, 1.5f); + Reset(); } - public override CreatureAI GetAI(Creature creature) + public override void Reset() { - return new npc_ancestral_wolfAI(creature); + ryga = null; + DoCast(me, AncestralWolf.SpellAncestralWoldBuff, true); } + + public override void MoveInLineOfSight(Unit who) + { + if (!ryga && who.GetEntry() == AncestralWolf.NpcRyga && me.IsWithinDistInMap(who, 15.0f)) + { + Creature temp = who.ToCreature(); + if (temp) + ryga = temp; + } + + base.MoveInLineOfSight(who); + } + + public override void WaypointReached(uint waypointId) + { + switch (waypointId) + { + case 0: + Talk(AncestralWolf.EmoteWoldLiftHead); + break; + case 2: + Talk(AncestralWolf.EmoteWolfHowl); + break; + case 50: + if (ryga && ryga.IsAlive() && !ryga.IsInCombat()) + ryga.GetAI().Talk(AncestralWolf.SayWolfWelcome); + break; + } + } + + Creature ryga; } [Script] - class npc_wounded_blood_elf : CreatureScript + class npc_wounded_blood_elf : npc_escortAI { + public npc_wounded_blood_elf(Creature creature) : base(creature) { } + + public override void Reset() { } + + public override void EnterCombat(Unit who) + { + if (HasEscortState(eEscortState.Escorting)) + Talk(SAY_ELF_AGGRO); + } + + public override void JustSummoned(Creature summoned) + { + summoned.GetAI().AttackStart(me); + } + + public override void sQuestAccept(Player player, Quest quest) + { + if (quest.Id == QUEST_ROAD_TO_FALCON_WATCH) + { + me.SetFaction(FACTION_FALCON_WATCH_QUEST); + base.Start(true, false, player.GetGUID()); + } + } + + public override void WaypointReached(uint waypointId) + { + Player player = GetPlayerForEscort(); + if (!player) + return; + + switch (waypointId) + { + case 0: + Talk(SAY_ELF_START, player); + break; + case 9: + Talk(SAY_ELF_SUMMON1, player); + // Spawn two Haal'eshi Talonguard + DoSpawnCreature(NPC_HAALESHI_TALONGUARD, -15, -15, 0, 0, TempSummonType.TimedDespawnOOC, 5000); + DoSpawnCreature(NPC_HAALESHI_TALONGUARD, -17, -17, 0, 0, TempSummonType.TimedDespawnOOC, 5000); + break; + case 13: + Talk(SAY_ELF_RESTING, player); + break; + case 14: + Talk(SAY_ELF_SUMMON2, player); + // Spawn two Haal'eshi Windwalker + DoSpawnCreature(NPC_HAALESHI_WINDWALKER, -15, -15, 0, 0, TempSummonType.TimedDespawnOOC, 5000); + DoSpawnCreature(NPC_HAALESHI_WINDWALKER, -17, -17, 0, 0, TempSummonType.TimedDespawnOOC, 5000); + break; + case 27: + Talk(SAY_ELF_COMPLETE, player); + // Award quest credit + player.GroupEventHappens(QUEST_ROAD_TO_FALCON_WATCH, me); + break; + } + } + const uint SAY_ELF_START = 0; const uint SAY_ELF_SUMMON1 = 1; const uint SAY_ELF_RESTING = 2; @@ -199,142 +237,65 @@ namespace Scripts.Outlands const uint NPC_HAALESHI_WINDWALKER = 16966; const uint NPC_HAALESHI_TALONGUARD = 16967; const uint FACTION_FALCON_WATCH_QUEST = 775; - - public npc_wounded_blood_elf() : base("npc_wounded_blood_elf") { } - - class npc_wounded_blood_elfAI : npc_escortAI - { - public npc_wounded_blood_elfAI(Creature creature) : base(creature) { } - - public override void Reset() { } - - public override void EnterCombat(Unit who) - { - if (HasEscortState(eEscortState.Escorting)) - Talk(SAY_ELF_AGGRO); - } - - public override void JustSummoned(Creature summoned) - { - summoned.GetAI().AttackStart(me); - } - - public override void sQuestAccept(Player player, Quest quest) - { - if (quest.Id == QUEST_ROAD_TO_FALCON_WATCH) - { - me.SetFaction(FACTION_FALCON_WATCH_QUEST); - base.Start(true, false, player.GetGUID()); - } - } - - public override void WaypointReached(uint waypointId) - { - Player player = GetPlayerForEscort(); - if (!player) - return; - - switch (waypointId) - { - case 0: - Talk(SAY_ELF_START, player); - break; - case 9: - Talk(SAY_ELF_SUMMON1, player); - // Spawn two Haal'eshi Talonguard - DoSpawnCreature(NPC_HAALESHI_TALONGUARD, -15, -15, 0, 0, TempSummonType.TimedDespawnOOC, 5000); - DoSpawnCreature(NPC_HAALESHI_TALONGUARD, -17, -17, 0, 0, TempSummonType.TimedDespawnOOC, 5000); - break; - case 13: - Talk(SAY_ELF_RESTING, player); - break; - case 14: - Talk(SAY_ELF_SUMMON2, player); - // Spawn two Haal'eshi Windwalker - DoSpawnCreature(NPC_HAALESHI_WINDWALKER, -15, -15, 0, 0, TempSummonType.TimedDespawnOOC, 5000); - DoSpawnCreature(NPC_HAALESHI_WINDWALKER, -17, -17, 0, 0, TempSummonType.TimedDespawnOOC, 5000); - break; - case 27: - Talk(SAY_ELF_COMPLETE, player); - // Award quest credit - player.GroupEventHappens(QUEST_ROAD_TO_FALCON_WATCH, me); - break; - } - } - } - - public override CreatureAI GetAI(Creature creature) - { - return new npc_wounded_blood_elfAI(creature); - } } + [Script] - class npc_fel_guard_hound : CreatureScript + class npc_fel_guard_hound : ScriptedAI { - const uint SPELL_SUMMON_POO = 37688; - const uint NPC_DERANGED_HELBOAR = 16863; + public npc_fel_guard_hound(Creature creature) : base(creature) { } - public npc_fel_guard_hound() : base("npc_fel_guard_hound") { } - - class npc_fel_guard_houndAI : ScriptedAI + public override void Reset() { - public npc_fel_guard_houndAI(Creature creature) : base(creature) { } + checkTimer = 5000; //check for creature every 5 sec + helboarGUID.Clear(); + } - public override void Reset() + public override void MovementInform(MovementGeneratorType type, uint id) + { + if (type != MovementGeneratorType.Point || id != 1) + return; + + Creature helboar = me.GetMap().GetCreature(helboarGUID); + if (helboar) { - checkTimer = 5000; //check for creature every 5 sec - helboarGUID.Clear(); + helboar.RemoveCorpse(); + DoCast(SPELL_SUMMON_POO); + + Player owner = me.GetCharmerOrOwnerPlayerOrPlayerItself(); + if (owner) + me.GetMotionMaster().MoveFollow(owner, 0.0f, 0.0f); } + } - public override void MovementInform(MovementGeneratorType type, uint id) + public override void UpdateAI(uint diff) + { + if (checkTimer <= diff) { - if (type != MovementGeneratorType.Point || id != 1) - return; - - Creature helboar = me.GetMap().GetCreature(helboarGUID); + Creature helboar = me.FindNearestCreature(NPC_DERANGED_HELBOAR, 10.0f, false); if (helboar) { - helboar.RemoveCorpse(); - DoCast(SPELL_SUMMON_POO); - - Player owner = me.GetCharmerOrOwnerPlayerOrPlayerItself(); - if (owner) - me.GetMotionMaster().MoveFollow(owner, 0.0f, 0.0f); - } - } - - public override void UpdateAI(uint diff) - { - if (checkTimer <= diff) - { - Creature helboar = me.FindNearestCreature(NPC_DERANGED_HELBOAR, 10.0f, false); - if (helboar) + if (helboar.GetGUID() != helboarGUID && me.GetMotionMaster().GetCurrentMovementGeneratorType() != MovementGeneratorType.Point && !me.FindCurrentSpellBySpellId(SPELL_SUMMON_POO)) { - if (helboar.GetGUID() != helboarGUID && me.GetMotionMaster().GetCurrentMovementGeneratorType() != MovementGeneratorType.Point && !me.FindCurrentSpellBySpellId(SPELL_SUMMON_POO)) - { - helboarGUID = helboar.GetGUID(); - me.GetMotionMaster().MovePoint(1, helboar.GetPositionX(), helboar.GetPositionY(), helboar.GetPositionZ()); - } + helboarGUID = helboar.GetGUID(); + me.GetMotionMaster().MovePoint(1, helboar.GetPositionX(), helboar.GetPositionY(), helboar.GetPositionZ()); } - checkTimer = 5000; } - else checkTimer -= diff; - - if (!UpdateVictim()) - return; - - DoMeleeAttackIfReady(); + checkTimer = 5000; } + else checkTimer -= diff; - uint checkTimer; - ObjectGuid helboarGUID; + if (!UpdateVictim()) + return; + + DoMeleeAttackIfReady(); } - public override CreatureAI GetAI(Creature creature) - { - return new npc_fel_guard_houndAI(creature); - } + uint checkTimer; + ObjectGuid helboarGUID; + + const uint SPELL_SUMMON_POO = 37688; + const uint NPC_DERANGED_HELBOAR = 16863; } } diff --git a/Scripts/Outlands/Zangarmarsh.cs b/Scripts/Outlands/Zangarmarsh.cs index 7746543fb..11fb3fba9 100644 --- a/Scripts/Outlands/Zangarmarsh.cs +++ b/Scripts/Outlands/Zangarmarsh.cs @@ -140,8 +140,7 @@ namespace Scripts.Outlands class npc_cooshcooshAI : ScriptedAI { - public npc_cooshcooshAI(Creature creature) - : base(creature) + public npc_cooshcooshAI(Creature creature) : base(creature) { m_uiNormFaction = creature.getFaction(); } @@ -263,32 +262,6 @@ namespace Scripts.Outlands const string GOSSIP_ITEM_KUR3 = "I will tell them. Farewell, elder."; } - [Script] - class npc_mortog_steamhead : CreatureScript - { - public npc_mortog_steamhead() : base("npc_mortog_steamhead") { } - - public override bool OnGossipHello(Player player, Creature creature) - { - if (creature.IsVendor() && player.GetReputationRank(942) == ReputationRank.Exalted) - player.ADD_GOSSIP_ITEM(GossipOptionIcon.Vendor, GOSSIP_TEXT_BROWSE_GOODS, eTradeskill.GossipSenderMain, eTradeskill.GossipActionTrade); - - player.SEND_GOSSIP_MENU(player.GetGossipTextId(creature), creature.GetGUID()); - - return true; - } - - public override bool OnGossipSelect(Player player, Creature creature, uint sender, uint action) - { - player.PlayerTalkClass.ClearMenus(); - if (action == eTradeskill.GossipActionTrade) - player.GetSession().SendListInventory(creature.GetGUID()); - return true; - } - - const string GOSSIP_TEXT_BROWSE_GOODS = "I'd like to browse your goods."; - } - [Script] class npc_kayra_longmane : CreatureScript { @@ -360,43 +333,4 @@ namespace Scripts.Outlands const uint QUEST_ESCAPE_FROM = 9752; const uint NPC_SLAVEBINDER = 18042; } - - [Script] - class npc_timothy_daniels : CreatureScript - { - public npc_timothy_daniels() : base("npc_timothy_daniels") { } - - public override bool OnGossipHello(Player player, Creature creature) - { - if (creature.IsQuestGiver()) - player.PrepareQuestMenu(creature.GetGUID()); - - if (creature.IsVendor()) - player.ADD_GOSSIP_ITEM(GossipOptionIcon.Vendor, GOSSIP_TEXT_BROWSE_POISONS, eTradeskill.GossipSenderMain, eTradeskill.GossipActionTrade); - - player.ADD_GOSSIP_ITEM(GossipOptionIcon.Chat, GOSSIP_TIMOTHY_DANIELS_ITEM1, eTradeskill.GossipSenderMain, eTradeskill.GossipActionInfoDef + 1); - player.SEND_GOSSIP_MENU(player.GetGossipTextId(creature), creature.GetGUID()); - return true; - } - - public override bool OnGossipSelect(Player player, Creature creature, uint sender, uint action) - { - player.PlayerTalkClass.ClearMenus(); - switch (action) - { - case eTradeskill.GossipActionInfoDef + 1: - player.SEND_GOSSIP_MENU(GOSSIP_TEXTID_TIMOTHY_DANIELS1, creature.GetGUID()); - break; - case eTradeskill.GossipActionTrade: - player.GetSession().SendListInventory(creature.GetGUID()); - break; - } - - return true; - } - - const string GOSSIP_TIMOTHY_DANIELS_ITEM1 = "Specialist, eh? Just what kind of specialist are you, anyway?"; - const string GOSSIP_TEXT_BROWSE_POISONS = "Let me browse your reagents and poison supplies."; - const uint GOSSIP_TEXTID_TIMOTHY_DANIELS1 = 9239; - } } diff --git a/Scripts/Pets/DeathKinght.cs b/Scripts/Pets/DeathKinght.cs index 57289fb9e..3a6ff6156 100644 --- a/Scripts/Pets/DeathKinght.cs +++ b/Scripts/Pets/DeathKinght.cs @@ -27,111 +27,91 @@ using System.Collections.Generic; namespace Scripts.Pets { [Script] - class npc_pet_dk_ebon_gargoyle : CreatureScript + class npc_pet_dk_ebon_gargoyle : CasterAI { - public npc_pet_dk_ebon_gargoyle() : base("npc_pet_dk_ebon_gargoyle") { } + public npc_pet_dk_ebon_gargoyle(Creature creature) : base(creature) { } - class npc_pet_dk_ebon_gargoyleAI : CasterAI + public override void InitializeAI() { - public npc_pet_dk_ebon_gargoyleAI(Creature creature) : base(creature) { } + base.InitializeAI(); + ObjectGuid ownerGuid = me.GetOwnerGUID(); + if (ownerGuid.IsEmpty()) + return; - public override void InitializeAI() + // Find victim of Summon Gargoyle spell + List targets = new List(); + var u_check = new AnyUnfriendlyUnitInObjectRangeCheck(me, me, 30.0f); + var searcher = new UnitListSearcher(me, targets, u_check); + Cell.VisitAllObjects(me, searcher, 30.0f); + foreach (var iter in targets) { - base.InitializeAI(); - ObjectGuid ownerGuid = me.GetOwnerGUID(); - if (ownerGuid.IsEmpty()) - return; - - // Find victim of Summon Gargoyle spell - List targets = new List(); - var u_check = new AnyUnfriendlyUnitInObjectRangeCheck(me, me, 30.0f); - var searcher = new UnitListSearcher(me, targets, u_check); - Cell.VisitAllObjects(me, searcher, 30.0f); - foreach (var iter in targets) + if (iter.GetAura(SpellSummonGargoyle1, ownerGuid) != null) { - if (iter.GetAura(SpellSummonGargoyle1, ownerGuid) != null) - { - me.Attack(iter, false); - break; - } + me.Attack(iter, false); + break; } } - - public override void JustDied(Unit killer) - { - // Stop Feeding Gargoyle when it dies - Unit owner = me.GetOwner(); - if (owner) - owner.RemoveAurasDueToSpell(SpellSummonGargoyle2); - } - - // Fly away when dismissed - public override void SpellHit(Unit source, SpellInfo spell) - { - if (spell.Id != SpellDismissGargoyle || !me.IsAlive()) - return; - - Unit owner = me.GetOwner(); - if (!owner || owner != source) - return; - - // Stop Fighting - me.ApplyModFlag(UnitFields.Flags, UnitFlags.NonAttackable, true); - - // Sanctuary - me.CastSpell(me, SpellSanctuary, true); - me.SetReactState(ReactStates.Passive); - - //! HACK: Creature's can't have MOVEMENTFLAG_FLYING - // Fly Away - me.SetCanFly(true); - me.SetSpeedRate(UnitMoveType.Flight, 0.75f); - me.SetSpeedRate(UnitMoveType.Run, 0.75f); - float x = me.GetPositionX() + 20 * (float)Math.Cos(me.GetOrientation()); - float y = me.GetPositionY() + 20 * (float)Math.Sin(me.GetOrientation()); - float z = me.GetPositionZ() + 40; - me.GetMotionMaster().Clear(false); - me.GetMotionMaster().MovePoint(0, x, y, z); - - // Despawn as soon as possible - me.DespawnOrUnsummon(4 * Time.InMilliseconds); - } - - const uint SpellSummonGargoyle1 = 49206; - const uint SpellSummonGargoyle2 = 50514; - const uint SpellDismissGargoyle = 50515; - const uint SpellSanctuary = 54661; } - public override CreatureAI GetAI(Creature creature) + public override void JustDied(Unit killer) { - return new npc_pet_dk_ebon_gargoyleAI(creature); + // Stop Feeding Gargoyle when it dies + Unit owner = me.GetOwner(); + if (owner) + owner.RemoveAurasDueToSpell(SpellSummonGargoyle2); } + + // Fly away when dismissed + public override void SpellHit(Unit source, SpellInfo spell) + { + if (spell.Id != SpellDismissGargoyle || !me.IsAlive()) + return; + + Unit owner = me.GetOwner(); + if (!owner || owner != source) + return; + + // Stop Fighting + me.ApplyModFlag(UnitFields.Flags, UnitFlags.NonAttackable, true); + + // Sanctuary + me.CastSpell(me, SpellSanctuary, true); + me.SetReactState(ReactStates.Passive); + + //! HACK: Creature's can't have MOVEMENTFLAG_FLYING + // Fly Away + me.SetCanFly(true); + me.SetSpeedRate(UnitMoveType.Flight, 0.75f); + me.SetSpeedRate(UnitMoveType.Run, 0.75f); + float x = me.GetPositionX() + 20 * (float)Math.Cos(me.GetOrientation()); + float y = me.GetPositionY() + 20 * (float)Math.Sin(me.GetOrientation()); + float z = me.GetPositionZ() + 40; + me.GetMotionMaster().Clear(false); + me.GetMotionMaster().MovePoint(0, x, y, z); + + // Despawn as soon as possible + me.DespawnOrUnsummon(4 * Time.InMilliseconds); + } + + const uint SpellSummonGargoyle1 = 49206; + const uint SpellSummonGargoyle2 = 50514; + const uint SpellDismissGargoyle = 50515; + const uint SpellSanctuary = 54661; } [Script] - class npc_pet_dk_guardian : CreatureScript + class npc_pet_dk_guardian : AggressorAI { - public npc_pet_dk_guardian() : base("npc_pet_dk_guardian") { } + public npc_pet_dk_guardian(Creature creature) : base(creature) { } - class npc_pet_dk_guardianAI : AggressorAI + public override bool CanAIAttack(Unit target) { - public npc_pet_dk_guardianAI(Creature creature) : base(creature) { } - - public override bool CanAIAttack(Unit target) - { - if (!target) - return false; - Unit owner = me.GetOwner(); - if (owner && !target.IsInCombatWith(owner)) - return false; - return base.CanAIAttack(target); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return new npc_pet_dk_guardianAI(creature); + if (!target) + return false; + Unit owner = me.GetOwner(); + if (owner && !target.IsInCombatWith(owner)) + return false; + return base.CanAIAttack(target); } } } diff --git a/Scripts/Pets/Generic.cs b/Scripts/Pets/Generic.cs index 53c26f39b..e86e45b13 100644 --- a/Scripts/Pets/Generic.cs +++ b/Scripts/Pets/Generic.cs @@ -23,63 +23,53 @@ using Game.Scripting; namespace Scripts.Pets { [Script] - class npc_pet_gen_mojo : CreatureScript + class npc_pet_gen_mojo : ScriptedAI { - public npc_pet_gen_mojo() : base("npc_pet_gen_mojo") { } + public npc_pet_gen_mojo(Creature creature) : base(creature) { } - class npc_pet_gen_mojoAI : ScriptedAI + public override void Reset() { - public npc_pet_gen_mojoAI(Creature creature) : base(creature) { } + _victimGUID.Clear(); - public override void Reset() - { - _victimGUID.Clear(); - - Unit owner = me.GetOwner(); - if (owner) - me.GetMotionMaster().MoveFollow(owner, 0.0f, 0.0f); - } - - public override void EnterCombat(Unit who) { } - - public override void UpdateAI(uint diff) { } - - public override void ReceiveEmote(Player player, TextEmotes emote) - { - me.HandleEmoteCommand((Emote)emote); - Unit owner = me.GetOwner(); - if (emote != TextEmotes.Kiss || !owner || !owner.IsTypeId(TypeId.Player) || - owner.ToPlayer().GetTeam() != player.GetTeam()) - { - return; - } - - Talk(SayMojo, player); - - if (!_victimGUID.IsEmpty()) - { - Player victim = Global.ObjAccessor.GetPlayer(me, _victimGUID); - if (victim) - victim.RemoveAura(SpellFeelingFroggy); - } - - _victimGUID = player.GetGUID(); - - DoCast(player, SpellFeelingFroggy, true); - DoCast(me, SpellSeductionVisual, true); - me.GetMotionMaster().MoveFollow(player, 0.0f, 0.0f); - } - - ObjectGuid _victimGUID; - - const uint SayMojo = 0; - const uint SpellFeelingFroggy = 43906; - const uint SpellSeductionVisual = 43919; + Unit owner = me.GetOwner(); + if (owner) + me.GetMotionMaster().MoveFollow(owner, 0.0f, 0.0f); } - public override CreatureAI GetAI(Creature creature) + public override void EnterCombat(Unit who) { } + + public override void UpdateAI(uint diff) { } + + public override void ReceiveEmote(Player player, TextEmotes emote) { - return new npc_pet_gen_mojoAI(creature); + me.HandleEmoteCommand((Emote)emote); + Unit owner = me.GetOwner(); + if (emote != TextEmotes.Kiss || !owner || !owner.IsTypeId(TypeId.Player) || + owner.ToPlayer().GetTeam() != player.GetTeam()) + { + return; + } + + Talk(SayMojo, player); + + if (!_victimGUID.IsEmpty()) + { + Player victim = Global.ObjAccessor.GetPlayer(me, _victimGUID); + if (victim) + victim.RemoveAura(SpellFeelingFroggy); + } + + _victimGUID = player.GetGUID(); + + DoCast(player, SpellFeelingFroggy, true); + DoCast(me, SpellSeductionVisual, true); + me.GetMotionMaster().MoveFollow(player, 0.0f, 0.0f); } + + ObjectGuid _victimGUID; + + const uint SayMojo = 0; + const uint SpellFeelingFroggy = 43906; + const uint SpellSeductionVisual = 43919; } } diff --git a/Scripts/Pets/Hunter.cs b/Scripts/Pets/Hunter.cs index 1f68e6a1f..1264d12c3 100644 --- a/Scripts/Pets/Hunter.cs +++ b/Scripts/Pets/Hunter.cs @@ -23,100 +23,90 @@ using Game.Scripting; namespace Scripts.Pets { [Script] - class npc_pet_hunter_snake_trap : CreatureScript + class npc_pet_hunter_snake_trap : ScriptedAI { - public npc_pet_hunter_snake_trap() : base("npc_pet_hunter_snake_trap") { } + public npc_pet_hunter_snake_trap(Creature creature) : base(creature) { } - class npc_pet_hunter_snake_trapAI : ScriptedAI + public override void EnterCombat(Unit who) { } + + public override void Reset() { - public npc_pet_hunter_snake_trapAI(Creature creature) : base(creature) { } + _spellTimer = 0; - public override void EnterCombat(Unit who) { } + CreatureTemplate Info = me.GetCreatureTemplate(); - public override void Reset() + _isViper = Info.Entry == NpcViper ? true : false; + + me.SetMaxHealth((uint)(107 * (me.getLevel() - 40) * 0.025f)); + // Add delta to make them not all hit the same time + uint delta = (RandomHelper.Rand32() % 7) * 100; + me.SetStatFloatValue(UnitFields.BaseAttackTime, Info.BaseAttackTime + delta); + //me.SetStatFloatValue(UnitFields.RangedAttackPower, (float)Info.AttackPower); + + // Start attacking attacker of owner on first ai update after spawn - move in line of sight may choose better target + if (!me.GetVictim() && me.IsSummon()) { - _spellTimer = 0; - - CreatureTemplate Info = me.GetCreatureTemplate(); - - _isViper = Info.Entry == NpcViper ? true : false; - - me.SetMaxHealth((uint)(107 * (me.getLevel() - 40) * 0.025f)); - // Add delta to make them not all hit the same time - uint delta = (RandomHelper.Rand32() % 7) * 100; - me.SetStatFloatValue(UnitFields.BaseAttackTime, Info.BaseAttackTime + delta); - //me.SetStatFloatValue(UnitFields.RangedAttackPower, (float)Info.AttackPower); - - // Start attacking attacker of owner on first ai update after spawn - move in line of sight may choose better target - if (!me.GetVictim() && me.IsSummon()) - { - Unit owner = me.ToTempSummon().GetSummoner(); - if (owner) - if (owner.getAttackerForHelper()) - AttackStart(owner.getAttackerForHelper()); - } - - if (!_isViper) - DoCast(me, SpellDeadlyPoisonPassive, true); + Unit owner = me.ToTempSummon().GetSummoner(); + if (owner) + if (owner.getAttackerForHelper()) + AttackStart(owner.getAttackerForHelper()); } - // Redefined for random target selection: - public override void MoveInLineOfSight(Unit who) - { - if (!me.GetVictim() && me.CanCreatureAttack(who)) - { - if (me.GetDistanceZ(who) > SharedConst.CreatureAttackRangeZ) - return; + if (!_isViper) + DoCast(me, SpellDeadlyPoisonPassive, true); + } - float attackRadius = me.GetAttackDistance(who); - if (me.IsWithinDistInMap(who, attackRadius) && me.IsWithinLOSInMap(who)) + // Redefined for random target selection: + public override void MoveInLineOfSight(Unit who) + { + if (!me.GetVictim() && me.CanCreatureAttack(who)) + { + if (me.GetDistanceZ(who) > SharedConst.CreatureAttackRangeZ) + return; + + float attackRadius = me.GetAttackDistance(who); + if (me.IsWithinDistInMap(who, attackRadius) && me.IsWithinLOSInMap(who)) + { + if ((RandomHelper.Rand32() % 5) == 0) { - if ((RandomHelper.Rand32() % 5) == 0) - { - me.setAttackTimer(WeaponAttackType.BaseAttack, (RandomHelper.Rand32() % 10) * 100); - _spellTimer = (RandomHelper.Rand32() % 10) * 100; - AttackStart(who); - } + me.setAttackTimer(WeaponAttackType.BaseAttack, (RandomHelper.Rand32() % 10) * 100); + _spellTimer = (RandomHelper.Rand32() % 10) * 100; + AttackStart(who); } } } + } - public override void UpdateAI(uint diff) + public override void UpdateAI(uint diff) + { + if (!UpdateVictim() || !me.GetVictim()) + return; + + if (me.GetVictim().HasBreakableByDamageCrowdControlAura(me)) { - if (!UpdateVictim() || !me.GetVictim()) - return; - - if (me.GetVictim().HasBreakableByDamageCrowdControlAura(me)) - { - me.InterruptNonMeleeSpells(false); - return; - } - - //Viper - if (_isViper) - { - if (_spellTimer <= diff) - { - if (RandomHelper.IRand(0, 2) == 0) //33% chance to cast - DoCastVictim(RandomHelper.RAND(SpellMindNumbingPoison, SpellCripplingPoison)); - - _spellTimer = 3000; - } - else - _spellTimer -= diff; - } - - DoMeleeAttackIfReady(); + me.InterruptNonMeleeSpells(false); + return; } - bool _isViper; - uint _spellTimer; + //Viper + if (_isViper) + { + if (_spellTimer <= diff) + { + if (RandomHelper.IRand(0, 2) == 0) //33% chance to cast + DoCastVictim(RandomHelper.RAND(SpellMindNumbingPoison, SpellCripplingPoison)); + + _spellTimer = 3000; + } + else + _spellTimer -= diff; + } + + DoMeleeAttackIfReady(); } - public override CreatureAI GetAI(Creature creature) - { - return new npc_pet_hunter_snake_trapAI(creature); - } + bool _isViper; + uint _spellTimer; const uint SpellCripplingPoison = 30981; // Viper const uint SpellDeadlyPoisonPassive = 34657; // Venomous Snake diff --git a/Scripts/Pets/Mage.cs b/Scripts/Pets/Mage.cs index d3a2cdc5f..caa459c51 100644 --- a/Scripts/Pets/Mage.cs +++ b/Scripts/Pets/Mage.cs @@ -37,216 +37,205 @@ namespace Scripts.Pets public const uint TimerMirrorImageFireBlast = 6000; } - [Script] - class npc_pet_mage_mirror_image : CreatureScript + class npc_pet_mage_mirror_image : CasterAI { - public npc_pet_mage_mirror_image() : base("npc_pet_mage_mirror_image") { } + public npc_pet_mage_mirror_image(Creature creature) : base(creature) { } - class npc_pet_mage_mirror_imageAI : CasterAI + void Init() { - public npc_pet_mage_mirror_imageAI(Creature creature) : base(creature) { } + Unit owner = me.GetCharmerOrOwner(); - void Init() + List targets = new List(); + var u_check = new AnyUnfriendlyUnitInObjectRangeCheck(me, me, 30.0f); + var searcher = new UnitListSearcher(me, targets, u_check); + Cell.VisitAllObjects(me, searcher, 40.0f); + + Unit highestThreatUnit = null; + float highestThreat = 0.0f; + Unit nearestPlayer = null; + foreach (var unit in targets) { - Unit owner = me.GetCharmerOrOwner(); + // Consider only units without CC + if (!unit.HasBreakableByDamageCrowdControlAura(unit)) + { + // Take first found unit + if (!highestThreatUnit && !unit.IsTypeId(TypeId.Player)) + { + highestThreatUnit = unit; + continue; + } + if (!nearestPlayer && unit.IsTypeId(TypeId.Player)) + { + nearestPlayer = unit; + continue; + } + // else compare best fit unit with current unit + var triggers = unit.GetThreatManager().getThreatList(); + foreach (var reference in triggers) + { + // Try to find threat referenced to owner + if (reference.getTarget() == owner) + { + // Check if best fit hostile unit hs lower threat than this current unit + if (highestThreat < reference.getThreat()) + { + // If so, update best fit unit + highestThreat = reference.getThreat(); + highestThreatUnit = unit; + break; + } + } + } + // In case no unit with threat was found so far, always check for nearest unit (only for players) + if (unit.IsTypeId(TypeId.Player)) + { + // If this player is closer than the previous one, update it + if (me.GetDistance(unit.GetPosition()) < me.GetDistance(nearestPlayer.GetPosition())) + nearestPlayer = unit; + } + } + } + // Prioritize units with threat referenced to owner + if (highestThreat > 0.0f && highestThreatUnit) + me.Attack(highestThreatUnit, false); + // If there is no such target, try to attack nearest hostile unit if such exists + else if (nearestPlayer) + me.Attack(nearestPlayer, false); + } - List targets = new List(); - var u_check = new AnyUnfriendlyUnitInObjectRangeCheck(me, me, 30.0f); - var searcher = new UnitListSearcher(me, targets, u_check); - Cell.VisitAllObjects(me, searcher, 40.0f); + bool IsInThreatList(Unit target) + { + Unit owner = me.GetCharmerOrOwner(); - Unit highestThreatUnit = null; - float highestThreat = 0.0f; - Unit nearestPlayer = null; - foreach (var unit in targets) + List targets = new List(); + var u_check = new AnyUnfriendlyUnitInObjectRangeCheck(me, me, 30.0f); + var searcher = new UnitListSearcher(me, targets, u_check); + Cell.VisitAllObjects(me, searcher, 40.0f); + + foreach (var unit in targets) + { + if (unit == target) { // Consider only units without CC if (!unit.HasBreakableByDamageCrowdControlAura(unit)) { - // Take first found unit - if (!highestThreatUnit && !unit.IsTypeId(TypeId.Player)) - { - highestThreatUnit = unit; - continue; - } - if (!nearestPlayer && unit.IsTypeId(TypeId.Player)) - { - nearestPlayer = unit; - continue; - } - // else compare best fit unit with current unit var triggers = unit.GetThreatManager().getThreatList(); foreach (var reference in triggers) { // Try to find threat referenced to owner if (reference.getTarget() == owner) - { - // Check if best fit hostile unit hs lower threat than this current unit - if (highestThreat < reference.getThreat()) - { - // If so, update best fit unit - highestThreat = reference.getThreat(); - highestThreatUnit = unit; - break; - } - } - } - // In case no unit with threat was found so far, always check for nearest unit (only for players) - if (unit.IsTypeId(TypeId.Player)) - { - // If this player is closer than the previous one, update it - if (me.GetDistance(unit.GetPosition()) < me.GetDistance(nearestPlayer.GetPosition())) - nearestPlayer = unit; + return true; } } } - // Prioritize units with threat referenced to owner - if (highestThreat > 0.0f && highestThreatUnit) - me.Attack(highestThreatUnit, false); - // If there is no such target, try to attack nearest hostile unit if such exists - else if (nearestPlayer) - me.Attack(nearestPlayer, false); - } - - bool IsInThreatList(Unit target) - { - Unit owner = me.GetCharmerOrOwner(); - - List targets = new List(); - var u_check = new AnyUnfriendlyUnitInObjectRangeCheck(me, me, 30.0f); - var searcher = new UnitListSearcher(me, targets, u_check); - Cell.VisitAllObjects(me, searcher, 40.0f); - - foreach (var unit in targets) - { - if (unit == target) - { - // Consider only units without CC - if (!unit.HasBreakableByDamageCrowdControlAura(unit)) - { - var triggers = unit.GetThreatManager().getThreatList(); - foreach (var reference in triggers) - { - // Try to find threat referenced to owner - if (reference.getTarget() == owner) - return true; - } - } - } - } - return false; - } - - public override void InitializeAI() - { - base.InitializeAI(); - Unit owner = me.GetOwner(); - if (!owner) - return; - - // here mirror image casts on summoner spell (not present in client dbc) 49866 - // here should be auras (not present in client dbc): 35657, 35658, 35659, 35660 selfcasted by mirror images (stats related?) - // Clone Me! - owner.CastSpell(me, PetMageConst.SpellCloneMe, false); - } - - public override void EnterCombat(Unit victim) - { - if (me.GetVictim() && !me.GetVictim().HasBreakableByDamageCrowdControlAura(me)) - { - me.CastSpell(victim, PetMageConst.SpellMageFireBlast, false); - _events.ScheduleEvent(PetMageConst.SpellMageFrostBolt, PetMageConst.TimerMirrorImageInit); - _events.ScheduleEvent(PetMageConst.SpellMageFireBlast, PetMageConst.TimerMirrorImageFireBlast); - } - else - EnterEvadeMode(EvadeReason.Other); - } - - public override void Reset() - { - _events.Reset(); - } - - public override void UpdateAI(uint diff) - { - Unit owner = me.GetCharmerOrOwner(); - if (!owner) - return; - - Unit target = owner.getAttackerForHelper(); - - _events.Update(diff); - - // prevent CC interrupts by images - if (me.GetVictim() && me.GetVictim().HasBreakableByDamageCrowdControlAura(me)) - { - me.InterruptNonMeleeSpells(false); - return; - } - - if (me.HasUnitState(UnitState.Casting)) - return; - - // assign target if image doesnt have any or the target is not actual - if (!target || me.GetVictim() != target) - { - Unit ownerTarget = null; - Player owner1 = me.GetCharmerOrOwner().ToPlayer(); - if (owner1) - ownerTarget = owner1.GetSelectedUnit(); - - // recognize which victim will be choosen - if (ownerTarget && ownerTarget.IsTypeId(TypeId.Player)) - { - if (!ownerTarget.HasBreakableByDamageCrowdControlAura(ownerTarget)) - me.Attack(ownerTarget, false); - } - else if (ownerTarget && !ownerTarget.IsTypeId(TypeId.Player) && IsInThreatList(ownerTarget)) - { - if (!ownerTarget.HasBreakableByDamageCrowdControlAura(ownerTarget)) - me.Attack(ownerTarget, false); - } - else - Init(); - } - - _events.ExecuteEvents(spellId => - { - if (spellId == PetMageConst.SpellMageFrostBolt) - { - _events.ScheduleEvent(PetMageConst.SpellMageFrostBolt, PetMageConst.TimerMirrorImageFrostBolt); - DoCastVictim(spellId); - } - else if (spellId == PetMageConst.SpellMageFireBlast) - { - DoCastVictim(spellId); - _events.ScheduleEvent(PetMageConst.SpellMageFireBlast, PetMageConst.TimerMirrorImageFireBlast); - } - }); - } - - // Do not reload Creature templates on evade mode enter - prevent visual lost - public override void EnterEvadeMode(EvadeReason why) - { - if (me.IsInEvadeMode() || !me.IsAlive()) - return; - - Unit owner = me.GetCharmerOrOwner(); - - me.CombatStop(true); - if (owner && !me.HasUnitState(UnitState.Follow)) - { - me.GetMotionMaster().Clear(false); - me.GetMotionMaster().MoveFollow(owner, SharedConst.PetFollowDist, me.GetFollowAngle(), MovementSlot.Active); - } - Init(); } + return false; } - public override CreatureAI GetAI(Creature creature) + public override void InitializeAI() { - return new npc_pet_mage_mirror_imageAI(creature); + base.InitializeAI(); + Unit owner = me.GetOwner(); + if (!owner) + return; + + // here mirror image casts on summoner spell (not present in client dbc) 49866 + // here should be auras (not present in client dbc): 35657, 35658, 35659, 35660 selfcasted by mirror images (stats related?) + // Clone Me! + owner.CastSpell(me, PetMageConst.SpellCloneMe, false); + } + + public override void EnterCombat(Unit victim) + { + if (me.GetVictim() && !me.GetVictim().HasBreakableByDamageCrowdControlAura(me)) + { + me.CastSpell(victim, PetMageConst.SpellMageFireBlast, false); + _events.ScheduleEvent(PetMageConst.SpellMageFrostBolt, PetMageConst.TimerMirrorImageInit); + _events.ScheduleEvent(PetMageConst.SpellMageFireBlast, PetMageConst.TimerMirrorImageFireBlast); + } + else + EnterEvadeMode(EvadeReason.Other); + } + + public override void Reset() + { + _events.Reset(); + } + + public override void UpdateAI(uint diff) + { + Unit owner = me.GetCharmerOrOwner(); + if (!owner) + return; + + Unit target = owner.getAttackerForHelper(); + + _events.Update(diff); + + // prevent CC interrupts by images + if (me.GetVictim() && me.GetVictim().HasBreakableByDamageCrowdControlAura(me)) + { + me.InterruptNonMeleeSpells(false); + return; + } + + if (me.HasUnitState(UnitState.Casting)) + return; + + // assign target if image doesnt have any or the target is not actual + if (!target || me.GetVictim() != target) + { + Unit ownerTarget = null; + Player owner1 = me.GetCharmerOrOwner().ToPlayer(); + if (owner1) + ownerTarget = owner1.GetSelectedUnit(); + + // recognize which victim will be choosen + if (ownerTarget && ownerTarget.IsTypeId(TypeId.Player)) + { + if (!ownerTarget.HasBreakableByDamageCrowdControlAura(ownerTarget)) + me.Attack(ownerTarget, false); + } + else if (ownerTarget && !ownerTarget.IsTypeId(TypeId.Player) && IsInThreatList(ownerTarget)) + { + if (!ownerTarget.HasBreakableByDamageCrowdControlAura(ownerTarget)) + me.Attack(ownerTarget, false); + } + else + Init(); + } + + _events.ExecuteEvents(spellId => + { + if (spellId == PetMageConst.SpellMageFrostBolt) + { + _events.ScheduleEvent(PetMageConst.SpellMageFrostBolt, PetMageConst.TimerMirrorImageFrostBolt); + DoCastVictim(spellId); + } + else if (spellId == PetMageConst.SpellMageFireBlast) + { + DoCastVictim(spellId); + _events.ScheduleEvent(PetMageConst.SpellMageFireBlast, PetMageConst.TimerMirrorImageFireBlast); + } + }); + } + + // Do not reload Creature templates on evade mode enter - prevent visual lost + public override void EnterEvadeMode(EvadeReason why) + { + if (me.IsInEvadeMode() || !me.IsAlive()) + return; + + Unit owner = me.GetCharmerOrOwner(); + + me.CombatStop(true); + if (owner && !me.HasUnitState(UnitState.Follow)) + { + me.GetMotionMaster().Clear(false); + me.GetMotionMaster().MoveFollow(owner, SharedConst.PetFollowDist, me.GetFollowAngle(), MovementSlot.Active); + } + Init(); } } } diff --git a/Scripts/Pets/Priest.cs b/Scripts/Pets/Priest.cs index 12608dca2..b4d6615f8 100644 --- a/Scripts/Pets/Priest.cs +++ b/Scripts/Pets/Priest.cs @@ -30,54 +30,33 @@ namespace Scripts.Pets.Priest } [Script] - class npc_pet_pri_lightwell : CreatureScript + class npc_pet_pri_lightwell : PassiveAI { - public npc_pet_pri_lightwell() : base("npc_pet_pri_lightwell") { } - - class npc_pet_pri_lightwellAI : PassiveAI + public npc_pet_pri_lightwell(Creature creature) : base(creature) { - public npc_pet_pri_lightwellAI(Creature creature) : base(creature) - { - DoCast(creature, SpellIds.LightWellCharges, false); - } - - public override void EnterEvadeMode(EvadeReason why) - { - if (!me.IsAlive()) - return; - - me.DeleteThreatList(); - me.CombatStop(true); - me.ResetPlayerDamageReq(); - } + DoCast(creature, SpellIds.LightWellCharges, false); } - public override CreatureAI GetAI(Creature creature) + public override void EnterEvadeMode(EvadeReason why) { - return new npc_pet_pri_lightwellAI(creature); + if (!me.IsAlive()) + return; + + me.DeleteThreatList(); + me.CombatStop(true); + me.ResetPlayerDamageReq(); } } [Script] - class npc_pet_pri_shadowfiend : CreatureScript + class npc_pet_pri_shadowfiend : PetAI { - public npc_pet_pri_shadowfiend() : base("npc_pet_pri_shadowfiend") { } + public npc_pet_pri_shadowfiend(Creature creature) : base(creature) { } - class npc_pet_pri_shadowfiendAI : PetAI + public override void IsSummonedBy(Unit summoner) { - public npc_pet_pri_shadowfiendAI(Creature creature) : base(creature) { } - - public override void IsSummonedBy(Unit summoner) - { - if (summoner.HasAura(SpellIds.GlyphOfShadowFiend)) - DoCastAOE(SpellIds.ShadowFiendDeath); - } - - } - - public override CreatureAI GetAI(Creature creature) - { - return new npc_pet_pri_shadowfiendAI(creature); + if (summoner.HasAura(SpellIds.GlyphOfShadowFiend)) + DoCastAOE(SpellIds.ShadowFiendDeath); } } } diff --git a/Scripts/Pets/Shaman.cs b/Scripts/Pets/Shaman.cs index 37a6eb0d9..1cac3cbda 100644 --- a/Scripts/Pets/Shaman.cs +++ b/Scripts/Pets/Shaman.cs @@ -23,111 +23,91 @@ using Game.Scripting; namespace Scripts.Pets { [Script] - class npc_pet_shaman_earth_elemental : CreatureScript + class npc_pet_shaman_earth_elemental : ScriptedAI { - public npc_pet_shaman_earth_elemental() : base("npc_pet_shaman_earth_elemental") { } + public npc_pet_shaman_earth_elemental(Creature creature) : base(creature) { } - class npc_pet_shaman_earth_elementalAI : ScriptedAI + public override void Reset() { - public npc_pet_shaman_earth_elementalAI(Creature creature) : base(creature) { } - - public override void Reset() - { - _events.Reset(); - _events.ScheduleEvent(EventAngeredEarth, 0); - me.ApplySpellImmune(0, SpellImmunity.School, SpellSchoolMask.Nature, true); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - _events.Update(diff); - - if (_events.ExecuteEvent() == EventAngeredEarth) - { - DoCastVictim(SpellAngeredEarth); - _events.ScheduleEvent(EventAngeredEarth, RandomHelper.URand(5000, 20000)); - } - - DoMeleeAttackIfReady(); - } - - const int EventAngeredEarth = 1; - const uint SpellAngeredEarth = 36213; + _events.Reset(); + _events.ScheduleEvent(EventAngeredEarth, 0); + me.ApplySpellImmune(0, SpellImmunity.School, SpellSchoolMask.Nature, true); } - public override CreatureAI GetAI(Creature creature) + public override void UpdateAI(uint diff) { - return new npc_pet_shaman_earth_elementalAI(creature); + if (!UpdateVictim()) + return; + + _events.Update(diff); + + if (_events.ExecuteEvent() == EventAngeredEarth) + { + DoCastVictim(SpellAngeredEarth); + _events.ScheduleEvent(EventAngeredEarth, RandomHelper.URand(5000, 20000)); + } + + DoMeleeAttackIfReady(); } + + const int EventAngeredEarth = 1; + const uint SpellAngeredEarth = 36213; } [Script] - class npc_pet_shaman_fire_elemental : CreatureScript + public class npc_pet_shaman_fire_elemental : ScriptedAI { - public npc_pet_shaman_fire_elemental() : base("npc_pet_shaman_fire_elemental") { } + public npc_pet_shaman_fire_elemental(Creature creature) : base(creature) { } - public class npc_pet_shaman_fire_elementalAI : ScriptedAI + public override void Reset() { - public npc_pet_shaman_fire_elementalAI(Creature creature) : base(creature) { } + _events.Reset(); + _events.ScheduleEvent(EventFireNova, RandomHelper.URand(5000, 20000)); + _events.ScheduleEvent(EventFireBlast, RandomHelper.URand(5000, 20000)); + _events.ScheduleEvent(EventFireShield, 0); + me.ApplySpellImmune(0, SpellImmunity.School, SpellSchoolMask.Fire, true); + } - public override void Reset() + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + if (me.HasUnitState(UnitState.Casting)) + return; + + _events.Update(diff); + + _events.ExecuteEvents(eventId => { - _events.Reset(); - _events.ScheduleEvent(EventFireNova, RandomHelper.URand(5000, 20000)); - _events.ScheduleEvent(EventFireBlast, RandomHelper.URand(5000, 20000)); - _events.ScheduleEvent(EventFireShield, 0); - me.ApplySpellImmune(0, SpellImmunity.School, SpellSchoolMask.Fire, true); - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - if (me.HasUnitState(UnitState.Casting)) - return; - - _events.Update(diff); - - _events.ExecuteEvents(eventId => + switch (eventId) { - switch (eventId) - { - case EventFireNova: - DoCastVictim(SpellFireNova); - _events.ScheduleEvent(EventFireNova, RandomHelper.URand(5000, 20000)); - break; - case EventFireShield: - DoCastVictim(SpellFireShield); - _events.ScheduleEvent(EventFireShield, 2000); - break; - case EventFireBlast: - DoCastVictim(SpellFireBlast); - _events.ScheduleEvent(EventFireBlast, RandomHelper.URand(5000, 20000)); - break; - default: - break; - } - }); + case EventFireNova: + DoCastVictim(SpellFireNova); + _events.ScheduleEvent(EventFireNova, RandomHelper.URand(5000, 20000)); + break; + case EventFireShield: + DoCastVictim(SpellFireShield); + _events.ScheduleEvent(EventFireShield, 2000); + break; + case EventFireBlast: + DoCastVictim(SpellFireBlast); + _events.ScheduleEvent(EventFireBlast, RandomHelper.URand(5000, 20000)); + break; + default: + break; + } + }); - DoMeleeAttackIfReady(); - } - - const int EventFireNova = 1; - const int EventFireShield = 2; - const int EventFireBlast = 3; - - const uint SpellFireBlast = 57984; - const uint SpellFireNova = 12470; - const uint SpellFireShield = 13376; + DoMeleeAttackIfReady(); } - public override CreatureAI GetAI(Creature creature) - { - return new npc_pet_shaman_fire_elementalAI(creature); - } + const int EventFireNova = 1; + const int EventFireShield = 2; + const int EventFireBlast = 3; + + const uint SpellFireBlast = 57984; + const uint SpellFireNova = 12470; + const uint SpellFireShield = 13376; } } diff --git a/Scripts/Spells/DeathKnight.cs b/Scripts/Spells/DeathKnight.cs index 41e9926ed..584d2ebc1 100644 --- a/Scripts/Spells/DeathKnight.cs +++ b/Scripts/Spells/DeathKnight.cs @@ -82,819 +82,605 @@ namespace Scripts.Spells.DeathKnight } [Script] // 70656 - Advantage (T10 4P Melee Bonus) - class spell_dk_advantage_t10_4p : SpellScriptLoader + class spell_dk_advantage_t10_4p : AuraScript { - public spell_dk_advantage_t10_4p() : base("spell_dk_advantage_t10_4p") { } - - class spell_dk_advantage_t10_4p_AuraScript : AuraScript + bool CheckProc(ProcEventInfo eventInfo) { - bool CheckProc(ProcEventInfo eventInfo) + Unit caster = eventInfo.GetActor(); + if (caster) { - Unit caster = eventInfo.GetActor(); - if (caster) - { - if (!caster.IsTypeId(TypeId.Player) || caster.GetClass() != Class.Deathknight) + if (!caster.IsTypeId(TypeId.Player) || caster.GetClass() != Class.Deathknight) + return false; + + for (byte i = 0; i < PlayerConst.MaxRunes; ++i) + if (caster.ToPlayer().GetRuneCooldown(i) == 0) return false; - for (byte i = 0; i < PlayerConst.MaxRunes; ++i) - if (caster.ToPlayer().GetRuneCooldown(i) == 0) - return false; - - return true; - } - - return false; + return true; } - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - } + return false; } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_dk_advantage_t10_4p_AuraScript(); + DoCheckProc.Add(new CheckProcHandler(CheckProc)); } } [Script] // 48707 - Anti-Magic Shell - class spell_dk_anti_magic_shell : SpellScriptLoader + class spell_dk_anti_magic_shell : AuraScript { - public spell_dk_anti_magic_shell() : base("spell_dk_anti_magic_shell") { } - - class spell_dk_anti_magic_shell_AuraScript : AuraScript + public spell_dk_anti_magic_shell() { - public spell_dk_anti_magic_shell_AuraScript() - { - absorbPct = 0; - maxHealth = 0; - absorbedAmount = 0; - } - - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.RunicPowerEnergize, SpellIds.VolatileShielding); - } - - public override bool Load() - { - absorbPct = GetSpellInfo().GetEffect(1).CalcValue(GetCaster()); - maxHealth = (int)GetCaster().GetMaxHealth(); - absorbedAmount = 0; - return true; - } - - void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) - { - amount = MathFunctions.CalculatePct(maxHealth, absorbPct); - } - - void Trigger(AuraEffect aurEff, DamageInfo dmgInfo, ref uint absorbAmount) - { - absorbedAmount += absorbAmount; - - if (!GetTarget().HasAura(SpellIds.VolatileShielding)) - { - int bp = (int)(2 * absorbAmount * 100 / maxHealth); - GetTarget().CastCustomSpell(SpellIds.RunicPowerEnergize, SpellValueMod.BasePoint0, bp, GetTarget(), true, null, aurEff); - } - } - - void HandleEffectRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - AuraEffect volatileShielding = GetTarget().GetAuraEffect(SpellIds.VolatileShielding, 1); - if (volatileShielding != null) - { - int damage = (int)MathFunctions.CalculatePct(absorbedAmount, volatileShielding.GetAmount()); - GetTarget().CastCustomSpell(SpellIds.VolatileShieldingDamage, SpellValueMod.BasePoint0, damage, null, TriggerCastFlags.FullMask, null, volatileShielding); - } - } - - public override void Register() - { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.SchoolAbsorb)); - AfterEffectAbsorb.Add(new EffectAbsorbHandler(Trigger, 0)); - AfterEffectRemove.Add(new EffectApplyHandler(HandleEffectRemove, 0, AuraType.SchoolAbsorb, AuraEffectHandleModes.Real)); - } - - int absorbPct; - int maxHealth; - uint absorbedAmount; + absorbPct = 0; + maxHealth = 0; + absorbedAmount = 0; } - public override AuraScript GetAuraScript() + public override bool Validate(SpellInfo spellInfo) { - return new spell_dk_anti_magic_shell_AuraScript(); + return ValidateSpellInfo(SpellIds.RunicPowerEnergize, SpellIds.VolatileShielding); } + + public override bool Load() + { + absorbPct = GetSpellInfo().GetEffect(1).CalcValue(GetCaster()); + maxHealth = (int)GetCaster().GetMaxHealth(); + absorbedAmount = 0; + return true; + } + + void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + amount = MathFunctions.CalculatePct(maxHealth, absorbPct); + } + + void Trigger(AuraEffect aurEff, DamageInfo dmgInfo, ref uint absorbAmount) + { + absorbedAmount += absorbAmount; + + if (!GetTarget().HasAura(SpellIds.VolatileShielding)) + { + int bp = (int)(2 * absorbAmount * 100 / maxHealth); + GetTarget().CastCustomSpell(SpellIds.RunicPowerEnergize, SpellValueMod.BasePoint0, bp, GetTarget(), true, null, aurEff); + } + } + + void HandleEffectRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + AuraEffect volatileShielding = GetTarget().GetAuraEffect(SpellIds.VolatileShielding, 1); + if (volatileShielding != null) + { + int damage = (int)MathFunctions.CalculatePct(absorbedAmount, volatileShielding.GetAmount()); + GetTarget().CastCustomSpell(SpellIds.VolatileShieldingDamage, SpellValueMod.BasePoint0, damage, null, TriggerCastFlags.FullMask, null, volatileShielding); + } + } + + public override void Register() + { + DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.SchoolAbsorb)); + AfterEffectAbsorb.Add(new EffectAbsorbHandler(Trigger, 0)); + AfterEffectRemove.Add(new EffectApplyHandler(HandleEffectRemove, 0, AuraType.SchoolAbsorb, AuraEffectHandleModes.Real)); + } + + int absorbPct; + int maxHealth; + uint absorbedAmount; } [Script] // 127517 - Army Transform // 6.x, does this belong here or in spell_generic? where do we cast this? sniffs say this is only cast when caster has glyph of foul menagerie. - class spell_dk_army_transform : SpellScriptLoader + class spell_dk_army_transform : SpellScript { - public spell_dk_army_transform() : base("spell_dk_army_transform") { } - - class spell_dk_army_transform_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.GlyphOfFoulMenagerie); - } - - public override bool Load() - { - return GetCaster().IsGuardian(); - } - - SpellCastResult CheckCast() - { - Unit owner = GetCaster().GetOwner(); - if (owner) - if (owner.HasAura(SpellIds.GlyphOfFoulMenagerie)) - return SpellCastResult.SpellCastOk; - - return SpellCastResult.SpellUnavailable; - } - - void HandleDummy(uint effIndex) - { - GetCaster().CastSpell(GetCaster(), SpellIds.ArmyTransforms.SelectRandom(), true); - } - - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellIds.GlyphOfFoulMenagerie); } - public override SpellScript GetSpellScript() + public override bool Load() { - return new spell_dk_army_transform_SpellScript(); + return GetCaster().IsGuardian(); + } + + SpellCastResult CheckCast() + { + Unit owner = GetCaster().GetOwner(); + if (owner) + if (owner.HasAura(SpellIds.GlyphOfFoulMenagerie)) + return SpellCastResult.SpellCastOk; + + return SpellCastResult.SpellUnavailable; + } + + void HandleDummy(uint effIndex) + { + GetCaster().CastSpell(GetCaster(), SpellIds.ArmyTransforms.SelectRandom(), true); + } + + public override void Register() + { + OnCheckCast.Add(new CheckCastHandler(CheckCast)); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 50842 - Blood Boil - class spell_dk_blood_boil : SpellScriptLoader + class spell_dk_blood_boil : SpellScript { - public spell_dk_blood_boil() : base("spell_dk_blood_boil") { } - - class spell_dk_blood_boil_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.BloodPlague); - } - - void HandleEffect() - { - GetCaster().CastSpell(GetHitUnit(), SpellIds.BloodPlague, true); - } - - public override void Register() - { - OnHit.Add(new HitHandler(HandleEffect)); - } + return ValidateSpellInfo(SpellIds.BloodPlague); } - public override SpellScript GetSpellScript() + void HandleEffect() { - return new spell_dk_blood_boil_SpellScript(); + GetCaster().CastSpell(GetHitUnit(), SpellIds.BloodPlague, true); + } + + public override void Register() + { + OnHit.Add(new HitHandler(HandleEffect)); } } [Script] // 49028 - Dancing Rune Weapon 7.1.5 - class spell_dk_dancing_rune_weapon : SpellScriptLoader + class spell_dk_dancing_rune_weapon : AuraScript { - public spell_dk_dancing_rune_weapon() : base("spell_dk_dancing_rune_weapon") { } - - class spell_dk_dancing_rune_weapon_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - if (Global.ObjectMgr.GetCreatureTemplate(CreatureIds.DancingRuneWeapon) == null) - return false; - return true; - } - - // This is a port of the old switch hack in Unit.cpp, it's not correct - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - Unit caster = GetCaster(); - if (!caster) - return; - - Unit drw = null; - foreach (Unit controlled in caster.m_Controlled) - { - if (controlled.GetEntry() == CreatureIds.DancingRuneWeapon) - { - drw = controlled; - break; - } - } - - if (!drw || !drw.GetVictim()) - return; - - SpellInfo spellInfo = eventInfo.GetSpellInfo(); - if (spellInfo == null) - return; - - DamageInfo damageInfo = eventInfo.GetDamageInfo(); - if (damageInfo == null || damageInfo.GetDamage() == 0) - return; - - int amount = (int)(damageInfo.GetDamage() / 2); - SpellNonMeleeDamage log = new SpellNonMeleeDamage(drw, drw.GetVictim(), spellInfo.Id, spellInfo.GetSpellXSpellVisualId(drw), spellInfo.GetSchoolMask()); - log.damage = (uint)amount; - drw.DealDamage(drw.GetVictim(), (uint)amount, null, DamageEffectType.Direct, spellInfo.GetSchoolMask(), spellInfo, true); - drw.SendSpellNonMeleeDamageLog(log); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.Dummy)); - } + if (Global.ObjectMgr.GetCreatureTemplate(CreatureIds.DancingRuneWeapon) == null) + return false; + return true; } - public override AuraScript GetAuraScript() + // This is a port of the old switch hack in Unit.cpp, it's not correct + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_dk_dancing_rune_weapon_AuraScript(); + PreventDefaultAction(); + Unit caster = GetCaster(); + if (!caster) + return; + + Unit drw = null; + foreach (Unit controlled in caster.m_Controlled) + { + if (controlled.GetEntry() == CreatureIds.DancingRuneWeapon) + { + drw = controlled; + break; + } + } + + if (!drw || !drw.GetVictim()) + return; + + SpellInfo spellInfo = eventInfo.GetSpellInfo(); + if (spellInfo == null) + return; + + DamageInfo damageInfo = eventInfo.GetDamageInfo(); + if (damageInfo == null || damageInfo.GetDamage() == 0) + return; + + int amount = (int)(damageInfo.GetDamage() / 2); + SpellNonMeleeDamage log = new SpellNonMeleeDamage(drw, drw.GetVictim(), spellInfo.Id, spellInfo.GetSpellXSpellVisualId(drw), spellInfo.GetSchoolMask()); + log.damage = (uint)amount; + drw.DealDamage(drw.GetVictim(), (uint)amount, null, DamageEffectType.Direct, spellInfo.GetSchoolMask(), spellInfo, true); + drw.SendSpellNonMeleeDamageLog(log); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.Dummy)); } } [Script] // 43265 - Death and Decay - class spell_dk_death_and_decay : SpellScriptLoader + class spell_dk_death_and_decay : SpellScript { - public spell_dk_death_and_decay() : base("spell_dk_death_and_decay") { } - - class spell_dk_death_and_decay_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.TighteningGrasp, SpellIds.TighteningGraspSlow); - } + return ValidateSpellInfo(SpellIds.TighteningGrasp, SpellIds.TighteningGraspSlow); + } - void HandleDummy() + void HandleDummy() + { + if (GetCaster().HasAura(SpellIds.TighteningGrasp)) { - if (GetCaster().HasAura(SpellIds.TighteningGrasp)) - { - Position pos = GetExplTargetDest(); - if (pos != null) - GetCaster().CastSpell(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), SpellIds.TighteningGraspSlow, true); - } - } - - public override void Register() - { - OnCast.Add(new CastHandler(HandleDummy)); + Position pos = GetExplTargetDest(); + if (pos != null) + GetCaster().CastSpell(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), SpellIds.TighteningGraspSlow, true); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_dk_death_and_decay_SpellScript(); + OnCast.Add(new CastHandler(HandleDummy)); + } + } + + [Script] + class spell_dk_death_and_decay_AuraScript: AuraScript + { + void HandleDummyTick(AuraEffect aurEff) + { + Unit caster = GetCaster(); + if (caster) + caster.CastSpell(GetTarget(), SpellIds.DeathAndDecayDamage, true, null, aurEff); } - class spell_dk_death_and_decay_AuraScript : AuraScript + public override void Register() { - void HandleDummyTick(AuraEffect aurEff) - { - Unit caster = GetCaster(); - if (caster) - caster.CastSpell(GetTarget(), SpellIds.DeathAndDecayDamage, true, null, aurEff); - } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleDummyTick, 2, AuraType.PeriodicDummy)); - } - } - - public override AuraScript GetAuraScript() - { - return new spell_dk_death_and_decay_AuraScript(); + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleDummyTick, 2, AuraType.PeriodicDummy)); } } [Script] // 47541 - Death Coil - class spell_dk_death_coil : SpellScriptLoader + class spell_dk_death_coil : SpellScript { - public spell_dk_death_coil() : base("spell_dk_death_coil") { } - - class spell_dk_death_coil_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.DeathCoilDamage, SpellIds.Unholy, SpellIds.UnholyVigor); - } - - void HandleDummy(uint effIndex) - { - Unit caster = GetCaster(); - caster.CastSpell(GetHitUnit(), SpellIds.DeathCoilDamage, true); - - AuraEffect unholyAura = caster.GetAuraEffect(SpellIds.Unholy, 6); - if (unholyAura != null) // can be any effect, just here to send SPELL_FAILED_DONT_REPORT on failure - caster.CastSpell(caster, SpellIds.UnholyVigor, true, null, unholyAura); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellIds.DeathCoilDamage, SpellIds.Unholy, SpellIds.UnholyVigor); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_dk_death_coil_SpellScript(); + Unit caster = GetCaster(); + caster.CastSpell(GetHitUnit(), SpellIds.DeathCoilDamage, true); + + AuraEffect unholyAura = caster.GetAuraEffect(SpellIds.Unholy, 6); + if (unholyAura != null) // can be any effect, just here to send SPELL_FAILED_DONT_REPORT on failure + caster.CastSpell(caster, SpellIds.UnholyVigor, true, null, unholyAura); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 52751 - Death Gate - class spell_dk_death_gate : SpellScriptLoader + class spell_dk_death_gate : SpellScript { - public spell_dk_death_gate() : base("spell_dk_death_gate") { } - - class spell_dk_death_gate_SpellScript : SpellScript + SpellCastResult CheckClass() { - SpellCastResult CheckClass() + if (GetCaster().GetClass() != Class.Deathknight) { - if (GetCaster().GetClass() != Class.Deathknight) - { - SetCustomCastResultMessage(SpellCustomErrors.MustBeDeathKnight); - return SpellCastResult.CustomError; - } - - return SpellCastResult.SpellCastOk; + SetCustomCastResultMessage(SpellCustomErrors.MustBeDeathKnight); + return SpellCastResult.CustomError; } - void HandleScript(uint effIndex) - { - PreventHitDefaultEffect(effIndex); - Unit target = GetHitUnit(); - if (target) - target.CastSpell(target, (uint)GetEffectValue(), false); - } - - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckClass)); - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } + return SpellCastResult.SpellCastOk; } - public override SpellScript GetSpellScript() + void HandleScript(uint effIndex) { - return new spell_dk_death_gate_SpellScript(); + PreventHitDefaultEffect(effIndex); + Unit target = GetHitUnit(); + if (target) + target.CastSpell(target, (uint)GetEffectValue(), false); + } + + public override void Register() + { + OnCheckCast.Add(new CheckCastHandler(CheckClass)); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] //49576 - Death Grip Initial - class spell_dk_death_grip_initial : SpellScriptLoader + class spell_dk_death_grip_initial : SpellScript { - public spell_dk_death_grip_initial() : base("spell_dk_death_grip_initial") { } - - class spell_dk_death_grip_initial_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.DeathGripDummy, SpellIds.DeathGripJump, SpellIds.Blood, SpellIds.DeathGripTaunt); - } - - SpellCastResult CheckCast() - { - Unit caster = GetCaster(); - // Death Grip should not be castable while jumping/falling - if (caster.HasUnitState(UnitState.Jumping) || caster.HasUnitMovementFlag(MovementFlag.Falling)) - return SpellCastResult.Moving; - - return SpellCastResult.SpellCastOk; - } - - void HandleDummy(uint effIndex) - { - GetCaster().CastSpell(GetHitUnit(), SpellIds.DeathGripDummy, true); - GetHitUnit().CastSpell(GetCaster(), SpellIds.DeathGripJump, true); - if (GetCaster().HasAura(SpellIds.Blood)) - GetCaster().CastSpell(GetHitUnit(), SpellIds.DeathGripTaunt, true); - } - - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.ScriptEffect)); - } + return ValidateSpellInfo(SpellIds.DeathGripDummy, SpellIds.DeathGripJump, SpellIds.Blood, SpellIds.DeathGripTaunt); } - public override SpellScript GetSpellScript() + SpellCastResult CheckCast() { - return new spell_dk_death_grip_initial_SpellScript(); + Unit caster = GetCaster(); + // Death Grip should not be castable while jumping/falling + if (caster.HasUnitState(UnitState.Jumping) || caster.HasUnitMovementFlag(MovementFlag.Falling)) + return SpellCastResult.Moving; + + return SpellCastResult.SpellCastOk; + } + + void HandleDummy(uint effIndex) + { + GetCaster().CastSpell(GetHitUnit(), SpellIds.DeathGripDummy, true); + GetHitUnit().CastSpell(GetCaster(), SpellIds.DeathGripJump, true); + if (GetCaster().HasAura(SpellIds.Blood)) + GetCaster().CastSpell(GetHitUnit(), SpellIds.DeathGripTaunt, true); + } + + public override void Register() + { + OnCheckCast.Add(new CheckCastHandler(CheckCast)); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.ScriptEffect)); } } [Script] // 48743 - Death Pact - class spell_dk_death_pact : SpellScriptLoader + class spell_dk_death_pact : AuraScript { - public spell_dk_death_pact() : base("spell_dk_death_pact") { } - - class spell_dk_death_pact_AuraScript : AuraScript + void HandleCalcAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) { - void HandleCalcAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) - { - Unit caster = GetCaster(); - if (caster) - amount = (int)caster.CountPctFromMaxHealth(amount); - } - - public override void Register() - { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(HandleCalcAmount, 1, AuraType.SchoolHealAbsorb)); - } + Unit caster = GetCaster(); + if (caster) + amount = (int)caster.CountPctFromMaxHealth(amount); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_dk_death_pact_AuraScript(); + DoEffectCalcAmount.Add(new EffectCalcAmountHandler(HandleCalcAmount, 1, AuraType.SchoolHealAbsorb)); } } [Script] // 49998 - Death Strike - class spell_dk_death_strike : SpellScriptLoader + class spell_dk_death_strike : SpellScript { - public spell_dk_death_strike() : base("spell_dk_death_strike") { } - - class spell_dk_death_strike_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.DeathStrikeHeal, SpellIds.BloodShieldMastery, SpellIds.BloodShieldAbsorb, - SpellIds.RecentlyUsedDeathStrike, SpellIds.Frost, SpellIds.DeathStrikeOffhand); - } - - void HandleHeal(uint effIndex) - { - Unit caster = GetCaster(); - //TODO: heal = std::min(10% health, 20% of all damage taken in last 5 seconds) - int heal = (int)MathFunctions.CalculatePct(caster.GetMaxHealth(), GetSpellInfo().GetEffect(4).CalcValue()); - caster.CastCustomSpell(SpellIds.DeathStrikeHeal, SpellValueMod.BasePoint0, heal, caster, true); - - AuraEffect aurEff = caster.GetAuraEffect(SpellIds.BloodShieldMastery, 0); - if (aurEff != null) - caster.CastCustomSpell(SpellIds.BloodShieldAbsorb, SpellValueMod.BasePoint0, MathFunctions.CalculatePct(heal, aurEff.GetAmount()), caster); - - if (caster.HasAura(SpellIds.Frost)) - caster.CastSpell(GetHitUnit(), SpellIds.DeathStrikeOffhand, true); - } - - void TriggerRecentlyUsedDeathStrike() - { - GetCaster().CastSpell(GetCaster(), SpellIds.RecentlyUsedDeathStrike, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleHeal, 1, SpellEffectName.WeaponPercentDamage)); - AfterCast.Add(new CastHandler(TriggerRecentlyUsedDeathStrike)); - } + return ValidateSpellInfo(SpellIds.DeathStrikeHeal, SpellIds.BloodShieldMastery, SpellIds.BloodShieldAbsorb, + SpellIds.RecentlyUsedDeathStrike, SpellIds.Frost, SpellIds.DeathStrikeOffhand); } - public override SpellScript GetSpellScript() + void HandleHeal(uint effIndex) { - return new spell_dk_death_strike_SpellScript(); + Unit caster = GetCaster(); + //TODO: heal = std::min(10% health, 20% of all damage taken in last 5 seconds) + int heal = (int)MathFunctions.CalculatePct(caster.GetMaxHealth(), GetSpellInfo().GetEffect(4).CalcValue()); + caster.CastCustomSpell(SpellIds.DeathStrikeHeal, SpellValueMod.BasePoint0, heal, caster, true); + + AuraEffect aurEff = caster.GetAuraEffect(SpellIds.BloodShieldMastery, 0); + if (aurEff != null) + caster.CastCustomSpell(SpellIds.BloodShieldAbsorb, SpellValueMod.BasePoint0, MathFunctions.CalculatePct(heal, aurEff.GetAmount()), caster); + + if (caster.HasAura(SpellIds.Frost)) + caster.CastSpell(GetHitUnit(), SpellIds.DeathStrikeOffhand, true); + } + + void TriggerRecentlyUsedDeathStrike() + { + GetCaster().CastSpell(GetCaster(), SpellIds.RecentlyUsedDeathStrike, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleHeal, 1, SpellEffectName.WeaponPercentDamage)); + AfterCast.Add(new CastHandler(TriggerRecentlyUsedDeathStrike)); } } [Script] // 85948 - Festering Strike - class spell_dk_festering_strike : SpellScriptLoader + class spell_dk_festering_strike : SpellScript { - public spell_dk_festering_strike() : base("spell_dk_festering_strike") { } - - class spell_dk_festering_strike_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.FesteringWound); - } - - void HandleDummy(uint effIndex) - { - GetCaster().CastCustomSpell(SpellIds.FesteringWound, SpellValueMod.AuraStack, GetEffectValue(), GetHitUnit(), TriggerCastFlags.FullMask); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 2, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellIds.FesteringWound); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_dk_festering_strike_SpellScript(); + GetCaster().CastCustomSpell(SpellIds.FesteringWound, SpellValueMod.AuraStack, GetEffectValue(), GetHitUnit(), TriggerCastFlags.FullMask); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 2, SpellEffectName.Dummy)); } } [Script] // 47496 - Explode, Ghoul spell for Corpse Explosion - class spell_dk_ghoul_explode : SpellScriptLoader + class spell_dk_ghoul_explode : SpellScript { - public spell_dk_ghoul_explode() : base("spell_dk_ghoul_explode") { } - - class spell_dk_ghoul_explode_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.CorpseExplosionTriggered); - } + return ValidateSpellInfo(SpellIds.CorpseExplosionTriggered); + } - void HandleDamage(uint effIndex) - { - SetHitDamage((int)GetCaster().CountPctFromMaxHealth(GetEffectInfo(2).CalcValue(GetCaster()))); - } + void HandleDamage(uint effIndex) + { + SetHitDamage((int)GetCaster().CountPctFromMaxHealth(GetEffectInfo(2).CalcValue(GetCaster()))); + } - void Suicide(uint effIndex) + void Suicide(uint effIndex) + { + Unit unitTarget = GetHitUnit(); + if (unitTarget) { - Unit unitTarget = GetHitUnit(); - if (unitTarget) - { - // Corpse Explosion (Suicide) - unitTarget.CastSpell(unitTarget, SpellIds.CorpseExplosionTriggered, true); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDamage, 0, SpellEffectName.SchoolDamage)); - OnEffectHitTarget.Add(new EffectHandler(Suicide, 1, SpellEffectName.SchoolDamage)); + // Corpse Explosion (Suicide) + unitTarget.CastSpell(unitTarget, SpellIds.CorpseExplosionTriggered, true); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_dk_ghoul_explode_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDamage, 0, SpellEffectName.SchoolDamage)); + OnEffectHitTarget.Add(new EffectHandler(Suicide, 1, SpellEffectName.SchoolDamage)); } } [Script] // 206940 - Mark of Blood - class spell_dk_mark_of_blood : SpellScriptLoader + class spell_dk_mark_of_blood : AuraScript { - public spell_dk_mark_of_blood() : base("spell_dk_mark_of_blood") { } - - class spell_dk_mark_of_blood_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.MarkOfBloodHeal); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - Unit caster = GetCaster(); - if (caster) - caster.CastSpell(eventInfo.GetProcTarget(), SpellIds.MarkOfBloodHeal, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.MarkOfBloodHeal); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_dk_mark_of_blood_AuraScript(); + PreventDefaultAction(); + Unit caster = GetCaster(); + if (caster) + caster.CastSpell(eventInfo.GetProcTarget(), SpellIds.MarkOfBloodHeal, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } [Script] // 207346 - Necrosis - class spell_dk_necrosis : SpellScriptLoader + class spell_dk_necrosis : AuraScript { - public spell_dk_necrosis() : base("spell_dk_necrosis") { } - - class spell_dk_necrosis_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.NecrosisEffect); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.NecrosisEffect, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.NecrosisEffect); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_dk_necrosis_AuraScript(); + PreventDefaultAction(); + GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.NecrosisEffect, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } [Script] // 121916 - Glyph of the Geist (Unholy) // 6.x, does this belong here or in spell_generic? apply this in creature_template_addon? sniffs say this is always cast on raise dead. - class spell_dk_pet_geist_transform : SpellScriptLoader + class spell_dk_pet_geist_transform : SpellScript { - public spell_dk_pet_geist_transform() : base("spell_dk_pet_geist_transform") { } - - class spell_dk_pet_geist_transform_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.GlyphOfTheGeist); - } - - public override bool Load() - { - return GetCaster().IsPet(); - } - - SpellCastResult CheckCast() - { - Unit owner = GetCaster().GetOwner(); - if (owner) - if (owner.HasAura(SpellIds.GlyphOfTheGeist)) - return SpellCastResult.SpellCastOk; - - return SpellCastResult.SpellUnavailable; - } - - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - } + return ValidateSpellInfo(SpellIds.GlyphOfTheGeist); } - public override SpellScript GetSpellScript() + public override bool Load() { - return new spell_dk_pet_geist_transform_SpellScript(); + return GetCaster().IsPet(); + } + + SpellCastResult CheckCast() + { + Unit owner = GetCaster().GetOwner(); + if (owner) + if (owner.HasAura(SpellIds.GlyphOfTheGeist)) + return SpellCastResult.SpellCastOk; + + return SpellCastResult.SpellUnavailable; + } + + public override void Register() + { + OnCheckCast.Add(new CheckCastHandler(CheckCast)); } } [Script] // 147157 Glyph of the Skeleton (Unholy) // 6.x, does this belong here or in spell_generic? apply this in creature_template_addon? sniffs say this is always cast on raise dead. - class spell_dk_pet_skeleton_transform : SpellScriptLoader + class spell_dk_pet_skeleton_transform : SpellScript { - public spell_dk_pet_skeleton_transform() : base("spell_dk_pet_skeleton_transform") { } - - class spell_dk_pet_skeleton_transform_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.GlyphOfTheSkeleton); - } - - SpellCastResult CheckCast() - { - Unit owner = GetCaster().GetOwner(); - if (owner) - if (owner.HasAura(SpellIds.GlyphOfTheSkeleton)) - return SpellCastResult.SpellCastOk; - - return SpellCastResult.SpellUnavailable; - } - - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - } + return ValidateSpellInfo(SpellIds.GlyphOfTheSkeleton); } - public override SpellScript GetSpellScript() + SpellCastResult CheckCast() { - return new spell_dk_pet_skeleton_transform_SpellScript(); + Unit owner = GetCaster().GetOwner(); + if (owner) + if (owner.HasAura(SpellIds.GlyphOfTheSkeleton)) + return SpellCastResult.SpellCastOk; + + return SpellCastResult.SpellUnavailable; + } + + public override void Register() + { + OnCheckCast.Add(new CheckCastHandler(CheckCast)); } } [Script] // 61257 - Runic Power Back on Snare/Root 7.1.5 - class spell_dk_pvp_4p_bonus : SpellScriptLoader + class spell_dk_pvp_4p_bonus : AuraScript { - public spell_dk_pvp_4p_bonus() : base("spell_dk_pvp_4p_bonus") { } - - class spell_dk_pvp_4p_bonus_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.RunicReturn); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - SpellInfo spellInfo = eventInfo.GetSpellInfo(); - if (spellInfo == null) - return false; - - return (spellInfo.GetAllEffectsMechanicMask() & ((1 << (int)Mechanics.Root) | (1 << (int)Mechanics.Snare))) != 0; - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - eventInfo.GetActionTarget().CastSpell((Unit)null, SpellIds.RunicReturn, true); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.RunicReturn); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_dk_pvp_4p_bonus_AuraScript(); + SpellInfo spellInfo = eventInfo.GetSpellInfo(); + if (spellInfo == null) + return false; + + return (spellInfo.GetAllEffectsMechanicMask() & ((1 << (int)Mechanics.Root) | (1 << (int)Mechanics.Snare))) != 0; + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + eventInfo.GetActionTarget().CastSpell((Unit)null, SpellIds.RunicReturn, true); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } [Script] // 46584 - Raise Dead - class spell_dk_raise_dead : SpellScriptLoader + class spell_dk_raise_dead : SpellScript { - public spell_dk_raise_dead() : base("spell_dk_raise_dead") { } - - class spell_dk_raise_dead_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.RaiseDeadSummon, SpellIds.SludgeBelcher, SpellIds.SludgeBelcherSummon); - } - - void HandleDummy(uint effIndex) - { - uint spellId = SpellIds.RaiseDeadSummon; - if (GetCaster().HasAura(SpellIds.SludgeBelcher)) - spellId = SpellIds.SludgeBelcherSummon; - - GetCaster().CastSpell((Unit)null, spellId, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellIds.RaiseDeadSummon, SpellIds.SludgeBelcher, SpellIds.SludgeBelcherSummon); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_dk_raise_dead_SpellScript(); + uint spellId = SpellIds.RaiseDeadSummon; + if (GetCaster().HasAura(SpellIds.SludgeBelcher)) + spellId = SpellIds.SludgeBelcherSummon; + + GetCaster().CastSpell((Unit)null, spellId, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 115994 - Unholy Blight - class spell_dk_unholy_blight : SpellScriptLoader + class spell_dk_unholy_blight : SpellScript { - public spell_dk_unholy_blight() : base("spell_dk_unholy_blight") { } - - class spell_dk_unholy_blight_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.FrostFever, SpellIds.BloodPlague); - } - - void HandleDummy(uint effIndex) - { - GetCaster().CastSpell(GetHitUnit(), SpellIds.FrostFever, true); - GetCaster().CastSpell(GetHitUnit(), SpellIds.BloodPlague, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellIds.FrostFever, SpellIds.BloodPlague); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_dk_unholy_blight_SpellScript(); + GetCaster().CastSpell(GetHitUnit(), SpellIds.FrostFever, true); + GetCaster().CastSpell(GetHitUnit(), SpellIds.BloodPlague, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 55233 - Vampiric Blood - class spell_dk_vampiric_blood : SpellScriptLoader + class spell_dk_vampiric_blood : AuraScript { - public spell_dk_vampiric_blood() : base("spell_dk_vampiric_blood") { } - - class spell_dk_vampiric_blood_AuraScript : AuraScript + void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) { - void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) - { - amount = (int)GetUnitOwner().CountPctFromMaxHealth(amount); - } - - public override void Register() - { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 1, AuraType.ModIncreaseHealth2)); - } + amount = (int)GetUnitOwner().CountPctFromMaxHealth(amount); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_dk_vampiric_blood_AuraScript(); + DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 1, AuraType.ModIncreaseHealth2)); } } } diff --git a/Scripts/Spells/Druid.cs b/Scripts/Spells/Druid.cs index c3c594b88..a8c5ea288 100644 --- a/Scripts/Spells/Druid.cs +++ b/Scripts/Spells/Druid.cs @@ -60,1109 +60,841 @@ namespace Scripts.Spells.Druid } [Script] // 1850 - Dash - class spell_dru_dash : SpellScriptLoader + public class spell_dru_dash : AuraScript { - public spell_dru_dash() : base("spell_dru_dash") { } - - public class spell_dru_dash_AuraScript : AuraScript + void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) { - void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) - { - // do not set speed if not in cat form - if (GetUnitOwner().GetShapeshiftForm() != ShapeShiftForm.CatForm) - amount = 0; - } - - public override void Register() - { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.ModIncreaseSpeed)); - } + // do not set speed if not in cat form + if (GetUnitOwner().GetShapeshiftForm() != ShapeShiftForm.CatForm) + amount = 0; } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_dru_dash_AuraScript(); + DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.ModIncreaseSpeed)); } } [Script] // 33943 - Flight Form - class spell_dru_flight_form : SpellScriptLoader + class spell_dru_flight_form : SpellScript { - public spell_dru_flight_form() : base("spell_dru_flight_form") { } - - class spell_dru_flight_form_SpellScript : SpellScript + SpellCastResult CheckCast() { - SpellCastResult CheckCast() - { - Unit caster = GetCaster(); - if (caster.IsInDisallowedMountForm()) - return SpellCastResult.NotShapeshift; + Unit caster = GetCaster(); + if (caster.IsInDisallowedMountForm()) + return SpellCastResult.NotShapeshift; - return SpellCastResult.SpellCastOk; - } - - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - } + return SpellCastResult.SpellCastOk; } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_dru_flight_form_SpellScript(); + OnCheckCast.Add(new CheckCastHandler(CheckCast)); } } [Script] // 37336 - Druid Forms Trinket - class spell_dru_forms_trinket : SpellScriptLoader + class spell_dru_forms_trinket : AuraScript { - public spell_dru_forms_trinket() : base("spell_dru_forms_trinket") { } - - class spell_dru_forms_trinket_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.FormsTrinketBear, SpellIds.FormsTrinketCat, SpellIds.FormsTrinketMoonkin, SpellIds.FormsTrinketNone, SpellIds.FormsTrinketTree); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - Unit target = eventInfo.GetActor(); - - switch (target.GetShapeshiftForm()) - { - case ShapeShiftForm.BearForm: - case ShapeShiftForm.DireBearForm: - case ShapeShiftForm.CatForm: - case ShapeShiftForm.MoonkinForm: - case ShapeShiftForm.None: - case ShapeShiftForm.TreeOfLife: - return true; - default: - break; - } - - return false; - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - Unit target = eventInfo.GetActor(); - uint triggerspell = 0; - - switch (target.GetShapeshiftForm()) - { - case ShapeShiftForm.BearForm: - case ShapeShiftForm.DireBearForm: - triggerspell = SpellIds.FormsTrinketBear; - break; - case ShapeShiftForm.CatForm: - triggerspell = SpellIds.FormsTrinketCat; - break; - case ShapeShiftForm.MoonkinForm: - triggerspell = SpellIds.FormsTrinketMoonkin; - break; - case ShapeShiftForm.None: - triggerspell = SpellIds.FormsTrinketNone; - break; - case ShapeShiftForm.TreeOfLife: - triggerspell = SpellIds.FormsTrinketTree; - break; - default: - return; - } - - target.CastSpell(target, triggerspell, true, null, aurEff); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); - } + return ValidateSpellInfo(SpellIds.FormsTrinketBear, SpellIds.FormsTrinketCat, SpellIds.FormsTrinketMoonkin, SpellIds.FormsTrinketNone, SpellIds.FormsTrinketTree); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_dru_forms_trinket_AuraScript(); + Unit target = eventInfo.GetActor(); + + switch (target.GetShapeshiftForm()) + { + case ShapeShiftForm.BearForm: + case ShapeShiftForm.DireBearForm: + case ShapeShiftForm.CatForm: + case ShapeShiftForm.MoonkinForm: + case ShapeShiftForm.None: + case ShapeShiftForm.TreeOfLife: + return true; + default: + break; + } + + return false; + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + Unit target = eventInfo.GetActor(); + uint triggerspell = 0; + + switch (target.GetShapeshiftForm()) + { + case ShapeShiftForm.BearForm: + case ShapeShiftForm.DireBearForm: + triggerspell = SpellIds.FormsTrinketBear; + break; + case ShapeShiftForm.CatForm: + triggerspell = SpellIds.FormsTrinketCat; + break; + case ShapeShiftForm.MoonkinForm: + triggerspell = SpellIds.FormsTrinketMoonkin; + break; + case ShapeShiftForm.None: + triggerspell = SpellIds.FormsTrinketNone; + break; + case ShapeShiftForm.TreeOfLife: + triggerspell = SpellIds.FormsTrinketTree; + break; + default: + return; + } + + target.CastSpell(target, triggerspell, true, null, aurEff); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); } } // 34246 - Idol of the Emerald Queen [Script] // 60779 - Idol of Lush Moss - class spell_dru_idol_lifebloom : SpellScriptLoader + class spell_dru_idol_lifebloom : AuraScript { - public spell_dru_idol_lifebloom() : base("spell_dru_idol_lifebloom") { } - - class spell_dru_idol_lifebloom_AuraScript : AuraScript + void HandleEffectCalcSpellMod(AuraEffect aurEff, ref SpellModifier spellMod) { - void HandleEffectCalcSpellMod(AuraEffect aurEff, ref SpellModifier spellMod) + if (spellMod == null) { - if (spellMod == null) - { - spellMod = new SpellModifier(GetAura()); - spellMod.op = SpellModOp.Dot; - spellMod.type = SpellModType.Flat; - spellMod.spellId = GetId(); - spellMod.mask = GetSpellInfo().GetEffect(aurEff.GetEffIndex()).SpellClassMask; - } - spellMod.value = aurEff.GetAmount() / 7; - } - - public override void Register() - { - DoEffectCalcSpellMod.Add(new EffectCalcSpellModHandler(HandleEffectCalcSpellMod, 0, AuraType.Dummy)); + spellMod = new SpellModifier(GetAura()); + spellMod.op = SpellModOp.Dot; + spellMod.type = SpellModType.Flat; + spellMod.spellId = GetId(); + spellMod.mask = GetSpellInfo().GetEffect(aurEff.GetEffIndex()).SpellClassMask; } + spellMod.value = aurEff.GetAmount() / 7; } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_dru_idol_lifebloom_AuraScript(); + DoEffectCalcSpellMod.Add(new EffectCalcSpellModHandler(HandleEffectCalcSpellMod, 0, AuraType.Dummy)); } } // 29166 - Innervate [Script] - class spell_dru_innervate : SpellScriptLoader + class spell_dru_innervate : AuraScript { - public spell_dru_innervate() : base("spell_dru_innervate") { } - - class spell_dru_innervate_AuraScript : AuraScript + void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) { - void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) - { - Unit caster = GetCaster(); - if (caster) - amount = MathFunctions.CalculatePct(caster.GetCreatePowers(PowerType.Mana), amount) / aurEff.GetTotalTicks(); - else - amount = 0; - } - - public override void Register() - { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.PeriodicEnergize)); - } + Unit caster = GetCaster(); + if (caster) + amount = MathFunctions.CalculatePct(caster.GetCreatePowers(PowerType.Mana), amount) / aurEff.GetTotalTicks(); + else + amount = 0; } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_dru_innervate_AuraScript(); + DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.PeriodicEnergize)); } } // 33763 - Lifebloom [Script] - class spell_dru_lifebloom : SpellScriptLoader + class spell_dru_lifebloom : AuraScript { - public spell_dru_lifebloom() : base("spell_dru_lifebloom") { } - - class spell_dru_lifebloom_AuraScript : AuraScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) + return ValidateSpellInfo(SpellIds.LifebloomFinalHeal, SpellIds.LifebloomEnergize); + } + + void AfterRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + // Final heal only on duration end + if (GetTargetApplication().GetRemoveMode() != AuraRemoveMode.Expire) + return; + + // final heal + uint stack = GetStackAmount(); + uint healAmount = (uint)aurEff.GetAmount(); + Unit caster = GetCaster(); + if (caster != null) { - return ValidateSpellInfo(SpellIds.LifebloomFinalHeal, SpellIds.LifebloomEnergize); - } - - void AfterRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - // Final heal only on duration end - if (GetTargetApplication().GetRemoveMode() != AuraRemoveMode.Expire) - return; - - // final heal - uint stack = GetStackAmount(); - uint healAmount = (uint)aurEff.GetAmount(); - Unit caster = GetCaster(); - if (caster != null) - { - healAmount = caster.SpellHealingBonusDone(GetTarget(), GetSpellInfo(), healAmount, DamageEffectType.Heal, aurEff.GetSpellEffectInfo(), stack); - healAmount = GetTarget().SpellHealingBonusTaken(caster, GetSpellInfo(), healAmount, DamageEffectType.Heal, aurEff.GetSpellEffectInfo(), stack); - - GetTarget().CastCustomSpell(GetTarget(), SpellIds.LifebloomFinalHeal, (int)healAmount, 0, 0, true, null, aurEff, GetCasterGUID()); - - // restore mana - var costs = GetSpellInfo().CalcPowerCost(caster, GetSpellInfo().GetSchoolMask()); - var m = costs.Find(cost => cost.Power == PowerType.Mana); - if (m != null) - { - int returnMana = m.Amount * (int)stack / 2; - caster.CastCustomSpell(caster, SpellIds.LifebloomEnergize, returnMana, 0, 0, true, null, aurEff, GetCasterGUID()); - } - return; - } + healAmount = caster.SpellHealingBonusDone(GetTarget(), GetSpellInfo(), healAmount, DamageEffectType.Heal, aurEff.GetSpellEffectInfo(), stack); + healAmount = GetTarget().SpellHealingBonusTaken(caster, GetSpellInfo(), healAmount, DamageEffectType.Heal, aurEff.GetSpellEffectInfo(), stack); GetTarget().CastCustomSpell(GetTarget(), SpellIds.LifebloomFinalHeal, (int)healAmount, 0, 0, true, null, aurEff, GetCasterGUID()); - } - void HandleDispel(DispelInfo dispelInfo) - { - Unit target = GetUnitOwner(); - if (target != null) + // restore mana + var costs = GetSpellInfo().CalcPowerCost(caster, GetSpellInfo().GetSchoolMask()); + var m = costs.Find(cost => cost.Power == PowerType.Mana); + if (m != null) { - AuraEffect aurEff = GetEffect(1); - if (aurEff != null) - { - // final heal - uint healAmount = (uint)aurEff.GetAmount(); - Unit caster = GetCaster(); - if (caster != null) - { - healAmount = caster.SpellHealingBonusDone(target, GetSpellInfo(), healAmount, DamageEffectType.Heal, aurEff.GetSpellEffectInfo(), dispelInfo.GetRemovedCharges()); - healAmount = target.SpellHealingBonusTaken(caster, GetSpellInfo(), healAmount, DamageEffectType.Heal, aurEff.GetSpellEffectInfo(), dispelInfo.GetRemovedCharges()); - target.CastCustomSpell(target, SpellIds.LifebloomFinalHeal, (int)healAmount, 0, 0, true, null, null, GetCasterGUID()); - - // restore mana - var costs = GetSpellInfo().CalcPowerCost(caster, GetSpellInfo().GetSchoolMask()); - var m = costs.Find(cost => cost.Power == PowerType.Mana); - if (m != null) - { - int returnMana = m.Amount * dispelInfo.GetRemovedCharges() / 2; - caster.CastCustomSpell(caster, SpellIds.LifebloomEnergize, returnMana, 0, 0, true, null, null, GetCasterGUID()); - } - return; - } - - target.CastCustomSpell(target, SpellIds.LifebloomFinalHeal, (int)healAmount, 0, 0, true, null, null, GetCasterGUID()); - } + int returnMana = m.Amount * (int)stack / 2; + caster.CastCustomSpell(caster, SpellIds.LifebloomEnergize, returnMana, 0, 0, true, null, aurEff, GetCasterGUID()); } + return; } - public override void Register() + GetTarget().CastCustomSpell(GetTarget(), SpellIds.LifebloomFinalHeal, (int)healAmount, 0, 0, true, null, aurEff, GetCasterGUID()); + } + + void HandleDispel(DispelInfo dispelInfo) + { + Unit target = GetUnitOwner(); + if (target != null) { - AfterEffectRemove.Add(new EffectApplyHandler(AfterRemove, 1, AuraType.Dummy, AuraEffectHandleModes.Real)); - AfterDispel.Add(new AuraDispelHandler(HandleDispel)); + AuraEffect aurEff = GetEffect(1); + if (aurEff != null) + { + // final heal + uint healAmount = (uint)aurEff.GetAmount(); + Unit caster = GetCaster(); + if (caster != null) + { + healAmount = caster.SpellHealingBonusDone(target, GetSpellInfo(), healAmount, DamageEffectType.Heal, aurEff.GetSpellEffectInfo(), dispelInfo.GetRemovedCharges()); + healAmount = target.SpellHealingBonusTaken(caster, GetSpellInfo(), healAmount, DamageEffectType.Heal, aurEff.GetSpellEffectInfo(), dispelInfo.GetRemovedCharges()); + target.CastCustomSpell(target, SpellIds.LifebloomFinalHeal, (int)healAmount, 0, 0, true, null, null, GetCasterGUID()); + + // restore mana + var costs = GetSpellInfo().CalcPowerCost(caster, GetSpellInfo().GetSchoolMask()); + var m = costs.Find(cost => cost.Power == PowerType.Mana); + if (m != null) + { + int returnMana = m.Amount * dispelInfo.GetRemovedCharges() / 2; + caster.CastCustomSpell(caster, SpellIds.LifebloomEnergize, returnMana, 0, 0, true, null, null, GetCasterGUID()); + } + return; + } + + target.CastCustomSpell(target, SpellIds.LifebloomFinalHeal, (int)healAmount, 0, 0, true, null, null, GetCasterGUID()); + } } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_dru_lifebloom_AuraScript(); + AfterEffectRemove.Add(new EffectApplyHandler(AfterRemove, 1, AuraType.Dummy, AuraEffectHandleModes.Real)); + AfterDispel.Add(new AuraDispelHandler(HandleDispel)); } } // 48496 - Living Seed [Script] - class spell_dru_living_seed : SpellScriptLoader + class spell_dru_living_seed : AuraScript { - public spell_dru_living_seed() : base("spell_dru_living_seed") { } - - class spell_dru_living_seed_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.LivingSeedProc); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - int amount = (int)MathFunctions.CalculatePct(eventInfo.GetHealInfo().GetHeal(), aurEff.GetAmount()); - GetTarget().CastCustomSpell(SpellIds.LivingSeedProc, SpellValueMod.BasePoint0, amount, eventInfo.GetProcTarget(), true, null, aurEff); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.LivingSeedProc); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_dru_living_seed_AuraScript(); + PreventDefaultAction(); + int amount = (int)MathFunctions.CalculatePct(eventInfo.GetHealInfo().GetHeal(), aurEff.GetAmount()); + GetTarget().CastCustomSpell(SpellIds.LivingSeedProc, SpellValueMod.BasePoint0, amount, eventInfo.GetProcTarget(), true, null, aurEff); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } // 48504 - Living Seed (Proc) [Script] - class spell_dru_living_seed_proc : SpellScriptLoader + class spell_dru_living_seed_proc : AuraScript { - public spell_dru_living_seed_proc() : base("spell_dru_living_seed_proc") { } - - class spell_dru_living_seed_proc_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.LivingSeedHeal); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - GetTarget().CastCustomSpell(SpellIds.LivingSeedHeal, SpellValueMod.BasePoint0, aurEff.GetAmount(), GetTarget(), true, null, aurEff); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.LivingSeedHeal); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_dru_living_seed_proc_AuraScript(); + PreventDefaultAction(); + GetTarget().CastCustomSpell(SpellIds.LivingSeedHeal, SpellValueMod.BasePoint0, aurEff.GetAmount(), GetTarget(), true, null, aurEff); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } [Script] // 8921 - Moonfire - class spell_dru_moonfire : SpellScriptLoader + class spell_dru_moonfire : SpellScript { - public spell_dru_moonfire() : base("spell_dru_moonfire") { } - - class spell_dru_moonfire_SpellScript : SpellScript + void HandleOnHit(uint effIndex) { - void HandleOnHit(uint effIndex) - { - GetCaster().CastSpell(GetHitUnit(), SpellIds.MoonfireDamage, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleOnHit, 0, SpellEffectName.Dummy)); - } + GetCaster().CastSpell(GetHitUnit(), SpellIds.MoonfireDamage, true); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_dru_moonfire_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleOnHit, 0, SpellEffectName.Dummy)); } } // 16972 - Predatory Strikes [Script] - class spell_dru_predatory_strikes : SpellScriptLoader + class spell_dru_predatory_strikes : AuraScript { - public spell_dru_predatory_strikes() : base("spell_dru_predatory_strikes") { } - - class spell_dru_predatory_strikes_AuraScript : AuraScript + void UpdateAmount(AuraEffect aurEff, AuraEffectHandleModes mode) { - void UpdateAmount(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Player target = GetTarget().ToPlayer(); - if (target != null) - target.UpdateAttackPowerAndDamage(); - } - - public override void Register() - { - AfterEffectApply.Add(new EffectApplyHandler(UpdateAmount, SpellConst.EffectAll, AuraType.Dummy, AuraEffectHandleModes.ChangeAmountMask)); - AfterEffectRemove.Add(new EffectApplyHandler(UpdateAmount, SpellConst.EffectAll, AuraType.Dummy, AuraEffectHandleModes.ChangeAmountMask)); - } + Player target = GetTarget().ToPlayer(); + if (target != null) + target.UpdateAttackPowerAndDamage(); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_dru_predatory_strikes_AuraScript(); + AfterEffectApply.Add(new EffectApplyHandler(UpdateAmount, SpellConst.EffectAll, AuraType.Dummy, AuraEffectHandleModes.ChangeAmountMask)); + AfterEffectRemove.Add(new EffectApplyHandler(UpdateAmount, SpellConst.EffectAll, AuraType.Dummy, AuraEffectHandleModes.ChangeAmountMask)); } } // 1079 - Rip [Script] - class spell_dru_rip : SpellScriptLoader + class spell_dru_rip : AuraScript { - public spell_dru_rip() : base("spell_dru_rip") { } - - class spell_dru_rip_AuraScript : AuraScript + public override bool Load() { - public override bool Load() + Unit caster = GetCaster(); + return caster != null && caster.IsTypeId(TypeId.Player); + } + + void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + canBeRecalculated = false; + + Unit caster = GetCaster(); + if (caster != null) { - Unit caster = GetCaster(); - return caster != null && caster.IsTypeId(TypeId.Player); - } + // 0.01 * $AP * cp + byte cp = caster.ToPlayer().GetComboPoints(); - void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) - { - canBeRecalculated = false; + // Idol of Feral Shadows. Can't be handled as SpellMod due its dependency from CPs + AuraEffect idol = caster.GetAuraEffect(SpellIds.IdolOfFeralShadows, 0); + if (idol != null) + amount += cp * idol.GetAmount(); + // Idol of Worship. Can't be handled as SpellMod due its dependency from CPs + else if ((idol = caster.GetAuraEffect(SpellIds.IdolOfWorship, 0)) != null) + amount += cp * idol.GetAmount(); - Unit caster = GetCaster(); - if (caster != null) - { - // 0.01 * $AP * cp - byte cp = caster.ToPlayer().GetComboPoints(); - - // Idol of Feral Shadows. Can't be handled as SpellMod due its dependency from CPs - AuraEffect idol = caster.GetAuraEffect(SpellIds.IdolOfFeralShadows, 0); - if (idol != null) - amount += cp * idol.GetAmount(); - // Idol of Worship. Can't be handled as SpellMod due its dependency from CPs - else if ((idol = caster.GetAuraEffect(SpellIds.IdolOfWorship, 0)) != null) - amount += cp * idol.GetAmount(); - - amount += (int)MathFunctions.CalculatePct(caster.GetTotalAttackPowerValue(WeaponAttackType.BaseAttack), cp); - } - } - - public override void Register() - { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.PeriodicDamage)); + amount += (int)MathFunctions.CalculatePct(caster.GetTotalAttackPowerValue(WeaponAttackType.BaseAttack), cp); } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_dru_rip_AuraScript(); + DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.PeriodicDamage)); } } [Script] // 16864 - Omen of Clarity - class spell_dru_omen_of_clarity : SpellScriptLoader + class spell_dru_omen_of_clarity : AuraScript { - public spell_dru_omen_of_clarity() : base("spell_dru_omen_of_clarity") { } - - class spell_dru_omen_of_clarity_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.BalanceT10Bonus, SpellIds.BalanceT10BonusProc); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - Unit target = GetTarget(); - if (target.HasAura(SpellIds.BalanceT10Bonus)) - target.CastSpell((Unit)null, SpellIds.BalanceT10BonusProc, true, null); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); - } + return ValidateSpellInfo(SpellIds.BalanceT10Bonus, SpellIds.BalanceT10BonusProc); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_dru_omen_of_clarity_AuraScript(); + Unit target = GetTarget(); + if (target.HasAura(SpellIds.BalanceT10Bonus)) + target.CastSpell((Unit)null, SpellIds.BalanceT10BonusProc, true, null); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); } } // 52610 - Savage Roar [Script] - class spell_dru_savage_roar : SpellScriptLoader + class spell_dru_savage_roar : SpellScript { - public spell_dru_savage_roar() : base("spell_dru_savage_roar") { } - - class spell_dru_savage_roar_SpellScript : SpellScript + SpellCastResult CheckCast() { - SpellCastResult CheckCast() - { - Unit caster = GetCaster(); - if (caster.GetShapeshiftForm() != ShapeShiftForm.CatForm) - return SpellCastResult.OnlyShapeshift; + Unit caster = GetCaster(); + if (caster.GetShapeshiftForm() != ShapeShiftForm.CatForm) + return SpellCastResult.OnlyShapeshift; - return SpellCastResult.SpellCastOk; - } - - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - } + return SpellCastResult.SpellCastOk; } - class spell_dru_savage_roar_AuraScript : AuraScript + public override void Register() { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.SavageRoar); - } + OnCheckCast.Add(new CheckCastHandler(CheckCast)); + } + } - void AfterApply(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Unit target = GetTarget(); - target.CastSpell(target, SpellIds.SavageRoar, true, null, aurEff, GetCasterGUID()); - } - - void AfterRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - GetTarget().RemoveAurasDueToSpell(SpellIds.SavageRoar); - } - - 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_dru_savage_roar_AuraScript : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.SavageRoar); } - public override SpellScript GetSpellScript() + void AfterApply(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_dru_savage_roar_SpellScript(); + Unit target = GetTarget(); + target.CastSpell(target, SpellIds.SavageRoar, true, null, aurEff, GetCasterGUID()); } - public override AuraScript GetAuraScript() + void AfterRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_dru_savage_roar_AuraScript(); + GetTarget().RemoveAurasDueToSpell(SpellIds.SavageRoar); + } + + 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] // 78892 - Stampede - class spell_dru_stampede : SpellScriptLoader + class spell_dru_stampede : AuraScript { - public spell_dru_stampede() : base("spell_dru_stampede") { } - - class spell_dru_stampede_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.StampedeBearRank1, SpellIds.StampedeCatRank1, SpellIds.StampedeCatState, SpellIds.FeralChargeCat, SpellIds.FeralChargeBear); - } - - void HandleEffectCatProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - if (GetTarget().GetShapeshiftForm() != ShapeShiftForm.CatForm || eventInfo.GetDamageInfo().GetSpellInfo().Id != SpellIds.FeralChargeCat) - return; - - GetTarget().CastSpell(GetTarget(), Global.SpellMgr.GetSpellWithRank(SpellIds.StampedeCatRank1, GetSpellInfo().GetRank()), true, null, aurEff); - GetTarget().CastSpell(GetTarget(), SpellIds.StampedeCatState, true, null, aurEff); - } - - void HandleEffectBearProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - if (GetTarget().GetShapeshiftForm() != ShapeShiftForm.BearForm || eventInfo.GetDamageInfo().GetSpellInfo().Id != SpellIds.FeralChargeBear) - return; - - GetTarget().CastSpell(GetTarget(), Global.SpellMgr.GetSpellWithRank(SpellIds.StampedeBearRank1, GetSpellInfo().GetRank()), true, null, aurEff); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleEffectCatProc, 0, AuraType.Dummy)); - OnEffectProc.Add(new EffectProcHandler(HandleEffectBearProc, 1, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.StampedeBearRank1, SpellIds.StampedeCatRank1, SpellIds.StampedeCatState, SpellIds.FeralChargeCat, SpellIds.FeralChargeBear); } - public override AuraScript GetAuraScript() + void HandleEffectCatProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_dru_stampede_AuraScript(); + PreventDefaultAction(); + if (GetTarget().GetShapeshiftForm() != ShapeShiftForm.CatForm || eventInfo.GetDamageInfo().GetSpellInfo().Id != SpellIds.FeralChargeCat) + return; + + GetTarget().CastSpell(GetTarget(), Global.SpellMgr.GetSpellWithRank(SpellIds.StampedeCatRank1, GetSpellInfo().GetRank()), true, null, aurEff); + GetTarget().CastSpell(GetTarget(), SpellIds.StampedeCatState, true, null, aurEff); + } + + void HandleEffectBearProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + if (GetTarget().GetShapeshiftForm() != ShapeShiftForm.BearForm || eventInfo.GetDamageInfo().GetSpellInfo().Id != SpellIds.FeralChargeBear) + return; + + GetTarget().CastSpell(GetTarget(), Global.SpellMgr.GetSpellWithRank(SpellIds.StampedeBearRank1, GetSpellInfo().GetRank()), true, null, aurEff); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleEffectCatProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new EffectProcHandler(HandleEffectBearProc, 1, AuraType.Dummy)); } } // 50286 - Starfall (Dummy) [Script] - class spell_dru_starfall_dummy : SpellScriptLoader + class spell_dru_starfall_dummy : SpellScript { - public spell_dru_starfall_dummy() : base("spell_dru_starfall_dummy") { } - - class spell_dru_starfall_dummy_SpellScript : SpellScript + void FilterTargets(List targets) { - void FilterTargets(List targets) - { - targets.Resize(2); - } - - void HandleDummy(uint effIndex) - { - Unit caster = GetCaster(); - // Shapeshifting into an animal form or mounting cancels the effect - if (caster.GetCreatureType() == CreatureType.Beast || caster.IsMounted()) - { - SpellInfo spellInfo = GetTriggeringSpell(); - if (spellInfo != null) - caster.RemoveAurasDueToSpell(spellInfo.Id); - return; - } - - // Any effect which causes you to lose control of your character will supress the starfall effect. - if (caster.HasUnitState(UnitState.Controlled)) - return; - - caster.CastSpell(GetHitUnit(), (uint)GetEffectValue(), true); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEnemy)); - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + targets.Resize(2); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_dru_starfall_dummy_SpellScript(); + Unit caster = GetCaster(); + // Shapeshifting into an animal form or mounting cancels the effect + if (caster.GetCreatureType() == CreatureType.Beast || caster.IsMounted()) + { + SpellInfo spellInfo = GetTriggeringSpell(); + if (spellInfo != null) + caster.RemoveAurasDueToSpell(spellInfo.Id); + return; + } + + // Any effect which causes you to lose control of your character will supress the starfall effect. + if (caster.HasUnitState(UnitState.Controlled)) + return; + + caster.CastSpell(GetHitUnit(), (uint)GetEffectValue(), true); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEnemy)); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 93402 - Sunfire - class spell_dru_sunfire : SpellScriptLoader + class spell_dru_sunfire : SpellScript { - public spell_dru_sunfire() : base("spell_dru_sunfire") { } - - class spell_dru_sunfire_SpellScript : SpellScript + void HandleOnHit(uint effIndex) { - void HandleOnHit(uint effIndex) - { - GetCaster().CastSpell(GetHitUnit(), SpellIds.SunfireDamage, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleOnHit, 0, SpellEffectName.Dummy)); - } + GetCaster().CastSpell(GetHitUnit(), SpellIds.SunfireDamage, true); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_dru_sunfire_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleOnHit, 0, SpellEffectName.Dummy)); } } // 61336 - Survival Instincts [Script] - class spell_dru_survival_instincts : SpellScriptLoader + class spell_dru_survival_instincts : SpellScript { - public spell_dru_survival_instincts() : base("spell_dru_survival_instincts") { } - - class spell_dru_survival_instincts_SpellScript : SpellScript + SpellCastResult CheckCast() { - SpellCastResult CheckCast() - { - Unit caster = GetCaster(); - if (!caster.IsInFeralForm()) - return SpellCastResult.OnlyShapeshift; + Unit caster = GetCaster(); + if (!caster.IsInFeralForm()) + return SpellCastResult.OnlyShapeshift; - return SpellCastResult.SpellCastOk; - } - - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - } + return SpellCastResult.SpellCastOk; } - class spell_dru_survival_instincts_AuraScript : AuraScript + public override void Register() { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.SurvivalInstincts); - } + OnCheckCast.Add(new CheckCastHandler(CheckCast)); + } + } - void AfterApply(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Unit target = GetTarget(); - int bp0 = (int)target.CountPctFromMaxHealth(aurEff.GetAmount()); - target.CastCustomSpell(target, SpellIds.SurvivalInstincts, bp0, 0, 0, true); - } - - void AfterRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - GetTarget().RemoveAurasDueToSpell(SpellIds.SurvivalInstincts); - } - - public override void Register() - { - AfterEffectApply.Add(new EffectApplyHandler(AfterApply, 0, AuraType.Dummy, AuraEffectHandleModes.ChangeAmountMask)); - AfterEffectRemove.Add(new EffectApplyHandler(AfterRemove, 0, AuraType.Dummy, AuraEffectHandleModes.ChangeAmountMask)); - } + [Script] + class spell_dru_survival_instincts_AuraScript : AuraScript + { + public override bool Validate(SpellInfo spell) + { + return ValidateSpellInfo(SpellIds.SurvivalInstincts); } - public override SpellScript GetSpellScript() + void AfterApply(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_dru_survival_instincts_SpellScript(); + Unit target = GetTarget(); + int bp0 = (int)target.CountPctFromMaxHealth(aurEff.GetAmount()); + target.CastCustomSpell(target, SpellIds.SurvivalInstincts, bp0, 0, 0, true); } - public override AuraScript GetAuraScript() + void AfterRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_dru_survival_instincts_AuraScript(); + GetTarget().RemoveAurasDueToSpell(SpellIds.SurvivalInstincts); + } + + public override void Register() + { + AfterEffectApply.Add(new EffectApplyHandler(AfterApply, 0, AuraType.Dummy, AuraEffectHandleModes.ChangeAmountMask)); + AfterEffectRemove.Add(new EffectApplyHandler(AfterRemove, 0, AuraType.Dummy, AuraEffectHandleModes.ChangeAmountMask)); } } // 40121 - Swift Flight Form (Passive) [Script] - class spell_dru_swift_flight_passive : SpellScriptLoader + class spell_dru_swift_flight_passive : AuraScript { - public spell_dru_swift_flight_passive() : base("spell_dru_swift_flight_passive") { } - - class spell_dru_swift_flight_passive_AuraScript : AuraScript + public override bool Load() { - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Player); - } - - void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) - { - Player caster = GetCaster().ToPlayer(); - if (caster != null) - if (caster.GetSkillValue(SkillType.Riding) >= 375) - amount = 310; - } - - public override void Register() - { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 1, AuraType.ModIncreaseVehicleFlightSpeed)); - } + return GetCaster().IsTypeId(TypeId.Player); } - public override AuraScript GetAuraScript() + void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) { - return new spell_dru_swift_flight_passive_AuraScript(); + Player caster = GetCaster().ToPlayer(); + if (caster != null) + if (caster.GetSkillValue(SkillType.Riding) >= 375) + amount = 310; + } + + public override void Register() + { + DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 1, AuraType.ModIncreaseVehicleFlightSpeed)); } } [Script] // 28744 - Regrowth - class spell_dru_t3_6p_bonus : SpellScriptLoader + class spell_dru_t3_6p_bonus : AuraScript { - public spell_dru_t3_6p_bonus() : base("spell_dru_t3_6p_bonus") { } - - class spell_dru_t3_6p_bonus_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.BlessingOfTheClaw); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), SpellIds.BlessingOfTheClaw, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.OverrideClassScripts)); - } + return ValidateSpellInfo(SpellIds.BlessingOfTheClaw); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_dru_t3_6p_bonus_AuraScript(); + PreventDefaultAction(); + eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), SpellIds.BlessingOfTheClaw, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.OverrideClassScripts)); } } [Script] // 28719 - Healing Touch - class spell_dru_t3_8p_bonus : SpellScriptLoader + class spell_dru_t3_8p_bonus : AuraScript { - public spell_dru_t3_8p_bonus() : base("spell_dru_t3_8p_bonus") { } - - class spell_dru_t3_8p_bonus_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.Exhilarate); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - SpellInfo spellInfo = eventInfo.GetSpellInfo(); - if (spellInfo == null) - return; - - Unit caster = eventInfo.GetActor(); - var costs = spellInfo.CalcPowerCost(caster, spellInfo.GetSchoolMask()); - var m = costs.First(cost => { return cost.Power == PowerType.Mana; }); - if (m == null) - return; - - int amount = MathFunctions.CalculatePct(m.Amount, aurEff.GetAmount()); - caster.CastCustomSpell(SpellIds.Exhilarate, SpellValueMod.BasePoint0, amount, (Unit)null, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.Exhilarate); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_dru_t3_8p_bonus_AuraScript(); + PreventDefaultAction(); + SpellInfo spellInfo = eventInfo.GetSpellInfo(); + if (spellInfo == null) + return; + + Unit caster = eventInfo.GetActor(); + var costs = spellInfo.CalcPowerCost(caster, spellInfo.GetSchoolMask()); + var m = costs.First(cost => { return cost.Power == PowerType.Mana; }); + if (m == null) + return; + + int amount = MathFunctions.CalculatePct(m.Amount, aurEff.GetAmount()); + caster.CastCustomSpell(SpellIds.Exhilarate, SpellValueMod.BasePoint0, amount, (Unit)null, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } // 37288 - Mana Restore [Script] // 37295 - Mana Restore - class spell_dru_t4_2p_bonus : SpellScriptLoader + class spell_dru_t4_2p_bonus : AuraScript { - public spell_dru_t4_2p_bonus() : base("spell_dru_t4_2p_bonus") { } - - class spell_dru_t4_2p_bonus_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.Infusion); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - eventInfo.GetActor().CastSpell((Unit)null, SpellIds.Infusion, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.Infusion); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_dru_t4_2p_bonus_AuraScript(); + PreventDefaultAction(); + eventInfo.GetActor().CastSpell((Unit)null, SpellIds.Infusion, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } [Script] // 40442 - Druid Tier 6 Trinket - class spell_dru_item_t6_trinket : SpellScriptLoader + class spell_dru_item_t6_trinket : AuraScript { - public spell_dru_item_t6_trinket() : base("spell_dru_item_t6_trinket") { } - - class spell_dru_item_t6_trinket_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.BlessingOfTheRemulos, SpellIds.BlessingOfTheElune, SpellIds.BlessingOfTheCenarius); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - SpellInfo spellInfo = eventInfo.GetSpellInfo(); - if (spellInfo == null) - return; - - uint spellId; - int chance; - - // Starfire - if (spellInfo.SpellFamilyFlags[0].HasAnyFlag(0x00000004u)) - { - spellId = SpellIds.BlessingOfTheRemulos; - chance = 25; - } - // Rejuvenation - else if (spellInfo.SpellFamilyFlags[0].HasAnyFlag(0x00000010u)) - { - spellId = SpellIds.BlessingOfTheElune; - chance = 25; - } - // Mangle (Bear) and Mangle (Cat) - else if (spellInfo.SpellFamilyFlags[1].HasAnyFlag(0x00000440u)) - { - spellId = SpellIds.BlessingOfTheCenarius; - chance = 40; - } - else - return; - - if (RandomHelper.randChance(chance)) - eventInfo.GetActor().CastSpell((Unit)null, spellId, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.BlessingOfTheRemulos, SpellIds.BlessingOfTheElune, SpellIds.BlessingOfTheCenarius); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_dru_item_t6_trinket_AuraScript(); + PreventDefaultAction(); + SpellInfo spellInfo = eventInfo.GetSpellInfo(); + if (spellInfo == null) + return; + + uint spellId; + int chance; + + // Starfire + if (spellInfo.SpellFamilyFlags[0].HasAnyFlag(0x00000004u)) + { + spellId = SpellIds.BlessingOfTheRemulos; + chance = 25; + } + // Rejuvenation + else if (spellInfo.SpellFamilyFlags[0].HasAnyFlag(0x00000010u)) + { + spellId = SpellIds.BlessingOfTheElune; + chance = 25; + } + // Mangle (Bear) and Mangle (Cat) + else if (spellInfo.SpellFamilyFlags[1].HasAnyFlag(0x00000440u)) + { + spellId = SpellIds.BlessingOfTheCenarius; + chance = 40; + } + else + return; + + if (RandomHelper.randChance(chance)) + eventInfo.GetActor().CastSpell((Unit)null, spellId, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } [Script] // 70723 - Item - Druid T10 Balance 4P Bonus - class spell_dru_t10_balance_4p_bonus : SpellScriptLoader + class spell_dru_t10_balance_4p_bonus : AuraScript { - public spell_dru_t10_balance_4p_bonus() : base("spell_dru_t10_balance_4p_bonus") { } - - class spell_dru_t10_balance_4p_bonus_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.Languish); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - DamageInfo damageInfo = eventInfo.GetDamageInfo(); - if (damageInfo == null || damageInfo.GetDamage() == 0) - return; - - Unit caster = eventInfo.GetActor(); - Unit target = eventInfo.GetProcTarget(); - - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.Languish); - int amount = (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount()); - amount /= (int)spellInfo.GetMaxTicks(Difficulty.None); - // Add remaining ticks to damage done - amount += (int)target.GetRemainingPeriodicAmount(caster.GetGUID(), SpellIds.Languish, AuraType.PeriodicDamage); - - caster.CastCustomSpell(SpellIds.Languish, SpellValueMod.BasePoint0, amount, target, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.Languish); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_dru_t10_balance_4p_bonus_AuraScript(); + PreventDefaultAction(); + + DamageInfo damageInfo = eventInfo.GetDamageInfo(); + if (damageInfo == null || damageInfo.GetDamage() == 0) + return; + + Unit caster = eventInfo.GetActor(); + Unit target = eventInfo.GetProcTarget(); + + SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.Languish); + int amount = (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount()); + amount /= (int)spellInfo.GetMaxTicks(Difficulty.None); + // Add remaining ticks to damage done + amount += (int)target.GetRemainingPeriodicAmount(caster.GetGUID(), SpellIds.Languish, AuraType.PeriodicDamage); + + caster.CastCustomSpell(SpellIds.Languish, SpellValueMod.BasePoint0, amount, target, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } // 70691 - Item T10 Restoration 4P Bonus [Script] - class spell_dru_t10_restoration_4p_bonus : SpellScriptLoader + class spell_dru_t10_restoration_4p_bonus : SpellScript { - public spell_dru_t10_restoration_4p_bonus() : base("spell_dru_t10_restoration_4p_bonus") { } - - class spell_dru_t10_restoration_4p_bonus_SpellScript : SpellScript + public override bool Load() { - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Player); - } + return GetCaster().IsTypeId(TypeId.Player); + } - void FilterTargets(List targets) + void FilterTargets(List targets) + { + if (GetCaster().ToPlayer().GetGroup() == null) { - if (GetCaster().ToPlayer().GetGroup() == null) + targets.Clear(); + targets.Add(GetCaster()); + } + else + { + targets.Remove(GetExplTargetUnit()); + List tempTargets = new List(); + foreach (var obj in targets) + if (obj.IsTypeId(TypeId.Player) && GetCaster().IsInRaidWith(obj.ToUnit())) + tempTargets.Add(obj.ToUnit()); + + if (tempTargets.Empty()) { targets.Clear(); - targets.Add(GetCaster()); + FinishCast(SpellCastResult.DontReport); + return; } - else - { - targets.Remove(GetExplTargetUnit()); - List tempTargets = new List(); - foreach (var obj in targets) - if (obj.IsTypeId(TypeId.Player) && GetCaster().IsInRaidWith(obj.ToUnit())) - tempTargets.Add(obj.ToUnit()); - if (tempTargets.Empty()) - { - targets.Clear(); - FinishCast(SpellCastResult.DontReport); - return; - } - - Unit target = tempTargets.SelectRandom(); - targets.Clear(); - targets.Add(target); - } - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaAlly)); + Unit target = tempTargets.SelectRandom(); + targets.Clear(); + targets.Add(target); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_dru_t10_restoration_4p_bonus_SpellScript(); + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaAlly)); } } [Script] // 70664 - Druid T10 Restoration 4P Bonus (Rejuvenation) - class spell_dru_t10_restoration_4p_bonus_dummy : SpellScriptLoader + class spell_dru_t10_restoration_4p_bonus_dummy : AuraScript { - public spell_dru_t10_restoration_4p_bonus_dummy() : base("spell_dru_t10_restoration_4p_bonus_dummy") { } - - class spell_dru_t10_restoration_4p_bonus_dummy_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.RejuvenationT10Proc); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - SpellInfo spellInfo = eventInfo.GetSpellInfo(); - if (spellInfo == null || spellInfo.Id == SpellIds.RejuvenationT10Proc) - return false; - - HealInfo healInfo = eventInfo.GetHealInfo(); - if (healInfo == null || healInfo.GetHeal() == 0) - return false; - - Player caster = eventInfo.GetActor().ToPlayer(); - if (!caster) - return false; - - return caster.GetGroup() || caster != eventInfo.GetProcTarget(); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - int amount = (int)eventInfo.GetHealInfo().GetHeal(); - eventInfo.GetActor().CastCustomSpell(SpellIds.RejuvenationT10Proc, SpellValueMod.BasePoint0, amount, (Unit)null, true); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.RejuvenationT10Proc); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_dru_t10_restoration_4p_bonus_dummy_AuraScript(); + SpellInfo spellInfo = eventInfo.GetSpellInfo(); + if (spellInfo == null || spellInfo.Id == SpellIds.RejuvenationT10Proc) + return false; + + HealInfo healInfo = eventInfo.GetHealInfo(); + if (healInfo == null || healInfo.GetHeal() == 0) + return false; + + Player caster = eventInfo.GetActor().ToPlayer(); + if (!caster) + return false; + + return caster.GetGroup() || caster != eventInfo.GetProcTarget(); + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + + int amount = (int)eventInfo.GetHealInfo().GetHeal(); + eventInfo.GetActor().CastCustomSpell(SpellIds.RejuvenationT10Proc, SpellValueMod.BasePoint0, amount, (Unit)null, true); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } [Script] // 48438 - Wild Growth - class spell_dru_wild_growth : SpellScriptLoader + class spell_dru_wild_growth : SpellScript { - public spell_dru_wild_growth() : base("spell_dru_wild_growth") { } - - class spell_dru_wild_growth_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) + SpellEffectInfo effect2 = spellInfo.GetEffect(2); + if (effect2 == null || effect2.IsEffect() || effect2.CalcValue() <= 0) + return false; + return true; + } + + void FilterTargets(List targets) + { + targets.RemoveAll(obj => { - SpellEffectInfo effect2 = spellInfo.GetEffect(2); - if (effect2 == null || effect2.IsEffect() || effect2.CalcValue() <= 0) - return false; + Unit target = obj.ToUnit(); + if (target) + return !GetCaster().IsInRaidWith(target); + return true; - } + }); - void FilterTargets(List targets) + int maxTargets = GetSpellInfo().GetEffect(2).CalcValue(GetCaster()); + + if (targets.Count > maxTargets) { - targets.RemoveAll(obj => - { - Unit target = obj.ToUnit(); - if (target) - return !GetCaster().IsInRaidWith(target); - - return true; - }); - - int maxTargets = GetSpellInfo().GetEffect(2).CalcValue(GetCaster()); - - if (targets.Count > maxTargets) - { - targets.Sort(new HealthPctOrderPred()); - targets.RemoveRange(maxTargets, targets.Count - maxTargets); - } - - _targets = targets; + targets.Sort(new HealthPctOrderPred()); + targets.RemoveRange(maxTargets, targets.Count - maxTargets); } - void SetTargets(List targets) - { - targets.Clear(); - targets .AddRange(_targets); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaAlly)); - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(SetTargets, 1, Targets.UnitDestAreaAlly)); - } - - List _targets; + _targets = targets; } - public override SpellScript GetSpellScript() + void SetTargets(List targets) { - return new spell_dru_wild_growth_SpellScript(); + targets.Clear(); + targets.AddRange(_targets); } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaAlly)); + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(SetTargets, 1, Targets.UnitDestAreaAlly)); + } + + List _targets; } } diff --git a/Scripts/Spells/Generic.cs b/Scripts/Spells/Generic.cs index 4a04ca1f7..40efcbae8 100644 --- a/Scripts/Spells/Generic.cs +++ b/Scripts/Spells/Generic.cs @@ -257,7 +257,7 @@ namespace Scripts.Spells.Generic //Landmineknockbackachievement public const uint LandmineKnockbackAchievement = 57064; - + //Ponyspells public const uint AchievementPonyup = 3736; public const uint MountPony = 29736; @@ -359,1442 +359,1107 @@ namespace Scripts.Spells.Generic } [Script] - class spell_gen_absorb0_hitlimit1 : SpellScriptLoader + class spell_gen_absorb0_hitlimit1 : AuraScript { - public spell_gen_absorb0_hitlimit1() : base("spell_gen_absorb0_hitlimit1") { } - - class spell_gen_absorb0_hitlimit1_AuraScript : AuraScript + public override bool Load() { - public override bool Load() - { - // Max absorb stored in 1 dummy effect - limit = GetSpellInfo().GetEffect(1).CalcValue(); - return true; - } - - void Absorb(AuraEffect aurEff, DamageInfo dmgInfo, ref uint absorbAmount) - { - absorbAmount = (uint)Math.Min(limit, absorbAmount); - } - - public override void Register() - { - OnEffectAbsorb.Add(new EffectAbsorbHandler(Absorb, 0)); - } - - int limit; + // Max absorb stored in 1 dummy effect + limit = GetSpellInfo().GetEffect(1).CalcValue(); + return true; } - public override AuraScript GetAuraScript() + void Absorb(AuraEffect aurEff, DamageInfo dmgInfo, ref uint absorbAmount) { - return new spell_gen_absorb0_hitlimit1_AuraScript(); + absorbAmount = (uint)Math.Min(limit, absorbAmount); } + + public override void Register() + { + OnEffectAbsorb.Add(new EffectAbsorbHandler(Absorb, 0)); + } + + int limit; } [Script] // 28764 - Adaptive Warding (Frostfire Regalia Set) - class spell_gen_adaptive_warding : SpellScriptLoader + class spell_gen_adaptive_warding : AuraScript { - public spell_gen_adaptive_warding() : base("spell_gen_adaptive_warding") { } - - class spell_gen_adaptive_warding_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.GenAdaptiveWardingFire, SpellIds.GenAdaptiveWardingNature, SpellIds.GenAdaptiveWardingFrost, SpellIds.GenAdaptiveWardingShadow, SpellIds.GenAdaptiveWardingArcane); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - if (eventInfo.GetDamageInfo().GetSpellInfo() != null) // eventInfo.GetSpellInfo() - return false; - - // find Mage Armor - if (GetTarget().GetAuraEffect(AuraType.ModManaRegenInterrupt, SpellFamilyNames.Mage, new FlagArray128(0x10000000, 0x0, 0x0)) == null) - return false; - - switch (SharedConst.GetFirstSchoolInMask(eventInfo.GetSchoolMask())) - { - case SpellSchools.Normal: - case SpellSchools.Holy: - return false; - default: - break; - } - return true; - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - uint spellId = 0; - switch (SharedConst.GetFirstSchoolInMask(eventInfo.GetSchoolMask())) - { - case SpellSchools.Fire: - spellId = SpellIds.GenAdaptiveWardingFire; - break; - case SpellSchools.Nature: - spellId = SpellIds.GenAdaptiveWardingNature; - break; - case SpellSchools.Frost: - spellId = SpellIds.GenAdaptiveWardingFrost; - break; - case SpellSchools.Shadow: - spellId = SpellIds.GenAdaptiveWardingShadow; - break; - case SpellSchools.Arcane: - spellId = SpellIds.GenAdaptiveWardingArcane; - break; - default: - return; - } - GetTarget().CastSpell(GetTarget(), spellId, true, null, aurEff); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.GenAdaptiveWardingFire, SpellIds.GenAdaptiveWardingNature, SpellIds.GenAdaptiveWardingFrost, SpellIds.GenAdaptiveWardingShadow, SpellIds.GenAdaptiveWardingArcane); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_gen_adaptive_warding_AuraScript(); + if (eventInfo.GetDamageInfo().GetSpellInfo() != null) // eventInfo.GetSpellInfo() + return false; + + // find Mage Armor + if (GetTarget().GetAuraEffect(AuraType.ModManaRegenInterrupt, SpellFamilyNames.Mage, new FlagArray128(0x10000000, 0x0, 0x0)) == null) + return false; + + switch (SharedConst.GetFirstSchoolInMask(eventInfo.GetSchoolMask())) + { + case SpellSchools.Normal: + case SpellSchools.Holy: + return false; + default: + break; + } + return true; + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + + uint spellId = 0; + switch (SharedConst.GetFirstSchoolInMask(eventInfo.GetSchoolMask())) + { + case SpellSchools.Fire: + spellId = SpellIds.GenAdaptiveWardingFire; + break; + case SpellSchools.Nature: + spellId = SpellIds.GenAdaptiveWardingNature; + break; + case SpellSchools.Frost: + spellId = SpellIds.GenAdaptiveWardingFrost; + break; + case SpellSchools.Shadow: + spellId = SpellIds.GenAdaptiveWardingShadow; + break; + case SpellSchools.Arcane: + spellId = SpellIds.GenAdaptiveWardingArcane; + break; + default: + return; + } + GetTarget().CastSpell(GetTarget(), spellId, true, null, aurEff); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } [Script] - class spell_gen_allow_cast_from_item_only : SpellScriptLoader + class spell_gen_allow_cast_from_item_only : SpellScript { - public spell_gen_allow_cast_from_item_only() : base("spell_gen_allow_cast_from_item_only") { } - - class spell_gen_allow_cast_from_item_only_SpellScript : SpellScript + SpellCastResult CheckRequirement() { - SpellCastResult CheckRequirement() - { - if (!GetCastItem()) - return SpellCastResult.CantDoThatRightNow; - return SpellCastResult.SpellCastOk; - } - - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckRequirement)); - } + if (!GetCastItem()) + return SpellCastResult.CantDoThatRightNow; + return SpellCastResult.SpellCastOk; } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_gen_allow_cast_from_item_only_SpellScript(); + OnCheckCast.Add(new CheckCastHandler(CheckRequirement)); } } [Script] - class spell_gen_animal_blood : SpellScriptLoader + class spell_gen_animal_blood : AuraScript { - public spell_gen_animal_blood() : base("spell_gen_animal_blood") { } - - class spell_gen_animal_blood_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.SpawnBloodPool); - } - - void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) - { - // Remove all auras with spell id 46221, except the one currently being applied - Aura aur; - while ((aur = GetUnitOwner().GetOwnedAura(SpellIds.AnimalBlood, ObjectGuid.Empty, ObjectGuid.Empty, 0, GetAura())) != null) - GetUnitOwner().RemoveOwnedAura(aur); - } - - void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Unit owner = GetUnitOwner(); - if (owner) - if (owner.IsInWater()) - owner.CastSpell(owner, SpellIds.SpawnBloodPool, true); - } - - public override void Register() - { - AfterEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.PeriodicTriggerSpell, AuraEffectHandleModes.Real)); - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.PeriodicTriggerSpell, AuraEffectHandleModes.Real)); - } + return ValidateSpellInfo(SpellIds.SpawnBloodPool); } - public override AuraScript GetAuraScript() + void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_gen_animal_blood_AuraScript(); + // Remove all auras with spell id 46221, except the one currently being applied + Aura aur; + while ((aur = GetUnitOwner().GetOwnedAura(SpellIds.AnimalBlood, ObjectGuid.Empty, ObjectGuid.Empty, 0, GetAura())) != null) + GetUnitOwner().RemoveOwnedAura(aur); + } + + void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit owner = GetUnitOwner(); + if (owner) + if (owner.IsInWater()) + owner.CastSpell(owner, SpellIds.SpawnBloodPool, true); + } + + public override void Register() + { + AfterEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.PeriodicTriggerSpell, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.PeriodicTriggerSpell, AuraEffectHandleModes.Real)); } } [Script] // 41337 Aura of Anger - class spell_gen_aura_of_anger : SpellScriptLoader + class spell_gen_aura_of_anger : AuraScript { - public spell_gen_aura_of_anger() : base("spell_gen_aura_of_anger") { } - - class spell_gen_aura_of_anger_AuraScript : AuraScript + void HandleEffectPeriodicUpdate(AuraEffect aurEff) { - void HandleEffectPeriodicUpdate(AuraEffect aurEff) - { - AuraEffect aurEff1 = aurEff.GetBase().GetEffect(1); - if (aurEff1 != null) - aurEff1.ChangeAmount(aurEff1.GetAmount() + 5); - aurEff.SetAmount((int)(100 * aurEff.GetTickNumber())); - } - - public override void Register() - { - OnEffectUpdatePeriodic.Add(new EffectUpdatePeriodicHandler(HandleEffectPeriodicUpdate, 0, AuraType.PeriodicDamage)); - } + AuraEffect aurEff1 = aurEff.GetBase().GetEffect(1); + if (aurEff1 != null) + aurEff1.ChangeAmount(aurEff1.GetAmount() + 5); + aurEff.SetAmount((int)(100 * aurEff.GetTickNumber())); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_gen_aura_of_anger_AuraScript(); + OnEffectUpdatePeriodic.Add(new EffectUpdatePeriodicHandler(HandleEffectPeriodicUpdate, 0, AuraType.PeriodicDamage)); } } [Script] - class spell_gen_aura_service_uniform : SpellScriptLoader + class spell_gen_aura_service_uniform : AuraScript { - public spell_gen_aura_service_uniform() : base("spell_gen_aura_service_uniform") { } - - class spell_gen_aura_service_uniform_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ServiceUniform); - } + return ValidateSpellInfo(SpellIds.ServiceUniform); + } - void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) + void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) + { + // Apply model goblin + Unit target = GetTarget(); + if (target.IsTypeId(TypeId.Player)) { - // Apply model goblin - Unit target = GetTarget(); - if (target.IsTypeId(TypeId.Player)) - { - if (target.GetGender() == Gender.Male) - target.SetDisplayId(ModelIds.GoblinMale); - else - target.SetDisplayId(ModelIds.GoblinFemale); - } - } - - void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Unit target = GetTarget(); - if (target.IsTypeId(TypeId.Player)) - target.RestoreDisplayId(); - } - - public override void Register() - { - AfterEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.Transform, AuraEffectHandleModes.Real)); - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Transform, AuraEffectHandleModes.Real)); + if (target.GetGender() == Gender.Male) + target.SetDisplayId(ModelIds.GoblinMale); + else + target.SetDisplayId(ModelIds.GoblinFemale); } } - public override AuraScript GetAuraScript() + void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_gen_aura_service_uniform_AuraScript(); + Unit target = GetTarget(); + if (target.IsTypeId(TypeId.Player)) + target.RestoreDisplayId(); + } + + public override void Register() + { + AfterEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.Transform, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Transform, AuraEffectHandleModes.Real)); } } [Script] - class spell_gen_av_drekthar_presence : SpellScriptLoader + class spell_gen_av_drekthar_presence : AuraScript { - public spell_gen_av_drekthar_presence() : base("spell_gen_av_drekthar_presence") { } - - class spell_gen_av_drekthar_presence_AuraScript : AuraScript + bool CheckAreaTarget(Unit target) { - bool CheckAreaTarget(Unit target) + switch (target.GetEntry()) { - switch (target.GetEntry()) - { - // alliance - case 14762: // Dun Baldar North Marshal - case 14763: // Dun Baldar South Marshal - case 14764: // Icewing Marshal - case 14765: // Stonehearth Marshal - case 11948: // Vandar Stormspike - // horde - case 14772: // East Frostwolf Warmaster - case 14776: // Tower Point Warmaster - case 14773: // Iceblood Warmaster - case 14777: // West Frostwolf Warmaster - case 11946: // Drek'thar - return true; - default: - return false; - } - } - - public override void Register() - { - DoCheckAreaTarget.Add(new CheckAreaTargetHandler(CheckAreaTarget)); + // alliance + case 14762: // Dun Baldar North Marshal + case 14763: // Dun Baldar South Marshal + case 14764: // Icewing Marshal + case 14765: // Stonehearth Marshal + case 11948: // Vandar Stormspike + // horde + case 14772: // East Frostwolf Warmaster + case 14776: // Tower Point Warmaster + case 14773: // Iceblood Warmaster + case 14777: // West Frostwolf Warmaster + case 11946: // Drek'thar + return true; + default: + return false; } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_gen_av_drekthar_presence_AuraScript(); + DoCheckAreaTarget.Add(new CheckAreaTargetHandler(CheckAreaTarget)); } } [Script] - class spell_gen_bandage : SpellScriptLoader + class spell_gen_bandage : SpellScript { - public spell_gen_bandage() : base("spell_gen_bandage") { } - - class spell_gen_bandage_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.RecentlyBandaged); - } - - SpellCastResult CheckCast() - { - Unit target = GetExplTargetUnit(); - if (target) - { - if (target.HasAura(SpellIds.RecentlyBandaged)) - return SpellCastResult.TargetAurastate; - } - return SpellCastResult.SpellCastOk; - } - - void HandleScript() - { - Unit target = GetHitUnit(); - if (target) - GetCaster().CastSpell(target, SpellIds.RecentlyBandaged, true); - } - - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - AfterHit.Add(new HitHandler(HandleScript)); - } + return ValidateSpellInfo(SpellIds.RecentlyBandaged); } - public override SpellScript GetSpellScript() + SpellCastResult CheckCast() { - return new spell_gen_bandage_SpellScript(); + Unit target = GetExplTargetUnit(); + if (target) + { + if (target.HasAura(SpellIds.RecentlyBandaged)) + return SpellCastResult.TargetAurastate; + } + return SpellCastResult.SpellCastOk; + } + + void HandleScript() + { + Unit target = GetHitUnit(); + if (target) + GetCaster().CastSpell(target, SpellIds.RecentlyBandaged, true); + } + + public override void Register() + { + OnCheckCast.Add(new CheckCastHandler(CheckCast)); + AfterHit.Add(new HitHandler(HandleScript)); } } [Script] // Blood Reserve - 64568 - class spell_gen_blood_reserve : SpellScriptLoader + class spell_gen_blood_reserve : AuraScript { - public spell_gen_blood_reserve() : base("spell_gen_blood_reserve") { } - - class spell_gen_blood_reserve_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.BloodReserveHeal); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - DamageInfo dmgInfo = eventInfo.GetDamageInfo(); - if (dmgInfo != null) - { - Unit caster = eventInfo.GetActionTarget(); - if (caster) - if (caster.HealthBelowPctDamaged(35, dmgInfo.GetDamage())) - return true; - } - - return false; - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - Unit caster = eventInfo.GetActionTarget(); - caster.CastCustomSpell(SpellIds.BloodReserveHeal, SpellValueMod.BasePoint0, aurEff.GetAmount(), caster, TriggerCastFlags.FullMask, null, aurEff); - caster.RemoveAura(SpellIds.BloodReserveAura); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); - } + return ValidateSpellInfo(SpellIds.BloodReserveHeal); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_gen_blood_reserve_AuraScript(); + DamageInfo dmgInfo = eventInfo.GetDamageInfo(); + if (dmgInfo != null) + { + Unit caster = eventInfo.GetActionTarget(); + if (caster) + if (caster.HealthBelowPctDamaged(35, dmgInfo.GetDamage())) + return true; + } + + return false; + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + + Unit caster = eventInfo.GetActionTarget(); + caster.CastCustomSpell(SpellIds.BloodReserveHeal, SpellValueMod.BasePoint0, aurEff.GetAmount(), caster, TriggerCastFlags.FullMask, null, aurEff); + caster.RemoveAura(SpellIds.BloodReserveAura); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); } } [Script] - class spell_gen_bonked : SpellScriptLoader + class spell_gen_bonked : SpellScript { - public spell_gen_bonked() : base("spell_gen_bonked") { } - - class spell_gen_bonked_SpellScript : SpellScript + void HandleScript(uint effIndex) { - void HandleScript(uint effIndex) + Player target = GetHitPlayer(); + if (target) { - Player target = GetHitPlayer(); - if (target) + Aura aura = GetHitAura(); + if (!(aura != null && aura.GetStackAmount() == 3)) + return; + + target.CastSpell(target, SpellIds.FormSwordDefeat, true); + target.RemoveAurasDueToSpell(SpellIds.Bonked); + + aura = target.GetAura(SpellIds.Onguard); + if (aura != null) { - Aura aura = GetHitAura(); - if (!(aura != null && aura.GetStackAmount() == 3)) - return; - - target.CastSpell(target, SpellIds.FormSwordDefeat, true); - target.RemoveAurasDueToSpell(SpellIds.Bonked); - - aura = target.GetAura(SpellIds.Onguard); - if (aura != null) - { - Item item = target.GetItemByGuid(aura.GetCastItemGUID()); - if (item) - target.DestroyItemCount(item.GetEntry(), 1, true); - } + Item item = target.GetItemByGuid(aura.GetCastItemGUID()); + if (item) + target.DestroyItemCount(item.GetEntry(), 1, true); } } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 1, SpellEffectName.ScriptEffect)); - } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_gen_bonked_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 1, SpellEffectName.ScriptEffect)); } } [Script("spell_gen_break_shield")] [Script("spell_gen_tournament_counterattack")] - class spell_gen_break_shield : SpellScriptLoader + class spell_gen_break_shield : SpellScript { - public spell_gen_break_shield(string name) : base(name) { } - - class spell_gen_break_shield_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(62552, 62719, 64100, 66482); - } + return ValidateSpellInfo(62552, 62719, 64100, 66482); + } - void HandleScriptEffect(uint effIndex) - { - Unit target = GetHitUnit(); + void HandleScriptEffect(uint effIndex) + { + Unit target = GetHitUnit(); - switch (effIndex) - { - case 0: // On spells wich trigger the damaging spell (and also the visual) + switch (effIndex) + { + case 0: // On spells wich trigger the damaging spell (and also the visual) + { + uint spellId; + + switch (GetSpellInfo().Id) { - uint spellId; - - switch (GetSpellInfo().Id) - { - case SpellIds.BreakShieldTriggerUnk: - case SpellIds.BreakShieldTriggerCampaingWarhorse: - spellId = SpellIds.BreakShieldDamage10k; - break; - case SpellIds.BreakShieldTriggerFactionMounts: - spellId = SpellIds.BreakShieldDamage2k; - break; - default: - return; - } - Unit rider = GetCaster().GetCharmer(); - if (rider) - rider.CastSpell(target, spellId, false); - else - GetCaster().CastSpell(target, spellId, false); - break; + case SpellIds.BreakShieldTriggerUnk: + case SpellIds.BreakShieldTriggerCampaingWarhorse: + spellId = SpellIds.BreakShieldDamage10k; + break; + case SpellIds.BreakShieldTriggerFactionMounts: + spellId = SpellIds.BreakShieldDamage2k; + break; + default: + return; } - case 1: // On damaging spells, for removing a defend layer + Unit rider = GetCaster().GetCharmer(); + if (rider) + rider.CastSpell(target, spellId, false); + else + GetCaster().CastSpell(target, spellId, false); + break; + } + case 1: // On damaging spells, for removing a defend layer + { + var auras = target.GetAppliedAuras(); + foreach (var pair in auras) { - var auras = target.GetAppliedAuras(); - foreach (var pair in auras) + Aura aura = pair.Value.GetBase(); + if (aura != null) { - Aura aura = pair.Value.GetBase(); - if (aura != null) + if (aura.GetId() == 62552 || aura.GetId() == 62719 || aura.GetId() == 64100 || aura.GetId() == 66482) { - if (aura.GetId() == 62552 || aura.GetId() == 62719 || aura.GetId() == 64100 || aura.GetId() == 66482) + aura.ModStackAmount(-1, AuraRemoveMode.EnemySpell); + // Remove dummys from rider (Necessary for updating visual shields) + Unit rider = target.GetCharmer(); + if (rider) { - aura.ModStackAmount(-1, AuraRemoveMode.EnemySpell); - // Remove dummys from rider (Necessary for updating visual shields) - Unit rider = target.GetCharmer(); - if (rider) - { - Aura defend = rider.GetAura(aura.GetId()); - if (defend != null) - defend.ModStackAmount(-1, AuraRemoveMode.EnemySpell); - } - break; + Aura defend = rider.GetAura(aura.GetId()); + if (defend != null) + defend.ModStackAmount(-1, AuraRemoveMode.EnemySpell); } + break; } } - break; } - default: break; - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, SpellConst.EffectFirstFound, SpellEffectName.ScriptEffect)); + } + default: + break; } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_gen_break_shield_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, SpellConst.EffectFirstFound, SpellEffectName.ScriptEffect)); } } [Script] // 46394 Brutallus Burn - class spell_gen_burn_brutallus : SpellScriptLoader + class spell_gen_burn_brutallus : AuraScript { - public spell_gen_burn_brutallus() : base("spell_gen_burn_brutallus") { } - - class spell_gen_burn_brutallus_AuraScript : AuraScript + void HandleEffectPeriodicUpdate(AuraEffect aurEff) { - void HandleEffectPeriodicUpdate(AuraEffect aurEff) - { - if (aurEff.GetTickNumber() % 11 == 0) - aurEff.SetAmount(aurEff.GetAmount() * 2); - } - - public override void Register() - { - OnEffectUpdatePeriodic.Add(new EffectUpdatePeriodicHandler(HandleEffectPeriodicUpdate, 0, AuraType.PeriodicDamage)); - } + if (aurEff.GetTickNumber() % 11 == 0) + aurEff.SetAmount(aurEff.GetAmount() * 2); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_gen_burn_brutallus_AuraScript(); + OnEffectUpdatePeriodic.Add(new EffectUpdatePeriodicHandler(HandleEffectPeriodicUpdate, 0, AuraType.PeriodicDamage)); } } [Script] // 48750 - Burning Depths Necrolyte Image - class spell_gen_burning_depths_necrolyte_image : SpellScriptLoader + class spell_gen_burning_depths_necrolyte_image : AuraScript { - public spell_gen_burning_depths_necrolyte_image() : base("spell_gen_burning_depths_necrolyte_image") { } - - class spell_gen_burning_depths_necrolyte_image_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo((uint)spellInfo.GetEffect(2).CalcValue()); - } - - void HandleApply(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Unit caster = GetCaster(); - if (caster) - caster.CastSpell(GetTarget(), (uint)GetSpellInfo().GetEffect(2).CalcValue()); - } - - void HandleRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - GetTarget().RemoveAurasDueToSpell((uint)GetSpellInfo().GetEffect(2).CalcValue(), GetCasterGUID()); - } - - public override void Register() - { - AfterEffectApply.Add(new EffectApplyHandler(HandleApply, 0, AuraType.Transform, AuraEffectHandleModes.Real)); - AfterEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.Transform, AuraEffectHandleModes.Real)); - } + return ValidateSpellInfo((uint)spellInfo.GetEffect(2).CalcValue()); } - public override AuraScript GetAuraScript() + void HandleApply(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_gen_burning_depths_necrolyte_image_AuraScript(); + Unit caster = GetCaster(); + if (caster) + caster.CastSpell(GetTarget(), (uint)GetSpellInfo().GetEffect(2).CalcValue()); + } + + void HandleRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + GetTarget().RemoveAurasDueToSpell((uint)GetSpellInfo().GetEffect(2).CalcValue(), GetCasterGUID()); + } + + public override void Register() + { + AfterEffectApply.Add(new EffectApplyHandler(HandleApply, 0, AuraType.Transform, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.Transform, AuraEffectHandleModes.Real)); } } [Script] - class spell_gen_cannibalize : SpellScriptLoader + class spell_gen_cannibalize : SpellScript { - public spell_gen_cannibalize() : base("spell_gen_cannibalize") { } - - class spell_gen_cannibalize_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.CannibalizeTriggered); - } - - SpellCastResult CheckIfCorpseNear() - { - Unit caster = GetCaster(); - float max_range = GetSpellInfo().GetMaxRange(false); - // search for nearby enemy corpse in range - var check = new AnyDeadUnitSpellTargetInRangeCheck(caster, max_range, GetSpellInfo(), SpellTargetCheckTypes.Enemy); - var searcher = new UnitSearcher(caster, check); - Cell.VisitWorldObjects(caster, searcher, max_range); - if (!searcher.GetTarget()) - Cell.VisitGridObjects(caster, searcher, max_range); - if (!searcher.GetTarget()) - return SpellCastResult.NoEdibleCorpses; - return SpellCastResult.SpellCastOk; - } - - void HandleDummy(uint effIndex) - { - GetCaster().CastSpell(GetCaster(), SpellIds.CannibalizeTriggered, false); - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - OnCheckCast.Add(new CheckCastHandler(CheckIfCorpseNear)); - } + return ValidateSpellInfo(SpellIds.CannibalizeTriggered); } - public override SpellScript GetSpellScript() + SpellCastResult CheckIfCorpseNear() { - return new spell_gen_cannibalize_SpellScript(); + Unit caster = GetCaster(); + float max_range = GetSpellInfo().GetMaxRange(false); + // search for nearby enemy corpse in range + var check = new AnyDeadUnitSpellTargetInRangeCheck(caster, max_range, GetSpellInfo(), SpellTargetCheckTypes.Enemy); + var searcher = new UnitSearcher(caster, check); + Cell.VisitWorldObjects(caster, searcher, max_range); + if (!searcher.GetTarget()) + Cell.VisitGridObjects(caster, searcher, max_range); + if (!searcher.GetTarget()) + return SpellCastResult.NoEdibleCorpses; + return SpellCastResult.SpellCastOk; + } + + void HandleDummy(uint effIndex) + { + GetCaster().CastSpell(GetCaster(), SpellIds.CannibalizeTriggered, false); + } + + public override void Register() + { + OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnCheckCast.Add(new CheckCastHandler(CheckIfCorpseNear)); } } [Script] - class spell_gen_chaos_blast : SpellScriptLoader + class spell_gen_chaos_blast : SpellScript { - public spell_gen_chaos_blast() : base("spell_gen_chaos_blast") { } - - class spell_gen_chaos_blast_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ChaosBlast); - } - - void HandleDummy(uint effIndex) - { - int basepoints0 = 100; - Unit caster = GetCaster(); - Unit target = GetHitUnit(); - if (target) - caster.CastCustomSpell(target, SpellIds.ChaosBlast, basepoints0, 0, 0, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellIds.ChaosBlast); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_gen_chaos_blast_SpellScript(); + int basepoints0 = 100; + Unit caster = GetCaster(); + Unit target = GetHitUnit(); + if (target) + caster.CastCustomSpell(target, SpellIds.ChaosBlast, basepoints0, 0, 0, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] - class spell_gen_clone : SpellScriptLoader + class spell_gen_clone : SpellScript { - public spell_gen_clone() : base("spell_gen_clone") { } - - class spell_gen_clone_SpellScript : SpellScript + void HandleScriptEffect(uint effIndex) { - void HandleScriptEffect(uint effIndex) - { - PreventHitDefaultEffect(effIndex); - GetHitUnit().CastSpell(GetCaster(), (uint)GetEffectValue(), true); - } - - public override void Register() - { - if (m_scriptSpellId == SpellIds.NightmareFigmentMirrorImage) - { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 1, SpellEffectName.Dummy)); - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 2, SpellEffectName.Dummy)); - } - else - { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 1, SpellEffectName.ScriptEffect)); - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 2, SpellEffectName.ScriptEffect)); - } - } + PreventHitDefaultEffect(effIndex); + GetHitUnit().CastSpell(GetCaster(), (uint)GetEffectValue(), true); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_gen_clone_SpellScript(); + if (m_scriptSpellId == SpellIds.NightmareFigmentMirrorImage) + { + OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 1, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 2, SpellEffectName.Dummy)); + } + else + { + OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 1, SpellEffectName.ScriptEffect)); + OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 2, SpellEffectName.ScriptEffect)); + } } } [Script] - class spell_gen_clone_weapon : SpellScriptLoader + class spell_gen_clone_weapon : SpellScript { - public spell_gen_clone_weapon() : base("spell_gen_clone_weapon") { } - - class spell_gen_clone_weapon_SpellScript : SpellScript + void HandleScriptEffect(uint effIndex) { - void HandleScriptEffect(uint effIndex) - { - PreventHitDefaultEffect(effIndex); - GetHitUnit().CastSpell(GetCaster(), (uint)GetEffectValue(), true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); - } + PreventHitDefaultEffect(effIndex); + GetHitUnit().CastSpell(GetCaster(), (uint)GetEffectValue(), true); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_gen_clone_weapon_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); } } [Script] - class spell_gen_clone_weapon_aura : SpellScriptLoader + class spell_gen_clone_weapon_AuraScript : AuraScript { - public spell_gen_clone_weapon_aura() : base("spell_gen_clone_weapon_aura") { } - - class spell_gen_clone_weapon_auraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.WeaponAura, SpellIds.Weapon2Aura, SpellIds.Weapon3Aura, SpellIds.OffhandAura, SpellIds.Offhand2Aura, SpellIds.RangedAura); - } + return ValidateSpellInfo(SpellIds.WeaponAura, SpellIds.Weapon2Aura, SpellIds.Weapon3Aura, SpellIds.OffhandAura, SpellIds.Offhand2Aura, SpellIds.RangedAura); + } - public override bool Load() - { - prevItem = 0; - return true; - } + public override bool Load() + { + prevItem = 0; + return true; + } - void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Unit caster = GetCaster(); - Unit target = GetTarget(); - if (!caster) - return; + void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit caster = GetCaster(); + Unit target = GetTarget(); + if (!caster) + return; - switch (GetSpellInfo().Id) - { - case SpellIds.WeaponAura: - case SpellIds.Weapon2Aura: - case SpellIds.Weapon3Aura: + switch (GetSpellInfo().Id) + { + case SpellIds.WeaponAura: + case SpellIds.Weapon2Aura: + case SpellIds.Weapon3Aura: + { + prevItem = target.GetVirtualItemId(0); + + Player player = caster.ToPlayer(); + if (player) { - prevItem = target.GetVirtualItemId(0); - - Player player = caster.ToPlayer(); - if (player) - { - Item mainItem = player.GetItemByPos(InventorySlots.Bag0, EquipmentSlot.MainHand); - if (mainItem) - target.SetVirtualItem(0, mainItem.GetEntry()); - } - else - target.SetVirtualItem(0, caster.GetVirtualItemId(0)); - break; + Item mainItem = player.GetItemByPos(InventorySlots.Bag0, EquipmentSlot.MainHand); + if (mainItem) + target.SetVirtualItem(0, mainItem.GetEntry()); } - case SpellIds.OffhandAura: - case SpellIds.Offhand2Aura: + else + target.SetVirtualItem(0, caster.GetVirtualItemId(0)); + break; + } + case SpellIds.OffhandAura: + case SpellIds.Offhand2Aura: + { + prevItem = target.GetVirtualItemId(1); + + Player player = caster.ToPlayer(); + if (player) { - prevItem = target.GetVirtualItemId(1); - - Player player = caster.ToPlayer(); - if (player) - { - Item offItem = player.GetItemByPos(InventorySlots.Bag0, EquipmentSlot.OffHand); - if (offItem) - target.SetVirtualItem(1, offItem.GetEntry()); - } - else - target.SetVirtualItem(1, caster.GetVirtualItemId(1)); - break; + Item offItem = player.GetItemByPos(InventorySlots.Bag0, EquipmentSlot.OffHand); + if (offItem) + target.SetVirtualItem(1, offItem.GetEntry()); } - case SpellIds.RangedAura: + else + target.SetVirtualItem(1, caster.GetVirtualItemId(1)); + break; + } + case SpellIds.RangedAura: + { + prevItem = target.GetVirtualItemId(2); + + Player player = caster.ToPlayer(); + if (player) { - prevItem = target.GetVirtualItemId(2); - - Player player = caster.ToPlayer(); - if (player) - { - Item rangedItem = player.GetItemByPos(InventorySlots.Bag0, EquipmentSlot.MainHand); - if (rangedItem) - target.SetVirtualItem(2, rangedItem.GetEntry()); - } - else - target.SetVirtualItem(2, caster.GetVirtualItemId(2)); - break; + Item rangedItem = player.GetItemByPos(InventorySlots.Bag0, EquipmentSlot.MainHand); + if (rangedItem) + target.SetVirtualItem(2, rangedItem.GetEntry()); } - default: + else + target.SetVirtualItem(2, caster.GetVirtualItemId(2)); break; - } + } + default: + break; } - - void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Unit target = GetTarget(); - - switch (GetSpellInfo().Id) - { - case SpellIds.WeaponAura: - case SpellIds.Weapon2Aura: - case SpellIds.Weapon3Aura: - target.SetVirtualItem(0, prevItem); - break; - case SpellIds.OffhandAura: - case SpellIds.Offhand2Aura: - target.SetVirtualItem(1, prevItem); - break; - case SpellIds.RangedAura: - target.SetVirtualItem(2, prevItem); - break; - default: - break; - } - } - - public override void Register() - { - OnEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.RealOrReapplyMask)); - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.RealOrReapplyMask)); - } - - uint prevItem; } - public override AuraScript GetAuraScript() + void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_gen_clone_weapon_auraScript(); + Unit target = GetTarget(); + + switch (GetSpellInfo().Id) + { + case SpellIds.WeaponAura: + case SpellIds.Weapon2Aura: + case SpellIds.Weapon3Aura: + target.SetVirtualItem(0, prevItem); + break; + case SpellIds.OffhandAura: + case SpellIds.Offhand2Aura: + target.SetVirtualItem(1, prevItem); + break; + case SpellIds.RangedAura: + target.SetVirtualItem(2, prevItem); + break; + default: + break; + } } + + public override void Register() + { + OnEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.RealOrReapplyMask)); + OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.RealOrReapplyMask)); + } + + uint prevItem; } [Script("spell_gen_default_count_pct_from_max_hp", 0)] [Script("spell_gen_50pct_count_pct_from_max_hp", 50)] - class spell_gen_count_pct_from_max_hp : SpellScriptLoader + class spell_gen_count_pct_from_max_hp : SpellScript { - public spell_gen_count_pct_from_max_hp(string name, int damagePct) : base(name) + public spell_gen_count_pct_from_max_hp(int damagePct) { _damagePct = damagePct; } - class spell_gen_count_pct_from_max_hp_SpellScript : SpellScript + void RecalculateDamage() { - public spell_gen_count_pct_from_max_hp_SpellScript(int damagePct) - { - _damagePct = damagePct; - } + if (_damagePct == 0) + _damagePct = GetHitDamage(); - void RecalculateDamage() - { - if (_damagePct == 0) - _damagePct = GetHitDamage(); - - SetHitDamage((int)GetHitUnit().CountPctFromMaxHealth(_damagePct)); - } - - public override void Register() - { - OnHit.Add(new HitHandler(RecalculateDamage)); - } - - int _damagePct; + SetHitDamage((int)GetHitUnit().CountPctFromMaxHealth(_damagePct)); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_gen_count_pct_from_max_hp_SpellScript(_damagePct); + OnHit.Add(new HitHandler(RecalculateDamage)); } int _damagePct; } [Script] // 63845 - Create Lance - class spell_gen_create_lance : SpellScriptLoader + class spell_gen_create_lance : SpellScript { - public spell_gen_create_lance() : base("spell_gen_create_lance") { } - - class spell_gen_create_lance_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.CreateLanceAlliance, SpellIds.CreateLanceHorde); - } + return ValidateSpellInfo(SpellIds.CreateLanceAlliance, SpellIds.CreateLanceHorde); + } - void HandleScript(uint effIndex) - { - PreventHitDefaultEffect(effIndex); + void HandleScript(uint effIndex) + { + PreventHitDefaultEffect(effIndex); - Player target = GetHitPlayer(); - if (target) - { - if (target.GetTeam() == Team.Alliance) - GetCaster().CastSpell(target, SpellIds.CreateLanceAlliance, true); - else - GetCaster().CastSpell(target, SpellIds.CreateLanceHorde, true); - } - } - - public override void Register() + Player target = GetHitPlayer(); + if (target) { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + if (target.GetTeam() == Team.Alliance) + GetCaster().CastSpell(target, SpellIds.CreateLanceAlliance, true); + else + GetCaster().CastSpell(target, SpellIds.CreateLanceHorde, true); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_gen_create_lance_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] - class spell_gen_creature_permanent_feign_death : SpellScriptLoader + class spell_gen_creature_permanent_feign_death : AuraScript { - public spell_gen_creature_permanent_feign_death() : base("spell_gen_creature_permanent_feign_death") { } - - class spell_gen_creature_permanent_feign_death_AuraScript : AuraScript + void HandleEffectApply(AuraEffect aurEff, AuraEffectHandleModes mode) { - void HandleEffectApply(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Unit target = GetTarget(); - target.SetFlag(ObjectFields.DynamicFlags, UnitDynFlags.Dead); - target.SetFlag(UnitFields.Flags2, UnitFlags2.FeignDeath); + Unit target = GetTarget(); + target.SetFlag(ObjectFields.DynamicFlags, UnitDynFlags.Dead); + target.SetFlag(UnitFields.Flags2, UnitFlags2.FeignDeath); - if (target.IsTypeId(TypeId.Unit)) - target.ToCreature().SetReactState(ReactStates.Passive); - } - - public override void Register() - { - OnEffectApply.Add(new EffectApplyHandler(HandleEffectApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - } + if (target.IsTypeId(TypeId.Unit)) + target.ToCreature().SetReactState(ReactStates.Passive); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_gen_creature_permanent_feign_death_AuraScript(); + OnEffectApply.Add(new EffectApplyHandler(HandleEffectApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } [Script("spell_gen_sunreaver_disguise")] [Script("spell_gen_silver_covenant_disguise")] - class spell_gen_dalaran_disguise : SpellScriptLoader + class spell_gen_dalaran_disguise : SpellScript { - public spell_gen_dalaran_disguise(string name) : base(name) { } - - class spell_gen_dalaran_disguise_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) + switch (spellInfo.Id) { - switch (spellInfo.Id) + case SpellIds.SunreaverTrigger: + return ValidateSpellInfo(SpellIds.SunreaverFemale, SpellIds.SunreaverMale); + case SpellIds.SilverCovenantTrigger: + return ValidateSpellInfo(SpellIds.SilverCovenantFemale, SpellIds.SilverCovenantMale); + } + return false; + } + + void HandleScript(uint effIndex) + { + Player player = GetHitPlayer(); + if (player) + { + Gender gender = player.GetGender(); + + uint spellId = GetSpellInfo().Id; + switch (spellId) { case SpellIds.SunreaverTrigger: - return ValidateSpellInfo(SpellIds.SunreaverFemale, SpellIds.SunreaverMale); + spellId = gender == Gender.Female ? SpellIds.SunreaverFemale : SpellIds.SunreaverMale; + break; case SpellIds.SilverCovenantTrigger: - return ValidateSpellInfo(SpellIds.SilverCovenantFemale, SpellIds.SilverCovenantMale); - } - return false; - } - - void HandleScript(uint effIndex) - { - Player player = GetHitPlayer(); - if (player) - { - Gender gender = player.GetGender(); - - uint spellId = GetSpellInfo().Id; - switch (spellId) - { - case SpellIds.SunreaverTrigger: - spellId = gender == Gender.Female ? SpellIds.SunreaverFemale : SpellIds.SunreaverMale; - break; - case SpellIds.SilverCovenantTrigger: - spellId = gender == Gender.Female ? SpellIds.SilverCovenantFemale : SpellIds.SilverCovenantMale; - break; - default: - break; - } - - GetCaster().CastSpell(player, spellId, true); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_gen_dalaran_disguise_SpellScript(); - } - } - - [Script] - class spell_gen_defend : SpellScriptLoader - { - public spell_gen_defend() : base("spell_gen_defend") { } - - class spell_gen_defend_AuraScript : AuraScript - { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.VisualShield1, SpellIds.VisualShield2, SpellIds.VisualShield3); - } - - void RefreshVisualShields(AuraEffect aurEff, AuraEffectHandleModes mode) - { - if (GetCaster()) - { - Unit target = GetTarget(); - - for (byte i = 0; i < GetSpellInfo().StackAmount; ++i) - target.RemoveAurasDueToSpell(SpellIds.VisualShield1 + i); - - target.CastSpell(target, SpellIds.VisualShield1 + GetAura().GetStackAmount() - 1, true, null, aurEff); - } - else - GetTarget().RemoveAurasDueToSpell(GetId()); - } - - void RemoveVisualShields(AuraEffect aurEff, AuraEffectHandleModes mode) - { - for (byte i = 0; i < GetSpellInfo().StackAmount; ++i) - GetTarget().RemoveAurasDueToSpell(SpellIds.VisualShield1 + i); - } - - void RemoveDummyFromDriver(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Unit caster = GetCaster(); - if (caster) - { - TempSummon vehicle = caster.ToTempSummon(); - if (vehicle) - { - Unit rider = vehicle.GetSummoner(); - if (rider) - rider.RemoveAurasDueToSpell(GetId()); - } - } - } - - public override void Register() - { - /*SpellInfo spell = Global.SpellMgr.GetSpellInfo(m_scriptSpellId); - - // Defend spells cast by NPCs (add visuals) - if (spell.GetEffect(0).ApplyAuraName == AuraType.ModDamagePercentTaken) - { - AfterEffectApply.Add(new EffectApplyHandler(RefreshVisualShields, 0, AuraType.ModDamagePercentTaken, AuraEffectHandleModes.RealOrReapplyMask)); - OnEffectRemove.Add(new EffectApplyHandler(RemoveVisualShields, 0, AuraType.ModDamagePercentTaken, AuraEffectHandleModes.ChangeAmountMask)); - } - - // Remove Defend spell from player when he dismounts - if (spell.GetEffect(2).ApplyAuraName == AuraType.ModDamagePercentTaken) - OnEffectRemove.Add(new EffectApplyHandler(RemoveDummyFromDriver, 2, AuraType.ModDamagePercentTaken, AuraEffectHandleModes.Real)); - - // Defend spells cast by players (add/remove visuals) - if (spell.GetEffect(1).ApplyAuraName == AuraType.Dummy) - { - AfterEffectApply.Add(new EffectApplyHandler(RefreshVisualShields, 1, AuraType.Dummy, AuraEffectHandleModes.RealOrReapplyMask)); - OnEffectRemove.Add(new EffectApplyHandler(RemoveVisualShields, 1, AuraType.Dummy, AuraEffectHandleModes.ChangeAmountMask)); - }*/ - } - } - - public override AuraScript GetAuraScript() - { - return new spell_gen_defend_AuraScript(); - } - } - - [Script] - class spell_gen_despawn_self : SpellScriptLoader - { - public spell_gen_despawn_self() : base("spell_gen_despawn_self") { } - - class spell_gen_despawn_self_SpellScript : SpellScript - { - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Unit); - } - - void HandleDummy(uint effIndex) - { - if (GetSpellInfo().GetEffect(effIndex).Effect == SpellEffectName.Dummy || GetSpellInfo().GetEffect(effIndex).Effect == SpellEffectName.ScriptEffect) - GetCaster().ToCreature().DespawnOrUnsummon(); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, SpellConst.EffectAll, SpellEffectName.Any)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_gen_despawn_self_SpellScript(); - } - } - - [Script] // 70769 Divine Storm! - class spell_gen_divine_storm_cd_reset : SpellScriptLoader - { - public spell_gen_divine_storm_cd_reset() : base("spell_gen_divine_storm_cd_reset") { } - - class spell_gen_divine_storm_cd_reset_SpellScript : SpellScript - { - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Player); - } - - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.DivineStorm); - } - - void HandleScript(uint effIndex) - { - GetCaster().GetSpellHistory().ResetCooldown(SpellIds.DivineStorm, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.Dummy)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_gen_divine_storm_cd_reset_SpellScript(); - } - } - - [Script] - class spell_gen_ds_flush_knockback : SpellScriptLoader - { - public spell_gen_ds_flush_knockback() : base("spell_gen_ds_flush_knockback") { } - - class spell_gen_ds_flush_knockback_SpellScript : SpellScript - { - void HandleScript(uint effIndex) - { - // Here the target is the water spout and determines the position where the player is knocked from - Unit target = GetHitUnit(); - if (target) - { - Player player = GetCaster().ToPlayer(); - if (player) - { - float horizontalSpeed = 20.0f + (40.0f - GetCaster().GetDistance(target)); - float verticalSpeed = 8.0f; - // This method relies on the Dalaran Sewer map disposition and Water Spout position - // What we do is knock the player from a position exactly behind him and at the end of the pipe - player.KnockbackFrom(target.GetPositionX(), player.GetPositionY(), horizontalSpeed, verticalSpeed); - } - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.Dummy)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_gen_ds_flush_knockback_SpellScript(); - } - } - - [Script] - class spell_gen_dungeon_credit : SpellScriptLoader - { - public spell_gen_dungeon_credit() : base("spell_gen_dungeon_credit") { } - - class spell_gen_dungeon_credit_SpellScript : SpellScript - { - public override bool Load() - { - _handled = false; - return GetCaster().IsTypeId(TypeId.Unit); - } - - void CreditEncounter() - { - // This hook is executed for every target, make sure we only credit instance once - if (_handled) - return; - - _handled = true; - Unit caster = GetCaster(); - InstanceScript instance = caster.GetInstanceScript(); - if (instance != null) - instance.UpdateEncounterStateForSpellCast(GetSpellInfo().Id, caster); - } - - public override void Register() - { - AfterHit.Add(new HitHandler(CreditEncounter)); - } - - bool _handled; - } - - public override SpellScript GetSpellScript() - { - return new spell_gen_dungeon_credit_SpellScript(); - } - } - - [Script] - class spell_gen_elune_candle : SpellScriptLoader - { - public spell_gen_elune_candle() : base("spell_gen_elune_candle") { } - - class spell_gen_elune_candle_SpellScript : SpellScript - { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.OmenHead, SpellIds.OmenChest, SpellIds.OmenHandR, SpellIds.OmenHandL, SpellIds.Normal); - } - - void HandleScript(uint effIndex) - { - uint spellId = 0; - - if (GetHitUnit().GetEntry() == CreatureIds.Omen) - { - switch (RandomHelper.URand(0, 3)) - { - case 0: - spellId = SpellIds.OmenHead; - break; - case 1: - spellId = SpellIds.OmenChest; - break; - case 2: - spellId = SpellIds.OmenHandR; - break; - case 3: - spellId = SpellIds.OmenHandL; - break; - } - } - else - spellId = SpellIds.Normal; - - GetCaster().CastSpell(GetHitUnit(), spellId, true, null); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.Dummy)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_gen_elune_candle_SpellScript(); - } - } - - [Script] // 131474 - Fishing - class spell_gen_fishing : SpellScriptLoader - { - public spell_gen_fishing() : base("spell_gen_fishing") { } - - class spell_gen_fishing_SpellScript : SpellScript - { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.FishingNoFishingPole, SpellIds.FishingWithPole); - } - - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Player); - } - - void HandleDummy(uint effIndex) - { - PreventHitDefaultEffect(effIndex); - uint spellId; - Item mainHand = GetCaster().ToPlayer().GetItemByPos(InventorySlots.Bag0, EquipmentSlot.MainHand); - if (!mainHand || mainHand.GetTemplate().GetClass() != ItemClass.Weapon || (ItemSubClassWeapon)mainHand.GetTemplate().GetSubClass() != ItemSubClassWeapon.FishingPole) - spellId = SpellIds.FishingNoFishingPole; - else - spellId = SpellIds.FishingWithPole; - - GetCaster().CastSpell(GetCaster(), spellId, false); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_gen_fishing_SpellScript(); - } - } - - [Script] - class spell_gen_gadgetzan_transporter_backfire : SpellScriptLoader - { - public spell_gen_gadgetzan_transporter_backfire() : base("spell_gen_gadgetzan_transporter_backfire") { } - - class spell_gen_gadgetzan_transporter_backfire_SpellScript : SpellScript - { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.TransporterMalfunctionPolymorph, SpellIds.TransporterEviltwin, SpellIds.TransporterMalfunctionMiss); - } - - void HandleDummy(uint effIndex) - { - Unit caster = GetCaster(); - int r = RandomHelper.IRand(0, 119); - if (r < 20) // Transporter Malfunction - 1/6 polymorph - caster.CastSpell(caster, SpellIds.TransporterMalfunctionPolymorph, true); - else if (r < 100) // Evil Twin - 4/6 evil twin - caster.CastSpell(caster, SpellIds.TransporterEviltwin, true); - else // Transporter Malfunction - 1/6 miss the target - caster.CastSpell(caster, SpellIds.TransporterMalfunctionMiss, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_gen_gadgetzan_transporter_backfire_SpellScript(); - } - } - - [Script] - class spell_gen_gift_of_naaru : SpellScriptLoader - { - public spell_gen_gift_of_naaru() : base("spell_gen_gift_of_naaru") { } - - class spell_gen_gift_of_naaru_AuraScript : AuraScript - { - void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) - { - if (!GetCaster()) - return; - - float heal = 0.0f; - switch (GetSpellInfo().SpellFamilyName) - { - case SpellFamilyNames.Mage: - case SpellFamilyNames.Warlock: - case SpellFamilyNames.Priest: - heal = 1.885f * (GetCaster().SpellBaseDamageBonusDone(GetSpellInfo().GetSchoolMask())); + spellId = gender == Gender.Female ? SpellIds.SilverCovenantFemale : SpellIds.SilverCovenantMale; break; - case SpellFamilyNames.Paladin: - case SpellFamilyNames.Shaman: - heal = Math.Max(1.885f * (GetCaster().SpellBaseDamageBonusDone(GetSpellInfo().GetSchoolMask())), 1.1f * (GetCaster().GetTotalAttackPowerValue(WeaponAttackType.BaseAttack))); - break; - case SpellFamilyNames.Warrior: - case SpellFamilyNames.Hunter: - case SpellFamilyNames.Deathknight: - heal = 1.1f * (Math.Max(GetCaster().GetTotalAttackPowerValue(WeaponAttackType.BaseAttack), GetCaster().GetTotalAttackPowerValue(WeaponAttackType.RangedAttack))); - break; - case SpellFamilyNames.Generic: default: break; } - int healTick = (int)Math.Floor(heal / aurEff.GetTotalTicks()); - amount += Math.Max(healTick, 0); - } - - public override void Register() - { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.PeriodicHeal)); + GetCaster().CastSpell(player, spellId, true); } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_gen_gift_of_naaru_AuraScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] - class spell_gen_gnomish_transporter : SpellScriptLoader + class spell_gen_defend : AuraScript { - public spell_gen_gnomish_transporter() : base("spell_gen_gnomish_transporter") { } - - class spell_gen_gnomish_transporter_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.TransporterSuccess, SpellIds.TransporterFailure); - } + return ValidateSpellInfo(SpellIds.VisualShield1, SpellIds.VisualShield2, SpellIds.VisualShield3); + } - void HandleDummy(uint effIndex) + void RefreshVisualShields(AuraEffect aurEff, AuraEffectHandleModes mode) + { + if (GetCaster()) { - GetCaster().CastSpell(GetCaster(), RandomHelper.randChance(50) ? SpellIds.TransporterSuccess : SpellIds.TransporterFailure, true); - } + Unit target = GetTarget(); - public override void Register() + for (byte i = 0; i < GetSpellInfo().StackAmount; ++i) + target.RemoveAurasDueToSpell(SpellIds.VisualShield1 + i); + + target.CastSpell(target, SpellIds.VisualShield1 + GetAura().GetStackAmount() - 1, true, null, aurEff); + } + else + GetTarget().RemoveAurasDueToSpell(GetId()); + } + + void RemoveVisualShields(AuraEffect aurEff, AuraEffectHandleModes mode) + { + for (byte i = 0; i < GetSpellInfo().StackAmount; ++i) + GetTarget().RemoveAurasDueToSpell(SpellIds.VisualShield1 + i); + } + + void RemoveDummyFromDriver(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit caster = GetCaster(); + if (caster) { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + TempSummon vehicle = caster.ToTempSummon(); + if (vehicle) + { + Unit rider = vehicle.GetSummoner(); + if (rider) + rider.RemoveAurasDueToSpell(GetId()); + } } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_gen_gnomish_transporter_SpellScript(); + /*SpellInfo spell = Global.SpellMgr.GetSpellInfo(m_scriptSpellId); + + // Defend spells cast by NPCs (add visuals) + if (spell.GetEffect(0).ApplyAuraName == AuraType.ModDamagePercentTaken) + { + AfterEffectApply.Add(new EffectApplyHandler(RefreshVisualShields, 0, AuraType.ModDamagePercentTaken, AuraEffectHandleModes.RealOrReapplyMask)); + OnEffectRemove.Add(new EffectApplyHandler(RemoveVisualShields, 0, AuraType.ModDamagePercentTaken, AuraEffectHandleModes.ChangeAmountMask)); + } + + // Remove Defend spell from player when he dismounts + if (spell.GetEffect(2).ApplyAuraName == AuraType.ModDamagePercentTaken) + OnEffectRemove.Add(new EffectApplyHandler(RemoveDummyFromDriver, 2, AuraType.ModDamagePercentTaken, AuraEffectHandleModes.Real)); + + // Defend spells cast by players (add/remove visuals) + if (spell.GetEffect(1).ApplyAuraName == AuraType.Dummy) + { + AfterEffectApply.Add(new EffectApplyHandler(RefreshVisualShields, 1, AuraType.Dummy, AuraEffectHandleModes.RealOrReapplyMask)); + OnEffectRemove.Add(new EffectApplyHandler(RemoveVisualShields, 1, AuraType.Dummy, AuraEffectHandleModes.ChangeAmountMask)); + }*/ } } [Script] - class spell_gen_interrupt : SpellScriptLoader + class spell_gen_despawn_self : SpellScript { - public spell_gen_interrupt() : base("spell_gen_interrupt") { } - - class spell_gen_interrupt_AuraScript : AuraScript + public override bool Load() { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.GenThrowInterrupt); - } + return GetCaster().IsTypeId(TypeId.Unit); + } - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.GenThrowInterrupt, true, null, aurEff); - } + void HandleDummy(uint effIndex) + { + if (GetSpellInfo().GetEffect(effIndex).Effect == SpellEffectName.Dummy || GetSpellInfo().GetEffect(effIndex).Effect == SpellEffectName.ScriptEffect) + GetCaster().ToCreature().DespawnOrUnsummon(); + } - public override void Register() + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, SpellConst.EffectAll, SpellEffectName.Any)); + } + } + + [Script] // 70769 Divine Storm! + class spell_gen_divine_storm_cd_reset : SpellScript + { + public override bool Load() + { + return GetCaster().IsTypeId(TypeId.Player); + } + + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.DivineStorm); + } + + void HandleScript(uint effIndex) + { + GetCaster().GetSpellHistory().ResetCooldown(SpellIds.DivineStorm, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.Dummy)); + } + } + + [Script] + class spell_gen_ds_flush_knockback : SpellScript + { + void HandleScript(uint effIndex) + { + // Here the target is the water spout and determines the position where the player is knocked from + Unit target = GetHitUnit(); + if (target) { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + Player player = GetCaster().ToPlayer(); + if (player) + { + float horizontalSpeed = 20.0f + (40.0f - GetCaster().GetDistance(target)); + float verticalSpeed = 8.0f; + // This method relies on the Dalaran Sewer map disposition and Water Spout position + // What we do is knock the player from a position exactly behind him and at the end of the pipe + player.KnockbackFrom(target.GetPositionX(), player.GetPositionY(), horizontalSpeed, verticalSpeed); + } } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_gen_interrupt_AuraScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.Dummy)); + } + } + + [Script] + class spell_gen_dungeon_credit : SpellScript + { + public override bool Load() + { + _handled = false; + return GetCaster().IsTypeId(TypeId.Unit); + } + + void CreditEncounter() + { + // This hook is executed for every target, make sure we only credit instance once + if (_handled) + return; + + _handled = true; + Unit caster = GetCaster(); + InstanceScript instance = caster.GetInstanceScript(); + if (instance != null) + instance.UpdateEncounterStateForSpellCast(GetSpellInfo().Id, caster); + } + + public override void Register() + { + AfterHit.Add(new HitHandler(CreditEncounter)); + } + + bool _handled; + } + + [Script] + class spell_gen_elune_candle : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.OmenHead, SpellIds.OmenChest, SpellIds.OmenHandR, SpellIds.OmenHandL, SpellIds.Normal); + } + + void HandleScript(uint effIndex) + { + uint spellId = 0; + + if (GetHitUnit().GetEntry() == CreatureIds.Omen) + { + switch (RandomHelper.URand(0, 3)) + { + case 0: + spellId = SpellIds.OmenHead; + break; + case 1: + spellId = SpellIds.OmenChest; + break; + case 2: + spellId = SpellIds.OmenHandR; + break; + case 3: + spellId = SpellIds.OmenHandL; + break; + } + } + else + spellId = SpellIds.Normal; + + GetCaster().CastSpell(GetHitUnit(), spellId, true, null); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.Dummy)); + } + } + + [Script] // 131474 - Fishing + class spell_gen_fishing : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.FishingNoFishingPole, SpellIds.FishingWithPole); + } + + public override bool Load() + { + return GetCaster().IsTypeId(TypeId.Player); + } + + void HandleDummy(uint effIndex) + { + PreventHitDefaultEffect(effIndex); + uint spellId; + Item mainHand = GetCaster().ToPlayer().GetItemByPos(InventorySlots.Bag0, EquipmentSlot.MainHand); + if (!mainHand || mainHand.GetTemplate().GetClass() != ItemClass.Weapon || (ItemSubClassWeapon)mainHand.GetTemplate().GetSubClass() != ItemSubClassWeapon.FishingPole) + spellId = SpellIds.FishingNoFishingPole; + else + spellId = SpellIds.FishingWithPole; + + GetCaster().CastSpell(GetCaster(), spellId, false); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + } + } + + [Script] + class spell_gen_gadgetzan_transporter_backfire : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.TransporterMalfunctionPolymorph, SpellIds.TransporterEviltwin, SpellIds.TransporterMalfunctionMiss); + } + + void HandleDummy(uint effIndex) + { + Unit caster = GetCaster(); + int r = RandomHelper.IRand(0, 119); + if (r < 20) // Transporter Malfunction - 1/6 polymorph + caster.CastSpell(caster, SpellIds.TransporterMalfunctionPolymorph, true); + else if (r < 100) // Evil Twin - 4/6 evil twin + caster.CastSpell(caster, SpellIds.TransporterEviltwin, true); + else // Transporter Malfunction - 1/6 miss the target + caster.CastSpell(caster, SpellIds.TransporterMalfunctionMiss, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + } + } + + [Script] + class spell_gen_gift_of_naaru : AuraScript + { + void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + if (!GetCaster()) + return; + + float heal = 0.0f; + switch (GetSpellInfo().SpellFamilyName) + { + case SpellFamilyNames.Mage: + case SpellFamilyNames.Warlock: + case SpellFamilyNames.Priest: + heal = 1.885f * (GetCaster().SpellBaseDamageBonusDone(GetSpellInfo().GetSchoolMask())); + break; + case SpellFamilyNames.Paladin: + case SpellFamilyNames.Shaman: + heal = Math.Max(1.885f * (GetCaster().SpellBaseDamageBonusDone(GetSpellInfo().GetSchoolMask())), 1.1f * (GetCaster().GetTotalAttackPowerValue(WeaponAttackType.BaseAttack))); + break; + case SpellFamilyNames.Warrior: + case SpellFamilyNames.Hunter: + case SpellFamilyNames.Deathknight: + heal = 1.1f * (Math.Max(GetCaster().GetTotalAttackPowerValue(WeaponAttackType.BaseAttack), GetCaster().GetTotalAttackPowerValue(WeaponAttackType.RangedAttack))); + break; + case SpellFamilyNames.Generic: + default: + break; + } + + int healTick = (int)Math.Floor(heal / aurEff.GetTotalTicks()); + amount += Math.Max(healTick, 0); + } + + public override void Register() + { + DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.PeriodicHeal)); + } + } + + [Script] + class spell_gen_gnomish_transporter : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.TransporterSuccess, SpellIds.TransporterFailure); + } + + void HandleDummy(uint effIndex) + { + GetCaster().CastSpell(GetCaster(), RandomHelper.randChance(50) ? SpellIds.TransporterSuccess : SpellIds.TransporterFailure, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + } + } + + [Script] + class spell_gen_interrupt : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.GenThrowInterrupt); + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.GenThrowInterrupt, true, null, aurEff); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } @@ -1805,29 +1470,19 @@ namespace Scripts.Spells.Generic [Script("spell_pri_shadow_protection")] [Script("spell_mage_arcane_brilliance")] [Script("spell_mage_dalaran_brilliance")] - class spell_gen_increase_stats_buff : SpellScriptLoader + class spell_gen_increase_stats_buff : SpellScript { - public spell_gen_increase_stats_buff(string scriptName) : base(scriptName) { } - - class spell_gen_increase_stats_buff_SpellScript : SpellScript + void HandleDummy(uint effIndex) { - void HandleDummy(uint effIndex) - { - if (GetHitUnit().IsInRaidWith(GetCaster())) - GetCaster().CastSpell(GetCaster(), (uint)GetEffectValue() + 1, true); // raid buff - else - GetCaster().CastSpell(GetHitUnit(), (uint)GetEffectValue(), true); // single-target buff - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + if (GetHitUnit().IsInRaidWith(GetCaster())) + GetCaster().CastSpell(GetCaster(), (uint)GetEffectValue() + 1, true); // raid buff + else + GetCaster().CastSpell(GetHitUnit(), (uint)GetEffectValue(), true); // single-target buff } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_gen_increase_stats_buff_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -1836,561 +1491,476 @@ namespace Scripts.Spells.Generic [Script("spell_cenarion_scout_lifebloom", SpellIds.CenarionScout)] [Script("spell_twisted_visage_lifebloom", SpellIds.TwistedVisage)] [Script("spell_faction_champion_dru_lifebloom", SpellIds.FactionChampionsDru)] - class spell_gen_lifebloom : SpellScriptLoader + class spell_gen_lifebloom : AuraScript { - public spell_gen_lifebloom(string name, uint spellId) : base(name) + public spell_gen_lifebloom(uint spellId) { _spellId = spellId; } - class spell_gen_lifebloom_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public spell_gen_lifebloom_AuraScript(uint spellId) - { - _spellId = spellId; - } - - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(_spellId); - } - - void AfterRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - // Final heal only on duration end - if (GetTargetApplication().GetRemoveMode() != AuraRemoveMode.Expire && GetTargetApplication().GetRemoveMode() != AuraRemoveMode.EnemySpell) - return; - - // final heal - GetTarget().CastSpell(GetTarget(), _spellId, true, null, aurEff, GetCasterGUID()); - } - - public override void Register() - { - AfterEffectRemove.Add(new EffectApplyHandler(AfterRemove, 0, AuraType.PeriodicHeal, AuraEffectHandleModes.Real)); - } - - uint _spellId; + return ValidateSpellInfo(_spellId); } - public override AuraScript GetAuraScript() + void AfterRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_gen_lifebloom_AuraScript(_spellId); + // Final heal only on duration end + if (GetTargetApplication().GetRemoveMode() != AuraRemoveMode.Expire && GetTargetApplication().GetRemoveMode() != AuraRemoveMode.EnemySpell) + return; + + // final heal + GetTarget().CastSpell(GetTarget(), _spellId, true, null, aurEff, GetCasterGUID()); + } + + public override void Register() + { + AfterEffectRemove.Add(new EffectApplyHandler(AfterRemove, 0, AuraType.PeriodicHeal, AuraEffectHandleModes.Real)); } uint _spellId; } [Script] - class spell_gen_mounted_charge : SpellScriptLoader + class spell_gen_mounted_charge : SpellScript { - public spell_gen_mounted_charge() : base("spell_gen_mounted_charge") { } - - class spell_gen_mounted_charge_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(62552, 62719, 64100, 66482); - } + return ValidateSpellInfo(62552, 62719, 64100, 66482); + } - void HandleScriptEffect(uint effIndex) - { - Unit target = GetHitUnit(); + void HandleScriptEffect(uint effIndex) + { + Unit target = GetHitUnit(); - switch (effIndex) - { - case 0: // On spells wich trigger the damaging spell (and also the visual) + switch (effIndex) + { + case 0: // On spells wich trigger the damaging spell (and also the visual) + { + uint spellId; + + switch (GetSpellInfo().Id) { - uint spellId; - - switch (GetSpellInfo().Id) - { - case SpellIds.TriggerTrialChampion: - spellId = SpellIds.ChargingEffect20k1; - break; - case SpellIds.TriggerFactionMounts: - spellId = SpellIds.ChargingEffect8k5; - break; - default: - return; - } - - // If target isn't a training dummy there's a chance of failing the charge - if (!target.IsCharmedOwnedByPlayerOrPlayer() && RandomHelper.randChance(12.5f)) - spellId = SpellIds.MissEffect; - - Unit vehicle = GetCaster().GetVehicleBase(); - if (vehicle) - vehicle.CastSpell(target, spellId, false); - else - GetCaster().CastSpell(target, spellId, false); - break; + case SpellIds.TriggerTrialChampion: + spellId = SpellIds.ChargingEffect20k1; + break; + case SpellIds.TriggerFactionMounts: + spellId = SpellIds.ChargingEffect8k5; + break; + default: + return; } - case 1: // On damaging spells, for removing a defend layer - case 2: + + // If target isn't a training dummy there's a chance of failing the charge + if (!target.IsCharmedOwnedByPlayerOrPlayer() && RandomHelper.randChance(12.5f)) + spellId = SpellIds.MissEffect; + + Unit vehicle = GetCaster().GetVehicleBase(); + if (vehicle) + vehicle.CastSpell(target, spellId, false); + else + GetCaster().CastSpell(target, spellId, false); + break; + } + case 1: // On damaging spells, for removing a defend layer + case 2: + { + var auras = target.GetAppliedAuras(); + foreach (var pair in auras) { - var auras = target.GetAppliedAuras(); - foreach (var pair in auras) + Aura aura = pair.Value.GetBase(); + if (aura != null) { - Aura aura = pair.Value.GetBase(); - if (aura != null) + if (aura.GetId() == 62552 || aura.GetId() == 62719 || aura.GetId() == 64100 || aura.GetId() == 66482) { - if (aura.GetId() == 62552 || aura.GetId() == 62719 || aura.GetId() == 64100 || aura.GetId() == 66482) + aura.ModStackAmount(-1, AuraRemoveMode.EnemySpell); + // Remove dummys from rider (Necessary for updating visual shields) + Unit rider = target.GetCharmer(); + if (rider) { - aura.ModStackAmount(-1, AuraRemoveMode.EnemySpell); - // Remove dummys from rider (Necessary for updating visual shields) - Unit rider = target.GetCharmer(); - if (rider) - { - Aura defend = rider.GetAura(aura.GetId()); - if (defend != null) - defend.ModStackAmount(-1, AuraRemoveMode.EnemySpell); - } - break; + Aura defend = rider.GetAura(aura.GetId()); + if (defend != null) + defend.ModStackAmount(-1, AuraRemoveMode.EnemySpell); } + break; } } - break; } - } - } - - void HandleChargeEffect(uint effIndex) - { - uint spellId; - - switch (GetSpellInfo().Id) - { - case SpellIds.ChargingEffect8k5: - spellId = SpellIds.Damage8k5; break; - case SpellIds.ChargingEffect20k1: - case SpellIds.ChargingEffect20k2: - spellId = SpellIds.Damage20k; - break; - case SpellIds.ChargingEffect45k1: - case SpellIds.ChargingEffect45k2: - spellId = SpellIds.Damage45k; - break; - default: - return; - } - Unit rider = GetCaster().GetCharmer(); - if (rider) - rider.CastSpell(GetHitUnit(), spellId, false); - else - GetCaster().CastSpell(GetHitUnit(), spellId, false); - } - - public override void Register() - { - SpellInfo spell = Global.SpellMgr.GetSpellInfo(m_scriptSpellId); - - if (spell.HasEffect(SpellEffectName.ScriptEffect)) - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, SpellConst.EffectFirstFound, SpellEffectName.ScriptEffect)); - - if (spell.GetEffect(0).Effect == SpellEffectName.Charge) - OnEffectHitTarget.Add(new EffectHandler(HandleChargeEffect, 0, SpellEffectName.Charge)); + } } } - public override SpellScript GetSpellScript() + void HandleChargeEffect(uint effIndex) { - return new spell_gen_mounted_charge_SpellScript(); + uint spellId; + + switch (GetSpellInfo().Id) + { + case SpellIds.ChargingEffect8k5: + spellId = SpellIds.Damage8k5; + break; + case SpellIds.ChargingEffect20k1: + case SpellIds.ChargingEffect20k2: + spellId = SpellIds.Damage20k; + break; + case SpellIds.ChargingEffect45k1: + case SpellIds.ChargingEffect45k2: + spellId = SpellIds.Damage45k; + break; + default: + return; + } + Unit rider = GetCaster().GetCharmer(); + if (rider) + rider.CastSpell(GetHitUnit(), spellId, false); + else + GetCaster().CastSpell(GetHitUnit(), spellId, false); + } + + public override void Register() + { + SpellInfo spell = Global.SpellMgr.GetSpellInfo(m_scriptSpellId); + + if (spell.HasEffect(SpellEffectName.ScriptEffect)) + OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, SpellConst.EffectFirstFound, SpellEffectName.ScriptEffect)); + + if (spell.GetEffect(0).Effect == SpellEffectName.Charge) + OnEffectHitTarget.Add(new EffectHandler(HandleChargeEffect, 0, SpellEffectName.Charge)); } } [Script] // 28702 - Netherbloom - class spell_gen_netherbloom : SpellScriptLoader + class spell_gen_netherbloom : SpellScript { - public spell_gen_netherbloom() : base("spell_gen_netherbloom") { } - - class spell_gen_netherbloom_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) + for (byte i = 0; i < 5; ++i) + if (!ValidateSpellInfo(SpellIds.NetherBloomPollen1 + i)) + return false; + + return true; + } + + void HandleScript(uint effIndex) + { + PreventHitDefaultEffect(effIndex); + Unit target = GetHitUnit(); + if (target) { + // 25% chance of casting a random buff + if (RandomHelper.randChance(75)) + return; + + // triggered spells are 28703 to 28707 + // Note: some sources say, that there was the possibility of + // receiving a debuff. However, this seems to be removed by a patch. + + // don't overwrite an existing aura for (byte i = 0; i < 5; ++i) - if (!ValidateSpellInfo(SpellIds.NetherBloomPollen1 + i)) - return false; - - return true; - } - - void HandleScript(uint effIndex) - { - PreventHitDefaultEffect(effIndex); - Unit target = GetHitUnit(); - if (target) - { - // 25% chance of casting a random buff - if (RandomHelper.randChance(75)) + if (target.HasAura(SpellIds.NetherBloomPollen1 + i)) return; - // triggered spells are 28703 to 28707 - // Note: some sources say, that there was the possibility of - // receiving a debuff. However, this seems to be removed by a patch. - - // don't overwrite an existing aura - for (byte i = 0; i < 5; ++i) - if (target.HasAura(SpellIds.NetherBloomPollen1 + i)) - return; - - target.CastSpell(target, SpellIds.NetherBloomPollen1 + RandomHelper.URand(0, 4), true); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + target.CastSpell(target, SpellIds.NetherBloomPollen1 + RandomHelper.URand(0, 4), true); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_gen_netherbloom_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] // 28720 - Nightmare Vine - class spell_gen_nightmare_vine : SpellScriptLoader + class spell_gen_nightmare_vine : SpellScript { - public spell_gen_nightmare_vine() : base("spell_gen_nightmare_vine") { } - - class spell_gen_nightmare_vine_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.NightmarePollen); - } + return ValidateSpellInfo(SpellIds.NightmarePollen); + } - void HandleScript(uint effIndex) + void HandleScript(uint effIndex) + { + PreventHitDefaultEffect(effIndex); + Unit target = GetHitUnit(); + if (target) { - PreventHitDefaultEffect(effIndex); - Unit target = GetHitUnit(); - if (target) - { - // 25% chance of casting Nightmare Pollen - if (RandomHelper.randChance(25)) - target.CastSpell(target, SpellIds.NightmarePollen, true); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + // 25% chance of casting Nightmare Pollen + if (RandomHelper.randChance(25)) + target.CastSpell(target, SpellIds.NightmarePollen, true); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_gen_nightmare_vine_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] // 27539 - Obsidian Armor - class spell_gen_obsidian_armor : SpellScriptLoader + class spell_gen_obsidian_armor : AuraScript { - public spell_gen_obsidian_armor() : base("spell_gen_obsidian_armor") { } - - class spell_gen_obsidian_armor_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.Holy, SpellIds.Fire, SpellIds.Nature, SpellIds.Frost, SpellIds.Shadow, SpellIds.Arcane); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - if (eventInfo.GetDamageInfo().GetSpellInfo() != null) // eventInfo.GetSpellInfo() - return false; - - if (SharedConst.GetFirstSchoolInMask(eventInfo.GetSchoolMask()) == SpellSchools.Normal) - return false; - - return true; - } - - void onProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - uint spellId = 0; - switch (SharedConst.GetFirstSchoolInMask(eventInfo.GetSchoolMask())) - { - case SpellSchools.Holy: - spellId = SpellIds.Holy; - break; - case SpellSchools.Fire: - spellId = SpellIds.Fire; - break; - case SpellSchools.Nature: - spellId = SpellIds.Nature; - break; - case SpellSchools.Frost: - spellId = SpellIds.Frost; - break; - case SpellSchools.Shadow: - spellId = SpellIds.Shadow; - break; - case SpellSchools.Arcane: - spellId = SpellIds.Arcane; - break; - default: - return; - } - GetTarget().CastSpell(GetTarget(), spellId, true, null, aurEff); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(onProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.Holy, SpellIds.Fire, SpellIds.Nature, SpellIds.Frost, SpellIds.Shadow, SpellIds.Arcane); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_gen_obsidian_armor_AuraScript(); - } - } + if (eventInfo.GetDamageInfo().GetSpellInfo() != null) // eventInfo.GetSpellInfo() + return false; - [Script] - class spell_gen_on_tournament_mount : SpellScriptLoader - { - public spell_gen_on_tournament_mount() : base("spell_gen_on_tournament_mount") { } + if (SharedConst.GetFirstSchoolInMask(eventInfo.GetSchoolMask()) == SpellSchools.Normal) + return false; - class spell_gen_on_tournament_mount_AuraScript : AuraScript - { - uint _pennantSpellId; - - public override bool Load() - { - _pennantSpellId = 0; - return GetCaster() && GetCaster().IsTypeId(TypeId.Player); - } - - void HandleApplyEffect(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Unit caster = GetCaster(); - if (caster) - { - Unit vehicle = caster.GetVehicleBase(); - if (vehicle) - { - _pennantSpellId = GetPennatSpellId(caster.ToPlayer(), vehicle); - caster.CastSpell(caster, _pennantSpellId, true); - } - } - } - - void HandleRemoveEffect(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Unit caster = GetCaster(); - if (caster) - caster.RemoveAurasDueToSpell(_pennantSpellId); - } - - uint GetPennatSpellId(Player player, Unit mount) - { - switch (mount.GetEntry()) - { - case CreatureIds.ArgentSteedAspirant: - case CreatureIds.StormwindSteed: - { - if (player.HasAchieved(AchievementIds.ChampionStormwind)) - return SpellIds.StormwindChampion; - else if (player.GetQuestRewardStatus(QuestIds.ValiantOfStormwind) || player.GetQuestRewardStatus(QuestIds.A_ValiantOfStormwind)) - return SpellIds.StormwindValiant; - else - return SpellIds.StormwindAspirant; - } - case CreatureIds.GnomereganMechanostrider: - { - if (player.HasAchieved(AchievementIds.ChampionGnomeregan)) - return SpellIds.GnomereganChampion; - else if (player.GetQuestRewardStatus(QuestIds.ValiantOfGnomeregan) || player.GetQuestRewardStatus(QuestIds.A_ValiantOfGnomeregan)) - return SpellIds.GnomereganValiant; - else - return SpellIds.GnomereganAspirant; - } - case CreatureIds.DarkSpearRaptor: - { - if (player.HasAchieved(AchievementIds.ChampionSenJin)) - return SpellIds.SenjinChampion; - else if (player.GetQuestRewardStatus(QuestIds.ValiantOfSenJin) || player.GetQuestRewardStatus(QuestIds.A_ValiantOfSenJin)) - return SpellIds.SenjinValiant; - else - return SpellIds.SenjinAspirant; - } - case CreatureIds.ArgentHawkstriderAspirant: - case CreatureIds.SilvermoonHawkstrider: - { - if (player.HasAchieved(AchievementIds.ChampionSilvermoon)) - return SpellIds.SilvermoonChampion; - else if (player.GetQuestRewardStatus(QuestIds.ValiantOfSilvermoon) || player.GetQuestRewardStatus(QuestIds.A_ValiantOfSilvermoon)) - return SpellIds.SilvermoonValiant; - else - return SpellIds.SilvermoonAspirant; - } - case CreatureIds.DarnassianNightsaber: - { - if (player.HasAchieved(AchievementIds.ChampionDarnassus)) - return SpellIds.DarnassusChampion; - else if (player.GetQuestRewardStatus(QuestIds.ValiantOfDarnassus) || player.GetQuestRewardStatus(QuestIds.A_ValiantOfDarnassus)) - return SpellIds.DarnassusValiant; - else - return SpellIds.DarnassusAspirant; - } - case CreatureIds.ExodarElekk: - { - if (player.HasAchieved(AchievementIds.ChampionTheExodar)) - return SpellIds.ExodarChampion; - else if (player.GetQuestRewardStatus(QuestIds.ValiantOfTheExodar) || player.GetQuestRewardStatus(QuestIds.A_ValiantOfTheExodar)) - return SpellIds.ExodarValiant; - else - return SpellIds.ExodarAspirant; - } - case CreatureIds.IronforgeRam: - { - if (player.HasAchieved(AchievementIds.ChampionIronforge)) - return SpellIds.IronforgeChampion; - else if (player.GetQuestRewardStatus(QuestIds.ValiantOfIronforge) || player.GetQuestRewardStatus(QuestIds.A_ValiantOfIronforge)) - return SpellIds.IronforgeValiant; - else - return SpellIds.IronforgeAspirant; - } - case CreatureIds.ForsakenWarhorse: - { - if (player.HasAchieved(AchievementIds.ChampionUndercity)) - return SpellIds.UndercityChampion; - else if (player.GetQuestRewardStatus(QuestIds.ValiantOfUndercity) || player.GetQuestRewardStatus(QuestIds.A_ValiantOfUndercity)) - return SpellIds.UndercityValiant; - else - return SpellIds.UndercityAspirant; - } - case CreatureIds.OrgrimmarWolf: - { - if (player.HasAchieved(AchievementIds.ChampionOrgrimmar)) - return SpellIds.OrgrimmarChampion; - else if (player.GetQuestRewardStatus(QuestIds.ValiantOfOrgrimmar) || player.GetQuestRewardStatus(QuestIds.A_ValiantOfOrgrimmar)) - return SpellIds.OrgrimmarValiant; - else - return SpellIds.OrgrimmarAspirant; - } - case CreatureIds.ThunderBluffKodo: - { - if (player.HasAchieved(AchievementIds.ChampionThunderBluff)) - return SpellIds.ThunderbluffChampion; - else if (player.GetQuestRewardStatus(QuestIds.ValiantOfThunderBluff) || player.GetQuestRewardStatus(QuestIds.A_ValiantOfThunderBluff)) - return SpellIds.ThunderbluffValiant; - else - return SpellIds.ThunderbluffAspirant; - } - case CreatureIds.ArgentWarhorse: - { - if (player.HasAchieved(AchievementIds.ChampionAlliance) || player.HasAchieved(AchievementIds.ChampionHorde)) - return player.GetClass() == Class.Deathknight ? SpellIds.EbonbladeChampion : SpellIds.ArgentcrusadeChampion; - else if (player.HasAchieved(AchievementIds.ArgentValor)) - return player.GetClass() == Class.Deathknight ? SpellIds.EbonbladeValiant : SpellIds.ArgentcrusadeValiant; - else - return player.GetClass() == Class.Deathknight ? SpellIds.EbonbladeAspirant : SpellIds.ArgentcrusadeAspirant; - } - default: - return 0; - } - } - - public override void Register() - { - AfterEffectApply.Add(new EffectApplyHandler(HandleApplyEffect, 0, AuraType.Dummy, AuraEffectHandleModes.RealOrReapplyMask)); - OnEffectRemove.Add(new EffectApplyHandler(HandleRemoveEffect, 0, AuraType.Dummy, AuraEffectHandleModes.RealOrReapplyMask)); - } + return true; } - public override AuraScript GetAuraScript() + void onProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_gen_on_tournament_mount_AuraScript(); - } - } + PreventDefaultAction(); - [Script] - class spell_gen_oracle_wolvar_reputation : SpellScriptLoader - { - public spell_gen_oracle_wolvar_reputation() : base("spell_gen_oracle_wolvar_reputation") { } - - class spell_gen_oracle_wolvar_reputation_SpellScript : SpellScript - { - public override bool Load() + uint spellId = 0; + switch (SharedConst.GetFirstSchoolInMask(eventInfo.GetSchoolMask())) { - return GetCaster().IsTypeId(TypeId.Player); - } - - void HandleDummy(uint effIndex) - { - Player player = GetCaster().ToPlayer(); - uint factionId = (uint)GetSpellInfo().GetEffect(effIndex).CalcValue(); - int repChange = GetSpellInfo().GetEffect(1).CalcValue(); - - FactionRecord factionEntry = CliDB.FactionStorage.LookupByKey(factionId); - - if (factionEntry == null) + case SpellSchools.Holy: + spellId = SpellIds.Holy; + break; + case SpellSchools.Fire: + spellId = SpellIds.Fire; + break; + case SpellSchools.Nature: + spellId = SpellIds.Nature; + break; + case SpellSchools.Frost: + spellId = SpellIds.Frost; + break; + case SpellSchools.Shadow: + spellId = SpellIds.Shadow; + break; + case SpellSchools.Arcane: + spellId = SpellIds.Arcane; + break; + default: return; - - // Set rep to baserep + basepoints (expecting spillover for oposite faction . become hated) - // Not when player already has equal or higher rep with this faction - if (player.GetReputationMgr().GetBaseReputation(factionEntry) < repChange) - player.GetReputationMgr().SetReputation(factionEntry, repChange); - - // EFFECT_INDEX_2 most likely update at war state, we already handle this in SetReputation - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } + GetTarget().CastSpell(GetTarget(), spellId, true, null, aurEff); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_gen_oracle_wolvar_reputation_SpellScript(); + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(onProc, 0, AuraType.Dummy)); } } [Script] - class spell_gen_orc_disguise : SpellScriptLoader + class spell_gen_on_tournament_mount : AuraScript { - public spell_gen_orc_disguise() : base("spell_gen_orc_disguise") { } + uint _pennantSpellId; - class spell_gen_orc_disguise_SpellScript : SpellScript + public override bool Load() { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.OrcDisguiseTrigger, SpellIds.OrcDisguiseMale, SpellIds.OrcDisguiseFemale); - } + _pennantSpellId = 0; + return GetCaster() && GetCaster().IsTypeId(TypeId.Player); + } - void HandleScript(uint effIndex) + void HandleApplyEffect(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit caster = GetCaster(); + if (caster) { - Unit caster = GetCaster(); - Player target = GetHitPlayer(); - if (target) + Unit vehicle = caster.GetVehicleBase(); + if (vehicle) { - Gender gender = target.GetGender(); - if (gender == Gender.Male) - caster.CastSpell(target, SpellIds.OrcDisguiseMale, true); - else - caster.CastSpell(target, SpellIds.OrcDisguiseFemale, true); + _pennantSpellId = GetPennatSpellId(caster.ToPlayer(), vehicle); + caster.CastSpell(caster, _pennantSpellId, true); } } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } } - public override SpellScript GetSpellScript() + void HandleRemoveEffect(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_gen_orc_disguise_SpellScript(); + Unit caster = GetCaster(); + if (caster) + caster.RemoveAurasDueToSpell(_pennantSpellId); + } + + uint GetPennatSpellId(Player player, Unit mount) + { + switch (mount.GetEntry()) + { + case CreatureIds.ArgentSteedAspirant: + case CreatureIds.StormwindSteed: + { + if (player.HasAchieved(AchievementIds.ChampionStormwind)) + return SpellIds.StormwindChampion; + else if (player.GetQuestRewardStatus(QuestIds.ValiantOfStormwind) || player.GetQuestRewardStatus(QuestIds.A_ValiantOfStormwind)) + return SpellIds.StormwindValiant; + else + return SpellIds.StormwindAspirant; + } + case CreatureIds.GnomereganMechanostrider: + { + if (player.HasAchieved(AchievementIds.ChampionGnomeregan)) + return SpellIds.GnomereganChampion; + else if (player.GetQuestRewardStatus(QuestIds.ValiantOfGnomeregan) || player.GetQuestRewardStatus(QuestIds.A_ValiantOfGnomeregan)) + return SpellIds.GnomereganValiant; + else + return SpellIds.GnomereganAspirant; + } + case CreatureIds.DarkSpearRaptor: + { + if (player.HasAchieved(AchievementIds.ChampionSenJin)) + return SpellIds.SenjinChampion; + else if (player.GetQuestRewardStatus(QuestIds.ValiantOfSenJin) || player.GetQuestRewardStatus(QuestIds.A_ValiantOfSenJin)) + return SpellIds.SenjinValiant; + else + return SpellIds.SenjinAspirant; + } + case CreatureIds.ArgentHawkstriderAspirant: + case CreatureIds.SilvermoonHawkstrider: + { + if (player.HasAchieved(AchievementIds.ChampionSilvermoon)) + return SpellIds.SilvermoonChampion; + else if (player.GetQuestRewardStatus(QuestIds.ValiantOfSilvermoon) || player.GetQuestRewardStatus(QuestIds.A_ValiantOfSilvermoon)) + return SpellIds.SilvermoonValiant; + else + return SpellIds.SilvermoonAspirant; + } + case CreatureIds.DarnassianNightsaber: + { + if (player.HasAchieved(AchievementIds.ChampionDarnassus)) + return SpellIds.DarnassusChampion; + else if (player.GetQuestRewardStatus(QuestIds.ValiantOfDarnassus) || player.GetQuestRewardStatus(QuestIds.A_ValiantOfDarnassus)) + return SpellIds.DarnassusValiant; + else + return SpellIds.DarnassusAspirant; + } + case CreatureIds.ExodarElekk: + { + if (player.HasAchieved(AchievementIds.ChampionTheExodar)) + return SpellIds.ExodarChampion; + else if (player.GetQuestRewardStatus(QuestIds.ValiantOfTheExodar) || player.GetQuestRewardStatus(QuestIds.A_ValiantOfTheExodar)) + return SpellIds.ExodarValiant; + else + return SpellIds.ExodarAspirant; + } + case CreatureIds.IronforgeRam: + { + if (player.HasAchieved(AchievementIds.ChampionIronforge)) + return SpellIds.IronforgeChampion; + else if (player.GetQuestRewardStatus(QuestIds.ValiantOfIronforge) || player.GetQuestRewardStatus(QuestIds.A_ValiantOfIronforge)) + return SpellIds.IronforgeValiant; + else + return SpellIds.IronforgeAspirant; + } + case CreatureIds.ForsakenWarhorse: + { + if (player.HasAchieved(AchievementIds.ChampionUndercity)) + return SpellIds.UndercityChampion; + else if (player.GetQuestRewardStatus(QuestIds.ValiantOfUndercity) || player.GetQuestRewardStatus(QuestIds.A_ValiantOfUndercity)) + return SpellIds.UndercityValiant; + else + return SpellIds.UndercityAspirant; + } + case CreatureIds.OrgrimmarWolf: + { + if (player.HasAchieved(AchievementIds.ChampionOrgrimmar)) + return SpellIds.OrgrimmarChampion; + else if (player.GetQuestRewardStatus(QuestIds.ValiantOfOrgrimmar) || player.GetQuestRewardStatus(QuestIds.A_ValiantOfOrgrimmar)) + return SpellIds.OrgrimmarValiant; + else + return SpellIds.OrgrimmarAspirant; + } + case CreatureIds.ThunderBluffKodo: + { + if (player.HasAchieved(AchievementIds.ChampionThunderBluff)) + return SpellIds.ThunderbluffChampion; + else if (player.GetQuestRewardStatus(QuestIds.ValiantOfThunderBluff) || player.GetQuestRewardStatus(QuestIds.A_ValiantOfThunderBluff)) + return SpellIds.ThunderbluffValiant; + else + return SpellIds.ThunderbluffAspirant; + } + case CreatureIds.ArgentWarhorse: + { + if (player.HasAchieved(AchievementIds.ChampionAlliance) || player.HasAchieved(AchievementIds.ChampionHorde)) + return player.GetClass() == Class.Deathknight ? SpellIds.EbonbladeChampion : SpellIds.ArgentcrusadeChampion; + else if (player.HasAchieved(AchievementIds.ArgentValor)) + return player.GetClass() == Class.Deathknight ? SpellIds.EbonbladeValiant : SpellIds.ArgentcrusadeValiant; + else + return player.GetClass() == Class.Deathknight ? SpellIds.EbonbladeAspirant : SpellIds.ArgentcrusadeAspirant; + } + default: + return 0; + } + } + + public override void Register() + { + AfterEffectApply.Add(new EffectApplyHandler(HandleApplyEffect, 0, AuraType.Dummy, AuraEffectHandleModes.RealOrReapplyMask)); + OnEffectRemove.Add(new EffectApplyHandler(HandleRemoveEffect, 0, AuraType.Dummy, AuraEffectHandleModes.RealOrReapplyMask)); + } + } + + [Script] + class spell_gen_oracle_wolvar_reputation : SpellScript + { + public override bool Load() + { + return GetCaster().IsTypeId(TypeId.Player); + } + + void HandleDummy(uint effIndex) + { + Player player = GetCaster().ToPlayer(); + uint factionId = (uint)GetSpellInfo().GetEffect(effIndex).CalcValue(); + int repChange = GetSpellInfo().GetEffect(1).CalcValue(); + + FactionRecord factionEntry = CliDB.FactionStorage.LookupByKey(factionId); + + if (factionEntry == null) + return; + + // Set rep to baserep + basepoints (expecting spillover for oposite faction . become hated) + // Not when player already has equal or higher rep with this faction + if (player.GetReputationMgr().GetBaseReputation(factionEntry) < repChange) + player.GetReputationMgr().SetReputation(factionEntry, repChange); + + // EFFECT_INDEX_2 most likely update at war state, we already handle this in SetReputation + } + + public override void Register() + { + OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + } + } + + [Script] + class spell_gen_orc_disguise : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.OrcDisguiseTrigger, SpellIds.OrcDisguiseMale, SpellIds.OrcDisguiseFemale); + } + + void HandleScript(uint effIndex) + { + Unit caster = GetCaster(); + Player target = GetHitPlayer(); + if (target) + { + Gender gender = target.GetGender(); + if (gender == Gender.Male) + caster.CastSpell(target, SpellIds.OrcDisguiseMale, true); + else + caster.CastSpell(target, SpellIds.OrcDisguiseFemale, true); + } + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } @@ -2400,876 +1970,653 @@ namespace Scripts.Spells.Generic [Script("spell_item_corpse_tongue_coin_heroic")] [Script("spell_item_petrified_twilight_scale")] [Script("spell_item_petrified_twilight_scale_heroic")] - class spell_gen_proc_below_pct_damaged : SpellScriptLoader + class spell_gen_proc_below_pct_damaged : AuraScript { - public spell_gen_proc_below_pct_damaged(string name) : base(name) { } - - class spell_gen_proc_below_pct_damaged_AuraScript : AuraScript + bool CheckProc(ProcEventInfo eventInfo) { - bool CheckProc(ProcEventInfo eventInfo) - { - DamageInfo damageInfo = eventInfo.GetDamageInfo(); - if (damageInfo == null || damageInfo.GetDamage() == 0) - return false; - - int pct = GetSpellInfo().GetEffect(0).CalcValue(); - - if (eventInfo.GetActionTarget().HealthBelowPctDamaged(pct, damageInfo.GetDamage())) - return true; - + DamageInfo damageInfo = eventInfo.GetDamageInfo(); + if (damageInfo == null || damageInfo.GetDamage() == 0) return false; - } - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - } + int pct = GetSpellInfo().GetEffect(0).CalcValue(); + + if (eventInfo.GetActionTarget().HealthBelowPctDamaged(pct, damageInfo.GetDamage())) + return true; + + return false; } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_gen_proc_below_pct_damaged_AuraScript(); + DoCheckProc.Add(new CheckProcHandler(CheckProc)); } } [Script] // 45472 Parachute - class spell_gen_parachute : SpellScriptLoader + class spell_gen_parachute : AuraScript { - public spell_gen_parachute() : base("spell_gen_parachute") { } - - class spell_gen_parachute_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) + return ValidateSpellInfo(SpellIds.Parachute, SpellIds.ParachuteBuff); + } + + void HandleEffectPeriodic(AuraEffect aurEff) + { + Player target = GetTarget().ToPlayer(); + if (target) { - return ValidateSpellInfo(SpellIds.Parachute, SpellIds.ParachuteBuff); + if (target.IsFalling()) + { + target.RemoveAurasDueToSpell(SpellIds.Parachute); + target.CastSpell(target, SpellIds.ParachuteBuff, true); + } + } + } + + public override void Register() + { + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); + } + } + + [Script] + class spell_gen_pet_summoned : SpellScript + { + public override bool Load() + { + return GetCaster().IsTypeId(TypeId.Player); + } + + void HandleScript(uint effIndex) + { + Player player = GetCaster().ToPlayer(); + if (player.GetLastPetNumber() != 0) + { + PetType newPetType = (player.GetClass() == Class.Hunter) ? PetType.Hunter : PetType.Summon; + Pet newPet = new Pet(player, newPetType); + if (newPet.LoadPetFromDB(player, 0, player.GetLastPetNumber(), true)) + { + // revive the pet if it is dead + if (newPet.getDeathState() == DeathState.Dead) + newPet.setDeathState(DeathState.Alive); + + newPet.SetFullHealth(); + newPet.SetPower(newPet.getPowerType(), newPet.GetMaxPower(newPet.getPowerType())); + + switch (newPet.GetEntry()) + { + case CreatureIds.Doomguard: + case CreatureIds.Infernal: + newPet.SetEntry(CreatureIds.Imp); + break; + default: + break; + } + } + } + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + } + } + + [Script] + class spell_gen_profession_research : SpellScript + { + public override bool Load() + { + return GetCaster().IsTypeId(TypeId.Player); + } + + SpellCastResult CheckRequirement() + { + if (SkillDiscovery.HasDiscoveredAllSpells(GetSpellInfo().Id, GetCaster().ToPlayer())) + { + SetCustomCastResultMessage(SpellCustomErrors.NothingToDiscover); + return SpellCastResult.CustomError; } - void HandleEffectPeriodic(AuraEffect aurEff) + return SpellCastResult.SpellCastOk; + } + + void HandleScript(uint effIndex) + { + Player caster = GetCaster().ToPlayer(); + uint spellId = GetSpellInfo().Id; + + // learn random explicit discovery recipe (if any) + uint discoveredSpellId = SkillDiscovery.GetExplicitDiscoverySpell(spellId, caster); + if (discoveredSpellId != 0) + caster.LearnSpell(discoveredSpellId, false); + + caster.UpdateCraftSkill(spellId); + } + + public override void Register() + { + OnCheckCast.Add(new CheckCastHandler(CheckRequirement)); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 1, SpellEffectName.ScriptEffect)); + } + } + + [Script] + class spell_gen_pvp_trinket : SpellScript + { + void TriggerAnimation() + { + Player caster = GetCaster().ToPlayer(); + + switch (caster.GetTeam()) { - Player target = GetTarget().ToPlayer(); + case Team.Alliance: + caster.CastSpell(caster, SpellIds.PvpTrinketAlliance, TriggerCastFlags.FullMask); + break; + case Team.Horde: + caster.CastSpell(caster, SpellIds.PvpTrinketHorde, TriggerCastFlags.FullMask); + break; + } + } + + public override void Register() + { + AfterCast.Add(new CastHandler(TriggerAnimation)); + } + } + + [Script] + class spell_gen_remove_flight_auras : SpellScript + { + void HandleScript(uint effIndex) + { + Unit target = GetHitUnit(); + if (target) + { + target.RemoveAurasByType(AuraType.Fly); + target.RemoveAurasByType(AuraType.ModIncreaseMountedFlightSpeed); + } + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 1, SpellEffectName.ScriptEffect)); + } + } + + [Script] + class spell_gen_replenishment : SpellScript + { + void RemoveInvalidTargets(List targets) + { + // In arenas Replenishment may only affect the caster + Player caster = GetCaster().ToPlayer(); + if (caster) + { + if (caster.InArena()) + { + targets.Clear(); + targets.Add(caster); + return; + } + } + + targets.RemoveAll(obj => + { + var target = obj.ToUnit(); if (target) - { - if (target.IsFalling()) - { - target.RemoveAurasDueToSpell(SpellIds.Parachute); - target.CastSpell(target, SpellIds.ParachuteBuff, true); - } - } - } + return target.getPowerType() != PowerType.Mana; - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); - } - } - - public override AuraScript GetAuraScript() - { - return new spell_gen_parachute_AuraScript(); - } - } - - [Script] - class spell_gen_pet_summoned : SpellScriptLoader - { - public spell_gen_pet_summoned() : base("spell_gen_pet_summoned") { } - - class spell_gen_pet_summoned_SpellScript : SpellScript - { - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Player); - } - - void HandleScript(uint effIndex) - { - Player player = GetCaster().ToPlayer(); - if (player.GetLastPetNumber() != 0) - { - PetType newPetType = (player.GetClass() == Class.Hunter) ? PetType.Hunter : PetType.Summon; - Pet newPet = new Pet(player, newPetType); - if (newPet.LoadPetFromDB(player, 0, player.GetLastPetNumber(), true)) - { - // revive the pet if it is dead - if (newPet.getDeathState() == DeathState.Dead) - newPet.setDeathState(DeathState.Alive); - - newPet.SetFullHealth(); - newPet.SetPower(newPet.getPowerType(), newPet.GetMaxPower(newPet.getPowerType())); - - switch (newPet.GetEntry()) - { - case CreatureIds.Doomguard: - case CreatureIds.Infernal: - newPet.SetEntry(CreatureIds.Imp); - break; - default: - break; - } - } - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_gen_pet_summoned_SpellScript(); - } - } - - [Script] - class spell_gen_profession_research : SpellScriptLoader - { - public spell_gen_profession_research() : base("spell_gen_profession_research") { } - - class spell_gen_profession_research_SpellScript : SpellScript - { - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Player); - } - - SpellCastResult CheckRequirement() - { - if (SkillDiscovery.HasDiscoveredAllSpells(GetSpellInfo().Id, GetCaster().ToPlayer())) - { - SetCustomCastResultMessage(SpellCustomErrors.NothingToDiscover); - return SpellCastResult.CustomError; - } - - return SpellCastResult.SpellCastOk; - } - - void HandleScript(uint effIndex) - { - Player caster = GetCaster().ToPlayer(); - uint spellId = GetSpellInfo().Id; - - // learn random explicit discovery recipe (if any) - uint discoveredSpellId = SkillDiscovery.GetExplicitDiscoverySpell(spellId, caster); - if (discoveredSpellId != 0) - caster.LearnSpell(discoveredSpellId, false); - - caster.UpdateCraftSkill(spellId); - } - - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckRequirement)); - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 1, SpellEffectName.ScriptEffect)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_gen_profession_research_SpellScript(); - } - } - - [Script] - class spell_gen_pvp_trinket : SpellScriptLoader - { - public spell_gen_pvp_trinket() : base("spell_gen_pvp_trinket") { } - - class spell_gen_pvp_trinket_SpellScript : SpellScript - { - void TriggerAnimation() - { - Player caster = GetCaster().ToPlayer(); - - switch (caster.GetTeam()) - { - case Team.Alliance: - caster.CastSpell(caster, SpellIds.PvpTrinketAlliance, TriggerCastFlags.FullMask); - break; - case Team.Horde: - caster.CastSpell(caster, SpellIds.PvpTrinketHorde, TriggerCastFlags.FullMask); - break; - } - } - - public override void Register() - { - AfterCast.Add(new CastHandler(TriggerAnimation)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_gen_pvp_trinket_SpellScript(); - } - } - - [Script] - class spell_gen_remove_flight_auras : SpellScriptLoader - { - public spell_gen_remove_flight_auras() : base("spell_gen_remove_flight_auras") { } - - class spell_gen_remove_flight_auras_SpellScript : SpellScript - { - void HandleScript(uint effIndex) - { - Unit target = GetHitUnit(); - if (target) - { - target.RemoveAurasByType(AuraType.Fly); - target.RemoveAurasByType(AuraType.ModIncreaseMountedFlightSpeed); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 1, SpellEffectName.ScriptEffect)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_gen_remove_flight_auras_SpellScript(); - } - } - - [Script] - class spell_gen_replenishment : SpellScriptLoader - { - public spell_gen_replenishment() : base("spell_gen_replenishment") { } - - class spell_gen_replenishment_SpellScript : SpellScript - { - void RemoveInvalidTargets(List targets) - { - // In arenas Replenishment may only affect the caster - Player caster = GetCaster().ToPlayer(); - if (caster) - { - if (caster.InArena()) - { - targets.Clear(); - targets.Add(caster); - return; - } - } - - targets.RemoveAll(obj => - { - var target = obj.ToUnit(); - if (target) - return target.getPowerType() != PowerType.Mana; - - return true; - }); - - byte maxTargets = 10; - - if (targets.Count > maxTargets) - { - targets.Sort(new PowerPctOrderPred(PowerType.Mana)); - targets.Resize(maxTargets); - } - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(RemoveInvalidTargets, 255, Targets.UnitCasterAreaRaid)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_gen_replenishment_SpellScript(); - } - - class spell_gen_replenishment_AuraScript : AuraScript - { - public override bool Load() - { - return GetUnitOwner().GetPower(PowerType.Mana) != 0; - } - - void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) - { - switch (GetSpellInfo().Id) - { - case SpellIds.Replenishment: - amount = (int)(GetUnitOwner().GetMaxPower(PowerType.Mana) * 0.002f); - break; - case SpellIds.InfiniteReplenishment: - amount = (int)(GetUnitOwner().GetMaxPower(PowerType.Mana) * 0.0025f); - break; - default: - break; - } - } - - public override void Register() - { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.PeriodicEnergize)); - } - } - - public override AuraScript GetAuraScript() - { - return new spell_gen_replenishment_AuraScript(); - } - } - - [Script] - class spell_gen_running_wild : SpellScriptLoader - { - public spell_gen_running_wild() : base("spell_gen_running_wild") { } - - class spell_gen_running_wild_AuraScript : AuraScript - { - public override bool Validate(SpellInfo spellInfo) - { - if (!CliDB.CreatureDisplayInfoStorage.ContainsKey(ModelIds.RunningWild)) - return false; return true; - } + }); - void HandleMount(AuraEffect aurEff, AuraEffectHandleModes mode) + byte maxTargets = 10; + + if (targets.Count > maxTargets) { - Unit target = GetTarget(); - PreventDefaultAction(); - - target.Mount(ModelIds.RunningWild, 0, 0); - - // cast speed aura - MountCapabilityRecord mountCapability = CliDB.MountCapabilityStorage.LookupByKey(aurEff.GetAmount()); - if (mountCapability != null) - target.CastSpell(target, mountCapability.SpeedModSpell, TriggerCastFlags.FullMask); - } - - public override void Register() - { - OnEffectApply.Add(new EffectApplyHandler(HandleMount, 1, AuraType.Mounted, AuraEffectHandleModes.Real)); + targets.Sort(new PowerPctOrderPred(PowerType.Mana)); + targets.Resize(maxTargets); } } - class spell_gen_running_wild_SpellScript : SpellScript + public override void Register() { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.AlteredForm); - } + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(RemoveInvalidTargets, 255, Targets.UnitCasterAreaRaid)); + } + } - public override bool Load() + [Script] + class spell_gen_replenishment_AuraScript : AuraScript + { + public override bool Load() + { + return GetUnitOwner().GetPower(PowerType.Mana) != 0; + } + + void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + switch (GetSpellInfo().Id) { - // Definitely not a good thing, but currently the only way to do something at cast start - // Should be replaced as soon as possible with a new hook: BeforeCastStart - GetCaster().CastSpell(GetCaster(), SpellIds.AlteredForm, TriggerCastFlags.FullMask); + case SpellIds.Replenishment: + amount = (int)(GetUnitOwner().GetMaxPower(PowerType.Mana) * 0.002f); + break; + case SpellIds.InfiniteReplenishment: + amount = (int)(GetUnitOwner().GetMaxPower(PowerType.Mana) * 0.0025f); + break; + default: + break; + } + } + + public override void Register() + { + DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.PeriodicEnergize)); + } + } + + [Script] + class spell_gen_running_wild : SpellScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.AlteredForm); + } + + public override bool Load() + { + // Definitely not a good thing, but currently the only way to do something at cast start + // Should be replaced as soon as possible with a new hook: BeforeCastStart + GetCaster().CastSpell(GetCaster(), SpellIds.AlteredForm, TriggerCastFlags.FullMask); + return false; + } + + public override void Register() + { + } + } + + [Script] + class spell_gen_running_wild_AuraScript : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + if (!CliDB.CreatureDisplayInfoStorage.ContainsKey(ModelIds.RunningWild)) return false; - } - - public override void Register() - { - } + return true; } - public override AuraScript GetAuraScript() + void HandleMount(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_gen_running_wild_AuraScript(); + Unit target = GetTarget(); + PreventDefaultAction(); + + target.Mount(ModelIds.RunningWild, 0, 0); + + // cast speed aura + MountCapabilityRecord mountCapability = CliDB.MountCapabilityStorage.LookupByKey(aurEff.GetAmount()); + if (mountCapability != null) + target.CastSpell(target, mountCapability.SpeedModSpell, TriggerCastFlags.FullMask); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_gen_running_wild_SpellScript(); + OnEffectApply.Add(new EffectApplyHandler(HandleMount, 1, AuraType.Mounted, AuraEffectHandleModes.Real)); } } [Script] - class spell_gen_two_forms : SpellScriptLoader + class spell_gen_two_forms : SpellScript { - public spell_gen_two_forms() : base("spell_gen_two_forms") { } - - class spell_gen_two_forms_SpellScript : SpellScript + SpellCastResult CheckCast() { - SpellCastResult CheckCast() + if (GetCaster().IsInCombat()) { - if (GetCaster().IsInCombat()) - { - SetCustomCastResultMessage(SpellCustomErrors.CantTransform); - return SpellCastResult.CustomError; - } - - // Player cannot transform to human form if he is forced to be worgen for some reason (Darkflight) - if (GetCaster().GetAuraEffectsByType(AuraType.WorgenAlteredForm).Count > 1) - { - SetCustomCastResultMessage(SpellCustomErrors.CantTransform); - return SpellCastResult.CustomError; - } - - return SpellCastResult.SpellCastOk; + SetCustomCastResultMessage(SpellCustomErrors.CantTransform); + return SpellCastResult.CustomError; } - void HandleTransform(uint effIndex) + // Player cannot transform to human form if he is forced to be worgen for some reason (Darkflight) + if (GetCaster().GetAuraEffectsByType(AuraType.WorgenAlteredForm).Count > 1) { - Unit target = GetHitUnit(); - PreventHitDefaultEffect(effIndex); - if (target.HasAuraType(AuraType.WorgenAlteredForm)) - target.RemoveAurasByType(AuraType.WorgenAlteredForm); - else // Basepoints 1 for this aura control whether to trigger transform transition animation or not. - target.CastCustomSpell(SpellIds.AlteredForm, SpellValueMod.BasePoint0, 1, target, TriggerCastFlags.FullMask); + SetCustomCastResultMessage(SpellCustomErrors.CantTransform); + return SpellCastResult.CustomError; } - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - OnEffectHitTarget.Add(new EffectHandler(HandleTransform, 0, SpellEffectName.Dummy)); - } + return SpellCastResult.SpellCastOk; } - public override SpellScript GetSpellScript() + void HandleTransform(uint effIndex) { - return new spell_gen_two_forms_SpellScript(); + Unit target = GetHitUnit(); + PreventHitDefaultEffect(effIndex); + if (target.HasAuraType(AuraType.WorgenAlteredForm)) + target.RemoveAurasByType(AuraType.WorgenAlteredForm); + else // Basepoints 1 for this aura control whether to trigger transform transition animation or not. + target.CastCustomSpell(SpellIds.AlteredForm, SpellValueMod.BasePoint0, 1, target, TriggerCastFlags.FullMask); + } + + public override void Register() + { + OnCheckCast.Add(new CheckCastHandler(CheckCast)); + OnEffectHitTarget.Add(new EffectHandler(HandleTransform, 0, SpellEffectName.Dummy)); } } [Script] - class spell_gen_darkflight : SpellScriptLoader + class spell_gen_darkflight : SpellScript { - public spell_gen_darkflight() : base("spell_gen_darkflight") { } - - class spell_gen_darkflight_SpellScript : SpellScript + void TriggerTransform() { - void TriggerTransform() - { - GetCaster().CastSpell(GetCaster(), SpellIds.AlteredForm, TriggerCastFlags.FullMask); - } - - public override void Register() - { - AfterCast.Add(new CastHandler(TriggerTransform)); - } + GetCaster().CastSpell(GetCaster(), SpellIds.AlteredForm, TriggerCastFlags.FullMask); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_gen_darkflight_SpellScript(); + AfterCast.Add(new CastHandler(TriggerTransform)); } } [Script] - class spell_gen_seaforium_blast : SpellScriptLoader + class spell_gen_seaforium_blast : SpellScript { - public spell_gen_seaforium_blast() : base("spell_gen_seaforium_blast") { } - - class spell_gen_seaforium_blast_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.PlantChargesCreditAchievement); - } + return ValidateSpellInfo(SpellIds.PlantChargesCreditAchievement); + } - public override bool Load() - { - // OriginalCaster is always available in Spell.prepare - return GetOriginalCaster().IsTypeId(TypeId.Player); - } + public override bool Load() + { + // OriginalCaster is always available in Spell.prepare + return GetOriginalCaster().IsTypeId(TypeId.Player); + } - void AchievementCredit(uint effIndex) + void AchievementCredit(uint effIndex) + { + // but in effect handling OriginalCaster can become null + Unit originalCaster = GetOriginalCaster(); + if (originalCaster) { - // but in effect handling OriginalCaster can become null - Unit originalCaster = GetOriginalCaster(); - if (originalCaster) - { - GameObject go = GetHitGObj(); - if (go) - if (go.GetGoInfo().type == GameObjectTypes.DestructibleBuilding) - originalCaster.CastSpell(originalCaster, SpellIds.PlantChargesCreditAchievement, true); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(AchievementCredit, 1, SpellEffectName.GameObjectDamage)); + GameObject go = GetHitGObj(); + if (go) + if (go.GetGoInfo().type == GameObjectTypes.DestructibleBuilding) + originalCaster.CastSpell(originalCaster, SpellIds.PlantChargesCreditAchievement, true); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_gen_seaforium_blast_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(AchievementCredit, 1, SpellEffectName.GameObjectDamage)); } } [Script] - class spell_gen_spectator_cheer_trigger : SpellScriptLoader + class spell_gen_spectator_cheer_trigger : SpellScript { - public spell_gen_spectator_cheer_trigger() : base("spell_gen_spectator_cheer_trigger") { } - - class spell_gen_spectator_cheer_trigger_SpellScript : SpellScript + void HandleDummy(uint effIndex) { - void HandleDummy(uint effIndex) - { - GetCaster().HandleEmoteCommand(EmoteArray[RandomHelper.URand(0, 2)]); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + GetCaster().HandleEmoteCommand(EmoteArray[RandomHelper.URand(0, 2)]); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_gen_spectator_cheer_trigger_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } static Emote[] EmoteArray = { Emote.OneshotCheer, Emote.OneshotExclamation, Emote.OneshotApplaud }; } [Script] - class spell_gen_spirit_healer_res : SpellScriptLoader + class spell_gen_spirit_healer_res : SpellScript { - public spell_gen_spirit_healer_res() : base("spell_gen_spirit_healer_res") { } - - class spell_gen_spirit_healer_res_SpellScript : SpellScript + public override bool Load() { - public override bool Load() - { - return GetOriginalCaster() && GetOriginalCaster().IsTypeId(TypeId.Player); - } + return GetOriginalCaster() && GetOriginalCaster().IsTypeId(TypeId.Player); + } - void HandleDummy(uint effIndex) + void HandleDummy(uint effIndex) + { + Player originalCaster = GetOriginalCaster().ToPlayer(); + Unit target = GetHitUnit(); + if (target) { - Player originalCaster = GetOriginalCaster().ToPlayer(); - Unit target = GetHitUnit(); - if (target) - { - SpiritHealerConfirm spiritHealerConfirm = new SpiritHealerConfirm(); - spiritHealerConfirm.Unit = target.GetGUID(); - originalCaster.SendPacket(spiritHealerConfirm); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + SpiritHealerConfirm spiritHealerConfirm = new SpiritHealerConfirm(); + spiritHealerConfirm.Unit = target.GetGUID(); + originalCaster.SendPacket(spiritHealerConfirm); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_gen_spirit_healer_res_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script("spell_gen_summon_fire_elemental", SpellIds.SummonFireElemental)] [Script("spell_gen_summon_earth_elemental", SpellIds.SummonEarthElemental)] - class spell_gen_summon_elemental : SpellScriptLoader + class spell_gen_summon_elemental : AuraScript { - public spell_gen_summon_elemental(string name, uint spellId) : base(name) + public spell_gen_summon_elemental(uint spellId) { _spellId = spellId; } - class spell_gen_summon_elemental_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public spell_gen_summon_elemental_AuraScript(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)); - } - - uint _spellId; + return ValidateSpellInfo(_spellId); } - public override AuraScript GetAuraScript() + void AfterApply(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_gen_summon_elemental_AuraScript(_spellId); + 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)); } uint _spellId; } [Script] - class spell_gen_summon_tournament_mount : SpellScriptLoader + class spell_gen_summon_tournament_mount : SpellScript { - public spell_gen_summon_tournament_mount() : base("spell_gen_summon_tournament_mount") { } - - class spell_gen_summon_tournament_mount_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.LanceEquipped); - } - - SpellCastResult CheckIfLanceEquiped() - { - if (GetCaster().IsInDisallowedMountForm()) - GetCaster().RemoveAurasByType(AuraType.ModShapeshift); - - if (!GetCaster().HasAura(SpellIds.LanceEquipped)) - { - SetCustomCastResultMessage(SpellCustomErrors.MustHaveLanceEquipped); - return SpellCastResult.CustomError; - } - - return SpellCastResult.SpellCastOk; - } - - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckIfLanceEquiped)); - } + return ValidateSpellInfo(SpellIds.LanceEquipped); } - public override SpellScript GetSpellScript() + SpellCastResult CheckIfLanceEquiped() { - return new spell_gen_summon_tournament_mount_SpellScript(); + if (GetCaster().IsInDisallowedMountForm()) + GetCaster().RemoveAurasByType(AuraType.ModShapeshift); + + if (!GetCaster().HasAura(SpellIds.LanceEquipped)) + { + SetCustomCastResultMessage(SpellCustomErrors.MustHaveLanceEquipped); + return SpellCastResult.CustomError; + } + + return SpellCastResult.SpellCastOk; + } + + public override void Register() + { + OnCheckCast.Add(new CheckCastHandler(CheckIfLanceEquiped)); } } [Script] // 41213, 43416, 69222, 73076 - Throw Shield - class spell_gen_throw_shield : SpellScriptLoader + class spell_gen_throw_shield : SpellScript { - public spell_gen_throw_shield() : base("spell_gen_throw_shield") { } - - class spell_gen_throw_shield_SpellScript : SpellScript + void HandleScriptEffect(uint effIndex) { - void HandleScriptEffect(uint effIndex) - { - PreventHitDefaultEffect(effIndex); - GetCaster().CastSpell(GetHitUnit(), (uint)GetEffectValue(), true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 1, SpellEffectName.ScriptEffect)); - } + PreventHitDefaultEffect(effIndex); + GetCaster().CastSpell(GetHitUnit(), (uint)GetEffectValue(), true); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_gen_throw_shield_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 1, SpellEffectName.ScriptEffect)); } } [Script] - class spell_gen_tournament_duel : SpellScriptLoader + class spell_gen_tournament_duel : SpellScript { - public spell_gen_tournament_duel() : base("spell_gen_tournament_duel") { } - - class spell_gen_tournament_duel_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.OnTournamentMount, SpellIds.MountedDuel); - } + return ValidateSpellInfo(SpellIds.OnTournamentMount, SpellIds.MountedDuel); + } - void HandleScriptEffect(uint effIndex) + void HandleScriptEffect(uint effIndex) + { + Unit rider = GetCaster().GetCharmer(); + if (rider) { - Unit rider = GetCaster().GetCharmer(); - if (rider) + Player playerTarget = GetHitPlayer(); + if (playerTarget) { - Player playerTarget = GetHitPlayer(); - if (playerTarget) - { - if (playerTarget.HasAura(SpellIds.OnTournamentMount) && playerTarget.GetVehicleBase()) - rider.CastSpell(playerTarget, SpellIds.MountedDuel, true); - return; - } - - Unit unitTarget = GetHitUnit(); - if (unitTarget) - { - if (unitTarget.GetCharmer() && unitTarget.GetCharmer().IsTypeId(TypeId.Player) && unitTarget.GetCharmer().HasAura(SpellIds.OnTournamentMount)) - rider.CastSpell(unitTarget.GetCharmer(), SpellIds.MountedDuel, true); - } - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_gen_tournament_duel_SpellScript(); - } - } - - [Script] - class spell_gen_tournament_pennant : SpellScriptLoader - { - public spell_gen_tournament_pennant() : base("spell_gen_tournament_pennant") { } - - class spell_gen_tournament_pennant_AuraScript : AuraScript - { - public override bool Load() - { - return GetCaster() && GetCaster().IsTypeId(TypeId.Player); - } - - void HandleApplyEffect(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Unit caster = GetCaster(); - if (caster) - if (!caster.GetVehicleBase()) - caster.RemoveAurasDueToSpell(GetId()); - } - - public override void Register() - { - OnEffectApply.Add(new EffectApplyHandler(HandleApplyEffect, 0, AuraType.Dummy, AuraEffectHandleModes.RealOrReapplyMask)); - } - } - - public override AuraScript GetAuraScript() - { - return new spell_gen_tournament_pennant_AuraScript(); - } - } - - [Script] - class spell_pvp_trinket_wotf_shared_cd : SpellScriptLoader - { - public spell_pvp_trinket_wotf_shared_cd() : base("spell_pvp_trinket_wotf_shared_cd") { } - - class spell_pvp_trinket_wotf_shared_cd_SpellScript : SpellScript - { - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Player); - } - - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.WillOfTheForsakenCooldownTrigger, SpellIds.WillOfTheForsakenCooldownTriggerWotf); - } - - void HandleScript() - { - // This is only needed because spells cast from spell_linked_spell are triggered by default - // Spell.SendSpellCooldown() skips all spells with TRIGGERED_IGNORE_SPELL_AND_CATEGORY_CD - GetCaster().GetSpellHistory().StartCooldown(GetSpellInfo(), 0, GetSpell()); - } - - public override void Register() - { - AfterCast.Add(new CastHandler(HandleScript)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_pvp_trinket_wotf_shared_cd_SpellScript(); - } - } - - [Script] - class spell_gen_turkey_marker : SpellScriptLoader - { - public spell_gen_turkey_marker() : base("spell_gen_turkey_marker") { } - - class spell_gen_turkey_marker_AuraScript : AuraScript - { - void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) - { - // store stack apply times, so we can pop them while they expire - _applyTimes.Add(Time.GetMSTime()); - Unit target = GetTarget(); - - // on stack 15 cast the achievement crediting spell - if (GetStackAmount() >= 15) - target.CastSpell(target, SpellIds.TurkeyVengeance, true, null, aurEff, GetCasterGUID()); - } - - void OnPeriodic(AuraEffect aurEff) - { - if (_applyTimes.Empty()) + if (playerTarget.HasAura(SpellIds.OnTournamentMount) && playerTarget.GetVehicleBase()) + rider.CastSpell(playerTarget, SpellIds.MountedDuel, true); return; + } - // pop stack if it expired for us - if (_applyTimes.First() + GetMaxDuration() < Time.GetMSTime()) - ModStackAmount(-1, AuraRemoveMode.Expire); + Unit unitTarget = GetHitUnit(); + if (unitTarget) + { + if (unitTarget.GetCharmer() && unitTarget.GetCharmer().IsTypeId(TypeId.Player) && unitTarget.GetCharmer().HasAura(SpellIds.OnTournamentMount)) + rider.CastSpell(unitTarget.GetCharmer(), SpellIds.MountedDuel, true); + } } - - public override void Register() - { - AfterEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.RealOrReapplyMask)); - OnEffectPeriodic.Add(new EffectPeriodicHandler(OnPeriodic, 0, AuraType.PeriodicDummy)); - } - - List _applyTimes = new List(); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_gen_turkey_marker_AuraScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); } } [Script] - class spell_gen_upper_deck_create_foam_sword : SpellScriptLoader + class spell_gen_tournament_pennant : AuraScript { - public spell_gen_upper_deck_create_foam_sword() : base("spell_gen_upper_deck_create_foam_sword") { } - - class spell_gen_upper_deck_create_foam_sword_SpellScript : SpellScript + public override bool Load() { - void HandleScript(uint effIndex) + return GetCaster() && GetCaster().IsTypeId(TypeId.Player); + } + + void HandleApplyEffect(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit caster = GetCaster(); + if (caster) + if (!caster.GetVehicleBase()) + caster.RemoveAurasDueToSpell(GetId()); + } + + public override void Register() + { + OnEffectApply.Add(new EffectApplyHandler(HandleApplyEffect, 0, AuraType.Dummy, AuraEffectHandleModes.RealOrReapplyMask)); + } + } + + [Script] + class spell_pvp_trinket_wotf_shared_cd : SpellScript + { + public override bool Load() + { + return GetCaster().IsTypeId(TypeId.Player); + } + + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.WillOfTheForsakenCooldownTrigger, SpellIds.WillOfTheForsakenCooldownTriggerWotf); + } + + void HandleScript() + { + // This is only needed because spells cast from spell_linked_spell are triggered by default + // Spell.SendSpellCooldown() skips all spells with TRIGGERED_IGNORE_SPELL_AND_CATEGORY_CD + GetCaster().GetSpellHistory().StartCooldown(GetSpellInfo(), 0, GetSpell()); + } + + public override void Register() + { + AfterCast.Add(new CastHandler(HandleScript)); + } + } + + [Script] + class spell_gen_turkey_marker : AuraScript + { + void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) + { + // store stack apply times, so we can pop them while they expire + _applyTimes.Add(Time.GetMSTime()); + Unit target = GetTarget(); + + // on stack 15 cast the achievement crediting spell + if (GetStackAmount() >= 15) + target.CastSpell(target, SpellIds.TurkeyVengeance, true, null, aurEff, GetCasterGUID()); + } + + void OnPeriodic(AuraEffect aurEff) + { + if (_applyTimes.Empty()) + return; + + // pop stack if it expired for us + if (_applyTimes.First() + GetMaxDuration() < Time.GetMSTime()) + ModStackAmount(-1, AuraRemoveMode.Expire); + } + + public override void Register() + { + AfterEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.RealOrReapplyMask)); + OnEffectPeriodic.Add(new EffectPeriodicHandler(OnPeriodic, 0, AuraType.PeriodicDummy)); + } + + List _applyTimes = new List(); + } + + [Script] + class spell_gen_upper_deck_create_foam_sword : SpellScript + { + void HandleScript(uint effIndex) + { + Player player = GetHitPlayer(); + if (player) { - Player player = GetHitPlayer(); - if (player) + // player can only have one of these items + for (byte i = 0; i < 5; ++i) { - // player can only have one of these items - for (byte i = 0; i < 5; ++i) - { - if (player.HasItemCount(itemId[i], 1, true)) - return; - } - - CreateItem(effIndex, itemId[RandomHelper.URand(0, 4)]); + if (player.HasItemCount(itemId[i], 1, true)) + return; } - } - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + CreateItem(effIndex, itemId[RandomHelper.URand(0, 4)]); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_gen_upper_deck_create_foam_sword_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } // green pink blue red yellow @@ -3278,295 +2625,215 @@ namespace Scripts.Spells.Generic // 52723 - Vampiric Touch [Script] // 60501 - Vampiric Touch - class spell_gen_vampiric_touch : SpellScriptLoader + class spell_gen_vampiric_touch : AuraScript { - public spell_gen_vampiric_touch() : base("spell_gen_vampiric_touch") { } - - class spell_gen_vampiric_touch_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.VampiricTouchHeal); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - DamageInfo damageInfo = eventInfo.GetDamageInfo(); - if (damageInfo == null || damageInfo.GetDamage() == 0) - return; - - Unit caster = eventInfo.GetActor(); - int bp = (int)(damageInfo.GetDamage() / 2); - caster.CastCustomSpell(SpellIds.VampiricTouchHeal, SpellValueMod.BasePoint0, bp, caster, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.VampiricTouchHeal); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_gen_vampiric_touch_AuraScript(); + PreventDefaultAction(); + DamageInfo damageInfo = eventInfo.GetDamageInfo(); + if (damageInfo == null || damageInfo.GetDamage() == 0) + return; + + Unit caster = eventInfo.GetActor(); + int bp = (int)(damageInfo.GetDamage() / 2); + caster.CastCustomSpell(SpellIds.VampiricTouchHeal, SpellValueMod.BasePoint0, bp, caster, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } [Script] - class spell_gen_vehicle_scaling : SpellScriptLoader + class spell_gen_vehicle_scaling : AuraScript { - public spell_gen_vehicle_scaling() : base("spell_gen_vehicle_scaling") { } - - class spell_gen_vehicle_scaling_AuraScript : AuraScript + public override bool Load() { - public override bool Load() + return GetCaster() && GetCaster().IsTypeId(TypeId.Player); + } + + void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Unit caster = GetCaster(); + float factor; + ushort baseItemLevel; + + /// @todo Reserach coeffs for different vehicles + switch (GetId()) { - return GetCaster() && GetCaster().IsTypeId(TypeId.Player); + case SpellIds.GearScaling: + factor = 1.0f; + baseItemLevel = 205; + break; + default: + factor = 1.0f; + baseItemLevel = 170; + break; } - void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) - { - Unit caster = GetCaster(); - float factor; - ushort baseItemLevel; + float avgILvl = caster.ToPlayer().GetAverageItemLevel(); + if (avgILvl < baseItemLevel) + return; /// @todo Research possibility of scaling down - /// @todo Reserach coeffs for different vehicles - switch (GetId()) + amount = (int)((avgILvl - baseItemLevel) * factor); + } + + public override void Register() + { + DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.ModHealingPct)); + DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 1, AuraType.ModDamagePercentDone)); + DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 2, AuraType.ModIncreaseHealthPercent)); + } + } + + [Script] + class spell_gen_vendor_bark_trigger : SpellScript + { + void HandleDummy(uint effIndex) + { + Creature vendor = GetCaster().ToCreature(); + if (vendor) + if (vendor.GetEntry() == CreatureIds.AmphitheaterVendor) + vendor.GetAI().Talk(TextIds.SayAmphitheaterVendor); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + } + } + + [Script] + class spell_gen_wg_water : SpellScript + { + SpellCastResult CheckCast() + { + if (!GetSpellInfo().CheckTargetCreatureType(GetCaster())) + return SpellCastResult.DontReport; + return SpellCastResult.SpellCastOk; + } + + public override void Register() + { + OnCheckCast.Add(new CheckCastHandler(CheckCast)); + } + } + + [Script] + class spell_gen_whisper_gulch_yogg_saron_whisper : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.YoggSaronWhisperDummy); + } + + void HandleEffectPeriodic(AuraEffect aurEff) + { + PreventDefaultAction(); + GetTarget().CastSpell((Unit)null, SpellIds.YoggSaronWhisperDummy, true); + } + + public override void Register() + { + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); + } + } + + [Script] + class spell_gen_eject_all_passengers : SpellScript + { + void RemoveVehicleAuras() + { + Vehicle vehicle = GetHitUnit().GetVehicleKit(); + if (vehicle) + vehicle.RemoveAllPassengers(); + } + + public override void Register() + { + AfterHit.Add(new HitHandler(RemoveVehicleAuras)); + } + } + + [Script] + class spell_gen_gm_freeze : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.GmFreeze); + } + + void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) + { + // Do what was done before to the target in HandleFreezeCommand + Player player = GetTarget().ToPlayer(); + if (player) + { + // stop combat + make player unattackable + duel stop + stop some spells + player.SetFaction(35); + player.CombatStop(); + if (player.IsNonMeleeSpellCast(true)) + player.InterruptNonMeleeSpells(true); + player.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable); + + // if player class = hunter || warlock remove pet if alive + if ((player.GetClass() == Class.Hunter) || (player.GetClass() == Class.Warlock)) { - case SpellIds.GearScaling: - factor = 1.0f; - baseItemLevel = 205; - break; - default: - factor = 1.0f; - baseItemLevel = 170; - break; - } - - float avgILvl = caster.ToPlayer().GetAverageItemLevel(); - if (avgILvl < baseItemLevel) - return; /// @todo Research possibility of scaling down - - amount = (int)((avgILvl - baseItemLevel) * factor); - } - - public override void Register() - { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.ModHealingPct)); - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 1, AuraType.ModDamagePercentDone)); - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 2, AuraType.ModIncreaseHealthPercent)); - } - } - - public override AuraScript GetAuraScript() - { - return new spell_gen_vehicle_scaling_AuraScript(); - } - } - - [Script] - class spell_gen_vendor_bark_trigger : SpellScriptLoader - { - public spell_gen_vendor_bark_trigger() : base("spell_gen_vendor_bark_trigger") { } - - class spell_gen_vendor_bark_trigger_SpellScript : SpellScript - { - void HandleDummy(uint effIndex) - { - Creature vendor = GetCaster().ToCreature(); - if (vendor) - if (vendor.GetEntry() == CreatureIds.AmphitheaterVendor) - vendor.GetAI().Talk(TextIds.SayAmphitheaterVendor); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_gen_vendor_bark_trigger_SpellScript(); - } - } - - [Script] - class spell_gen_wg_water : SpellScriptLoader - { - public spell_gen_wg_water() : base("spell_gen_wg_water") { } - - class spell_gen_wg_water_SpellScript : SpellScript - { - SpellCastResult CheckCast() - { - if (!GetSpellInfo().CheckTargetCreatureType(GetCaster())) - return SpellCastResult.DontReport; - return SpellCastResult.SpellCastOk; - } - - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_gen_wg_water_SpellScript(); - } - } - - [Script] - class spell_gen_whisper_gulch_yogg_saron_whisper : SpellScriptLoader - { - public spell_gen_whisper_gulch_yogg_saron_whisper() : base("spell_gen_whisper_gulch_yogg_saron_whisper") { } - - class spell_gen_whisper_gulch_yogg_saron_whisper_AuraScript : AuraScript - { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.YoggSaronWhisperDummy); - } - - void HandleEffectPeriodic(AuraEffect aurEff) - { - PreventDefaultAction(); - GetTarget().CastSpell((Unit)null, SpellIds.YoggSaronWhisperDummy, true); - } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); - } - } - - public override AuraScript GetAuraScript() - { - return new spell_gen_whisper_gulch_yogg_saron_whisper_AuraScript(); - } - } - - [Script] - class spell_gen_eject_all_passengers : SpellScriptLoader - { - public spell_gen_eject_all_passengers() : base("spell_gen_eject_all_passengers") { } - - class spell_gen_eject_all_passengers_SpellScript : SpellScript - { - void RemoveVehicleAuras() - { - Vehicle vehicle = GetHitUnit().GetVehicleKit(); - if (vehicle) - vehicle.RemoveAllPassengers(); - } - - public override void Register() - { - AfterHit.Add(new HitHandler(RemoveVehicleAuras)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_gen_eject_all_passengers_SpellScript(); - } - } - - [Script] - class spell_gen_gm_freeze : SpellScriptLoader - { - public spell_gen_gm_freeze() : base("spell_gen_gm_freeze") { } - - class spell_gen_gm_freeze_AuraScript : AuraScript - { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.GmFreeze); - } - - void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) - { - // Do what was done before to the target in HandleFreezeCommand - Player player = GetTarget().ToPlayer(); - if (player) - { - // stop combat + make player unattackable + duel stop + stop some spells - player.SetFaction(35); - player.CombatStop(); - if (player.IsNonMeleeSpellCast(true)) - player.InterruptNonMeleeSpells(true); - player.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable); - - // if player class = hunter || warlock remove pet if alive - if ((player.GetClass() == Class.Hunter) || (player.GetClass() == Class.Warlock)) + Pet pet = player.GetPet(); + if (pet) { - Pet pet = player.GetPet(); - if (pet) - { - pet.SavePetToDB(PetSaveMode.AsCurrent); - // not let dismiss dead pet - if (pet.IsAlive()) - player.RemovePet(pet, PetSaveMode.NotInSlot); - } + pet.SavePetToDB(PetSaveMode.AsCurrent); + // not let dismiss dead pet + if (pet.IsAlive()) + player.RemovePet(pet, PetSaveMode.NotInSlot); } } } + } - void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + // Do what was done before to the target in HandleUnfreezeCommand + Player player = GetTarget().ToPlayer(); + if (player) { - // Do what was done before to the target in HandleUnfreezeCommand - Player player = GetTarget().ToPlayer(); - if (player) - { - // Reset player faction + allow combat + allow duels - player.setFactionForRace(player.GetRace()); - player.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); - // save player - player.SaveToDB(); - } - } - - public override void Register() - { - OnEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.ModStun, AuraEffectHandleModes.Real)); - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ModStun, AuraEffectHandleModes.Real)); + // Reset player faction + allow combat + allow duels + player.setFactionForRace(player.GetRace()); + player.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable); + // save player + player.SaveToDB(); } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_gen_gm_freeze_AuraScript(); + OnEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.ModStun, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ModStun, AuraEffectHandleModes.Real)); } } [Script] - class spell_gen_stand : SpellScriptLoader + class spell_gen_stand : SpellScript { - public spell_gen_stand() : base("spell_gen_stand") { } - - class spell_gen_stand_SpellScript : SpellScript + void HandleScript(uint eff) { - void HandleScript(uint eff) - { - Creature target = GetHitCreature(); - if (!target) - return; + Creature target = GetHitCreature(); + if (!target) + return; - target.SetStandState(UnitStandStateType.Stand); - target.HandleEmoteCommand(Emote.StateNone); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } + target.SetStandState(UnitStandStateType.Stand); + target.HandleEmoteCommand(Emote.StateNone); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_gen_stand_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } @@ -3659,513 +2926,409 @@ namespace Scripts.Spells.Generic }; [Script] - class spell_gen_mixology_bonus : SpellScriptLoader + class spell_gen_mixology_bonus : AuraScript { - public spell_gen_mixology_bonus() : base("spell_gen_mixology_bonus") { } - - class spell_gen_mixology_bonus_AuraScript : AuraScript + public spell_gen_mixology_bonus() { - public spell_gen_mixology_bonus_AuraScript() - { - bonus = 0; - } + bonus = 0; + } - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo((uint)RequiredMixologySpells.Mixology); - } + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo((uint)RequiredMixologySpells.Mixology); + } - public override bool Load() - { - return GetCaster() && GetCaster().GetTypeId() == TypeId.Player; - } + public override bool Load() + { + return GetCaster() && GetCaster().GetTypeId() == TypeId.Player; + } - void SetBonusValueForEffect(uint effIndex, int value, AuraEffect aurEff) - { - if (aurEff.GetEffIndex() == effIndex) - bonus = value; - } + void SetBonusValueForEffect(uint effIndex, int value, AuraEffect aurEff) + { + if (aurEff.GetEffIndex() == effIndex) + bonus = value; + } - void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + if (GetCaster().HasAura((uint)RequiredMixologySpells.Mixology) && GetCaster().HasSpell(GetSpellInfo().GetEffect(0).TriggerSpell)) { - if (GetCaster().HasAura((uint)RequiredMixologySpells.Mixology) && GetCaster().HasSpell(GetSpellInfo().GetEffect(0).TriggerSpell)) + switch ((RequiredMixologySpells)GetId()) { - switch ((RequiredMixologySpells)GetId()) - { - case RequiredMixologySpells.WeakTrollsBloodElixir: - case RequiredMixologySpells.MagebloodElixir: - bonus = amount; - break; - case RequiredMixologySpells.ElixirOfFrostPower: - case RequiredMixologySpells.LesserFlaskOfToughness: - case RequiredMixologySpells.LesserFlaskOfResistance: - bonus = MathFunctions.CalculatePct(amount, 80); - break; - case RequiredMixologySpells.ElixirOfMinorDefense: - case RequiredMixologySpells.ElixirOfLionsStrength: - case RequiredMixologySpells.ElixirOfMinorAgility: - case RequiredMixologySpells.MajorTrollsBlloodElixir: - case RequiredMixologySpells.ElixirOfShadowPower: - case RequiredMixologySpells.ElixirOfBruteForce: - case RequiredMixologySpells.MightyTrollsBloodElixir: - case RequiredMixologySpells.ElixirOfGreaterFirepower: - case RequiredMixologySpells.OnslaughtElixir: - case RequiredMixologySpells.EarthenElixir: - case RequiredMixologySpells.ElixirOfMajorAgility: - case RequiredMixologySpells.FlaskOfTheTitans: - case RequiredMixologySpells.FlaskOfRelentlessAssault: - case RequiredMixologySpells.FlaskOfStoneblood: - case RequiredMixologySpells.ElixirOfMinorAccuracy: - bonus = MathFunctions.CalculatePct(amount, 50); - break; - case RequiredMixologySpells.ElixirOfProtection: - bonus = 280; - break; - case RequiredMixologySpells.ElixirOfMajorDefense: - bonus = 200; - break; - case RequiredMixologySpells.ElixirOfGreaterDefense: - case RequiredMixologySpells.ElixirOfSuperiorDefense: - bonus = 140; - break; - case RequiredMixologySpells.ElixirOfFortitude: - bonus = 100; - break; - case RequiredMixologySpells.FlaskOfEndlessRage: - bonus = 82; - break; - case RequiredMixologySpells.ElixirOfDefense: - bonus = 70; - break; - case RequiredMixologySpells.ElixirOfDemonslaying: - bonus = 50; - break; - case RequiredMixologySpells.FlaskOfTheFrostWyrm: - bonus = 47; - break; - case RequiredMixologySpells.WrathElixir: - bonus = 32; - break; - case RequiredMixologySpells.ElixirOfMajorFrostPower: - case RequiredMixologySpells.ElixirOfMajorFirepower: - case RequiredMixologySpells.ElixirOfMajorShadowPower: - bonus = 29; - break; - case RequiredMixologySpells.ElixirOfMightyToughts: - bonus = 27; - break; - case RequiredMixologySpells.FlaskOfSupremePower: - case RequiredMixologySpells.FlaskOfBlindingLight: - case RequiredMixologySpells.FlaskOfPureDeath: - case RequiredMixologySpells.ShadowpowerElixir: - bonus = 23; - break; - case RequiredMixologySpells.ElixirOfMightyAgility: - case RequiredMixologySpells.FlaskOfDistilledWisdom: - case RequiredMixologySpells.ElixirOfSpirit: - case RequiredMixologySpells.ElixirOfMightyStrength: - case RequiredMixologySpells.FlaskOfPureMojo: - case RequiredMixologySpells.ElixirOfAccuracy: - case RequiredMixologySpells.ElixirOfDeadlyStrikes: - case RequiredMixologySpells.ElixirOfMightyDefense: - case RequiredMixologySpells.ElixirOfExpertise: - case RequiredMixologySpells.ElixirOfArmorPiercing: - case RequiredMixologySpells.ElixirOfLightningSpeed: - bonus = 20; - break; - case RequiredMixologySpells.FlaskOfChromaticResistance: - bonus = 17; - break; - case RequiredMixologySpells.ElixirOfMinorFortitude: - case RequiredMixologySpells.ElixirOfMajorStrength: - bonus = 15; - break; - case RequiredMixologySpells.FlaskOfMightyRestoration: - bonus = 13; - break; - case RequiredMixologySpells.ArcaneElixir: - bonus = 12; - break; - case RequiredMixologySpells.ElixirOfGreaterAgility: - case RequiredMixologySpells.ElixirOfGiants: - bonus = 11; - break; - case RequiredMixologySpells.ElixirOfAgility: - case RequiredMixologySpells.ElixirOfGreaterIntellect: - case RequiredMixologySpells.ElixirOfSages: - case RequiredMixologySpells.ElixirOfIronskin: - case RequiredMixologySpells.ElixirOfMightyMageblood: - bonus = 10; - break; - case RequiredMixologySpells.ElixirOfHealingPower: - bonus = 9; - break; - case RequiredMixologySpells.ElixirOfDraenicWisdom: - case RequiredMixologySpells.GurusElixir: - bonus = 8; - break; - case RequiredMixologySpells.ElixirOfFirepower: - case RequiredMixologySpells.ElixirOfMajorMageblood: - case RequiredMixologySpells.ElixirOfMastery: - bonus = 6; - break; - case RequiredMixologySpells.ElixirOfLesserAgility: - case RequiredMixologySpells.ElixirOfOgresStrength: - case RequiredMixologySpells.ElixirOfWisdom: - case RequiredMixologySpells.ElixirOfTheMongoose: - bonus = 5; - break; - case RequiredMixologySpells.StrongTrollsBloodElixir: - case RequiredMixologySpells.FlaskOfChromaticWonder: - bonus = 4; - break; - case RequiredMixologySpells.ElixirOfEmpowerment: - bonus = -10; - break; - case RequiredMixologySpells.AdeptsElixir: - SetBonusValueForEffect(0, 13, aurEff); - SetBonusValueForEffect(1, 13, aurEff); - SetBonusValueForEffect(2, 8, aurEff); - break; - case RequiredMixologySpells.ElixirOfMightyFortitude: - SetBonusValueForEffect(0, 160, aurEff); - break; - case RequiredMixologySpells.ElixirOfMajorFortitude: - SetBonusValueForEffect(0, 116, aurEff); - SetBonusValueForEffect(1, 6, aurEff); - break; - case RequiredMixologySpells.FelStrengthElixir: - SetBonusValueForEffect(0, 40, aurEff); - SetBonusValueForEffect(1, 40, aurEff); - break; - case RequiredMixologySpells.FlaskOfFortification: - SetBonusValueForEffect(0, 210, aurEff); - SetBonusValueForEffect(1, 5, aurEff); - break; - case RequiredMixologySpells.GreaterArcaneElixir: - SetBonusValueForEffect(0, 19, aurEff); - SetBonusValueForEffect(1, 19, aurEff); - SetBonusValueForEffect(2, 5, aurEff); - break; - case RequiredMixologySpells.ElixirOfGianthGrowth: - SetBonusValueForEffect(0, 5, aurEff); - break; - default: - Log.outError(LogFilter.Spells, "SpellId {0} couldn't be processed in spell_gen_mixology_bonus", GetId()); - break; - } - amount += bonus; + case RequiredMixologySpells.WeakTrollsBloodElixir: + case RequiredMixologySpells.MagebloodElixir: + bonus = amount; + break; + case RequiredMixologySpells.ElixirOfFrostPower: + case RequiredMixologySpells.LesserFlaskOfToughness: + case RequiredMixologySpells.LesserFlaskOfResistance: + bonus = MathFunctions.CalculatePct(amount, 80); + break; + case RequiredMixologySpells.ElixirOfMinorDefense: + case RequiredMixologySpells.ElixirOfLionsStrength: + case RequiredMixologySpells.ElixirOfMinorAgility: + case RequiredMixologySpells.MajorTrollsBlloodElixir: + case RequiredMixologySpells.ElixirOfShadowPower: + case RequiredMixologySpells.ElixirOfBruteForce: + case RequiredMixologySpells.MightyTrollsBloodElixir: + case RequiredMixologySpells.ElixirOfGreaterFirepower: + case RequiredMixologySpells.OnslaughtElixir: + case RequiredMixologySpells.EarthenElixir: + case RequiredMixologySpells.ElixirOfMajorAgility: + case RequiredMixologySpells.FlaskOfTheTitans: + case RequiredMixologySpells.FlaskOfRelentlessAssault: + case RequiredMixologySpells.FlaskOfStoneblood: + case RequiredMixologySpells.ElixirOfMinorAccuracy: + bonus = MathFunctions.CalculatePct(amount, 50); + break; + case RequiredMixologySpells.ElixirOfProtection: + bonus = 280; + break; + case RequiredMixologySpells.ElixirOfMajorDefense: + bonus = 200; + break; + case RequiredMixologySpells.ElixirOfGreaterDefense: + case RequiredMixologySpells.ElixirOfSuperiorDefense: + bonus = 140; + break; + case RequiredMixologySpells.ElixirOfFortitude: + bonus = 100; + break; + case RequiredMixologySpells.FlaskOfEndlessRage: + bonus = 82; + break; + case RequiredMixologySpells.ElixirOfDefense: + bonus = 70; + break; + case RequiredMixologySpells.ElixirOfDemonslaying: + bonus = 50; + break; + case RequiredMixologySpells.FlaskOfTheFrostWyrm: + bonus = 47; + break; + case RequiredMixologySpells.WrathElixir: + bonus = 32; + break; + case RequiredMixologySpells.ElixirOfMajorFrostPower: + case RequiredMixologySpells.ElixirOfMajorFirepower: + case RequiredMixologySpells.ElixirOfMajorShadowPower: + bonus = 29; + break; + case RequiredMixologySpells.ElixirOfMightyToughts: + bonus = 27; + break; + case RequiredMixologySpells.FlaskOfSupremePower: + case RequiredMixologySpells.FlaskOfBlindingLight: + case RequiredMixologySpells.FlaskOfPureDeath: + case RequiredMixologySpells.ShadowpowerElixir: + bonus = 23; + break; + case RequiredMixologySpells.ElixirOfMightyAgility: + case RequiredMixologySpells.FlaskOfDistilledWisdom: + case RequiredMixologySpells.ElixirOfSpirit: + case RequiredMixologySpells.ElixirOfMightyStrength: + case RequiredMixologySpells.FlaskOfPureMojo: + case RequiredMixologySpells.ElixirOfAccuracy: + case RequiredMixologySpells.ElixirOfDeadlyStrikes: + case RequiredMixologySpells.ElixirOfMightyDefense: + case RequiredMixologySpells.ElixirOfExpertise: + case RequiredMixologySpells.ElixirOfArmorPiercing: + case RequiredMixologySpells.ElixirOfLightningSpeed: + bonus = 20; + break; + case RequiredMixologySpells.FlaskOfChromaticResistance: + bonus = 17; + break; + case RequiredMixologySpells.ElixirOfMinorFortitude: + case RequiredMixologySpells.ElixirOfMajorStrength: + bonus = 15; + break; + case RequiredMixologySpells.FlaskOfMightyRestoration: + bonus = 13; + break; + case RequiredMixologySpells.ArcaneElixir: + bonus = 12; + break; + case RequiredMixologySpells.ElixirOfGreaterAgility: + case RequiredMixologySpells.ElixirOfGiants: + bonus = 11; + break; + case RequiredMixologySpells.ElixirOfAgility: + case RequiredMixologySpells.ElixirOfGreaterIntellect: + case RequiredMixologySpells.ElixirOfSages: + case RequiredMixologySpells.ElixirOfIronskin: + case RequiredMixologySpells.ElixirOfMightyMageblood: + bonus = 10; + break; + case RequiredMixologySpells.ElixirOfHealingPower: + bonus = 9; + break; + case RequiredMixologySpells.ElixirOfDraenicWisdom: + case RequiredMixologySpells.GurusElixir: + bonus = 8; + break; + case RequiredMixologySpells.ElixirOfFirepower: + case RequiredMixologySpells.ElixirOfMajorMageblood: + case RequiredMixologySpells.ElixirOfMastery: + bonus = 6; + break; + case RequiredMixologySpells.ElixirOfLesserAgility: + case RequiredMixologySpells.ElixirOfOgresStrength: + case RequiredMixologySpells.ElixirOfWisdom: + case RequiredMixologySpells.ElixirOfTheMongoose: + bonus = 5; + break; + case RequiredMixologySpells.StrongTrollsBloodElixir: + case RequiredMixologySpells.FlaskOfChromaticWonder: + bonus = 4; + break; + case RequiredMixologySpells.ElixirOfEmpowerment: + bonus = -10; + break; + case RequiredMixologySpells.AdeptsElixir: + SetBonusValueForEffect(0, 13, aurEff); + SetBonusValueForEffect(1, 13, aurEff); + SetBonusValueForEffect(2, 8, aurEff); + break; + case RequiredMixologySpells.ElixirOfMightyFortitude: + SetBonusValueForEffect(0, 160, aurEff); + break; + case RequiredMixologySpells.ElixirOfMajorFortitude: + SetBonusValueForEffect(0, 116, aurEff); + SetBonusValueForEffect(1, 6, aurEff); + break; + case RequiredMixologySpells.FelStrengthElixir: + SetBonusValueForEffect(0, 40, aurEff); + SetBonusValueForEffect(1, 40, aurEff); + break; + case RequiredMixologySpells.FlaskOfFortification: + SetBonusValueForEffect(0, 210, aurEff); + SetBonusValueForEffect(1, 5, aurEff); + break; + case RequiredMixologySpells.GreaterArcaneElixir: + SetBonusValueForEffect(0, 19, aurEff); + SetBonusValueForEffect(1, 19, aurEff); + SetBonusValueForEffect(2, 5, aurEff); + break; + case RequiredMixologySpells.ElixirOfGianthGrowth: + SetBonusValueForEffect(0, 5, aurEff); + break; + default: + Log.outError(LogFilter.Spells, "SpellId {0} couldn't be processed in spell_gen_mixology_bonus", GetId()); + break; } - } - - int bonus; - - public override void Register() - { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, SpellConst.EffectAll, AuraType.Any)); + amount += bonus; } } - public override AuraScript GetAuraScript() + int bonus; + + public override void Register() { - return new spell_gen_mixology_bonus_AuraScript(); + DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, SpellConst.EffectAll, AuraType.Any)); } } [Script] - class spell_gen_landmine_knockback_achievement : SpellScriptLoader + class spell_gen_landmine_knockback_achievement : SpellScript { - public spell_gen_landmine_knockback_achievement() : base("spell_gen_landmine_knockback_achievement") { } - - class spell_gen_landmine_knockback_achievement_SpellScript : SpellScript + void HandleScript(uint effIndex) { - void HandleScript(uint effIndex) + Player target = GetHitPlayer(); + if (target) { - Player target = GetHitPlayer(); - if (target) - { - Aura aura = GetHitAura(); - if (aura == null || aura.GetStackAmount() < 10) - return; + Aura aura = GetHitAura(); + if (aura == null || aura.GetStackAmount() < 10) + return; - target.CastSpell(target, SpellIds.LandmineKnockbackAchievement, true); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + target.CastSpell(target, SpellIds.LandmineKnockbackAchievement, true); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_gen_landmine_knockback_achievement_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] // 34098 - ClearAllDebuffs - class spell_gen_clear_debuffs : SpellScriptLoader + class spell_gen_clear_debuffs : SpellScript { - public spell_gen_clear_debuffs() : base("spell_gen_clear_debuffs") { } - - class spell_gen_clear_debuffs_SpellScript : SpellScript + void HandleScript(uint effIndex) { - void HandleScript(uint effIndex) + Unit target = GetHitUnit(); + if (target) { - Unit target = GetHitUnit(); - if (target) + target.RemoveOwnedAuras(aura => { - target.RemoveOwnedAuras(aura => - { - SpellInfo spellInfo = aura.GetSpellInfo(); - return !spellInfo.IsPositive() && !spellInfo.IsPassive(); - }); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + SpellInfo spellInfo = aura.GetSpellInfo(); + return !spellInfo.IsPositive() && !spellInfo.IsPassive(); + }); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_gen_clear_debuffs_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] - class spell_gen_pony_mount_check : SpellScriptLoader + class spell_gen_pony_mount_check : AuraScript { - public spell_gen_pony_mount_check() : base("spell_gen_pony_mount_check") { } - - class spell_gen_pony_mount_check_AuraScript : AuraScript + void HandleEffectPeriodic(AuraEffect aurEff) { - void HandleEffectPeriodic(AuraEffect aurEff) + Unit caster = GetCaster(); + if (!caster) + return; + + Player owner = caster.GetOwner().ToPlayer(); + if (!owner || !owner.HasAchieved(SpellIds.AchievementPonyup)) + return; + + if (owner.IsMounted()) { - Unit caster = GetCaster(); - if (!caster) - return; - - Player owner = caster.GetOwner().ToPlayer(); - if (!owner || !owner.HasAchieved(SpellIds.AchievementPonyup)) - return; - - if (owner.IsMounted()) - { - caster.Mount(SpellIds.MountPony); - caster.SetSpeedRate(UnitMoveType.Run, owner.GetSpeedRate(UnitMoveType.Run)); - } - else if (caster.IsMounted()) - { - caster.Dismount(); - caster.SetSpeedRate(UnitMoveType.Run, owner.GetSpeedRate(UnitMoveType.Run)); - } + caster.Mount(SpellIds.MountPony); + caster.SetSpeedRate(UnitMoveType.Run, owner.GetSpeedRate(UnitMoveType.Run)); } - - public override void Register() + else if (caster.IsMounted()) { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); + caster.Dismount(); + caster.SetSpeedRate(UnitMoveType.Run, owner.GetSpeedRate(UnitMoveType.Run)); } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_gen_pony_mount_check_AuraScript(); + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); } } [Script] // 169869 - Transformation Sickness - class spell_gen_decimatus_transformation_sickness : SpellScriptLoader + class spell_gen_decimatus_transformation_sickness : SpellScript { - public spell_gen_decimatus_transformation_sickness() : base("spell_gen_decimatus_transformation_sickness") { } - - class spell_gen_decimatus_transformation_sickness_SpellScript : SpellScript + void HandleScript(uint effIndex) { - void HandleScript(uint effIndex) - { - Unit target = GetHitUnit(); - if (target) - target.SetHealth(target.CountPctFromMaxHealth(25)); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 1, SpellEffectName.ScriptEffect)); - } + Unit target = GetHitUnit(); + if (target) + target.SetHealth(target.CountPctFromMaxHealth(25)); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_gen_decimatus_transformation_sickness_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 1, SpellEffectName.ScriptEffect)); } } [Script] // 189491 - Summon Towering Infernal. - class spell_gen_anetheron_summon_towering_infernal : SpellScriptLoader + class spell_gen_anetheron_summon_towering_infernal : SpellScript { - public spell_gen_anetheron_summon_towering_infernal() : base("spell_gen_anetheron_summon_towering_infernal") { } - - class spell_gen_anetheron_summon_towering_infernal_SpellScript : SpellScript + void HandleDummy(uint effIndex) { - void HandleDummy(uint effIndex) - { - GetCaster().CastSpell(GetHitUnit(), (uint)GetEffectValue(), true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + GetCaster().CastSpell(GetHitUnit(), (uint)GetEffectValue(), true); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_gen_anetheron_summon_towering_infernal_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] - class spell_gen_mark_of_kazrogal_hellfire : SpellScriptLoader + class spell_gen_mark_of_kazrogal_hellfire : SpellScript { - public spell_gen_mark_of_kazrogal_hellfire() : base("spell_gen_mark_of_kazrogal_hellfire") { } - - class spell_gen_mark_of_kazrogal_hellfire_SpellScript : SpellScript + void FilterTargets(List targets) { - void FilterTargets(List targets) + targets.RemoveAll(target => { - targets.RemoveAll(target => - { - Unit unit = target.ToUnit(); - if (unit) - return unit.getPowerType() != PowerType.Mana; - return false; - }); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEnemy)); - } + Unit unit = target.ToUnit(); + if (unit) + return unit.getPowerType() != PowerType.Mana; + return false; + }); } - class spell_gen_mark_of_kazrogal_hellfire_AuraScript : AuraScript + public override void Register() { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.MarkOfKazrogalDamageHellfire); - } - - void OnPeriodic(AuraEffect aurEff) - { - Unit target = GetTarget(); - - if (target.GetPower(PowerType.Mana) == 0) - { - target.CastSpell(target, SpellIds.MarkOfKazrogalDamageHellfire, true, null, aurEff); - // Remove aura - SetDuration(0); - } - } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(OnPeriodic, 0, AuraType.PowerBurn)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_gen_mark_of_kazrogal_hellfire_SpellScript(); - } - - public override AuraScript GetAuraScript() - { - return new spell_gen_mark_of_kazrogal_hellfire_AuraScript(); + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEnemy)); } } [Script] - class spell_gen_azgalor_rain_of_fire_hellfire_citadel : SpellScriptLoader + class spell_gen_mark_of_kazrogal_hellfire_AuraScript : AuraScript { - public spell_gen_azgalor_rain_of_fire_hellfire_citadel() : base("spell_gen_azgalor_rain_of_fire_hellfire_citadel") { } - - class spell_gen_azgalor_rain_of_fire_hellfire_citadel_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - void HandleDummy(uint effIndex) - { - GetCaster().CastSpell(GetHitUnit(), (uint)GetEffectValue(), true); - } + return ValidateSpellInfo(SpellIds.MarkOfKazrogalDamageHellfire); + } - public override void Register() + void OnPeriodic(AuraEffect aurEff) + { + Unit target = GetTarget(); + + if (target.GetPower(PowerType.Mana) == 0) { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + target.CastSpell(target, SpellIds.MarkOfKazrogalDamageHellfire, true, null, aurEff); + // Remove aura + SetDuration(0); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_gen_azgalor_rain_of_fire_hellfire_citadel_SpellScript(); + OnEffectPeriodic.Add(new EffectPeriodicHandler(OnPeriodic, 0, AuraType.PowerBurn)); + } + } + + [Script] + class spell_gen_azgalor_rain_of_fire_hellfire_citadel : SpellScript + { + void HandleDummy(uint effIndex) + { + GetCaster().CastSpell(GetHitUnit(), (uint)GetEffectValue(), true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 99947 - Face Rage - class spell_gen_face_rage : SpellScriptLoader + class spell_gen_face_rage : AuraScript { - public spell_gen_face_rage() : base("spell_gen_face_rage") { } - - class spell_gen_face_rage_AuraScript : AuraScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.FaceRage); - } - - void OnRemove(AuraEffect effect, AuraEffectHandleModes mode) - { - GetTarget().RemoveAurasDueToSpell(GetSpellInfo().GetEffect(2).TriggerSpell); - } - - public override void Register() - { - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ModStun, AuraEffectHandleModes.Real)); - } + return ValidateSpellInfo(SpellIds.FaceRage); } - public override AuraScript GetAuraScript() + void OnRemove(AuraEffect effect, AuraEffectHandleModes mode) { - return new spell_gen_face_rage_AuraScript(); + GetTarget().RemoveAurasDueToSpell(GetSpellInfo().GetEffect(2).TriggerSpell); + } + + public override void Register() + { + OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ModStun, AuraEffectHandleModes.Real)); } } [Script] // 187213 - Impatient Mind - class spell_gen_impatient_mind : SpellScriptLoader + class spell_gen_impatient_mind : AuraScript { - public spell_gen_impatient_mind() : base("spell_gen_impatient_mind") { } - - class spell_gen_impatient_mind_AuraScript : AuraScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.ImpatientMind); - } - - void OnRemove(AuraEffect effect, AuraEffectHandleModes mode) - { - GetTarget().RemoveAurasDueToSpell(effect.GetSpellEffectInfo().TriggerSpell); - } - - public override void Register() - { - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ProcTriggerSpell, AuraEffectHandleModes.Real)); - } + return ValidateSpellInfo(SpellIds.ImpatientMind); } - public override AuraScript GetAuraScript() + void OnRemove(AuraEffect effect, AuraEffectHandleModes mode) { - return new spell_gen_impatient_mind_AuraScript(); + GetTarget().RemoveAurasDueToSpell(effect.GetSpellEffectInfo().TriggerSpell); + } + + public override void Register() + { + OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ProcTriggerSpell, AuraEffectHandleModes.Real)); } } } diff --git a/Scripts/Spells/Holiday.cs b/Scripts/Spells/Holiday.cs index 55c87392c..7de8e9e40 100644 --- a/Scripts/Spells/Holiday.cs +++ b/Scripts/Spells/Holiday.cs @@ -163,251 +163,201 @@ namespace Scripts.Spells.Holiday [Script] // 45102 Romantic Picnic - class spell_love_is_in_the_air_romantic_picnic : SpellScriptLoader + class spell_love_is_in_the_air_romantic_picnic : AuraScript { - public spell_love_is_in_the_air_romantic_picnic() : base("spell_love_is_in_the_air_romantic_picnic") { } - - class spell_love_is_in_the_air_romantic_picnic_AuraScript : AuraScript + void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) { - void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Unit target = GetTarget(); - target.SetStandState(UnitStandStateType.Sit); - target.CastSpell(target, SpellIds.MealPeriodic, false); - } - - void OnPeriodic(AuraEffect aurEff) - { - // Every 5 seconds - Unit target = GetTarget(); - Unit caster = GetCaster(); - - // If our player is no longer sit, remove all auras - if (target.GetStandState() != UnitStandStateType.Sit) - { - target.RemoveAura(SpellIds.RomanticPicnicAchiev); - target.RemoveAura(GetAura()); - return; - } - - target.CastSpell(target, SpellIds.BasketCheck, false); // unknown use, it targets Romantic Basket - target.CastSpell(target, RandomHelper.RAND(SpellIds.MealEatVisual, SpellIds.DrinkVisual), false); - - bool foundSomeone = false; - // For nearby players, check if they have the same aura. If so, cast Romantic Picnic (45123) - // required by achievement and "hearts" visual - List playerList = new List(); - AnyPlayerInObjectRangeCheck checker = new AnyPlayerInObjectRangeCheck(target, SharedConst.InteractionDistance * 2); - var searcher = new PlayerListSearcher(target, playerList, checker); - Cell.VisitWorldObjects(target, searcher, SharedConst.InteractionDistance * 2); - foreach (var player in playerList) - { - if (player != target && player.HasAura(GetId())) // && player.GetStandState() == UNIT_STAND_STATE_SIT) - { - if (caster) - { - caster.CastSpell(player, SpellIds.RomanticPicnicAchiev, true); - caster.CastSpell(target, SpellIds.RomanticPicnicAchiev, true); - } - foundSomeone = true; - // break; - } - } - - if (!foundSomeone && target.HasAura(SpellIds.RomanticPicnicAchiev)) - target.RemoveAura(SpellIds.RomanticPicnicAchiev); - } - - public override void Register() - { - AfterEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.Real)); - OnEffectPeriodic.Add(new EffectPeriodicHandler(OnPeriodic, 0, AuraType.PeriodicDummy)); - } + Unit target = GetTarget(); + target.SetStandState(UnitStandStateType.Sit); + target.CastSpell(target, SpellIds.MealPeriodic, false); } - public override AuraScript GetAuraScript() + void OnPeriodic(AuraEffect aurEff) { - return new spell_love_is_in_the_air_romantic_picnic_AuraScript(); + // Every 5 seconds + Unit target = GetTarget(); + Unit caster = GetCaster(); + + // If our player is no longer sit, remove all auras + if (target.GetStandState() != UnitStandStateType.Sit) + { + target.RemoveAura(SpellIds.RomanticPicnicAchiev); + target.RemoveAura(GetAura()); + return; + } + + target.CastSpell(target, SpellIds.BasketCheck, false); // unknown use, it targets Romantic Basket + target.CastSpell(target, RandomHelper.RAND(SpellIds.MealEatVisual, SpellIds.DrinkVisual), false); + + bool foundSomeone = false; + // For nearby players, check if they have the same aura. If so, cast Romantic Picnic (45123) + // required by achievement and "hearts" visual + List playerList = new List(); + AnyPlayerInObjectRangeCheck checker = new AnyPlayerInObjectRangeCheck(target, SharedConst.InteractionDistance * 2); + var searcher = new PlayerListSearcher(target, playerList, checker); + Cell.VisitWorldObjects(target, searcher, SharedConst.InteractionDistance * 2); + foreach (var player in playerList) + { + if (player != target && player.HasAura(GetId())) // && player.GetStandState() == UNIT_STAND_STATE_SIT) + { + if (caster) + { + caster.CastSpell(player, SpellIds.RomanticPicnicAchiev, true); + caster.CastSpell(target, SpellIds.RomanticPicnicAchiev, true); + } + foundSomeone = true; + // break; + } + } + + if (!foundSomeone && target.HasAura(SpellIds.RomanticPicnicAchiev)) + target.RemoveAura(SpellIds.RomanticPicnicAchiev); + } + + public override void Register() + { + AfterEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.Real)); + OnEffectPeriodic.Add(new EffectPeriodicHandler(OnPeriodic, 0, AuraType.PeriodicDummy)); } } [Script] // 24750 Trick - class spell_hallow_end_trick : SpellScriptLoader + class spell_hallow_end_trick : SpellScript { - public spell_hallow_end_trick() : base("spell_hallow_end_trick") { } - - class spell_hallow_end_trick_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.PirateCostumeMale, SpellIds.PirateCostumeFemale, SpellIds.NinjaCostumeMale, SpellIds.NinjaCostumeFemale, - SpellIds.LeperGnomeCostumeMale, SpellIds.LeperGnomeCostumeFemale, SpellIds.SkeletonCostume, SpellIds.GhostCostumeMale, SpellIds.GhostCostumeFemale, SpellIds.TrickBuff); - } + return ValidateSpellInfo(SpellIds.PirateCostumeMale, SpellIds.PirateCostumeFemale, SpellIds.NinjaCostumeMale, SpellIds.NinjaCostumeFemale, + SpellIds.LeperGnomeCostumeMale, SpellIds.LeperGnomeCostumeFemale, SpellIds.SkeletonCostume, SpellIds.GhostCostumeMale, SpellIds.GhostCostumeFemale, SpellIds.TrickBuff); + } - void HandleScript(uint effIndex) + void HandleScript(uint effIndex) + { + Unit caster = GetCaster(); + Player target = GetHitPlayer(); + if (target) { - Unit caster = GetCaster(); - Player target = GetHitPlayer(); - if (target) + Gender gender = target.GetGender(); + uint spellId = SpellIds.TrickBuff; + switch (RandomHelper.URand(0, 5)) { - Gender gender = target.GetGender(); - uint spellId = SpellIds.TrickBuff; - switch (RandomHelper.URand(0, 5)) - { - case 1: - spellId = gender == Gender.Female ? SpellIds.LeperGnomeCostumeFemale : SpellIds.LeperGnomeCostumeMale; - break; - case 2: - spellId = gender == Gender.Female ? SpellIds.PirateCostumeFemale : SpellIds.PirateCostumeMale; - break; - case 3: - spellId = gender == Gender.Female ? SpellIds.GhostCostumeFemale : SpellIds.GhostCostumeMale; - break; - case 4: - spellId = gender == Gender.Female ? SpellIds.NinjaCostumeFemale : SpellIds.NinjaCostumeMale; - break; - case 5: - spellId = SpellIds.SkeletonCostume; - break; - default: - break; - } - - caster.CastSpell(target, spellId, true); + case 1: + spellId = gender == Gender.Female ? SpellIds.LeperGnomeCostumeFemale : SpellIds.LeperGnomeCostumeMale; + break; + case 2: + spellId = gender == Gender.Female ? SpellIds.PirateCostumeFemale : SpellIds.PirateCostumeMale; + break; + case 3: + spellId = gender == Gender.Female ? SpellIds.GhostCostumeFemale : SpellIds.GhostCostumeMale; + break; + case 4: + spellId = gender == Gender.Female ? SpellIds.NinjaCostumeFemale : SpellIds.NinjaCostumeMale; + break; + case 5: + spellId = SpellIds.SkeletonCostume; + break; + default: + break; } - } - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + caster.CastSpell(target, spellId, true); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_hallow_end_trick_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] // 24751 Trick or Treat - class spell_hallow_end_trick_or_treat : SpellScriptLoader + class spell_hallow_end_trick_or_treat : SpellScript { - public spell_hallow_end_trick_or_treat() : base("spell_hallow_end_trick_or_treat") { } - - class spell_hallow_end_trick_or_treat_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.Trick, SpellIds.Treat, SpellIds.TrickedOrTreated); - } + return ValidateSpellInfo(SpellIds.Trick, SpellIds.Treat, SpellIds.TrickedOrTreated); + } - void HandleScript(uint effIndex) + void HandleScript(uint effIndex) + { + Unit caster = GetCaster(); + Player target = GetHitPlayer(); + if (target) { - Unit caster = GetCaster(); - Player target = GetHitPlayer(); - if (target) - { - caster.CastSpell(target, RandomHelper.randChance(50) ? SpellIds.Trick : SpellIds.Treat, true); - caster.CastSpell(target, SpellIds.TrickedOrTreated, true); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + caster.CastSpell(target, RandomHelper.randChance(50) ? SpellIds.Trick : SpellIds.Treat, true); + caster.CastSpell(target, SpellIds.TrickedOrTreated, true); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_hallow_end_trick_or_treat_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] - class spell_hallow_end_tricky_treat : SpellScriptLoader + class spell_hallow_end_tricky_treat : SpellScript { - public spell_hallow_end_tricky_treat() : base("spell_hallow_end_tricky_treat") { } - - class spell_hallow_end_tricky_treat_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.TrickyTreatSpeed, SpellIds.TrickyTreatTrigger, SpellIds.UpsetTummy); - } - - void HandleScript(uint effIndex) - { - Unit caster = GetCaster(); - if (caster.HasAura(SpellIds.TrickyTreatTrigger) && caster.GetAuraCount(SpellIds.TrickyTreatSpeed) > 3 && RandomHelper.randChance(33)) - caster.CastSpell(caster, SpellIds.UpsetTummy, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } + return ValidateSpellInfo(SpellIds.TrickyTreatSpeed, SpellIds.TrickyTreatTrigger, SpellIds.UpsetTummy); } - public override SpellScript GetSpellScript() + void HandleScript(uint effIndex) { - return new spell_hallow_end_tricky_treat_SpellScript(); + Unit caster = GetCaster(); + if (caster.HasAura(SpellIds.TrickyTreatTrigger) && caster.GetAuraCount(SpellIds.TrickyTreatSpeed) > 3 && RandomHelper.randChance(33)) + caster.CastSpell(caster, SpellIds.UpsetTummy, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] - class spell_hallow_end_wand : SpellScriptLoader + class spell_hallow_end_wand : SpellScript { - public spell_hallow_end_wand() : base("spell_hallow_end_wand") { } - - class spell_hallow_end_wand_SpellScript : SpellScript + public override bool Validate(SpellInfo spellEntry) { - public override bool Validate(SpellInfo spellEntry) - { - return ValidateSpellInfo(SpellIds.PirateCostumeMale, SpellIds.PirateCostumeFemale, SpellIds.NinjaCostumeMale, SpellIds.NinjaCostumeFemale, - SpellIds.LeperGnomeCostumeMale, SpellIds.LeperGnomeCostumeFemale, SpellIds.GhostCostumeMale, SpellIds.GhostCostumeFemale); - } - - void HandleScriptEffect() - { - Unit caster = GetCaster(); - Unit target = GetHitUnit(); - - uint spellId = 0; - bool female = target.GetGender() == Gender.Female; - - switch (GetSpellInfo().Id) - { - case SpellIds.HallowedWandLeperGnome: - spellId = female ? SpellIds.LeperGnomeCostumeFemale : SpellIds.LeperGnomeCostumeMale; - break; - case SpellIds.HallowedWandPirate: - spellId = female ? SpellIds.PirateCostumeFemale : SpellIds.PirateCostumeMale; - break; - case SpellIds.HallowedWandGhost: - spellId = female ? SpellIds.GhostCostumeFemale : SpellIds.GhostCostumeMale; - break; - case SpellIds.HallowedWandNinja: - spellId = female ? SpellIds.NinjaCostumeFemale : SpellIds.NinjaCostumeMale; - break; - case SpellIds.HallowedWandRandom: - spellId = RandomHelper.RAND(SpellIds.HallowedWandPirate, SpellIds.HallowedWandNinja, SpellIds.HallowedWandLeperGnome, SpellIds.HallowedWandSkeleton, SpellIds.HallowedWandWisp, SpellIds.HallowedWandGhost, SpellIds.HallowedWandBat); - break; - default: - return; - } - caster.CastSpell(target, spellId, true); - } - - public override void Register() - { - AfterHit.Add(new HitHandler(HandleScriptEffect)); - } + return ValidateSpellInfo(SpellIds.PirateCostumeMale, SpellIds.PirateCostumeFemale, SpellIds.NinjaCostumeMale, SpellIds.NinjaCostumeFemale, + SpellIds.LeperGnomeCostumeMale, SpellIds.LeperGnomeCostumeFemale, SpellIds.GhostCostumeMale, SpellIds.GhostCostumeFemale); } - public override SpellScript GetSpellScript() + void HandleScriptEffect() { - return new spell_hallow_end_wand_SpellScript(); + Unit caster = GetCaster(); + Unit target = GetHitUnit(); + + uint spellId = 0; + bool female = target.GetGender() == Gender.Female; + + switch (GetSpellInfo().Id) + { + case SpellIds.HallowedWandLeperGnome: + spellId = female ? SpellIds.LeperGnomeCostumeFemale : SpellIds.LeperGnomeCostumeMale; + break; + case SpellIds.HallowedWandPirate: + spellId = female ? SpellIds.PirateCostumeFemale : SpellIds.PirateCostumeMale; + break; + case SpellIds.HallowedWandGhost: + spellId = female ? SpellIds.GhostCostumeFemale : SpellIds.GhostCostumeMale; + break; + case SpellIds.HallowedWandNinja: + spellId = female ? SpellIds.NinjaCostumeFemale : SpellIds.NinjaCostumeMale; + break; + case SpellIds.HallowedWandRandom: + spellId = RandomHelper.RAND(SpellIds.HallowedWandPirate, SpellIds.HallowedWandNinja, SpellIds.HallowedWandLeperGnome, SpellIds.HallowedWandSkeleton, SpellIds.HallowedWandWisp, SpellIds.HallowedWandGhost, SpellIds.HallowedWandBat); + break; + default: + return; + } + caster.CastSpell(target, spellId, true); + } + + public override void Register() + { + AfterHit.Add(new HitHandler(HandleScriptEffect)); } } @@ -416,193 +366,148 @@ namespace Scripts.Spells.Holiday [Script("spell_gen_spice_bread_stuffing", SpellIds.WellFedHitTrigger)] [Script("spell_gen_pumpkin_pie", SpellIds.WellFedSpiritTrigger)] [Script("spell_gen_candied_sweet_potato", SpellIds.WellFedHasteTrigger)] - class spell_pilgrims_bounty_buff_food : SpellScriptLoader + class spell_pilgrims_bounty_buff_food : AuraScript { - public spell_pilgrims_bounty_buff_food(string name, uint triggeredSpellId) : base(name) + public spell_pilgrims_bounty_buff_food(uint triggeredSpellId) : base() { _triggeredSpellId = triggeredSpellId; + _handled = false; } - class spell_pilgrims_bounty_buff_food_AuraScript : AuraScript + void HandleTriggerSpell(AuraEffect aurEff) { - public spell_pilgrims_bounty_buff_food_AuraScript(uint triggeredSpellId) : base() - { - _triggeredSpellId = triggeredSpellId; - _handled = false; - } + PreventDefaultAction(); + if (_handled) + return; - void HandleTriggerSpell(AuraEffect aurEff) - { - PreventDefaultAction(); - if (_handled) - return; - - _handled = true; - GetTarget().CastSpell(GetTarget(), _triggeredSpellId, true); - } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleTriggerSpell, 2, AuraType.PeriodicTriggerSpell)); - } - - uint _triggeredSpellId; - - bool _handled; + _handled = true; + GetTarget().CastSpell(GetTarget(), _triggeredSpellId, true); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_pilgrims_bounty_buff_food_AuraScript(_triggeredSpellId); + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleTriggerSpell, 2, AuraType.PeriodicTriggerSpell)); } uint _triggeredSpellId; + + bool _handled; } [Script] - class spell_winter_veil_mistletoe : SpellScriptLoader + class spell_winter_veil_mistletoe : SpellScript { - public spell_winter_veil_mistletoe() : base("spell_winter_veil_mistletoe") { } - - class spell_winter_veil_mistletoe_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.CreateMistletoe, SpellIds.CreateHolly, SpellIds.CreateSnowflakes); - } + return ValidateSpellInfo(SpellIds.CreateMistletoe, SpellIds.CreateHolly, SpellIds.CreateSnowflakes); + } - void HandleScript(uint effIndex) + void HandleScript(uint effIndex) + { + Player target = GetHitPlayer(); + if (target) { - Player target = GetHitPlayer(); - if (target) - { - uint spellId = RandomHelper.RAND(SpellIds.CreateHolly, SpellIds.CreateMistletoe, SpellIds.CreateSnowflakes); - GetCaster().CastSpell(target, spellId, true); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + uint spellId = RandomHelper.RAND(SpellIds.CreateHolly, SpellIds.CreateMistletoe, SpellIds.CreateSnowflakes); + GetCaster().CastSpell(target, spellId, true); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_winter_veil_mistletoe_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] // 26275 - PX-238 Winter Wondervolt TRAP - class spell_winter_veil_px_238_winter_wondervolt : SpellScriptLoader + class spell_winter_veil_px_238_winter_wondervolt : SpellScript { - public spell_winter_veil_px_238_winter_wondervolt() : base("spell_winter_veil_px_238_winter_wondervolt") { } - - class spell_winter_veil_px_238_winter_wondervolt_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.Px238WinterWondervoltTransform1, SpellIds.Px238WinterWondervoltTransform2, - SpellIds.Px238WinterWondervoltTransform3, SpellIds.Px238WinterWondervoltTransform4); - } + return ValidateSpellInfo(SpellIds.Px238WinterWondervoltTransform1, SpellIds.Px238WinterWondervoltTransform2, + SpellIds.Px238WinterWondervoltTransform3, SpellIds.Px238WinterWondervoltTransform4); + } - void HandleScript(uint effIndex) - { - PreventHitDefaultEffect(effIndex); + void HandleScript(uint effIndex) + { + PreventHitDefaultEffect(effIndex); - uint[] spells = - { + uint[] spells = + { SpellIds.Px238WinterWondervoltTransform1, SpellIds.Px238WinterWondervoltTransform2, SpellIds.Px238WinterWondervoltTransform3, SpellIds.Px238WinterWondervoltTransform4 }; - Unit target = GetHitUnit(); - if (target) - { - for (byte i = 0; i < 4; ++i) - if (target.HasAura(spells[i])) - return; - - target.CastSpell(target, spells[RandomHelper.URand(0, 3)], true); - } - } - - public override void Register() + Unit target = GetHitUnit(); + if (target) { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + for (byte i = 0; i < 4; ++i) + if (target.HasAura(spells[i])) + return; + + target.CastSpell(target, spells[RandomHelper.URand(0, 3)], true); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_winter_veil_px_238_winter_wondervolt_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] // 42924 - Giddyup! - class spell_brewfest_giddyup : SpellScriptLoader + class spell_brewfest_giddyup : AuraScript { - public spell_brewfest_giddyup() : base("spell_brewfest_giddyup") { } - - class spell_brewfest_giddyup_AuraScript : AuraScript + void OnChange(AuraEffect aurEff, AuraEffectHandleModes mode) { - void OnChange(AuraEffect aurEff, AuraEffectHandleModes mode) + Unit target = GetTarget(); + if (!target.HasAura(SpellIds.RentalRacingRam) && !target.HasAura(SpellIds.SwiftWorkRam)) { - Unit target = GetTarget(); - if (!target.HasAura(SpellIds.RentalRacingRam) && !target.HasAura(SpellIds.SwiftWorkRam)) - { - target.RemoveAura(GetId()); - return; - } + target.RemoveAura(GetId()); + return; + } - if (target.HasAura(SpellIds.ExhaustedRam)) - return; + if (target.HasAura(SpellIds.ExhaustedRam)) + return; - switch (GetStackAmount()) - { - case 1: // green - target.RemoveAura(SpellIds.RamLevelNeutral); - target.RemoveAura(SpellIds.RamCanter); - target.CastSpell(target, SpellIds.RamTrot, true); - break; - case 6: // yellow - target.RemoveAura(SpellIds.RamTrot); - target.RemoveAura(SpellIds.RamGallop); - target.CastSpell(target, SpellIds.RamCanter, true); - break; - case 11: // red - target.RemoveAura(SpellIds.RamCanter); - target.CastSpell(target, SpellIds.RamGallop, true); - break; - default: - break; - } - - if (GetTargetApplication().GetRemoveMode() == AuraRemoveMode.Default) - { + switch (GetStackAmount()) + { + case 1: // green + target.RemoveAura(SpellIds.RamLevelNeutral); + target.RemoveAura(SpellIds.RamCanter); + target.CastSpell(target, SpellIds.RamTrot, true); + break; + case 6: // yellow target.RemoveAura(SpellIds.RamTrot); - target.CastSpell(target, SpellIds.RamLevelNeutral, true); - } + target.RemoveAura(SpellIds.RamGallop); + target.CastSpell(target, SpellIds.RamCanter, true); + break; + case 11: // red + target.RemoveAura(SpellIds.RamCanter); + target.CastSpell(target, SpellIds.RamGallop, true); + break; + default: + break; } - void OnPeriodic(AuraEffect aurEff) + if (GetTargetApplication().GetRemoveMode() == AuraRemoveMode.Default) { - GetTarget().RemoveAuraFromStack(GetId()); - } - - public override void Register() - { - AfterEffectApply.Add(new EffectApplyHandler(OnChange, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.ChangeAmountMask)); - OnEffectRemove.Add(new EffectApplyHandler(OnChange, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.ChangeAmountMask)); - OnEffectPeriodic.Add(new EffectPeriodicHandler(OnPeriodic, 0, AuraType.PeriodicDummy)); + target.RemoveAura(SpellIds.RamTrot); + target.CastSpell(target, SpellIds.RamLevelNeutral, true); } } - public override AuraScript GetAuraScript() + void OnPeriodic(AuraEffect aurEff) { - return new spell_brewfest_giddyup_AuraScript(); + GetTarget().RemoveAuraFromStack(GetId()); + } + + public override void Register() + { + AfterEffectApply.Add(new EffectApplyHandler(OnChange, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.ChangeAmountMask)); + OnEffectRemove.Add(new EffectApplyHandler(OnChange, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.ChangeAmountMask)); + OnEffectPeriodic.Add(new EffectPeriodicHandler(OnPeriodic, 0, AuraType.PeriodicDummy)); } } @@ -611,227 +516,157 @@ namespace Scripts.Spells.Holiday // 42993 - Ram - Canter // 42994 - Ram - Gallop [Script] - class spell_brewfest_ram : SpellScriptLoader + class spell_brewfest_ram : AuraScript { - public spell_brewfest_ram() : base("spell_brewfest_ram") { } - - class spell_brewfest_ram_AuraScript : AuraScript + void OnPeriodic(AuraEffect aurEff) { - void OnPeriodic(AuraEffect aurEff) + Unit target = GetTarget(); + if (target.HasAura(SpellIds.ExhaustedRam)) + return; + + switch (GetId()) { - Unit target = GetTarget(); - if (target.HasAura(SpellIds.ExhaustedRam)) - return; - - switch (GetId()) - { - case SpellIds.RamLevelNeutral: - { - Aura aura = target.GetAura(SpellIds.RamFatigue); - if (aura != null) - aura.ModStackAmount(-4); - } - break; - case SpellIds.RamTrot: // green - { - Aura aura = target.GetAura(SpellIds.RamFatigue); - if (aura != null) - aura.ModStackAmount(-2); - if (aurEff.GetTickNumber() == 4) - target.CastSpell(target, QuestIds.BrewfestSpeedBunnyGreen, true); - } - break; - case SpellIds.RamCanter: - target.CastCustomSpell(SpellIds.RamFatigue, SpellValueMod.AuraStack, 1, target, TriggerCastFlags.FullMask); - if (aurEff.GetTickNumber() == 8) - target.CastSpell(target, QuestIds.BrewfestSpeedBunnyYellow, true); - break; - case SpellIds.RamGallop: - target.CastCustomSpell(SpellIds.RamFatigue, SpellValueMod.AuraStack, target.HasAura(SpellIds.RamFatigue) ? 4 : 5 /*Hack*/, target, TriggerCastFlags.FullMask); - if (aurEff.GetTickNumber() == 8) - target.CastSpell(target, QuestIds.BrewfestSpeedBunnyRed, true); - break; - default: - break; - } - + case SpellIds.RamLevelNeutral: + { + Aura aura = target.GetAura(SpellIds.RamFatigue); + if (aura != null) + aura.ModStackAmount(-4); + } + break; + case SpellIds.RamTrot: // green + { + Aura aura = target.GetAura(SpellIds.RamFatigue); + if (aura != null) + aura.ModStackAmount(-2); + if (aurEff.GetTickNumber() == 4) + target.CastSpell(target, QuestIds.BrewfestSpeedBunnyGreen, true); + } + break; + case SpellIds.RamCanter: + target.CastCustomSpell(SpellIds.RamFatigue, SpellValueMod.AuraStack, 1, target, TriggerCastFlags.FullMask); + if (aurEff.GetTickNumber() == 8) + target.CastSpell(target, QuestIds.BrewfestSpeedBunnyYellow, true); + break; + case SpellIds.RamGallop: + target.CastCustomSpell(SpellIds.RamFatigue, SpellValueMod.AuraStack, target.HasAura(SpellIds.RamFatigue) ? 4 : 5 /*Hack*/, target, TriggerCastFlags.FullMask); + if (aurEff.GetTickNumber() == 8) + target.CastSpell(target, QuestIds.BrewfestSpeedBunnyRed, true); + break; + default: + break; } - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(OnPeriodic, 1, AuraType.PeriodicDummy)); - } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_brewfest_ram_AuraScript(); + OnEffectPeriodic.Add(new EffectPeriodicHandler(OnPeriodic, 1, AuraType.PeriodicDummy)); } } [Script] // 43052 - Ram Fatigue - class spell_brewfest_ram_fatigue : SpellScriptLoader + class spell_brewfest_ram_fatigue : AuraScript { - public spell_brewfest_ram_fatigue() : base("spell_brewfest_ram_fatigue") { } - - class spell_brewfest_ram_fatigue_AuraScript : AuraScript + void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) { - void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) + Unit target = GetTarget(); + + if (GetStackAmount() == 101) { - Unit target = GetTarget(); + target.RemoveAura(SpellIds.RamLevelNeutral); + target.RemoveAura(SpellIds.RamTrot); + target.RemoveAura(SpellIds.RamCanter); + target.RemoveAura(SpellIds.RamGallop); + target.RemoveAura(SpellIds.Giddyup); - if (GetStackAmount() == 101) - { - target.RemoveAura(SpellIds.RamLevelNeutral); - target.RemoveAura(SpellIds.RamTrot); - target.RemoveAura(SpellIds.RamCanter); - target.RemoveAura(SpellIds.RamGallop); - target.RemoveAura(SpellIds.Giddyup); - - target.CastSpell(target, SpellIds.ExhaustedRam, true); - } - } - - public override void Register() - { - AfterEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.Dummy, AuraEffectHandleModes.RealOrReapplyMask)); + target.CastSpell(target, SpellIds.ExhaustedRam, true); } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_brewfest_ram_fatigue_AuraScript(); + AfterEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.Dummy, AuraEffectHandleModes.RealOrReapplyMask)); } } [Script] // 43450 - Brewfest - apple trap - friendly DND - class spell_brewfest_apple_trap : SpellScriptLoader + class spell_brewfest_apple_trap : AuraScript { - public spell_brewfest_apple_trap() : base("spell_brewfest_apple_trap") { } - - class spell_brewfest_apple_trap_AuraScript : AuraScript + void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) { - void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) - { - GetTarget().RemoveAura(SpellIds.RamFatigue); - } - - public override void Register() - { - OnEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.ForceReaction, AuraEffectHandleModes.Real)); - } + GetTarget().RemoveAura(SpellIds.RamFatigue); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_brewfest_apple_trap_AuraScript(); + OnEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.ForceReaction, AuraEffectHandleModes.Real)); } } [Script] // 43332 - Exhausted Ram - class spell_brewfest_exhausted_ram : SpellScriptLoader + class spell_brewfest_exhausted_ram : AuraScript { - public spell_brewfest_exhausted_ram() : base("spell_brewfest_exhausted_ram") { } - - class spell_brewfest_exhausted_ram_AuraScript : AuraScript + void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Unit target = GetTarget(); - target.CastSpell(target, SpellIds.RamLevelNeutral, true); - } - - public override void Register() - { - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ModDecreaseSpeed, AuraEffectHandleModes.Real)); - } + Unit target = GetTarget(); + target.CastSpell(target, SpellIds.RamLevelNeutral, true); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_brewfest_exhausted_ram_AuraScript(); + OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ModDecreaseSpeed, AuraEffectHandleModes.Real)); } } [Script] // 43714 - Brewfest - Relay Race - Intro - Force - Player to throw- DND - class spell_brewfest_relay_race_intro_force_player_to_throw : SpellScriptLoader + class spell_brewfest_relay_race_intro_force_player_to_throw : SpellScript { - public spell_brewfest_relay_race_intro_force_player_to_throw() : base("spell_brewfest_relay_race_intro_force_player_to_throw") { } - - class spell_brewfest_relay_race_intro_force_player_to_throw_SpellScript : SpellScript + void HandleForceCast(uint effIndex) { - void HandleForceCast(uint effIndex) - { - PreventHitDefaultEffect(effIndex); - // All this spells trigger a spell that requires reagents; if the - // triggered spell is cast as "triggered", reagents are not consumed - GetHitUnit().CastSpell(null, GetSpellInfo().GetEffect(effIndex).TriggerSpell, TriggerCastFlags.FullMask & ~TriggerCastFlags.IgnorePowerAndReagentCost); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleForceCast, 0, SpellEffectName.ForceCast)); - } + PreventHitDefaultEffect(effIndex); + // All this spells trigger a spell that requires reagents; if the + // triggered spell is cast as "triggered", reagents are not consumed + GetHitUnit().CastSpell(null, GetSpellInfo().GetEffect(effIndex).TriggerSpell, TriggerCastFlags.FullMask & ~TriggerCastFlags.IgnorePowerAndReagentCost); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_brewfest_relay_race_intro_force_player_to_throw_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleForceCast, 0, SpellEffectName.ForceCast)); } } [Script] - class spell_brewfest_relay_race_turn_in : SpellScriptLoader + class spell_brewfest_relay_race_turn_in : SpellScript { - public spell_brewfest_relay_race_turn_in() : base("spell_brewfest_relay_race_turn_in") { } - - class spell_brewfest_relay_race_turn_in_SpellScript : SpellScript + void HandleDummy(uint effIndex) { - void HandleDummy(uint effIndex) - { - PreventHitDefaultEffect(effIndex); + PreventHitDefaultEffect(effIndex); - Aura aura = GetHitUnit().GetAura(SpellIds.SwiftWorkRam); - if (aura != null) - { - aura.SetDuration(aura.GetDuration() + 30 * Time.InMilliseconds); - GetCaster().CastSpell(GetHitUnit(), SpellIds.RelayRaceTurnIn, TriggerCastFlags.FullMask); - } - } - - public override void Register() + Aura aura = GetHitUnit().GetAura(SpellIds.SwiftWorkRam); + if (aura != null) { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + aura.SetDuration(aura.GetDuration() + 30 * Time.InMilliseconds); + GetCaster().CastSpell(GetHitUnit(), SpellIds.RelayRaceTurnIn, TriggerCastFlags.FullMask); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_brewfest_relay_race_turn_in_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 43876 - Dismount Ram - class spell_brewfest_dismount_ram : SpellScriptLoader + class spell_brewfest_dismount_ram : SpellScript { - public spell_brewfest_dismount_ram() : base("spell_brewfest_dismount_ram") { } - - class spell_brewfest_relay_race_intro_force_player_to_throw_SpellScript : SpellScript + void HandleScript(uint effIndex) { - void HandleScript(uint effIndex) - { - GetCaster().RemoveAura(SpellIds.RentalRacingRam); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } + GetCaster().RemoveAura(SpellIds.RentalRacingRam); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_brewfest_relay_race_intro_force_player_to_throw_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } @@ -840,145 +675,114 @@ namespace Scripts.Spells.Holiday // 43261 Brewfest - Barker Bunny 3 // 43262 Brewfest - Barker Bunny 4 [Script] - class spell_brewfest_barker_bunny : SpellScriptLoader + class spell_brewfest_barker_bunny : AuraScript { - public spell_brewfest_barker_bunny() : base("spell_brewfest_barker_bunny") { } - - class spell_brewfest_barker_bunny_AuraScript : AuraScript + public override bool Load() { - public override bool Load() - { - return GetUnitOwner().IsTypeId(TypeId.Player); - } - - void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Player target = GetTarget().ToPlayer(); - - uint BroadcastTextId = 0; - - if (target.GetQuestStatus(QuestIds.BarkForDrohnsDistillery) == QuestStatus.Incomplete || - target.GetQuestStatus(QuestIds.BarkForDrohnsDistillery) == QuestStatus.Complete) - BroadcastTextId = RandomHelper.RAND(TextIds.DrohnDistillery1, TextIds.DrohnDistillery2, TextIds.DrohnDistillery3, TextIds.DrohnDistillery4); - - if (target.GetQuestStatus(QuestIds.BarkForTchalisVoodooBrewery) == QuestStatus.Incomplete || - target.GetQuestStatus(QuestIds.BarkForTchalisVoodooBrewery) == QuestStatus.Complete) - BroadcastTextId = RandomHelper.RAND(TextIds.TChalisVoodoo1, TextIds.TChalisVoodoo2, TextIds.TChalisVoodoo3, TextIds.TChalisVoodoo4); - - if (target.GetQuestStatus(QuestIds.BarkBarleybrew) == QuestStatus.Incomplete || - target.GetQuestStatus(QuestIds.BarkBarleybrew) == QuestStatus.Complete) - BroadcastTextId = RandomHelper.RAND(TextIds.Barleybrew1, TextIds.Barleybrew2, TextIds.Barleybrew3, TextIds.Barleybrew4); - - if (target.GetQuestStatus(QuestIds.BarkForThunderbrews) == QuestStatus.Incomplete || - target.GetQuestStatus(QuestIds.BarkForThunderbrews) == QuestStatus.Complete) - BroadcastTextId = RandomHelper.RAND(TextIds.Thunderbrews1, TextIds.Thunderbrews2, TextIds.Thunderbrews3, TextIds.Thunderbrews4); - - if (BroadcastTextId != 0) - target.Talk(BroadcastTextId, ChatMsg.Say, WorldConfig.GetFloatValue(WorldCfg.ListenRangeSay), target); - } - - public override void Register() - { - OnEffectApply.Add(new EffectApplyHandler(OnApply, 1, AuraType.Dummy, AuraEffectHandleModes.Real)); - } + return GetUnitOwner().IsTypeId(TypeId.Player); } - public override AuraScript GetAuraScript() + void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_brewfest_barker_bunny_AuraScript(); + Player target = GetTarget().ToPlayer(); + + uint BroadcastTextId = 0; + + if (target.GetQuestStatus(QuestIds.BarkForDrohnsDistillery) == QuestStatus.Incomplete || + target.GetQuestStatus(QuestIds.BarkForDrohnsDistillery) == QuestStatus.Complete) + BroadcastTextId = RandomHelper.RAND(TextIds.DrohnDistillery1, TextIds.DrohnDistillery2, TextIds.DrohnDistillery3, TextIds.DrohnDistillery4); + + if (target.GetQuestStatus(QuestIds.BarkForTchalisVoodooBrewery) == QuestStatus.Incomplete || + target.GetQuestStatus(QuestIds.BarkForTchalisVoodooBrewery) == QuestStatus.Complete) + BroadcastTextId = RandomHelper.RAND(TextIds.TChalisVoodoo1, TextIds.TChalisVoodoo2, TextIds.TChalisVoodoo3, TextIds.TChalisVoodoo4); + + if (target.GetQuestStatus(QuestIds.BarkBarleybrew) == QuestStatus.Incomplete || + target.GetQuestStatus(QuestIds.BarkBarleybrew) == QuestStatus.Complete) + BroadcastTextId = RandomHelper.RAND(TextIds.Barleybrew1, TextIds.Barleybrew2, TextIds.Barleybrew3, TextIds.Barleybrew4); + + if (target.GetQuestStatus(QuestIds.BarkForThunderbrews) == QuestStatus.Incomplete || + target.GetQuestStatus(QuestIds.BarkForThunderbrews) == QuestStatus.Complete) + BroadcastTextId = RandomHelper.RAND(TextIds.Thunderbrews1, TextIds.Thunderbrews2, TextIds.Thunderbrews3, TextIds.Thunderbrews4); + + if (BroadcastTextId != 0) + target.Talk(BroadcastTextId, ChatMsg.Say, WorldConfig.GetFloatValue(WorldCfg.ListenRangeSay), target); + } + + public override void Register() + { + OnEffectApply.Add(new EffectApplyHandler(OnApply, 1, AuraType.Dummy, AuraEffectHandleModes.Real)); } } - [Script] // 45724 - Braziers Hit! - class spell_midsummer_braziers_hit : SpellScriptLoader + class spell_midsummer_braziers_hit : AuraScript { - public spell_midsummer_braziers_hit() : base("spell_midsummer_braziers_hit") { } - - class spell_midsummer_braziers_hit_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.TorchTossingTraining, SpellIds.TorchTossingPractice); - } + return ValidateSpellInfo(SpellIds.TorchTossingTraining, SpellIds.TorchTossingPractice); + } - void HandleEffectApply(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Player player = GetTarget().ToPlayer(); - if (!player) - return; + void HandleEffectApply(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Player player = GetTarget().ToPlayer(); + if (!player) + return; - if ((player.HasAura(SpellIds.TorchTossingTraining) && GetStackAmount() == 8) || (player.HasAura(SpellIds.TorchTossingPractice) && GetStackAmount() == 20)) - { - if (player.GetTeam() == Team.Alliance) - player.CastSpell(player, SpellIds.TorchTossingTrainingSuccessAlliance, true); - else if (player.GetTeam() == Team.Horde) - player.CastSpell(player, SpellIds.TorchTossingTrainingSuccessHorde, true); - Remove(); - } - } - - public override void Register() + if ((player.HasAura(SpellIds.TorchTossingTraining) && GetStackAmount() == 8) || (player.HasAura(SpellIds.TorchTossingPractice) && GetStackAmount() == 20)) { - AfterEffectApply.Add(new EffectApplyHandler(HandleEffectApply, 0, AuraType.Dummy, AuraEffectHandleModes.Reapply)); + if (player.GetTeam() == Team.Alliance) + player.CastSpell(player, SpellIds.TorchTossingTrainingSuccessAlliance, true); + else if (player.GetTeam() == Team.Horde) + player.CastSpell(player, SpellIds.TorchTossingTrainingSuccessHorde, true); + Remove(); } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_midsummer_braziers_hit_AuraScript(); + AfterEffectApply.Add(new EffectApplyHandler(HandleEffectApply, 0, AuraType.Dummy, AuraEffectHandleModes.Reapply)); } } [Script] - class spell_gen_ribbon_pole_dancer_check : SpellScriptLoader + class spell_gen_ribbon_pole_dancer_check : AuraScript { - public spell_gen_ribbon_pole_dancer_check() : base("spell_gen_ribbon_pole_dancer_check") { } - - class spell_gen_ribbon_pole_dancer_check_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.HasFullMidsummerSet, SpellIds.RibbonDance, SpellIds.BurningHotPoleDance); - } - - void PeriodicTick(AuraEffect aurEff) - { - Unit target = GetTarget(); - - // check if aura needs to be removed - if (!target.FindNearestGameObject(GameobjectIds.RibbonPole, 8.0f) || !target.HasUnitState(UnitState.Casting)) - { - target.InterruptNonMeleeSpells(false); - target.RemoveAurasDueToSpell(GetId()); - target.RemoveAura(SpellIds.RibbonDanceCosmetic); - return; - } - - // set xp buff duration - Aura aur = target.GetAura(SpellIds.RibbonDance); - if (aur != null) - { - aur.SetMaxDuration(Math.Min(3600000, aur.GetMaxDuration() + 180000)); - aur.RefreshDuration(); - - // reward achievement criteria - if (aur.GetMaxDuration() == 3600000 && target.HasAura(SpellIds.HasFullMidsummerSet)) - target.CastSpell(target, SpellIds.BurningHotPoleDance, true); - } - else - target.AddAura(SpellIds.RibbonDance, target); - } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(PeriodicTick, 0, AuraType.PeriodicDummy)); - } + return ValidateSpellInfo(SpellIds.HasFullMidsummerSet, SpellIds.RibbonDance, SpellIds.BurningHotPoleDance); } - public override AuraScript GetAuraScript() + void PeriodicTick(AuraEffect aurEff) { - return new spell_gen_ribbon_pole_dancer_check_AuraScript(); + Unit target = GetTarget(); + + // check if aura needs to be removed + if (!target.FindNearestGameObject(GameobjectIds.RibbonPole, 8.0f) || !target.HasUnitState(UnitState.Casting)) + { + target.InterruptNonMeleeSpells(false); + target.RemoveAurasDueToSpell(GetId()); + target.RemoveAura(SpellIds.RibbonDanceCosmetic); + return; + } + + // set xp buff duration + Aura aur = target.GetAura(SpellIds.RibbonDance); + if (aur != null) + { + aur.SetMaxDuration(Math.Min(3600000, aur.GetMaxDuration() + 180000)); + aur.RefreshDuration(); + + // reward achievement criteria + if (aur.GetMaxDuration() == 3600000 && target.HasAura(SpellIds.HasFullMidsummerSet)) + target.CastSpell(target, SpellIds.BurningHotPoleDance, true); + } + else + target.AddAura(SpellIds.RibbonDance, target); + } + + public override void Register() + { + OnEffectPeriodic.Add(new EffectPeriodicHandler(PeriodicTick, 0, AuraType.PeriodicDummy)); } } } \ No newline at end of file diff --git a/Scripts/Spells/Hunter.cs b/Scripts/Spells/Hunter.cs index a08d7ce6b..27a9ab9af 100644 --- a/Scripts/Spells/Hunter.cs +++ b/Scripts/Spells/Hunter.cs @@ -56,994 +56,712 @@ namespace Scripts.Spells.Hunter } [Script] // 186257 - Aspect of the Cheetah - class spell_hun_aspect_cheetah : SpellScriptLoader + class spell_hun_aspect_cheetah : AuraScript { - public spell_hun_aspect_cheetah() : base("spell_hun_aspect_cheetah") { } - - class spell_hun_aspect_cheetah_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.AspectCheetahSlow); - } - - void HandleOnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - if (GetTargetApplication().GetRemoveMode() == AuraRemoveMode.Expire) - GetTarget().CastSpell(GetTarget(), SpellIds.AspectCheetahSlow, true); - } - - public override void Register() - { - AfterEffectRemove.Add(new EffectApplyHandler(HandleOnRemove, 0, AuraType.ModIncreaseSpeed, AuraEffectHandleModes.Real)); - } + return ValidateSpellInfo(SpellIds.AspectCheetahSlow); } - public override AuraScript GetAuraScript() + void HandleOnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_hun_aspect_cheetah_AuraScript(); + if (GetTargetApplication().GetRemoveMode() == AuraRemoveMode.Expire) + GetTarget().CastSpell(GetTarget(), SpellIds.AspectCheetahSlow, true); + } + + public override void Register() + { + AfterEffectRemove.Add(new EffectApplyHandler(HandleOnRemove, 0, AuraType.ModIncreaseSpeed, AuraEffectHandleModes.Real)); } } // 53209 - Chimera Shot [Script] - class HunterChimeraShot : SpellScriptLoader + class spell_hun_chimera_shot : SpellScript { - public HunterChimeraShot() : base("spell_hun_chimera_shot") { } - - class spell_hun_chimera_shot_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ChimeraShotHeal, SpellIds.SerpentSting); - } - - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Player); - } - - void HandleScriptEffect(uint effIndex) - { - GetCaster().CastSpell(GetCaster(), SpellIds.ChimeraShotHeal, true); - Aura aur = GetHitUnit().GetAura(SpellIds.SerpentSting, GetCaster().GetGUID()); - if (aur != null) - aur.SetDuration(aur.GetSpellInfo().GetMaxDuration(), true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); - } + return ValidateSpellInfo(SpellIds.ChimeraShotHeal, SpellIds.SerpentSting); } - public override SpellScript GetSpellScript() + public override bool Load() { - return new spell_hun_chimera_shot_SpellScript(); + return GetCaster().IsTypeId(TypeId.Player); + } + + void HandleScriptEffect(uint effIndex) + { + GetCaster().CastSpell(GetCaster(), SpellIds.ChimeraShotHeal, true); + Aura aur = GetHitUnit().GetAura(SpellIds.SerpentSting, GetCaster().GetGUID()); + if (aur != null) + aur.SetDuration(aur.GetSpellInfo().GetMaxDuration(), true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); } } // 77767 - Cobra Shot [Script] - class spell_hun_cobra_shot : SpellScriptLoader + class spell_hun_cobra_shot : SpellScript { - public spell_hun_cobra_shot() - : base("spell_hun_cobra_shot") - { } - - class spell_hun_cobra_shot_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.GenericEnergizeFocus, SpellIds.SerpentSting); - } + return ValidateSpellInfo(SpellIds.GenericEnergizeFocus, SpellIds.SerpentSting); + } - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Player); - } + public override bool Load() + { + return GetCaster().IsTypeId(TypeId.Player); + } - void HandleScriptEffect(uint effIndex) + void HandleScriptEffect(uint effIndex) + { + GetCaster().CastSpell(GetCaster(), SpellIds.GenericEnergizeFocus, true); + Aura aur = GetHitUnit().GetAura(SpellIds.SerpentSting, GetCaster().GetGUID()); + if (aur != null) { - GetCaster().CastSpell(GetCaster(), SpellIds.GenericEnergizeFocus, true); - Aura aur = GetHitUnit().GetAura(SpellIds.SerpentSting, GetCaster().GetGUID()); - if (aur != null) - { - int newDuration = aur.GetDuration() + GetEffectValue() * Time.InMilliseconds; - aur.SetDuration(Math.Min(newDuration, aur.GetMaxDuration()), true); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 1, SpellEffectName.ScriptEffect)); + int newDuration = aur.GetDuration() + GetEffectValue() * Time.InMilliseconds; + aur.SetDuration(Math.Min(newDuration, aur.GetMaxDuration()), true); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_hun_cobra_shot_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 1, SpellEffectName.ScriptEffect)); } } // 781 - Disengage [Script] - class spell_hun_disengage : SpellScriptLoader + class spell_hun_disengage : SpellScript { - public spell_hun_disengage() - : base("spell_hun_disengage") - { } - - class spell_hun_disengage_SpellScript : SpellScript + SpellCastResult CheckCast() { - SpellCastResult CheckCast() - { - Unit caster = GetCaster(); - if (caster.IsTypeId(TypeId.Player) && !caster.IsInCombat()) - return SpellCastResult.CantDoThatRightNow; + Unit caster = GetCaster(); + if (caster.IsTypeId(TypeId.Player) && !caster.IsInCombat()) + return SpellCastResult.CantDoThatRightNow; - return SpellCastResult.SpellCastOk; - } - - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - } + return SpellCastResult.SpellCastOk; } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_hun_disengage_SpellScript(); + OnCheckCast.Add(new CheckCastHandler(CheckCast)); } } // 82926 - Fire! [Script] - class spell_hun_fire : SpellScriptLoader + class spell_hun_fire : AuraScript { - public spell_hun_fire() - : base("spell_hun_fire") - { } - - class spell_hun_fire_AuraScript : AuraScript + void HandleEffectCalcSpellMod(AuraEffect aurEff, ref SpellModifier spellMod) { - void HandleEffectCalcSpellMod(AuraEffect aurEff, ref SpellModifier spellMod) + if (spellMod == null) { - if (spellMod == null) - { - spellMod = new SpellModifier(GetAura()); - spellMod.op = SpellModOp.CastingTime; - spellMod.type = SpellModType.Pct; - spellMod.spellId = GetId(); - spellMod.mask = GetSpellInfo().GetEffect(aurEff.GetEffIndex()).SpellClassMask; - } - - spellMod.value = -aurEff.GetAmount(); + spellMod = new SpellModifier(GetAura()); + spellMod.op = SpellModOp.CastingTime; + spellMod.type = SpellModType.Pct; + spellMod.spellId = GetId(); + spellMod.mask = GetSpellInfo().GetEffect(aurEff.GetEffIndex()).SpellClassMask; } - public override void Register() - { - DoEffectCalcSpellMod.Add(new EffectCalcSpellModHandler(HandleEffectCalcSpellMod, 0, AuraType.Dummy)); - } + spellMod.value = -aurEff.GetAmount(); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_hun_fire_AuraScript(); + DoEffectCalcSpellMod.Add(new EffectCalcSpellModHandler(HandleEffectCalcSpellMod, 0, AuraType.Dummy)); } } [Script] // 109304 - Exhilaration - class spell_hun_exhilaration : SpellScriptLoader + class spell_hun_exhilaration : SpellScript { - public spell_hun_exhilaration() : base("spell_hun_exhilaration") { } - - class spell_hun_exhilaration_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ExhilarationR2, SpellIds.Lonewolf); - } - - void HandleOnHit() - { - if (GetCaster().HasAura(SpellIds.ExhilarationR2) && !GetCaster().HasAura(SpellIds.Lonewolf)) - GetCaster().CastSpell((Unit)null, SpellIds.ExhilarationPet, true); - } - - public override void Register() - { - OnHit.Add(new HitHandler(HandleOnHit)); - } + return ValidateSpellInfo(SpellIds.ExhilarationR2, SpellIds.Lonewolf); } - public override SpellScript GetSpellScript() + void HandleOnHit() { - return new spell_hun_exhilaration_SpellScript(); + if (GetCaster().HasAura(SpellIds.ExhilarationR2) && !GetCaster().HasAura(SpellIds.Lonewolf)) + GetCaster().CastSpell((Unit)null, SpellIds.ExhilarationPet, true); + } + + public override void Register() + { + OnHit.Add(new HitHandler(HandleOnHit)); } } [Script] // 212658 - Hunting Party - class spell_hun_hunting_party : SpellScriptLoader + class spell_hun_hunting_party : AuraScript { - public spell_hun_hunting_party() : base("spell_hun_hunting_party") { } - - class spell_hun_hunting_party_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.Exhilaration, SpellIds.ExhilarationPet); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - GetTarget().GetSpellHistory().ModifyCooldown(SpellIds.Exhilaration, -TimeSpan.FromSeconds(aurEff.GetAmount())); - GetTarget().GetSpellHistory().ModifyCooldown(SpellIds.ExhilarationPet, -TimeSpan.FromSeconds(aurEff.GetAmount())); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.Exhilaration, SpellIds.ExhilarationPet); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_hun_hunting_party_AuraScript(); + PreventDefaultAction(); + GetTarget().GetSpellHistory().ModifyCooldown(SpellIds.Exhilaration, -TimeSpan.FromSeconds(aurEff.GetAmount())); + GetTarget().GetSpellHistory().ModifyCooldown(SpellIds.ExhilarationPet, -TimeSpan.FromSeconds(aurEff.GetAmount())); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } // -19572 - Improved Mend Pet [Script] - class spell_hun_improved_mend_pet : SpellScriptLoader + class spell_hun_improved_mend_pet : AuraScript { - public spell_hun_improved_mend_pet() : base("spell_hun_improved_mend_pet") { } - - class spell_hun_improved_mend_pet_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ImprovedMendPet); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - return RandomHelper.randChance(GetEffect(0).GetAmount()); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), SpellIds.ImprovedMendPet, true, null, aurEff); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.ImprovedMendPet); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_hun_improved_mend_pet_AuraScript(); + return RandomHelper.randChance(GetEffect(0).GetAmount()); + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + GetTarget().CastSpell(GetTarget(), SpellIds.ImprovedMendPet, true, null, aurEff); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } // -19464 Improved Serpent Sting [Script] - class spell_hun_improved_serpent_sting : SpellScriptLoader + class spell_hun_improved_serpent_sting : AuraScript { - public spell_hun_improved_serpent_sting() - : base("spell_hun_improved_serpent_sting") - { } - - class spell_hun_improved_serpent_sting_AuraScript : AuraScript + void HandleEffectCalcSpellMod(AuraEffect aurEff, ref SpellModifier spellMod) { - void HandleEffectCalcSpellMod(AuraEffect aurEff, ref SpellModifier spellMod) + if (spellMod == null) { - if (spellMod == null) - { - spellMod = new SpellModifier(GetAura()); - spellMod.op = (SpellModOp)aurEff.GetMiscValue(); - spellMod.type = SpellModType.Pct; - spellMod.spellId = GetId(); - spellMod.mask = GetSpellInfo().GetEffect(aurEff.GetEffIndex()).SpellClassMask; - } - - spellMod.value = aurEff.GetAmount(); + spellMod = new SpellModifier(GetAura()); + spellMod.op = (SpellModOp)aurEff.GetMiscValue(); + spellMod.type = SpellModType.Pct; + spellMod.spellId = GetId(); + spellMod.mask = GetSpellInfo().GetEffect(aurEff.GetEffIndex()).SpellClassMask; } - public override void Register() - { - DoEffectCalcSpellMod.Add(new EffectCalcSpellModHandler(HandleEffectCalcSpellMod, 0, AuraType.Dummy)); - } + spellMod.value = aurEff.GetAmount(); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_hun_improved_serpent_sting_AuraScript(); + DoEffectCalcSpellMod.Add(new EffectCalcSpellModHandler(HandleEffectCalcSpellMod, 0, AuraType.Dummy)); } } // 53478 - Last Stand Pet [Script] - class spell_hun_last_stand_pet : SpellScriptLoader + class spell_hun_last_stand_pet : SpellScript { - public spell_hun_last_stand_pet() - : base("spell_hun_last_stand_pet") - { } - - class spell_hun_last_stand_pet_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.PetLastStandTriggered); - } - - void HandleDummy(uint effIndex) - { - Unit caster = GetCaster(); - int healthModSpellBasePoints0 = (int)caster.CountPctFromMaxHealth(30); - caster.CastCustomSpell(caster, SpellIds.PetLastStandTriggered, healthModSpellBasePoints0, 0, 0, true, null); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellIds.PetLastStandTriggered); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_hun_last_stand_pet_SpellScript(); + Unit caster = GetCaster(); + int healthModSpellBasePoints0 = (int)caster.CountPctFromMaxHealth(30); + caster.CastCustomSpell(caster, SpellIds.PetLastStandTriggered, healthModSpellBasePoints0, 0, 0, true, null); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } // 53271 - Masters Call [Script] - class spell_hun_masters_call : SpellScriptLoader + class spell_hun_masters_call : SpellScript { - public spell_hun_masters_call() - : base("spell_hun_masters_call") - { } - - class spell_hun_masters_call_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.MastersCallTriggered, (uint)spellInfo.GetEffect(0).CalcValue()); - } + return ValidateSpellInfo(SpellIds.MastersCallTriggered, (uint)spellInfo.GetEffect(0).CalcValue()); + } - void HandleDummy(uint effIndex) + void HandleDummy(uint effIndex) + { + Unit ally = GetHitUnit(); + if (ally) { - Unit ally = GetHitUnit(); - if (ally) + Player caster = GetCaster().ToPlayer(); + if (caster) { - Player caster = GetCaster().ToPlayer(); - if (caster) + Pet target = caster.GetPet(); + if (target) { - Pet target = caster.GetPet(); - if (target) - { - TriggerCastFlags castMask = (TriggerCastFlags.FullMask & ~TriggerCastFlags.IgnoreCasterAurastate); - target.CastSpell(ally, (uint)GetEffectValue(), castMask); - } + TriggerCastFlags castMask = (TriggerCastFlags.FullMask & ~TriggerCastFlags.IgnoreCasterAurastate); + target.CastSpell(ally, (uint)GetEffectValue(), castMask); } } } + } - void HandleScriptEffect(uint effIndex) + void HandleScriptEffect(uint effIndex) + { + Unit target = GetHitUnit(); + if (target) { - Unit target = GetHitUnit(); - if (target) - { - // Cannot be processed while pet is dead - TriggerCastFlags castMask = (TriggerCastFlags.FullMask & ~TriggerCastFlags.IgnoreCasterAurastate); - target.CastSpell(target, SpellIds.MastersCallTriggered, castMask); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 1, SpellEffectName.ScriptEffect)); + // Cannot be processed while pet is dead + TriggerCastFlags castMask = (TriggerCastFlags.FullMask & ~TriggerCastFlags.IgnoreCasterAurastate); + target.CastSpell(target, SpellIds.MastersCallTriggered, castMask); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_hun_masters_call_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 1, SpellEffectName.ScriptEffect)); } } // 34477 - Misdirection [Script] - class spell_hun_misdirection : SpellScriptLoader + class spell_hun_misdirection : AuraScript { - public spell_hun_misdirection() : base("spell_hun_misdirection") { } - - class spell_hun_misdirection_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.MisdirectionProc); - } - - void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - if (GetTargetApplication().GetRemoveMode() != AuraRemoveMode.Default || !GetTarget().HasAura(SpellIds.MisdirectionProc)) - GetTarget().ResetRedirectThreat(); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - return GetTarget().GetRedirectThreatTarget(); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), SpellIds.MisdirectionProc, true, null, aurEff); - } - - public override void Register() - { - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 1, AuraType.Dummy, AuraEffectHandleModes.Real)); - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.MisdirectionProc); } - public override AuraScript GetAuraScript() + void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_hun_misdirection_AuraScript(); + if (GetTargetApplication().GetRemoveMode() != AuraRemoveMode.Default || !GetTarget().HasAura(SpellIds.MisdirectionProc)) + GetTarget().ResetRedirectThreat(); + } + + bool CheckProc(ProcEventInfo eventInfo) + { + return GetTarget().GetRedirectThreatTarget(); + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + GetTarget().CastSpell(GetTarget(), SpellIds.MisdirectionProc, true, null, aurEff); + } + + public override void Register() + { + AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 1, AuraType.Dummy, AuraEffectHandleModes.Real)); + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.Dummy)); } } // 35079 - Misdirection (Proc) [Script] - class spell_hun_misdirection_proc : SpellScriptLoader + class spell_hun_misdirection_proc : AuraScript { - public spell_hun_misdirection_proc() - : base("spell_hun_misdirection_proc") - { } - - class spell_hun_misdirection_proc_AuraScript : AuraScript + void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - GetTarget().ResetRedirectThreat(); - } - - public override void Register() - { - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - } + GetTarget().ResetRedirectThreat(); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_hun_misdirection_proc_AuraScript(); + AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } // 54044 - Pet Carrion Feeder [Script] - class spell_hun_pet_carrion_feeder : SpellScriptLoader + class spell_hun_pet_carrion_feeder : SpellScript { - public spell_hun_pet_carrion_feeder() - : base("spell_hun_pet_carrion_feeder") - { } - - class spell_hun_pet_carrion_feeder_SpellScript : SpellScript + public override bool Load() { - public override bool Load() - { - if (!GetCaster().IsPet()) - return false; - return true; - } - - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.PetCarrionFeederTriggered); - } - - SpellCastResult CheckIfCorpseNear() - { - Unit caster = GetCaster(); - float max_range = GetSpellInfo().GetMaxRange(false); - - // search for nearby enemy corpse in range - var check = new AnyDeadUnitSpellTargetInRangeCheck(caster, max_range, GetSpellInfo(), SpellTargetCheckTypes.Enemy); - var searcher = new WorldObjectSearcher(caster, check); - Cell.VisitWorldObjects(caster, searcher, max_range); - if (!searcher.GetTarget()) - Cell.VisitGridObjects(caster, searcher, max_range); - if (!searcher.GetTarget()) - return SpellCastResult.NoEdibleCorpses; - return SpellCastResult.SpellCastOk; - } - - void HandleDummy(uint effIndex) - { - Unit caster = GetCaster(); - caster.CastSpell(caster, SpellIds.PetCarrionFeederTriggered, false); - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - OnCheckCast.Add(new CheckCastHandler(CheckIfCorpseNear)); - } + if (!GetCaster().IsPet()) + return false; + return true; } - public override SpellScript GetSpellScript() + public override bool Validate(SpellInfo spellInfo) { - return new spell_hun_pet_carrion_feeder_SpellScript(); + return ValidateSpellInfo(SpellIds.PetCarrionFeederTriggered); + } + + SpellCastResult CheckIfCorpseNear() + { + Unit caster = GetCaster(); + float max_range = GetSpellInfo().GetMaxRange(false); + + // search for nearby enemy corpse in range + var check = new AnyDeadUnitSpellTargetInRangeCheck(caster, max_range, GetSpellInfo(), SpellTargetCheckTypes.Enemy); + var searcher = new WorldObjectSearcher(caster, check); + Cell.VisitWorldObjects(caster, searcher, max_range); + if (!searcher.GetTarget()) + Cell.VisitGridObjects(caster, searcher, max_range); + if (!searcher.GetTarget()) + return SpellCastResult.NoEdibleCorpses; + return SpellCastResult.SpellCastOk; + } + + void HandleDummy(uint effIndex) + { + Unit caster = GetCaster(); + caster.CastSpell(caster, SpellIds.PetCarrionFeederTriggered, false); + } + + public override void Register() + { + OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnCheckCast.Add(new CheckCastHandler(CheckIfCorpseNear)); } } // 55709 - Pet Heart of the Phoenix [Script] - class spell_hun_pet_heart_of_the_phoenix : SpellScriptLoader + class spell_hun_pet_heart_of_the_phoenix : SpellScript { - public spell_hun_pet_heart_of_the_phoenix() - : base("spell_hun_pet_heart_of_the_phoenix") - { } - - class spell_hun_pet_heart_of_the_phoenix_SpellScript : SpellScript + public override bool Load() { - public override bool Load() - { - if (!GetCaster().IsPet()) - return false; - return true; - } + if (!GetCaster().IsPet()) + return false; + return true; + } - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.PetHeartOfThePhoenixTriggered, SpellIds.PetHeartOfThePhoenixDebuff); - } + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.PetHeartOfThePhoenixTriggered, SpellIds.PetHeartOfThePhoenixDebuff); + } - void HandleScript(uint effIndex) + void HandleScript(uint effIndex) + { + Unit caster = GetCaster(); + Unit owner = caster.GetOwner(); + if (owner) { - Unit caster = GetCaster(); - Unit owner = caster.GetOwner(); - if (owner) + if (!caster.HasAura(SpellIds.PetHeartOfThePhoenixDebuff)) { - if (!caster.HasAura(SpellIds.PetHeartOfThePhoenixDebuff)) - { - owner.CastCustomSpell(SpellIds.PetHeartOfThePhoenixTriggered, SpellValueMod.BasePoint0, 100, caster, true); - caster.CastSpell(caster, SpellIds.PetHeartOfThePhoenixDebuff, true); - } + owner.CastCustomSpell(SpellIds.PetHeartOfThePhoenixTriggered, SpellValueMod.BasePoint0, 100, caster, true); + caster.CastSpell(caster, SpellIds.PetHeartOfThePhoenixDebuff, true); } } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_hun_pet_heart_of_the_phoenix_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } // 23989 - Readiness [Script] - class spell_hun_readiness : SpellScriptLoader + class spell_hun_readiness : SpellScript { - public spell_hun_readiness() - : base("spell_hun_readiness") - { } - - class spell_hun_readiness_SpellScript : SpellScript + public override bool Load() { - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Player); - } - - void HandleDummy(uint effIndex) - { - // immediately finishes the cooldown on your other Hunter abilities except Bestial Wrath - GetCaster().GetSpellHistory().ResetCooldowns(p => - { - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(p.Key); - - ///! If spellId in cooldown map isn't valid, the above will return a null pointer. - if (spellInfo.SpellFamilyName == SpellFamilyNames.Hunter && - spellInfo.Id != SpellIds.Readiness && - spellInfo.Id != SpellIds.BestialWrath && - spellInfo.Id != SpellIds.DraeneiGiftOfTheNaaru && - spellInfo.GetRecoveryTime() > 0) - return true; - return false; - }, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return GetCaster().IsTypeId(TypeId.Player); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_hun_readiness_SpellScript(); + // immediately finishes the cooldown on your other Hunter abilities except Bestial Wrath + GetCaster().GetSpellHistory().ResetCooldowns(p => + { + SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(p.Key); + + ///! If spellId in cooldown map isn't valid, the above will return a null pointer. + if (spellInfo.SpellFamilyName == SpellFamilyNames.Hunter && + spellInfo.Id != SpellIds.Readiness && + spellInfo.Id != SpellIds.BestialWrath && + spellInfo.Id != SpellIds.DraeneiGiftOfTheNaaru && + spellInfo.GetRecoveryTime() > 0) + return true; + return false; + }, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } // 82925 - Ready, Set, Aim... [Script] - class spell_hun_ready_set_aim : SpellScriptLoader + class spell_hun_ready_set_aim : AuraScript { - public spell_hun_ready_set_aim() - : base("spell_hun_ready_set_aim") - { } - - class spell_hun_ready_set_aim_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.Fire); - } + return ValidateSpellInfo(SpellIds.Fire); + } - void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) + void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) + { + if (GetStackAmount() == 5) { - if (GetStackAmount() == 5) - { - GetTarget().CastSpell(GetTarget(), SpellIds.Fire, true, null, aurEff); - GetTarget().RemoveAura(GetId()); - } - } - - public override void Register() - { - AfterEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.Dummy, AuraEffectHandleModes.RealOrReapplyMask)); + GetTarget().CastSpell(GetTarget(), SpellIds.Fire, true, null, aurEff); + GetTarget().RemoveAura(GetId()); } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_hun_ready_set_aim_AuraScript(); + AfterEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.Dummy, AuraEffectHandleModes.RealOrReapplyMask)); } } [Script] // 53480 - Roar of Sacrifice - class spell_hun_roar_of_sacrifice : SpellScriptLoader + class spell_hun_roar_of_sacrifice : AuraScript { - public spell_hun_roar_of_sacrifice() : base("spell_hun_roar_of_sacrifice") { } - - class spell_hun_roar_of_sacrifice_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.RoarOfSacrificeTriggered); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - return GetCaster() && ((uint)eventInfo.GetDamageInfo().GetSchoolMask() & GetEffect(1).GetMiscValue()) != 0; - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - int damage = (int)MathFunctions.CalculatePct(eventInfo.GetDamageInfo().GetDamage(), aurEff.GetAmount()); - eventInfo.GetActor().CastCustomSpell(SpellIds.RoarOfSacrificeTriggered, SpellValueMod.BasePoint0, damage, GetCaster(), TriggerCastFlags.FullMask, null, aurEff); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.RoarOfSacrificeTriggered); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_hun_roar_of_sacrifice_AuraScript(); + return GetCaster() && ((uint)eventInfo.GetDamageInfo().GetSchoolMask() & GetEffect(1).GetMiscValue()) != 0; + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + + int damage = (int)MathFunctions.CalculatePct(eventInfo.GetDamageInfo().GetDamage(), aurEff.GetAmount()); + eventInfo.GetActor().CastCustomSpell(SpellIds.RoarOfSacrificeTriggered, SpellValueMod.BasePoint0, damage, GetCaster(), TriggerCastFlags.FullMask, null, aurEff); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.Dummy)); } } // 37506 - Scatter Shot [Script] - class spell_hun_scatter_shot : SpellScriptLoader + class spell_hun_scatter_shot : SpellScript { - public spell_hun_scatter_shot() - : base("spell_hun_scatter_shot") - { } - - class spell_hun_scatter_shot_SpellScript : SpellScript + public override bool Load() { - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Player); - } - - void HandleDummy(uint effIndex) - { - Player caster = GetCaster().ToPlayer(); - // break Auto Shot and autohit - caster.InterruptSpell(CurrentSpellTypes.AutoRepeat); - caster.AttackStop(); - caster.SendAttackSwingCancelAttack(); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return GetCaster().IsTypeId(TypeId.Player); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_hun_scatter_shot_SpellScript(); + Player caster = GetCaster().ToPlayer(); + // break Auto Shot and autohit + caster.InterruptSpell(CurrentSpellTypes.AutoRepeat); + caster.AttackStop(); + caster.SendAttackSwingCancelAttack(); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } // -53302 - Sniper Training [Script] - class spell_hun_sniper_training : SpellScriptLoader + class spell_hun_sniper_training : AuraScript { - public spell_hun_sniper_training() - : base("spell_hun_sniper_training") - { } - - class spell_hun_sniper_training_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.SniperTrainingR1, SpellIds.SniperTrainingBuffR1); - } + return ValidateSpellInfo(SpellIds.SniperTrainingR1, SpellIds.SniperTrainingBuffR1); + } - void HandlePeriodic(AuraEffect aurEff) - { - PreventDefaultAction(); - if (aurEff.GetAmount() <= 0) - { - uint spellId = SpellIds.SniperTrainingBuffR1 + GetId() - SpellIds.SniperTrainingR1; - Unit target = GetTarget(); - target.CastSpell(target, spellId, true, null, aurEff); - Player playerTarget = GetUnitOwner().ToPlayer(); - if (playerTarget) - { - int baseAmount = aurEff.GetBaseAmount(); - int amount = playerTarget.CalculateSpellDamage(playerTarget, GetSpellInfo(), aurEff.GetEffIndex(), baseAmount); - GetEffect(0).SetAmount(amount); - } - } - } - - void HandleUpdatePeriodic(AuraEffect aurEff) + void HandlePeriodic(AuraEffect aurEff) + { + PreventDefaultAction(); + if (aurEff.GetAmount() <= 0) { + uint spellId = SpellIds.SniperTrainingBuffR1 + GetId() - SpellIds.SniperTrainingR1; + Unit target = GetTarget(); + target.CastSpell(target, spellId, true, null, aurEff); Player playerTarget = GetUnitOwner().ToPlayer(); if (playerTarget) { int baseAmount = aurEff.GetBaseAmount(); - int amount = playerTarget.isMoving() ? - playerTarget.CalculateSpellDamage(playerTarget, GetSpellInfo(), aurEff.GetEffIndex(), baseAmount) : - aurEff.GetAmount() - 1; - aurEff.SetAmount(amount); + int amount = playerTarget.CalculateSpellDamage(playerTarget, GetSpellInfo(), aurEff.GetEffIndex(), baseAmount); + GetEffect(0).SetAmount(amount); } } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandlePeriodic, 0, AuraType.PeriodicTriggerSpell)); - OnEffectUpdatePeriodic.Add(new EffectUpdatePeriodicHandler(HandleUpdatePeriodic, 0, AuraType.PeriodicTriggerSpell)); - } } - public override AuraScript GetAuraScript() + void HandleUpdatePeriodic(AuraEffect aurEff) { - return new spell_hun_sniper_training_AuraScript(); + Player playerTarget = GetUnitOwner().ToPlayer(); + if (playerTarget) + { + int baseAmount = aurEff.GetBaseAmount(); + int amount = playerTarget.isMoving() ? + playerTarget.CalculateSpellDamage(playerTarget, GetSpellInfo(), aurEff.GetEffIndex(), baseAmount) : + aurEff.GetAmount() - 1; + aurEff.SetAmount(amount); + } + } + + public override void Register() + { + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandlePeriodic, 0, AuraType.PeriodicTriggerSpell)); + OnEffectUpdatePeriodic.Add(new EffectUpdatePeriodicHandler(HandleUpdatePeriodic, 0, AuraType.PeriodicTriggerSpell)); } } // 56641 - Steady Shot [Script] - class spell_hun_steady_shot : SpellScriptLoader + class spell_hun_steady_shot : SpellScript { - public spell_hun_steady_shot() : base("spell_hun_steady_shot") { } - - class spell_hun_steady_shot_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.SteadyShotFocus); - } - - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Player); - } - - void HandleOnHit() - { - GetCaster().CastSpell(GetCaster(), SpellIds.SteadyShotFocus, true); - } - - public override void Register() - { - OnHit.Add(new HitHandler(HandleOnHit)); - } + return ValidateSpellInfo(SpellIds.SteadyShotFocus); } - public override SpellScript GetSpellScript() + public override bool Load() { - return new spell_hun_steady_shot_SpellScript(); + return GetCaster().IsTypeId(TypeId.Player); + } + + void HandleOnHit() + { + GetCaster().CastSpell(GetCaster(), SpellIds.SteadyShotFocus, true); + } + + public override void Register() + { + OnHit.Add(new HitHandler(HandleOnHit)); } } // 1515 - Tame Beast [Script] - class spell_hun_tame_beast : SpellScriptLoader + class spell_hun_tame_beast : SpellScript { - public spell_hun_tame_beast() - : base("spell_hun_tame_beast") - { } - - class spell_hun_tame_beast_SpellScript : SpellScript + SpellCastResult CheckCast() { - SpellCastResult CheckCast() + Unit caster = GetCaster(); + if (!caster.IsTypeId(TypeId.Player)) + return SpellCastResult.DontReport; + + if (!GetExplTargetUnit()) + return SpellCastResult.BadImplicitTargets; + + Creature target = GetExplTargetUnit().ToCreature(); + if (target) { - Unit caster = GetCaster(); - if (!caster.IsTypeId(TypeId.Player)) - return SpellCastResult.DontReport; + if (target.getLevel() > caster.getLevel()) + return SpellCastResult.Highlevel; - if (!GetExplTargetUnit()) - return SpellCastResult.BadImplicitTargets; + // use SMSG_PET_TAME_FAILURE? + if (!target.GetCreatureTemplate().IsTameable(caster.ToPlayer().CanTameExoticPets())) + return SpellCastResult.BadTargets; - Creature target = GetExplTargetUnit().ToCreature(); - if (target) - { - if (target.getLevel() > caster.getLevel()) - return SpellCastResult.Highlevel; + if (!caster.GetPetGUID().IsEmpty()) + return SpellCastResult.AlreadyHaveSummon; - // use SMSG_PET_TAME_FAILURE? - if (!target.GetCreatureTemplate().IsTameable(caster.ToPlayer().CanTameExoticPets())) - return SpellCastResult.BadTargets; - - if (!caster.GetPetGUID().IsEmpty()) - return SpellCastResult.AlreadyHaveSummon; - - if (!caster.GetCharmGUID().IsEmpty()) - return SpellCastResult.AlreadyHaveCharm; - } - else - return SpellCastResult.BadImplicitTargets; - - return SpellCastResult.SpellCastOk; + if (!caster.GetCharmGUID().IsEmpty()) + return SpellCastResult.AlreadyHaveCharm; } + else + return SpellCastResult.BadImplicitTargets; - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - } + return SpellCastResult.SpellCastOk; } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_hun_tame_beast_SpellScript(); + OnCheckCast.Add(new CheckCastHandler(CheckCast)); } } // 53434 - Call of the Wild [Script] - class spell_hun_target_only_pet_and_owner : SpellScriptLoader + class spell_hun_target_only_pet_and_owner : SpellScript { - public spell_hun_target_only_pet_and_owner() - : base("spell_hun_target_only_pet_and_owner") - { } - - class spell_hun_target_only_pet_and_owner_SpellScript : SpellScript + void FilterTargets(List targets) { - void FilterTargets(List targets) - { - targets.Clear(); - targets.Add(GetCaster()); - Unit owner = GetCaster().GetOwner(); - if (owner) - targets.Add(owner); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitCasterAreaParty)); - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 1, Targets.UnitCasterAreaParty)); - } + targets.Clear(); + targets.Add(GetCaster()); + Unit owner = GetCaster().GetOwner(); + if (owner) + targets.Add(owner); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_hun_target_only_pet_and_owner_SpellScript(); + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitCasterAreaParty)); + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 1, Targets.UnitCasterAreaParty)); } } [Script] // 67151 - Item - Hunter T9 4P Bonus (Steady Shot) - class spell_hun_t9_4p_bonus : SpellScriptLoader + class spell_hun_t9_4p_bonus : AuraScript { - public spell_hun_t9_4p_bonus() : base("spell_hun_t9_4p_bonus") { } - - class spell_hun_t9_4p_bonus_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.T94PGreatness); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - if (eventInfo.GetActor().IsTypeId(TypeId.Player) && eventInfo.GetActor().ToPlayer().GetPet()) - return true; - return false; - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - Unit caster = eventInfo.GetActor(); - - caster.CastSpell(caster.ToPlayer().GetPet(), SpellIds.T94PGreatness, true, null, aurEff); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); - } + return ValidateSpellInfo(SpellIds.T94PGreatness); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_hun_t9_4p_bonus_AuraScript(); + if (eventInfo.GetActor().IsTypeId(TypeId.Player) && eventInfo.GetActor().ToPlayer().GetPet()) + return true; + return false; + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + Unit caster = eventInfo.GetActor(); + + caster.CastSpell(caster.ToPlayer().GetPet(), SpellIds.T94PGreatness, true, null, aurEff); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); } } // -56333 - T.N.T. [Script] - class spell_hun_tnt : SpellScriptLoader + class spell_hun_tnt : AuraScript { - public spell_hun_tnt() - : base("spell_hun_tnt") - { } - - class spell_hun_tnt_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.LockAndLoad); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - return RandomHelper.randChance(GetEffect(0).GetAmount()); - } - - void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), SpellIds.LockAndLoad, true, null, aurEff); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.LockAndLoad); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_hun_tnt_AuraScript(); + return RandomHelper.randChance(GetEffect(0).GetAmount()); + } + + void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + GetTarget().CastSpell(GetTarget(), SpellIds.LockAndLoad, true, null, aurEff); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); } } } diff --git a/Scripts/Spells/Items.cs b/Scripts/Spells/Items.cs index c8d7b5fcc..97c28c70f 100644 --- a/Scripts/Spells/Items.cs +++ b/Scripts/Spells/Items.cs @@ -469,76 +469,51 @@ namespace Scripts.Spells.Items [Script("spell_item_gnomish_battle_chicken", SpellIds.BattleChicken)] [Script("spell_item_mechanical_dragonling", SpellIds.MechanicalDragonling)] [Script("spell_item_mithril_mechanical_dragonling", SpellIds.MithrilMechanicalDragonling)] - class spell_item_trigger_spell : SpellScriptLoader + class spell_item_trigger_spell : SpellScript { - public spell_item_trigger_spell(string name, uint triggeredSpellId) : base(name) + public spell_item_trigger_spell(uint triggeredSpellId) { _triggeredSpellId = triggeredSpellId; } - class spell_item_trigger_spell_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public spell_item_trigger_spell_SpellScript(uint triggeredSpellId) : base() - { - _triggeredSpellId = triggeredSpellId; - } - - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(_triggeredSpellId); - } - - void HandleDummy(uint effIndex) - { - Unit caster = GetCaster(); - Item item = GetCastItem(); - if (item) - caster.CastSpell(caster, _triggeredSpellId, true, item); - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } - - uint _triggeredSpellId; + return ValidateSpellInfo(_triggeredSpellId); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_item_trigger_spell_SpellScript(_triggeredSpellId); + Unit caster = GetCaster(); + Item item = GetCastItem(); + if (item) + caster.CastSpell(caster, _triggeredSpellId, true, item); + } + + public override void Register() + { + OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } uint _triggeredSpellId; } [Script] // 23780 - Aegis of Preservation - class spell_item_aegis_of_preservation : SpellScriptLoader + class spell_item_aegis_of_preservation : AuraScript { - public spell_item_aegis_of_preservation() : base("spell_item_aegis_of_preservation") { } - - class spell_item_aegis_of_preservation_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.AegisHeal); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), SpellIds.AegisHeal, true, null, aurEff); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.PeriodicTriggerSpell)); - } + return ValidateSpellInfo(SpellIds.AegisHeal); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_item_aegis_of_preservation_AuraScript(); + PreventDefaultAction(); + GetTarget().CastSpell(GetTarget(), SpellIds.AegisHeal, true, null, aurEff); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.PeriodicTriggerSpell)); } } @@ -552,50 +527,40 @@ namespace Scripts.Spells.Items // Item - 44324: Mighty Alchemist's Stone [Script] // 17619 - Alchemist Stone - class spell_item_alchemist_stone : SpellScriptLoader + class spell_item_alchemist_stone : AuraScript { - public spell_item_alchemist_stone() : base("spell_item_alchemist_stone") { } - - class spell_item_alchemist_stone_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.AlchemistStoneExtraHeal, SpellIds.AlchemistStoneExtraMana); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - return eventInfo.GetDamageInfo().GetSpellInfo().SpellFamilyName == SpellFamilyNames.Potion; - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - uint spellId = 0; - int amount = (int)(eventInfo.GetDamageInfo().GetDamage() * 0.4f); - - if (eventInfo.GetDamageInfo().GetSpellInfo().HasEffect(Difficulty.None, SpellEffectName.Heal)) - spellId = SpellIds.AlchemistStoneExtraHeal; - else if (eventInfo.GetDamageInfo().GetSpellInfo().HasEffect(Difficulty.None, SpellEffectName.Energize)) - spellId = SpellIds.AlchemistStoneExtraMana; - - if (spellId == 0) - return; - - GetTarget().CastCustomSpell(spellId, SpellValueMod.BasePoint0, amount, GetTarget(), true, null, aurEff); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.AlchemistStoneExtraHeal, SpellIds.AlchemistStoneExtraMana); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_item_alchemist_stone_AuraScript(); + return eventInfo.GetDamageInfo().GetSpellInfo().SpellFamilyName == SpellFamilyNames.Potion; + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + + uint spellId = 0; + int amount = (int)(eventInfo.GetDamageInfo().GetDamage() * 0.4f); + + if (eventInfo.GetDamageInfo().GetSpellInfo().HasEffect(Difficulty.None, SpellEffectName.Heal)) + spellId = SpellIds.AlchemistStoneExtraHeal; + else if (eventInfo.GetDamageInfo().GetSpellInfo().HasEffect(Difficulty.None, SpellEffectName.Energize)) + spellId = SpellIds.AlchemistStoneExtraMana; + + if (spellId == 0) + return; + + GetTarget().CastCustomSpell(spellId, SpellValueMod.BasePoint0, amount, GetTarget(), true, null, aurEff); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } @@ -606,106 +571,77 @@ namespace Scripts.Spells.Items // 71545 - Anger Capacitor [Script("spell_item_tiny_abomination_in_a_jar", 8)] [Script("spell_item_tiny_abomination_in_a_jar_hero", 7)] - class spell_item_anger_capacitor : SpellScriptLoader + class spell_item_anger_capacitor : AuraScript { - public spell_item_anger_capacitor(string scriptName, int stackAmount) : base(scriptName) + public spell_item_anger_capacitor(int stackAmount) { _stackAmount = stackAmount; } - class spell_item_anger_capacitor_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public spell_item_anger_capacitor_AuraScript(int stackAmount) - { - _stackAmount = stackAmount; - } - - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.MoteOfAnger, SpellIds.ManifestAngerMainHand, SpellIds.ManifestAngerOffHand); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - Unit caster = eventInfo.GetActor(); - Unit target = eventInfo.GetProcTarget(); - - caster.CastSpell((Unit)null, SpellIds.MoteOfAnger, true); - Aura motes = caster.GetAura(SpellIds.MoteOfAnger); - if (motes == null || motes.GetStackAmount() < _stackAmount) - return; - - caster.RemoveAurasDueToSpell(SpellIds.MoteOfAnger); - uint spellId = SpellIds.ManifestAngerMainHand; - Player player = caster.ToPlayer(); - if (player) - if (player.GetWeaponForAttack(WeaponAttackType.OffAttack, true) && RandomHelper.URand(0, 1) != 0) - spellId = SpellIds.ManifestAngerOffHand; - - caster.CastSpell(target, spellId, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } - - int _stackAmount; + return ValidateSpellInfo(SpellIds.MoteOfAnger, SpellIds.ManifestAngerMainHand, SpellIds.ManifestAngerOffHand); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_item_anger_capacitor_AuraScript(_stackAmount); + PreventDefaultAction(); + Unit caster = eventInfo.GetActor(); + Unit target = eventInfo.GetProcTarget(); + + caster.CastSpell((Unit)null, SpellIds.MoteOfAnger, true); + Aura motes = caster.GetAura(SpellIds.MoteOfAnger); + if (motes == null || motes.GetStackAmount() < _stackAmount) + return; + + caster.RemoveAurasDueToSpell(SpellIds.MoteOfAnger); + uint spellId = SpellIds.ManifestAngerMainHand; + Player player = caster.ToPlayer(); + if (player) + if (player.GetWeaponForAttack(WeaponAttackType.OffAttack, true) && RandomHelper.URand(0, 1) != 0) + spellId = SpellIds.ManifestAngerOffHand; + + caster.CastSpell(target, spellId, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } int _stackAmount; } [Script] // 26400 - Arcane Shroud - class spell_item_arcane_shroud : SpellScriptLoader + class spell_item_arcane_shroud : AuraScript { - public spell_item_arcane_shroud() : base("spell_item_arcane_shroud") { } - - class spell_item_arcane_shroud_AuraScript : AuraScript + void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) { - void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) - { - int diff = (int)GetUnitOwner().getLevel() - 60; - if (diff > 0) - amount += 2 * diff; - } - - public override void Register() - { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.ModThreat)); - } + int diff = (int)GetUnitOwner().getLevel() - 60; + if (diff > 0) + amount += 2 * diff; } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_item_arcane_shroud_AuraScript(); + DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.ModThreat)); } } // Item - 31859: Darkmoon Card: Madness [Script] // 39446 - Aura of Madness - class spell_item_aura_of_madness : SpellScriptLoader + class spell_item_aura_of_madness : AuraScript { - public spell_item_aura_of_madness() : base("spell_item_aura_of_madness") { } - - class spell_item_aura_of_madness_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return CliDB.BroadcastTextStorage.ContainsKey(TextIds.SayMadness) && ValidateSpellInfo(SpellIds.Sociopath, SpellIds.Delusional, SpellIds.Kleptomania, - SpellIds.Megalomania, SpellIds.Paranoia, SpellIds.Manic, SpellIds.Narcissism, SpellIds.MartyrComplex, SpellIds.Dementia); - } + return CliDB.BroadcastTextStorage.ContainsKey(TextIds.SayMadness) && ValidateSpellInfo(SpellIds.Sociopath, SpellIds.Delusional, SpellIds.Kleptomania, + SpellIds.Megalomania, SpellIds.Paranoia, SpellIds.Manic, SpellIds.Narcissism, SpellIds.MartyrComplex, SpellIds.Dementia); + } - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + uint[][] triggeredSpells = { - uint[][] triggeredSpells = - { //CLASS_NONE new uint[] { }, //CLASS_WARRIOR @@ -732,161 +668,115 @@ namespace Scripts.Spells.Items new uint[]{ SpellIds.Sociopath, SpellIds.Delusional, SpellIds.Kleptomania, SpellIds.Megalomania, SpellIds.Paranoia, SpellIds.Manic, SpellIds.Narcissism, SpellIds.MartyrComplex, SpellIds.Dementia } }; - PreventDefaultAction(); - Unit caster = eventInfo.GetActor(); - uint spellId = triggeredSpells[(int)caster.GetClass()].SelectRandom(); - caster.CastSpell(caster, spellId, true); + PreventDefaultAction(); + Unit caster = eventInfo.GetActor(); + uint spellId = triggeredSpells[(int)caster.GetClass()].SelectRandom(); + caster.CastSpell(caster, spellId, true); - if (RandomHelper.randChance(10)) - caster.Say(TextIds.SayMadness); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + if (RandomHelper.randChance(10)) + caster.Say(TextIds.SayMadness); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_item_aura_of_madness_AuraScript(); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } [Script] // 41404 - Dementia - class spell_item_dementia : SpellScriptLoader + class spell_item_dementia : AuraScript { - public spell_item_dementia() : base("spell_item_dementia") { } - - class spell_item_dementia_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.DementiaPos, SpellIds.DementiaNeg); - } - - void HandlePeriodicDummy(AuraEffect aurEff) - { - PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), RandomHelper.RAND(SpellIds.DementiaPos, SpellIds.DementiaNeg), true); - } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandlePeriodicDummy, 0, AuraType.PeriodicDummy)); - } + return ValidateSpellInfo(SpellIds.DementiaPos, SpellIds.DementiaNeg); } - public override AuraScript GetAuraScript() + void HandlePeriodicDummy(AuraEffect aurEff) { - return new spell_item_dementia_AuraScript(); + PreventDefaultAction(); + GetTarget().CastSpell(GetTarget(), RandomHelper.RAND(SpellIds.DementiaPos, SpellIds.DementiaNeg), true); + } + + public override void Register() + { + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandlePeriodicDummy, 0, AuraType.PeriodicDummy)); } } [Script] // 64411 - Blessing of Ancient Kings (Val'anyr, Hammer of Ancient Kings) - class spell_item_blessing_of_ancient_kings : SpellScriptLoader + class spell_item_blessing_of_ancient_kings : AuraScript { - public spell_item_blessing_of_ancient_kings() : base("spell_item_blessing_of_ancient_kings") { } - - class spell_item_blessing_of_ancient_kings_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ProtectionOfAncientKings); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - return eventInfo.GetProcTarget() != null; - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - HealInfo healInfo = eventInfo.GetHealInfo(); - if (healInfo == null || healInfo.GetHeal() == 0) - return; - - int absorb = (int)MathFunctions.CalculatePct(healInfo.GetHeal(), 15.0f); - AuraEffect protEff = eventInfo.GetProcTarget().GetAuraEffect(SpellIds.ProtectionOfAncientKings, 0, eventInfo.GetActor().GetGUID()); - if (protEff != null) - { - // The shield can grow to a maximum size of 20,000 damage absorbtion - protEff.SetAmount(Math.Min(protEff.GetAmount() + absorb, 20000)); - - // Refresh and return to prevent replacing the aura - protEff.GetBase().RefreshDuration(); - } - else - GetTarget().CastCustomSpell(SpellIds.ProtectionOfAncientKings, SpellValueMod.BasePoint0, absorb, eventInfo.GetProcTarget(), true, null, aurEff); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.ProtectionOfAncientKings); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_item_blessing_of_ancient_kings_AuraScript(); + return eventInfo.GetProcTarget() != null; + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + + HealInfo healInfo = eventInfo.GetHealInfo(); + if (healInfo == null || healInfo.GetHeal() == 0) + return; + + int absorb = (int)MathFunctions.CalculatePct(healInfo.GetHeal(), 15.0f); + AuraEffect protEff = eventInfo.GetProcTarget().GetAuraEffect(SpellIds.ProtectionOfAncientKings, 0, eventInfo.GetActor().GetGUID()); + if (protEff != null) + { + // The shield can grow to a maximum size of 20,000 damage absorbtion + protEff.SetAmount(Math.Min(protEff.GetAmount() + absorb, 20000)); + + // Refresh and return to prevent replacing the aura + protEff.GetBase().RefreshDuration(); + } + else + GetTarget().CastCustomSpell(SpellIds.ProtectionOfAncientKings, SpellValueMod.BasePoint0, absorb, eventInfo.GetProcTarget(), true, null, aurEff); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } [Script] // 71564 - Deadly Precision - class spell_item_deadly_precision : SpellScriptLoader + class spell_item_deadly_precision_charm : AuraScript { - public spell_item_deadly_precision() : base("spell_item_deadly_precision") { } - - class spell_item_deadly_precision_charm_AuraScript : AuraScript + void HandleStackDrop(AuraEffect aurEff, ProcEventInfo eventInfo) { - void HandleStackDrop(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - GetTarget().RemoveAuraFromStack(GetId(), GetTarget().GetGUID()); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleStackDrop, 0, AuraType.ModRating)); - } + PreventDefaultAction(); + GetTarget().RemoveAuraFromStack(GetId(), GetTarget().GetGUID()); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_item_deadly_precision_charm_AuraScript(); + OnEffectProc.Add(new EffectProcHandler(HandleStackDrop, 0, AuraType.ModRating)); } } [Script] // 71563 - Deadly Precision Dummy - class spell_item_deadly_precision_dummy : SpellScriptLoader + class spell_item_deadly_precision_dummy : SpellScript { - public spell_item_deadly_precision_dummy() : base("spell_item_deadly_precision_dummy") { } - - class spell_item_deadly_precision_dummy_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.DeadlyPrecision); - } - - void HandleDummy(uint effIndex) - { - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.DeadlyPrecision); - GetCaster().CastCustomSpell(spellInfo.Id, SpellValueMod.AuraStack, (int)spellInfo.StackAmount, GetCaster(), true); - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.ApplyAura)); - } + return ValidateSpellInfo(SpellIds.DeadlyPrecision); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_item_deadly_precision_dummy_SpellScript(); + SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.DeadlyPrecision); + GetCaster().CastCustomSpell(spellInfo.Id, SpellValueMod.AuraStack, (int)spellInfo.StackAmount, GetCaster(), true); + } + + public override void Register() + { + OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.ApplyAura)); } } @@ -897,9 +787,9 @@ namespace Scripts.Spells.Items // 71562 - Item - Icecrown 25 Heroic Melee Trinket [Script("spell_item_deathbringers_will_normal", SpellIds.StrengthOfTheTaunka, SpellIds.AgilityOfTheVrykul, SpellIds.PowerOfTheTaunka, SpellIds.AimOfTheIronDwarves, SpellIds.SpeedOfTheVrykul)] [Script("spell_item_deathbringers_will_heroic", SpellIds.StrengthOfTheTaunkaHero, SpellIds.AgilityOfTheVrykulHero, SpellIds.PowerOfTheTaunkaHero, SpellIds.AimOfTheIronDwarvesHero, SpellIds.SpeedOfTheVrykulHero)] - class spell_item_deathbringers_will : SpellScriptLoader + class spell_item_deathbringers_will : AuraScript { - public spell_item_deathbringers_will(string scriptName, uint strengthSpellId, uint agilitySpellId, uint apSpellId, uint criticalSpellId, uint hasteSpellId) : base(scriptName) + public spell_item_deathbringers_will(uint strengthSpellId, uint agilitySpellId, uint apSpellId, uint criticalSpellId, uint hasteSpellId) { _strengthSpellId = strengthSpellId; _agilitySpellId = agilitySpellId; @@ -908,26 +798,15 @@ namespace Scripts.Spells.Items _hasteSpellId = hasteSpellId; } - class spell_item_deathbringers_will_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public spell_item_deathbringers_will_AuraScript(uint strengthSpellId, uint agilitySpellId, uint apSpellId, uint criticalSpellId, uint hasteSpellId) - { - _strengthSpellId = strengthSpellId; - _agilitySpellId = agilitySpellId; - _apSpellId = apSpellId; - _criticalSpellId = criticalSpellId; - _hasteSpellId = hasteSpellId; - } + return ValidateSpellInfo(_strengthSpellId, _agilitySpellId, _apSpellId, _criticalSpellId, _hasteSpellId); + } - public override bool Validate(SpellInfo spellInfo) + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + uint[][] triggeredSpells = { - return ValidateSpellInfo(_strengthSpellId, _agilitySpellId, _apSpellId, _criticalSpellId, _hasteSpellId); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - uint[][] triggeredSpells = - { //CLASS_NONE new uint[] { }, //CLASS_WARRIOR @@ -954,31 +833,19 @@ namespace Scripts.Spells.Items new uint[] { _strengthSpellId, _agilitySpellId, _hasteSpellId } }; - PreventDefaultAction(); - Unit caster = eventInfo.GetActor(); - var randomSpells = triggeredSpells[(int)caster.GetClass()]; - if (randomSpells.Empty()) - return; + PreventDefaultAction(); + Unit caster = eventInfo.GetActor(); + var randomSpells = triggeredSpells[(int)caster.GetClass()]; + if (randomSpells.Empty()) + return; - uint spellId = randomSpells.SelectRandom(); - caster.CastSpell(caster, spellId, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } - - uint _strengthSpellId; - uint _agilitySpellId; - uint _apSpellId; - uint _criticalSpellId; - uint _hasteSpellId; + uint spellId = randomSpells.SelectRandom(); + caster.CastSpell(caster, spellId, true); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_item_deathbringers_will_AuraScript(_strengthSpellId, _agilitySpellId, _apSpellId, _criticalSpellId, _hasteSpellId); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } uint _strengthSpellId; @@ -989,43 +856,33 @@ namespace Scripts.Spells.Items } [Script] // 47770 - Roll Dice - class spell_item_decahedral_dwarven_dice : SpellScriptLoader + class spell_item_decahedral_dwarven_dice : SpellScript { - public spell_item_decahedral_dwarven_dice() : base("spell_item_decahedral_dwarven_dice") { } - - class spell_item_decahedral_dwarven_dice_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - if (!CliDB.BroadcastTextStorage.ContainsKey(TextIds.DecahedralDwarvenDice)) - return false; - return true; - } - - public override bool Load() - { - return GetCaster().GetTypeId() == TypeId.Player; - } - - void HandleScript(uint effIndex) - { - GetCaster().TextEmote(TextIds.DecahedralDwarvenDice, GetHitUnit()); - - uint minimum = 1; - uint maximum = 100; - - GetCaster().ToPlayer().DoRandomRoll(minimum, maximum); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } + if (!CliDB.BroadcastTextStorage.ContainsKey(TextIds.DecahedralDwarvenDice)) + return false; + return true; } - public override SpellScript GetSpellScript() + public override bool Load() { - return new spell_item_decahedral_dwarven_dice_SpellScript(); + return GetCaster().GetTypeId() == TypeId.Player; + } + + void HandleScript(uint effIndex) + { + GetCaster().TextEmote(TextIds.DecahedralDwarvenDice, GetHitUnit()); + + uint minimum = 1; + uint maximum = 100; + + GetCaster().ToPlayer().DoRandomRoll(minimum, maximum); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } @@ -1035,51 +892,34 @@ namespace Scripts.Spells.Items [Script("spell_item_goblin_jumper_cables", 33, SpellIds.GoblinJumperCablesFail)] [Script("spell_item_goblin_jumper_cables_xl", 50, SpellIds.GoblinJumperCablesXlFail)] [Script("spell_item_gnomish_army_knife", 67, 0)] - class spell_item_defibrillate : SpellScriptLoader + class spell_item_defibrillate : SpellScript { - public spell_item_defibrillate(string name, int chance, int failSpell) : base(name) + public spell_item_defibrillate(uint chance, uint failSpell) { - _chance = (uint)chance; - _failSpell = (uint)failSpell; + _chance = chance; + _failSpell = failSpell; } - class spell_item_defibrillate_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public spell_item_defibrillate_SpellScript(uint chance, uint failSpell) : base() - { - _chance = chance; - _failSpell = failSpell; - } - - public override bool Validate(SpellInfo spellInfo) - { - if (_failSpell != 0 && !ValidateSpellInfo(_failSpell)) - return false; - return true; - } - - void HandleScript(uint effIndex) - { - if (RandomHelper.randChance(_chance)) - { - PreventHitDefaultEffect(effIndex); - if (_failSpell != 0) - GetCaster().CastSpell(GetCaster(), _failSpell, true, GetCastItem()); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.Resurrect)); - } - - uint _chance; - uint _failSpell; + if (_failSpell != 0 && !ValidateSpellInfo(_failSpell)) + return false; + return true; } - public override SpellScript GetSpellScript() + void HandleScript(uint effIndex) { - return new spell_item_defibrillate_SpellScript(_chance, _failSpell); + if (RandomHelper.randChance(_chance)) + { + PreventHitDefaultEffect(effIndex); + if (_failSpell != 0) + GetCaster().CastSpell(GetCaster(), _failSpell, true, GetCastItem()); + } + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.Resurrect)); } uint _chance; @@ -1087,299 +927,219 @@ namespace Scripts.Spells.Items } [Script] // 33896 - Desperate Defense - class spell_item_desperate_defense : SpellScriptLoader + class spell_item_desperate_defense : AuraScript { - public spell_item_desperate_defense() : base("spell_item_desperate_defense") { } - - class spell_item_desperate_defense_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.DesperateRage); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), SpellIds.DesperateRage, true, null, aurEff); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 2, AuraType.PeriodicTriggerSpell)); - } + return ValidateSpellInfo(SpellIds.DesperateRage); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_item_desperate_defense_AuraScript(); + PreventDefaultAction(); + GetTarget().CastSpell(GetTarget(), SpellIds.DesperateRage, true, null, aurEff); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 2, AuraType.PeriodicTriggerSpell)); } } // http://www.wowhead.com/item=6522 Deviate Fish [Script] // 8063 Deviate Fish - class spell_item_deviate_fish : SpellScriptLoader + class spell_item_deviate_fish : SpellScript { - public spell_item_deviate_fish() : base("spell_item_deviate_fish") { } - - class spell_item_deviate_fish_SpellScript : SpellScript + public override bool Load() { - public override bool Load() - { - return GetCaster().GetTypeId() == TypeId.Player; - } - - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.Sleepy, SpellIds.Invigorate, SpellIds.Shrink, SpellIds.PartyTime, SpellIds.HealthySpirit); - } - - void HandleDummy(uint effIndex) - { - Unit caster = GetCaster(); - uint spellId = RandomHelper.URand(SpellIds.Sleepy, SpellIds.HealthySpirit); - caster.CastSpell(caster, spellId, true, null); - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return GetCaster().GetTypeId() == TypeId.Player; } - public override SpellScript GetSpellScript() + public override bool Validate(SpellInfo spellInfo) { - return new spell_item_deviate_fish_SpellScript(); + return ValidateSpellInfo(SpellIds.Sleepy, SpellIds.Invigorate, SpellIds.Shrink, SpellIds.PartyTime, SpellIds.HealthySpirit); + } + + void HandleDummy(uint effIndex) + { + Unit caster = GetCaster(); + uint spellId = RandomHelper.URand(SpellIds.Sleepy, SpellIds.HealthySpirit); + caster.CastSpell(caster, spellId, true, null); + } + + public override void Register() + { + OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 59915 - Discerning Eye of the Beast Dummy - class spell_item_discerning_eye_beast_dummy : SpellScriptLoader + class spell_item_discerning_eye_beast_dummy : AuraScript { - public spell_item_discerning_eye_beast_dummy() : base("spell_item_discerning_eye_beast_dummy") { } - - class spell_item_discerning_eye_beast_dummy_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.DiscerningEyeBeast); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - eventInfo.GetActor().CastSpell((Unit)null, SpellIds.DiscerningEyeBeast, true, null, aurEff); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.DiscerningEyeBeast); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_item_discerning_eye_beast_dummy_AuraScript(); + PreventDefaultAction(); + eventInfo.GetActor().CastSpell((Unit)null, SpellIds.DiscerningEyeBeast, true, null, aurEff); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } [Script] // 71610, 71641 - Echoes of Light (Althor's Abacus) - class spell_item_echoes_of_light : SpellScriptLoader + class spell_item_echoes_of_light : SpellScript { - public spell_item_echoes_of_light() : base("spell_item_echoes_of_light") { } - - class spell_item_echoes_of_light_SpellScript : SpellScript + void FilterTargets(List targets) { - void FilterTargets(List targets) - { - if (targets.Count < 2) - return; + if (targets.Count < 2) + return; - targets.Sort(new HealthPctOrderPred()); + targets.Sort(new HealthPctOrderPred()); - WorldObject target = targets.FirstOrDefault(); - targets.Clear(); - targets.Add(target); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaAlly)); - } + WorldObject target = targets.FirstOrDefault(); + targets.Clear(); + targets.Add(target); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_item_echoes_of_light_SpellScript(); + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaAlly)); } } [Script] // 7434 - Fate Rune of Unsurpassed Vigor - class spell_item_fate_rune_of_unsurpassed_vigor : SpellScriptLoader + class spell_item_fate_rune_of_unsurpassed_vigor : AuraScript { - public spell_item_fate_rune_of_unsurpassed_vigor() : base("spell_item_fate_rune_of_unsurpassed_vigor") { } - - class spell_item_fate_rune_of_unsurpassed_vigor_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.UnsurpassedVigor); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), SpellIds.UnsurpassedVigor, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.UnsurpassedVigor); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_item_fate_rune_of_unsurpassed_vigor_AuraScript(); + PreventDefaultAction(); + GetTarget().CastSpell(GetTarget(), SpellIds.UnsurpassedVigor, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } // http://www.wowhead.com/item=47499 Flask of the North [Script] // 67019 Flask of the North - class spell_item_flask_of_the_north : SpellScriptLoader + class spell_item_flask_of_the_north : SpellScript { - public spell_item_flask_of_the_north() : base("spell_item_flask_of_the_north") { } - - class spell_item_flask_of_the_north_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.FlaskOfTheNorthSp, SpellIds.FlaskOfTheNorthAp, SpellIds.FlaskOfTheNorthStr); - } - - void HandleDummy(uint effIndex) - { - Unit caster = GetCaster(); - List possibleSpells = new List(); - switch (caster.GetClass()) - { - case Class.Warlock: - case Class.Mage: - case Class.Priest: - possibleSpells.Add(SpellIds.FlaskOfTheNorthSp); - break; - case Class.Deathknight: - case Class.Warrior: - possibleSpells.Add(SpellIds.FlaskOfTheNorthStr); - break; - case Class.Rogue: - case Class.Hunter: - possibleSpells.Add(SpellIds.FlaskOfTheNorthAp); - break; - case Class.Druid: - case Class.Paladin: - possibleSpells.Add(SpellIds.FlaskOfTheNorthSp); - possibleSpells.Add(SpellIds.FlaskOfTheNorthStr); - break; - case Class.Shaman: - possibleSpells.Add(SpellIds.FlaskOfTheNorthSp); - possibleSpells.Add(SpellIds.FlaskOfTheNorthAp); - break; - } - - if (possibleSpells.Empty()) - { - Log.outWarn(LogFilter.Spells, "Missing spells for class {0} in script spell_item_flask_of_the_north", caster.GetClass()); - return; - } - - caster.CastSpell(caster, possibleSpells.SelectRandom(), true); - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellIds.FlaskOfTheNorthSp, SpellIds.FlaskOfTheNorthAp, SpellIds.FlaskOfTheNorthStr); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_item_flask_of_the_north_SpellScript(); + Unit caster = GetCaster(); + List possibleSpells = new List(); + switch (caster.GetClass()) + { + case Class.Warlock: + case Class.Mage: + case Class.Priest: + possibleSpells.Add(SpellIds.FlaskOfTheNorthSp); + break; + case Class.Deathknight: + case Class.Warrior: + possibleSpells.Add(SpellIds.FlaskOfTheNorthStr); + break; + case Class.Rogue: + case Class.Hunter: + possibleSpells.Add(SpellIds.FlaskOfTheNorthAp); + break; + case Class.Druid: + case Class.Paladin: + possibleSpells.Add(SpellIds.FlaskOfTheNorthSp); + possibleSpells.Add(SpellIds.FlaskOfTheNorthStr); + break; + case Class.Shaman: + possibleSpells.Add(SpellIds.FlaskOfTheNorthSp); + possibleSpells.Add(SpellIds.FlaskOfTheNorthAp); + break; + } + + if (possibleSpells.Empty()) + { + Log.outWarn(LogFilter.Spells, "Missing spells for class {0} in script spell_item_flask_of_the_north", caster.GetClass()); + return; + } + + caster.CastSpell(caster, possibleSpells.SelectRandom(), true); + } + + public override void Register() + { + OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } // 39372 - Frozen Shadoweave [Script] // Frozen Shadoweave set 3p bonus - class spell_item_frozen_shadoweave : SpellScriptLoader + class spell_item_frozen_shadoweave : AuraScript { - public spell_item_frozen_shadoweave() : base("spell_item_frozen_shadoweave") { } - - class spell_item_frozen_shadoweave_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.Shadowmend); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - DamageInfo damageInfo = eventInfo.GetDamageInfo(); - if (damageInfo == null || damageInfo.GetDamage() == 0) - return; - - int amount = (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount()); - Unit caster = eventInfo.GetActor(); - caster.CastCustomSpell(SpellIds.Shadowmend, SpellValueMod.BasePoint0, amount, (Unit)null, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.Shadowmend); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_item_frozen_shadoweave_AuraScript(); + PreventDefaultAction(); + DamageInfo damageInfo = eventInfo.GetDamageInfo(); + if (damageInfo == null || damageInfo.GetDamage() == 0) + return; + + int amount = (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount()); + Unit caster = eventInfo.GetActor(); + caster.CastCustomSpell(SpellIds.Shadowmend, SpellValueMod.BasePoint0, amount, (Unit)null, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } // http://www.wowhead.com/item=10645 Gnomish Death Ray [Script] // 13280 Gnomish Death Ray - class spell_item_gnomish_death_ray : SpellScriptLoader + class spell_item_gnomish_death_ray : SpellScript { - public spell_item_gnomish_death_ray() : base("spell_item_gnomish_death_ray") { } - - class spell_item_gnomish_death_ray_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.GnomishDeathRaySelf, SpellIds.GnomishDeathRayTarget); - } + return ValidateSpellInfo(SpellIds.GnomishDeathRaySelf, SpellIds.GnomishDeathRayTarget); + } - void HandleDummy(uint effIndex) + void HandleDummy(uint effIndex) + { + Unit caster = GetCaster(); + Unit target = GetHitUnit(); + if (target) { - Unit caster = GetCaster(); - Unit target = GetHitUnit(); - if (target) - { - if (RandomHelper.URand(0, 99) < 15) - caster.CastSpell(caster, SpellIds.GnomishDeathRaySelf, true, null); // failure - else - caster.CastSpell(target, SpellIds.GnomishDeathRayTarget, true, null); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + if (RandomHelper.URand(0, 99) < 15) + caster.CastSpell(caster, SpellIds.GnomishDeathRaySelf, true, null); // failure + else + caster.CastSpell(target, SpellIds.GnomishDeathRayTarget, true, null); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_item_gnomish_death_ray_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -1390,9 +1150,9 @@ namespace Scripts.Spells.Items // 71892 - Item - Icecrown 25 Heroic Dagger Proc [Script("spell_item_heartpierce", SpellIds.InvigorationEnergy, SpellIds.InvigorationMana, SpellIds.InvigorationRage, SpellIds.InvigorationRp)] [Script("spell_item_heartpierce_hero", SpellIds.InvigorationEnergyHero, SpellIds.InvigorationManaHero, SpellIds.InvigorationRageHero, SpellIds.InvigorationRpHero)] - class spell_item_heartpierce : SpellScriptLoader + class spell_item_heartpierce : AuraScript { - public spell_item_heartpierce(string scriptName, uint energySpellId, uint manaSpellId, uint rageSpellId, uint rpSpellId) : base(scriptName) + public spell_item_heartpierce(uint energySpellId, uint manaSpellId, uint rageSpellId, uint rpSpellId) { _energySpellId = energySpellId; _manaSpellId = manaSpellId; @@ -1400,62 +1160,41 @@ namespace Scripts.Spells.Items _rpSpellId = rpSpellId; } - class spell_item_heartpierce_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public spell_item_heartpierce_AuraScript(uint energySpellId, uint manaSpellId, uint rageSpellId, uint rpSpellId) - { - _energySpellId = energySpellId; - _manaSpellId = manaSpellId; - _rageSpellId = rageSpellId; - _rpSpellId = rpSpellId; - } - - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(_energySpellId, _manaSpellId, _rageSpellId, _rpSpellId); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - Unit caster = eventInfo.GetActor(); - - uint spellId; - switch (caster.getPowerType()) - { - case PowerType.Mana: - spellId = _manaSpellId; - break; - case PowerType.Energy: - spellId = _energySpellId; - break; - case PowerType.Rage: - spellId = _rageSpellId; - break; - case PowerType.RunicPower: - spellId = _rpSpellId; - break; - default: - return; - } - - caster.CastSpell((Unit)null, spellId, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } - - uint _energySpellId; - uint _manaSpellId; - uint _rageSpellId; - uint _rpSpellId; + return ValidateSpellInfo(_energySpellId, _manaSpellId, _rageSpellId, _rpSpellId); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_item_heartpierce_AuraScript(_energySpellId, _manaSpellId, _rageSpellId, _rpSpellId); + PreventDefaultAction(); + Unit caster = eventInfo.GetActor(); + + uint spellId; + switch (caster.getPowerType()) + { + case PowerType.Mana: + spellId = _manaSpellId; + break; + case PowerType.Energy: + spellId = _energySpellId; + break; + case PowerType.Rage: + spellId = _rageSpellId; + break; + case PowerType.RunicPower: + spellId = _rpSpellId; + break; + default: + return; + } + + caster.CastSpell((Unit)null, spellId, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } uint _energySpellId; @@ -1465,1982 +1204,1482 @@ namespace Scripts.Spells.Items } [Script] // 40971 - Bonus Healing (Crystal Spire of Karabor) - class spell_item_crystal_spire_of_karabor : SpellScriptLoader + class spell_item_crystal_spire_of_karabor : AuraScript { - public spell_item_crystal_spire_of_karabor() : base("spell_item_crystal_spire_of_karabor") { } - - class spell_item_crystal_spire_of_karabor_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return spellInfo.GetEffect(0) != null; - } - - bool CheckProc(ProcEventInfo eventInfo) - { - int pct = GetSpellInfo().GetEffect(0).CalcValue(); - HealInfo healInfo = eventInfo.GetHealInfo(); - if (healInfo != null) - { - Unit healTarget = healInfo.GetTarget(); - if (healTarget) - if (healTarget.GetHealth() - healInfo.GetEffectiveHeal() <= healTarget.CountPctFromMaxHealth(pct)) - return true; - } - - return false; - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - } + return spellInfo.GetEffect(0) != null; } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_item_crystal_spire_of_karabor_AuraScript(); + int pct = GetSpellInfo().GetEffect(0).CalcValue(); + HealInfo healInfo = eventInfo.GetHealInfo(); + if (healInfo != null) + { + Unit healTarget = healInfo.GetTarget(); + if (healTarget) + if (healTarget.GetHealth() - healInfo.GetEffectiveHeal() <= healTarget.CountPctFromMaxHealth(pct)) + return true; + } + + return false; + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); } } // http://www.wowhead.com/item=27388 Mr. Pinchy [Script] // 33060 Make a Wish - class spell_item_make_a_wish : SpellScriptLoader + class spell_item_make_a_wish : SpellScript { - public spell_item_make_a_wish() : base("spell_item_make_a_wish") { } - - class spell_item_make_a_wish_SpellScript : SpellScript + public override bool Load() { - public override bool Load() - { - return GetCaster().GetTypeId() == TypeId.Player; - } - - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.MrPinchysBlessing, SpellIds.SummonMightyMrPinchy, SpellIds.SummonFuriousMrPinchy, SpellIds.TinyMagicalCrawdad, SpellIds.MrPinchysGift); - } - - void HandleDummy(uint effIndex) - { - Unit caster = GetCaster(); - uint spellId = SpellIds.MrPinchysGift; - switch (RandomHelper.URand(1, 5)) - { - case 1: - spellId = SpellIds.MrPinchysBlessing; - break; - case 2: - spellId = SpellIds.SummonMightyMrPinchy; - break; - case 3: - spellId = SpellIds.SummonFuriousMrPinchy; - break; - case 4: - spellId = SpellIds.TinyMagicalCrawdad; - break; - } - caster.CastSpell(caster, spellId, true, null); - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return GetCaster().GetTypeId() == TypeId.Player; } - public override SpellScript GetSpellScript() + public override bool Validate(SpellInfo spellInfo) { - return new spell_item_make_a_wish_SpellScript(); + return ValidateSpellInfo(SpellIds.MrPinchysBlessing, SpellIds.SummonMightyMrPinchy, SpellIds.SummonFuriousMrPinchy, SpellIds.TinyMagicalCrawdad, SpellIds.MrPinchysGift); + } + + void HandleDummy(uint effIndex) + { + Unit caster = GetCaster(); + uint spellId = SpellIds.MrPinchysGift; + switch (RandomHelper.URand(1, 5)) + { + case 1: + spellId = SpellIds.MrPinchysBlessing; + break; + case 2: + spellId = SpellIds.SummonMightyMrPinchy; + break; + case 3: + spellId = SpellIds.SummonFuriousMrPinchy; + break; + case 4: + spellId = SpellIds.TinyMagicalCrawdad; + break; + } + caster.CastSpell(caster, spellId, true, null); + } + + public override void Register() + { + OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } // Item - 27920: Mark of Conquest // Item - 27921: Mark of Conquest [Script] // 33510 - Health Restore - class spell_item_mark_of_conquest : SpellScriptLoader + class spell_item_mark_of_conquest : AuraScript { - public spell_item_mark_of_conquest() : base("spell_item_mark_of_conquest") { } - - class spell_item_mark_of_conquest_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.MarkOfConquestEnergize); - } + return ValidateSpellInfo(SpellIds.MarkOfConquestEnergize); + } - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + if (eventInfo.GetTypeMask().HasAnyFlag(ProcFlags.DoneRangedAutoAttack | ProcFlags.DoneSpellRangedDmgClass)) { - if (eventInfo.GetTypeMask().HasAnyFlag(ProcFlags.DoneRangedAutoAttack | ProcFlags.DoneSpellRangedDmgClass)) - { - // in that case, do not cast heal spell - PreventDefaultAction(); - // but mana instead - eventInfo.GetActor().CastSpell((Unit)null, SpellIds.MarkOfConquestEnergize, true); - } - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.PeriodicTriggerSpell)); + // in that case, do not cast heal spell + PreventDefaultAction(); + // but mana instead + eventInfo.GetActor().CastSpell((Unit)null, SpellIds.MarkOfConquestEnergize, true); } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_item_mark_of_conquest_AuraScript(); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.PeriodicTriggerSpell)); } } // http://www.wowhead.com/item=32686 Mingo's Fortune Giblets [Script] // 40802 Mingo's Fortune Generator - class spell_item_mingos_fortune_generator : SpellScriptLoader + class spell_item_mingos_fortune_generator : SpellScript { - public spell_item_mingos_fortune_generator() : base("spell_item_mingos_fortune_generator") { } - - class spell_item_mingos_fortune_generator_SpellScript : SpellScript + void HandleDummy(uint effIndex) { - void HandleDummy(uint effIndex) + // Selecting one from Bloodstained Fortune item + uint newitemid; + switch (RandomHelper.URand(1, 20)) { - // Selecting one from Bloodstained Fortune item - uint newitemid; - switch (RandomHelper.URand(1, 20)) - { - case 1: newitemid = 32688; break; - case 2: newitemid = 32689; break; - case 3: newitemid = 32690; break; - case 4: newitemid = 32691; break; - case 5: newitemid = 32692; break; - case 6: newitemid = 32693; break; - case 7: newitemid = 32700; break; - case 8: newitemid = 32701; break; - case 9: newitemid = 32702; break; - case 10: newitemid = 32703; break; - case 11: newitemid = 32704; break; - case 12: newitemid = 32705; break; - case 13: newitemid = 32706; break; - case 14: newitemid = 32707; break; - case 15: newitemid = 32708; break; - case 16: newitemid = 32709; break; - case 17: newitemid = 32710; break; - case 18: newitemid = 32711; break; - case 19: newitemid = 32712; break; - case 20: newitemid = 32713; break; - default: - return; - } - - CreateItem(effIndex, newitemid); + case 1: newitemid = 32688; break; + case 2: newitemid = 32689; break; + case 3: newitemid = 32690; break; + case 4: newitemid = 32691; break; + case 5: newitemid = 32692; break; + case 6: newitemid = 32693; break; + case 7: newitemid = 32700; break; + case 8: newitemid = 32701; break; + case 9: newitemid = 32702; break; + case 10: newitemid = 32703; break; + case 11: newitemid = 32704; break; + case 12: newitemid = 32705; break; + case 13: newitemid = 32706; break; + case 14: newitemid = 32707; break; + case 15: newitemid = 32708; break; + case 16: newitemid = 32709; break; + case 17: newitemid = 32710; break; + case 18: newitemid = 32711; break; + case 19: newitemid = 32712; break; + case 20: newitemid = 32713; break; + default: + return; } - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + CreateItem(effIndex, newitemid); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_item_mingos_fortune_generator_SpellScript(); + OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 71875, 71877 - Item - Black Bruise: Necrotic Touch Proc - class spell_item_necrotic_touch : SpellScriptLoader + class spell_item_necrotic_touch : AuraScript { - public spell_item_necrotic_touch() : base("spell_item_necrotic_touch") { } - - class spell_item_necrotic_touch_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ItemNecroticTouchProc); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - return eventInfo.GetProcTarget() && eventInfo.GetProcTarget().IsAlive(); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - int bp = (int)MathFunctions.CalculatePct(eventInfo.GetDamageInfo().GetDamage(), aurEff.GetAmount()); - GetTarget().CastCustomSpell(SpellIds.ItemNecroticTouchProc, SpellValueMod.BasePoint0, bp, eventInfo.GetProcTarget(), true, null, aurEff); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.ItemNecroticTouchProc); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_item_necrotic_touch_AuraScript(); + return eventInfo.GetProcTarget() && eventInfo.GetProcTarget().IsAlive(); + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + int bp = (int)MathFunctions.CalculatePct(eventInfo.GetDamageInfo().GetDamage(), aurEff.GetAmount()); + GetTarget().CastCustomSpell(SpellIds.ItemNecroticTouchProc, SpellValueMod.BasePoint0, bp, eventInfo.GetProcTarget(), true, null, aurEff); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } // http://www.wowhead.com/item=10720 Gnomish Net-o-Matic Projector [Script] // 13120 Net-o-Matic - class spell_item_net_o_matic : SpellScriptLoader + class spell_item_net_o_matic : SpellScript { - public spell_item_net_o_matic() : base("spell_item_net_o_matic") { } - - class spell_item_net_o_matic_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.NetOMaticTriggered1, SpellIds.NetOMaticTriggered2, SpellIds.NetOMaticTriggered3); - } + return ValidateSpellInfo(SpellIds.NetOMaticTriggered1, SpellIds.NetOMaticTriggered2, SpellIds.NetOMaticTriggered3); + } - void HandleDummy(uint effIndex) + void HandleDummy(uint effIndex) + { + Unit target = GetHitUnit(); + if (target) { - Unit target = GetHitUnit(); - if (target) - { - uint spellId = SpellIds.NetOMaticTriggered3; - uint roll = RandomHelper.URand(0, 99); - if (roll < 2) // 2% for 30 sec self root (off-like chance unknown) - spellId = SpellIds.NetOMaticTriggered1; - else if (roll < 4) // 2% for 20 sec root, charge to target (off-like chance unknown) - spellId = SpellIds.NetOMaticTriggered2; + uint spellId = SpellIds.NetOMaticTriggered3; + uint roll = RandomHelper.URand(0, 99); + if (roll < 2) // 2% for 30 sec self root (off-like chance unknown) + spellId = SpellIds.NetOMaticTriggered1; + else if (roll < 4) // 2% for 20 sec root, charge to target (off-like chance unknown) + spellId = SpellIds.NetOMaticTriggered2; - GetCaster().CastSpell(target, spellId, true, null); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + GetCaster().CastSpell(target, spellId, true, null); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_item_net_o_matic_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } // http://www.wowhead.com/item=8529 Noggenfogger Elixir [Script] // 16589 Noggenfogger Elixir - class spell_item_noggenfogger_elixir : SpellScriptLoader + class spell_item_noggenfogger_elixir : SpellScript { - public spell_item_noggenfogger_elixir() : base("spell_item_noggenfogger_elixir") { } - - class spell_item_noggenfogger_elixir_SpellScript : SpellScript + public override bool Load() { - public override bool Load() - { - return GetCaster().GetTypeId() == TypeId.Player; - } - - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.NoggenfoggerElixirTriggered1, SpellIds.NoggenfoggerElixirTriggered2, SpellIds.NoggenfoggerElixirTriggered3); - } - - void HandleDummy(uint effIndex) - { - Unit caster = GetCaster(); - uint spellId = SpellIds.NoggenfoggerElixirTriggered3; - switch (RandomHelper.URand(1, 3)) - { - case 1: - spellId = SpellIds.NoggenfoggerElixirTriggered1; - break; - case 2: - spellId = SpellIds.NoggenfoggerElixirTriggered2; - break; - } - - caster.CastSpell(caster, spellId, true, null); - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return GetCaster().GetTypeId() == TypeId.Player; } - public override SpellScript GetSpellScript() + public override bool Validate(SpellInfo spellInfo) { - return new spell_item_noggenfogger_elixir_SpellScript(); + return ValidateSpellInfo(SpellIds.NoggenfoggerElixirTriggered1, SpellIds.NoggenfoggerElixirTriggered2, SpellIds.NoggenfoggerElixirTriggered3); + } + + void HandleDummy(uint effIndex) + { + Unit caster = GetCaster(); + uint spellId = SpellIds.NoggenfoggerElixirTriggered3; + switch (RandomHelper.URand(1, 3)) + { + case 1: + spellId = SpellIds.NoggenfoggerElixirTriggered1; + break; + case 2: + spellId = SpellIds.NoggenfoggerElixirTriggered2; + break; + } + + caster.CastSpell(caster, spellId, true, null); + } + + public override void Register() + { + OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 29601 - Enlightenment (Pendant of the Violet Eye) - class spell_item_pendant_of_the_violet_eye : SpellScriptLoader + class spell_item_pendant_of_the_violet_eye : AuraScript { - public spell_item_pendant_of_the_violet_eye() : base("spell_item_pendant_of_the_violet_eye") { } - - class spell_item_pendant_of_the_violet_eye_AuraScript : AuraScript + bool CheckProc(ProcEventInfo eventInfo) { - bool CheckProc(ProcEventInfo eventInfo) + SpellInfo spellInfo = eventInfo.GetSpellInfo(); + if (spellInfo != null) { - SpellInfo spellInfo = eventInfo.GetSpellInfo(); - if (spellInfo != null) - { - var costs = spellInfo.CalcPowerCost(GetTarget(), spellInfo.GetSchoolMask()); - var m = costs.FirstOrDefault(cost => { return cost.Power == PowerType.Mana && cost.Amount > 0; }); - if (m != null) - return true; - } - - return false; + var costs = spellInfo.CalcPowerCost(GetTarget(), spellInfo.GetSchoolMask()); + var m = costs.FirstOrDefault(cost => { return cost.Power == PowerType.Mana && cost.Amount > 0; }); + if (m != null) + return true; } - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - } + return false; } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_item_pendant_of_the_violet_eye_AuraScript(); + DoCheckProc.Add(new CheckProcHandler(CheckProc)); } } [Script] // 26467 - Persistent Shield - class spell_item_persistent_shield : SpellScriptLoader + class spell_item_persistent_shield : AuraScript { - public spell_item_persistent_shield() : base("spell_item_persistent_shield") { } - - class spell_item_persistent_shield_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.PersistentShieldTriggered); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - return eventInfo.GetHealInfo() != null && eventInfo.GetHealInfo().GetHeal() != 0; - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - Unit caster = eventInfo.GetActor(); - Unit target = eventInfo.GetProcTarget(); - int bp0 = (int)MathFunctions.CalculatePct(eventInfo.GetHealInfo().GetHeal(), 15); - - // Scarab Brooch does not replace stronger shields - AuraEffect shield = target.GetAuraEffect(SpellIds.PersistentShieldTriggered, 0, caster.GetGUID()); - if (shield != null) - if (shield.GetAmount() > bp0) - return; - - caster.CastCustomSpell(SpellIds.PersistentShieldTriggered, SpellValueMod.BasePoint0, bp0, target, true, null, aurEff); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.PeriodicTriggerSpell)); - } + return ValidateSpellInfo(SpellIds.PersistentShieldTriggered); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_item_persistent_shield_AuraScript(); + return eventInfo.GetHealInfo() != null && eventInfo.GetHealInfo().GetHeal() != 0; + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + Unit caster = eventInfo.GetActor(); + Unit target = eventInfo.GetProcTarget(); + int bp0 = (int)MathFunctions.CalculatePct(eventInfo.GetHealInfo().GetHeal(), 15); + + // Scarab Brooch does not replace stronger shields + AuraEffect shield = target.GetAuraEffect(SpellIds.PersistentShieldTriggered, 0, caster.GetGUID()); + if (shield != null) + if (shield.GetAmount() > bp0) + return; + + caster.CastCustomSpell(SpellIds.PersistentShieldTriggered, SpellValueMod.BasePoint0, bp0, target, true, null, aurEff); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.PeriodicTriggerSpell)); } } // 37381 - Pet Healing // Hunter T5 2P Bonus [Script] // Warlock T5 2P Bonus - class spell_item_pet_healing : SpellScriptLoader + class spell_item_pet_healing : AuraScript { - public spell_item_pet_healing() : base("spell_item_pet_healing") { } - - class spell_item_pet_healing_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.HealthLink); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - DamageInfo damageInfo = eventInfo.GetDamageInfo(); - if (damageInfo == null || damageInfo.GetDamage() == 0) - return; - - int bp = (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount()); - Unit caster = eventInfo.GetActor(); - caster.CastCustomSpell(SpellIds.HealthLink, SpellValueMod.BasePoint0, bp, (Unit)null, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.HealthLink); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_item_pet_healing_AuraScript(); + PreventDefaultAction(); + DamageInfo damageInfo = eventInfo.GetDamageInfo(); + if (damageInfo == null || damageInfo.GetDamage() == 0) + return; + + int bp = (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount()); + Unit caster = eventInfo.GetActor(); + caster.CastCustomSpell(SpellIds.HealthLink, SpellValueMod.BasePoint0, bp, (Unit)null, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } [Script] // 17512 - Piccolo of the Flaming Fire - class spell_item_piccolo_of_the_flaming_fire : SpellScriptLoader + class spell_item_piccolo_of_the_flaming_fire : SpellScript { - public spell_item_piccolo_of_the_flaming_fire() : base("spell_item_piccolo_of_the_flaming_fire") { } - - class spell_item_piccolo_of_the_flaming_fire_SpellScript : SpellScript + void HandleScript(uint effIndex) { - void HandleScript(uint effIndex) - { - PreventHitDefaultEffect(effIndex); - Player target = GetHitPlayer(); - if (target) - target.HandleEmoteCommand(Emote.StateDance); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } + PreventHitDefaultEffect(effIndex); + Player target = GetHitPlayer(); + if (target) + target.HandleEmoteCommand(Emote.StateDance); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_item_piccolo_of_the_flaming_fire_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } // http://www.wowhead.com/item=6657 Savory Deviate Delight [Script] // 8213 Savory Deviate Delight - class spell_item_savory_deviate_delight : SpellScriptLoader + class spell_item_savory_deviate_delight : SpellScript { - public spell_item_savory_deviate_delight() : base("spell_item_savory_deviate_delight") { } - - class spell_item_savory_deviate_delight_SpellScript : SpellScript + public override bool Load() { - public override bool Load() - { - return GetCaster().GetTypeId() == TypeId.Player; - } - - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.FlipOutMale, SpellIds.FlipOutFemale, SpellIds.YaaarrrrMale, SpellIds.YaaarrrrFemale); - } - - void HandleDummy(uint effIndex) - { - Unit caster = GetCaster(); - uint spellId = 0; - switch (RandomHelper.URand(1, 2)) - { - // Flip Out - ninja - case 1: spellId = (caster.GetGender() == Gender.Male ? SpellIds.FlipOutMale : SpellIds.FlipOutFemale); break; - // Yaaarrrr - pirate - case 2: spellId = (caster.GetGender() == Gender.Male ? SpellIds.YaaarrrrMale : SpellIds.YaaarrrrFemale); break; - } - caster.CastSpell(caster, spellId, true, null); - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return GetCaster().GetTypeId() == TypeId.Player; } - public override SpellScript GetSpellScript() + public override bool Validate(SpellInfo spellInfo) { - return new spell_item_savory_deviate_delight_SpellScript(); + return ValidateSpellInfo(SpellIds.FlipOutMale, SpellIds.FlipOutFemale, SpellIds.YaaarrrrMale, SpellIds.YaaarrrrFemale); + } + + void HandleDummy(uint effIndex) + { + Unit caster = GetCaster(); + uint spellId = 0; + switch (RandomHelper.URand(1, 2)) + { + // Flip Out - ninja + case 1: spellId = (caster.GetGender() == Gender.Male ? SpellIds.FlipOutMale : SpellIds.FlipOutFemale); break; + // Yaaarrrr - pirate + case 2: spellId = (caster.GetGender() == Gender.Male ? SpellIds.YaaarrrrMale : SpellIds.YaaarrrrFemale); break; + } + caster.CastSpell(caster, spellId, true, null); + } + + public override void Register() + { + OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } // 48129 - Scroll of Recall // 60320 - Scroll of Recall II [Script] // 60321 - Scroll of Recall III - class spell_item_scroll_of_recall : SpellScriptLoader + class spell_item_scroll_of_recall : SpellScript { - public spell_item_scroll_of_recall() : base("spell_item_scroll_of_recall") { } - - class spell_item_scroll_of_recall_SpellScript : SpellScript + public override bool Load() { - public override bool Load() + return GetCaster().GetTypeId() == TypeId.Player; + } + + void HandleScript(uint effIndex) + { + Unit caster = GetCaster(); + byte maxSafeLevel = 0; + switch (GetSpellInfo().Id) { - return GetCaster().GetTypeId() == TypeId.Player; + case SpellIds.ScrollOfRecallI: // Scroll of Recall + maxSafeLevel = 40; + break; + case SpellIds.ScrollOfRecallII: // Scroll of Recall II + maxSafeLevel = 70; + break; + case SpellIds.ScrollOfRecallIII: // Scroll of Recal III + maxSafeLevel = 80; + break; + default: + break; } - void HandleScript(uint effIndex) + if (caster.getLevel() > maxSafeLevel) { - Unit caster = GetCaster(); - byte maxSafeLevel = 0; - switch (GetSpellInfo().Id) - { - case SpellIds.ScrollOfRecallI: // Scroll of Recall - maxSafeLevel = 40; - break; - case SpellIds.ScrollOfRecallII: // Scroll of Recall II - maxSafeLevel = 70; - break; - case SpellIds.ScrollOfRecallIII: // Scroll of Recal III - maxSafeLevel = 80; - break; - default: - break; - } + caster.CastSpell(caster, SpellIds.Lost, true); - if (caster.getLevel() > maxSafeLevel) - { - caster.CastSpell(caster, SpellIds.Lost, true); + // ALLIANCE from 60323 to 60330 - HORDE from 60328 to 60335 + uint spellId = SpellIds.ScrollOfRecallFailAlliance1; + if (GetCaster().ToPlayer().GetTeam() == Team.Horde) + spellId = SpellIds.ScrollOfRecallFailHorde1; - // ALLIANCE from 60323 to 60330 - HORDE from 60328 to 60335 - uint spellId = SpellIds.ScrollOfRecallFailAlliance1; - if (GetCaster().ToPlayer().GetTeam() == Team.Horde) - spellId = SpellIds.ScrollOfRecallFailHorde1; + GetCaster().CastSpell(GetCaster(), spellId + RandomHelper.URand(0, 7), true); - GetCaster().CastSpell(GetCaster(), spellId + RandomHelper.URand(0, 7), true); - - PreventHitDefaultEffect(effIndex); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.TeleportUnits)); + PreventHitDefaultEffect(effIndex); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_item_scroll_of_recall_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.TeleportUnits)); } } [Script] // 71169 - Shadow's Fate (Shadowmourne questline) - class spell_item_unsated_craving : SpellScriptLoader + class spell_item_unsated_craving : AuraScript { - public spell_item_unsated_craving() : base("spell_item_unsated_craving") { } - - class spell_item_unsated_craving_AuraScript : AuraScript + bool CheckProc(ProcEventInfo procInfo) { - bool CheckProc(ProcEventInfo procInfo) - { - Unit caster = procInfo.GetActor(); - if (!caster || caster.GetTypeId() != TypeId.Player) - return false; + Unit caster = procInfo.GetActor(); + if (!caster || caster.GetTypeId() != TypeId.Player) + return false; - Unit target = procInfo.GetActionTarget(); - if (!target || target.GetTypeId() != TypeId.Unit || target.IsCritter() || (target.GetEntry() != CreatureIds.Sindragosa && target.IsSummon())) - return false; + Unit target = procInfo.GetActionTarget(); + if (!target || target.GetTypeId() != TypeId.Unit || target.IsCritter() || (target.GetEntry() != CreatureIds.Sindragosa && target.IsSummon())) + return false; - return true; - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - } + return true; } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_item_unsated_craving_AuraScript(); + DoCheckProc.Add(new CheckProcHandler(CheckProc)); } } [Script] - class spell_item_shadows_fate : SpellScriptLoader + class spell_item_shadows_fate : AuraScript { - public spell_item_shadows_fate() : base("spell_item_shadows_fate") { } - - class spell_item_shadows_fate_AuraScript : AuraScript + void HandleProc(ProcEventInfo procInfo) { - void HandleProc(ProcEventInfo procInfo) - { - Unit caster = procInfo.GetActor(); - Unit target = GetCaster(); - if (!caster || !target) - return; + Unit caster = procInfo.GetActor(); + Unit target = GetCaster(); + if (!caster || !target) + return; - caster.CastSpell(target, SpellIds.SoulFeast, TriggerCastFlags.FullMask); - } - - public override void Register() - { - OnProc.Add(new AuraProcHandler(HandleProc)); - } + caster.CastSpell(target, SpellIds.SoulFeast, TriggerCastFlags.FullMask); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_item_shadows_fate_AuraScript(); + OnProc.Add(new AuraProcHandler(HandleProc)); } } [Script] // 71903 - Item - Shadowmourne Legendary - class spell_item_shadowmourne : SpellScriptLoader + class spell_item_shadowmourne : AuraScript { - public spell_item_shadowmourne() : base("spell_item_shadowmourne") { } - - class spell_item_shadowmourne_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ShadowmourneChaosBaneDamage, SpellIds.ShadowmourneSoulFragment, SpellIds.ShadowmourneChaosBaneBuff); - } + return ValidateSpellInfo(SpellIds.ShadowmourneChaosBaneDamage, SpellIds.ShadowmourneSoulFragment, SpellIds.ShadowmourneChaosBaneBuff); + } - bool CheckProc(ProcEventInfo eventInfo) - { - if (GetTarget().HasAura(SpellIds.ShadowmourneChaosBaneBuff)) // cant collect shards while under effect of Chaos Bane buff - return false; - return eventInfo.GetProcTarget() && eventInfo.GetProcTarget().IsAlive(); - } + bool CheckProc(ProcEventInfo eventInfo) + { + if (GetTarget().HasAura(SpellIds.ShadowmourneChaosBaneBuff)) // cant collect shards while under effect of Chaos Bane buff + return false; + return eventInfo.GetProcTarget() && eventInfo.GetProcTarget().IsAlive(); + } - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), SpellIds.ShadowmourneSoulFragment, true, null, aurEff); + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + GetTarget().CastSpell(GetTarget(), SpellIds.ShadowmourneSoulFragment, true, null, aurEff); - // this can't be handled in AuraScript of SoulFragments because we need to know victim - Aura soulFragments = GetTarget().GetAura(SpellIds.ShadowmourneSoulFragment); - if (soulFragments != null) + // this can't be handled in AuraScript of SoulFragments because we need to know victim + Aura soulFragments = GetTarget().GetAura(SpellIds.ShadowmourneSoulFragment); + if (soulFragments != null) + { + if (soulFragments.GetStackAmount() >= 10) { - if (soulFragments.GetStackAmount() >= 10) - { - GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.ShadowmourneChaosBaneDamage, true, null, aurEff); - soulFragments.Remove(); - } + GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.ShadowmourneChaosBaneDamage, true, null, aurEff); + soulFragments.Remove(); } } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_item_shadowmourne_AuraScript(); + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } [Script] // 71905 - Soul Fragment - class spell_item_shadowmourne_soul_fragment : SpellScriptLoader + class spell_item_shadowmourne_soul_fragment : AuraScript { - public spell_item_shadowmourne_soul_fragment() : base("spell_item_shadowmourne_soul_fragment") { } - - class spell_item_shadowmourne_soul_fragment_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ShadowmourneVisualLow, SpellIds.ShadowmourneVisualHigh, SpellIds.ShadowmourneChaosBaneBuff); - } + return ValidateSpellInfo(SpellIds.ShadowmourneVisualLow, SpellIds.ShadowmourneVisualHigh, SpellIds.ShadowmourneChaosBaneBuff); + } - void OnStackChange(AuraEffect aurEff, AuraEffectHandleModes mode) + void OnStackChange(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit target = GetTarget(); + switch (GetStackAmount()) { - Unit target = GetTarget(); - switch (GetStackAmount()) - { - case 1: - target.CastSpell(target, SpellIds.ShadowmourneVisualLow, true); - break; - case 6: - target.RemoveAurasDueToSpell(SpellIds.ShadowmourneVisualLow); - target.CastSpell(target, SpellIds.ShadowmourneVisualHigh, true); - break; - case 10: - target.RemoveAurasDueToSpell(SpellIds.ShadowmourneVisualHigh); - target.CastSpell(target, SpellIds.ShadowmourneChaosBaneBuff, true); - break; - default: - break; - } - } - - void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Unit target = GetTarget(); - target.RemoveAurasDueToSpell(SpellIds.ShadowmourneVisualLow); - target.RemoveAurasDueToSpell(SpellIds.ShadowmourneVisualHigh); - } - - public override void Register() - { - AfterEffectApply.Add(new EffectApplyHandler(OnStackChange, 0, AuraType.ModStat, AuraEffectHandleModes.Real | AuraEffectHandleModes.Reapply)); - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ModStat, AuraEffectHandleModes.Real)); + case 1: + target.CastSpell(target, SpellIds.ShadowmourneVisualLow, true); + break; + case 6: + target.RemoveAurasDueToSpell(SpellIds.ShadowmourneVisualLow); + target.CastSpell(target, SpellIds.ShadowmourneVisualHigh, true); + break; + case 10: + target.RemoveAurasDueToSpell(SpellIds.ShadowmourneVisualHigh); + target.CastSpell(target, SpellIds.ShadowmourneChaosBaneBuff, true); + break; + default: + break; } } - public override AuraScript GetAuraScript() + void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_item_shadowmourne_soul_fragment_AuraScript(); + Unit target = GetTarget(); + target.RemoveAurasDueToSpell(SpellIds.ShadowmourneVisualLow); + target.RemoveAurasDueToSpell(SpellIds.ShadowmourneVisualHigh); + } + + public override void Register() + { + AfterEffectApply.Add(new EffectApplyHandler(OnStackChange, 0, AuraType.ModStat, AuraEffectHandleModes.Real | AuraEffectHandleModes.Reapply)); + AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ModStat, AuraEffectHandleModes.Real)); } } // http://www.wowhead.com/item=7734 Six Demon Bag [Script] // 14537 Six Demon Bag - class spell_item_six_demon_bag : SpellScriptLoader + class spell_item_six_demon_bag : SpellScript { - public spell_item_six_demon_bag() : base("spell_item_six_demon_bag") { } - - class spell_item_six_demon_bag_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.Frostbolt, SpellIds.Polymorph, SpellIds.SummonFelhoundMinion, SpellIds.Fireball, SpellIds.ChainLightning, SpellIds.EnvelopingWinds); - } + return ValidateSpellInfo(SpellIds.Frostbolt, SpellIds.Polymorph, SpellIds.SummonFelhoundMinion, SpellIds.Fireball, SpellIds.ChainLightning, SpellIds.EnvelopingWinds); + } - void HandleDummy(uint effIndex) + void HandleDummy(uint effIndex) + { + Unit caster = GetCaster(); + Unit target = GetHitUnit(); + if (target) { - Unit caster = GetCaster(); - Unit target = GetHitUnit(); - if (target) + uint spellId = 0; + uint rand = RandomHelper.URand(0, 99); + if (rand < 25) // Fireball (25% chance) + spellId = SpellIds.Fireball; + else if (rand < 50) // Frostball (25% chance) + spellId = SpellIds.Frostbolt; + else if (rand < 70) // Chain Lighting (20% chance) + spellId = SpellIds.ChainLightning; + else if (rand < 80) // Polymorph (10% chance) { - uint spellId = 0; - uint rand = RandomHelper.URand(0, 99); - if (rand < 25) // Fireball (25% chance) - spellId = SpellIds.Fireball; - else if (rand < 50) // Frostball (25% chance) - spellId = SpellIds.Frostbolt; - else if (rand < 70) // Chain Lighting (20% chance) - spellId = SpellIds.ChainLightning; - else if (rand < 80) // Polymorph (10% chance) - { - spellId = SpellIds.Polymorph; - if (RandomHelper.URand(0, 100) <= 30) // 30% chance to self-cast - target = caster; - } - else if (rand < 95) // Enveloping Winds (15% chance) - spellId = SpellIds.EnvelopingWinds; - else // Summon Felhund minion (5% chance) - { - spellId = SpellIds.SummonFelhoundMinion; + spellId = SpellIds.Polymorph; + if (RandomHelper.URand(0, 100) <= 30) // 30% chance to self-cast target = caster; - } - - caster.CastSpell(target, spellId, true, GetCastItem()); } - } + else if (rand < 95) // Enveloping Winds (15% chance) + spellId = SpellIds.EnvelopingWinds; + else // Summon Felhund minion (5% chance) + { + spellId = SpellIds.SummonFelhoundMinion; + target = caster; + } - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + caster.CastSpell(target, spellId, true, GetCastItem()); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_item_six_demon_bag_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 59906 - Swift Hand of Justice Dummy - class spell_item_swift_hand_justice_dummy : SpellScriptLoader + class spell_item_swift_hand_justice_dummy : AuraScript { - public spell_item_swift_hand_justice_dummy() : base("spell_item_swift_hand_justice_dummy") { } - - class spell_item_swift_hand_justice_dummy_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.SwiftHandOfJusticeHeal); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - Unit caster = eventInfo.GetActor(); - int amount = (int)caster.CountPctFromMaxHealth(aurEff.GetAmount()); - caster.CastCustomSpell(SpellIds.SwiftHandOfJusticeHeal, SpellValueMod.BasePoint0, amount, (Unit)null, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.SwiftHandOfJusticeHeal); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_item_swift_hand_justice_dummy_AuraScript(); + PreventDefaultAction(); + + Unit caster = eventInfo.GetActor(); + int amount = (int)caster.CountPctFromMaxHealth(aurEff.GetAmount()); + caster.CastCustomSpell(SpellIds.SwiftHandOfJusticeHeal, SpellValueMod.BasePoint0, amount, (Unit)null, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } [Script] // 28862 - The Eye of Diminution - class spell_item_the_eye_of_diminution : SpellScriptLoader + class spell_item_the_eye_of_diminution : AuraScript { - public spell_item_the_eye_of_diminution() : base("spell_item_the_eye_of_diminution") { } - - class spell_item_the_eye_of_diminution_AuraScript : AuraScript + void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) { - void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) - { - int diff = (int)GetUnitOwner().getLevel() - 60; - if (diff > 0) - amount += diff; - } - - public override void Register() - { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.ModThreat)); - } + int diff = (int)GetUnitOwner().getLevel() - 60; + if (diff > 0) + amount += diff; } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_item_the_eye_of_diminution_AuraScript(); + DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.ModThreat)); } } // http://www.wowhead.com/item=44012 Underbelly Elixir [Script] // 59640 Underbelly Elixir - class spell_item_underbelly_elixir : SpellScriptLoader + class spell_item_underbelly_elixir : SpellScript { - public spell_item_underbelly_elixir() : base("spell_item_underbelly_elixir") { } - - class spell_item_underbelly_elixir_SpellScript : SpellScript + public override bool Load() { - public override bool Load() - { - return GetCaster().GetTypeId() == TypeId.Player; - } - - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.UnderbellyElixirTriggered1, SpellIds.UnderbellyElixirTriggered2, SpellIds.UnderbellyElixirTriggered3); - } - - void HandleDummy(uint effIndex) - { - Unit caster = GetCaster(); - uint spellId = SpellIds.UnderbellyElixirTriggered3; - switch (RandomHelper.URand(1, 3)) - { - case 1: - spellId = SpellIds.UnderbellyElixirTriggered1; - break; - case 2: - spellId = SpellIds.UnderbellyElixirTriggered2; - break; - } - caster.CastSpell(caster, spellId, true, null); - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return GetCaster().GetTypeId() == TypeId.Player; } - public override SpellScript GetSpellScript() + public override bool Validate(SpellInfo spellInfo) { - return new spell_item_underbelly_elixir_SpellScript(); + return ValidateSpellInfo(SpellIds.UnderbellyElixirTriggered1, SpellIds.UnderbellyElixirTriggered2, SpellIds.UnderbellyElixirTriggered3); + } + + void HandleDummy(uint effIndex) + { + Unit caster = GetCaster(); + uint spellId = SpellIds.UnderbellyElixirTriggered3; + switch (RandomHelper.URand(1, 3)) + { + case 1: + spellId = SpellIds.UnderbellyElixirTriggered1; + break; + case 2: + spellId = SpellIds.UnderbellyElixirTriggered2; + break; + } + caster.CastSpell(caster, spellId, true, null); + } + + public override void Register() + { + OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 126755 - Wormhole: Pandaria - class spell_item_wormhole_pandaria : SpellScriptLoader + class spell_item_wormhole_pandaria : SpellScript { - public spell_item_wormhole_pandaria() : base("spell_item_wormhole_pandaria") { } - - class spell_item_wormhole_pandaria_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.WormholeTargetLocations); - } - - void HandleTeleport(uint effIndex) - { - PreventHitDefaultEffect(effIndex); - uint spellId = SpellIds.WormholeTargetLocations.SelectRandom(); - GetCaster().CastSpell(GetHitUnit(), spellId, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleTeleport, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellIds.WormholeTargetLocations); } - public override SpellScript GetSpellScript() + void HandleTeleport(uint effIndex) { - return new spell_item_wormhole_pandaria_SpellScript(); + PreventHitDefaultEffect(effIndex); + uint spellId = SpellIds.WormholeTargetLocations.SelectRandom(); + GetCaster().CastSpell(GetHitUnit(), spellId, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleTeleport, 0, SpellEffectName.Dummy)); } } [Script] // 47776 - Roll 'dem Bones - class spell_item_worn_troll_dice : SpellScriptLoader + class spell_item_worn_troll_dice : SpellScript { - public spell_item_worn_troll_dice() : base("spell_item_worn_troll_dice") { } - - class spell_item_worn_troll_dice_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - if (!CliDB.BroadcastTextStorage.ContainsKey(TextIds.WornTrollDice)) - return false; - return true; - } - - public override bool Load() - { - return GetCaster().GetTypeId() == TypeId.Player; - } - - void HandleScript(uint effIndex) - { - GetCaster().TextEmote(TextIds.WornTrollDice, GetHitUnit()); - - uint minimum = 1; - uint maximum = 6; - - // roll twice - GetCaster().ToPlayer().DoRandomRoll(minimum, maximum); - GetCaster().ToPlayer().DoRandomRoll(minimum, maximum); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } + if (!CliDB.BroadcastTextStorage.ContainsKey(TextIds.WornTrollDice)) + return false; + return true; } - public override SpellScript GetSpellScript() + public override bool Load() { - return new spell_item_worn_troll_dice_SpellScript(); + return GetCaster().GetTypeId() == TypeId.Player; + } + + void HandleScript(uint effIndex) + { + GetCaster().TextEmote(TextIds.WornTrollDice, GetHitUnit()); + + uint minimum = 1; + uint maximum = 6; + + // roll twice + GetCaster().ToPlayer().DoRandomRoll(minimum, maximum); + GetCaster().ToPlayer().DoRandomRoll(minimum, maximum); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] - class spell_item_red_rider_air_rifle : SpellScriptLoader + class spell_item_red_rider_air_rifle : SpellScript { - public spell_item_red_rider_air_rifle() : base("spell_item_red_rider_air_rifle") { } - - class spell_item_red_rider_air_rifle_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.AirRifleHoldVisual, SpellIds.AirRifleShoot, SpellIds.AirRifleShootSelf); - } + return ValidateSpellInfo(SpellIds.AirRifleHoldVisual, SpellIds.AirRifleShoot, SpellIds.AirRifleShootSelf); + } - void HandleScript(uint effIndex) + void HandleScript(uint effIndex) + { + PreventHitDefaultEffect(effIndex); + Unit caster = GetCaster(); + Unit target = GetHitUnit(); + if (target) { - PreventHitDefaultEffect(effIndex); - Unit caster = GetCaster(); - Unit target = GetHitUnit(); - if (target) - { - caster.CastSpell(caster, SpellIds.AirRifleHoldVisual, true); - // needed because this spell shares GCD with its triggered spells (which must not be cast with triggered flag) - Player player = caster.ToPlayer(); - if (player) - player.GetSpellHistory().CancelGlobalCooldown(GetSpellInfo()); - if (RandomHelper.URand(0, 4) != 0) - caster.CastSpell(target, SpellIds.AirRifleShoot, false); - else - caster.CastSpell(caster, SpellIds.AirRifleShootSelf, false); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + caster.CastSpell(caster, SpellIds.AirRifleHoldVisual, true); + // needed because this spell shares GCD with its triggered spells (which must not be cast with triggered flag) + Player player = caster.ToPlayer(); + if (player) + player.GetSpellHistory().CancelGlobalCooldown(GetSpellInfo()); + if (RandomHelper.URand(0, 4) != 0) + caster.CastSpell(target, SpellIds.AirRifleShoot, false); + else + caster.CastSpell(caster, SpellIds.AirRifleShootSelf, false); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_item_red_rider_air_rifle_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] - class spell_item_create_heart_candy : SpellScriptLoader + class spell_item_create_heart_candy : SpellScript { - public spell_item_create_heart_candy() : base("spell_item_create_heart_candy") { } - - class spell_item_create_heart_candy_SpellScript : SpellScript + void HandleScript(uint effIndex) { - void HandleScript(uint effIndex) + PreventHitDefaultEffect(effIndex); + Player target = GetHitPlayer(); + if (target) { - PreventHitDefaultEffect(effIndex); - Player target = GetHitPlayer(); - if (target) - { - uint[] items = { ItemIds.HeartCandy1, ItemIds.HeartCandy2, ItemIds.HeartCandy3, ItemIds.HeartCandy4, ItemIds.HeartCandy5, ItemIds.HeartCandy6, ItemIds.HeartCandy7, ItemIds.HeartCandy8 }; - target.AddItem(items[RandomHelper.IRand(0, 7)], 1); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + uint[] items = { ItemIds.HeartCandy1, ItemIds.HeartCandy2, ItemIds.HeartCandy3, ItemIds.HeartCandy4, ItemIds.HeartCandy5, ItemIds.HeartCandy6, ItemIds.HeartCandy7, ItemIds.HeartCandy8 }; + target.AddItem(items[RandomHelper.IRand(0, 7)], 1); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_item_create_heart_candy_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] - class spell_item_book_of_glyph_mastery : SpellScriptLoader + class spell_item_book_of_glyph_mastery : SpellScript { - public spell_item_book_of_glyph_mastery() : base("spell_item_book_of_glyph_mastery") { } - - class spell_item_book_of_glyph_mastery_SpellScript : SpellScript + public override bool Load() { - public override bool Load() - { - return GetCaster().GetTypeId() == TypeId.Player; - } - - SpellCastResult CheckRequirement() - { - if (SkillDiscovery.HasDiscoveredAllSpells(GetSpellInfo().Id, GetCaster().ToPlayer())) - { - SetCustomCastResultMessage(SpellCustomErrors.LearnedEverything); - return SpellCastResult.CustomError; - } - - return SpellCastResult.SpellCastOk; - } - - void HandleScript(uint effIndex) - { - Player caster = GetCaster().ToPlayer(); - uint spellId = GetSpellInfo().Id; - - // learn random explicit discovery recipe (if any) - uint discoveredSpellId = SkillDiscovery.GetExplicitDiscoverySpell(spellId, caster); - if (discoveredSpellId != 0) - caster.LearnSpell(discoveredSpellId, false); - } - - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckRequirement)); - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } + return GetCaster().GetTypeId() == TypeId.Player; } - public override SpellScript GetSpellScript() + SpellCastResult CheckRequirement() { - return new spell_item_book_of_glyph_mastery_SpellScript(); - } - } - - [Script] - class spell_item_gift_of_the_harvester : SpellScriptLoader - { - public spell_item_gift_of_the_harvester() : base("spell_item_gift_of_the_harvester") { } - - class spell_item_gift_of_the_harvester_SpellScript : SpellScript - { - SpellCastResult CheckRequirement() + if (SkillDiscovery.HasDiscoveredAllSpells(GetSpellInfo().Id, GetCaster().ToPlayer())) { - List ghouls = new List(); - GetCaster().GetAllMinionsByEntry(ghouls, CreatureIds.Ghoul); - if (ghouls.Count >= CreatureIds.MaxGhouls) - { - SetCustomCastResultMessage(SpellCustomErrors.TooManyGhouls); - return SpellCastResult.CustomError; - } - - return SpellCastResult.SpellCastOk; - } - - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckRequirement)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_item_gift_of_the_harvester_SpellScript(); - } - } - - [Script] - class spell_item_map_of_the_geyser_fields : SpellScriptLoader - { - public spell_item_map_of_the_geyser_fields() : base("spell_item_map_of_the_geyser_fields") { } - - class spell_item_map_of_the_geyser_fields_SpellScript : SpellScript - { - SpellCastResult CheckSinkholes() - { - Unit caster = GetCaster(); - if (caster.FindNearestCreature(CreatureIds.SouthSinkhole, 30.0f, true) || - caster.FindNearestCreature(CreatureIds.NortheastSinkhole, 30.0f, true) || - caster.FindNearestCreature(CreatureIds.NorthwestSinkhole, 30.0f, true)) - return SpellCastResult.SpellCastOk; - - SetCustomCastResultMessage(SpellCustomErrors.MustBeCloseToSinkhole); + SetCustomCastResultMessage(SpellCustomErrors.LearnedEverything); return SpellCastResult.CustomError; } - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckSinkholes)); - } + return SpellCastResult.SpellCastOk; } - public override SpellScript GetSpellScript() + void HandleScript(uint effIndex) { - return new spell_item_map_of_the_geyser_fields_SpellScript(); + Player caster = GetCaster().ToPlayer(); + uint spellId = GetSpellInfo().Id; + + // learn random explicit discovery recipe (if any) + uint discoveredSpellId = SkillDiscovery.GetExplicitDiscoverySpell(spellId, caster); + if (discoveredSpellId != 0) + caster.LearnSpell(discoveredSpellId, false); + } + + public override void Register() + { + OnCheckCast.Add(new CheckCastHandler(CheckRequirement)); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] - class spell_item_vanquished_clutches : SpellScriptLoader + class spell_item_gift_of_the_harvester : SpellScript { - public spell_item_vanquished_clutches() : base("spell_item_vanquished_clutches") { } - - class spell_item_vanquished_clutches_SpellScript : SpellScript + SpellCastResult CheckRequirement() { - public override bool Validate(SpellInfo spellInfo) + List ghouls = new List(); + GetCaster().GetAllMinionsByEntry(ghouls, CreatureIds.Ghoul); + if (ghouls.Count >= CreatureIds.MaxGhouls) { - return ValidateSpellInfo(SpellIds.Crusher, SpellIds.Constrictor, SpellIds.Corruptor); + SetCustomCastResultMessage(SpellCustomErrors.TooManyGhouls); + return SpellCastResult.CustomError; } - void HandleDummy(uint effIndex) - { - uint spellId = RandomHelper.RAND(SpellIds.Crusher, SpellIds.Constrictor, SpellIds.Corruptor); - Unit caster = GetCaster(); - caster.CastSpell(caster, spellId, true); - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return SpellCastResult.SpellCastOk; } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_item_vanquished_clutches_SpellScript(); + OnCheckCast.Add(new CheckCastHandler(CheckRequirement)); } } [Script] - class spell_item_ashbringer : SpellScriptLoader + class spell_item_map_of_the_geyser_fields : SpellScript { - public spell_item_ashbringer() : base("spell_item_ashbringer") { } - - class spell_item_ashbringer_SpellScript : SpellScript + SpellCastResult CheckSinkholes() { - public override bool Load() - { - return GetCaster().GetTypeId() == TypeId.Player; - } + Unit caster = GetCaster(); + if (caster.FindNearestCreature(CreatureIds.SouthSinkhole, 30.0f, true) || + caster.FindNearestCreature(CreatureIds.NortheastSinkhole, 30.0f, true) || + caster.FindNearestCreature(CreatureIds.NorthwestSinkhole, 30.0f, true)) + return SpellCastResult.SpellCastOk; - void OnDummyEffect(uint effIndex) - { - PreventHitDefaultEffect(effIndex); - - Player player = GetCaster().ToPlayer(); - uint sound_id = RandomHelper.RAND(SoundIds.Ashbringer1, SoundIds.Ashbringer2, SoundIds.Ashbringer3, SoundIds.Ashbringer4, SoundIds.Ashbringer5, SoundIds.Ashbringer6, - SoundIds.Ashbringer7, SoundIds.Ashbringer8, SoundIds.Ashbringer9, SoundIds.Ashbringer10, SoundIds.Ashbringer11, SoundIds.Ashbringer12); - - // Ashbringers effect (spellID 28441) retriggers every 5 seconds, with a chance of making it say one of the above 12 sounds - if (RandomHelper.URand(0, 60) < 1) - player.PlayDirectSound(sound_id, player); - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(OnDummyEffect, 0, SpellEffectName.Dummy)); - } + SetCustomCastResultMessage(SpellCustomErrors.MustBeCloseToSinkhole); + return SpellCastResult.CustomError; } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_item_ashbringer_SpellScript(); + OnCheckCast.Add(new CheckCastHandler(CheckSinkholes)); } } [Script] - class spell_magic_eater_food : SpellScriptLoader + class spell_item_vanquished_clutches : SpellScript { - public spell_magic_eater_food() : base("spell_magic_eater_food") { } - - class spell_magic_eater_food_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - void HandleTriggerSpell(AuraEffect aurEff) + return ValidateSpellInfo(SpellIds.Crusher, SpellIds.Constrictor, SpellIds.Corruptor); + } + + void HandleDummy(uint effIndex) + { + uint spellId = RandomHelper.RAND(SpellIds.Crusher, SpellIds.Constrictor, SpellIds.Corruptor); + Unit caster = GetCaster(); + caster.CastSpell(caster, spellId, true); + } + + public override void Register() + { + OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + } + } + + [Script] + class spell_item_ashbringer : SpellScript + { + public override bool Load() + { + return GetCaster().GetTypeId() == TypeId.Player; + } + + void OnDummyEffect(uint effIndex) + { + PreventHitDefaultEffect(effIndex); + + Player player = GetCaster().ToPlayer(); + uint sound_id = RandomHelper.RAND(SoundIds.Ashbringer1, SoundIds.Ashbringer2, SoundIds.Ashbringer3, SoundIds.Ashbringer4, SoundIds.Ashbringer5, SoundIds.Ashbringer6, + SoundIds.Ashbringer7, SoundIds.Ashbringer8, SoundIds.Ashbringer9, SoundIds.Ashbringer10, SoundIds.Ashbringer11, SoundIds.Ashbringer12); + + // Ashbringers effect (spellID 28441) retriggers every 5 seconds, with a chance of making it say one of the above 12 sounds + if (RandomHelper.URand(0, 60) < 1) + player.PlayDirectSound(sound_id, player); + } + + public override void Register() + { + OnEffectHit.Add(new EffectHandler(OnDummyEffect, 0, SpellEffectName.Dummy)); + } + } + + [Script] + class spell_magic_eater_food : AuraScript + { + void HandleTriggerSpell(AuraEffect aurEff) + { + PreventDefaultAction(); + Unit target = GetTarget(); + switch (RandomHelper.URand(0, 5)) { - PreventDefaultAction(); - Unit target = GetTarget(); - switch (RandomHelper.URand(0, 5)) + case 0: + target.CastSpell(target, SpellIds.WildMagic, true); + break; + case 1: + target.CastSpell(target, SpellIds.WellFed1, true); + break; + case 2: + target.CastSpell(target, SpellIds.WellFed2, true); + break; + case 3: + target.CastSpell(target, SpellIds.WellFed3, true); + break; + case 4: + target.CastSpell(target, SpellIds.WellFed4, true); + break; + case 5: + target.CastSpell(target, SpellIds.WellFed5, true); + break; + } + } + + public override void Register() + { + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleTriggerSpell, 1, AuraType.PeriodicTriggerSpell)); + } + } + + [Script] + class spell_item_shimmering_vessel : SpellScript + { + void HandleDummy(uint effIndex) + { + Creature target = GetHitCreature(); + if (target) + target.setDeathState(DeathState.JustRespawned); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + } + } + + [Script] + class spell_item_purify_helboar_meat : SpellScript + { + public override bool Load() + { + return GetCaster().GetTypeId() == TypeId.Player; + } + + public override bool Validate(SpellInfo spell) + { + return ValidateSpellInfo(SpellIds.SummonPurifiedHelboarMeat, SpellIds.SummonToxicHelboarMeat); + } + + void HandleDummy(uint effIndex) + { + Unit caster = GetCaster(); + caster.CastSpell(caster, RandomHelper.randChance(50) ? SpellIds.SummonPurifiedHelboarMeat : SpellIds.SummonToxicHelboarMeat, true, null); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + } + } + + [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()) { - case 0: - target.CastSpell(target, SpellIds.WildMagic, true); - break; - case 1: - target.CastSpell(target, SpellIds.WellFed1, true); - break; - case 2: - target.CastSpell(target, SpellIds.WellFed2, true); - break; - case 3: - target.CastSpell(target, SpellIds.WellFed3, true); - break; - case 4: - target.CastSpell(target, SpellIds.WellFed4, true); - break; - case 5: - target.CastSpell(target, SpellIds.WellFed5, true); - break; + GetCaster().SummonGameObject(ObjectIds.ImprisonedDoomguard, target, Quaternion.WAxis, (uint)(target.GetRespawnTime() - Time.UnixTime)); + target.DespawnOrUnsummon(); } } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleTriggerSpell, 1, AuraType.PeriodicTriggerSpell)); - } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_magic_eater_food_AuraScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] - class spell_item_shimmering_vessel : SpellScriptLoader + class spell_item_reindeer_transformation : SpellScript { - public spell_item_shimmering_vessel() : base("spell_item_shimmering_vessel") { } - - class spell_item_shimmering_vessel_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - void HandleDummy(uint effIndex) - { - Creature target = GetHitCreature(); - if (target) - target.setDeathState(DeathState.JustRespawned); - } + return ValidateSpellInfo(SpellIds.FlyingReindeer310, SpellIds.FlyingReindeer280, SpellIds.FlyingReindeer60, SpellIds.Reindeer100, SpellIds.Reindeer60); + } - public override void Register() + void HandleDummy(uint effIndex) + { + Unit caster = GetCaster(); + if (caster.HasAuraType(AuraType.Mounted)) { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + float flyspeed = caster.GetSpeedRate(UnitMoveType.Flight); + float speed = caster.GetSpeedRate(UnitMoveType.Run); + + caster.RemoveAurasByType(AuraType.Mounted); + //5 different spells used depending on mounted speed and if mount can fly or not + + if (flyspeed >= 4.1f) + // Flying Reindeer + caster.CastSpell(caster, SpellIds.FlyingReindeer310, true); //310% flying Reindeer + else if (flyspeed >= 3.8f) + // Flying Reindeer + caster.CastSpell(caster, SpellIds.FlyingReindeer280, true); //280% flying Reindeer + else if (flyspeed >= 1.6f) + // Flying Reindeer + caster.CastSpell(caster, SpellIds.FlyingReindeer60, true); //60% flying Reindeer + else if (speed >= 2.0f) + // Reindeer + caster.CastSpell(caster, SpellIds.Reindeer100, true); //100% ground Reindeer + else + // Reindeer + caster.CastSpell(caster, SpellIds.Reindeer60, true); //60% ground Reindeer } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_item_shimmering_vessel_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] - class spell_item_purify_helboar_meat : SpellScriptLoader + class spell_item_nigh_invulnerability : SpellScript { - public spell_item_purify_helboar_meat() : base("spell_item_purify_helboar_meat") { } - - class spell_item_purify_helboar_meat_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - public override bool Load() - { - return GetCaster().GetTypeId() == TypeId.Player; - } + return ValidateSpellInfo(SpellIds.NighInvulnerability, SpellIds.CompleteVulnerability); + } - public override bool Validate(SpellInfo spell) + void HandleDummy(uint effIndex) + { + Unit caster = GetCaster(); + Item castItem = GetCastItem(); + if (castItem) { - return ValidateSpellInfo(SpellIds.SummonPurifiedHelboarMeat, SpellIds.SummonToxicHelboarMeat); - } - - void HandleDummy(uint effIndex) - { - Unit caster = GetCaster(); - caster.CastSpell(caster, RandomHelper.randChance(50) ? SpellIds.SummonPurifiedHelboarMeat : SpellIds.SummonToxicHelboarMeat, true, null); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + if (RandomHelper.randChance(86)) // Nigh-Invulnerability - success + caster.CastSpell(caster, SpellIds.NighInvulnerability, true, castItem); + else // Complete Vulnerability - backfire in 14% casts + caster.CastSpell(caster, SpellIds.CompleteVulnerability, true, castItem); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_item_purify_helboar_meat_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] - class spell_item_crystal_prison_dummy_dnd : SpellScriptLoader + class spell_item_poultryizer : SpellScript { - public spell_item_crystal_prison_dummy_dnd() : base("spell_item_crystal_prison_dummy_dnd") { } - - class spell_item_crystal_prison_dummy_dnd_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - if (Global.ObjectMgr.GetGameObjectTemplate(ObjectIds.ImprisonedDoomguard) == null) - return false; - return true; - } + return ValidateSpellInfo(SpellIds.PoultryizerSuccess, SpellIds.PoultryizerBackfire); + } - void HandleDummy(uint effIndex) + void HandleDummy(uint effIndex) + { + if (GetCastItem() && GetHitUnit()) + GetCaster().CastSpell(GetHitUnit(), RandomHelper.randChance(80) ? SpellIds.PoultryizerSuccess : SpellIds.PoultryizerBackfire, true, GetCastItem()); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + } + } + + [Script] + class spell_item_socrethars_stone : SpellScript + { + public override bool Load() + { + return (GetCaster().GetAreaId() == 3900 || GetCaster().GetAreaId() == 3742); + } + + public override bool Validate(SpellInfo spell) + { + return ValidateSpellInfo(SpellIds.SocretharToSeat, SpellIds.SocretharFromSeat); + } + + void HandleDummy(uint effIndex) + { + Unit caster = GetCaster(); + switch (caster.GetAreaId()) { - Creature target = GetHitCreature(); - if (target) + case 3900: + caster.CastSpell(caster, SpellIds.SocretharToSeat, true); + break; + case 3742: + caster.CastSpell(caster, SpellIds.SocretharFromSeat, true); + break; + default: + return; + } + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + } + } + + [Script] + class spell_item_demon_broiled_surprise : SpellScript + { + public override bool Validate(SpellInfo spell) + { + return Global.ObjectMgr.GetCreatureTemplate(CreatureIds.AbyssalFlamebringer) != null + && Global.ObjectMgr.GetQuestTemplate(QuestIds.SuperHotStew) != null + && ValidateSpellInfo(SpellIds.CreateDemonBroiledSurprise); + } + + public override bool Load() + { + return GetCaster().GetTypeId() == TypeId.Player; + } + + void HandleDummy(uint effIndex) + { + Unit player = GetCaster(); + player.CastSpell(player, SpellIds.CreateDemonBroiledSurprise, false); + } + + SpellCastResult CheckRequirement() + { + Player player = GetCaster().ToPlayer(); + if (player.GetQuestStatus(QuestIds.SuperHotStew) != QuestStatus.Incomplete) + return SpellCastResult.CantDoThatRightNow; + + Creature creature = player.FindNearestCreature(CreatureIds.AbyssalFlamebringer, 10, false); + if (creature) + if (creature.IsDead()) + return SpellCastResult.SpellCastOk; + return SpellCastResult.NotHere; + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 1, SpellEffectName.Dummy)); + OnCheckCast.Add(new CheckCastHandler(CheckRequirement)); + } + } + + [Script] + class spell_item_complete_raptor_capture : SpellScript + { + public override bool Validate(SpellInfo spell) + { + return ValidateSpellInfo(SpellIds.RaptorCaptureCredit); + } + + void HandleDummy(uint effIndex) + { + Unit caster = GetCaster(); + if (GetHitCreature()) + { + GetHitCreature().DespawnOrUnsummon(); + + //cast spell Raptor Capture Credit + caster.CastSpell(caster, SpellIds.RaptorCaptureCredit, true, null); + } + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + } + } + + [Script] + class spell_item_impale_leviroth : SpellScript + { + public override bool Validate(SpellInfo spell) + { + if (Global.ObjectMgr.GetCreatureTemplate(CreatureIds.Leviroth) == null) + return false; + return true; + } + + void HandleDummy(uint effIndex) + { + Creature target = GetHitCreature(); + if (target) + if (target.GetEntry() == CreatureIds.Leviroth && !target.HealthBelowPct(95)) { - if (target.IsDead() && !target.IsPet()) - { - GetCaster().SummonGameObject(ObjectIds.ImprisonedDoomguard, target, Quaternion.WAxis, (uint)(target.GetRespawnTime() - Time.UnixTime)); - target.DespawnOrUnsummon(); - } + target.CastSpell(target, SpellIds.LevirothSelfImpale, true); + target.ResetPlayerDamageReq(); } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_item_crystal_prison_dummy_dnd_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] - class spell_item_reindeer_transformation : SpellScriptLoader + class spell_item_brewfest_mount_transformation : SpellScript { - public spell_item_reindeer_transformation() : base("spell_item_reindeer_transformation") { } - - class spell_item_reindeer_transformation_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.FlyingReindeer310, SpellIds.FlyingReindeer280, SpellIds.FlyingReindeer60, SpellIds.Reindeer100, SpellIds.Reindeer60); - } + return ValidateSpellInfo(SpellIds.MountRam100, SpellIds.MountRam60, SpellIds.MountKodo100, SpellIds.MountKodo60); + } - void HandleDummy(uint effIndex) + void HandleDummy(uint effIndex) + { + Player caster = GetCaster().ToPlayer(); + if (caster.HasAuraType(AuraType.Mounted)) { - Unit caster = GetCaster(); - if (caster.HasAuraType(AuraType.Mounted)) + caster.RemoveAurasByType(AuraType.Mounted); + uint spell_id; + + switch (GetSpellInfo().Id) { - float flyspeed = caster.GetSpeedRate(UnitMoveType.Flight); - float speed = caster.GetSpeedRate(UnitMoveType.Run); - - caster.RemoveAurasByType(AuraType.Mounted); - //5 different spells used depending on mounted speed and if mount can fly or not - - if (flyspeed >= 4.1f) - // Flying Reindeer - caster.CastSpell(caster, SpellIds.FlyingReindeer310, true); //310% flying Reindeer - else if (flyspeed >= 3.8f) - // Flying Reindeer - caster.CastSpell(caster, SpellIds.FlyingReindeer280, true); //280% flying Reindeer - else if (flyspeed >= 1.6f) - // Flying Reindeer - caster.CastSpell(caster, SpellIds.FlyingReindeer60, true); //60% flying Reindeer - else if (speed >= 2.0f) - // Reindeer - caster.CastSpell(caster, SpellIds.Reindeer100, true); //100% ground Reindeer - else - // Reindeer - caster.CastSpell(caster, SpellIds.Reindeer60, true); //60% ground Reindeer - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_item_reindeer_transformation_SpellScript(); - } - } - - [Script] - class spell_item_nigh_invulnerability : SpellScriptLoader - { - public spell_item_nigh_invulnerability() : base("spell_item_nigh_invulnerability") { } - - class spell_item_nigh_invulnerability_SpellScript : SpellScript - { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.NighInvulnerability, SpellIds.CompleteVulnerability); - } - - void HandleDummy(uint effIndex) - { - Unit caster = GetCaster(); - Item castItem = GetCastItem(); - if (castItem) - { - if (RandomHelper.randChance(86)) // Nigh-Invulnerability - success - caster.CastSpell(caster, SpellIds.NighInvulnerability, true, castItem); - else // Complete Vulnerability - backfire in 14% casts - caster.CastSpell(caster, SpellIds.CompleteVulnerability, true, castItem); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_item_nigh_invulnerability_SpellScript(); - } - } - - [Script] - class spell_item_poultryizer : SpellScriptLoader - { - public spell_item_poultryizer() : base("spell_item_poultryizer") { } - - class spell_item_poultryizer_SpellScript : SpellScript - { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.PoultryizerSuccess, SpellIds.PoultryizerBackfire); - } - - void HandleDummy(uint effIndex) - { - if (GetCastItem() && GetHitUnit()) - GetCaster().CastSpell(GetHitUnit(), RandomHelper.randChance(80) ? SpellIds.PoultryizerSuccess : SpellIds.PoultryizerBackfire, true, GetCastItem()); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_item_poultryizer_SpellScript(); - } - } - - [Script] - class spell_item_socrethars_stone : SpellScriptLoader - { - public spell_item_socrethars_stone() : base("spell_item_socrethars_stone") { } - - class spell_item_socrethars_stone_SpellScript : SpellScript - { - public override bool Load() - { - return (GetCaster().GetAreaId() == 3900 || GetCaster().GetAreaId() == 3742); - } - - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.SocretharToSeat, SpellIds.SocretharFromSeat); - } - - void HandleDummy(uint effIndex) - { - Unit caster = GetCaster(); - switch (caster.GetAreaId()) - { - case 3900: - caster.CastSpell(caster, SpellIds.SocretharToSeat, true); + case SpellIds.BrewfestMountTransform: + if (caster.GetSpeedRate(UnitMoveType.Run) >= 2.0f) + spell_id = caster.GetTeam() == Team.Alliance ? SpellIds.MountRam100 : SpellIds.MountKodo100; + else + spell_id = caster.GetTeam() == Team.Alliance ? SpellIds.MountRam60 : SpellIds.MountKodo60; break; - case 3742: - caster.CastSpell(caster, SpellIds.SocretharFromSeat, true); + case SpellIds.BrewfestMountTransformReverse: + if (caster.GetSpeedRate(UnitMoveType.Run) >= 2.0f) + spell_id = caster.GetTeam() == Team.Horde ? SpellIds.MountRam100 : SpellIds.MountKodo100; + else + spell_id = caster.GetTeam() == Team.Horde ? SpellIds.MountRam60 : SpellIds.MountKodo60; break; default: return; } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + caster.CastSpell(caster, spell_id, true); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_item_socrethars_stone_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] - class spell_item_demon_broiled_surprise : SpellScriptLoader + class spell_item_nitro_boots : SpellScript { - public spell_item_demon_broiled_surprise() : base("spell_item_demon_broiled_surprise") { } - - class spell_item_demon_broiled_surprise_SpellScript : SpellScript + public override bool Load() { - public override bool Validate(SpellInfo spell) - { - return Global.ObjectMgr.GetCreatureTemplate(CreatureIds.AbyssalFlamebringer) != null - && Global.ObjectMgr.GetQuestTemplate(QuestIds.SuperHotStew) != null - && ValidateSpellInfo(SpellIds.CreateDemonBroiledSurprise); - } - - public override bool Load() - { - return GetCaster().GetTypeId() == TypeId.Player; - } - - void HandleDummy(uint effIndex) - { - Unit player = GetCaster(); - player.CastSpell(player, SpellIds.CreateDemonBroiledSurprise, false); - } - - SpellCastResult CheckRequirement() - { - Player player = GetCaster().ToPlayer(); - if (player.GetQuestStatus(QuestIds.SuperHotStew) != QuestStatus.Incomplete) - return SpellCastResult.CantDoThatRightNow; - - Creature creature = player.FindNearestCreature(CreatureIds.AbyssalFlamebringer, 10, false); - if (creature) - if (creature.IsDead()) - return SpellCastResult.SpellCastOk; - return SpellCastResult.NotHere; - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 1, SpellEffectName.Dummy)); - OnCheckCast.Add(new CheckCastHandler(CheckRequirement)); - } + if (!GetCastItem()) + return false; + return true; } - public override SpellScript GetSpellScript() + public override bool Validate(SpellInfo spell) { - return new spell_item_demon_broiled_surprise_SpellScript(); + return ValidateSpellInfo(SpellIds.NitroBootsSuccess, SpellIds.NitroBootsBackfire); + } + + void HandleDummy(uint effIndex) + { + Unit caster = GetCaster(); + bool success = caster.GetMap().IsDungeon() || RandomHelper.randChance(95); + caster.CastSpell(caster, success ? SpellIds.NitroBootsSuccess : SpellIds.NitroBootsBackfire, true, GetCastItem()); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] - class spell_item_complete_raptor_capture : SpellScriptLoader + class spell_item_teach_language : SpellScript { - public spell_item_complete_raptor_capture() : base("spell_item_complete_raptor_capture") { } - - class spell_item_complete_raptor_capture_SpellScript : SpellScript + public override bool Load() { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.RaptorCaptureCredit); - } - - void HandleDummy(uint effIndex) - { - Unit caster = GetCaster(); - if (GetHitCreature()) - { - GetHitCreature().DespawnOrUnsummon(); - - //cast spell Raptor Capture Credit - caster.CastSpell(caster, SpellIds.RaptorCaptureCredit, true, null); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return GetCaster().GetTypeId() == TypeId.Player; } - public override SpellScript GetSpellScript() + public override bool Validate(SpellInfo spell) { - return new spell_item_complete_raptor_capture_SpellScript(); + return ValidateSpellInfo(SpellIds.LearnGnomishBinary, SpellIds.LearnGoblinBinary); + } + + void HandleDummy(uint effIndex) + { + Player caster = GetCaster().ToPlayer(); + + if (RandomHelper.randChance(34)) + caster.CastSpell(caster, caster.GetTeam() == Team.Alliance ? SpellIds.LearnGnomishBinary : SpellIds.LearnGoblinBinary, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] - class spell_item_impale_leviroth : SpellScriptLoader + class spell_item_rocket_boots : SpellScript { - public spell_item_impale_leviroth() : base("spell_item_impale_leviroth") { } - - class spell_item_impale_leviroth_SpellScript : SpellScript + public override bool Load() { - public override bool Validate(SpellInfo spell) - { - if (Global.ObjectMgr.GetCreatureTemplate(CreatureIds.Leviroth) == null) - return false; - return true; - } - - void HandleDummy(uint effIndex) - { - Creature target = GetHitCreature(); - if (target) - if (target.GetEntry() == CreatureIds.Leviroth && !target.HealthBelowPct(95)) - { - target.CastSpell(target, SpellIds.LevirothSelfImpale, true); - target.ResetPlayerDamageReq(); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return GetCaster().GetTypeId() == TypeId.Player; } - public override SpellScript GetSpellScript() + public override bool Validate(SpellInfo spell) { - return new spell_item_impale_leviroth_SpellScript(); + return ValidateSpellInfo(SpellIds.RocketBootsProc); + } + + void HandleDummy(uint effIndex) + { + Player caster = GetCaster().ToPlayer(); + + Battleground bg = caster.GetBattleground(); + if (bg) + bg.EventPlayerDroppedFlag(caster); + + caster.GetSpellHistory().ResetCooldown(SpellIds.RocketBootsProc); + caster.CastSpell(caster, SpellIds.RocketBootsProc, true, null); + } + + SpellCastResult CheckCast() + { + if (GetCaster().IsInWater()) + return SpellCastResult.OnlyAbovewater; + return SpellCastResult.SpellCastOk; + } + + public override void Register() + { + OnCheckCast.Add(new CheckCastHandler(CheckCast)); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] - class spell_item_brewfest_mount_transformation : SpellScriptLoader + class spell_item_pygmy_oil : SpellScript { - public spell_item_brewfest_mount_transformation() : base("spell_item_brewfest_mount_transformation") { } - - class spell_item_brewfest_mount_transformation_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.MountRam100, SpellIds.MountRam60, SpellIds.MountKodo100, SpellIds.MountKodo60); - } - - void HandleDummy(uint effIndex) - { - Player caster = GetCaster().ToPlayer(); - if (caster.HasAuraType(AuraType.Mounted)) - { - caster.RemoveAurasByType(AuraType.Mounted); - uint spell_id; - - switch (GetSpellInfo().Id) - { - case SpellIds.BrewfestMountTransform: - if (caster.GetSpeedRate(UnitMoveType.Run) >= 2.0f) - spell_id = caster.GetTeam() == Team.Alliance ? SpellIds.MountRam100 : SpellIds.MountKodo100; - else - spell_id = caster.GetTeam() == Team.Alliance ? SpellIds.MountRam60 : SpellIds.MountKodo60; - break; - case SpellIds.BrewfestMountTransformReverse: - if (caster.GetSpeedRate(UnitMoveType.Run) >= 2.0f) - spell_id = caster.GetTeam() == Team.Horde ? SpellIds.MountRam100 : SpellIds.MountKodo100; - else - spell_id = caster.GetTeam() == Team.Horde ? SpellIds.MountRam60 : SpellIds.MountKodo60; - break; - default: - return; - } - caster.CastSpell(caster, spell_id, true); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellIds.PygmyOilPygmyAura, SpellIds.PygmyOilSmallerAura); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_item_brewfest_mount_transformation_SpellScript(); - } - } - - [Script] - class spell_item_nitro_boots : SpellScriptLoader - { - public spell_item_nitro_boots() : base("spell_item_nitro_boots") { } - - class spell_item_nitro_boots_SpellScript : SpellScript - { - public override bool Load() + Unit caster = GetCaster(); + Aura aura = caster.GetAura(SpellIds.PygmyOilPygmyAura); + if (aura != null) + aura.RefreshDuration(); + else { - if (!GetCastItem()) - return false; - return true; - } - - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.NitroBootsSuccess, SpellIds.NitroBootsBackfire); - } - - void HandleDummy(uint effIndex) - { - Unit caster = GetCaster(); - bool success = caster.GetMap().IsDungeon() || RandomHelper.randChance(95); - caster.CastSpell(caster, success ? SpellIds.NitroBootsSuccess : SpellIds.NitroBootsBackfire, true, GetCastItem()); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_item_nitro_boots_SpellScript(); - } - } - - [Script] - class spell_item_teach_language : SpellScriptLoader - { - public spell_item_teach_language() : base("spell_item_teach_language") { } - - class spell_item_teach_language_SpellScript : SpellScript - { - public override bool Load() - { - return GetCaster().GetTypeId() == TypeId.Player; - } - - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.LearnGnomishBinary, SpellIds.LearnGoblinBinary); - } - - void HandleDummy(uint effIndex) - { - Player caster = GetCaster().ToPlayer(); - - if (RandomHelper.randChance(34)) - caster.CastSpell(caster, caster.GetTeam() == Team.Alliance ? SpellIds.LearnGnomishBinary : SpellIds.LearnGoblinBinary, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_item_teach_language_SpellScript(); - } - } - - [Script] - class spell_item_rocket_boots : SpellScriptLoader - { - public spell_item_rocket_boots() : base("spell_item_rocket_boots") { } - - class spell_item_rocket_boots_SpellScript : SpellScript - { - public override bool Load() - { - return GetCaster().GetTypeId() == TypeId.Player; - } - - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.RocketBootsProc); - } - - void HandleDummy(uint effIndex) - { - Player caster = GetCaster().ToPlayer(); - - Battleground bg = caster.GetBattleground(); - if (bg) - bg.EventPlayerDroppedFlag(caster); - - caster.GetSpellHistory().ResetCooldown(SpellIds.RocketBootsProc); - caster.CastSpell(caster, SpellIds.RocketBootsProc, true, null); - } - - SpellCastResult CheckCast() - { - if (GetCaster().IsInWater()) - return SpellCastResult.OnlyAbovewater; - return SpellCastResult.SpellCastOk; - } - - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } - } - - public override SpellScript GetSpellScript() - { - return new spell_item_rocket_boots_SpellScript(); - } - } - - [Script] - class spell_item_pygmy_oil : SpellScriptLoader - { - public spell_item_pygmy_oil() : base("spell_item_pygmy_oil") { } - - class spell_item_pygmy_oil_SpellScript : SpellScript - { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.PygmyOilPygmyAura, SpellIds.PygmyOilSmallerAura); - } - - void HandleDummy(uint effIndex) - { - Unit caster = GetCaster(); - Aura aura = caster.GetAura(SpellIds.PygmyOilPygmyAura); - if (aura != null) - aura.RefreshDuration(); + aura = caster.GetAura(SpellIds.PygmyOilSmallerAura); + if (aura == null || aura.GetStackAmount() < 5 || !RandomHelper.randChance(50)) + caster.CastSpell(caster, SpellIds.PygmyOilSmallerAura, true); else { - aura = caster.GetAura(SpellIds.PygmyOilSmallerAura); - if (aura == null || aura.GetStackAmount() < 5 || !RandomHelper.randChance(50)) - caster.CastSpell(caster, SpellIds.PygmyOilSmallerAura, true); - else - { - aura.Remove(); - caster.CastSpell(caster, SpellIds.PygmyOilPygmyAura, true); - } + aura.Remove(); + caster.CastSpell(caster, SpellIds.PygmyOilPygmyAura, true); } } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_item_pygmy_oil_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] - class spell_item_unusual_compass : SpellScriptLoader + class spell_item_unusual_compass : SpellScript { - public spell_item_unusual_compass() : base("spell_item_unusual_compass") { } - - class spell_item_unusual_compass_SpellScript : SpellScript + void HandleDummy(uint effIndex) { - void HandleDummy(uint effIndex) - { - Unit caster = GetCaster(); - caster.SetFacingTo(RandomHelper.FRand(0.0f, 2.0f * (float)Math.PI)); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + Unit caster = GetCaster(); + caster.SetFacingTo(RandomHelper.FRand(0.0f, 2.0f * (float)Math.PI)); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_item_unusual_compass_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] - class spell_item_chicken_cover : SpellScriptLoader + class spell_item_chicken_cover : SpellScript { - public spell_item_chicken_cover() : base("spell_item_chicken_cover") { } - - class spell_item_chicken_cover_SpellScript : SpellScript + public override bool Load() { - public override bool Load() - { - return GetCaster().GetTypeId() == TypeId.Player; - } + return GetCaster().GetTypeId() == TypeId.Player; + } - public override bool Validate(SpellInfo spell) - { - return Global.ObjectMgr.GetQuestTemplate(QuestIds.ChickenParty) != null - && Global.ObjectMgr.GetQuestTemplate(QuestIds.FlownTheCoop) != null - && ValidateSpellInfo(SpellIds.ChickenNet, SpellIds.CaptureChickenEscape); - } + public override bool Validate(SpellInfo spell) + { + return Global.ObjectMgr.GetQuestTemplate(QuestIds.ChickenParty) != null + && Global.ObjectMgr.GetQuestTemplate(QuestIds.FlownTheCoop) != null + && ValidateSpellInfo(SpellIds.ChickenNet, SpellIds.CaptureChickenEscape); + } - void HandleDummy(uint effIndex) + void HandleDummy(uint effIndex) + { + Player caster = GetCaster().ToPlayer(); + Unit target = GetHitUnit(); + if (target) { - Player caster = GetCaster().ToPlayer(); - Unit target = GetHitUnit(); - if (target) + if (!target.HasAura(SpellIds.ChickenNet) && (caster.GetQuestStatus(QuestIds.ChickenParty) == QuestStatus.Incomplete || caster.GetQuestStatus(QuestIds.FlownTheCoop) == QuestStatus.Incomplete)) { - if (!target.HasAura(SpellIds.ChickenNet) && (caster.GetQuestStatus(QuestIds.ChickenParty) == QuestStatus.Incomplete || caster.GetQuestStatus(QuestIds.FlownTheCoop) == QuestStatus.Incomplete)) - { - caster.CastSpell(caster, SpellIds.CaptureChickenEscape, true); - target.KillSelf(); - } + caster.CastSpell(caster, SpellIds.CaptureChickenEscape, true); + target.KillSelf(); } } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_item_chicken_cover_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] - class spell_item_muisek_vessel : SpellScriptLoader + class spell_item_muisek_vessel : SpellScript { - public spell_item_muisek_vessel() : base("spell_item_muisek_vessel") { } - - class spell_item_muisek_vessel_SpellScript : SpellScript + void HandleDummy(uint effIndex) { - void HandleDummy(uint effIndex) - { - Creature target = GetHitCreature(); - if (target) - if (target.IsDead()) - target.DespawnOrUnsummon(); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + Creature target = GetHitCreature(); + if (target) + if (target.IsDead()) + target.DespawnOrUnsummon(); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_item_muisek_vessel_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] - class spell_item_greatmothers_soulcatcher : SpellScriptLoader + class spell_item_greatmothers_soulcatcher : SpellScript { - public spell_item_greatmothers_soulcatcher() : base("spell_item_greatmothers_soulcatcher") { } - - class spell_item_greatmothers_soulcatcher_SpellScript : SpellScript + void HandleDummy(uint effIndex) { - void HandleDummy(uint effIndex) - { - if (GetHitUnit()) - GetCaster().CastSpell(GetCaster(), SpellIds.ForceCastSummonGnomeSoul); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + if (GetHitUnit()) + GetCaster().CastSpell(GetCaster(), SpellIds.ForceCastSummonGnomeSoul); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_item_greatmothers_soulcatcher_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -3451,52 +2690,35 @@ namespace Scripts.Spells.Items // 69739 - Shiny Shard of the Scale - Equip Effect [Script("spell_item_purified_shard_of_the_scale", SpellIds.PurifiedCauterizingHeal, SpellIds.PurifiedSearingFlames)] [Script("spell_item_shiny_shard_of_the_scale", SpellIds.ShinyCauterizingHeal, SpellIds.ShinySearingFlames)] - class spell_item_shard_of_the_scale : SpellScriptLoader + class spell_item_shard_of_the_scale : AuraScript { - public spell_item_shard_of_the_scale(string scriptName, uint healProcSpellId, uint damageProcSpellId) : base(scriptName) + public spell_item_shard_of_the_scale(uint healProcSpellId, uint damageProcSpellId) { _healProcSpellId = healProcSpellId; _damageProcSpellId = damageProcSpellId; } - class spell_item_shard_of_the_scale_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public spell_item_shard_of_the_scale_AuraScript(uint healProcSpellId, uint damageProcSpellId) - { - _healProcSpellId = healProcSpellId; - _damageProcSpellId = damageProcSpellId; - } - - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(_healProcSpellId, _damageProcSpellId); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - Unit caster = eventInfo.GetActor(); - Unit target = eventInfo.GetProcTarget(); - - if (eventInfo.GetTypeMask().HasAnyFlag(ProcFlags.DoneSpellMagicDmgClassPos)) - caster.CastSpell(target, _healProcSpellId, true); - - if (eventInfo.GetTypeMask().HasAnyFlag(ProcFlags.DoneSpellMagicDmgClassNeg)) - caster.CastSpell(target, _damageProcSpellId, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } - - uint _healProcSpellId; - uint _damageProcSpellId; + return ValidateSpellInfo(_healProcSpellId, _damageProcSpellId); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_item_shard_of_the_scale_AuraScript(_healProcSpellId, _damageProcSpellId); + PreventDefaultAction(); + Unit caster = eventInfo.GetActor(); + Unit target = eventInfo.GetProcTarget(); + + if (eventInfo.GetTypeMask().HasAnyFlag(ProcFlags.DoneSpellMagicDmgClassPos)) + caster.CastSpell(target, _healProcSpellId, true); + + if (eventInfo.GetTypeMask().HasAnyFlag(ProcFlags.DoneSpellMagicDmgClassNeg)) + caster.CastSpell(target, _damageProcSpellId, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } uint _healProcSpellId; @@ -3504,51 +2726,41 @@ namespace Scripts.Spells.Items } [Script] - class spell_item_soul_preserver : SpellScriptLoader + class spell_item_soul_preserver : AuraScript { - public spell_item_soul_preserver() : base("spell_item_soul_preserver") { } - - class spell_item_soul_preserver_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) + return ValidateSpellInfo(SpellIds.SoulPreserverDruid, SpellIds.SoulPreserverPaladin, SpellIds.SoulPreserverPriest, SpellIds.SoulPreserverShaman); + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + + Unit caster = eventInfo.GetActor(); + + switch (caster.GetClass()) { - return ValidateSpellInfo(SpellIds.SoulPreserverDruid, SpellIds.SoulPreserverPaladin, SpellIds.SoulPreserverPriest, SpellIds.SoulPreserverShaman); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - Unit caster = eventInfo.GetActor(); - - switch (caster.GetClass()) - { - case Class.Druid: - caster.CastSpell(caster, SpellIds.SoulPreserverDruid, true, null, aurEff); - break; - case Class.Paladin: - caster.CastSpell(caster, SpellIds.SoulPreserverPaladin, true, null, aurEff); - break; - case Class.Priest: - caster.CastSpell(caster, SpellIds.SoulPreserverPriest, true, null, aurEff); - break; - case Class.Shaman: - caster.CastSpell(caster, SpellIds.SoulPreserverShaman, true, null, aurEff); - break; - default: - break; - } - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); + case Class.Druid: + caster.CastSpell(caster, SpellIds.SoulPreserverDruid, true, null, aurEff); + break; + case Class.Paladin: + caster.CastSpell(caster, SpellIds.SoulPreserverPaladin, true, null, aurEff); + break; + case Class.Priest: + caster.CastSpell(caster, SpellIds.SoulPreserverPriest, true, null, aurEff); + break; + case Class.Shaman: + caster.CastSpell(caster, SpellIds.SoulPreserverShaman, true, null, aurEff); + break; + default: + break; } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_item_soul_preserver_AuraScript(); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); } } @@ -3556,62 +2768,45 @@ namespace Scripts.Spells.Items [Script("spell_item_sunwell_exalted_melee_neck", SpellIds.LightsStrength, SpellIds.ArcaneStrike)] [Script("spell_item_sunwell_exalted_tank_neck", SpellIds.LightsWard, SpellIds.ArcaneInsight)] [Script("spell_item_sunwell_exalted_healer_neck", SpellIds.LightsSalvation, SpellIds.ArcaneSurge)] - class spell_item_sunwell_neck : SpellScriptLoader + class spell_item_sunwell_neck : AuraScript { - public spell_item_sunwell_neck(string scriptName, uint aldorSpellId, uint scryersSpellId) : base(scriptName) + public spell_item_sunwell_neck(uint aldorSpellId, uint scryersSpellId) { _aldorSpellId = aldorSpellId; _scryersSpellId = scryersSpellId; } - class spell_item_sunwell_neck_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public spell_item_sunwell_neck_AuraScript(uint aldorSpellId, uint scryersSpellId) - { - _aldorSpellId = aldorSpellId; - _scryersSpellId = scryersSpellId; - } - - public override bool Validate(SpellInfo spellInfo) - { - return CliDB.FactionStorage.ContainsKey(FactionIds.Aldor) && CliDB.FactionStorage.ContainsKey(FactionIds.Scryers) - && ValidateSpellInfo(_aldorSpellId, _scryersSpellId); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - if (eventInfo.GetActor().GetTypeId() != TypeId.Player) - return false; - return true; - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - Player player = eventInfo.GetActor().ToPlayer(); - Unit target = eventInfo.GetProcTarget(); - - // Aggression checks are in the spell system... just cast and forget - if (player.GetReputationRank(FactionIds.Aldor) == ReputationRank.Exalted) - player.CastSpell(target, _aldorSpellId, true); - - if (player.GetReputationRank(FactionIds.Scryers) == ReputationRank.Exalted) - player.CastSpell(target, _scryersSpellId, true); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } - - uint _aldorSpellId; - uint _scryersSpellId; + return CliDB.FactionStorage.ContainsKey(FactionIds.Aldor) && CliDB.FactionStorage.ContainsKey(FactionIds.Scryers) + && ValidateSpellInfo(_aldorSpellId, _scryersSpellId); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_item_sunwell_neck_AuraScript(_aldorSpellId, _scryersSpellId); + if (eventInfo.GetActor().GetTypeId() != TypeId.Player) + return false; + return true; + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + Player player = eventInfo.GetActor().ToPlayer(); + Unit target = eventInfo.GetProcTarget(); + + // Aggression checks are in the spell system... just cast and forget + if (player.GetReputationRank(FactionIds.Aldor) == ReputationRank.Exalted) + player.CastSpell(target, _aldorSpellId, true); + + if (player.GetReputationRank(FactionIds.Scryers) == ReputationRank.Exalted) + player.CastSpell(target, _scryersSpellId, true); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } uint _aldorSpellId; @@ -3619,94 +2814,74 @@ namespace Scripts.Spells.Items } [Script] - class spell_item_toy_train_set_pulse : SpellScriptLoader + class spell_item_toy_train_set_pulse : SpellScript { - public spell_item_toy_train_set_pulse() : base("spell_item_toy_train_set_pulse") { } - - class spell_item_toy_train_set_pulse_SpellScript : SpellScript + void HandleDummy(uint index) { - void HandleDummy(uint index) + Player target = GetHitUnit().ToPlayer(); + if (target) { - Player target = GetHitUnit().ToPlayer(); - if (target) - { - target.HandleEmoteCommand(Emote.OneshotTrain); - EmotesTextSoundRecord soundEntry = Global.DB2Mgr.GetTextSoundEmoteFor((uint)TextEmotes.Train, target.GetRace(), target.GetGender(), target.GetClass()); - if (soundEntry != null) - target.PlayDistanceSound(soundEntry.SoundId); - } - } - - void HandleTargets(List targetList) - { - targetList.RemoveAll(obj => !obj.IsTypeId(TypeId.Player)); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.ScriptEffect)); - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(HandleTargets, SpellConst.EffectAll, Targets.UnitSrcAreaAlly)); + target.HandleEmoteCommand(Emote.OneshotTrain); + EmotesTextSoundRecord soundEntry = Global.DB2Mgr.GetTextSoundEmoteFor((uint)TextEmotes.Train, target.GetRace(), target.GetGender(), target.GetClass()); + if (soundEntry != null) + target.PlayDistanceSound(soundEntry.SoundId); } } - public override SpellScript GetSpellScript() + void HandleTargets(List targetList) { - return new spell_item_toy_train_set_pulse_SpellScript(); + targetList.RemoveAll(obj => !obj.IsTypeId(TypeId.Player)); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.ScriptEffect)); + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(HandleTargets, SpellConst.EffectAll, Targets.UnitSrcAreaAlly)); } } [Script] - class spell_item_death_choice : SpellScriptLoader + class spell_item_death_choice : AuraScript { - public spell_item_death_choice() : base("spell_item_death_choice") { } - - class spell_item_death_choice_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) + return ValidateSpellInfo(SpellIds.DeathChoiceNormalStrength, SpellIds.DeathChoiceNormalAgility, SpellIds.DeathChoiceHeroicStrength, SpellIds.DeathChoiceHeroicAgility); + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + + Unit caster = eventInfo.GetActor(); + float str = caster.GetStat(Stats.Strength); + float agi = caster.GetStat(Stats.Agility); + + switch (aurEff.GetId()) { - return ValidateSpellInfo(SpellIds.DeathChoiceNormalStrength, SpellIds.DeathChoiceNormalAgility, SpellIds.DeathChoiceHeroicStrength, SpellIds.DeathChoiceHeroicAgility); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - Unit caster = eventInfo.GetActor(); - float str = caster.GetStat(Stats.Strength); - float agi = caster.GetStat(Stats.Agility); - - switch (aurEff.GetId()) - { - case SpellIds.DeathChoiceNormalAura: - { - if (str > agi) - caster.CastSpell(caster, SpellIds.DeathChoiceNormalStrength, true, null, aurEff); - else - caster.CastSpell(caster, SpellIds.DeathChoiceNormalAgility, true, null, aurEff); - break; - } - case SpellIds.DeathChoiceHeroicAura: - { - if (str > agi) - caster.CastSpell(caster, SpellIds.DeathChoiceHeroicStrength, true, null, aurEff); - else - caster.CastSpell(caster, SpellIds.DeathChoiceHeroicAgility, true, null, aurEff); - break; - } - default: + case SpellIds.DeathChoiceNormalAura: + { + if (str > agi) + caster.CastSpell(caster, SpellIds.DeathChoiceNormalStrength, true, null, aurEff); + else + caster.CastSpell(caster, SpellIds.DeathChoiceNormalAgility, true, null, aurEff); break; - } - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.PeriodicTriggerSpell)); + } + case SpellIds.DeathChoiceHeroicAura: + { + if (str > agi) + caster.CastSpell(caster, SpellIds.DeathChoiceHeroicStrength, true, null, aurEff); + else + caster.CastSpell(caster, SpellIds.DeathChoiceHeroicAgility, true, null, aurEff); + break; + } + default: + break; } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_item_death_choice_AuraScript(); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.PeriodicTriggerSpell)); } } @@ -3714,60 +2889,43 @@ namespace Scripts.Spells.Items [Script("spell_item_thunder_capacitor", SpellIds.ThunderCapacitorStack, SpellIds.ThunderCapacitorTrigger)] [Script("spell_item_toc25_normal_caster_trinket", SpellIds.Toc25CasterTrinketNormalStack, SpellIds.Toc25CasterTrinketNormalTrigger)] [Script("spell_item_toc25_heroic_caster_trinket", SpellIds.Toc25CasterTrinketHeroicStack, SpellIds.Toc25CasterTrinketHeroicTrigger)] - class spell_item_trinket_stack : SpellScriptLoader + class spell_item_trinket_stack : AuraScript { - public spell_item_trinket_stack(string scriptName, uint stackSpell, uint triggerSpell) : base(scriptName) + public spell_item_trinket_stack(uint stackSpell, uint triggerSpell) { _stackSpell = stackSpell; _triggerSpell = triggerSpell; } - class spell_item_trinket_stack_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public spell_item_trinket_stack_AuraScript(uint stackSpell, uint triggerSpell) - { - _stackSpell = stackSpell; - _triggerSpell = triggerSpell; - } - - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(_stackSpell, _triggerSpell); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - Unit caster = eventInfo.GetActor(); - - caster.CastSpell(caster, _stackSpell, true, null, aurEff); // cast the stack - - Aura dummy = caster.GetAura(_stackSpell); // retrieve aura - - //dont do anything if it's not the right amount of stacks; - if (dummy == null || dummy.GetStackAmount() < aurEff.GetAmount()) - return; - - // if right amount, remove the aura and cast real trigger - caster.RemoveAurasDueToSpell(_stackSpell); - Unit target = eventInfo.GetActionTarget(); - if (target) - caster.CastSpell(target, _triggerSpell, true, null, aurEff); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.PeriodicTriggerSpell)); - } - - uint _stackSpell; - uint _triggerSpell; + return ValidateSpellInfo(_stackSpell, _triggerSpell); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_item_trinket_stack_AuraScript(_stackSpell, _triggerSpell); + PreventDefaultAction(); + + Unit caster = eventInfo.GetActor(); + + caster.CastSpell(caster, _stackSpell, true, null, aurEff); // cast the stack + + Aura dummy = caster.GetAura(_stackSpell); // retrieve aura + + //dont do anything if it's not the right amount of stacks; + if (dummy == null || dummy.GetStackAmount() < aurEff.GetAmount()) + return; + + // if right amount, remove the aura and cast real trigger + caster.RemoveAurasDueToSpell(_stackSpell); + Unit target = eventInfo.GetActionTarget(); + if (target) + caster.CastSpell(target, _triggerSpell, true, null, aurEff); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.PeriodicTriggerSpell)); } uint _stackSpell; @@ -3775,154 +2933,124 @@ namespace Scripts.Spells.Items } [Script] // 57345 - Darkmoon Card: Greatness - class spell_item_darkmoon_card_greatness : SpellScriptLoader + class spell_item_darkmoon_card_greatness : AuraScript { - public spell_item_darkmoon_card_greatness() : base("spell_item_darkmoon_card_greatness") { } - - class spell_item_darkmoon_card_greatness_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.DarkmoonCardStrenght, SpellIds.DarkmoonCardAgility, SpellIds.DarkmoonCardIntellect, SpellIds.DarkmoonCardVersatility); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - Unit caster = eventInfo.GetActor(); - float str = caster.GetStat(Stats.Strength); - float agi = caster.GetStat(Stats.Agility); - float intl = caster.GetStat(Stats.Intellect); - float vers = 0.0f; // caster.GetStat(STAT_VERSATILITY); - float stat = 0.0f; - - uint spellTrigger = SpellIds.DarkmoonCardStrenght; - - if (str > stat) - { - spellTrigger = SpellIds.DarkmoonCardStrenght; - stat = str; - } - - if (agi > stat) - { - spellTrigger = SpellIds.DarkmoonCardAgility; - stat = agi; - } - - if (intl > stat) - { - spellTrigger = SpellIds.DarkmoonCardIntellect; - stat = intl; - } - - if (vers > stat) - { - spellTrigger = SpellIds.DarkmoonCardVersatility; - stat = vers; - } - - caster.CastSpell(caster, spellTrigger, true, null, aurEff); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.PeriodicTriggerSpell)); - } + return ValidateSpellInfo(SpellIds.DarkmoonCardStrenght, SpellIds.DarkmoonCardAgility, SpellIds.DarkmoonCardIntellect, SpellIds.DarkmoonCardVersatility); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_item_darkmoon_card_greatness_AuraScript(); + PreventDefaultAction(); + + Unit caster = eventInfo.GetActor(); + float str = caster.GetStat(Stats.Strength); + float agi = caster.GetStat(Stats.Agility); + float intl = caster.GetStat(Stats.Intellect); + float vers = 0.0f; // caster.GetStat(STAT_VERSATILITY); + float stat = 0.0f; + + uint spellTrigger = SpellIds.DarkmoonCardStrenght; + + if (str > stat) + { + spellTrigger = SpellIds.DarkmoonCardStrenght; + stat = str; + } + + if (agi > stat) + { + spellTrigger = SpellIds.DarkmoonCardAgility; + stat = agi; + } + + if (intl > stat) + { + spellTrigger = SpellIds.DarkmoonCardIntellect; + stat = intl; + } + + if (vers > stat) + { + spellTrigger = SpellIds.DarkmoonCardVersatility; + stat = vers; + } + + caster.CastSpell(caster, spellTrigger, true, null, aurEff); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.PeriodicTriggerSpell)); } } [Script] // 27522, 40336 - Mana Drain - class spell_item_mana_drain : SpellScriptLoader + class spell_item_mana_drain : AuraScript { - public spell_item_mana_drain() : base("spell_item_mana_drain") { } - - class spell_item_mana_drain_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ManaDrainEnergize, SpellIds.ManaDrainLeech); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - Unit caster = eventInfo.GetActor(); - Unit target = eventInfo.GetActionTarget(); - - if (caster.IsAlive()) - caster.CastSpell(caster, SpellIds.ManaDrainEnergize, true, null, aurEff); - - if (target && target.IsAlive()) - caster.CastSpell(target, SpellIds.ManaDrainLeech, true, null, aurEff); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.PeriodicTriggerSpell)); - } + return ValidateSpellInfo(SpellIds.ManaDrainEnergize, SpellIds.ManaDrainLeech); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_item_mana_drain_AuraScript(); + PreventDefaultAction(); + + Unit caster = eventInfo.GetActor(); + Unit target = eventInfo.GetActionTarget(); + + if (caster.IsAlive()) + caster.CastSpell(caster, SpellIds.ManaDrainEnergize, true, null, aurEff); + + if (target && target.IsAlive()) + caster.CastSpell(target, SpellIds.ManaDrainLeech, true, null, aurEff); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.PeriodicTriggerSpell)); } } [Script] // 51640 - Taunt Flag Targeting - class spell_item_taunt_flag_targeting : SpellScriptLoader + class spell_item_taunt_flag_targeting : SpellScript { - public spell_item_taunt_flag_targeting() : base("spell_item_taunt_flag_targeting") { } - - class spell_item_taunt_flag_targeting_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return CliDB.BroadcastTextStorage.ContainsKey(TextIds.EmotePlantsFlag) && ValidateSpellInfo(SpellIds.TauntFlag); - } - - void FilterTargets(List targets) - { - targets.RemoveAll(obj => - { - return !obj.IsTypeId(TypeId.Player) && !obj.IsTypeId(TypeId.Corpse); - }); - - if (targets.Empty()) - { - FinishCast(SpellCastResult.NoValidTargets); - return; - } - - targets.RandomResize(1); - } - - void HandleDummy(uint effIndex) - { - // we *really* want the unit implementation here - // it sends a packet like seen on sniff - GetCaster().TextEmote(TextIds.EmotePlantsFlag, GetHitUnit(), false); - - GetCaster().CastSpell(GetHitUnit(), SpellIds.TauntFlag, true); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.CorpseSrcAreaEnemy)); - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return CliDB.BroadcastTextStorage.ContainsKey(TextIds.EmotePlantsFlag) && ValidateSpellInfo(SpellIds.TauntFlag); } - public override SpellScript GetSpellScript() + void FilterTargets(List targets) { - return new spell_item_taunt_flag_targeting_SpellScript(); + targets.RemoveAll(obj => + { + return !obj.IsTypeId(TypeId.Player) && !obj.IsTypeId(TypeId.Corpse); + }); + + if (targets.Empty()) + { + FinishCast(SpellCastResult.NoValidTargets); + return; + } + + targets.RandomResize(1); + } + + void HandleDummy(uint effIndex) + { + // we *really* want the unit implementation here + // it sends a packet like seen on sniff + GetCaster().TextEmote(TextIds.EmotePlantsFlag, GetHitUnit(), false); + + GetCaster().CastSpell(GetHitUnit(), SpellIds.TauntFlag, true); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.CorpseSrcAreaEnemy)); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -3932,243 +3060,168 @@ namespace Scripts.Spells.Items // 24661 - Restless Strength [Script("spell_item_unstable_power", SpellIds.UnstablePowerAuraStack)] [Script("spell_item_restless_strength", SpellIds.RestlessStrengthAuraStack)] - class spell_item_zandalarian_charm : SpellScriptLoader + class spell_item_zandalarian_charm : AuraScript { - public spell_item_zandalarian_charm(string ScriptName, uint SpellId) : base(ScriptName) + public spell_item_zandalarian_charm(uint SpellId) { _spellId = SpellId; } - class spell_item_zandalarian_charm_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public spell_item_zandalarian_charm_AuraScript(uint SpellId) - { - _spellId = SpellId; - } - - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(_spellId); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - SpellInfo spellInfo = eventInfo.GetSpellInfo(); - if (spellInfo != null) - if (spellInfo.Id != m_scriptSpellId) - return true; - - return false; - } - - void HandleStackDrop(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - GetTarget().RemoveAuraFromStack(_spellId); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleStackDrop, 0, AuraType.Dummy)); - } - - uint _spellId; + return ValidateSpellInfo(_spellId); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_item_zandalarian_charm_AuraScript(_spellId); + SpellInfo spellInfo = eventInfo.GetSpellInfo(); + if (spellInfo != null) + if (spellInfo.Id != m_scriptSpellId) + return true; + + return false; + } + + void HandleStackDrop(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + GetTarget().RemoveAuraFromStack(_spellId); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleStackDrop, 0, AuraType.Dummy)); } uint _spellId; } [Script] - class spell_item_artifical_stamina : SpellScriptLoader + class spell_item_artifical_stamina : AuraScript { - public spell_item_artifical_stamina() : base("spell_item_artifical_stamina") { } - - class spell_item_artifical_stamina_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return spellInfo.GetEffect(1) != null; - } - - public override bool Load() - { - return GetOwner().IsTypeId(TypeId.Player); - } - - void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) - { - Item artifact = GetOwner().ToPlayer().GetItemByGuid(GetAura().GetCastItemGUID()); - if (artifact) - amount = (int)(GetSpellInfo().GetEffect(1).BasePoints * artifact.GetTotalPurchasedArtifactPowers() / 100); - } - - public override void Register() - { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.ModTotalStatPercentage)); - } + return spellInfo.GetEffect(1) != null; } - public override AuraScript GetAuraScript() + public override bool Load() { - return new spell_item_artifical_stamina_AuraScript(); + return GetOwner().IsTypeId(TypeId.Player); + } + + void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Item artifact = GetOwner().ToPlayer().GetItemByGuid(GetAura().GetCastItemGUID()); + if (artifact) + amount = (int)(GetSpellInfo().GetEffect(1).BasePoints * artifact.GetTotalPurchasedArtifactPowers() / 100); + } + + public override void Register() + { + DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.ModTotalStatPercentage)); } } [Script] - class spell_item_artifical_damage : SpellScriptLoader + class spell_item_artifical_damage : AuraScript { - public spell_item_artifical_damage() : base("spell_item_artifical_damage") { } - - class spell_item_artifical_damage_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return spellInfo.GetEffect(1) != null; - } - - public override bool Load() - { - return GetOwner().IsTypeId(TypeId.Player); - } - - void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) - { - Item artifact = GetOwner().ToPlayer().GetItemByGuid(GetAura().GetCastItemGUID()); - if (artifact) - amount = (int)(GetSpellInfo().GetEffect(1).BasePoints * artifact.GetTotalPurchasedArtifactPowers() / 100); - } - - public override void Register() - { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.ModDamagePercentDone)); - } + return spellInfo.GetEffect(1) != null; } - public override AuraScript GetAuraScript() + public override bool Load() { - return new spell_item_artifical_damage_AuraScript(); + return GetOwner().IsTypeId(TypeId.Player); + } + + void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + Item artifact = GetOwner().ToPlayer().GetItemByGuid(GetAura().GetCastItemGUID()); + if (artifact) + amount = (int)(GetSpellInfo().GetEffect(1).BasePoints * artifact.GetTotalPurchasedArtifactPowers() / 100); + } + + public override void Register() + { + DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.ModDamagePercentDone)); } } [Script] // 28200 - Ascendance - class spell_item_talisman_of_ascendance : SpellScriptLoader + class spell_item_talisman_of_ascendance : AuraScript { - public spell_item_talisman_of_ascendance() : base("spell_item_talisman_of_ascendance") { } - - class spell_item_talisman_of_ascendance_AuraScript : AuraScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.TalismanOfAscendance); - } - - void OnRemove(AuraEffect effect, AuraEffectHandleModes mode) - { - GetTarget().RemoveAurasDueToSpell(effect.GetSpellEffectInfo().TriggerSpell); - } - - public override void Register() - { - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ProcTriggerSpell, AuraEffectHandleModes.Real)); - } + return ValidateSpellInfo(SpellIds.TalismanOfAscendance); } - public override AuraScript GetAuraScript() + void OnRemove(AuraEffect effect, AuraEffectHandleModes mode) { - return new spell_item_talisman_of_ascendance_AuraScript(); + GetTarget().RemoveAurasDueToSpell(effect.GetSpellEffectInfo().TriggerSpell); + } + + public override void Register() + { + OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ProcTriggerSpell, AuraEffectHandleModes.Real)); } } [Script] // 29602 - Jom Gabbar - class spell_item_jom_gabbar : SpellScriptLoader + class spell_item_jom_gabbar : AuraScript { - public spell_item_jom_gabbar() : base("spell_item_jom_gabbar") { } - - class spell_item_jom_gabbar_AuraScript : AuraScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.JomGabbar); - } - - void OnRemove(AuraEffect effect, AuraEffectHandleModes mode) - { - GetTarget().RemoveAurasDueToSpell(effect.GetSpellEffectInfo().TriggerSpell); - } - - public override void Register() - { - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.PeriodicTriggerSpell, AuraEffectHandleModes.Real)); - } + return ValidateSpellInfo(SpellIds.JomGabbar); } - public override AuraScript GetAuraScript() + void OnRemove(AuraEffect effect, AuraEffectHandleModes mode) { - return new spell_item_jom_gabbar_AuraScript(); + GetTarget().RemoveAurasDueToSpell(effect.GetSpellEffectInfo().TriggerSpell); + } + + public override void Register() + { + OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.PeriodicTriggerSpell, AuraEffectHandleModes.Real)); } } [Script] // 45040 - Battle Trance - class spell_item_battle_trance : SpellScriptLoader + class spell_item_battle_trance : AuraScript { - public spell_item_battle_trance() : base("spell_item_battle_trance") { } - - class spell_item_battle_trance_AuraScript : AuraScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.BattleTrance); - } - - void OnRemove(AuraEffect effect, AuraEffectHandleModes mode) - { - GetTarget().RemoveAurasDueToSpell(effect.GetSpellEffectInfo().TriggerSpell); - } - - public override void Register() - { - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ProcTriggerSpell, AuraEffectHandleModes.Real)); - } + return ValidateSpellInfo(SpellIds.BattleTrance); } - public override AuraScript GetAuraScript() + void OnRemove(AuraEffect effect, AuraEffectHandleModes mode) { - return new spell_item_battle_trance_AuraScript(); + GetTarget().RemoveAurasDueToSpell(effect.GetSpellEffectInfo().TriggerSpell); + } + + public override void Register() + { + OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ProcTriggerSpell, AuraEffectHandleModes.Real)); } } [Script] // 90900 - World-Queller Focus - class spell_item_world_queller_focus : SpellScriptLoader + class spell_item_world_queller_focus : AuraScript { - public spell_item_world_queller_focus() : base("spell_item_world_queller_focus") { } - - class spell_item_world_queller_focus_AuraScript : AuraScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.WorldQuellerFocus); - } - - void OnRemove(AuraEffect effect, AuraEffectHandleModes mode) - { - GetTarget().RemoveAurasDueToSpell(effect.GetSpellEffectInfo().TriggerSpell); - } - - public override void Register() - { - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ProcTriggerSpell, AuraEffectHandleModes.Real)); - } + return ValidateSpellInfo(SpellIds.WorldQuellerFocus); } - public override AuraScript GetAuraScript() + void OnRemove(AuraEffect effect, AuraEffectHandleModes mode) { - return new spell_item_world_queller_focus_AuraScript(); + GetTarget().RemoveAurasDueToSpell(effect.GetSpellEffectInfo().TriggerSpell); + } + + public override void Register() + { + OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ProcTriggerSpell, AuraEffectHandleModes.Real)); } } @@ -4177,61 +3230,41 @@ namespace Scripts.Spells.Items // 127272 - Orange Water Strider // 127274 - Jade Water Strider [Script] // 127278 - Golden Water Strider - class spell_item_water_strider : SpellScriptLoader + class spell_item_water_strider : AuraScript { - public spell_item_water_strider() : base("spell_item_water_strider") { } - - class spell_item_water_strider_AuraScript : AuraScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.AzureWaterStrider, SpellIds.CrimsonWaterStrider, SpellIds.OrangeWaterStrider, SpellIds.JadeWaterStrider, SpellIds.GoldenWaterStrider); - } - - void OnRemove(AuraEffect effect, AuraEffectHandleModes mode) - { - GetTarget().RemoveAurasDueToSpell(GetSpellInfo().GetEffect(1).TriggerSpell); - } - - public override void Register() - { - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Mounted, AuraEffectHandleModes.Real)); - } + return ValidateSpellInfo(SpellIds.AzureWaterStrider, SpellIds.CrimsonWaterStrider, SpellIds.OrangeWaterStrider, SpellIds.JadeWaterStrider, SpellIds.GoldenWaterStrider); } - public override AuraScript GetAuraScript() + void OnRemove(AuraEffect effect, AuraEffectHandleModes mode) { - return new spell_item_water_strider_AuraScript(); + GetTarget().RemoveAurasDueToSpell(GetSpellInfo().GetEffect(1).TriggerSpell); + } + + public override void Register() + { + OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.Mounted, AuraEffectHandleModes.Real)); } } // 144671 - Brutal Kinship [Script] // 145738 - Brutal Kinship - class spell_item_brutal_kinship : SpellScriptLoader + class spell_item_brutal_kinship : AuraScript { - public spell_item_brutal_kinship() : base("spell_item_brutal_kinship") { } - - class spell_item_brutal_kinship_AuraScript : AuraScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.BrutalKinship1, SpellIds.BrutalKinship2); - } - - void OnRemove(AuraEffect effect, AuraEffectHandleModes mode) - { - GetTarget().RemoveAurasDueToSpell(effect.GetSpellEffectInfo().TriggerSpell); - } - - public override void Register() - { - OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ProcTriggerSpell, AuraEffectHandleModes.Real)); - } + return ValidateSpellInfo(SpellIds.BrutalKinship1, SpellIds.BrutalKinship2); } - public override AuraScript GetAuraScript() + void OnRemove(AuraEffect effect, AuraEffectHandleModes mode) { - return new spell_item_brutal_kinship_AuraScript(); + GetTarget().RemoveAurasDueToSpell(effect.GetSpellEffectInfo().TriggerSpell); + } + + public override void Register() + { + OnEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ProcTriggerSpell, AuraEffectHandleModes.Real)); } } } diff --git a/Scripts/Spells/Mage.cs b/Scripts/Spells/Mage.cs index f57e91fea..cfd4cfef1 100644 --- a/Scripts/Spells/Mage.cs +++ b/Scripts/Spells/Mage.cs @@ -72,665 +72,488 @@ namespace Scripts.Spells.Mage } [Script] // 235313 - Blazing Barrier - class spell_mage_blazing_barrier : SpellScriptLoader + class spell_mage_blazing_barrier : AuraScript { - public spell_mage_blazing_barrier() : base("spell_mage_blazing_barrier") { } - - class spell_mage_blazing_barrier_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.BlazingBarrierTrigger); - } - - void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) - { - canBeRecalculated = false; - Unit caster = GetCaster(); - if (caster) - amount = (int)(caster.SpellBaseHealingBonusDone(GetSpellInfo().GetSchoolMask()) * 7.0f); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - Unit caster = eventInfo.GetDamageInfo().GetVictim(); - Unit target = eventInfo.GetDamageInfo().GetAttacker(); - - if (caster && target) - caster.CastSpell(target, SpellIds.BlazingBarrierTrigger, true); - } - - public override void Register() - { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.SchoolAbsorb)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.ProcTriggerSpell)); - } + return ValidateSpellInfo(SpellIds.BlazingBarrierTrigger); } - public override AuraScript GetAuraScript() + void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) { - return new spell_mage_blazing_barrier_AuraScript(); + canBeRecalculated = false; + Unit caster = GetCaster(); + if (caster) + amount = (int)(caster.SpellBaseHealingBonusDone(GetSpellInfo().GetSchoolMask()) * 7.0f); + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + Unit caster = eventInfo.GetDamageInfo().GetVictim(); + Unit target = eventInfo.GetDamageInfo().GetAttacker(); + + if (caster && target) + caster.CastSpell(target, SpellIds.BlazingBarrierTrigger, true); + } + + public override void Register() + { + DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.SchoolAbsorb)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.ProcTriggerSpell)); } } [Script] // 198063 - Burning Determination - class spell_mage_burning_determination : SpellScriptLoader + class spell_mage_burning_determination : AuraScript { - public spell_mage_burning_determination() : base("spell_mage_burning_determination") { } - - class spell_mage_burning_determination_AuraScript : AuraScript + bool CheckProc(ProcEventInfo eventInfo) { - bool CheckProc(ProcEventInfo eventInfo) - { - SpellInfo spellInfo = eventInfo.GetSpellInfo(); - if (spellInfo != null) - if (spellInfo.GetAllEffectsMechanicMask().HasAnyFlag((uint)((1 << (int)Mechanics.Interrupt) | (1 << (int)Mechanics.Silence)))) - return true; + SpellInfo spellInfo = eventInfo.GetSpellInfo(); + if (spellInfo != null) + if (spellInfo.GetAllEffectsMechanicMask().HasAnyFlag((uint)((1 << (int)Mechanics.Interrupt) | (1 << (int)Mechanics.Silence)))) + return true; - return false; - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - } + return false; } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_mage_burning_determination_AuraScript(); + DoCheckProc.Add(new CheckProcHandler(CheckProc)); } } // 11958 - Cold Snap [Script] - class spell_mage_cold_snap : SpellScriptLoader + class spell_mage_cold_snap : SpellScript { - public spell_mage_cold_snap() : base("spell_mage_cold_snap") { } - - class spell_mage_cold_snap_SpellScript : SpellScript + public override bool Load() { - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Player); - } - - void HandleDummy(uint effIndex) - { - GetCaster().GetSpellHistory().ResetCooldowns(p => - { - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(p.Key); - return spellInfo.SpellFamilyName == SpellFamilyNames.Mage && spellInfo.GetSchoolMask().HasAnyFlag(SpellSchoolMask.Frost) && - spellInfo.Id != SpellIds.ColdSnap && spellInfo.GetRecoveryTime() > 0; - }, true); - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return GetCaster().IsTypeId(TypeId.Player); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_mage_cold_snap_SpellScript(); + GetCaster().GetSpellHistory().ResetCooldowns(p => + { + SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(p.Key); + return spellInfo.SpellFamilyName == SpellFamilyNames.Mage && spellInfo.GetSchoolMask().HasAnyFlag(SpellSchoolMask.Frost) && + spellInfo.Id != SpellIds.ColdSnap && spellInfo.GetRecoveryTime() > 0; + }, true); + } + + public override void Register() + { + OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } - + // Updated 4.3.4 [Script] // 120 - Cone of Cold - class spell_mage_cone_of_cold : SpellScriptLoader + class spell_mage_cone_of_cold : SpellScript { - public spell_mage_cone_of_cold() : base("spell_mage_cone_of_cold") { } - - class spell_mage_cone_of_cold_SpellScript : SpellScript + void HandleConeOfColdScript(uint effIndex) { - void HandleConeOfColdScript(uint effIndex) + Unit caster = GetCaster(); + Unit unitTarget = GetHitUnit(); + if (unitTarget) { - Unit caster = GetCaster(); - Unit unitTarget = GetHitUnit(); - if (unitTarget) - { - if (caster.HasAura(SpellIds.ConeOfColdAuraR1)) // Improved Cone of Cold Rank 1 - unitTarget.CastSpell(unitTarget, SpellIds.ConeOfColdTriggerR1, true); - else if (caster.HasAura(SpellIds.ConeOfColdAuraR2)) // Improved Cone of Cold Rank 2 - unitTarget.CastSpell(unitTarget, SpellIds.ConeOfColdTriggerR2, true); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleConeOfColdScript, 0, SpellEffectName.ApplyAura)); + if (caster.HasAura(SpellIds.ConeOfColdAuraR1)) // Improved Cone of Cold Rank 1 + unitTarget.CastSpell(unitTarget, SpellIds.ConeOfColdTriggerR1, true); + else if (caster.HasAura(SpellIds.ConeOfColdAuraR2)) // Improved Cone of Cold Rank 2 + unitTarget.CastSpell(unitTarget, SpellIds.ConeOfColdTriggerR2, true); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_mage_cone_of_cold_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleConeOfColdScript, 0, SpellEffectName.ApplyAura)); } } - [Script] // 190336 - Conjure Refreshment - class spell_mage_conjure_refreshment : SpellScriptLoader + class spell_mage_conjure_refreshment : SpellScript { - public spell_mage_conjure_refreshment() : base("spell_mage_conjure_refreshment") { } - - class spell_mage_conjure_refreshment_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ConjureRefreshment, SpellIds.ConjureRefreshmentTable); - } + return ValidateSpellInfo(SpellIds.ConjureRefreshment, SpellIds.ConjureRefreshmentTable); + } - void HandleDummy(uint effIndex) + void HandleDummy(uint effIndex) + { + Player caster = GetCaster().ToPlayer(); + if (caster) { - Player caster = GetCaster().ToPlayer(); - if (caster) - { - Group group = caster.GetGroup(); - if (group) - caster.CastSpell(caster, SpellIds.ConjureRefreshmentTable, true); - else - caster.CastSpell(caster, SpellIds.ConjureRefreshment, true); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + Group group = caster.GetGroup(); + if (group) + caster.CastSpell(caster, SpellIds.ConjureRefreshmentTable, true); + else + caster.CastSpell(caster, SpellIds.ConjureRefreshment, true); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_mage_conjure_refreshment_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } // 54646 - Focus Magic [Script] - class spell_mage_focus_magic : SpellScriptLoader + class spell_mage_focus_magic : AuraScript { - public spell_mage_focus_magic() : base("spell_mage_focus_magic") { } - - class spell_mage_focus_magic_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.FocusMagicProc); - } - - public override bool Load() - { - _procTarget = null; - return true; - } - - bool CheckProc(ProcEventInfo eventInfo) - { - _procTarget = GetCaster(); - return _procTarget && _procTarget.IsAlive(); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - GetTarget().CastSpell(_procTarget, SpellIds.FocusMagicProc, true, null, aurEff); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ModSpellCritChance)); - } - - Unit _procTarget; + return ValidateSpellInfo(SpellIds.FocusMagicProc); } - public override AuraScript GetAuraScript() + public override bool Load() { - return new spell_mage_focus_magic_AuraScript(); + _procTarget = null; + return true; } + + bool CheckProc(ProcEventInfo eventInfo) + { + _procTarget = GetCaster(); + return _procTarget && _procTarget.IsAlive(); + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + GetTarget().CastSpell(_procTarget, SpellIds.FocusMagicProc, true, null, aurEff); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ModSpellCritChance)); + } + + Unit _procTarget; } [Script] // 195283 - Hot Streak - class spell_mage_hot_streak : SpellScriptLoader + class spell_mage_hot_streak : AuraScript { - public spell_mage_hot_streak() : base("spell_mage_hot_streak") { } - - class spell_mage_hot_streak_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return true; - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return true; } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_mage_hot_streak_AuraScript(); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } // 56374 - Glyph of Icy Veins [Script] - class spell_mage_glyph_of_icy_veins : SpellScriptLoader + class spell_mage_glyph_of_icy_veins : AuraScript { - public spell_mage_glyph_of_icy_veins() : base("spell_mage_glyph_of_icy_veins") { } - - class spell_mage_glyph_of_icy_veins_AuraScript : AuraScript + void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); + PreventDefaultAction(); - GetTarget().RemoveAurasByType(AuraType.HasteSpells, ObjectGuid.Empty, null, true, false); - GetTarget().RemoveAurasByType(AuraType.ModDecreaseSpeed); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); - } + GetTarget().RemoveAurasByType(AuraType.HasteSpells, ObjectGuid.Empty, null, true, false); + GetTarget().RemoveAurasByType(AuraType.ModDecreaseSpeed); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_mage_glyph_of_icy_veins_AuraScript(); + OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); } } // 56375 - Glyph of Polymorph [Script] - class spell_mage_glyph_of_polymorph : SpellScriptLoader + class spell_mage_glyph_of_polymorph : AuraScript { - public spell_mage_glyph_of_polymorph() : base("spell_mage_glyph_of_polymorph") { } - - class spell_mage_glyph_of_polymorph_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.PriestShadowWordDeath); - } - - void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - Unit target = eventInfo.GetProcTarget(); - - target.RemoveAurasByType(AuraType.PeriodicDamage, ObjectGuid.Empty, target.GetAura(SpellIds.PriestShadowWordDeath)); // SW:D shall not be removed. - target.RemoveAurasByType(AuraType.PeriodicDamagePercent); - target.RemoveAurasByType(AuraType.PeriodicLeech); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.PriestShadowWordDeath); } - public override AuraScript GetAuraScript() + void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_mage_glyph_of_polymorph_AuraScript(); + PreventDefaultAction(); + Unit target = eventInfo.GetProcTarget(); + + target.RemoveAurasByType(AuraType.PeriodicDamage, ObjectGuid.Empty, target.GetAura(SpellIds.PriestShadowWordDeath)); // SW:D shall not be removed. + target.RemoveAurasByType(AuraType.PeriodicDamagePercent); + target.RemoveAurasByType(AuraType.PeriodicLeech); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); } } // 37447 - Improved Mana Gems [Script] // 61062 - Improved Mana Gems - class spell_mage_imp_mana_gems : SpellScriptLoader + class spell_mage_imp_mana_gems : AuraScript { - public spell_mage_imp_mana_gems() : base("spell_mage_imp_mana_gems") { } - - class spell_mage_imp_mana_gems_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ManaSurge); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - eventInfo.GetActor().CastSpell((Unit)null, SpellIds.ManaSurge, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.OverrideClassScripts)); - } + return ValidateSpellInfo(SpellIds.ManaSurge); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_mage_imp_mana_gems_AuraScript(); + PreventDefaultAction(); + eventInfo.GetActor().CastSpell((Unit)null, SpellIds.ManaSurge, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.OverrideClassScripts)); } } // 44457 - Living Bomb [Script] - class spell_mage_living_bomb : SpellScriptLoader + class spell_mage_living_bomb : AuraScript { - public spell_mage_living_bomb() : base("spell_mage_living_bomb") { } - - class spell_mage_living_bomb_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo((uint)spellInfo.GetEffect(1).CalcValue()); - } - - void AfterRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - AuraRemoveMode removeMode = GetTargetApplication().GetRemoveMode(); - if (removeMode != AuraRemoveMode.EnemySpell && removeMode != AuraRemoveMode.Expire) - return; - Unit caster = GetCaster(); - if (caster) - caster.CastSpell(GetTarget(), (uint)aurEff.GetAmount(), true, null, aurEff); - } - - public override void Register() - { - AfterEffectRemove.Add(new EffectApplyHandler(AfterRemove, 1, AuraType.Dummy, AuraEffectHandleModes.Real)); - } + return ValidateSpellInfo((uint)spellInfo.GetEffect(1).CalcValue()); } - public override AuraScript GetAuraScript() + void AfterRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_mage_living_bomb_AuraScript(); + AuraRemoveMode removeMode = GetTargetApplication().GetRemoveMode(); + if (removeMode != AuraRemoveMode.EnemySpell && removeMode != AuraRemoveMode.Expire) + return; + Unit caster = GetCaster(); + if (caster) + caster.CastSpell(GetTarget(), (uint)aurEff.GetAmount(), true, null, aurEff); + } + + public override void Register() + { + AfterEffectRemove.Add(new EffectApplyHandler(AfterRemove, 1, AuraType.Dummy, AuraEffectHandleModes.Real)); } } - + [Script] // 11426 - Ice Barrier - class spell_mage_ice_barrier : SpellScriptLoader + class spell_mage_ice_barrier : AuraScript { - public spell_mage_ice_barrier() : base("spell_mage_ice_barrier") { } - - class spell_mage_ice_barrier_AuraScript : AuraScript + public override bool Validate(SpellInfo spellEntry) { - public override bool Validate(SpellInfo spellEntry) - { - return ValidateSpellInfo(SpellIds.Chilled); - } - - void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) - { - canBeRecalculated = false; - Unit caster = GetCaster(); - if (caster) - amount += (int)(caster.SpellBaseHealingBonusDone(GetSpellInfo().GetSchoolMask()) * 10.0f); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - Unit caster = eventInfo.GetDamageInfo().GetVictim(); - Unit target = eventInfo.GetDamageInfo().GetAttacker(); - - if (caster && target) - caster.CastSpell(target, SpellIds.Chilled, true); - } - - public override void Register() - { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.SchoolAbsorb)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.SchoolAbsorb)); - } + return ValidateSpellInfo(SpellIds.Chilled); } - public override AuraScript GetAuraScript() + void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) { - return new spell_mage_ice_barrier_AuraScript(); + canBeRecalculated = false; + Unit caster = GetCaster(); + if (caster) + amount += (int)(caster.SpellBaseHealingBonusDone(GetSpellInfo().GetSchoolMask()) * 10.0f); + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + Unit caster = eventInfo.GetDamageInfo().GetVictim(); + Unit target = eventInfo.GetDamageInfo().GetAttacker(); + + if (caster && target) + caster.CastSpell(target, SpellIds.Chilled, true); + } + + public override void Register() + { + DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.SchoolAbsorb)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.SchoolAbsorb)); } } // -11119 - Ignite [Script] - class spell_mage_ignite : SpellScriptLoader + class spell_mage_ignite : AuraScript { - public spell_mage_ignite() : base("spell_mage_ignite") { } - - class spell_mage_ignite_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.Ignite); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - return eventInfo.GetProcTarget(); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - SpellInfo igniteDot = Global.SpellMgr.GetSpellInfo(SpellIds.Ignite); - int pct = 8 * GetSpellInfo().GetRank(); - - int amount = (int)(MathFunctions.CalculatePct(eventInfo.GetDamageInfo().GetDamage(), pct) / igniteDot.GetMaxTicks(Difficulty.None)); - amount += (int)eventInfo.GetProcTarget().GetRemainingPeriodicAmount(eventInfo.GetActor().GetGUID(), SpellIds.Ignite, AuraType.PeriodicDamage); - GetTarget().CastCustomSpell(SpellIds.Ignite, SpellValueMod.BasePoint0, amount, eventInfo.GetProcTarget(), true, null, aurEff); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.Ignite); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_mage_ignite_AuraScript(); + return eventInfo.GetProcTarget(); + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + + SpellInfo igniteDot = Global.SpellMgr.GetSpellInfo(SpellIds.Ignite); + int pct = 8 * GetSpellInfo().GetRank(); + + int amount = (int)(MathFunctions.CalculatePct(eventInfo.GetDamageInfo().GetDamage(), pct) / igniteDot.GetMaxTicks(Difficulty.None)); + amount += (int)eventInfo.GetProcTarget().GetRemainingPeriodicAmount(eventInfo.GetActor().GetGUID(), SpellIds.Ignite, AuraType.PeriodicDamage); + GetTarget().CastCustomSpell(SpellIds.Ignite, SpellValueMod.BasePoint0, amount, eventInfo.GetProcTarget(), true, null, aurEff); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } // -29074 - Master of Elements [Script] - class spell_mage_master_of_elements : SpellScriptLoader + class spell_mage_master_of_elements : AuraScript { - public spell_mage_master_of_elements() : base("spell_mage_master_of_elements") { } - - class spell_mage_master_of_elements_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.MasterOfElementsEnergize); - } + return ValidateSpellInfo(SpellIds.MasterOfElementsEnergize); + } - bool CheckProc(ProcEventInfo eventInfo) - { - return eventInfo.GetDamageInfo().GetSpellInfo() != null; // eventInfo.GetSpellInfo() - } + bool CheckProc(ProcEventInfo eventInfo) + { + return eventInfo.GetDamageInfo().GetSpellInfo() != null; // eventInfo.GetSpellInfo() + } - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); - var costs = eventInfo.GetDamageInfo().GetSpellInfo().CalcPowerCost(GetTarget(), eventInfo.GetDamageInfo().GetSchoolMask()); - var m = costs.Find(cost => cost.Power == PowerType.Mana); - if (m != null) - { - int mana = MathFunctions.CalculatePct(m.Amount, aurEff.GetAmount()); - if (mana > 0) - GetTarget().CastCustomSpell(SpellIds.MasterOfElementsEnergize, SpellValueMod.BasePoint0, mana, GetTarget(), true, null, aurEff); - } - } - - public override void Register() + var costs = eventInfo.GetDamageInfo().GetSpellInfo().CalcPowerCost(GetTarget(), eventInfo.GetDamageInfo().GetSchoolMask()); + var m = costs.Find(cost => cost.Power == PowerType.Mana); + if (m != null) { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + int mana = MathFunctions.CalculatePct(m.Amount, aurEff.GetAmount()); + if (mana > 0) + GetTarget().CastCustomSpell(SpellIds.MasterOfElementsEnergize, SpellValueMod.BasePoint0, mana, GetTarget(), true, null, aurEff); } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_mage_master_of_elements_AuraScript(); + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } // 86181 - Nether Vortex [Script] - class spell_mage_nether_vortex : SpellScriptLoader + class spell_mage_nether_vortex : AuraScript { - public spell_mage_nether_vortex() : base("spell_mage_nether_vortex") { } - - class spell_mage_nether_vortex_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.Slow); - } - - bool DoCheck(ProcEventInfo eventInfo) - { - Aura aura = eventInfo.GetProcTarget().GetAura(SpellIds.Slow); - if (aura != null) - if (aura.GetCasterGUID() != GetTarget().GetGUID()) - return false; - - return true; - } - - void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.Slow, true, null, aurEff); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(DoCheck)); - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.Slow); } - public override AuraScript GetAuraScript() + bool DoCheck(ProcEventInfo eventInfo) { - return new spell_mage_nether_vortex_AuraScript(); + Aura aura = eventInfo.GetProcTarget().GetAura(SpellIds.Slow); + if (aura != null) + if (aura.GetCasterGUID() != GetTarget().GetGUID()) + return false; + + return true; + } + + void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.Slow, true, null, aurEff); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(DoCheck)); + OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); } } // -11175 - Permafrost [Script] - class spell_mage_permafrost : SpellScriptLoader + class spell_mage_permafrost : AuraScript { - public spell_mage_permafrost() : base("spell_mage_permafrost") { } - - class spell_mage_permafrost_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.Permafrost); - } - - bool DoCheck(ProcEventInfo eventInfo) - { - return GetTarget().GetGuardianPet() && eventInfo.GetDamageInfo().GetDamage() != 0; - } - - void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - int heal = (int)(MathFunctions.CalculatePct(eventInfo.GetDamageInfo().GetDamage(), aurEff.GetAmount())); - GetTarget().CastCustomSpell(SpellIds.Permafrost, SpellValueMod.BasePoint0, heal, null, true, null, aurEff); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(DoCheck)); - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.Permafrost); } - public override AuraScript GetAuraScript() + bool DoCheck(ProcEventInfo eventInfo) { - return new spell_mage_permafrost_AuraScript(); + return GetTarget().GetGuardianPet() && eventInfo.GetDamageInfo().GetDamage() != 0; + } + + void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + + int heal = (int)(MathFunctions.CalculatePct(eventInfo.GetDamageInfo().GetDamage(), aurEff.GetAmount())); + GetTarget().CastCustomSpell(SpellIds.Permafrost, SpellValueMod.BasePoint0, heal, null, true, null, aurEff); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(DoCheck)); + OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); } } // 118 - Polymorph [Script] - class spell_mage_polymorph : SpellScriptLoader + class spell_mage_polymorph : AuraScript { - public spell_mage_polymorph() : base("spell_mage_polymorph") { } - - class spell_mage_polymorph_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ImprovedPolymorphRank1, SpellIds.ImprovedPolymorphStunRank1, SpellIds.ImprovedPolymorphMarker); - } - - public override bool Load() - { - _caster = null; - return true; - } - - bool DoCheck(ProcEventInfo eventInfo) - { - _caster = GetCaster(); - return _caster && eventInfo.GetDamageInfo() != null; - } - - void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - // Improved Polymorph - AuraEffect improvedPolymorph = _caster.GetAuraEffectOfRankedSpell(SpellIds.ImprovedPolymorphRank1, 0); - if (improvedPolymorph != null) - { - if (_caster.HasAura(SpellIds.ImprovedPolymorphMarker)) - return; - - GetTarget().CastSpell(GetTarget(), Global.SpellMgr.GetSpellWithRank(SpellIds.ImprovedPolymorphStunRank1, improvedPolymorph.GetSpellInfo().GetRank()), true, null, aurEff); - _caster.CastSpell(_caster, SpellIds.ImprovedPolymorphMarker, true, null, aurEff); - } - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(DoCheck)); - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.ModConfuse)); - } - - Unit _caster; + return ValidateSpellInfo(SpellIds.ImprovedPolymorphRank1, SpellIds.ImprovedPolymorphStunRank1, SpellIds.ImprovedPolymorphMarker); } - public override AuraScript GetAuraScript() + public override bool Load() { - return new spell_mage_polymorph_AuraScript(); + _caster = null; + return true; } + + bool DoCheck(ProcEventInfo eventInfo) + { + _caster = GetCaster(); + return _caster && eventInfo.GetDamageInfo() != null; + } + + void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + // Improved Polymorph + AuraEffect improvedPolymorph = _caster.GetAuraEffectOfRankedSpell(SpellIds.ImprovedPolymorphRank1, 0); + if (improvedPolymorph != null) + { + if (_caster.HasAura(SpellIds.ImprovedPolymorphMarker)) + return; + + GetTarget().CastSpell(GetTarget(), Global.SpellMgr.GetSpellWithRank(SpellIds.ImprovedPolymorphStunRank1, improvedPolymorph.GetSpellInfo().GetRank()), true, null, aurEff); + _caster.CastSpell(_caster, SpellIds.ImprovedPolymorphMarker, true, null, aurEff); + } + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(DoCheck)); + OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.ModConfuse)); + } + + Unit _caster; } // @todo move out of here and rename - not a mage spell // 32826 - Polymorph (Visual) [Script] - class spell_mage_polymorph_cast_visual : SpellScriptLoader + class spell_mage_polymorph_cast_visual : SpellScript { - public spell_mage_polymorph_cast_visual() : base("spell_mage_polymorph_visual") { } - - const uint NPC_AUROSALIA = 18744; - - class spell_mage_polymorph_cast_visual_SpellScript : SpellScript + uint[] PolymorhForms = { - uint[] PolymorhForms = - { SpellIds.SquirrelForm, SpellIds.GiraffeForm, SpellIds.SerpentForm, @@ -739,293 +562,225 @@ namespace Scripts.Spells.Mage SpellIds.SheepForm }; - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(PolymorhForms); - } - - void HandleDummy(uint effIndex) - { - Unit target = GetCaster().FindNearestCreature(NPC_AUROSALIA, 30.0f); - if (target) - if (target.IsTypeId(TypeId.Unit)) - target.CastSpell(target, PolymorhForms[RandomHelper.IRand(0, 5)], true); - } - - public override void Register() - { - // add dummy effect spell handler to Polymorph visual - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } - } - - public override SpellScript GetSpellScript() + public override bool Validate(SpellInfo spellInfo) { - return new spell_mage_polymorph_cast_visual_SpellScript(); + return ValidateSpellInfo(PolymorhForms); } + + void HandleDummy(uint effIndex) + { + Unit target = GetCaster().FindNearestCreature(NPC_AUROSALIA, 30.0f); + if (target) + if (target.IsTypeId(TypeId.Unit)) + target.CastSpell(target, PolymorhForms[RandomHelper.IRand(0, 5)], true); + } + + public override void Register() + { + // add dummy effect spell handler to Polymorph visual + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + } + + const uint NPC_AUROSALIA = 18744; } [Script] // 235450 - Prismatic Barrier - class spell_mage_prismatic_barrier : SpellScriptLoader + class spell_mage_prismatic_barrier : AuraScript { - public spell_mage_prismatic_barrier() : base("spell_mage_prismatic_barrier") { } - - class spell_mage_prismatic_barrier_AuraScript : AuraScript + void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) { - void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) - { - canBeRecalculated = false; - Unit caster = GetCaster(); - if (caster) - amount += (int)(caster.SpellBaseHealingBonusDone(GetSpellInfo().GetSchoolMask()) * 7.0f); - } - - public override void Register() - { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.SchoolAbsorb)); - } + canBeRecalculated = false; + Unit caster = GetCaster(); + if (caster) + amount += (int)(caster.SpellBaseHealingBonusDone(GetSpellInfo().GetSchoolMask()) * 7.0f); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_mage_prismatic_barrier_AuraScript(); + DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.SchoolAbsorb)); } } // 82676 - Ring of Frost // Updated 4.3.4 [Script] - class spell_mage_ring_of_frost : SpellScriptLoader + class spell_mage_ring_of_frost : AuraScript { - public spell_mage_ring_of_frost() : base("spell_mage_ring_of_frost") { } - - class spell_mage_ring_of_frost_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.RingOfFrostSummon, SpellIds.RingOfFrostFreeze, SpellIds.RingOfFrostDummy); - } + return ValidateSpellInfo(SpellIds.RingOfFrostSummon, SpellIds.RingOfFrostFreeze, SpellIds.RingOfFrostDummy); + } - public override bool Load() - { - ringOfFrost = null; - return true; - } + public override bool Load() + { + ringOfFrost = null; + return true; + } - void HandleEffectPeriodic(AuraEffect aurEff) - { - if (ringOfFrost) - if (GetMaxDuration() - (int)ringOfFrost.GetTimer() >= Global.SpellMgr.GetSpellInfo(SpellIds.RingOfFrostDummy).GetDuration()) - GetTarget().CastSpell(ringOfFrost.GetPositionX(), ringOfFrost.GetPositionY(), ringOfFrost.GetPositionZ(), SpellIds.RingOfFrostFreeze, true); - } + void HandleEffectPeriodic(AuraEffect aurEff) + { + if (ringOfFrost) + if (GetMaxDuration() - (int)ringOfFrost.GetTimer() >= Global.SpellMgr.GetSpellInfo(SpellIds.RingOfFrostDummy).GetDuration()) + GetTarget().CastSpell(ringOfFrost.GetPositionX(), ringOfFrost.GetPositionY(), ringOfFrost.GetPositionZ(), SpellIds.RingOfFrostFreeze, true); + } - void Apply(AuraEffect aurEff, AuraEffectHandleModes mode) - { - List MinionList = new List(); - GetTarget().GetAllMinionsByEntry(MinionList, (uint)GetSpellInfo().GetEffect(0).MiscValue); + void Apply(AuraEffect aurEff, AuraEffectHandleModes mode) + { + List MinionList = new List(); + GetTarget().GetAllMinionsByEntry(MinionList, (uint)GetSpellInfo().GetEffect(0).MiscValue); - // Get the last summoned RoF, save it and despawn older ones - foreach (var creature in MinionList) + // Get the last summoned RoF, save it and despawn older ones + foreach (var creature in MinionList) + { + TempSummon summon = creature.ToTempSummon(); + + if (ringOfFrost && summon) { - TempSummon summon = creature.ToTempSummon(); - - if (ringOfFrost && summon) + if (summon.GetTimer() > ringOfFrost.GetTimer()) { - if (summon.GetTimer() > ringOfFrost.GetTimer()) - { - ringOfFrost.DespawnOrUnsummon(); - ringOfFrost = summon; - } - else - summon.DespawnOrUnsummon(); - } - else if (summon) + ringOfFrost.DespawnOrUnsummon(); ringOfFrost = summon; + } + else + summon.DespawnOrUnsummon(); } - } - - TempSummon ringOfFrost; - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 1, AuraType.ProcTriggerSpell)); - OnEffectApply.Add(new EffectApplyHandler(Apply, 1, AuraType.ProcTriggerSpell, AuraEffectHandleModes.RealOrReapplyMask)); + else if (summon) + ringOfFrost = summon; } } - public override AuraScript GetAuraScript() + TempSummon ringOfFrost; + + public override void Register() { - return new spell_mage_ring_of_frost_AuraScript(); + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 1, AuraType.ProcTriggerSpell)); + OnEffectApply.Add(new EffectApplyHandler(Apply, 1, AuraType.ProcTriggerSpell, AuraEffectHandleModes.RealOrReapplyMask)); } } // 82691 - Ring of Frost (freeze efect) // Updated 4.3.4 [Script] - class spell_mage_ring_of_frost_freeze : SpellScriptLoader + class spell_mage_ring_of_frost_freeze : SpellScript { - public spell_mage_ring_of_frost_freeze() : base("spell_mage_ring_of_frost_freeze") { } - - class spell_mage_ring_of_frost_freeze_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.RingOfFrostSummon, SpellIds.RingOfFrostFreeze); - } + return ValidateSpellInfo(SpellIds.RingOfFrostSummon, SpellIds.RingOfFrostFreeze); + } - void FilterTargets(List targets) - { - float outRadius = Global.SpellMgr.GetSpellInfo(SpellIds.RingOfFrostSummon).GetEffect(0).CalcRadius(); - float inRadius = 4.7f; + void FilterTargets(List targets) + { + float outRadius = Global.SpellMgr.GetSpellInfo(SpellIds.RingOfFrostSummon).GetEffect(0).CalcRadius(); + float inRadius = 4.7f; - foreach (var obj in targets.ToList()) - { - Unit unit = obj.ToUnit(); - if (unit) - if (unit.HasAura(SpellIds.RingOfFrostDummy) || unit.HasAura(SpellIds.RingOfFrostFreeze) || unit.GetExactDist(GetExplTargetDest()) > outRadius || unit.GetExactDist(GetExplTargetDest()) < inRadius) - targets.Remove(obj); - } - } - - public override void Register() + foreach (var obj in targets.ToList()) { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaEnemy)); + Unit unit = obj.ToUnit(); + if (unit) + if (unit.HasAura(SpellIds.RingOfFrostDummy) || unit.HasAura(SpellIds.RingOfFrostFreeze) || unit.GetExactDist(GetExplTargetDest()) > outRadius || unit.GetExactDist(GetExplTargetDest()) < inRadius) + targets.Remove(obj); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_mage_ring_of_frost_freeze_SpellScript(); + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaEnemy)); + } + } + + [Script] + class spell_mage_ring_of_frost_freeze_AuraScript : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.RingOfFrostDummy); } - class spell_mage_ring_of_frost_freeze_AuraScript : AuraScript + void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.RingOfFrostDummy); - } - - void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - if (GetTargetApplication().GetRemoveMode() != AuraRemoveMode.Expire) - if (GetCaster()) - GetCaster().CastSpell(GetTarget(), SpellIds.RingOfFrostDummy, true); - } - - public override void Register() - { - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ModStun, AuraEffectHandleModes.Real)); - } + if (GetTargetApplication().GetRemoveMode() != AuraRemoveMode.Expire) + if (GetCaster()) + GetCaster().CastSpell(GetTarget(), SpellIds.RingOfFrostDummy, true); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_mage_ring_of_frost_freeze_AuraScript(); + AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.ModStun, AuraEffectHandleModes.Real)); } } // 80353 - Time Warp [Script] - class spell_mage_time_warp : SpellScriptLoader + class spell_mage_time_warp : SpellScript { - public spell_mage_time_warp() : base("spell_mage_time_warp") { } - - class spell_mage_time_warp_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.TemporalDisplacement, SpellIds.HunterInsanity, SpellIds.ShamanExhaustion, SpellIds.ShamanSated); - } - - void RemoveInvalidTargets(List targets) - { - targets.RemoveAll(new UnitAuraCheck(true, SpellIds.TemporalDisplacement)); - targets.RemoveAll(new UnitAuraCheck(true, SpellIds.HunterInsanity)); - targets.RemoveAll(new UnitAuraCheck(true, SpellIds.ShamanExhaustion)); - targets.RemoveAll(new UnitAuraCheck(true, SpellIds.ShamanSated)); - } - - void ApplyDebuff() - { - Unit target = GetHitUnit(); - if (target) - target.CastSpell(target, SpellIds.TemporalDisplacement, true); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(RemoveInvalidTargets, SpellConst.EffectAll, Targets.UnitCasterAreaRaid)); - AfterHit.Add(new HitHandler(ApplyDebuff)); - } + return ValidateSpellInfo(SpellIds.TemporalDisplacement, SpellIds.HunterInsanity, SpellIds.ShamanExhaustion, SpellIds.ShamanSated); } - public override SpellScript GetSpellScript() + void RemoveInvalidTargets(List targets) { - return new spell_mage_time_warp_SpellScript(); + targets.RemoveAll(new UnitAuraCheck(true, SpellIds.TemporalDisplacement)); + targets.RemoveAll(new UnitAuraCheck(true, SpellIds.HunterInsanity)); + targets.RemoveAll(new UnitAuraCheck(true, SpellIds.ShamanExhaustion)); + targets.RemoveAll(new UnitAuraCheck(true, SpellIds.ShamanSated)); + } + + void ApplyDebuff() + { + Unit target = GetHitUnit(); + if (target) + target.CastSpell(target, SpellIds.TemporalDisplacement, true); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(RemoveInvalidTargets, SpellConst.EffectAll, Targets.UnitCasterAreaRaid)); + AfterHit.Add(new HitHandler(ApplyDebuff)); } } [Script] //228597 - Frostbolt 84721 - Frozen Orb 190357 - Blizzard - class spell_mage_trigger_chilled : SpellScriptLoader + class spell_mage_trigger_chilled : SpellScript { - public spell_mage_trigger_chilled() : base("spell_mage_trigger_chilled") { } - - class spell_mage_trigger_chilled_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.Chilled); - } - - void HandleChilled() - { - Unit target = GetHitUnit(); - if (target) - GetCaster().CastSpell(target, SpellIds.Chilled, true); - } - - public override void Register() - { - OnHit.Add(new HitHandler(HandleChilled)); - } + return ValidateSpellInfo(SpellIds.Chilled); } - public override SpellScript GetSpellScript() + void HandleChilled() { - return new spell_mage_trigger_chilled_SpellScript(); + Unit target = GetHitUnit(); + if (target) + GetCaster().CastSpell(target, SpellIds.Chilled, true); + } + + public override void Register() + { + OnHit.Add(new HitHandler(HandleChilled)); } } - + [Script] // 33395 Water Elemental's Freeze - class spell_mage_water_elemental_freeze : SpellScriptLoader + class spell_mage_water_elemental_freeze : SpellScript { - public spell_mage_water_elemental_freeze() : base("spell_mage_water_elemental_freeze") { } - - class spell_mage_water_elemental_freeze_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.FingersOfFrost); - } - - void HandleImprovedFreeze() - { - Unit owner = GetCaster().GetOwner(); - if (!owner) - return; - - owner.CastSpell(owner, SpellIds.FingersOfFrost, true); - } - - public override void Register() - { - AfterHit.Add(new HitHandler(HandleImprovedFreeze)); - } + return ValidateSpellInfo(SpellIds.FingersOfFrost); } - public override SpellScript GetSpellScript() + void HandleImprovedFreeze() { - return new spell_mage_water_elemental_freeze_SpellScript(); + Unit owner = GetCaster().GetOwner(); + if (!owner) + return; + + owner.CastSpell(owner, SpellIds.FingersOfFrost, true); + } + + public override void Register() + { + AfterHit.Add(new HitHandler(HandleImprovedFreeze)); } } } diff --git a/Scripts/Spells/Monk.cs b/Scripts/Spells/Monk.cs index 212f6b17b..3ef587d21 100644 --- a/Scripts/Spells/Monk.cs +++ b/Scripts/Spells/Monk.cs @@ -37,133 +37,103 @@ namespace Scripts.Spells.Monk } [Script] // 117952 - Crackling Jade Lightning - class spell_monk_crackling_jade_lightning : SpellScriptLoader + class spell_monk_crackling_jade_lightning : AuraScript { - public spell_monk_crackling_jade_lightning() : base("spell_monk_crackling_jade_lightning") { } - - class spell_monk_crackling_jade_lightning_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.CracklingJadeLightningChiProc); - } - - void OnTick(AuraEffect aurEff) - { - Unit caster = GetCaster(); - if (caster) - if (caster.HasAura(SpellIds.StanceOfTheSpiritedCrane)) - caster.CastSpell(caster, SpellIds.CracklingJadeLightningChiProc, TriggerCastFlags.FullMask); - } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(OnTick, 0, Framework.Constants.AuraType.PeriodicDamage)); - } + return ValidateSpellInfo(SpellIds.CracklingJadeLightningChiProc); } - public override AuraScript GetAuraScript() + void OnTick(AuraEffect aurEff) { - return new spell_monk_crackling_jade_lightning_AuraScript(); + Unit caster = GetCaster(); + if (caster) + if (caster.HasAura(SpellIds.StanceOfTheSpiritedCrane)) + caster.CastSpell(caster, SpellIds.CracklingJadeLightningChiProc, TriggerCastFlags.FullMask); + } + + public override void Register() + { + OnEffectPeriodic.Add(new EffectPeriodicHandler(OnTick, 0, Framework.Constants.AuraType.PeriodicDamage)); } } [Script] // 117959 - Crackling Jade Lightning - class spell_monk_crackling_jade_lightning_knockback_proc_aura : SpellScriptLoader + class spell_monk_crackling_jade_lightning_aura : AuraScript { - public spell_monk_crackling_jade_lightning_knockback_proc_aura() : base("spell_monk_crackling_jade_lightning_knockback_proc_aura") { } - - class spell_monk_crackling_jade_lightning_aura_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.CracklingJadeLightningKnockback, SpellIds.CracklingJadeLightningKnockbackCd); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - if (GetTarget().HasAura(SpellIds.CracklingJadeLightningKnockbackCd)) - return false; - - if (eventInfo.GetActor().HasAura(SpellIds.CracklingJadeLightningChannel, GetTarget().GetGUID())) - return false; - - Spell currentChanneledSpell = GetTarget().GetCurrentSpell(CurrentSpellTypes.Channeled); - if (!currentChanneledSpell || currentChanneledSpell.GetSpellInfo().Id != SpellIds.CracklingJadeLightningChannel) - return false; - - return true; - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - GetTarget().CastSpell(eventInfo.GetActor(), SpellIds.CracklingJadeLightningKnockback, TriggerCastFlags.FullMask); - GetTarget().CastSpell(GetTarget(), SpellIds.CracklingJadeLightningKnockbackCd, TriggerCastFlags.FullMask); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, Framework.Constants.AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.CracklingJadeLightningKnockback, SpellIds.CracklingJadeLightningKnockbackCd); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_monk_crackling_jade_lightning_aura_AuraScript(); + if (GetTarget().HasAura(SpellIds.CracklingJadeLightningKnockbackCd)) + return false; + + if (eventInfo.GetActor().HasAura(SpellIds.CracklingJadeLightningChannel, GetTarget().GetGUID())) + return false; + + Spell currentChanneledSpell = GetTarget().GetCurrentSpell(CurrentSpellTypes.Channeled); + if (!currentChanneledSpell || currentChanneledSpell.GetSpellInfo().Id != SpellIds.CracklingJadeLightningChannel) + return false; + + return true; + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + GetTarget().CastSpell(eventInfo.GetActor(), SpellIds.CracklingJadeLightningKnockback, TriggerCastFlags.FullMask); + GetTarget().CastSpell(GetTarget(), SpellIds.CracklingJadeLightningKnockbackCd, TriggerCastFlags.FullMask); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, Framework.Constants.AuraType.Dummy)); } } [Script] // 115546 - Provoke - class spell_monk_provoke : SpellScriptLoader + class spell_monk_provoke : SpellScript { - public spell_monk_provoke() : base("spell_monk_provoke") { } + const uint BlackOxStatusEntry = 61146; - class spell_monk_provoke_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - const uint BlackOxStatusEntry = 61146; - - public override bool Validate(SpellInfo spellInfo) - { - if (!spellInfo.GetExplicitTargetMask().HasAnyFlag(SpellCastTargetFlags.UnitMask)) // ensure GetExplTargetUnit() will return something meaningful during CheckCast - return false; - return ValidateSpellInfo(SpellIds.ProvokeSingleTarget, SpellIds.ProvokeAoe); - } - - SpellCastResult CheckExplicitTarget() - { - if (GetExplTargetUnit().GetEntry() != BlackOxStatusEntry) - { - SpellInfo singleTarget = Global.SpellMgr.GetSpellInfo(SpellIds.ProvokeSingleTarget); - SpellCastResult singleTargetExplicitResult = singleTarget.CheckExplicitTarget(GetCaster(), GetExplTargetUnit()); - if (singleTargetExplicitResult != SpellCastResult.SpellCastOk) - return singleTargetExplicitResult; - } - else if (GetExplTargetUnit().GetOwnerGUID() != GetCaster().GetGUID()) - return SpellCastResult.BadTargets; - - return SpellCastResult.SpellCastOk; - } - - void HandleDummy(uint effIndex) - { - PreventHitDefaultEffect(effIndex); - if (GetHitUnit().GetEntry() != BlackOxStatusEntry) - GetCaster().CastSpell(GetHitUnit(), SpellIds.ProvokeSingleTarget, true); - else - GetCaster().CastSpell(GetHitUnit(), SpellIds.ProvokeAoe, true); - } - - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckExplicitTarget)); - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + if (!spellInfo.GetExplicitTargetMask().HasAnyFlag(SpellCastTargetFlags.UnitMask)) // ensure GetExplTargetUnit() will return something meaningful during CheckCast + return false; + return ValidateSpellInfo(SpellIds.ProvokeSingleTarget, SpellIds.ProvokeAoe); } - public override SpellScript GetSpellScript() + SpellCastResult CheckExplicitTarget() { - return new spell_monk_provoke_SpellScript(); + if (GetExplTargetUnit().GetEntry() != BlackOxStatusEntry) + { + SpellInfo singleTarget = Global.SpellMgr.GetSpellInfo(SpellIds.ProvokeSingleTarget); + SpellCastResult singleTargetExplicitResult = singleTarget.CheckExplicitTarget(GetCaster(), GetExplTargetUnit()); + if (singleTargetExplicitResult != SpellCastResult.SpellCastOk) + return singleTargetExplicitResult; + } + else if (GetExplTargetUnit().GetOwnerGUID() != GetCaster().GetGUID()) + return SpellCastResult.BadTargets; + + return SpellCastResult.SpellCastOk; + } + + void HandleDummy(uint effIndex) + { + PreventHitDefaultEffect(effIndex); + if (GetHitUnit().GetEntry() != BlackOxStatusEntry) + GetCaster().CastSpell(GetHitUnit(), SpellIds.ProvokeSingleTarget, true); + else + GetCaster().CastSpell(GetHitUnit(), SpellIds.ProvokeAoe, true); + } + + public override void Register() + { + OnCheckCast.Add(new CheckCastHandler(CheckExplicitTarget)); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } } diff --git a/Scripts/Spells/Paladin.cs b/Scripts/Spells/Paladin.cs index 6e274c83b..92f0d9ff8 100644 --- a/Scripts/Spells/Paladin.cs +++ b/Scripts/Spells/Paladin.cs @@ -66,1008 +66,779 @@ namespace Scripts.Spells.Paladin // 31821 - Aura Mastery [Script] - class spell_pal_aura_mastery : SpellScriptLoader + class spell_pal_aura_mastery : AuraScript { - public spell_pal_aura_mastery() : base("spell_pal_aura_mastery") { } - - class spell_pal_aura_mastery_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.AuraMasteryImmune); - } - - void HandleEffectApply(AuraEffect aurEff, AuraEffectHandleModes mode) - { - GetTarget().CastSpell(GetTarget(), SpellIds.AuraMasteryImmune, true); - } - - void HandleEffectRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - GetTarget().RemoveOwnedAura(SpellIds.AuraMasteryImmune, GetCasterGUID()); - } - - public override void Register() - { - AfterEffectApply.Add(new EffectApplyHandler(HandleEffectApply, 0, AuraType.AddPctModifier, AuraEffectHandleModes.Real)); - AfterEffectRemove.Add(new EffectApplyHandler(HandleEffectRemove, 0, AuraType.AddPctModifier, AuraEffectHandleModes.Real)); - } + return ValidateSpellInfo(SpellIds.AuraMasteryImmune); } - public override AuraScript GetAuraScript() + void HandleEffectApply(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_pal_aura_mastery_AuraScript(); + GetTarget().CastSpell(GetTarget(), SpellIds.AuraMasteryImmune, true); + } + + void HandleEffectRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + GetTarget().RemoveOwnedAura(SpellIds.AuraMasteryImmune, GetCasterGUID()); + } + + public override void Register() + { + AfterEffectApply.Add(new EffectApplyHandler(HandleEffectApply, 0, AuraType.AddPctModifier, AuraEffectHandleModes.Real)); + AfterEffectRemove.Add(new EffectApplyHandler(HandleEffectRemove, 0, AuraType.AddPctModifier, AuraEffectHandleModes.Real)); } } // 64364 - Aura Mastery Immune [Script] - class spell_pal_aura_mastery_immune : SpellScriptLoader + class spell_pal_aura_mastery_immune : AuraScript { - public spell_pal_aura_mastery_immune() - : base("spell_pal_aura_mastery_immune") { } - - class spell_pal_aura_mastery_immune_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ConcentractionAura); - } - - bool CheckAreaTarget(Unit target) - { - return target.HasAura(SpellIds.ConcentractionAura, GetCasterGUID()); - } - - public override void Register() - { - DoCheckAreaTarget.Add(new CheckAreaTargetHandler(CheckAreaTarget)); - } + return ValidateSpellInfo(SpellIds.ConcentractionAura); } - public override AuraScript GetAuraScript() + bool CheckAreaTarget(Unit target) { - return new spell_pal_aura_mastery_immune_AuraScript(); + return target.HasAura(SpellIds.ConcentractionAura, GetCasterGUID()); + } + + public override void Register() + { + DoCheckAreaTarget.Add(new CheckAreaTargetHandler(CheckAreaTarget)); } } // 37877 - Blessing of Faith [Script] - class spell_pal_blessing_of_faith : SpellScriptLoader + class spell_pal_blessing_of_faith : SpellScript { - public spell_pal_blessing_of_faith() - : base("spell_pal_blessing_of_faith") { } - - class spell_pal_blessing_of_faith_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.BlessingOfLowerCityDruid, SpellIds.BlessingOfLowerCityPaladin, SpellIds.BlessingOfLowerCityPriest, SpellIds.BlessingOfLowerCityShaman); - } + return ValidateSpellInfo(SpellIds.BlessingOfLowerCityDruid, SpellIds.BlessingOfLowerCityPaladin, SpellIds.BlessingOfLowerCityPriest, SpellIds.BlessingOfLowerCityShaman); + } - void HandleDummy(uint effIndex) + void HandleDummy(uint effIndex) + { + Unit unitTarget = GetHitUnit(); + if (unitTarget) { - Unit unitTarget = GetHitUnit(); - if (unitTarget) + uint spell_id = 0; + switch (unitTarget.GetClass()) { - uint spell_id = 0; - switch (unitTarget.GetClass()) - { - case Class.Druid: - spell_id = SpellIds.BlessingOfLowerCityDruid; - break; - case Class.Paladin: - spell_id = SpellIds.BlessingOfLowerCityPaladin; - break; - case Class.Priest: - spell_id = SpellIds.BlessingOfLowerCityPriest; - break; - case Class.Shaman: - spell_id = SpellIds.BlessingOfLowerCityShaman; - break; - default: - return; // ignore for non-healing classes - } - Unit caster = GetCaster(); - caster.CastSpell(caster, spell_id, true); + case Class.Druid: + spell_id = SpellIds.BlessingOfLowerCityDruid; + break; + case Class.Paladin: + spell_id = SpellIds.BlessingOfLowerCityPaladin; + break; + case Class.Priest: + spell_id = SpellIds.BlessingOfLowerCityPriest; + break; + case Class.Shaman: + spell_id = SpellIds.BlessingOfLowerCityShaman; + break; + default: + return; // ignore for non-healing classes } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + Unit caster = GetCaster(); + caster.CastSpell(caster, spell_id, true); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_pal_blessing_of_faith_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 190784 - Divine Steed - class spell_pal_divine_steed : SpellScriptLoader + class spell_pal_divine_steed : SpellScript { - public spell_pal_divine_steed() : base("spell_pal_divine_steed") { } - - class spell_pal_divine_steed_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.DivineSteedHuman, SpellIds.DivineSteedDraenei, SpellIds.DivineSteedBloodelf, SpellIds.DivineSteedTauren); - } - - void HandleOnCast() - { - Unit caster = GetCaster(); - - uint spellId = SpellIds.DivineSteedHuman; - switch (caster.GetRace()) - { - case Race.Draenei: - spellId = SpellIds.DivineSteedDraenei; - break; - case Race.BloodElf: - spellId = SpellIds.DivineSteedBloodelf; - break; - case Race.Tauren: - spellId = SpellIds.DivineSteedTauren; - break; - default: - break; - } - - caster.CastSpell(caster, spellId, true); - } - - public override void Register() - { - OnCast.Add(new CastHandler(HandleOnCast)); - } + return ValidateSpellInfo(SpellIds.DivineSteedHuman, SpellIds.DivineSteedDraenei, SpellIds.DivineSteedBloodelf, SpellIds.DivineSteedTauren); } - public override SpellScript GetSpellScript() + void HandleOnCast() { - return new spell_pal_divine_steed_SpellScript(); + Unit caster = GetCaster(); + + uint spellId = SpellIds.DivineSteedHuman; + switch (caster.GetRace()) + { + case Race.Draenei: + spellId = SpellIds.DivineSteedDraenei; + break; + case Race.BloodElf: + spellId = SpellIds.DivineSteedBloodelf; + break; + case Race.Tauren: + spellId = SpellIds.DivineSteedTauren; + break; + default: + break; + } + + caster.CastSpell(caster, spellId, true); + } + + public override void Register() + { + OnCast.Add(new CastHandler(HandleOnCast)); } } // 224239 - Divine Storm [Script] - class spell_pal_divine_storm : SpellScriptLoader + class spell_pal_divine_storm : SpellScript { - public spell_pal_divine_storm() : base("spell_pal_divine_storm") { } - - class spell_pal_divine_storm_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.DivineStormDamage); - } - - void HandleOnCast() - { - Unit caster = GetCaster(); - caster.SendPlaySpellVisualKit(73892, 0, 0); - } - - void HandleDummy(uint effIndex) - { - Unit caster = GetCaster(); - Unit target = GetHitUnit(); - if (!target) - return; - - caster.CastSpell(target, SpellIds.DivineStormDamage, true); - } - - public override void Register() - { - OnCast.Add(new CastHandler(HandleOnCast)); - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellIds.DivineStormDamage); } - public override SpellScript GetSpellScript() + void HandleOnCast() { - return new spell_pal_divine_storm_SpellScript(); + Unit caster = GetCaster(); + caster.SendPlaySpellVisualKit(73892, 0, 0); + } + + void HandleDummy(uint effIndex) + { + Unit caster = GetCaster(); + Unit target = GetHitUnit(); + if (!target) + return; + + caster.CastSpell(target, SpellIds.DivineStormDamage, true); + } + + public override void Register() + { + OnCast.Add(new CastHandler(HandleOnCast)); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } // 33695 - Exorcism and Holy Wrath Damage [Script] - class spell_pal_exorcism_and_holy_wrath_damage : SpellScriptLoader + class spell_pal_exorcism_and_holy_wrath_damage : AuraScript { - public spell_pal_exorcism_and_holy_wrath_damage() - : base("spell_pal_exorcism_and_holy_wrath_damage") { } - - class spell_pal_exorcism_and_holy_wrath_damage_AuraScript : AuraScript + void HandleEffectCalcSpellMod(AuraEffect aurEff, ref SpellModifier spellMod) { - void HandleEffectCalcSpellMod(AuraEffect aurEff, ref SpellModifier spellMod) + if (spellMod == null) { - if (spellMod == null) - { - spellMod = new SpellModifier(aurEff.GetBase()); - spellMod.op = SpellModOp.Damage; - spellMod.type = SpellModType.Flat; - spellMod.spellId = GetId(); - spellMod.mask[1] = 0x200002; - } - - spellMod.value = aurEff.GetAmount(); + spellMod = new SpellModifier(aurEff.GetBase()); + spellMod.op = SpellModOp.Damage; + spellMod.type = SpellModType.Flat; + spellMod.spellId = GetId(); + spellMod.mask[1] = 0x200002; } - public override void Register() - { - DoEffectCalcSpellMod.Add(new EffectCalcSpellModHandler(HandleEffectCalcSpellMod, 0, AuraType.Dummy)); - } + spellMod.value = aurEff.GetAmount(); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_pal_exorcism_and_holy_wrath_damage_AuraScript(); + DoEffectCalcSpellMod.Add(new EffectCalcSpellModHandler(HandleEffectCalcSpellMod, 0, AuraType.Dummy)); } } // -9799 - Eye for an Eye [Script] - class spell_pal_eye_for_an_eye : SpellScriptLoader + class spell_pal_eye_for_an_eye : AuraScript { - public spell_pal_eye_for_an_eye() - : base("spell_pal_eye_for_an_eye") { } - - class spell_pal_eye_for_an_eye_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.EyeForAnEyeDamage); - } - - void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - int damage = (int)MathFunctions.CalculatePct(eventInfo.GetDamageInfo().GetDamage(), aurEff.GetAmount()); - GetTarget().CastCustomSpell(SpellIds.EyeForAnEyeDamage, SpellValueMod.BasePoint0, damage, eventInfo.GetProcTarget(), true, null, aurEff); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, m_scriptSpellId == SpellIds.EyeForAnEyeRank1 ? AuraType.Dummy : AuraType.ProcTriggerSpell)); - } + return ValidateSpellInfo(SpellIds.EyeForAnEyeDamage); } - public override AuraScript GetAuraScript() + void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_pal_eye_for_an_eye_AuraScript(); + PreventDefaultAction(); + int damage = (int)MathFunctions.CalculatePct(eventInfo.GetDamageInfo().GetDamage(), aurEff.GetAmount()); + GetTarget().CastCustomSpell(SpellIds.EyeForAnEyeDamage, SpellValueMod.BasePoint0, damage, eventInfo.GetProcTarget(), true, null, aurEff); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, m_scriptSpellId == SpellIds.EyeForAnEyeRank1 ? AuraType.Dummy : AuraType.ProcTriggerSpell)); } } // -75806 - Grand Crusader [Script] - class spell_pal_grand_crusader : SpellScriptLoader + class spell_pal_grand_crusader : AuraScript { - public spell_pal_grand_crusader() - : base("spell_pal_grand_crusader") { } - - class spell_pal_grand_crusader_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.AvengersShield); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - return GetTarget().IsTypeId(TypeId.Player); - } - - void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - GetTarget().GetSpellHistory().ResetCooldown(SpellIds.AvengersShield, true); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.ProcTriggerSpell)); - } + return ValidateSpellInfo(SpellIds.AvengersShield); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_pal_grand_crusader_AuraScript(); + return GetTarget().IsTypeId(TypeId.Player); + } + + void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + GetTarget().GetSpellHistory().ResetCooldown(SpellIds.AvengersShield, true); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.ProcTriggerSpell)); } } // 54968 - Glyph of Holy Light [Script] - class spell_pal_glyph_of_holy_light : SpellScriptLoader + class spell_pal_glyph_of_holy_light : SpellScript { - public spell_pal_glyph_of_holy_light() - : base("spell_pal_glyph_of_holy_light") { } - - class spell_pal_glyph_of_holy_light_SpellScript : SpellScript + void FilterTargets(List targets) { - void FilterTargets(List targets) - { - uint maxTargets = GetSpellInfo().MaxAffectedTargets; + uint maxTargets = GetSpellInfo().MaxAffectedTargets; - if (targets.Count > maxTargets) - { - targets.Sort(new HealthPctOrderPred()); - targets.Resize(maxTargets); - } - } - - public override void Register() + if (targets.Count > maxTargets) { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaAlly)); + targets.Sort(new HealthPctOrderPred()); + targets.Resize(maxTargets); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_pal_glyph_of_holy_light_SpellScript(); + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaAlly)); } } // 6940 - Hand of Sacrifice [Script] - class spell_pal_hand_of_sacrifice : SpellScriptLoader + class spell_pal_hand_of_sacrifice : AuraScript { - public spell_pal_hand_of_sacrifice() - : base("spell_pal_hand_of_sacrifice") { } + int remainingAmount; - class spell_pal_hand_of_sacrifice_AuraScript : AuraScript + public override bool Load() { - int remainingAmount; - - public override bool Load() + Unit caster = GetCaster(); + if (caster) { - Unit caster = GetCaster(); - if (caster) - { - remainingAmount = (int)caster.GetMaxHealth(); - return true; - } - return false; + remainingAmount = (int)caster.GetMaxHealth(); + return true; } + return false; + } - void Split(AuraEffect aurEff, DamageInfo dmgInfo, uint splitAmount) + void Split(AuraEffect aurEff, DamageInfo dmgInfo, uint splitAmount) + { + remainingAmount -= (int)splitAmount; + + if (remainingAmount <= 0) { - remainingAmount -= (int)splitAmount; - - if (remainingAmount <= 0) - { - GetTarget().RemoveAura(SpellIds.HandOfSacrifice); - } - } - - public override void Register() - { - OnEffectSplit.Add(new EffectSplitHandler(Split, 0)); + GetTarget().RemoveAura(SpellIds.HandOfSacrifice); } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_pal_hand_of_sacrifice_AuraScript(); + OnEffectSplit.Add(new EffectSplitHandler(Split, 0)); } } // 20473 - Holy Shock [Script] - class spell_pal_holy_shock : SpellScriptLoader + class spell_pal_holy_shock : SpellScript { - public spell_pal_holy_shock() - : base("spell_pal_holy_shock") { } - - class spell_pal_holy_shock_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) + SpellInfo firstRankSpellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.HolyShockR1); + if (firstRankSpellInfo == null) + return false; + + // can't use other spell than holy shock due to spell_ranks dependency + if (!spellInfo.IsRankOf(firstRankSpellInfo)) + return false; + + byte rank = spellInfo.GetRank(); + if (Global.SpellMgr.GetSpellWithRank(SpellIds.HolyShockR1Damage, rank, true) == 0 || Global.SpellMgr.GetSpellWithRank(SpellIds.HolyShockR1Healing, rank, true) == 0) + return false; + + return true; + } + + void HandleDummy(uint effIndex) + { + Unit caster = GetCaster(); + Unit unitTarget = GetHitUnit(); + if (unitTarget) { - SpellInfo firstRankSpellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.HolyShockR1); - if (firstRankSpellInfo == null) - return false; - - // can't use other spell than holy shock due to spell_ranks dependency - if (!spellInfo.IsRankOf(firstRankSpellInfo)) - return false; - - byte rank = spellInfo.GetRank(); - if (Global.SpellMgr.GetSpellWithRank(SpellIds.HolyShockR1Damage, rank, true) == 0 || Global.SpellMgr.GetSpellWithRank(SpellIds.HolyShockR1Healing, rank, true) == 0) - return false; - - return true; - } - - void HandleDummy(uint effIndex) - { - Unit caster = GetCaster(); - Unit unitTarget = GetHitUnit(); - if (unitTarget) - { - byte rank = GetSpellInfo().GetRank(); - if (caster.IsFriendlyTo(unitTarget)) - caster.CastSpell(unitTarget, Global.SpellMgr.GetSpellWithRank(SpellIds.HolyShockR1Healing, rank), true); - else - caster.CastSpell(unitTarget, Global.SpellMgr.GetSpellWithRank(SpellIds.HolyShockR1Damage, rank), true); - } - } - - SpellCastResult CheckCast() - { - Unit caster = GetCaster(); - Unit target = GetExplTargetUnit(); - if (target) - { - if (!caster.IsFriendlyTo(target)) - { - if (!caster.IsValidAttackTarget(target)) - return SpellCastResult.BadTargets; - - if (!caster.isInFront(target)) - return SpellCastResult.NotInfront; - } - } + byte rank = GetSpellInfo().GetRank(); + if (caster.IsFriendlyTo(unitTarget)) + caster.CastSpell(unitTarget, Global.SpellMgr.GetSpellWithRank(SpellIds.HolyShockR1Healing, rank), true); else - return SpellCastResult.BadTargets; - return SpellCastResult.SpellCastOk; - } - - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + caster.CastSpell(unitTarget, Global.SpellMgr.GetSpellWithRank(SpellIds.HolyShockR1Damage, rank), true); } } - public override SpellScript GetSpellScript() + SpellCastResult CheckCast() { - return new spell_pal_holy_shock_SpellScript(); + Unit caster = GetCaster(); + Unit target = GetExplTargetUnit(); + if (target) + { + if (!caster.IsFriendlyTo(target)) + { + if (!caster.IsValidAttackTarget(target)) + return SpellCastResult.BadTargets; + + if (!caster.isInFront(target)) + return SpellCastResult.NotInfront; + } + } + else + return SpellCastResult.BadTargets; + return SpellCastResult.SpellCastOk; + } + + public override void Register() + { + OnCheckCast.Add(new CheckCastHandler(CheckCast)); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } // 37705 - Healing Discount [Script] - class spell_pal_item_healing_discount : SpellScriptLoader + class spell_pal_item_healing_discount : AuraScript { - public spell_pal_item_healing_discount() - : base("spell_pal_item_healing_discount") { } - - class spell_pal_item_healing_discount_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ItemHealingTrance); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), SpellIds.ItemHealingTrance, true, null, aurEff); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); - } + return ValidateSpellInfo(SpellIds.ItemHealingTrance); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_pal_item_healing_discount_AuraScript(); + PreventDefaultAction(); + GetTarget().CastSpell(GetTarget(), SpellIds.ItemHealingTrance, true, null, aurEff); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); } } [Script] // 40470 - Paladin Tier 6 Trinket - class spell_pal_item_t6_trinket : SpellScriptLoader + class spell_pal_item_t6_trinket : AuraScript { - public spell_pal_item_t6_trinket() : base("spell_pal_item_t6_trinket") { } - - class spell_pal_item_t6_trinket_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.EnduringLight, SpellIds.EnduringJudgement); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - SpellInfo spellInfo = eventInfo.GetSpellInfo(); - if (spellInfo == null) - return; - - uint spellId; - int chance; - - // Holy Light & Flash of Light - if (spellInfo.SpellFamilyFlags[0].HasAnyFlag(0xC0000000)) - { - spellId = SpellIds.EnduringLight; - chance = 15; - } - // Judgements - else if (spellInfo.SpellFamilyFlags[0].HasAnyFlag(0x00800000u)) - { - spellId = SpellIds.EnduringJudgement; - chance = 50; - } - else - return; - - if (RandomHelper.randChance(chance)) - eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), spellId, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.EnduringLight, SpellIds.EnduringJudgement); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_pal_item_t6_trinket_AuraScript(); + PreventDefaultAction(); + SpellInfo spellInfo = eventInfo.GetSpellInfo(); + if (spellInfo == null) + return; + + uint spellId; + int chance; + + // Holy Light & Flash of Light + if (spellInfo.SpellFamilyFlags[0].HasAnyFlag(0xC0000000)) + { + spellId = SpellIds.EnduringLight; + chance = 15; + } + // Judgements + else if (spellInfo.SpellFamilyFlags[0].HasAnyFlag(0x00800000u)) + { + spellId = SpellIds.EnduringJudgement; + chance = 50; + } + else + return; + + if (RandomHelper.randChance(chance)) + eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), spellId, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } // 20271 - Judgement // Updated 4.3.4 [Script] - class spell_pal_judgement : SpellScriptLoader + class spell_pal_judgement : SpellScript { - public spell_pal_judgement() : base("spell_pal_judgement") { } - - class spell_pal_judgement_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.JudgementDamage); - } - - void HandleScriptEffect(uint effIndex) - { - uint spellId = SpellIds.JudgementDamage; - - // some seals have SPELL_AURA_DUMMY in EFFECT_2 - var auras = GetCaster().GetAuraEffectsByType(AuraType.Dummy); - foreach (var eff in auras) - { - if (eff.GetSpellInfo().GetSpellSpecific() == SpellSpecificType.Seal && eff.GetEffIndex() == 2) - { - if (Global.SpellMgr.HasSpellInfo((uint)eff.GetAmount())) - { - spellId = (uint)eff.GetAmount(); - break; - } - } - } - - GetCaster().CastSpell(GetHitUnit(), spellId, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellIds.JudgementDamage); } - public override SpellScript GetSpellScript() + void HandleScriptEffect(uint effIndex) { - return new spell_pal_judgement_SpellScript(); + uint spellId = SpellIds.JudgementDamage; + + // some seals have SPELL_AURA_DUMMY in EFFECT_2 + var auras = GetCaster().GetAuraEffectsByType(AuraType.Dummy); + foreach (var eff in auras) + { + if (eff.GetSpellInfo().GetSpellSpecific() == SpellSpecificType.Seal && eff.GetEffIndex() == 2) + { + if (Global.SpellMgr.HasSpellInfo((uint)eff.GetAmount())) + { + spellId = (uint)eff.GetAmount(); + break; + } + } + } + + GetCaster().CastSpell(GetHitUnit(), spellId, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.Dummy)); } } // 633 - Lay on Hands [Script] - class spell_pal_lay_on_hands : SpellScriptLoader + class spell_pal_lay_on_hands : SpellScript { - public spell_pal_lay_on_hands() : base("spell_pal_lay_on_hands") { } - - class spell_pal_lay_on_hands_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.Forbearance, SpellIds.ImmuneShieldMarker); - } + return ValidateSpellInfo(SpellIds.Forbearance, SpellIds.ImmuneShieldMarker); + } - SpellCastResult CheckCast() + SpellCastResult CheckCast() + { + Unit caster = GetCaster(); + Unit target = GetExplTargetUnit(); + if (target) { - Unit caster = GetCaster(); - Unit target = GetExplTargetUnit(); - if (target) + if (caster == target) { - if (caster == target) - { - if (target.HasAura(SpellIds.Forbearance) || target.HasAura(SpellIds.ImmuneShieldMarker)) - return SpellCastResult.TargetAurastate; - } - } - - return SpellCastResult.SpellCastOk; - } - - void HandleScript() - { - Unit caster = GetCaster(); - if (caster == GetHitUnit()) - { - caster.CastSpell(caster, SpellIds.Forbearance, true); - caster.CastSpell(caster, SpellIds.ImmuneShieldMarker, true); + if (target.HasAura(SpellIds.Forbearance) || target.HasAura(SpellIds.ImmuneShieldMarker)) + return SpellCastResult.TargetAurastate; } } - public override void Register() + return SpellCastResult.SpellCastOk; + } + + void HandleScript() + { + Unit caster = GetCaster(); + if (caster == GetHitUnit()) { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - AfterHit.Add(new HitHandler(HandleScript)); + caster.CastSpell(caster, SpellIds.Forbearance, true); + caster.CastSpell(caster, SpellIds.ImmuneShieldMarker, true); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_pal_lay_on_hands_SpellScript(); + OnCheckCast.Add(new CheckCastHandler(CheckCast)); + AfterHit.Add(new HitHandler(HandleScript)); } } // 53651 - Beacon of Light [Script] - class spell_pal_light_s_beacon : SpellScriptLoader + class spell_pal_light_s_beacon : AuraScript { - public spell_pal_light_s_beacon() : base("spell_pal_light_s_beacon") { } - - class spell_pal_light_s_beacon_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) + return ValidateSpellInfo(SpellIds.BeaconOfLight, SpellIds.BeaconOfLightHeal); + } + + bool CheckProc(ProcEventInfo eventInfo) + { + if (!eventInfo.GetActionTarget()) + return false; + if (eventInfo.GetActionTarget().HasAura(SpellIds.BeaconOfLight, eventInfo.GetActor().GetGUID())) + return false; + return true; + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + + HealInfo healInfo = eventInfo.GetHealInfo(); + if (healInfo == null || healInfo.GetHeal() == 0) + return; + + uint heal = MathFunctions.CalculatePct(healInfo.GetHeal(), aurEff.GetAmount()); + + var auras = GetCaster().GetSingleCastAuras(); + foreach (var eff in auras) { - return ValidateSpellInfo(SpellIds.BeaconOfLight, SpellIds.BeaconOfLightHeal); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - if (!eventInfo.GetActionTarget()) - return false; - if (eventInfo.GetActionTarget().HasAura(SpellIds.BeaconOfLight, eventInfo.GetActor().GetGUID())) - return false; - return true; - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - HealInfo healInfo = eventInfo.GetHealInfo(); - if (healInfo == null || healInfo.GetHeal() == 0) - return; - - uint heal = MathFunctions.CalculatePct(healInfo.GetHeal(), aurEff.GetAmount()); - - var auras = GetCaster().GetSingleCastAuras(); - foreach (var eff in auras) + if (eff.GetId() == SpellIds.BeaconOfLight) { - if (eff.GetId() == SpellIds.BeaconOfLight) - { - List applications = eff.GetApplicationList(); - if (!applications.Empty()) - eventInfo.GetActor().CastCustomSpell(SpellIds.BeaconOfLightHeal, SpellValueMod.BasePoint0, (int)heal, applications.First().GetTarget(), true); - return; - } + List applications = eff.GetApplicationList(); + if (!applications.Empty()) + eventInfo.GetActor().CastCustomSpell(SpellIds.BeaconOfLightHeal, SpellValueMod.BasePoint0, (int)heal, applications.First().GetTarget(), true); + return; } } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_pal_light_s_beacon_AuraScript(); + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } // 31789 - Righteous Defense [Script] - class spell_pal_righteous_defense : SpellScriptLoader + class spell_pal_righteous_defense : SpellScript { - public spell_pal_righteous_defense() : base("spell_pal_righteous_defense") { } - - class spell_pal_righteous_defense_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.RighteousDefenseTaunt); - } - - SpellCastResult CheckCast() - { - Unit caster = GetCaster(); - if (!caster.IsTypeId(TypeId.Player)) - return SpellCastResult.DontReport; - - Unit target = GetExplTargetUnit(); - if (target) - { - if (!target.IsFriendlyTo(caster) || target.getAttackers().Empty()) - return SpellCastResult.BadTargets; - } - else - return SpellCastResult.BadTargets; - - return SpellCastResult.SpellCastOk; - } - - void HandleTriggerSpellLaunch(uint effIndex) - { - PreventHitDefaultEffect(effIndex); - } - - void HandleTriggerSpellHit(uint effIndex) - { - PreventHitDefaultEffect(effIndex); - Unit target = GetHitUnit(); - if (target) - GetCaster().CastSpell(target, SpellIds.RighteousDefenseTaunt, true); - } - - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - //! WORKAROUND - //! target select will be executed in hitphase of effect 0 - //! so we must handle trigger spell also in hit phase (default execution in launch phase) - //! see issue #3718 - OnEffectLaunchTarget.Add(new EffectHandler(HandleTriggerSpellLaunch, 1, SpellEffectName.TriggerSpell)); - OnEffectHitTarget.Add(new EffectHandler(HandleTriggerSpellHit, 1, SpellEffectName.TriggerSpell)); - } + return ValidateSpellInfo(SpellIds.RighteousDefenseTaunt); } - public override SpellScript GetSpellScript() + SpellCastResult CheckCast() { - return new spell_pal_righteous_defense_SpellScript(); + Unit caster = GetCaster(); + if (!caster.IsTypeId(TypeId.Player)) + return SpellCastResult.DontReport; + + Unit target = GetExplTargetUnit(); + if (target) + { + if (!target.IsFriendlyTo(caster) || target.getAttackers().Empty()) + return SpellCastResult.BadTargets; + } + else + return SpellCastResult.BadTargets; + + return SpellCastResult.SpellCastOk; + } + + void HandleTriggerSpellLaunch(uint effIndex) + { + PreventHitDefaultEffect(effIndex); + } + + void HandleTriggerSpellHit(uint effIndex) + { + PreventHitDefaultEffect(effIndex); + Unit target = GetHitUnit(); + if (target) + GetCaster().CastSpell(target, SpellIds.RighteousDefenseTaunt, true); + } + + public override void Register() + { + OnCheckCast.Add(new CheckCastHandler(CheckCast)); + //! WORKAROUND + //! target select will be executed in hitphase of effect 0 + //! so we must handle trigger spell also in hit phase (default execution in launch phase) + //! see issue #3718 + OnEffectLaunchTarget.Add(new EffectHandler(HandleTriggerSpellLaunch, 1, SpellEffectName.TriggerSpell)); + OnEffectHitTarget.Add(new EffectHandler(HandleTriggerSpellHit, 1, SpellEffectName.TriggerSpell)); } } // 85285 - Sacred Shield [Script] - class spell_pal_sacred_shield : SpellScriptLoader + class spell_pal_sacred_shield : SpellScript { - public spell_pal_sacred_shield() : base("spell_pal_sacred_shield") { } - - class spell_pal_sacred_shield_SpellScript : SpellScript + SpellCastResult CheckCast() { - SpellCastResult CheckCast() - { - Unit caster = GetCaster(); - if (!caster.IsTypeId(TypeId.Player)) - return SpellCastResult.DontReport; + Unit caster = GetCaster(); + if (!caster.IsTypeId(TypeId.Player)) + return SpellCastResult.DontReport; - if (!caster.HealthBelowPct(30)) - return SpellCastResult.CantDoThatRightNow; + if (!caster.HealthBelowPct(30)) + return SpellCastResult.CantDoThatRightNow; - return SpellCastResult.SpellCastOk; - } - - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - } - }; - - public override SpellScript GetSpellScript() - { - return new spell_pal_sacred_shield_SpellScript(); + return SpellCastResult.SpellCastOk; } - } + + public override void Register() + { + OnCheckCast.Add(new CheckCastHandler(CheckCast)); + } + }; // 85256 - Templar's Verdict // Updated 4.3.4 [Script] - class spell_pal_templar_s_verdict : SpellScriptLoader + class spell_pal_templar_s_verdict : SpellScript { - public spell_pal_templar_s_verdict() : base("spell_pal_templar_s_verdict") { } - - class spell_pal_templar_s_verdict_SpellScript : SpellScript + public override bool Validate(SpellInfo spellEntry) { - public override bool Validate(SpellInfo spellEntry) - { - return ValidateSpellInfo(SpellIds.DivinePurposeProc); - } - - public override bool Load() - { - if (!GetCaster().IsTypeId(TypeId.Player)) - return false; - - if (GetCaster().ToPlayer().GetClass() != Class.Paladin) - return false; - - return true; - } - - void ChangeDamage(uint effIndex) - { - Unit caster = GetCaster(); - float damage = GetHitDamage(); - - if (caster.HasAura(SpellIds.DivinePurposeProc)) - damage *= 7.5f; // 7.5*30% = 225% - else - { - switch (caster.GetPower(PowerType.HolyPower)) - { - case 0: // 1 Holy Power - //damage = damage; - break; - case 1: // 2 Holy Power - damage *= 3; // 3*30 = 90% - break; - case 2: // 3 Holy Power - damage *= 7.5f; // 7.5*30% = 225% - break; - } - } - - SetHitDamage((int)damage); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(ChangeDamage, 0, SpellEffectName.WeaponPercentDamage)); - } + return ValidateSpellInfo(SpellIds.DivinePurposeProc); } - public override SpellScript GetSpellScript() + public override bool Load() { - return new spell_pal_templar_s_verdict_SpellScript(); + if (!GetCaster().IsTypeId(TypeId.Player)) + return false; + + if (GetCaster().ToPlayer().GetClass() != Class.Paladin) + return false; + + return true; + } + + void ChangeDamage(uint effIndex) + { + Unit caster = GetCaster(); + float damage = GetHitDamage(); + + if (caster.HasAura(SpellIds.DivinePurposeProc)) + damage *= 7.5f; // 7.5*30% = 225% + else + { + switch (caster.GetPower(PowerType.HolyPower)) + { + case 0: // 1 Holy Power + //damage = damage; + break; + case 1: // 2 Holy Power + damage *= 3; // 3*30 = 90% + break; + case 2: // 3 Holy Power + damage *= 7.5f; // 7.5*30% = 225% + break; + } + } + + SetHitDamage((int)damage); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(ChangeDamage, 0, SpellEffectName.WeaponPercentDamage)); } } // 20154, 21084 - Seal of Righteousness - melee proc dummy (addition ${$MWS*(0.022*$AP+0.044*$SPH)} damage) [Script] - class spell_pal_seal_of_righteousness : SpellScriptLoader + class spell_pal_seal_of_righteousness : AuraScript { - public spell_pal_seal_of_righteousness() : base("spell_pal_seal_of_righteousness") { } - - class spell_pal_seal_of_righteousness_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.SealOfCommand); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - return eventInfo.GetProcTarget(); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - float ap = GetTarget().GetTotalAttackPowerValue(WeaponAttackType.BaseAttack); - int holy = GetTarget().SpellBaseDamageBonusDone(SpellSchoolMask.Holy); - holy += eventInfo.GetProcTarget().SpellBaseDamageBonusTaken(SpellSchoolMask.Holy); - int bp = (int)((ap * 0.022f + 0.044f * holy) * GetTarget().GetBaseAttackTime(WeaponAttackType.BaseAttack) / 1000); - GetTarget().CastCustomSpell(SpellIds.SealOfCommand, SpellValueMod.BasePoint0, bp, eventInfo.GetProcTarget(), true, null, aurEff); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.SealOfCommand); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_pal_seal_of_righteousness_AuraScript(); + return eventInfo.GetProcTarget(); + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + + float ap = GetTarget().GetTotalAttackPowerValue(WeaponAttackType.BaseAttack); + int holy = GetTarget().SpellBaseDamageBonusDone(SpellSchoolMask.Holy); + holy += eventInfo.GetProcTarget().SpellBaseDamageBonusTaken(SpellSchoolMask.Holy); + int bp = (int)((ap * 0.022f + 0.044f * holy) * GetTarget().GetBaseAttackTime(WeaponAttackType.BaseAttack) / 1000); + GetTarget().CastCustomSpell(SpellIds.SealOfCommand, SpellValueMod.BasePoint0, bp, eventInfo.GetProcTarget(), true, null, aurEff); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } [Script] // 28789 - Holy Power - class spell_pal_t3_6p_bonus : SpellScriptLoader + class spell_pal_t3_6p_bonus : AuraScript { - public spell_pal_t3_6p_bonus() : base("spell_pal_t3_6p_bonus") { } - - class spell_pal_t3_6p_bonus_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.HolyPowerArmor, SpellIds.HolyPowerAttackPower, SpellIds.HolyPowerSpellPower, SpellIds.HolyPowerMp5); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - uint spellId; - Unit caster = eventInfo.GetActor(); - Unit target = eventInfo.GetProcTarget(); - - switch (target.GetClass()) - { - case Class.Paladin: - case Class.Priest: - case Class.Shaman: - case Class.Druid: - spellId = SpellIds.HolyPowerMp5; - break; - case Class.Mage: - case Class.Warlock: - spellId = SpellIds.HolyPowerSpellPower; - break; - case Class.Hunter: - case Class.Rogue: - spellId = SpellIds.HolyPowerAttackPower; - break; - case Class.Warrior: - spellId = SpellIds.HolyPowerArmor; - break; - default: - return; - } - - caster.CastSpell(target, spellId, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.HolyPowerArmor, SpellIds.HolyPowerAttackPower, SpellIds.HolyPowerSpellPower, SpellIds.HolyPowerMp5); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_pal_t3_6p_bonus_AuraScript(); + PreventDefaultAction(); + + uint spellId; + Unit caster = eventInfo.GetActor(); + Unit target = eventInfo.GetProcTarget(); + + switch (target.GetClass()) + { + case Class.Paladin: + case Class.Priest: + case Class.Shaman: + case Class.Druid: + spellId = SpellIds.HolyPowerMp5; + break; + case Class.Mage: + case Class.Warlock: + spellId = SpellIds.HolyPowerSpellPower; + break; + case Class.Hunter: + case Class.Rogue: + spellId = SpellIds.HolyPowerAttackPower; + break; + case Class.Warrior: + spellId = SpellIds.HolyPowerArmor; + break; + default: + return; + } + + caster.CastSpell(target, spellId, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } [Script] // 64890 Item - Paladin T8 Holy 2P Bonus - class spell_pal_t8_2p_bonus : SpellScriptLoader + class spell_pal_t8_2p_bonus : AuraScript { - public spell_pal_t8_2p_bonus() : base("spell_pal_t8_2p_bonus") { } - - class spell_pal_t8_2p_bonus_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.HolyMending); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - HealInfo healInfo = eventInfo.GetHealInfo(); - if (healInfo == null || healInfo.GetHeal() == 0) - return; - - Unit caster = eventInfo.GetActor(); - Unit target = eventInfo.GetProcTarget(); - - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.HolyMending); - int amount = (int)MathFunctions.CalculatePct(healInfo.GetHeal(), aurEff.GetAmount()); - amount /= (int)spellInfo.GetMaxTicks(Difficulty.None); - // Add remaining ticks to damage done - amount += (int)target.GetRemainingPeriodicAmount(caster.GetGUID(), SpellIds.HolyMending, AuraType.PeriodicHeal); - - caster.CastCustomSpell(SpellIds.HolyMending, SpellValueMod.BasePoint0, amount, target, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.HolyMending); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_pal_t8_2p_bonus_AuraScript(); + PreventDefaultAction(); + + HealInfo healInfo = eventInfo.GetHealInfo(); + if (healInfo == null || healInfo.GetHeal() == 0) + return; + + Unit caster = eventInfo.GetActor(); + Unit target = eventInfo.GetProcTarget(); + + SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.HolyMending); + int amount = (int)MathFunctions.CalculatePct(healInfo.GetHeal(), aurEff.GetAmount()); + amount /= (int)spellInfo.GetMaxTicks(Difficulty.None); + // Add remaining ticks to damage done + amount += (int)target.GetRemainingPeriodicAmount(caster.GetGUID(), SpellIds.HolyMending, AuraType.PeriodicHeal); + + caster.CastCustomSpell(SpellIds.HolyMending, SpellValueMod.BasePoint0, amount, target, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } } diff --git a/Scripts/Spells/Priest.cs b/Scripts/Spells/Priest.cs index 8470a8644..5779972c3 100644 --- a/Scripts/Spells/Priest.cs +++ b/Scripts/Spells/Priest.cs @@ -84,1345 +84,1035 @@ namespace Scripts.Spells.Priest } [Script] // 26169 - Oracle Healing Bonus - class spell_pri_aq_3p_bonus : SpellScriptLoader + class spell_pri_aq_3p_bonus : AuraScript { - public spell_pri_aq_3p_bonus() : base("spell_pri_aq_3p_bonus") { } - - class spell_pri_aq_3p_bonus_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.OracularHeal); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - Unit caster = eventInfo.GetActor(); - if (caster == eventInfo.GetProcTarget()) - return; - - HealInfo healInfo = eventInfo.GetHealInfo(); - if (healInfo == null || healInfo.GetHeal() == 0) - return; - - int amount = (int)MathFunctions.CalculatePct(healInfo.GetHeal(), 10); - caster.CastCustomSpell(SpellIds.OracularHeal, SpellValueMod.BasePoint0, amount, caster, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.OracularHeal); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_pri_aq_3p_bonus_AuraScript(); + PreventDefaultAction(); + Unit caster = eventInfo.GetActor(); + if (caster == eventInfo.GetProcTarget()) + return; + + HealInfo healInfo = eventInfo.GetHealInfo(); + if (healInfo == null || healInfo.GetHeal() == 0) + return; + + int amount = (int)MathFunctions.CalculatePct(healInfo.GetHeal(), 10); + caster.CastCustomSpell(SpellIds.OracularHeal, SpellValueMod.BasePoint0, amount, caster, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } [Script] // 81749 - Atonement - class spell_pri_atonement : SpellScriptLoader + public class spell_pri_atonement : AuraScript { - public spell_pri_atonement() : base("spell_pri_atonement") { } - - public class spell_pri_atonement_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.AtonementHeal); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - return eventInfo.GetDamageInfo() != null; - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - DamageInfo damageInfo = eventInfo.GetDamageInfo(); - int heal = (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount()); - _appliedAtonements.RemoveAll(targetGuid => - { - Unit target = Global.ObjAccessor.GetUnit(GetTarget(), targetGuid); - if (target) - { - if (target.GetExactDist(GetTarget()) < GetSpellInfo().GetEffect(1).CalcValue()) - GetTarget().CastCustomSpell(SpellIds.AtonementHeal, SpellValueMod.BasePoint0, heal, target, true); - - return false; - } - return true; - }); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } - - List _appliedAtonements = new List(); - - public void AddAtonementTarget(ObjectGuid target) - { - _appliedAtonements.Add(target); - } - - public void RemoveAtonementTarget(ObjectGuid target) - { - _appliedAtonements.Remove(target); - } + return ValidateSpellInfo(SpellIds.AtonementHeal); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_pri_atonement_AuraScript(); + return eventInfo.GetDamageInfo() != null; + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + DamageInfo damageInfo = eventInfo.GetDamageInfo(); + int heal = (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount()); + _appliedAtonements.RemoveAll(targetGuid => + { + Unit target = Global.ObjAccessor.GetUnit(GetTarget(), targetGuid); + if (target) + { + if (target.GetExactDist(GetTarget()) < GetSpellInfo().GetEffect(1).CalcValue()) + GetTarget().CastCustomSpell(SpellIds.AtonementHeal, SpellValueMod.BasePoint0, heal, target, true); + + return false; + } + return true; + }); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + } + + List _appliedAtonements = new List(); + + public void AddAtonementTarget(ObjectGuid target) + { + _appliedAtonements.Add(target); + } + + public void RemoveAtonementTarget(ObjectGuid target) + { + _appliedAtonements.Remove(target); } } [Script] // 194384 - Atonement - class spell_pri_atonement_triggered : SpellScriptLoader + class spell_pri_atonement_triggered : AuraScript { - public spell_pri_atonement_triggered() : base("spell_pri_atonement_triggered") { } - - class spell_pri_atonement_triggered_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.Atonement); - } + return ValidateSpellInfo(SpellIds.Atonement); + } - void HandleOnApply(AuraEffect aurEff, AuraEffectHandleModes mode) + void HandleOnApply(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit caster = GetCaster(); + if (caster) { - Unit caster = GetCaster(); - if (caster) + Aura atonement = caster.GetAura(SpellIds.Atonement); + if (atonement != null) { - Aura atonement = caster.GetAura(SpellIds.Atonement); - if (atonement != null) - { - var script = atonement.GetScript(nameof(spell_pri_atonement)); - if (script != null) - script.AddAtonementTarget(GetTarget().GetGUID()); - } + var script = atonement.GetScript("spell_pri_atonement"); + if (script != null) + script.AddAtonementTarget(GetTarget().GetGUID()); } } - - void HandleOnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Unit caster = GetCaster(); - if (caster) - { - Aura atonement = caster.GetAura(SpellIds.Atonement); - if (atonement != null) - { - var script = atonement.GetScript(nameof(spell_pri_atonement)); - if (script != null) - script.RemoveAtonementTarget(GetTarget().GetGUID()); - } - } - } - - public override void Register() - { - OnEffectApply.Add(new EffectApplyHandler(HandleOnApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - OnEffectRemove.Add(new EffectApplyHandler(HandleOnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - } } - public override AuraScript GetAuraScript() + void HandleOnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_pri_atonement_triggered_AuraScript(); + Unit caster = GetCaster(); + if (caster) + { + Aura atonement = caster.GetAura(SpellIds.Atonement); + if (atonement != null) + { + var script = atonement.GetScript("spell_pri_atonement"); + if (script != null) + script.RemoveAtonementTarget(GetTarget().GetGUID()); + } + } + } + + public override void Register() + { + OnEffectApply.Add(new EffectApplyHandler(HandleOnApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new EffectApplyHandler(HandleOnRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } [Script] // 64129 - Body and Soul - class spell_pri_body_and_soul : SpellScriptLoader + class spell_pri_body_and_soul : AuraScript { - public spell_pri_body_and_soul() : base("spell_pri_body_and_soul") { } - - class spell_pri_body_and_soul_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.CureDisease, SpellIds.BodyAndSoulDispel); - } - - void HandleEffectSpeedProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - // Proc only with Power Word: Shield or Leap of Faith - if (!(eventInfo.GetDamageInfo().GetSpellInfo().SpellFamilyFlags[0].HasAnyFlag(0x1u) || eventInfo.GetDamageInfo().GetSpellInfo().SpellFamilyFlags[2].HasAnyFlag(0x80000u))) - return; - - GetTarget().CastCustomSpell(SpellIds.BodyAndSoulSpeed, SpellValueMod.BasePoint0, aurEff.GetAmount(), eventInfo.GetProcTarget(), true, null, aurEff); - } - - void HandleEffectDispelProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - // Proc only with Cure Disease - if (eventInfo.GetDamageInfo().GetSpellInfo().Id != SpellIds.CureDisease || eventInfo.GetProcTarget() != GetTarget()) - return; - - if (RandomHelper.randChance(aurEff.GetAmount())) - GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.BodyAndSoulDispel, true, null, aurEff); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleEffectSpeedProc, 0, AuraType.Dummy)); - OnEffectProc.Add(new EffectProcHandler(HandleEffectDispelProc, 1, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.CureDisease, SpellIds.BodyAndSoulDispel); } - public override AuraScript GetAuraScript() + void HandleEffectSpeedProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_pri_body_and_soul_AuraScript(); + PreventDefaultAction(); + // Proc only with Power Word: Shield or Leap of Faith + if (!(eventInfo.GetDamageInfo().GetSpellInfo().SpellFamilyFlags[0].HasAnyFlag(0x1u) || eventInfo.GetDamageInfo().GetSpellInfo().SpellFamilyFlags[2].HasAnyFlag(0x80000u))) + return; + + GetTarget().CastCustomSpell(SpellIds.BodyAndSoulSpeed, SpellValueMod.BasePoint0, aurEff.GetAmount(), eventInfo.GetProcTarget(), true, null, aurEff); + } + + void HandleEffectDispelProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + // Proc only with Cure Disease + if (eventInfo.GetDamageInfo().GetSpellInfo().Id != SpellIds.CureDisease || eventInfo.GetProcTarget() != GetTarget()) + return; + + if (RandomHelper.randChance(aurEff.GetAmount())) + GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.BodyAndSoulDispel, true, null, aurEff); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleEffectSpeedProc, 0, AuraType.Dummy)); + OnEffectProc.Add(new EffectProcHandler(HandleEffectDispelProc, 1, AuraType.Dummy)); } } // 34861 - Circle of Healing [Script] - class spell_pri_circle_of_healing : SpellScriptLoader + class spell_pri_circle_of_healing : SpellScript { - public spell_pri_circle_of_healing() : base("spell_pri_circle_of_healing") { } - - class spell_pri_circle_of_healing_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) + return ValidateSpellInfo(SpellIds.GlyphOfCircleOfHealing); + } + + void FilterTargets(List targets) + { + targets.RemoveAll(new Predicate(obj => { - return ValidateSpellInfo(SpellIds.GlyphOfCircleOfHealing); - } + Unit target = obj.ToUnit(); + if (target) + return !GetCaster().IsInRaidWith(target); - void FilterTargets(List targets) + return true; + })); + + uint maxTargets = (uint)(GetCaster().HasAura(SpellIds.GlyphOfCircleOfHealing) ? 6 : 5); // Glyph of Circle of Healing + + if (targets.Count > maxTargets) { - targets.RemoveAll(new Predicate(obj => - { - Unit target = obj.ToUnit(); - if (target) - return !GetCaster().IsInRaidWith(target); - - return true; - })); - - uint maxTargets = (uint)(GetCaster().HasAura(SpellIds.GlyphOfCircleOfHealing) ? 6 : 5); // Glyph of Circle of Healing - - if (targets.Count > maxTargets) - { - targets.Sort(new HealthPctOrderPred()); - targets.Resize(maxTargets); - } - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaAlly)); + targets.Sort(new HealthPctOrderPred()); + targets.Resize(maxTargets); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_pri_circle_of_healing_SpellScript(); + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaAlly)); } } // 527 - Dispel magic [Script] - class spell_pri_dispel_magic : SpellScriptLoader + class spell_pri_dispel_magic : SpellScript { - public spell_pri_dispel_magic() : base("spell_pri_dispel_magic") { } - - class spell_pri_dispel_magic_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.Absolution, SpellIds.GlyphOfDispelMagicHeal, SpellIds.GlyphOfDispelMagic); - } - - SpellCastResult CheckCast() - { - Unit caster = GetCaster(); - Unit target = GetExplTargetUnit(); - - if (!target || (!caster.HasAura(SpellIds.Absolution) && caster != target && target.IsFriendlyTo(caster))) - return SpellCastResult.BadTargets; - return SpellCastResult.SpellCastOk; - } - - void AfterEffectHit(uint effIndex) - { - if (GetHitUnit().IsFriendlyTo(GetCaster())) - { - GetCaster().CastSpell(GetHitUnit(), SpellIds.DispelMagicFriendly, true); - AuraEffect aurEff = GetHitUnit().GetAuraEffect(SpellIds.GlyphOfDispelMagic, 0); - if (aurEff != null) - { - int heal = (int)GetHitUnit().CountPctFromMaxHealth(aurEff.GetAmount()); - GetCaster().CastCustomSpell(SpellIds.GlyphOfDispelMagicHeal, SpellValueMod.BasePoint0, heal, GetHitUnit()); - } - } - else - GetCaster().CastSpell(GetHitUnit(), SpellIds.DispelMagicHostile, true); - } - - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - OnEffectHitTarget.Add(new EffectHandler(AfterEffectHit, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellIds.Absolution, SpellIds.GlyphOfDispelMagicHeal, SpellIds.GlyphOfDispelMagic); } - public override SpellScript GetSpellScript() + SpellCastResult CheckCast() { - return new spell_pri_dispel_magic_SpellScript(); + Unit caster = GetCaster(); + Unit target = GetExplTargetUnit(); + + if (!target || (!caster.HasAura(SpellIds.Absolution) && caster != target && target.IsFriendlyTo(caster))) + return SpellCastResult.BadTargets; + return SpellCastResult.SpellCastOk; + } + + void AfterEffectHit(uint effIndex) + { + if (GetHitUnit().IsFriendlyTo(GetCaster())) + { + GetCaster().CastSpell(GetHitUnit(), SpellIds.DispelMagicFriendly, true); + AuraEffect aurEff = GetHitUnit().GetAuraEffect(SpellIds.GlyphOfDispelMagic, 0); + if (aurEff != null) + { + int heal = (int)GetHitUnit().CountPctFromMaxHealth(aurEff.GetAmount()); + GetCaster().CastCustomSpell(SpellIds.GlyphOfDispelMagicHeal, SpellValueMod.BasePoint0, heal, GetHitUnit()); + } + } + else + GetCaster().CastSpell(GetHitUnit(), SpellIds.DispelMagicHostile, true); + } + + public override void Register() + { + OnCheckCast.Add(new CheckCastHandler(CheckCast)); + OnEffectHitTarget.Add(new EffectHandler(AfterEffectHit, 0, SpellEffectName.Dummy)); } } // -47509 - Divine Aegis [Script] - class spell_pri_divine_aegis : SpellScriptLoader + class spell_pri_divine_aegis : AuraScript { - public spell_pri_divine_aegis() : base("spell_pri_divine_aegis") { } - - class spell_pri_divine_aegis_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.DivineAegis); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - return eventInfo.GetProcTarget(); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - HealInfo healInfo = eventInfo.GetHealInfo(); - if (healInfo == null || healInfo.GetHeal() == 0) - return; - - int absorb = (int)MathFunctions.CalculatePct(healInfo.GetHeal(), aurEff.GetAmount()); - - // Multiple effects stack, so let's try to find this aura. - AuraEffect aegis = eventInfo.GetProcTarget().GetAuraEffect(SpellIds.DivineAegis, 0); - if (aegis != null) - absorb += aegis.GetAmount(); - - absorb = (int)Math.Min(absorb, eventInfo.GetProcTarget().getLevel() * 125); - - GetTarget().CastCustomSpell(SpellIds.DivineAegis, SpellValueMod.BasePoint0, absorb, eventInfo.GetProcTarget(), true, null, aurEff); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.DivineAegis); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_pri_divine_aegis_AuraScript(); + return eventInfo.GetProcTarget(); + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + + HealInfo healInfo = eventInfo.GetHealInfo(); + if (healInfo == null || healInfo.GetHeal() == 0) + return; + + int absorb = (int)MathFunctions.CalculatePct(healInfo.GetHeal(), aurEff.GetAmount()); + + // Multiple effects stack, so let's try to find this aura. + AuraEffect aegis = eventInfo.GetProcTarget().GetAuraEffect(SpellIds.DivineAegis, 0); + if (aegis != null) + absorb += aegis.GetAmount(); + + absorb = (int)Math.Min(absorb, eventInfo.GetProcTarget().getLevel() * 125); + + GetTarget().CastCustomSpell(SpellIds.DivineAegis, SpellValueMod.BasePoint0, absorb, eventInfo.GetProcTarget(), true, null, aurEff); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } // 64844 - Divine Hymn [Script] - class spell_pri_divine_hymn : SpellScriptLoader + class spell_pri_divine_hymn : SpellScript { - public spell_pri_divine_hymn() : base("spell_pri_divine_hymn") { } - - class spell_pri_divine_hymn_SpellScript : SpellScript + void FilterTargets(List targets) { - void FilterTargets(List targets) + targets.RemoveAll(new Predicate(obj => { - targets.RemoveAll(new Predicate(obj => - { - Unit target = obj.ToUnit(); - if (target) - return !GetCaster().IsInRaidWith(target); + Unit target = obj.ToUnit(); + if (target) + return !GetCaster().IsInRaidWith(target); - return true; - })); + return true; + })); - uint maxTargets = 3; + uint maxTargets = 3; - if (targets.Count > maxTargets) - { - targets.Sort(new HealthPctOrderPred()); - targets.Resize(maxTargets); - } - } - - public override void Register() + if (targets.Count > maxTargets) { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, SpellConst.EffectAll, Targets.UnitSrcAreaAlly)); + targets.Sort(new HealthPctOrderPred()); + targets.Resize(maxTargets); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_pri_divine_hymn_SpellScript(); + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, SpellConst.EffectAll, Targets.UnitSrcAreaAlly)); } } // 55680 - Glyph of Prayer of Healing [Script] - class spell_pri_glyph_of_prayer_of_healing : SpellScriptLoader + class spell_pri_glyph_of_prayer_of_healing : AuraScript { - public spell_pri_glyph_of_prayer_of_healing() : base("spell_pri_glyph_of_prayer_of_healing") { } - - class spell_pri_glyph_of_prayer_of_healing_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.GlyphOfPrayerOfHealingHeal); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - HealInfo healInfo = eventInfo.GetHealInfo(); - if (healInfo == null || healInfo.GetHeal() == 0) - return; - - SpellInfo triggeredSpellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.GlyphOfPrayerOfHealingHeal); - int heal = (int)(MathFunctions.CalculatePct(healInfo.GetHeal(), aurEff.GetAmount()) / triggeredSpellInfo.GetMaxTicks(Difficulty.None)); - GetTarget().CastCustomSpell(SpellIds.GlyphOfPrayerOfHealingHeal, SpellValueMod.BasePoint0, heal, eventInfo.GetProcTarget(), true, null, aurEff); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.GlyphOfPrayerOfHealingHeal); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_pri_glyph_of_prayer_of_healing_AuraScript(); + PreventDefaultAction(); + + HealInfo healInfo = eventInfo.GetHealInfo(); + if (healInfo == null || healInfo.GetHeal() == 0) + return; + + SpellInfo triggeredSpellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.GlyphOfPrayerOfHealingHeal); + int heal = (int)(MathFunctions.CalculatePct(healInfo.GetHeal(), aurEff.GetAmount()) / triggeredSpellInfo.GetMaxTicks(Difficulty.None)); + GetTarget().CastCustomSpell(SpellIds.GlyphOfPrayerOfHealingHeal, SpellValueMod.BasePoint0, heal, eventInfo.GetProcTarget(), true, null, aurEff); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } [Script] // 24191 - Improved Power Word Shield - class spell_pri_improved_power_word_shield : SpellScriptLoader + class spell_pri_improved_power_word_shield : AuraScript { - public spell_pri_improved_power_word_shield() : base("spell_pri_improved_power_word_shield") { } - - class spell_pri_improved_power_word_shield_AuraScript : AuraScript + void HandleEffectCalcSpellMod(AuraEffect aurEff, ref SpellModifier spellMod) { - void HandleEffectCalcSpellMod(AuraEffect aurEff, ref SpellModifier spellMod) + if (spellMod == null) { - if (spellMod == null) - { - spellMod = new SpellModifier(GetAura()); - spellMod.op = (SpellModOp)aurEff.GetMiscValue(); - spellMod.type = SpellModType.Pct; - spellMod.spellId = GetId(); - spellMod.mask = GetSpellInfo().GetEffect(aurEff.GetEffIndex()).SpellClassMask; - } - - spellMod.value = aurEff.GetAmount(); + spellMod = new SpellModifier(GetAura()); + spellMod.op = (SpellModOp)aurEff.GetMiscValue(); + spellMod.type = SpellModType.Pct; + spellMod.spellId = GetId(); + spellMod.mask = GetSpellInfo().GetEffect(aurEff.GetEffIndex()).SpellClassMask; } - public override void Register() - { - DoEffectCalcSpellMod.Add(new EffectCalcSpellModHandler(HandleEffectCalcSpellMod, 0, AuraType.Dummy)); - } + spellMod.value = aurEff.GetAmount(); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_pri_improved_power_word_shield_AuraScript(); + DoEffectCalcSpellMod.Add(new EffectCalcSpellModHandler(HandleEffectCalcSpellMod, 0, AuraType.Dummy)); } } // 47788 - Guardian Spirit [Script] - class spell_pri_guardian_spirit : SpellScriptLoader + class spell_pri_guardian_spirit : AuraScript { - public spell_pri_guardian_spirit() : base("spell_pri_guardian_spirit") { } + uint healPct; - class spell_pri_guardian_spirit_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - uint healPct; - - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.GuardianSpiritHeal); - } - - public override bool Load() - { - healPct = (uint)GetSpellInfo().GetEffect(1).CalcValue(); - return true; - } - - void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) - { - // Set absorbtion amount to unlimited - amount = -1; - } - - void Absorb(AuraEffect aurEff, DamageInfo dmgInfo, ref uint absorbAmount) - { - Unit target = GetTarget(); - if (dmgInfo.GetDamage() < target.GetHealth()) - return; - - int healAmount = (int)target.CountPctFromMaxHealth((int)healPct); - // remove the aura now, we don't want 40% healing bonus - Remove(AuraRemoveMode.EnemySpell); - target.CastCustomSpell(target, SpellIds.GuardianSpiritHeal, healAmount, 0, 0, true); - absorbAmount = dmgInfo.GetDamage(); - } - - public override void Register() - { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 1, AuraType.SchoolAbsorb)); - OnEffectAbsorb.Add(new EffectAbsorbHandler(Absorb, 1)); - } + return ValidateSpellInfo(SpellIds.GuardianSpiritHeal); } - public override AuraScript GetAuraScript() + public override bool Load() { - return new spell_pri_guardian_spirit_AuraScript(); + healPct = (uint)GetSpellInfo().GetEffect(1).CalcValue(); + return true; + } + + void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + { + // Set absorbtion amount to unlimited + amount = -1; + } + + void Absorb(AuraEffect aurEff, DamageInfo dmgInfo, ref uint absorbAmount) + { + Unit target = GetTarget(); + if (dmgInfo.GetDamage() < target.GetHealth()) + return; + + int healAmount = (int)target.CountPctFromMaxHealth((int)healPct); + // remove the aura now, we don't want 40% healing bonus + Remove(AuraRemoveMode.EnemySpell); + target.CastCustomSpell(target, SpellIds.GuardianSpiritHeal, healAmount, 0, 0, true); + absorbAmount = dmgInfo.GetDamage(); + } + + public override void Register() + { + DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 1, AuraType.SchoolAbsorb)); + OnEffectAbsorb.Add(new EffectAbsorbHandler(Absorb, 1)); } } // 64904 - Hymn of Hope [Script] - class spell_pri_hymn_of_hope : SpellScriptLoader + class spell_pri_hymn_of_hope : SpellScript { - public spell_pri_hymn_of_hope() : base("spell_pri_hymn_of_hope") { } - - class spell_pri_hymn_of_hope_SpellScript : SpellScript + void FilterTargets(List targets) { - void FilterTargets(List targets) + targets.RemoveAll(new Predicate(obj => { - targets.RemoveAll(new Predicate(obj => - { - Unit target = obj.ToUnit(); - if (target) - return target.getPowerType() != PowerType.Mana; + Unit target = obj.ToUnit(); + if (target) + return target.getPowerType() != PowerType.Mana; - return true; - })); + return true; + })); - targets.RemoveAll(new Predicate(obj => - { - Unit target = obj.ToUnit(); - if (target) - return !GetCaster().IsInRaidWith(target); - - return true; - })); - - uint maxTargets = 3; - - if (targets.Count > maxTargets) - { - targets.Sort(new PowerPctOrderPred(PowerType.Mana)); - targets.Resize(maxTargets); - } - } - - public override void Register() + targets.RemoveAll(new Predicate(obj => { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, SpellConst.EffectAll, Targets.UnitSrcAreaAlly)); + Unit target = obj.ToUnit(); + if (target) + return !GetCaster().IsInRaidWith(target); + + return true; + })); + + uint maxTargets = 3; + + if (targets.Count > maxTargets) + { + targets.Sort(new PowerPctOrderPred(PowerType.Mana)); + targets.Resize(maxTargets); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_pri_hymn_of_hope_SpellScript(); + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, SpellConst.EffectAll, Targets.UnitSrcAreaAlly)); } } [Script] // 40438 - Priest Tier 6 Trinket - class spell_pri_item_t6_trinket : SpellScriptLoader + class spell_pri_item_t6_trinket : AuraScript { - public spell_pri_item_t6_trinket() : base("spell_pri_item_t6_trinket") { } - - class spell_pri_item_t6_trinket_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.DivineBlessing, SpellIds.DivineWrath); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - Unit caster = eventInfo.GetActor(); - if (eventInfo.GetSpellTypeMask().HasAnyFlag(ProcFlagsSpellType.Heal)) - caster.CastSpell((Unit)null, SpellIds.DivineBlessing, true); - - if (eventInfo.GetSpellTypeMask().HasAnyFlag(ProcFlagsSpellType.Damage)) - caster.CastSpell((Unit)null, SpellIds.DivineWrath, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.DivineBlessing, SpellIds.DivineWrath); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_pri_item_t6_trinket_AuraScript(); + PreventDefaultAction(); + Unit caster = eventInfo.GetActor(); + if (eventInfo.GetSpellTypeMask().HasAnyFlag(ProcFlagsSpellType.Heal)) + caster.CastSpell((Unit)null, SpellIds.DivineBlessing, true); + + if (eventInfo.GetSpellTypeMask().HasAnyFlag(ProcFlagsSpellType.Damage)) + caster.CastSpell((Unit)null, SpellIds.DivineWrath, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } // 92833 - Leap of Faith [Script] - class spell_pri_leap_of_faith_effect_trigger : SpellScriptLoader + class spell_pri_leap_of_faith_effect_trigger : SpellScript { - public spell_pri_leap_of_faith_effect_trigger() : base("spell_pri_leap_of_faith_effect_trigger") { } - - class spell_pri_leap_of_faith_effect_trigger_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.LeapOfFaithEffect); - } - - void HandleEffectDummy(uint effIndex) - { - Position destPos = GetHitDest().GetPosition(); - - SpellCastTargets targets = new SpellCastTargets(); - targets.SetDst(destPos); - targets.SetUnitTarget(GetCaster()); - GetHitUnit().CastSpell(targets, Global.SpellMgr.GetSpellInfo((uint)GetEffectValue()), null); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleEffectDummy, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellIds.LeapOfFaithEffect); } - public override SpellScript GetSpellScript() + void HandleEffectDummy(uint effIndex) { - return new spell_pri_leap_of_faith_effect_trigger_SpellScript(); + Position destPos = GetHitDest().GetPosition(); + + SpellCastTargets targets = new SpellCastTargets(); + targets.SetDst(destPos); + targets.SetUnitTarget(GetCaster()); + GetHitUnit().CastSpell(targets, Global.SpellMgr.GetSpellInfo((uint)GetEffectValue()), null); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleEffectDummy, 0, SpellEffectName.Dummy)); } } [Script] // 1706 - Levitate - class spell_pri_levitate : SpellScriptLoader + class spell_pri_levitate : SpellScript { - public spell_pri_levitate() : base("spell_pri_levitate") { } - - class spell_pri_levitate_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.LevitateEffect); - } - - void HandleDummy(uint effIndex) - { - GetCaster().CastSpell(GetHitUnit(), SpellIds.LevitateEffect, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellIds.LevitateEffect); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_pri_levitate_SpellScript(); + GetCaster().CastSpell(GetHitUnit(), SpellIds.LevitateEffect, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } // 7001 - Lightwell Renew [Script] - class spell_pri_lightwell_renew : SpellScriptLoader + class spell_pri_lightwell_renew : AuraScript { - public spell_pri_lightwell_renew() : base("spell_pri_lightwell_renew") { } - - class spell_pri_lightwell_renew_AuraScript : AuraScript + void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) { - void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + Unit caster = GetCaster(); + if (caster) { - Unit caster = GetCaster(); - if (caster) - { - // Bonus from Glyph of Lightwell - AuraEffect modHealing = caster.GetAuraEffect(SpellIds.GlyphOfLightwell, 0); - if (modHealing != null) - MathFunctions.AddPct(ref amount, modHealing.GetAmount()); - } - } - - public override void Register() - { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.PeriodicHeal)); + // Bonus from Glyph of Lightwell + AuraEffect modHealing = caster.GetAuraEffect(SpellIds.GlyphOfLightwell, 0); + if (modHealing != null) + MathFunctions.AddPct(ref amount, modHealing.GetAmount()); } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_pri_lightwell_renew_AuraScript(); + DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.PeriodicHeal)); } } // 8129 - Mana Burn [Script] - class spell_pri_mana_burn : SpellScriptLoader + class spell_pri_mana_burn : SpellScript { - public spell_pri_mana_burn() : base("spell_pri_mana_burn") { } - - class spell_pri_mana_burn_SpellScript : SpellScript + void HandleAfterHit() { - void HandleAfterHit() - { - Unit unitTarget = GetHitUnit(); - if (unitTarget) - unitTarget.RemoveAurasWithMechanic((1 << (int)Mechanics.Fear) | (1 << (int)Mechanics.Polymorph)); - } - - public override void Register() - { - AfterHit.Add(new HitHandler(HandleAfterHit)); - } + Unit unitTarget = GetHitUnit(); + if (unitTarget) + unitTarget.RemoveAurasWithMechanic((1 << (int)Mechanics.Fear) | (1 << (int)Mechanics.Polymorph)); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_pri_mana_burn_SpellScript(); + AfterHit.Add(new HitHandler(HandleAfterHit)); } } // 28305 - Mana Leech (Passive) (Priest Pet Aura) [Script] - class spell_pri_mana_leech : SpellScriptLoader + class spell_pri_mana_leech : AuraScript { - public spell_pri_mana_leech() : base("spell_pri_mana_leech") { } - - class spell_pri_mana_leech_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ManaLeechProc); - } - - public override bool Load() - { - _procTarget = null; - return true; - } - - bool CheckProc(ProcEventInfo eventInfo) - { - _procTarget = GetTarget().GetOwner(); - return _procTarget; - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - GetTarget().CastSpell(_procTarget, SpellIds.ManaLeechProc, true, null, aurEff); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } - - Unit _procTarget; + return ValidateSpellInfo(SpellIds.ManaLeechProc); } - public override AuraScript GetAuraScript() + public override bool Load() { - return new spell_pri_mana_leech_AuraScript(); + _procTarget = null; + return true; } + + bool CheckProc(ProcEventInfo eventInfo) + { + _procTarget = GetTarget().GetOwner(); + return _procTarget; + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + GetTarget().CastSpell(_procTarget, SpellIds.ManaLeechProc, true, null, aurEff); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + } + + Unit _procTarget; } // 47948 - Pain and Suffering (Proc) [Script] - class spell_pri_pain_and_suffering_proc : SpellScriptLoader + class spell_pri_pain_and_suffering_proc : SpellScript { - public spell_pri_pain_and_suffering_proc() : base("spell_pri_pain_and_suffering_proc") { } - - class spell_pri_pain_and_suffering_proc_SpellScript : SpellScript + void HandleEffectScriptEffect(uint effIndex) { - void HandleEffectScriptEffect(uint effIndex) + // Refresh Shadow Word: Pain on target + Unit unitTarget = GetHitUnit(); + if (unitTarget) { - // Refresh Shadow Word: Pain on target - Unit unitTarget = GetHitUnit(); - if (unitTarget) - { - AuraEffect aur = unitTarget.GetAuraEffect(AuraType.PeriodicDamage, SpellFamilyNames.Priest, new FlagArray128(0x8000, 0, 0), GetCaster().GetGUID()); - if (aur != null) - aur.GetBase().RefreshDuration(); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleEffectScriptEffect, 0, SpellEffectName.ScriptEffect)); + AuraEffect aur = unitTarget.GetAuraEffect(AuraType.PeriodicDamage, SpellFamilyNames.Priest, new FlagArray128(0x8000, 0, 0), GetCaster().GetGUID()); + if (aur != null) + aur.GetBase().RefreshDuration(); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_pri_pain_and_suffering_proc_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleEffectScriptEffect, 0, SpellEffectName.ScriptEffect)); } } // 47540 - Penance [Script] - class spell_pri_penance : SpellScriptLoader + class spell_pri_penance : SpellScript { - public spell_pri_penance() : base("spell_pri_penance") { } - - class spell_pri_penance_SpellScript : SpellScript + public override bool Load() { - public override bool Load() + return GetCaster().IsTypeId(TypeId.Player); + } + + public override bool Validate(SpellInfo spellInfo) + { + SpellInfo firstRankSpellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.PenanceR1); + if (firstRankSpellInfo == null) + return false; + + // can't use other spell than this penance due to spell_ranks dependency + if (!spellInfo.IsRankOf(firstRankSpellInfo)) + return false; + + byte rank = spellInfo.GetRank(); + if (Global.SpellMgr.GetSpellWithRank(SpellIds.PenanceR1Damage, rank, true) == 0) + return false; + if (Global.SpellMgr.GetSpellWithRank(SpellIds.PenanceR1Heal, rank, true) == 0) + return false; + + return true; + } + + void HandleDummy(uint effIndex) + { + Unit caster = GetCaster(); + Unit target = GetHitUnit(); + if (target) { - return GetCaster().IsTypeId(TypeId.Player); - } + if (!target.IsAlive()) + return; - public override bool Validate(SpellInfo spellInfo) - { - SpellInfo firstRankSpellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.PenanceR1); - if (firstRankSpellInfo == null) - return false; + byte rank = GetSpellInfo().GetRank(); - // can't use other spell than this penance due to spell_ranks dependency - if (!spellInfo.IsRankOf(firstRankSpellInfo)) - return false; - - byte rank = spellInfo.GetRank(); - if (Global.SpellMgr.GetSpellWithRank(SpellIds.PenanceR1Damage, rank, true) == 0) - return false; - if (Global.SpellMgr.GetSpellWithRank(SpellIds.PenanceR1Heal, rank, true) == 0) - return false; - - return true; - } - - void HandleDummy(uint effIndex) - { - Unit caster = GetCaster(); - Unit target = GetHitUnit(); - if (target) - { - if (!target.IsAlive()) - return; - - byte rank = GetSpellInfo().GetRank(); - - if (caster.IsFriendlyTo(target)) - caster.CastSpell(target, Global.SpellMgr.GetSpellWithRank(SpellIds.PenanceR1Heal, rank), false); - else - caster.CastSpell(target, Global.SpellMgr.GetSpellWithRank(SpellIds.PenanceR1Damage, rank), false); - } - } - - SpellCastResult CheckCast() - { - Player caster = GetCaster().ToPlayer(); - Unit target = GetExplTargetUnit(); - if (target) - { - if (!caster.IsFriendlyTo(target)) - { - if (!caster.IsValidAttackTarget(target)) - return SpellCastResult.BadTargets; - - if (!caster.isInFront(target)) - return SpellCastResult.NotInfront; - } - else - { - //Support for modifications of this spell in Legion with The Penitent talent (7.1.5) - if (!caster.HasAura(SpellIds.ThePenitentAura)) - return SpellCastResult.BadTargets; - - if (!caster.isInFront(target)) - return SpellCastResult.UnitNotInfront; - } - } - return SpellCastResult.SpellCastOk; - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - OnCheckCast.Add(new CheckCastHandler(CheckCast)); + if (caster.IsFriendlyTo(target)) + caster.CastSpell(target, Global.SpellMgr.GetSpellWithRank(SpellIds.PenanceR1Heal, rank), false); + else + caster.CastSpell(target, Global.SpellMgr.GetSpellWithRank(SpellIds.PenanceR1Damage, rank), false); } } - public override SpellScript GetSpellScript() + SpellCastResult CheckCast() { - return new spell_pri_penance_SpellScript(); + Player caster = GetCaster().ToPlayer(); + Unit target = GetExplTargetUnit(); + if (target) + { + if (!caster.IsFriendlyTo(target)) + { + if (!caster.IsValidAttackTarget(target)) + return SpellCastResult.BadTargets; + + if (!caster.isInFront(target)) + return SpellCastResult.NotInfront; + } + else + { + //Support for modifications of this spell in Legion with The Penitent talent (7.1.5) + if (!caster.HasAura(SpellIds.ThePenitentAura)) + return SpellCastResult.BadTargets; + + if (!caster.isInFront(target)) + return SpellCastResult.UnitNotInfront; + } + } + return SpellCastResult.SpellCastOk; + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnCheckCast.Add(new CheckCastHandler(CheckCast)); } } // -47569 - Phantasm [Script] - class spell_pri_phantasm : SpellScriptLoader + class spell_pri_phantasm : AuraScript { - public spell_pri_phantasm() : base("spell_pri_phantasm") { } - - class spell_pri_phantasm_AuraScript : AuraScript + bool CheckProc(ProcEventInfo eventInfo) { - bool CheckProc(ProcEventInfo eventInfo) - { - return RandomHelper.randChance(GetEffect(0).GetAmount()); - } - - void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - GetTarget().RemoveMovementImpairingAuras(); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); - } + return RandomHelper.randChance(GetEffect(0).GetAmount()); } - public override AuraScript GetAuraScript() + void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_pri_phantasm_AuraScript(); + PreventDefaultAction(); + GetTarget().RemoveMovementImpairingAuras(); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); } } [Script] // 17 - Power Word: Shield - class spell_pri_power_word_shield : SpellScriptLoader + class spell_pri_power_word_shield : AuraScript { - public spell_pri_power_word_shield() : base("spell_pri_power_word_shield") { } - - class spell_pri_power_word_shield_AuraScript : AuraScript + void CalculateAmount(AuraEffect auraEffect, ref int amount, ref bool canBeRecalculated) { - void CalculateAmount(AuraEffect auraEffect, ref int amount, ref bool canBeRecalculated) + canBeRecalculated = false; + + Player player = GetCaster().ToPlayer(); + if (player) { - canBeRecalculated = false; + int playerMastery = (int)player.GetRatingBonusValue(CombatRating.Mastery); + int playerSpellPower = player.SpellBaseDamageBonusDone(SpellSchoolMask.Holy); + int playerVersatileDamage = (int)player.GetRatingBonusValue(CombatRating.VersatilityDamageDone); - Player player = GetCaster().ToPlayer(); - if (player) - { - int playerMastery = (int)player.GetRatingBonusValue(CombatRating.Mastery); - int playerSpellPower = player.SpellBaseDamageBonusDone(SpellSchoolMask.Holy); - int playerVersatileDamage = (int)player.GetRatingBonusValue(CombatRating.VersatilityDamageDone); - - //Formula taken from SpellWork - amount = (int)((playerSpellPower * 5.5f) + playerMastery) * (1 + playerVersatileDamage); - } - } - - void HandleOnApply(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Unit caster = GetCaster(); - Unit target = GetTarget(); - if (!caster) - return; - - if (caster.HasAura(SpellIds.BodyAndSoul)) - caster.CastSpell(target, SpellIds.BodyAndSoulSpeed, true); - if (caster.HasAura(SpellIds.StrengthOfSoul)) - caster.CastSpell(target, SpellIds.StrengthOfSoulEffect, true); - if (caster.HasAura(SpellIds.RenewedHope)) - caster.CastSpell(target, SpellIds.RenewedHopeEffect, true); - if (caster.HasAura(SpellIds.VoidShield) && caster == target) - caster.CastSpell(target, SpellIds.VoidShieldEffect, true); - if (caster.HasAura(SpellIds.Atonement)) - caster.CastSpell(target, SpellIds.AtonementTriggered, true); - } - - void HandleOnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - GetTarget().RemoveAura(SpellIds.StrengthOfSoulEffect); - Unit caster = GetCaster(); - if (caster) - if (GetTargetApplication().GetRemoveMode() == AuraRemoveMode.EnemySpell && caster.HasAura(SpellIds.ShieldDisciplinePassive)) - caster.CastSpell(caster, SpellIds.ShieldDisciplineEnergize, true); - } - - public override void Register() - { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.SchoolAbsorb)); - AfterEffectApply.Add(new EffectApplyHandler(HandleOnApply, 0, AuraType.SchoolAbsorb, AuraEffectHandleModes.RealOrReapplyMask)); - AfterEffectRemove.Add(new EffectApplyHandler(HandleOnRemove, 0, AuraType.SchoolAbsorb, AuraEffectHandleModes.Real)); + //Formula taken from SpellWork + amount = (int)((playerSpellPower * 5.5f) + playerMastery) * (1 + playerVersatileDamage); } } - public override AuraScript GetAuraScript() + void HandleOnApply(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_pri_power_word_shield_AuraScript(); + Unit caster = GetCaster(); + Unit target = GetTarget(); + if (!caster) + return; + + if (caster.HasAura(SpellIds.BodyAndSoul)) + caster.CastSpell(target, SpellIds.BodyAndSoulSpeed, true); + if (caster.HasAura(SpellIds.StrengthOfSoul)) + caster.CastSpell(target, SpellIds.StrengthOfSoulEffect, true); + if (caster.HasAura(SpellIds.RenewedHope)) + caster.CastSpell(target, SpellIds.RenewedHopeEffect, true); + if (caster.HasAura(SpellIds.VoidShield) && caster == target) + caster.CastSpell(target, SpellIds.VoidShieldEffect, true); + if (caster.HasAura(SpellIds.Atonement)) + caster.CastSpell(target, SpellIds.AtonementTriggered, true); + } + + void HandleOnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + GetTarget().RemoveAura(SpellIds.StrengthOfSoulEffect); + Unit caster = GetCaster(); + if (caster) + if (GetTargetApplication().GetRemoveMode() == AuraRemoveMode.EnemySpell && caster.HasAura(SpellIds.ShieldDisciplinePassive)) + caster.CastSpell(caster, SpellIds.ShieldDisciplineEnergize, true); + } + + public override void Register() + { + DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.SchoolAbsorb)); + AfterEffectApply.Add(new EffectApplyHandler(HandleOnApply, 0, AuraType.SchoolAbsorb, AuraEffectHandleModes.RealOrReapplyMask)); + AfterEffectRemove.Add(new EffectApplyHandler(HandleOnRemove, 0, AuraType.SchoolAbsorb, AuraEffectHandleModes.Real)); } } [Script] // 33110 - Prayer of Mending Heal - class spell_pri_prayer_of_mending_heal : SpellScriptLoader + class spell_pri_prayer_of_mending_heal : SpellScript { - public spell_pri_prayer_of_mending_heal() : base("spell_pri_prayer_of_mending_heal") { } - - class spell_pri_prayer_of_mending_heal_SpellScript : SpellScript + void HandleHeal(uint effIndex) { - void HandleHeal(uint effIndex) + Unit caster = GetOriginalCaster(); + if (caster) { - Unit caster = GetOriginalCaster(); - if (caster) + AuraEffect aurEff = caster.GetAuraEffect(SpellIds.T9Healing2p, 0); + if (aurEff != null) { - AuraEffect aurEff = caster.GetAuraEffect(SpellIds.T9Healing2p, 0); - if (aurEff != null) - { - int heal = GetHitHeal(); - MathFunctions.AddPct(ref heal, aurEff.GetAmount()); - SetHitHeal(heal); - } + int heal = GetHitHeal(); + MathFunctions.AddPct(ref heal, aurEff.GetAmount()); + SetHitHeal(heal); } } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleHeal, 0, SpellEffectName.Heal)); - } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_pri_prayer_of_mending_heal_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleHeal, 0, SpellEffectName.Heal)); } } // 15473 - Shadowform [Script] - class spell_pri_shadowform : SpellScriptLoader + class spell_pri_shadowform : AuraScript { - public spell_pri_shadowform() : base("spell_pri_shadowform") { } - - class spell_pri_shadowform_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ShadowformVisualWithoutGlyph, SpellIds.ShadowformVisualWithGlyph); - } - - void HandleEffectApply(AuraEffect aurEff, AuraEffectHandleModes mode) - { - GetTarget().CastSpell(GetTarget(), GetTarget().HasAura(SpellIds.GlyphOfShadow) ? SpellIds.ShadowformVisualWithGlyph : SpellIds.ShadowformVisualWithoutGlyph, true); - } - - void HandleEffectRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - GetTarget().RemoveAurasDueToSpell(GetTarget().HasAura(SpellIds.GlyphOfShadow) ? SpellIds.ShadowformVisualWithGlyph : SpellIds.ShadowformVisualWithoutGlyph); - } - - public override void Register() - { - AfterEffectApply.Add(new EffectApplyHandler(HandleEffectApply, 0, AuraType.ModShapeshift, AuraEffectHandleModes.RealOrReapplyMask)); - AfterEffectRemove.Add(new EffectApplyHandler(HandleEffectRemove, 0, AuraType.ModShapeshift, AuraEffectHandleModes.RealOrReapplyMask)); - } + return ValidateSpellInfo(SpellIds.ShadowformVisualWithoutGlyph, SpellIds.ShadowformVisualWithGlyph); } - public override AuraScript GetAuraScript() + void HandleEffectApply(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_pri_shadowform_AuraScript(); + GetTarget().CastSpell(GetTarget(), GetTarget().HasAura(SpellIds.GlyphOfShadow) ? SpellIds.ShadowformVisualWithGlyph : SpellIds.ShadowformVisualWithoutGlyph, true); + } + + void HandleEffectRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + GetTarget().RemoveAurasDueToSpell(GetTarget().HasAura(SpellIds.GlyphOfShadow) ? SpellIds.ShadowformVisualWithGlyph : SpellIds.ShadowformVisualWithoutGlyph); + } + + public override void Register() + { + AfterEffectApply.Add(new EffectApplyHandler(HandleEffectApply, 0, AuraType.ModShapeshift, AuraEffectHandleModes.RealOrReapplyMask)); + AfterEffectRemove.Add(new EffectApplyHandler(HandleEffectRemove, 0, AuraType.ModShapeshift, AuraEffectHandleModes.RealOrReapplyMask)); } } [Script] // 28809 - Greater Heal - class spell_pri_t3_4p_bonus : SpellScriptLoader + class spell_pri_t3_4p_bonus : AuraScript { - public spell_pri_t3_4p_bonus() : base("spell_pri_t3_4p_bonus") { } - - class spell_pri_t3_4p_bonus_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ArmorOfFaith); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), SpellIds.ArmorOfFaith, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.ArmorOfFaith); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_pri_t3_4p_bonus_AuraScript(); + PreventDefaultAction(); + eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), SpellIds.ArmorOfFaith, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } [Script] // 37594 - Greater Heal Refund - class spell_pri_t5_heal_2p_bonus : SpellScriptLoader + class spell_pri_t5_heal_2p_bonus : AuraScript { - public spell_pri_t5_heal_2p_bonus() : base("spell_pri_t5_heal_2p_bonus") { } - - class spell_pri_t5_heal_2p_bonus_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ItemEfficiency); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - HealInfo healInfo = eventInfo.GetHealInfo(); - if (healInfo != null) - { - Unit healTarget = healInfo.GetTarget(); - if (healTarget) - // @todo: fix me later if (healInfo.GetEffectiveHeal()) - if (healTarget.GetHealth() >= healTarget.GetMaxHealth()) - return true; - } - - return false; - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), SpellIds.ItemEfficiency, true, null, aurEff); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); - } + return ValidateSpellInfo(SpellIds.ItemEfficiency); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_pri_t5_heal_2p_bonus_AuraScript(); + HealInfo healInfo = eventInfo.GetHealInfo(); + if (healInfo != null) + { + Unit healTarget = healInfo.GetTarget(); + if (healTarget) + // @todo: fix me later if (healInfo.GetEffectiveHeal()) + if (healTarget.GetHealth() >= healTarget.GetMaxHealth()) + return true; + } + + return false; + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + GetTarget().CastSpell(GetTarget(), SpellIds.ItemEfficiency, true, null, aurEff); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); } } [Script] // 70770 - Item - Priest T10 Healer 2P Bonus - class spell_pri_t10_heal_2p_bonus : SpellScriptLoader + class spell_pri_t10_heal_2p_bonus : AuraScript { - public spell_pri_t10_heal_2p_bonus() : base("spell_pri_t10_heal_2p_bonus") { } - - class spell_pri_t10_heal_2p_bonus_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.BlessedHealing); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - HealInfo healInfo = eventInfo.GetHealInfo(); - if (healInfo == null || healInfo.GetHeal() == 0) - return; - - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.BlessedHealing); - int amount = (int)MathFunctions.CalculatePct(healInfo.GetHeal(), aurEff.GetAmount()); - amount /= (int)spellInfo.GetMaxTicks(Difficulty.None); - - // Add remaining ticks to healing done - Unit caster = eventInfo.GetActor(); - Unit target = eventInfo.GetProcTarget(); - amount += (int)target.GetRemainingPeriodicAmount(caster.GetGUID(), SpellIds.BlessedHealing, AuraType.PeriodicHeal); - - caster.CastCustomSpell(SpellIds.BlessedHealing, SpellValueMod.BasePoint0, amount, target, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.BlessedHealing); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_pri_t10_heal_2p_bonus_AuraScript(); + PreventDefaultAction(); + + HealInfo healInfo = eventInfo.GetHealInfo(); + if (healInfo == null || healInfo.GetHeal() == 0) + return; + + SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.BlessedHealing); + int amount = (int)MathFunctions.CalculatePct(healInfo.GetHeal(), aurEff.GetAmount()); + amount /= (int)spellInfo.GetMaxTicks(Difficulty.None); + + // Add remaining ticks to healing done + Unit caster = eventInfo.GetActor(); + Unit target = eventInfo.GetProcTarget(); + amount += (int)target.GetRemainingPeriodicAmount(caster.GetGUID(), SpellIds.BlessedHealing, AuraType.PeriodicHeal); + + caster.CastCustomSpell(SpellIds.BlessedHealing, SpellValueMod.BasePoint0, amount, target, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } // 15286 - Vampiric Embrace [Script] - class spell_pri_vampiric_embrace : SpellScriptLoader + class spell_pri_vampiric_embrace : AuraScript { - public spell_pri_vampiric_embrace() : base("spell_pri_vampiric_embrace") { } - - class spell_pri_vampiric_embrace_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.VampiricEmbraceHeal); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - // Not proc from Mind Sear - return !eventInfo.GetDamageInfo().GetSpellInfo().SpellFamilyFlags[1].HasAnyFlag(0x80000u); - } - - void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - DamageInfo damageInfo = eventInfo.GetDamageInfo(); - if (damageInfo == null || damageInfo.GetDamage() == 0) - return; - - int selfHeal = (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount()); - int teamHeal = selfHeal / 2; - - GetTarget().CastCustomSpell(null, SpellIds.VampiricEmbraceHeal, teamHeal, selfHeal, 0, true, null, aurEff); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.VampiricEmbraceHeal); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_pri_vampiric_embrace_AuraScript(); + // Not proc from Mind Sear + return !eventInfo.GetDamageInfo().GetSpellInfo().SpellFamilyFlags[1].HasAnyFlag(0x80000u); + } + + void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + DamageInfo damageInfo = eventInfo.GetDamageInfo(); + if (damageInfo == null || damageInfo.GetDamage() == 0) + return; + + int selfHeal = (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount()); + int teamHeal = selfHeal / 2; + + GetTarget().CastCustomSpell(null, SpellIds.VampiricEmbraceHeal, teamHeal, selfHeal, 0, true, null, aurEff); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); } } // 15290 - Vampiric Embrace (heal) [Script] - class spell_pri_vampiric_embrace_target : SpellScriptLoader + class spell_pri_vampiric_embrace_target : SpellScript { - public spell_pri_vampiric_embrace_target() : base("spell_pri_vampiric_embrace_target") { } - - class spell_pri_vampiric_embrace_target_SpellScript : SpellScript + void FilterTargets(List unitList) { - void FilterTargets(List unitList) - { - unitList.Remove(GetCaster()); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitCasterAreaParty)); - } + unitList.Remove(GetCaster()); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_pri_vampiric_embrace_target_SpellScript(); + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitCasterAreaParty)); } } // 34914 - Vampiric Touch [Script] - class spell_pri_vampiric_touch : SpellScriptLoader + class spell_pri_vampiric_touch : AuraScript { - public spell_pri_vampiric_touch() : base("spell_pri_vampiric_touch") { } - - class spell_pri_vampiric_touch_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.VampiricTouchDispel, SpellIds.GenReplenishment); - } + return ValidateSpellInfo(SpellIds.VampiricTouchDispel, SpellIds.GenReplenishment); + } - void HandleDispel(DispelInfo dispelInfo) + void HandleDispel(DispelInfo dispelInfo) + { + Unit caster = GetCaster(); + if (caster) { - Unit caster = GetCaster(); - if (caster) + Unit target = GetUnitOwner(); + if (target) { - Unit target = GetUnitOwner(); - if (target) + AuraEffect aurEff = GetEffect(1); + if (aurEff != null) { - AuraEffect aurEff = GetEffect(1); - if (aurEff != null) - { - int damage = aurEff.GetAmount() * 8; - // backfire damage - caster.CastCustomSpell(target, SpellIds.VampiricTouchDispel, damage, 0, 0, true, null, aurEff); - } + int damage = aurEff.GetAmount() * 8; + // backfire damage + caster.CastCustomSpell(target, SpellIds.VampiricTouchDispel, damage, 0, 0, true, null, aurEff); } } } - - bool CheckProc(ProcEventInfo eventInfo) - { - return eventInfo.GetProcTarget() == GetCaster(); - } - - void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - eventInfo.GetProcTarget().CastSpell((Unit)null, SpellIds.GenReplenishment, true, null, aurEff); - } - - public override void Register() - { - AfterDispel.Add(new AuraDispelHandler(HandleDispel)); - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 2, AuraType.Dummy)); - } } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_pri_vampiric_touch_AuraScript(); + return eventInfo.GetProcTarget() == GetCaster(); + } + + void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + eventInfo.GetProcTarget().CastSpell((Unit)null, SpellIds.GenReplenishment, true, null, aurEff); + } + + public override void Register() + { + AfterDispel.Add(new AuraDispelHandler(HandleDispel)); + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 2, AuraType.Dummy)); } } [Script] // 121536 - Angelic Feather talent - class spell_pri_angelic_feather_trigger : SpellScriptLoader + class spell_pri_angelic_feather_trigger : SpellScript { - public spell_pri_angelic_feather_trigger() : base("spell_pri_angelic_feather_trigger") { } - - class spell_pri_angelic_feather_trigger_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) + return ValidateSpellInfo(SpellIds.AngelicFeatherAreatrigger); + } + + void HandleEffectDummy(uint effIndex) + { + Position destPos = GetHitDest().GetPosition(); + float radius = GetEffectInfo().CalcRadius(); + + // Caster is prioritary + if (GetCaster().IsWithinDist2d(destPos, radius)) { - return ValidateSpellInfo(SpellIds.AngelicFeatherAreatrigger); + GetCaster().CastSpell(GetCaster(), SpellIds.AngelicFeatherAura, true); } - - void HandleEffectDummy(uint effIndex) + else { - Position destPos = GetHitDest().GetPosition(); - float radius = GetEffectInfo().CalcRadius(); - - // Caster is prioritary - if (GetCaster().IsWithinDist2d(destPos, radius)) - { - GetCaster().CastSpell(GetCaster(), SpellIds.AngelicFeatherAura, true); - } - else - { - SpellCastTargets targets = new SpellCastTargets(); - targets.SetDst(destPos); - GetCaster().CastSpell(targets, Global.SpellMgr.GetSpellInfo(SpellIds.AngelicFeatherAreatrigger), null); - } - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleEffectDummy, 0, SpellEffectName.Dummy)); + SpellCastTargets targets = new SpellCastTargets(); + targets.SetDst(destPos); + GetCaster().CastSpell(targets, Global.SpellMgr.GetSpellInfo(SpellIds.AngelicFeatherAreatrigger), null); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_pri_angelic_feather_trigger_SpellScript(); + OnEffectHit.Add(new EffectHandler(HandleEffectDummy, 0, SpellEffectName.Dummy)); } } @@ -1439,7 +1129,7 @@ namespace Scripts.Spells.Priest public override void OnInitialize() { Unit caster = at.GetCaster(); - if (caster ) + if (caster) { List areaTriggers = caster.GetAreaTriggers(SpellIds.AngelicFeatherAreatrigger); diff --git a/Scripts/Spells/Quest.cs b/Scripts/Spells/Quest.cs index 0341baa66..59ce37c33 100644 --- a/Scripts/Spells/Quest.cs +++ b/Scripts/Spells/Quest.cs @@ -278,12 +278,21 @@ namespace Scripts.Spells.Quest public const uint QuestIdBurstAtTheSeams = 12690; } - class spell_generic_quest_update_entry_SpellScript : SpellScript + // http://www.wowhead.com/quest=55 Morbent Fel + // 8913 Sacred Cleansing + // http://www.wowhead.com/quest=10255 Testing the Antidote + // 34665 Administer Antidote + // http://www.wowhead.com/quest=11515 Blood for Blood + // 44936 Quest - Fel Siphon Dummy + [Script("spell_q55_sacred_cleansing", SpellEffectName.Dummy, 1u, CreatureIds.Morbent, CreatureIds.WeakenedMorbent, true)] + [Script("spell_q10255_administer_antidote", SpellEffectName.Dummy, 0u, CreatureIds.Helboar, CreatureIds.Dreadtusk, true)] + [Script("spell_q11515_fel_siphon_dummy", SpellEffectName.Dummy, 0u, CreatureIds.FelbloodInitiate, CreatureIds.EmaciatedFelblood, true)] + class spell_generic_quest_update_entry : SpellScript { - public spell_generic_quest_update_entry_SpellScript(SpellEffectName spellEffect, byte effIndex, uint originalEntry, uint newEntry, bool shouldAttack, uint despawnTime = 0) + public spell_generic_quest_update_entry(SpellEffectName spellEffect, uint effIndex, uint originalEntry, uint newEntry, bool shouldAttack, uint despawnTime = 0) { _spellEffect = spellEffect; - _effIndex = effIndex; + _effIndex = (byte)effIndex; _originalEntry = originalEntry; _newEntry = newEntry; _shouldAttack = shouldAttack; @@ -320,87 +329,54 @@ namespace Scripts.Spells.Quest uint _despawnTime; } - // http://www.wowhead.com/quest=55 Morbent Fel - // 8913 Sacred Cleansing - [Script] - class spell_q55_sacred_cleansing : SpellScriptLoader - { - public spell_q55_sacred_cleansing() : base("spell_q55_sacred_cleansing") { } - - public override SpellScript GetSpellScript() - { - return new spell_generic_quest_update_entry_SpellScript(SpellEffectName.Dummy, 1, CreatureIds.Morbent, CreatureIds.WeakenedMorbent, true); - } - } - // 9712 - Thaumaturgy Channel [Script] - class spell_q2203_thaumaturgy_channel : SpellScriptLoader + class spell_q2203_thaumaturgy_channel : AuraScript { - public spell_q2203_thaumaturgy_channel() : base("spell_q2203_thaumaturgy_channel") { } - - class spell_q2203_thaumaturgy_channel_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ThaumaturgyChannel); - } - - void HandleEffectPeriodic(AuraEffect aurEff) - { - PreventDefaultAction(); - Unit caster = GetCaster(); - if (caster) - caster.CastSpell(caster, SpellIds.ThaumaturgyChannel, false); - } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicTriggerSpell)); - } + return ValidateSpellInfo(SpellIds.ThaumaturgyChannel); } - public override AuraScript GetAuraScript() + void HandleEffectPeriodic(AuraEffect aurEff) { - return new spell_q2203_thaumaturgy_channel_AuraScript(); + PreventDefaultAction(); + Unit caster = GetCaster(); + if (caster) + caster.CastSpell(caster, SpellIds.ThaumaturgyChannel, false); + } + + public override void Register() + { + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicTriggerSpell)); } } // http://www.wowhead.com/quest=5206 Marauders of Darrowshire // 17271 Test Fetid Skull [Script] - class spell_q5206_test_fetid_skull : SpellScriptLoader + class spell_q5206_test_fetid_skull : SpellScript { - public spell_q5206_test_fetid_skull() : base("spell_q5206_test_fetid_skull") { } - - class spell_q5206_test_fetid_skull_SpellScript : SpellScript + public override bool Load() { - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Player); - } - - public override bool Validate(SpellInfo spellEntry) - { - return ValidateSpellInfo(SpellIds.CreateResonatingSkull, SpellIds.CreateBoneDust); - } - - void HandleDummy(uint effIndex) - { - Unit caster = GetCaster(); - uint spellId = RandomHelper.randChance(50) ? SpellIds.CreateResonatingSkull : SpellIds.CreateBoneDust; - caster.CastSpell(caster, spellId, true, null); - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return GetCaster().IsTypeId(TypeId.Player); } - public override SpellScript GetSpellScript() + public override bool Validate(SpellInfo spellEntry) { - return new spell_q5206_test_fetid_skull_SpellScript(); + return ValidateSpellInfo(SpellIds.CreateResonatingSkull, SpellIds.CreateBoneDust); + } + + void HandleDummy(uint effIndex) + { + Unit caster = GetCaster(); + uint spellId = RandomHelper.randChance(50) ? SpellIds.CreateResonatingSkull : SpellIds.CreateBoneDust; + caster.CastSpell(caster, spellId, true, null); + } + + public override void Register() + { + OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } @@ -408,2028 +384,1438 @@ namespace Scripts.Spells.Quest // http://www.wowhead.com/quest=6129 Curing the Sick (H) // 19512 Apply Salve [Script] - class spell_q6124_6129_apply_salve : SpellScriptLoader + class spell_q6124_6129_apply_salve : SpellScript { - public spell_q6124_6129_apply_salve() : base("spell_q6124_6129_apply_salve") { } - - class spell_q6124_6129_apply_salve_SpellScript : SpellScript + public override bool Load() { - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Player); - } + return GetCaster().IsTypeId(TypeId.Player); + } - void HandleDummy(uint effIndex) + void HandleDummy(uint effIndex) + { + Player caster = GetCaster().ToPlayer(); + if (GetCastItem()) { - Player caster = GetCaster().ToPlayer(); - if (GetCastItem()) + Creature creatureTarget = GetHitCreature(); + if (creatureTarget) { - Creature creatureTarget = GetHitCreature(); - if (creatureTarget) + uint newEntry = 0; + switch (caster.GetTeam()) { - uint newEntry = 0; - switch (caster.GetTeam()) - { - case Team.Horde: - if (creatureTarget.GetEntry() == CreatureIds.SicklyGazelle) - newEntry = CreatureIds.CuredGazelle; - break; - case Team.Alliance: - if (creatureTarget.GetEntry() == CreatureIds.SicklyDeer) - newEntry = CreatureIds.CuredDeer; - break; - } - if (newEntry != 0) - { - creatureTarget.UpdateEntry(newEntry); - creatureTarget.DespawnOrUnsummon(Misc.DespawnTime); - caster.KilledMonsterCredit(newEntry); - } + case Team.Horde: + if (creatureTarget.GetEntry() == CreatureIds.SicklyGazelle) + newEntry = CreatureIds.CuredGazelle; + break; + case Team.Alliance: + if (creatureTarget.GetEntry() == CreatureIds.SicklyDeer) + newEntry = CreatureIds.CuredDeer; + break; + } + if (newEntry != 0) + { + creatureTarget.UpdateEntry(newEntry); + creatureTarget.DespawnOrUnsummon(Misc.DespawnTime); + caster.KilledMonsterCredit(newEntry); } } } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q6124_6129_apply_salve_SpellScript(); - } - } - - // http://www.wowhead.com/quest=10255 Testing the Antidote - // 34665 Administer Antidote - [Script] - class spell_q10255_administer_antidote : SpellScriptLoader - { - public spell_q10255_administer_antidote() : base("spell_q10255_administer_antidote") { } - - public override SpellScript GetSpellScript() - { - return new spell_generic_quest_update_entry_SpellScript(SpellEffectName.Dummy, 0, CreatureIds.Helboar, CreatureIds.Dreadtusk, true); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } // 43874 Scourge Mur'gul Camp: Force Shield Arcane Purple x3 [Script] - class spell_q11396_11399_force_shield_arcane_purple_x3 : SpellScriptLoader + class spell_q11396_11399_force_shield_arcane_purple_x3 : AuraScript { - public spell_q11396_11399_force_shield_arcane_purple_x3() : base("spell_q11396_11399_force_shield_arcane_purple_x3") { } - - class spell_q11396_11399_force_shield_arcane_purple_x3_AuraScript : AuraScript + void HandleEffectApply(AuraEffect aurEff, AuraEffectHandleModes mode) { - void HandleEffectApply(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Unit target = GetTarget(); - target.SetFlag(UnitFields.Flags, UnitFlags.ImmuneToPc); - target.AddUnitState(UnitState.Root); - } - - void HandleEffectRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - GetTarget().RemoveFlag(UnitFields.Flags, UnitFlags.ImmuneToPc); - } - - public override void Register() - { - OnEffectApply.Add(new EffectApplyHandler(HandleEffectApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - OnEffectRemove.Add(new EffectApplyHandler(HandleEffectRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - } + Unit target = GetTarget(); + target.SetFlag(UnitFields.Flags, UnitFlags.ImmuneToPc); + target.AddUnitState(UnitState.Root); } - public override AuraScript GetAuraScript() + void HandleEffectRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_q11396_11399_force_shield_arcane_purple_x3_AuraScript(); + GetTarget().RemoveFlag(UnitFields.Flags, UnitFlags.ImmuneToPc); + } + + public override void Register() + { + OnEffectApply.Add(new EffectApplyHandler(HandleEffectApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new EffectApplyHandler(HandleEffectRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } // 50133 Scourging Crystal Controller [Script] - class spell_q11396_11399_scourging_crystal_controller : SpellScriptLoader + class spell_q11396_11399_scourging_crystal_controller : SpellScript { - public spell_q11396_11399_scourging_crystal_controller() : base("spell_q11396_11399_scourging_crystal_controller") { } - - class spell_q11396_11399_scourging_crystal_controller_SpellScript : SpellScript + public override bool Validate(SpellInfo spellEntry) { - public override bool Validate(SpellInfo spellEntry) - { - return ValidateSpellInfo(SpellIds.ForceShieldArcanePurpleX3, SpellIds.ScourgingCrystalController); - } - - void HandleDummy(uint effIndex) - { - Unit target = GetExplTargetUnit(); - if (target) - if (target.IsTypeId(TypeId.Unit) && target.HasAura(SpellIds.ForceShieldArcanePurpleX3)) - // Make sure nobody else is channeling the same target - if (!target.HasAura(SpellIds.ScourgingCrystalController)) - GetCaster().CastSpell(target, SpellIds.ScourgingCrystalController, true, GetCastItem()); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellIds.ForceShieldArcanePurpleX3, SpellIds.ScourgingCrystalController); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_q11396_11399_scourging_crystal_controller_SpellScript(); + Unit target = GetExplTargetUnit(); + if (target) + if (target.IsTypeId(TypeId.Unit) && target.HasAura(SpellIds.ForceShieldArcanePurpleX3)) + // Make sure nobody else is channeling the same target + if (!target.HasAura(SpellIds.ScourgingCrystalController)) + GetCaster().CastSpell(target, SpellIds.ScourgingCrystalController, true, GetCastItem()); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } // 43882 Scourging Crystal Controller Dummy [Script] - class spell_q11396_11399_scourging_crystal_controller_dummy : SpellScriptLoader + class spell_q11396_11399_scourging_crystal_controller_dummy : SpellScript { - public spell_q11396_11399_scourging_crystal_controller_dummy() : base("spell_q11396_11399_scourging_crystal_controller_dummy") { } - - class spell_q11396_11399_scourging_crystal_controller_dummy_SpellScript : SpellScript + public override bool Validate(SpellInfo spellEntry) { - public override bool Validate(SpellInfo spellEntry) - { - return ValidateSpellInfo(SpellIds.ForceShieldArcanePurpleX3); - } - - void HandleDummy(uint effIndex) - { - Unit target = GetHitUnit(); - if (target) - if (target.IsTypeId(TypeId.Unit)) - target.RemoveAurasDueToSpell(SpellIds.ForceShieldArcanePurpleX3); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellIds.ForceShieldArcanePurpleX3); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_q11396_11399_scourging_crystal_controller_dummy_SpellScript(); + Unit target = GetHitUnit(); + if (target) + if (target.IsTypeId(TypeId.Unit)) + target.RemoveAurasDueToSpell(SpellIds.ForceShieldArcanePurpleX3); } - } - // http://www.wowhead.com/quest=11515 Blood for Blood - // 44936 Quest - Fel Siphon Dummy - [Script] - class spell_q11515_fel_siphon_dummy : SpellScriptLoader - { - public spell_q11515_fel_siphon_dummy() : base("spell_q11515_fel_siphon_dummy") { } - - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_generic_quest_update_entry_SpellScript(SpellEffectName.Dummy, 0, CreatureIds.FelbloodInitiate, CreatureIds.EmaciatedFelblood, true); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } // http://www.wowhead.com/quest=11587 Prison Break // 45449 Arcane Prisoner Rescue [Script] - class spell_q11587_arcane_prisoner_rescue : SpellScriptLoader + class spell_q11587_arcane_prisoner_rescue : SpellScript { - public spell_q11587_arcane_prisoner_rescue() : base("spell_q11587_arcane_prisoner_rescue") { } - - class spell_q11587_arcane_prisoner_rescue_SpellScript : SpellScript + public override bool Validate(SpellInfo spellEntry) { - public override bool Validate(SpellInfo spellEntry) - { - return ValidateSpellInfo(SpellIds.SummonArcanePrisonerMale, SpellIds.SummonArcanePrisonerFemale, SpellIds.ArcanePrisonerKillCredit); - } + return ValidateSpellInfo(SpellIds.SummonArcanePrisonerMale, SpellIds.SummonArcanePrisonerFemale, SpellIds.ArcanePrisonerKillCredit); + } - void HandleDummy(uint effIndex) - { - Unit caster = GetCaster(); + void HandleDummy(uint effIndex) + { + Unit caster = GetCaster(); - Unit unitTarget = GetHitUnit(); - if (unitTarget) - { - uint spellId = SpellIds.SummonArcanePrisonerMale; - if (Convert.ToBoolean(RandomHelper.Rand32() % 2)) - spellId = SpellIds.SummonArcanePrisonerFemale; - caster.CastSpell(caster, spellId, true); - unitTarget.CastSpell(caster, SpellIds.ArcanePrisonerKillCredit, true); - } - } - - public override void Register() + Unit unitTarget = GetHitUnit(); + if (unitTarget) { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + uint spellId = SpellIds.SummonArcanePrisonerMale; + if (Convert.ToBoolean(RandomHelper.Rand32() % 2)) + spellId = SpellIds.SummonArcanePrisonerFemale; + caster.CastSpell(caster, spellId, true); + unitTarget.CastSpell(caster, SpellIds.ArcanePrisonerKillCredit, true); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q11587_arcane_prisoner_rescue_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } // http://www.wowhead.com/quest=11730 Master and Servant // 46023 The Ultrasonic Screwdriver [Script] - class spell_q11730_ultrasonic_screwdriver : SpellScriptLoader + class spell_q11730_ultrasonic_screwdriver : SpellScript { - public spell_q11730_ultrasonic_screwdriver() : base("spell_q11730_ultrasonic_screwdriver") { } - - class spell_q11730_ultrasonic_screwdriver_SpellScript : SpellScript + public override bool Load() { - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Player) && GetCastItem(); - } + return GetCaster().IsTypeId(TypeId.Player) && GetCastItem(); + } - public override bool Validate(SpellInfo spellEntry) - { - return ValidateSpellInfo(SpellIds.SummonScavengebot004a8, SpellIds.SummonSentrybot57k, SpellIds.SummonDefendotank66d, - SpellIds.SummonScavengebot005b6, SpellIds.Summon55dCollectatron, SpellIds.RobotKillCredit); - } + public override bool Validate(SpellInfo spellEntry) + { + return ValidateSpellInfo(SpellIds.SummonScavengebot004a8, SpellIds.SummonSentrybot57k, SpellIds.SummonDefendotank66d, + SpellIds.SummonScavengebot005b6, SpellIds.Summon55dCollectatron, SpellIds.RobotKillCredit); + } - void HandleDummy(uint effIndex) - { - Item castItem = GetCastItem(); - Unit caster = GetCaster(); + void HandleDummy(uint effIndex) + { + Item castItem = GetCastItem(); + Unit caster = GetCaster(); - Creature target = GetHitCreature(); - if (target) + Creature target = GetHitCreature(); + if (target) + { + uint spellId = 0; + switch (target.GetEntry()) { - uint spellId = 0; - switch (target.GetEntry()) - { - case CreatureIds.Scavengebot004a8: - spellId = SpellIds.SummonScavengebot004a8; - break; - case CreatureIds.Sentrybot57k: - spellId = SpellIds.SummonSentrybot57k; - break; - case CreatureIds.Defendotank66d: - spellId = SpellIds.SummonDefendotank66d; - break; - case CreatureIds.Scavengebot005b6: - spellId = SpellIds.SummonScavengebot005b6; - break; - case CreatureIds.Npc55dCollectatron: - spellId = SpellIds.Summon55dCollectatron; - break; - default: - return; - } - caster.CastSpell(caster, spellId, true, castItem); - caster.CastSpell(caster, SpellIds.RobotKillCredit, true); - target.DespawnOrUnsummon(); + case CreatureIds.Scavengebot004a8: + spellId = SpellIds.SummonScavengebot004a8; + break; + case CreatureIds.Sentrybot57k: + spellId = SpellIds.SummonSentrybot57k; + break; + case CreatureIds.Defendotank66d: + spellId = SpellIds.SummonDefendotank66d; + break; + case CreatureIds.Scavengebot005b6: + spellId = SpellIds.SummonScavengebot005b6; + break; + case CreatureIds.Npc55dCollectatron: + spellId = SpellIds.Summon55dCollectatron; + break; + default: + return; } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + caster.CastSpell(caster, spellId, true, castItem); + caster.CastSpell(caster, SpellIds.RobotKillCredit, true); + target.DespawnOrUnsummon(); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q11730_ultrasonic_screwdriver_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } // http://www.wowhead.com/quest=12459 That Which Creates Can Also Destroy // 49587 Seeds of Nature's Wrath [Script] - class spell_q12459_seeds_of_natures_wrath : SpellScriptLoader + class spell_q12459_seeds_of_natures_wrath : SpellScript { - public spell_q12459_seeds_of_natures_wrath() : base("spell_q12459_seeds_of_natures_wrath") { } - - class spell_q12459_seeds_of_natures_wrath_SpellScript : SpellScript + void HandleDummy(uint effIndex) { - void HandleDummy(uint effIndex) + Creature creatureTarget = GetHitCreature(); + if (creatureTarget) { - Creature creatureTarget = GetHitCreature(); - if (creatureTarget) + uint uiNewEntry = 0; + switch (creatureTarget.GetEntry()) { - uint uiNewEntry = 0; - switch (creatureTarget.GetEntry()) - { - case CreatureIds.ReanimatedFrostwyrm: - uiNewEntry = CreatureIds.WeakReanimatedFrostwyrm; - break; - case CreatureIds.Turgid: - uiNewEntry = CreatureIds.WeakTurgid; - break; - case CreatureIds.Deathgaze: - uiNewEntry = CreatureIds.WeakDeathgaze; - break; - } - if (uiNewEntry != 0) - creatureTarget.UpdateEntry(uiNewEntry); + case CreatureIds.ReanimatedFrostwyrm: + uiNewEntry = CreatureIds.WeakReanimatedFrostwyrm; + break; + case CreatureIds.Turgid: + uiNewEntry = CreatureIds.WeakTurgid; + break; + case CreatureIds.Deathgaze: + uiNewEntry = CreatureIds.WeakDeathgaze; + break; } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + if (uiNewEntry != 0) + creatureTarget.UpdateEntry(uiNewEntry); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q12459_seeds_of_natures_wrath_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } // http://www.wowhead.com/quest=12634 Some Make Lemonade, Some Make Liquor // 51840 Despawn Fruit Tosser [Script] - class spell_q12634_despawn_fruit_tosser : SpellScriptLoader + class spell_q12634_despawn_fruit_tosser : SpellScript { - public spell_q12634_despawn_fruit_tosser() : base("spell_q12634_despawn_fruit_tosser") { } - - class spell_q12634_despawn_fruit_tosser_SpellScript : SpellScript + public override bool Validate(SpellInfo spellEntry) { - public override bool Validate(SpellInfo spellEntry) - { - return ValidateSpellInfo(SpellIds.BananasFallToGround, SpellIds.OrangeFallsToGround, SpellIds.PapayaFallsToGround, SpellIds.SummonAdventurousDwarf); - } - - void HandleDummy(uint effIndex) - { - uint spellId = SpellIds.BananasFallToGround; - switch (RandomHelper.URand(0, 3)) - { - case 1: - spellId = SpellIds.OrangeFallsToGround; - break; - case 2: - spellId = SpellIds.PapayaFallsToGround; - break; - } - // sometimes, if you're lucky, you get a dwarf - if (RandomHelper.randChance(5)) - spellId = SpellIds.SummonAdventurousDwarf; - GetCaster().CastSpell(GetCaster(), spellId, true, null); - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellIds.BananasFallToGround, SpellIds.OrangeFallsToGround, SpellIds.PapayaFallsToGround, SpellIds.SummonAdventurousDwarf); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_q12634_despawn_fruit_tosser_SpellScript(); + uint spellId = SpellIds.BananasFallToGround; + switch (RandomHelper.URand(0, 3)) + { + case 1: + spellId = SpellIds.OrangeFallsToGround; + break; + case 2: + spellId = SpellIds.PapayaFallsToGround; + break; + } + // sometimes, if you're lucky, you get a dwarf + if (RandomHelper.randChance(5)) + spellId = SpellIds.SummonAdventurousDwarf; + GetCaster().CastSpell(GetCaster(), spellId, true, null); + } + + public override void Register() + { + OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } // http://www.wowhead.com/quest=12683 Burning to Help // 52308 Take Sputum Sample [Script] - class spell_q12683_take_sputum_sample : SpellScriptLoader + class spell_q12683_take_sputum_sample : SpellScript { - public spell_q12683_take_sputum_sample() : base("spell_q12683_take_sputum_sample") { } - - class spell_q12683_take_sputum_sample_SpellScript : SpellScript + void HandleDummy(uint effIndex) { - void HandleDummy(uint effIndex) - { - uint reqAuraId = (uint)GetSpellInfo().GetEffect(1).CalcValue(); + uint reqAuraId = (uint)GetSpellInfo().GetEffect(1).CalcValue(); - Unit caster = GetCaster(); - if (caster.HasAuraEffect(reqAuraId, 0)) - { - uint spellId = (uint)GetSpellInfo().GetEffect(0).CalcValue(); - caster.CastSpell(caster, spellId, true, null); - } - } - - public override void Register() + Unit caster = GetCaster(); + if (caster.HasAuraEffect(reqAuraId, 0)) { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + uint spellId = (uint)GetSpellInfo().GetEffect(0).CalcValue(); + caster.CastSpell(caster, spellId, true, null); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q12683_take_sputum_sample_SpellScript(); + OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } // http://www.wowhead.com/quest=12851 Going Bearback // 54798 FLAMING Arrow Triggered Effect [Script] - class spell_q12851_going_bearback : SpellScriptLoader + class spell_q12851_going_bearback : AuraScript { - public spell_q12851_going_bearback() : base("spell_q12851_going_bearback") { } - - class spell_q12851_going_bearback_AuraScript : AuraScript + void HandleEffectApply(AuraEffect aurEff, AuraEffectHandleModes mode) { - void HandleEffectApply(AuraEffect aurEff, AuraEffectHandleModes mode) + Unit caster = GetCaster(); + if (caster) { - Unit caster = GetCaster(); - if (caster) + Unit target = GetTarget(); + // Already in fire + if (target.HasAura(SpellIds.Ablaze)) + return; + Player player = caster.GetCharmerOrOwnerPlayerOrPlayerItself(); + if (player) { - Unit target = GetTarget(); - // Already in fire - if (target.HasAura(SpellIds.Ablaze)) - return; - Player player = caster.GetCharmerOrOwnerPlayerOrPlayerItself(); - if (player) + switch (target.GetEntry()) { - switch (target.GetEntry()) - { - case CreatureIds.Frostworg: - target.CastSpell(player, SpellIds.FrostworgCredit, true); - target.CastSpell(target, SpellIds.Immolation, true); - target.CastSpell(target, SpellIds.Ablaze, true); - break; - case CreatureIds.Frostgiant: - target.CastSpell(player, SpellIds.FrostgiantCredit, true); - target.CastSpell(target, SpellIds.Immolation, true); - target.CastSpell(target, SpellIds.Ablaze, true); - break; - } + case CreatureIds.Frostworg: + target.CastSpell(player, SpellIds.FrostworgCredit, true); + target.CastSpell(target, SpellIds.Immolation, true); + target.CastSpell(target, SpellIds.Ablaze, true); + break; + case CreatureIds.Frostgiant: + target.CastSpell(player, SpellIds.FrostgiantCredit, true); + target.CastSpell(target, SpellIds.Immolation, true); + target.CastSpell(target, SpellIds.Ablaze, true); + break; } } } - - public override void Register() - { - AfterEffectApply.Add(new EffectApplyHandler(HandleEffectApply, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.RealOrReapplyMask)); - } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_q12851_going_bearback_AuraScript(); + AfterEffectApply.Add(new EffectApplyHandler(HandleEffectApply, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.RealOrReapplyMask)); } } // http://www.wowhead.com/quest=12937 Relief for the Fallen // 55804 Healing Finished [Script] - class spell_q12937_relief_for_the_fallen : SpellScriptLoader + class spell_q12937_relief_for_the_fallen : SpellScript { - public spell_q12937_relief_for_the_fallen() : base("spell_q12937_relief_for_the_fallen") { } - - class spell_q12937_relief_for_the_fallen_SpellScript : SpellScript + public override bool Load() { - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Player); - } + return GetCaster().IsTypeId(TypeId.Player); + } - public override bool Validate(SpellInfo spellEntry) - { - return ValidateSpellInfo(SpellIds.TriggerAidOfTheEarthen); - } + public override bool Validate(SpellInfo spellEntry) + { + return ValidateSpellInfo(SpellIds.TriggerAidOfTheEarthen); + } - void HandleDummy(uint effIndex) - { - Player caster = GetCaster().ToPlayer(); + void HandleDummy(uint effIndex) + { + Player caster = GetCaster().ToPlayer(); - Creature target = GetHitCreature(); - if (target) - { - caster.CastSpell(caster, SpellIds.TriggerAidOfTheEarthen, true, null); - caster.KilledMonsterCredit(CreatureIds.FallenEarthenDefender); - target.DespawnOrUnsummon(); - } - } - - public override void Register() + Creature target = GetHitCreature(); + if (target) { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + caster.CastSpell(caster, SpellIds.TriggerAidOfTheEarthen, true, null); + caster.KilledMonsterCredit(CreatureIds.FallenEarthenDefender); + target.DespawnOrUnsummon(); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q12937_relief_for_the_fallen_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] - class spell_q10041_q10040_who_are_they : SpellScriptLoader + class spell_q10041_q10040_who_are_they : SpellScript { - public spell_q10041_q10040_who_are_they() : base("spell_q10041_q10040_who_are_they") { } - - class spell_q10041_q10040_who_are_they_SpellScript : SpellScript + public override bool Validate(SpellInfo spellEntry) { - public override bool Validate(SpellInfo spellEntry) - { - return ValidateSpellInfo(SpellIds.MaleDisguise, SpellIds.FemaleDisguise, SpellIds.GenericDisguise); - } + return ValidateSpellInfo(SpellIds.MaleDisguise, SpellIds.FemaleDisguise, SpellIds.GenericDisguise); + } - void HandleScript(uint effIndex) + void HandleScript(uint effIndex) + { + PreventHitDefaultEffect(effIndex); + Player target = GetHitPlayer(); + if (target) { - PreventHitDefaultEffect(effIndex); - Player target = GetHitPlayer(); - if (target) - { - target.CastSpell(target, target.GetGender() == 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)); + target.CastSpell(target, target.GetGender() == Gender.Male ? SpellIds.MaleDisguise : SpellIds.FemaleDisguise, true); + target.CastSpell(target, SpellIds.GenericDisguise, true); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q10041_q10040_who_are_they_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } // 8593 Symbol of life dummy [Script] - class spell_symbol_of_life_dummy : SpellScriptLoader + class spell_symbol_of_life_dummy : SpellScript { - public spell_symbol_of_life_dummy() : base("spell_symbol_of_life_dummy") { } - - class spell_symbol_of_life_dummy_SpellScript : SpellScript + void HandleDummy(uint effIndex) { - void HandleDummy(uint effIndex) + Creature target = GetHitCreature(); + if (target) { - Creature target = GetHitCreature(); - if (target) + if (target.HasAura(SpellIds.PermanentFeignDeath)) { - if (target.HasAura(SpellIds.PermanentFeignDeath)) - { - target.RemoveAurasDueToSpell(SpellIds.PermanentFeignDeath); - target.SetUInt32Value(ObjectFields.DynamicFlags, 0); - target.SetUInt32Value(UnitFields.Flags2, 0); - target.SetHealth(target.GetMaxHealth() / 2); - target.SetPower(PowerType.Mana, (int)(target.GetMaxPower(PowerType.Mana) * 0.75f)); - } + target.RemoveAurasDueToSpell(SpellIds.PermanentFeignDeath); + target.SetUInt32Value(ObjectFields.DynamicFlags, 0); + target.SetUInt32Value(UnitFields.Flags2, 0); + target.SetHealth(target.GetMaxHealth() / 2); + target.SetPower(PowerType.Mana, (int)(target.GetMaxPower(PowerType.Mana) * 0.75f)); } } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_symbol_of_life_dummy_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } // http://www.wowhead.com/quest=12659 Scalps! // 52090 Ahunae's Knife [Script] - class spell_q12659_ahunaes_knife : SpellScriptLoader + class spell_q12659_ahunaes_knife : SpellScript { - public spell_q12659_ahunaes_knife() : base("spell_q12659_ahunaes_knife") { } - - class spell_q12659_ahunaes_knife_SpellScript : SpellScript + public override bool Load() { - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Player); - } + return GetCaster().IsTypeId(TypeId.Player); + } - void HandleDummy(uint effIndex) - { - Player caster = GetCaster().ToPlayer(); + void HandleDummy(uint effIndex) + { + Player caster = GetCaster().ToPlayer(); - Creature target = GetHitCreature(); - if (target) - { - target.DespawnOrUnsummon(); - caster.KilledMonsterCredit(CreatureIds.ScalpsKcBunny); - } - } - - public override void Register() + Creature target = GetHitCreature(); + if (target) { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + target.DespawnOrUnsummon(); + caster.KilledMonsterCredit(CreatureIds.ScalpsKcBunny); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q12659_ahunaes_knife_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] - class spell_q9874_liquid_fire : SpellScriptLoader + class spell_q9874_liquid_fire : SpellScript { - public spell_q9874_liquid_fire() : base("spell_q9874_liquid_fire") + public override bool Load() { + return GetCaster().IsTypeId(TypeId.Player); } - class spell_q9874_liquid_fire_SpellScript : SpellScript + void HandleDummy(uint effIndex) { - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Player); - } + Player caster = GetCaster().ToPlayer(); - void HandleDummy(uint effIndex) + Creature target = GetHitCreature(); + if (target) { - Player caster = GetCaster().ToPlayer(); - - Creature target = GetHitCreature(); - if (target) + if (target && !target.HasAura(SpellIds.Flames)) { - if (target && !target.HasAura(SpellIds.Flames)) - { - caster.KilledMonsterCredit(CreatureIds.VillagerKillCredit); - target.CastSpell(target, SpellIds.Flames, true); - target.DespawnOrUnsummon(60000); - } + caster.KilledMonsterCredit(CreatureIds.VillagerKillCredit); + target.CastSpell(target, SpellIds.Flames, true); + target.DespawnOrUnsummon(60000); } } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q9874_liquid_fire_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] - class spell_q12805_lifeblood_dummy : SpellScriptLoader + class spell_q12805_lifeblood_dummy : SpellScript { - public spell_q12805_lifeblood_dummy() : base("spell_q12805_lifeblood_dummy") + public override bool Load() { + return GetCaster().IsTypeId(TypeId.Player); } - class spell_q12805_lifeblood_dummy_SpellScript : SpellScript + void HandleScript(uint effIndex) { - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Player); - } + Player caster = GetCaster().ToPlayer(); - void HandleScript(uint effIndex) + Creature target = GetHitCreature(); + if (target) { - Player caster = GetCaster().ToPlayer(); - - Creature target = GetHitCreature(); - if (target) - { - caster.KilledMonsterCredit(CreatureIds.ShardKillCredit); - target.CastSpell(target, (uint)GetEffectValue(), true); - target.DespawnOrUnsummon(2000); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + caster.KilledMonsterCredit(CreatureIds.ShardKillCredit); + target.CastSpell(target, (uint)GetEffectValue(), true); + target.DespawnOrUnsummon(2000); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q12805_lifeblood_dummy_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } /* - http://www.wowhead.com/quest=13283 King of the Mountain - http://www.wowhead.com/quest=13280 King of the Mountain - 59643 Plant Horde Battle Standard - 4338 Plant Alliance Battle Standard - */ + http://www.wowhead.com/quest=13283 King of the Mountain + http://www.wowhead.com/quest=13280 King of the Mountain + 59643 Plant Horde Battle Standard + 4338 Plant Alliance Battle Standard + */ [Script] - class spell_q13280_13283_plant_battle_standard : SpellScriptLoader + class spell_q13280_13283_plant_battle_standard : SpellScript { - public spell_q13280_13283_plant_battle_standard() : base("spell_q13280_13283_plant_battle_standard") { } - - class spell_q13280_13283_plant_battle_standard_SpellScript : SpellScript + void HandleDummy(uint effIndex) { - void HandleDummy(uint effIndex) + Unit caster = GetCaster(); + if (caster.IsVehicle()) { - Unit caster = GetCaster(); - if (caster.IsVehicle()) - { - Unit player = caster.GetVehicleKit().GetPassenger(0); - if (player) - player.ToPlayer().KilledMonsterCredit(CreatureIds.KingOfTheMountaintKc); - } - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + Unit player = caster.GetVehicleKit().GetPassenger(0); + if (player) + player.ToPlayer().KilledMonsterCredit(CreatureIds.KingOfTheMountaintKc); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q13280_13283_plant_battle_standard_SpellScript(); + OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] - class spell_q14112_14145_chum_the_water : SpellScriptLoader + class spell_q14112_14145_chum_the_water : SpellScript { - public spell_q14112_14145_chum_the_water() : base("spell_q14112_14145_chum_the_water") { } - - class spell_q14112_14145_chum_the_water_SpellScript : SpellScript + public override bool Validate(SpellInfo spellEntry) { - 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)); - } + return ValidateSpellInfo(SpellIds.SummonAngryKvaldir, SpellIds.SummonNorthSeaMako, SpellIds.SummonNorthSeaThresher, SpellIds.SummonNorthSeaBlueShark); } - public override SpellScript GetSpellScript() + void HandleScriptEffect(uint effIndex) { - return new spell_q14112_14145_chum_the_water_SpellScript(); + 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)); } } // http://old01.wowhead.com/quest=9452 - Red Snapper - Very Tasty! [Script] - class spell_q9452_cast_net : SpellScriptLoader + class spell_q9452_cast_net : SpellScript { - public spell_q9452_cast_net() : base("spell_q9452_cast_net") { } - - class spell_q9452_cast_net_SpellScript : SpellScript + public override bool Load() { - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Player); - } - - void HandleDummy(uint effIndex) - { - Player caster = GetCaster().ToPlayer(); - if (RandomHelper.randChance(66)) - caster.AddItem(Misc.ItemIdRedSnapper, 1); - else - caster.CastSpell(caster, SpellIds.FishedUpMurloc, true); - } - - void HandleActiveObject(uint effIndex) - { - PreventHitDefaultEffect(effIndex); - GetHitGObj().SetRespawnTime(RandomHelper.randChance(50) ? 2 * Time.Minute : 3 * Time.Minute); - GetHitGObj().Use(GetCaster()); - GetHitGObj().SetLootState(LootState.JustDeactivated); - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - OnEffectHitTarget.Add(new EffectHandler(HandleActiveObject, 1, SpellEffectName.ActivateObject)); - } + return GetCaster().IsTypeId(TypeId.Player); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_q9452_cast_net_SpellScript(); + Player caster = GetCaster().ToPlayer(); + if (RandomHelper.randChance(66)) + caster.AddItem(Misc.ItemIdRedSnapper, 1); + else + caster.CastSpell(caster, SpellIds.FishedUpMurloc, true); + } + + void HandleActiveObject(uint effIndex) + { + PreventHitDefaultEffect(effIndex); + GetHitGObj().SetRespawnTime(RandomHelper.randChance(50) ? 2 * Time.Minute : 3 * Time.Minute); + GetHitGObj().Use(GetCaster()); + GetHitGObj().SetLootState(LootState.JustDeactivated); + } + + public override void Register() + { + OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + OnEffectHitTarget.Add(new EffectHandler(HandleActiveObject, 1, SpellEffectName.ActivateObject)); } } [Script] - class spell_q14076_14092_pound_drum : SpellScriptLoader + class spell_q14076_14092_pound_drum : SpellScript { - public spell_q14076_14092_pound_drum() : base("spell_q14076_14092_pound_drum") { } - - class spell_q14076_14092_pound_drum_SpellScript : SpellScript + void HandleSummon() { - void HandleSummon() - { - Unit caster = GetCaster(); + Unit caster = GetCaster(); - if (RandomHelper.randChance(80)) - caster.CastSpell(caster, SpellIds.SummonDeepJormungar, true); - else - caster.CastSpell(caster, SpellIds.StormforgedMoleMachine, true); - } - - void HandleActiveObject(uint effIndex) - { - GetHitGObj().SetLootState(LootState.JustDeactivated); - } - - public override void Register() - { - OnCast.Add(new CastHandler(HandleSummon)); - OnEffectHitTarget.Add(new EffectHandler(HandleActiveObject, 0, SpellEffectName.ActivateObject)); - } + if (RandomHelper.randChance(80)) + caster.CastSpell(caster, SpellIds.SummonDeepJormungar, true); + else + caster.CastSpell(caster, SpellIds.StormforgedMoleMachine, true); } - public override SpellScript GetSpellScript() + void HandleActiveObject(uint effIndex) { - return new spell_q14076_14092_pound_drum_SpellScript(); + GetHitGObj().SetLootState(LootState.JustDeactivated); + } + + public override void Register() + { + OnCast.Add(new CastHandler(HandleSummon)); + OnEffectHitTarget.Add(new EffectHandler(HandleActiveObject, 0, SpellEffectName.ActivateObject)); } } [Script] - class spell_q12279_cast_net : SpellScriptLoader + class spell_q12279_cast_net : SpellScript { - public spell_q12279_cast_net() : base("spell_q12279_cast_net") { } - - class spell_q12279_cast_net_SpellScript : SpellScript + void HandleActiveObject(uint effIndex) { - void HandleActiveObject(uint effIndex) - { - GetHitGObj().SetLootState(LootState.JustDeactivated); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleActiveObject, 1, SpellEffectName.ActivateObject)); - } + GetHitGObj().SetLootState(LootState.JustDeactivated); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q12279_cast_net_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleActiveObject, 1, SpellEffectName.ActivateObject)); } } [Script] - class spell_q12987_read_pronouncement : SpellScriptLoader + class spell_q12987_read_pronouncement : AuraScript { - public spell_q12987_read_pronouncement() : base("spell_q12987_read_pronouncement") { } - - class spell_q12987_read_pronouncement_AuraScript : AuraScript + void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) { - void OnApply(AuraEffect aurEff, AuraEffectHandleModes mode) + // player must cast kill credit and do emote text, according to sniff + Player target = GetTarget().ToPlayer(); + if (target) { - // 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) { - 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, Team.Other, false, target); - target.KilledMonsterCredit(CreatureIds.Killcredit); - Global.CreatureTextMgr.SendChat(trigger, Misc.Say2, target, ChatMsg.Addon, Language.Addon, Game.CreatureTextRange.Normal, 0, Team.Other, false, target); - } + Global.CreatureTextMgr.SendChat(trigger, Misc.Say1, target, ChatMsg.Addon, Language.Addon, Game.CreatureTextRange.Normal, 0, Team.Other, false, target); + target.KilledMonsterCredit(CreatureIds.Killcredit); + Global.CreatureTextMgr.SendChat(trigger, Misc.Say2, target, ChatMsg.Addon, Language.Addon, Game.CreatureTextRange.Normal, 0, Team.Other, false, target); } } - - public override void Register() - { - AfterEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.None, AuraEffectHandleModes.Real)); - } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_q12987_read_pronouncement_AuraScript(); + AfterEffectApply.Add(new EffectApplyHandler(OnApply, 0, AuraType.None, AuraEffectHandleModes.Real)); } } [Script] - class spell_q12277_wintergarde_mine_explosion : SpellScriptLoader + class spell_q12277_wintergarde_mine_explosion : SpellScript { - public spell_q12277_wintergarde_mine_explosion() : base("spell_q12277_wintergarde_mine_explosion") { } - - class spell_q12277_wintergarde_mine_explosion_SpellScript : SpellScript + void HandleDummy(uint effIndex) { - void HandleDummy(uint effIndex) + Creature unitTarget = GetHitCreature(); + if (unitTarget) { - Creature unitTarget = GetHitCreature(); - if (unitTarget) + Unit caster = GetCaster(); + if (caster) { - Unit caster = GetCaster(); - if (caster) + if (caster.IsTypeId(TypeId.Unit)) { - if (caster.IsTypeId(TypeId.Unit)) + Unit owner = caster.GetOwner(); + if (owner) { - Unit owner = caster.GetOwner(); - if (owner) + switch (unitTarget.GetEntry()) { - 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; - } + 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)); - } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q12277_wintergarde_mine_explosion_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] - class spell_q12066_bunny_kill_credit : SpellScriptLoader + class spell_q12066_bunny_kill_credit : SpellScript { - public spell_q12066_bunny_kill_credit() : base("spell_q12066_bunny_kill_credit") { } - - class spell_q12066_bunny_kill_credit_SpellScript : SpellScript + void HandleDummy(uint effIndex) { - void HandleDummy(uint effIndex) - { - Creature target = GetHitCreature(); - if (target) - target.CastSpell(GetCaster(), SpellIds.BunnyCreditBeam, false); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + Creature target = GetHitCreature(); + if (target) + target.CastSpell(GetCaster(), SpellIds.BunnyCreditBeam, false); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q12066_bunny_kill_credit_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] - class spell_q12735_song_of_cleansing : SpellScriptLoader + class spell_q12735_song_of_cleansing : SpellScript { - public spell_q12735_song_of_cleansing() : base("spell_q12735_song_of_cleansing") { } - - class spell_q12735_song_of_cleansing_SpellScript : SpellScript + void HandleScript(uint effIndex) { - void HandleScript(uint effIndex) + Unit caster = GetCaster(); + switch (caster.GetAreaId()) { - 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)); + 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 SpellScript GetSpellScript() + public override void Register() { - return new spell_q12735_song_of_cleansing_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] - class spell_q12372_cast_from_gossip_trigger : SpellScriptLoader + class spell_q12372_cast_from_gossip_trigger : SpellScript { - public spell_q12372_cast_from_gossip_trigger() : base("spell_q12372_cast_from_gossip_trigger") { } - - class spell_q12372_cast_from_gossip_trigger_SpellScript : SpellScript + void HandleScript(uint effIndex) { - void HandleScript(uint effIndex) - { - GetCaster().CastSpell(GetCaster(), SpellIds.SummonWyrmrestDefender, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } + GetCaster().CastSpell(GetCaster(), SpellIds.SummonWyrmrestDefender, true); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q12372_cast_from_gossip_trigger_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } // http://www.wowhead.com/quest=12372 Defending Wyrmrest Temple // 49370 - Wyrmrest Defender: Destabilize Azure Dragonshrine Effect [Script] - class spell_q12372_destabilize_azure_dragonshrine_dummy : SpellScriptLoader + class spell_q12372_destabilize_azure_dragonshrine_dummy : SpellScript { - public spell_q12372_destabilize_azure_dragonshrine_dummy() : base("spell_q12372_destabilize_azure_dragonshrine_dummy") { } - - class spell_q12372_destabilize_azure_dragonshrine_dummy_SpellScript : SpellScript + void HandleDummy(uint effIndex) { - void HandleDummy(uint effIndex) + if (GetHitCreature()) { - if (GetHitCreature()) + Unit caster = GetOriginalCaster(); + if (caster) { - Unit caster = GetOriginalCaster(); - if (caster) + Vehicle vehicle = caster.GetVehicleKit(); + if (vehicle) { - Vehicle vehicle = caster.GetVehicleKit(); - if (vehicle) + Unit passenger = vehicle.GetPassenger(0); + if (passenger) { - Unit passenger = vehicle.GetPassenger(0); - if (passenger) - { - Player player = passenger.ToPlayer(); - if (player) - player.KilledMonsterCredit(CreatureIds.WyrmrestTempleCredit); - } + Player player = passenger.ToPlayer(); + if (player) + player.KilledMonsterCredit(CreatureIds.WyrmrestTempleCredit); } } } } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q12372_destabilize_azure_dragonshrine_dummy_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } // ID - 50287 Azure Dragon: On Death Force Cast Wyrmrest Defender to Whisper to Controller - Random (cast from Azure Dragons and Azure Drakes on death) [Script] - class spell_q12372_azure_on_death_force_whisper : SpellScriptLoader + class spell_q12372_azure_on_death_force_whisper : SpellScript { - public spell_q12372_azure_on_death_force_whisper() : base("spell_q12372_azure_on_death_force_whisper") { } - - class spell_q12372_azure_on_death_force_whisper_SpellScript : SpellScript + void HandleScript(uint effIndex) { - void HandleScript(uint effIndex) - { - Creature defender = GetHitCreature(); - if (defender) - defender.GetAI().Talk(Misc.WhisperOnHitByForceWhisper, defender.GetCharmerOrOwner()); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } + Creature defender = GetHitCreature(); + if (defender) + defender.GetAI().Talk(Misc.WhisperOnHitByForceWhisper, defender.GetCharmerOrOwner()); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q12372_azure_on_death_force_whisper_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } // 40113 Knockdown Fel Cannon: The Aggro Check Aura [Script] - class spell_q11010_q11102_q11023_aggro_check_aura : SpellScriptLoader + class spell_q11010_q11102_q11023_aggro_check_aura : AuraScript { - public spell_q11010_q11102_q11023_aggro_check_aura() : base("spell_q11010_q11102_q11023_aggro_check_aura") { } - - class spell_q11010_q11102_q11023_aggro_check_aura_AuraScript : AuraScript + void HandleTriggerSpell(AuraEffect aurEff) { - void HandleTriggerSpell(AuraEffect aurEff) - { - Unit target = GetTarget(); - if (target) - // On trigger proccing - target.CastSpell(target, SpellIds.AggroCheck); - } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleTriggerSpell, 0, AuraType.PeriodicTriggerSpell)); - } + Unit target = GetTarget(); + if (target) + // On trigger proccing + target.CastSpell(target, SpellIds.AggroCheck); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_q11010_q11102_q11023_aggro_check_aura_AuraScript(); + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleTriggerSpell, 0, AuraType.PeriodicTriggerSpell)); } } // 40112 Knockdown Fel Cannon: The Aggro Check [Script] - class spell_q11010_q11102_q11023_aggro_check : SpellScriptLoader + class spell_q11010_q11102_q11023_aggro_check : SpellScript { - public spell_q11010_q11102_q11023_aggro_check() : base("spell_q11010_q11102_q11023_aggro_check") { } - - class spell_q11010_q11102_q11023_aggro_check_SpellScript : SpellScript + void HandleDummy(uint effIndex) { - void HandleDummy(uint effIndex) - { - Player playerTarget = GetHitPlayer(); - if (playerTarget) - // Check if found player target is on fly mount or using flying form - if (playerTarget.HasAuraType(AuraType.Fly) || playerTarget.HasAuraType(AuraType.ModIncreaseMountedFlightSpeed)) - playerTarget.CastSpell(playerTarget, SpellIds.FlakCannonTrigger, TriggerCastFlags.IgnoreCasterMountedOrOnVehicle); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + Player playerTarget = GetHitPlayer(); + if (playerTarget) + // Check if found player target is on fly mount or using flying form + if (playerTarget.HasAuraType(AuraType.Fly) || playerTarget.HasAuraType(AuraType.ModIncreaseMountedFlightSpeed)) + playerTarget.CastSpell(playerTarget, SpellIds.FlakCannonTrigger, TriggerCastFlags.IgnoreCasterMountedOrOnVehicle); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q11010_q11102_q11023_aggro_check_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } // 40119 Knockdown Fel Cannon: The Aggro Burst [Script] - class spell_q11010_q11102_q11023_aggro_burst : SpellScriptLoader + class spell_q11010_q11102_q11023_aggro_burst : AuraScript { - public spell_q11010_q11102_q11023_aggro_burst() : base("spell_q11010_q11102_q11023_aggro_burst") { } - - class spell_q11010_q11102_q11023_aggro_burst_AuraScript : AuraScript + void HandleEffectPeriodic(AuraEffect aurEff) { - void HandleEffectPeriodic(AuraEffect aurEff) - { - Unit target = GetTarget(); - if (target) - // On each tick cast Choose Loc to trigger summon - target.CastSpell(target, SpellIds.ChooseLoc); - } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); - } + Unit target = GetTarget(); + if (target) + // On each tick cast Choose Loc to trigger summon + target.CastSpell(target, SpellIds.ChooseLoc); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_q11010_q11102_q11023_aggro_burst_AuraScript(); + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); } } // 40056 Knockdown Fel Cannon: Choose Loc [Script] - class spell_q11010_q11102_q11023_choose_loc : SpellScriptLoader + class spell_q11010_q11102_q11023_choose_loc : SpellScript { - public spell_q11010_q11102_q11023_choose_loc() : base("spell_q11010_q11102_q11023_choose_loc") { } - - class spell_q11010_q11102_q11023_choose_loc_SpellScript : SpellScript + void HandleDummy(uint effIndex) { - void HandleDummy(uint effIndex) + Unit caster = GetCaster(); + // Check for player that is in 65 y range + List playerList = new List(); + AnyPlayerInObjectRangeCheck checker = new AnyPlayerInObjectRangeCheck(caster, 65.0f); + PlayerListSearcher searcher = new PlayerListSearcher(caster, playerList, checker); + Cell.VisitWorldObjects(caster, searcher, 65.0f); + foreach (var player in playerList) { - Unit caster = GetCaster(); - // Check for player that is in 65 y range - List playerList = new List(); - AnyPlayerInObjectRangeCheck checker = new AnyPlayerInObjectRangeCheck(caster, 65.0f); - PlayerListSearcher searcher = new PlayerListSearcher(caster, playerList, checker); - Cell.VisitWorldObjects(caster, searcher, 65.0f); - foreach (var player in playerList) - { - // Check if found player target is on fly mount or using flying form - if (player.HasAuraType(AuraType.Fly) || player.HasAuraType(AuraType.ModIncreaseMountedFlightSpeed)) - // Summom Fel Cannon (bunny version) at found player - caster.SummonCreature(CreatureIds.FelCannon2, player.GetPositionX(), player.GetPositionY(), player.GetPositionZ()); - } - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + // Check if found player target is on fly mount or using flying form + if (player.HasAuraType(AuraType.Fly) || player.HasAuraType(AuraType.ModIncreaseMountedFlightSpeed)) + // Summom Fel Cannon (bunny version) at found player + caster.SummonCreature(CreatureIds.FelCannon2, player.GetPositionX(), player.GetPositionY(), player.GetPositionZ()); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q11010_q11102_q11023_choose_loc_SpellScript(); + OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } // 39844 - Skyguard Blasting Charge // 40160 - Throw Bomb [Script] - class spell_q11010_q11102_q11023_q11008_check_fly_mount : SpellScriptLoader + class spell_q11010_q11102_q11023_q11008_check_fly_mount : SpellScript { - public spell_q11010_q11102_q11023_q11008_check_fly_mount() : base("spell_q11010_q11102_q11023_q11008_check_fly_mount") { } - - class spell_q11010_q11102_q11023_q11008_check_fly_mount_SpellScript : SpellScript + SpellCastResult CheckRequirement() { - SpellCastResult CheckRequirement() - { - Unit caster = GetCaster(); - // This spell will be cast only if caster has one of these auras - if (!(caster.HasAuraType(AuraType.Fly) || caster.HasAuraType(AuraType.ModIncreaseMountedFlightSpeed))) - return SpellCastResult.CantDoThatRightNow; - return SpellCastResult.SpellCastOk; - } - - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckRequirement)); - } + Unit caster = GetCaster(); + // This spell will be cast only if caster has one of these auras + if (!(caster.HasAuraType(AuraType.Fly) || caster.HasAuraType(AuraType.ModIncreaseMountedFlightSpeed))) + return SpellCastResult.CantDoThatRightNow; + return SpellCastResult.SpellCastOk; } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q11010_q11102_q11023_q11008_check_fly_mount_SpellScript(); + OnCheckCast.Add(new CheckCastHandler(CheckRequirement)); } } [Script] - class spell_q12527_zuldrak_rat : SpellScriptLoader + class spell_q12527_zuldrak_rat : SpellScript { - public spell_q12527_zuldrak_rat() : base("spell_q12527_zuldrak_rat") { } - - class spell_q12527_zuldrak_rat_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.SummonGorgedLurkingBasilisk); - } + return ValidateSpellInfo(SpellIds.SummonGorgedLurkingBasilisk); + } - void HandleScriptEffect(uint effIndex) + void HandleScriptEffect(uint effIndex) + { + if (GetHitAura() != null && GetHitAura().GetStackAmount() >= GetSpellInfo().StackAmount) { - if (GetHitAura() != null && GetHitAura().GetStackAmount() >= GetSpellInfo().StackAmount) - { - GetHitUnit().CastSpell((Unit)null, SpellIds.SummonGorgedLurkingBasilisk, true); - Creature basilisk = GetHitUnit().ToCreature(); - if (basilisk) - basilisk.DespawnOrUnsummon(); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 1, SpellEffectName.ScriptEffect)); + GetHitUnit().CastSpell((Unit)null, SpellIds.SummonGorgedLurkingBasilisk, true); + Creature basilisk = GetHitUnit().ToCreature(); + if (basilisk) + basilisk.DespawnOrUnsummon(); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q12527_zuldrak_rat_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 1, SpellEffectName.ScriptEffect)); } } // 55368 - Summon Stefan [Script] - class spell_q12661_q12669_q12676_q12677_q12713_summon_stefan : SpellScriptLoader + class spell_q12661_q12669_q12676_q12677_q12713_summon_stefan : SpellScript { - public spell_q12661_q12669_q12676_q12677_q12713_summon_stefan() : base("spell_q12661_q12669_q12676_q12677_q12713_summon_stefan") { } - - class spell_q12661_q12669_q12676_q12677_q12713_summon_stefan_SpellScript : SpellScript + void SetDest(ref SpellDestination dest) { - void SetDest(ref SpellDestination dest) - { - // Adjust effect summon position - Position offset = new Position(0.0f, 0.0f, 20.0f, 0.0f); - dest.RelocateOffset(offset); - } - - public override void Register() - { - OnDestinationTargetSelect.Add(new DestinationTargetSelectHandler(SetDest, 0, Targets.DestCasterBack)); - } + // Adjust effect summon position + Position offset = new Position(0.0f, 0.0f, 20.0f, 0.0f); + dest.RelocateOffset(offset); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q12661_q12669_q12676_q12677_q12713_summon_stefan_SpellScript(); + OnDestinationTargetSelect.Add(new DestinationTargetSelectHandler(SetDest, 0, Targets.DestCasterBack)); } } [Script] - class spell_q12730_quenching_mist : SpellScriptLoader + class spell_q12730_quenching_mist : AuraScript { - public spell_q12730_quenching_mist() : base("spell_q12730_quenching_mist") { } - - class spell_q12730_quenching_mist_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.FlickeringFlames); - } - - void HandleEffectPeriodic(AuraEffect aurEff) - { - GetTarget().RemoveAurasDueToSpell(SpellIds.FlickeringFlames); - } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicHeal)); - } + return ValidateSpellInfo(SpellIds.FlickeringFlames); } - public override AuraScript GetAuraScript() + void HandleEffectPeriodic(AuraEffect aurEff) { - return new spell_q12730_quenching_mist_AuraScript(); + GetTarget().RemoveAurasDueToSpell(SpellIds.FlickeringFlames); + } + + public override void Register() + { + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicHeal)); } } // 13291 - Borrowed Technology/13292 - The Solution Solution /Daily//13239 - Volatility/13261 - Volatiliy /Daily// [Script] - class spell_q13291_q13292_q13239_q13261_frostbrood_skytalon_grab_decoy : SpellScriptLoader + class spell_q13291_q13292_q13239_q13261_frostbrood_skytalon_grab_decoy : SpellScript { - public spell_q13291_q13292_q13239_q13261_frostbrood_skytalon_grab_decoy() : base("spell_q13291_q13292_q13239_q13261_frostbrood_skytalon_grab_decoy") { } - - class spell_q13291_q13292_q13239_q13261_frostbrood_skytalon_grab_decoy_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.Ride); - } - - void HandleDummy(uint effIndex) - { - if (!GetHitCreature()) - return; - // TO DO: Being triggered is hack, but in checkcast it doesn't pass aurastate requirements. - // Beside that the decoy won't keep it's freeze animation state when enter. - GetHitCreature().CastSpell(GetCaster(), SpellIds.Ride, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellIds.Ride); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_q13291_q13292_q13239_q13261_frostbrood_skytalon_grab_decoy_SpellScript(); + if (!GetHitCreature()) + return; + // TO DO: Being triggered is hack, but in checkcast it doesn't pass aurastate requirements. + // Beside that the decoy won't keep it's freeze animation state when enter. + GetHitCreature().CastSpell(GetCaster(), SpellIds.Ride, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } // 59303 - Summon Frost Wyrm [Script] - class spell_q13291_q13292_q13239_q13261_armored_decoy_summon_skytalon : SpellScriptLoader + class spell_q13291_q13292_q13239_q13261_armored_decoy_summon_skytalon : SpellScript { - public spell_q13291_q13292_q13239_q13261_armored_decoy_summon_skytalon() : base("spell_q13291_q13292_q13239_q13261_armored_decoy_summon_skytalon") { } - - class spell_q13291_q13292_q13239_q13261_armored_decoy_summon_skytalon_SpellScript : SpellScript + void SetDest(ref SpellDestination dest) { - void SetDest(ref SpellDestination dest) - { - // Adjust effect summon position - Position offset = new Position(0.0f, 0.0f, 20.0f, 0.0f); - dest.RelocateOffset(offset); - } - - public override void Register() - { - OnDestinationTargetSelect.Add(new DestinationTargetSelectHandler(SetDest, 0, Targets.DestCasterBack)); - } + // Adjust effect summon position + Position offset = new Position(0.0f, 0.0f, 20.0f, 0.0f); + dest.RelocateOffset(offset); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q13291_q13292_q13239_q13261_armored_decoy_summon_skytalon_SpellScript(); + OnDestinationTargetSelect.Add(new DestinationTargetSelectHandler(SetDest, 0, Targets.DestCasterBack)); } } // 12601 - Second Chances: Summon Landgren's Soul Moveto Target Bunny [Script] - class spell_q12847_summon_soul_moveto_bunny : SpellScriptLoader + class spell_q12847_summon_soul_moveto_bunny : SpellScript { - public spell_q12847_summon_soul_moveto_bunny() : base("spell_q12847_summon_soul_moveto_bunny") { } - - class spell_q12847_summon_soul_moveto_bunny_SpellScript : SpellScript + void SetDest(ref SpellDestination dest) { - void SetDest(ref SpellDestination dest) - { - // Adjust effect summon position - Position offset = new Position(0.0f, 0.0f, 2.5f, 0.0f); - dest.RelocateOffset(offset); - } - - public override void Register() - { - OnDestinationTargetSelect.Add(new DestinationTargetSelectHandler(SetDest, 0, Targets.DestCaster)); - } + // Adjust effect summon position + Position offset = new Position(0.0f, 0.0f, 2.5f, 0.0f); + dest.RelocateOffset(offset); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q12847_summon_soul_moveto_bunny_SpellScript(); + OnDestinationTargetSelect.Add(new DestinationTargetSelectHandler(SetDest, 0, Targets.DestCaster)); } } [Script] - class spell_q13011_bear_flank_master : SpellScriptLoader + class spell_q13011_bear_flank_master : SpellScript { - public spell_q13011_bear_flank_master() : base("spell_q13011_bear_flank_master") { } - - class spell_q13011_bear_flank_master_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.BearFlankMaster, SpellIds.CreateBearFlank); - } + return ValidateSpellInfo(SpellIds.BearFlankMaster, SpellIds.CreateBearFlank); + } - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Unit); - } + public override bool Load() + { + return GetCaster().IsTypeId(TypeId.Unit); + } - void HandleScript(uint effIndex) + void HandleScript(uint effIndex) + { + Player player = GetHitPlayer(); + if (player) { - Player player = GetHitPlayer(); - if (player) + if (RandomHelper.randChance(50)) { - if (RandomHelper.randChance(50)) - { - Creature creature = GetCaster().ToCreature(); - player.CastSpell(creature, SpellIds.BearFlankFail); - creature.GetAI().Talk(0, player); - } - else - player.CastSpell(player, SpellIds.CreateBearFlank); + Creature creature = GetCaster().ToCreature(); + player.CastSpell(creature, SpellIds.BearFlankFail); + creature.GetAI().Talk(0, player); } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); + else + player.CastSpell(player, SpellIds.CreateBearFlank); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q13011_bear_flank_master_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] - class spell_q13086_cannons_target : SpellScriptLoader + class spell_q13086_cannons_target : SpellScript { - public spell_q13086_cannons_target() : base("spell_q13086_cannons_target") { } - - class spell_q13086_cannons_target_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo((uint)spellInfo.GetEffect(0).CalcValue()); - } - - void HandleEffectDummy(uint effIndex) - { - WorldLocation pos = GetExplTargetDest(); - if (pos != null) - GetCaster().CastSpell(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), (uint)GetEffectValue(), true); - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleEffectDummy, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo((uint)spellInfo.GetEffect(0).CalcValue()); } - public override SpellScript GetSpellScript() + void HandleEffectDummy(uint effIndex) { - return new spell_q13086_cannons_target_SpellScript(); + WorldLocation pos = GetExplTargetDest(); + if (pos != null) + GetCaster().CastSpell(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), (uint)GetEffectValue(), true); + } + + public override void Register() + { + OnEffectHit.Add(new EffectHandler(HandleEffectDummy, 0, SpellEffectName.Dummy)); } } [Script] - class spell_q12690_burst_at_the_seams : SpellScriptLoader + class spell_q12690_burst_at_the_seams : SpellScript { - public spell_q12690_burst_at_the_seams() : base("spell_q12690_burst_at_the_seams") { } - - class spell_q12690_burst_at_the_seams_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.BurstAtTheSeams, SpellIds.BurstAtTheSeamsDmg, SpellIds.BurstAtTheSeamsDmg2, - SpellIds.BurstAtTheSeamsBone, SpellIds.BurstAtTheSeamsMeat, SpellIds.BurstAtTheSeamsBmeat); - } + return ValidateSpellInfo(SpellIds.BurstAtTheSeams, SpellIds.BurstAtTheSeamsDmg, SpellIds.BurstAtTheSeamsDmg2, + SpellIds.BurstAtTheSeamsBone, SpellIds.BurstAtTheSeamsMeat, SpellIds.BurstAtTheSeamsBmeat); + } - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Unit); - } + public override bool Load() + { + return GetCaster().IsTypeId(TypeId.Unit); + } - void HandleKnockBack(uint effIndex) + void HandleKnockBack(uint effIndex) + { + Unit creature = GetHitCreature(); + if (creature) { - Unit creature = GetHitCreature(); - if (creature) + Unit charmer = GetCaster().GetCharmerOrOwner(); + if (charmer) { - Unit charmer = GetCaster().GetCharmerOrOwner(); - if (charmer) + Player player = charmer.ToPlayer(); + if (player) { - Player player = charmer.ToPlayer(); - if (player) + if (player.GetQuestStatus(Misc.QuestIdBurstAtTheSeams) == QuestStatus.Incomplete) { - if (player.GetQuestStatus(Misc.QuestIdBurstAtTheSeams) == QuestStatus.Incomplete) - { - creature.CastSpell(creature, SpellIds.BurstAtTheSeamsBone, true); - creature.CastSpell(creature, SpellIds.BurstAtTheSeamsMeat, true); - creature.CastSpell(creature, SpellIds.BurstAtTheSeamsBmeat, true); - creature.CastSpell(creature, SpellIds.BurstAtTheSeamsDmg, true); - creature.CastSpell(creature, SpellIds.BurstAtTheSeamsDmg2, true); + creature.CastSpell(creature, SpellIds.BurstAtTheSeamsBone, true); + creature.CastSpell(creature, SpellIds.BurstAtTheSeamsMeat, true); + creature.CastSpell(creature, SpellIds.BurstAtTheSeamsBmeat, true); + creature.CastSpell(creature, SpellIds.BurstAtTheSeamsDmg, true); + creature.CastSpell(creature, SpellIds.BurstAtTheSeamsDmg2, true); - player.CastSpell(player, SpellIds.DrakkariSkullcrusherCredit, true); - ushort count = player.GetReqKillOrCastCurrentCount(Misc.QuestIdBurstAtTheSeams, (int)CreatureIds.DrakkariChieftaink); - if ((count % 20) == 0) - player.CastSpell(player, SpellIds.SummonDrakkariChieftain, true); - } + player.CastSpell(player, SpellIds.DrakkariSkullcrusherCredit, true); + ushort count = player.GetReqKillOrCastCurrentCount(Misc.QuestIdBurstAtTheSeams, (int)CreatureIds.DrakkariChieftaink); + if ((count % 20) == 0) + player.CastSpell(player, SpellIds.SummonDrakkariChieftain, true); } } } } - - void HandleScript(uint effIndex) - { - GetCaster().ToCreature().DespawnOrUnsummon(2 * Time.InMilliseconds); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleKnockBack, 1, SpellEffectName.KnockBack)); - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } } - public override SpellScript GetSpellScript() + void HandleScript(uint effIndex) { - return new spell_q12690_burst_at_the_seams_SpellScript(); + GetCaster().ToCreature().DespawnOrUnsummon(2 * Time.InMilliseconds); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleKnockBack, 1, SpellEffectName.KnockBack)); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } // 48682 - Escape from Silverbrook - Periodic Dummy [Script] - class spell_q12308_escape_from_silverbrook : SpellScriptLoader + class spell_q12308_escape_from_silverbrook : SpellScript { - public spell_q12308_escape_from_silverbrook() : base("spell_q12308_escape_from_silverbrook") { } - - class spell_q12308_escape_from_silverbrook_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.SummonWorgen); - } - - void HandleDummy(uint effIndex) - { - GetCaster().CastSpell(GetCaster(), SpellIds.SummonWorgen, true); - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellIds.SummonWorgen); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_q12308_escape_from_silverbrook_SpellScript(); + GetCaster().CastSpell(GetCaster(), SpellIds.SummonWorgen, true); + } + + public override void Register() + { + OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } // 48681 - Summon Silverbrook Worgen [Script] - class spell_q12308_escape_from_silverbrook_summon_worgen : SpellScriptLoader + class spell_q12308_escape_from_silverbrook_summon_worgen : SpellScript { - public spell_q12308_escape_from_silverbrook_summon_worgen() : base("spell_q12308_escape_from_silverbrook_summon_worgen") { } - - class spell_q12308_escape_from_silverbrook_summon_worgen_SpellScript : SpellScript + void ModDest(ref SpellDestination dest) { - void ModDest(ref SpellDestination dest) - { - float dist = GetSpellInfo().GetEffect(0).CalcRadius(GetCaster()); - float angle = RandomHelper.FRand(0.75f, 1.25f) * MathFunctions.PI; + float dist = GetSpellInfo().GetEffect(0).CalcRadius(GetCaster()); + float angle = RandomHelper.FRand(0.75f, 1.25f) * MathFunctions.PI; - Position pos = GetCaster().GetNearPosition(dist, angle); - dest.Relocate(pos); - } - - public override void Register() - { - OnDestinationTargetSelect.Add(new DestinationTargetSelectHandler(ModDest, 0, Targets.DestCasterSummon)); - } + Position pos = GetCaster().GetNearPosition(dist, angle); + dest.Relocate(pos); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q12308_escape_from_silverbrook_summon_worgen_SpellScript(); + OnDestinationTargetSelect.Add(new DestinationTargetSelectHandler(ModDest, 0, Targets.DestCasterSummon)); } } // 51858 - Siphon of Acherus [Script] - class spell_q12641_death_comes_from_on_high : SpellScriptLoader + class spell_q12641_death_comes_from_on_high : SpellScript { - public spell_q12641_death_comes_from_on_high() : base("spell_q12641_death_comes_from_on_high") { } - - class spell_q12641_death_comes_from_on_high_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ForgeCredit, SpellIds.TownHallCredit, SpellIds.ScarletHoldCredit, SpellIds.ChapelCredit); - } - - void HandleDummy(uint effIndex) - { - uint spellId = 0; - - switch (GetHitCreature().GetEntry()) - { - case CreatureIds.NewAvalonForge: - spellId = SpellIds.ForgeCredit; - break; - case CreatureIds.NewAvalonTownHall: - spellId = SpellIds.TownHallCredit; - break; - case CreatureIds.ScarletHold: - spellId = SpellIds.ScarletHoldCredit; - break; - case CreatureIds.ChapelOfTheCrimsonFlame: - spellId = SpellIds.ChapelCredit; - break; - default: - return; - } - - GetCaster().CastSpell((Unit)null, spellId, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellIds.ForgeCredit, SpellIds.TownHallCredit, SpellIds.ScarletHoldCredit, SpellIds.ChapelCredit); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_q12641_death_comes_from_on_high_SpellScript(); + uint spellId = 0; + + switch (GetHitCreature().GetEntry()) + { + case CreatureIds.NewAvalonForge: + spellId = SpellIds.ForgeCredit; + break; + case CreatureIds.NewAvalonTownHall: + spellId = SpellIds.TownHallCredit; + break; + case CreatureIds.ScarletHold: + spellId = SpellIds.ScarletHoldCredit; + break; + case CreatureIds.ChapelOfTheCrimsonFlame: + spellId = SpellIds.ChapelCredit; + break; + default: + return; + } + + GetCaster().CastSpell((Unit)null, spellId, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } // 52694 - Recall Eye of Acherus [Script] - class spell_q12641_recall_eye_of_acherus : SpellScriptLoader + class spell_q12641_recall_eye_of_acherus : SpellScript { - public spell_q12641_recall_eye_of_acherus() : base("spell_q12641_recall_eye_of_acherus") { } - - class spell_q12641_recall_eye_of_acherus_SpellScript : SpellScript + void HandleDummy(uint effIndex) { - void HandleDummy(uint effIndex) + Player player = GetCaster().GetCharmerOrOwner().ToPlayer(); + if (player) { - Player player = GetCaster().GetCharmerOrOwner().ToPlayer(); - if (player) - { - player.StopCastingCharm(); - player.StopCastingBindSight(); - player.RemoveAura(SpellIds.TheEyeOfAcherus); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.ScriptEffect)); + player.StopCastingCharm(); + player.StopCastingBindSight(); + player.RemoveAura(SpellIds.TheEyeOfAcherus); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q12641_recall_eye_of_acherus_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.ScriptEffect)); } } // 51769 - Emblazon Runeblade [Script] - class spell_q12619_emblazon_runeblade : SpellScriptLoader + class spell_q12619_emblazon_runeblade : AuraScript { - public spell_q12619_emblazon_runeblade() : base("spell_q12619_emblazon_runeblade") { } - - class spell_q12619_emblazon_runeblade_AuraScript : AuraScript + void HandleEffectPeriodic(AuraEffect aurEff) { - void HandleEffectPeriodic(AuraEffect aurEff) - { - PreventDefaultAction(); - Unit caster = GetCaster(); - if (caster) - caster.CastSpell(caster, GetSpellInfo().GetEffect(aurEff.GetEffIndex()).TriggerSpell, true, null, aurEff); - } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicTriggerSpell)); - } + PreventDefaultAction(); + Unit caster = GetCaster(); + if (caster) + caster.CastSpell(caster, GetSpellInfo().GetEffect(aurEff.GetEffIndex()).TriggerSpell, true, null, aurEff); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_q12619_emblazon_runeblade_AuraScript(); + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicTriggerSpell)); } } // 51770 - Emblazon Runeblade [Script] - class spell_q12619_emblazon_runeblade_effect : SpellScriptLoader + class spell_q12619_emblazon_runeblade_effect : SpellScript { - public spell_q12619_emblazon_runeblade_effect() : base("spell_q12619_emblazon_runeblade_effect") { } - - class spell_q12619_emblazon_runeblade_effect_SpellScript : SpellScript + void HandleScript(uint effIndex) { - void HandleScript(uint effIndex) - { - GetCaster().CastSpell(GetCaster(), (uint)GetEffectValue(), false); - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } + GetCaster().CastSpell(GetCaster(), (uint)GetEffectValue(), false); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q12619_emblazon_runeblade_effect_SpellScript(); + OnEffectHit.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] - class spell_q12919_gymers_grab : SpellScriptLoader + class spell_q12919_gymers_grab : SpellScript { - public spell_q12919_gymers_grab() : base("spell_q12919_gymers_grab") { } - - class spell_q12919_gymers_grab_SpellScript : SpellScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.RideGymer); - } - - void HandleScript(uint effIndex) - { - sbyte seatId = 2; - if (!GetHitCreature()) - return; - GetHitCreature().CastCustomSpell(SpellIds.RideGymer, SpellValueMod.BasePoint0, seatId, GetCaster(), true); - GetHitCreature().CastSpell(GetHitCreature(), SpellIds.Grabbed, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } + return ValidateSpellInfo(SpellIds.RideGymer); } - public override SpellScript GetSpellScript() + void HandleScript(uint effIndex) { - return new spell_q12919_gymers_grab_SpellScript(); + sbyte seatId = 2; + if (!GetHitCreature()) + return; + GetHitCreature().CastCustomSpell(SpellIds.RideGymer, SpellValueMod.BasePoint0, seatId, GetCaster(), true); + GetHitCreature().CastSpell(GetHitCreature(), SpellIds.Grabbed, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] - class spell_q12919_gymers_throw : SpellScriptLoader + class spell_q12919_gymers_throw : SpellScript { - public spell_q12919_gymers_throw() : base("spell_q12919_gymers_throw") { } - - class spell_q12919_gymers_throw_SpellScript : SpellScript + void HandleScript(uint effIndex) { - void HandleScript(uint effIndex) + Unit caster = GetCaster(); + if (caster.IsVehicle()) { - Unit caster = GetCaster(); - if (caster.IsVehicle()) + Unit passenger = caster.GetVehicleKit().GetPassenger(1); + if (passenger) { - Unit passenger = caster.GetVehicleKit().GetPassenger(1); - if (passenger) - { - passenger.ExitVehicle(); - caster.CastSpell(passenger, SpellIds.VargulExplosion, true); - } + passenger.ExitVehicle(); + caster.CastSpell(passenger, SpellIds.VargulExplosion, true); } } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q12919_gymers_throw_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } [Script] - class spell_q13400_illidan_kill_master : SpellScriptLoader + class spell_q13400_illidan_kill_master : SpellScript { - public spell_q13400_illidan_kill_master() : base("spell_q13400_illidan_kill_master") { } - - class spell_q13400_illidan_kill_master_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.IllidanKillCredit); - } + return ValidateSpellInfo(SpellIds.IllidanKillCredit); + } - void HandleDummy(uint effIndex) + void HandleDummy(uint effIndex) + { + Unit caster = GetCaster(); + if (caster.IsVehicle()) { - Unit caster = GetCaster(); - if (caster.IsVehicle()) - { - Unit passenger = caster.GetVehicleKit().GetPassenger(0); - if (passenger) - passenger.CastSpell(passenger, SpellIds.IllidanKillCredit, true); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); + Unit passenger = caster.GetVehicleKit().GetPassenger(0); + if (passenger) + passenger.CastSpell(passenger, SpellIds.IllidanKillCredit, true); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q13400_illidan_kill_master_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } // 66744 - Make Player Destroy Totems [Script] - class spell_q14100_q14111_make_player_destroy_totems : SpellScriptLoader + class spell_q14100_q14111_make_player_destroy_totems : SpellScript { - public spell_q14100_q14111_make_player_destroy_totems() : base("spell_q14100_q14111_make_player_destroy_totems") { } - - class spell_q14100_q14111_make_player_destroy_totems_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.TotemOfTheEarthenRing); - } - - void HandleScriptEffect(uint effIndex) - { - Player player = GetHitPlayer(); - if (player) - player.CastSpell(player, SpellIds.TotemOfTheEarthenRing, TriggerCastFlags.FullMask); // ignore reagent cost, consumed by quest - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); - } + return ValidateSpellInfo(SpellIds.TotemOfTheEarthenRing); } - public override SpellScript GetSpellScript() + void HandleScriptEffect(uint effIndex) { - return new spell_q14100_q14111_make_player_destroy_totems_SpellScript(); + Player player = GetHitPlayer(); + if (player) + player.CastSpell(player, SpellIds.TotemOfTheEarthenRing, TriggerCastFlags.FullMask); // ignore reagent cost, consumed by quest + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); } } // 39238 - Fumping [Script] - class spell_q10929_fumping : SpellScriptLoader + class spell_q10929_fumpingAuraScript : AuraScript { - public spell_q10929_fumping() : base("spell_q10929_fumping") { } - - class spell_q10929_fumpingAuraScript : AuraScript + public override bool Validate(SpellInfo spell) { - public override bool Validate(SpellInfo spell) - { - return ValidateSpellInfo(SpellIds.SummonSandGnome, SpellIds.SummonBoneSlicer); - } - - void HandleEffectRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - if (GetTargetApplication().GetRemoveMode() != AuraRemoveMode.Expire) - return; - - Unit caster = GetCaster(); - if (caster) - caster.CastSpell(caster, RandomHelper.URand(SpellIds.SummonSandGnome, SpellIds.SummonBoneSlicer), true); - } - - public override void Register() - { - OnEffectRemove.Add(new EffectApplyHandler(HandleEffectRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - } + return ValidateSpellInfo(SpellIds.SummonSandGnome, SpellIds.SummonBoneSlicer); } - public override AuraScript GetAuraScript() + void HandleEffectRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_q10929_fumpingAuraScript(); + if (GetTargetApplication().GetRemoveMode() != AuraRemoveMode.Expire) + return; + + Unit caster = GetCaster(); + if (caster) + caster.CastSpell(caster, RandomHelper.URand(SpellIds.SummonSandGnome, SpellIds.SummonBoneSlicer), true); + } + + public override void Register() + { + OnEffectRemove.Add(new EffectApplyHandler(HandleEffectRemove, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); } } // 93072 - Get Our Boys Back Dummy [Script] - class spell_q28813_get_our_boys_back_dummy : SpellScriptLoader + class spell_q28813_get_our_boys_back_dummy : SpellScript { - public spell_q28813_get_our_boys_back_dummy() : base("spell_q28813_get_our_boys_back_dummy") { } - - class spell_q28813_get_our_boys_back_dummy_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.RenewedLife); - } + return ValidateSpellInfo(SpellIds.RenewedLife); + } - void HandleDummyEffect() + void HandleDummyEffect() + { + Unit caster = GetCaster(); + Creature injuredStormwindInfantry = caster.FindNearestCreature(CreatureIds.InjuredStormwindInfantry, 5.0f, true); + if (injuredStormwindInfantry) { - Unit caster = GetCaster(); - Creature injuredStormwindInfantry = caster.FindNearestCreature(CreatureIds.InjuredStormwindInfantry, 5.0f, true); - if (injuredStormwindInfantry) - { - injuredStormwindInfantry.SetCreatorGUID(caster.GetGUID()); - injuredStormwindInfantry.CastSpell(injuredStormwindInfantry, SpellIds.RenewedLife, true); - } - } - - public override void Register() - { - OnCast.Add(new CastHandler(HandleDummyEffect)); + injuredStormwindInfantry.SetCreatorGUID(caster.GetGUID()); + injuredStormwindInfantry.CastSpell(injuredStormwindInfantry, SpellIds.RenewedLife, true); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q28813_get_our_boys_back_dummy_SpellScript(); + OnCast.Add(new CastHandler(HandleDummyEffect)); } } [Script] - class spell_q28813_set_health_random : SpellScriptLoader + class spell_q28813_set_health_random : SpellScript { - public spell_q28813_set_health_random() : base("spell_q28813_set_health_random") { } - - class spell_q28813_set_health_random_SpellScript : SpellScript + void HandleDummyEffect() { - void HandleDummyEffect() - { - Unit caster = GetCaster(); - caster.SetHealth(caster.CountPctFromMaxHealth(RandomHelper.IRand(3, 5) * 10)); - } - - public override void Register() - { - OnCast.Add(new CastHandler(HandleDummyEffect)); - } + Unit caster = GetCaster(); + caster.SetHealth(caster.CountPctFromMaxHealth(RandomHelper.IRand(3, 5) * 10)); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q28813_set_health_random_SpellScript(); + OnCast.Add(new CastHandler(HandleDummyEffect)); } } [Script] - class spell_q12414_hand_over_reins : SpellScriptLoader + class spell_q12414_hand_over_reins : SpellScript { - public spell_q12414_hand_over_reins() : base("spell_q12414_hand_over_reins") { } - - class spell_q12414_hand_over_reins_SpellScript : SpellScript + void HandleScript(uint effIndex) { - void HandleScript(uint effIndex) - { - Creature caster = GetCaster().ToCreature(); - GetHitUnit().ExitVehicle(); + Creature caster = GetCaster().ToCreature(); + GetHitUnit().ExitVehicle(); - if (caster) - caster.DespawnOrUnsummon(); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 1, SpellEffectName.ScriptEffect)); - } + if (caster) + caster.DespawnOrUnsummon(); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_q12414_hand_over_reins_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 1, SpellEffectName.ScriptEffect)); } } } diff --git a/Scripts/Spells/Rogue.cs b/Scripts/Spells/Rogue.cs index d4b68386f..2b62c60a1 100644 --- a/Scripts/Spells/Rogue.cs +++ b/Scripts/Spells/Rogue.cs @@ -41,177 +41,132 @@ namespace Scripts.Spells.Rogue public const uint HonorAmongThievesEnergize = 51699; public const uint T52pSetBonus = 37169; } - + [Script] // 51690 - Killing Spree - class spell_rog_killing_spree : SpellScriptLoader + class spell_rog_killing_spree : SpellScript { - public spell_rog_killing_spree() : base("spell_rog_killing_spree") { } - - class spell_rog_killing_spree_SpellScript : SpellScript + void FilterTargets(List targets) { - void FilterTargets(List targets) - { - if (targets.Empty() || GetCaster().GetVehicleBase()) - FinishCast(SpellCastResult.OutOfRange); - } + if (targets.Empty() || GetCaster().GetVehicleBase()) + FinishCast(SpellCastResult.OutOfRange); + } - void HandleDummy(uint effIndex) + void HandleDummy(uint effIndex) + { + Aura aura = GetCaster().GetAura(SpellIds.KillingSpree); + if (aura != null) { - Aura aura = GetCaster().GetAura(SpellIds.KillingSpree); - if (aura != null) + var script = aura.GetScript(nameof(spell_rog_killing_spree_AuraScript)); + if (script != null) + script.AddTarget(GetHitUnit()); + } + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 1, Targets.UnitDestAreaEnemy)); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 1, SpellEffectName.Dummy)); + } + } + + public class spell_rog_killing_spree_AuraScript : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.KillingSpreeTeleport, SpellIds.KillingSpreeWeaponDmg, SpellIds.KillingSpreeDmgBuff); + } + + void HandleApply(AuraEffect aurEff, AuraEffectHandleModes mode) + { + GetTarget().CastSpell(GetTarget(), SpellIds.KillingSpreeDmgBuff, true); + } + + void HandleEffectPeriodic(AuraEffect aurEff) + { + while (!_targets.Empty()) + { + ObjectGuid guid = _targets.SelectRandom(); + Unit target = Global.ObjAccessor.GetUnit(GetTarget(), guid); + if (target) { - var script = aura.GetScript(nameof(spell_rog_killing_spree_AuraScript)); - if (script != null) - script.AddTarget(GetHitUnit()); + GetTarget().CastSpell(target, SpellIds.KillingSpreeTeleport, true); + GetTarget().CastSpell(target, SpellIds.KillingSpreeWeaponDmg, true); + break; } - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 1, Targets.UnitDestAreaEnemy)); - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 1, SpellEffectName.Dummy)); + else + _targets.Remove(guid); } } - public override SpellScript GetSpellScript() + void HandleRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_rog_killing_spree_SpellScript(); + GetTarget().RemoveAurasDueToSpell(SpellIds.KillingSpreeDmgBuff); } - public class spell_rog_killing_spree_AuraScript : AuraScript + public override void Register() { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.KillingSpreeTeleport, SpellIds.KillingSpreeWeaponDmg, SpellIds.KillingSpreeDmgBuff); - } - - void HandleApply(AuraEffect aurEff, AuraEffectHandleModes mode) - { - GetTarget().CastSpell(GetTarget(), SpellIds.KillingSpreeDmgBuff, true); - } - - void HandleEffectPeriodic(AuraEffect aurEff) - { - while (!_targets.Empty()) - { - ObjectGuid guid = _targets.SelectRandom(); - Unit target = Global.ObjAccessor.GetUnit(GetTarget(), guid); - if (target) - { - GetTarget().CastSpell(target, SpellIds.KillingSpreeTeleport, true); - GetTarget().CastSpell(target, SpellIds.KillingSpreeWeaponDmg, true); - break; - } - else - _targets.Remove(guid); - } - } - - void HandleRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - GetTarget().RemoveAurasDueToSpell(SpellIds.KillingSpreeDmgBuff); - } - - public override void Register() - { - AfterEffectApply.Add(new EffectApplyHandler(HandleApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); - AfterEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.Real)); - } - - public void AddTarget(Unit target) - { - _targets.Add(target.GetGUID()); - } - - List _targets = new List(); + AfterEffectApply.Add(new EffectApplyHandler(HandleApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); + AfterEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.Real)); } - public override AuraScript GetAuraScript() + public void AddTarget(Unit target) { - return new spell_rog_killing_spree_AuraScript(); + _targets.Add(target.GetGUID()); } + + List _targets = new List(); } [Script] // 70805 - Rogue T10 2P Bonus -- THIS SHOULD BE REMOVED WITH NEW PROC SYSTEM. - class spell_rog_t10_2p_bonus : SpellScriptLoader + class spell_rog_t10_2p_bonus : AuraScript { - public spell_rog_t10_2p_bonus() : base("spell_rog_t10_2p_bonus") { } - - class spell_rog_t10_2p_bonus_AuraScript : AuraScript + bool CheckProc(ProcEventInfo eventInfo) { - bool CheckProc(ProcEventInfo eventInfo) - { - return eventInfo.GetActor() == eventInfo.GetActionTarget(); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - } + return eventInfo.GetActor() == eventInfo.GetActionTarget(); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_rog_t10_2p_bonus_AuraScript(); + DoCheckProc.Add(new CheckProcHandler(CheckProc)); } } - + [Script] // 2098 - Eviscerate - class spell_rog_eviscerate : SpellScriptLoader + class spell_rog_eviscerate : SpellScript { - public spell_rog_eviscerate() : base("spell_rog_eviscerate") { } - - class spell_rog_eviscerate_SpellScript : SpellScript + void CalculateDamage(uint effIndex) { - void CalculateDamage(uint effIndex) - { - int damagePerCombo = (int)(GetCaster().GetTotalAttackPowerValue(WeaponAttackType.BaseAttack) * 0.559f); - AuraEffect t5 = GetCaster().GetAuraEffect(SpellIds.T52pSetBonus, 0); - if (t5 != null) - damagePerCombo += t5.GetAmount(); + int damagePerCombo = (int)(GetCaster().GetTotalAttackPowerValue(WeaponAttackType.BaseAttack) * 0.559f); + AuraEffect t5 = GetCaster().GetAuraEffect(SpellIds.T52pSetBonus, 0); + if (t5 != null) + damagePerCombo += t5.GetAmount(); - SetEffectValue(GetEffectValue() + damagePerCombo * GetCaster().GetPower(PowerType.ComboPoints)); - } - - public override void Register() - { - OnEffectLaunchTarget.Add(new EffectHandler(CalculateDamage, 0, SpellEffectName.SchoolDamage)); - } + SetEffectValue(GetEffectValue() + damagePerCombo * GetCaster().GetPower(PowerType.ComboPoints)); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_rog_eviscerate_SpellScript(); + OnEffectLaunchTarget.Add(new EffectHandler(CalculateDamage, 0, SpellEffectName.SchoolDamage)); } } - + [Script] // 32645 - Envenom - class spell_rog_envenom : SpellScriptLoader + class spell_rog_envenom : SpellScript { - public spell_rog_envenom() : base("spell_rog_envenom") { } - - class spell_rog_envenom_SpellScript : SpellScript + void CalculateDamage(uint effIndex) { - void CalculateDamage(uint effIndex) - { - int damagePerCombo = (int)(GetCaster().GetTotalAttackPowerValue(WeaponAttackType.BaseAttack) * 0.417f); - AuraEffect t5 = GetCaster().GetAuraEffect(SpellIds.T52pSetBonus, 0); - if (t5 != null) - damagePerCombo += t5.GetAmount(); + int damagePerCombo = (int)(GetCaster().GetTotalAttackPowerValue(WeaponAttackType.BaseAttack) * 0.417f); + AuraEffect t5 = GetCaster().GetAuraEffect(SpellIds.T52pSetBonus, 0); + if (t5 != null) + damagePerCombo += t5.GetAmount(); - SetEffectValue(GetEffectValue() + damagePerCombo * GetCaster().GetPower(PowerType.ComboPoints)); - } - - public override void Register() - { - OnEffectLaunchTarget.Add(new EffectHandler(CalculateDamage, 0, SpellEffectName.SchoolDamage)); - } + SetEffectValue(GetEffectValue() + damagePerCombo * GetCaster().GetPower(PowerType.ComboPoints)); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_rog_envenom_SpellScript(); + OnEffectLaunchTarget.Add(new EffectHandler(CalculateDamage, 0, SpellEffectName.SchoolDamage)); } } } diff --git a/Scripts/Spells/Shaman.cs b/Scripts/Spells/Shaman.cs index 733effdad..8a468d8ab 100644 --- a/Scripts/Spells/Shaman.cs +++ b/Scripts/Spells/Shaman.cs @@ -75,1114 +75,824 @@ namespace Scripts.Spells.Shaman } [Script] // 108281 - Ancestral Guidance - class spell_sha_ancestral_guidance : SpellScriptLoader + class spell_sha_ancestral_guidance : AuraScript { - public spell_sha_ancestral_guidance() : base("spell_sha_ancestral_guidance") { } - - class spell_sha_ancestral_guidance_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.AncestralGuidanceHeal); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - if (eventInfo.GetHealInfo().GetSpellInfo().Id == SpellIds.AncestralGuidanceHeal) - return false; - return true; - } - - void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - int bp0 = MathFunctions.CalculatePct((int)eventInfo.GetDamageInfo().GetDamage(), aurEff.GetAmount()); - if (bp0 != 0) - eventInfo.GetActor().CastCustomSpell(SpellIds.AncestralGuidanceHeal, SpellValueMod.BasePoint0, bp0, eventInfo.GetActor(), true, null, aurEff); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.AncestralGuidanceHeal); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_sha_ancestral_guidance_AuraScript(); + if (eventInfo.GetHealInfo().GetSpellInfo().Id == SpellIds.AncestralGuidanceHeal) + return false; + return true; + } + + void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + int bp0 = MathFunctions.CalculatePct((int)eventInfo.GetDamageInfo().GetDamage(), aurEff.GetAmount()); + if (bp0 != 0) + eventInfo.GetActor().CastCustomSpell(SpellIds.AncestralGuidanceHeal, SpellValueMod.BasePoint0, bp0, eventInfo.GetActor(), true, null, aurEff); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); } } [Script] // 114911 - Ancestral Guidance Heal - class spell_sha_ancestral_guidance_heal : SpellScriptLoader + class spell_sha_ancestral_guidance_heal : SpellScript { - public spell_sha_ancestral_guidance_heal() : base("spell_sha_ancestral_guidance_heal") { } - - class spell_sha_ancestral_guidance_heal_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.AncestralGuidance); - } - - void ResizeTargets(List targets) - { - targets.Resize(3); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(ResizeTargets, 0, Targets.UnitDestAreaAlly)); - } + return ValidateSpellInfo(SpellIds.AncestralGuidance); } - public override SpellScript GetSpellScript() + void ResizeTargets(List targets) { - return new spell_sha_ancestral_guidance_heal_SpellScript(); + targets.Resize(3); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(ResizeTargets, 0, Targets.UnitDestAreaAlly)); } } [Script] // 2825 - Bloodlust - class spell_sha_bloodlust : SpellScriptLoader + class spell_sha_bloodlust : SpellScript { - public spell_sha_bloodlust() : base("spell_sha_bloodlust") { } - - class spell_sha_bloodlust_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.Sated, SpellIds.HunterInsanity, SpellIds.MageTemporalDisplacement, SpellIds.PetNetherwindsFatigued); - } - - void RemoveInvalidTargets(List targets) - { - targets.RemoveAll(new UnitAuraCheck(true, SpellIds.Sated)); - targets.RemoveAll(new UnitAuraCheck(true, SpellIds.HunterInsanity)); - targets.RemoveAll(new UnitAuraCheck(true, SpellIds.MageTemporalDisplacement)); - } - - void ApplyDebuff() - { - Unit target = GetHitUnit(); - if (target) - target.CastSpell(target, SpellIds.Sated, true); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(RemoveInvalidTargets, 0, Targets.UnitCasterAreaRaid)); - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(RemoveInvalidTargets, 1, Targets.UnitCasterAreaRaid)); - AfterHit.Add(new HitHandler(ApplyDebuff)); - } + return ValidateSpellInfo(SpellIds.Sated, SpellIds.HunterInsanity, SpellIds.MageTemporalDisplacement, SpellIds.PetNetherwindsFatigued); } - public override SpellScript GetSpellScript() + void RemoveInvalidTargets(List targets) { - return new spell_sha_bloodlust_SpellScript(); + targets.RemoveAll(new UnitAuraCheck(true, SpellIds.Sated)); + targets.RemoveAll(new UnitAuraCheck(true, SpellIds.HunterInsanity)); + targets.RemoveAll(new UnitAuraCheck(true, SpellIds.MageTemporalDisplacement)); + } + + void ApplyDebuff() + { + Unit target = GetHitUnit(); + if (target) + target.CastSpell(target, SpellIds.Sated, true); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(RemoveInvalidTargets, 0, Targets.UnitCasterAreaRaid)); + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(RemoveInvalidTargets, 1, Targets.UnitCasterAreaRaid)); + AfterHit.Add(new HitHandler(ApplyDebuff)); } } [Script] // 187874 - Crash Lightning - class spell_sha_crash_lightning : SpellScriptLoader + class spell_sha_crash_lightning : SpellScript { - public spell_sha_crash_lightning() : base("spell_sha_crash_lightning") { } - - class spell_sha_crash_lightning_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.CrashLightningCleave); - } - - void CountTargets(List targets) - { - _targetsHit = targets.Count; - } - - void TriggerCleaveBuff() - { - if (_targetsHit >= 2) - GetCaster().CastSpell(GetCaster(), SpellIds.CrashLightningCleave, true); - - AuraEffect gatheringStorms = GetCaster().GetAuraEffect(SpellIds.GatheringStorms, 0); - if (gatheringStorms != null) - GetCaster().CastCustomSpell(SpellIds.GatheringStormsBuff, SpellValueMod.BasePoint0, (int)(gatheringStorms.GetAmount() * _targetsHit), GetCaster(), true); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(CountTargets, 0, Targets.UnitConeEnemy104)); - AfterCast.Add(new CastHandler(TriggerCleaveBuff)); - } - - int _targetsHit = 0; + return ValidateSpellInfo(SpellIds.CrashLightningCleave); } - public override SpellScript GetSpellScript() + void CountTargets(List targets) { - return new spell_sha_crash_lightning_SpellScript(); + _targetsHit = targets.Count; } + + void TriggerCleaveBuff() + { + if (_targetsHit >= 2) + GetCaster().CastSpell(GetCaster(), SpellIds.CrashLightningCleave, true); + + AuraEffect gatheringStorms = GetCaster().GetAuraEffect(SpellIds.GatheringStorms, 0); + if (gatheringStorms != null) + GetCaster().CastCustomSpell(SpellIds.GatheringStormsBuff, SpellValueMod.BasePoint0, (int)(gatheringStorms.GetAmount() * _targetsHit), GetCaster(), true); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(CountTargets, 0, Targets.UnitConeEnemy104)); + AfterCast.Add(new CastHandler(TriggerCleaveBuff)); + } + + int _targetsHit = 0; } [Script] // 204288 - Earth Shield - class spell_sha_earth_shield : SpellScriptLoader + class spell_sha_earth_shield : AuraScript { - public spell_sha_earth_shield() : base("spell_sha_earth_shield") { } - - class spell_sha_earth_shield_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.EarthShieldHeal); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - if (eventInfo.GetDamageInfo() == null || !HasEffect(1) || eventInfo.GetDamageInfo().GetDamage() < GetTarget().CountPctFromMaxHealth(GetEffect(1).GetAmount())) - return false; - return true; - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - GetTarget().CastSpell(GetTarget(), SpellIds.EarthShieldHeal, true, null, aurEff, GetCasterGUID()); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.EarthShieldHeal); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_sha_earth_shield_AuraScript(); + if (eventInfo.GetDamageInfo() == null || !HasEffect(1) || eventInfo.GetDamageInfo().GetDamage() < GetTarget().CountPctFromMaxHealth(GetEffect(1).GetAmount())) + return false; + return true; + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + + GetTarget().CastSpell(GetTarget(), SpellIds.EarthShieldHeal, true, null, aurEff, GetCasterGUID()); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.Dummy)); } } [Script] // 170374 - Earthen Rage (Passive) - class spell_sha_earthen_rage_passive : SpellScriptLoader + public class spell_sha_earthen_rage_passive : AuraScript { - public spell_sha_earthen_rage_passive() : base("spell_sha_earthen_rage_passive") { } - - public class spell_sha_earthen_rage_passive_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.EarthenRagePeriodic, SpellIds.EarthenRageDamage); - } - - void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - _procTargetGuid = eventInfo.GetProcTarget().GetGUID(); - eventInfo.GetActor().CastSpell(eventInfo.GetActor(), SpellIds.EarthenRagePeriodic, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); - } - - public ObjectGuid GetProcTargetGuid() - { - return _procTargetGuid; - } - - ObjectGuid _procTargetGuid; + return ValidateSpellInfo(SpellIds.EarthenRagePeriodic, SpellIds.EarthenRageDamage); } - public override AuraScript GetAuraScript() + void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_sha_earthen_rage_passive_AuraScript(); + PreventDefaultAction(); + _procTargetGuid = eventInfo.GetProcTarget().GetGUID(); + eventInfo.GetActor().CastSpell(eventInfo.GetActor(), SpellIds.EarthenRagePeriodic, true); } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); + } + + public ObjectGuid GetProcTargetGuid() + { + return _procTargetGuid; + } + + ObjectGuid _procTargetGuid; } [Script] // 170377 - Earthen Rage (Proc Aura) - class spell_sha_earthen_rage_proc_aura : SpellScriptLoader + class spell_sha_earthen_rage_proc_aura : AuraScript { - public spell_sha_earthen_rage_proc_aura() : base("spell_sha_earthen_rage_proc_aura") { } - - class spell_sha_earthen_rage_proc_aura_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.EarthenRagePassive, SpellIds.EarthenRageDamage); - } + return ValidateSpellInfo(SpellIds.EarthenRagePassive, SpellIds.EarthenRageDamage); + } - void HandleEffectPeriodic(AuraEffect aurEff) + void HandleEffectPeriodic(AuraEffect aurEff) + { + PreventDefaultAction(); + Aura aura = GetCaster().GetAura(SpellIds.EarthenRagePassive); + if (aura != null) { - PreventDefaultAction(); - Aura aura = GetCaster().GetAura(SpellIds.EarthenRagePassive); - if (aura != null) + var earthen_rage_script = aura.GetScript("spell_sha_earthen_rage_passive"); + if (earthen_rage_script != null) { - var earthen_rage_script = aura.GetScript(nameof(spell_sha_earthen_rage_passive)); - if (earthen_rage_script != null) - { - Unit procTarget = Global.ObjAccessor.GetUnit(GetCaster(), earthen_rage_script.GetProcTargetGuid()); - if (procTarget) - GetTarget().CastSpell(procTarget, SpellIds.EarthenRageDamage, true); + Unit procTarget = Global.ObjAccessor.GetUnit(GetCaster(), earthen_rage_script.GetProcTargetGuid()); + if (procTarget) + GetTarget().CastSpell(procTarget, SpellIds.EarthenRageDamage, true); - } } } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); - } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_sha_earthen_rage_proc_aura_AuraScript(); + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicDummy)); } } [Script] // 117014 - Elemental Blast - class spell_sha_elemental_blast : SpellScriptLoader + class spell_sha_elemental_blast : SpellScript { - public spell_sha_elemental_blast() : base("spell_sha_elemental_blast") { } - - class spell_sha_elemental_blast_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ElementalBlastCrit, SpellIds.ElementalBlastHaste, SpellIds.ElementalBlastMastery); - } - - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Player); - } - - void TriggerBuff() - { - Player caster = GetCaster().ToPlayer(); - uint spellId = RandomHelper.RAND(SpellIds.ElementalBlastCrit, SpellIds.ElementalBlastHaste, SpellIds.ElementalBlastMastery); - - caster.CastSpell(caster, spellId, TriggerCastFlags.FullMask); - } - - public override void Register() - { - AfterCast.Add(new CastHandler(TriggerBuff)); - } + return ValidateSpellInfo(SpellIds.ElementalBlastCrit, SpellIds.ElementalBlastHaste, SpellIds.ElementalBlastMastery); } - public override SpellScript GetSpellScript() + public override bool Load() { - return new spell_sha_elemental_blast_SpellScript(); + return GetCaster().IsTypeId(TypeId.Player); + } + + void TriggerBuff() + { + Player caster = GetCaster().ToPlayer(); + uint spellId = RandomHelper.RAND(SpellIds.ElementalBlastCrit, SpellIds.ElementalBlastHaste, SpellIds.ElementalBlastMastery); + + caster.CastSpell(caster, spellId, TriggerCastFlags.FullMask); + } + + public override void Register() + { + AfterCast.Add(new CastHandler(TriggerBuff)); } } [Script] // 1535 Fire Nova - class spell_sha_fire_nova : SpellScriptLoader + class spell_sha_fire_nova : SpellScript { - public spell_sha_fire_nova() : base("spell_sha_fire_nova") { } - - class spell_sha_fire_nova_SpellScript : SpellScript + void HandleDummy(uint effIndex) { - void HandleDummy(uint effIndex) - { - Unit target = GetHitUnit(); - if (target) - if (target.HasAura(SpellIds.FlameShock)) - GetCaster().CastSpell(target, SpellIds.FireNovaTriggered, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + Unit target = GetHitUnit(); + if (target) + if (target.HasAura(SpellIds.FlameShock)) + GetCaster().CastSpell(target, SpellIds.FireNovaTriggered, true); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_sha_fire_nova_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 194084 - Flametongue - class spell_sha_flametongue : SpellScriptLoader + class spell_sha_flametongue : AuraScript { - public spell_sha_flametongue() : base("spell_sha_flametongue") { } - - class spell_sha_flametongue_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.FlametongueAttack); - } - - void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - Unit attacker = eventInfo.GetActor(); - int damage = (int)(attacker.GetTotalAttackPowerValue(WeaponAttackType.BaseAttack) * 0.12f / 2600 * attacker.GetBaseAttackTime(WeaponAttackType.BaseAttack)); - attacker.CastCustomSpell(SpellIds.FlametongueAttack, SpellValueMod.BasePoint0, damage, eventInfo.GetActionTarget(), TriggerCastFlags.FullMask, null, aurEff); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.FlametongueAttack); } - public override AuraScript GetAuraScript() + void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_sha_flametongue_AuraScript(); + PreventDefaultAction(); + + Unit attacker = eventInfo.GetActor(); + int damage = (int)(attacker.GetTotalAttackPowerValue(WeaponAttackType.BaseAttack) * 0.12f / 2600 * attacker.GetBaseAttackTime(WeaponAttackType.BaseAttack)); + attacker.CastCustomSpell(SpellIds.FlametongueAttack, SpellValueMod.BasePoint0, damage, eventInfo.GetActionTarget(), TriggerCastFlags.FullMask, null, aurEff); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); } } [Script] // 52042 - Healing Stream Totem - class spell_sha_healing_stream_totem_heal : SpellScriptLoader + class spell_sha_healing_stream_totem_heal : SpellScript { - public spell_sha_healing_stream_totem_heal() : base("spell_sha_healing_stream_totem_heal") { } - - class spell_sha_healing_stream_totem_heal_SpellScript : SpellScript + void SelectTargets(List targets) { - void SelectTargets(List targets) + targets.RemoveAll(target => { - targets.RemoveAll(target => - { - return !target.ToUnit() || target.ToUnit().IsFullHealth(); - }); + return !target.ToUnit() || target.ToUnit().IsFullHealth(); + }); - targets.RandomResize(1); + targets.RandomResize(1); - if (targets.Empty()) - targets.Add(GetOriginalCaster()); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(SelectTargets, 0, Targets.UnitDestAreaAlly)); - } + if (targets.Empty()) + targets.Add(GetOriginalCaster()); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_sha_healing_stream_totem_heal_SpellScript(); + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(SelectTargets, 0, Targets.UnitDestAreaAlly)); } } [Script] // 32182 - Heroism - class spell_sha_heroism : SpellScriptLoader + class spell_sha_heroism : SpellScript { - public spell_sha_heroism() : base("spell_sha_heroism") { } - - class spell_sha_heroism_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.Exhaustion, SpellIds.HunterInsanity, SpellIds.MageTemporalDisplacement, SpellIds.PetNetherwindsFatigued); - } - - void RemoveInvalidTargets(List targets) - { - targets.RemoveAll(new UnitAuraCheck(true, SpellIds.Exhaustion)); - targets.RemoveAll(new UnitAuraCheck(true, SpellIds.HunterInsanity)); - targets.RemoveAll(new UnitAuraCheck(true, SpellIds.MageTemporalDisplacement)); - } - - void ApplyDebuff() - { - Unit target = GetHitUnit(); - if (target) - target.CastSpell(target, SpellIds.Exhaustion, true); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(RemoveInvalidTargets, 0, Targets.UnitCasterAreaRaid)); - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(RemoveInvalidTargets, 1, Targets.UnitCasterAreaRaid)); - AfterHit.Add(new HitHandler(ApplyDebuff)); - } + return ValidateSpellInfo(SpellIds.Exhaustion, SpellIds.HunterInsanity, SpellIds.MageTemporalDisplacement, SpellIds.PetNetherwindsFatigued); } - public override SpellScript GetSpellScript() + void RemoveInvalidTargets(List targets) { - return new spell_sha_heroism_SpellScript(); + targets.RemoveAll(new UnitAuraCheck(true, SpellIds.Exhaustion)); + targets.RemoveAll(new UnitAuraCheck(true, SpellIds.HunterInsanity)); + targets.RemoveAll(new UnitAuraCheck(true, SpellIds.MageTemporalDisplacement)); + } + + void ApplyDebuff() + { + Unit target = GetHitUnit(); + if (target) + target.CastSpell(target, SpellIds.Exhaustion, true); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(RemoveInvalidTargets, 0, Targets.UnitCasterAreaRaid)); + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(RemoveInvalidTargets, 1, Targets.UnitCasterAreaRaid)); + AfterHit.Add(new HitHandler(ApplyDebuff)); } } [Script] // 23551 - Lightning Shield T2 Bonus - class spell_sha_item_lightning_shield : SpellScriptLoader + class spell_sha_item_lightning_shield : AuraScript { - public spell_sha_item_lightning_shield() : base("spell_sha_item_lightning_shield") { } - - class spell_sha_item_lightning_shield_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ItemLightningShield); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.ItemLightningShield, true, null, aurEff); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); - } + return ValidateSpellInfo(SpellIds.ItemLightningShield); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_sha_item_lightning_shield_AuraScript(); + PreventDefaultAction(); + GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.ItemLightningShield, true, null, aurEff); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); } } [Script] // 23552 - Lightning Shield T2 Bonus - class spell_sha_item_lightning_shield_trigger : SpellScriptLoader + class spell_sha_item_lightning_shield_trigger : AuraScript { - public spell_sha_item_lightning_shield_trigger() : base("spell_sha_item_lightning_shield_trigger") { } - - class spell_sha_item_lightning_shield_trigger_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ItemLightningShieldDamage); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), SpellIds.ItemLightningShieldDamage, true, null, aurEff); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); - } + return ValidateSpellInfo(SpellIds.ItemLightningShieldDamage); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_sha_item_lightning_shield_trigger_AuraScript(); + PreventDefaultAction(); + GetTarget().CastSpell(GetTarget(), SpellIds.ItemLightningShieldDamage, true, null, aurEff); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); } } [Script] // 23572 - Mana Surge - class spell_sha_item_mana_surge : SpellScriptLoader + class spell_sha_item_mana_surge : AuraScript { - public spell_sha_item_mana_surge() : base("spell_sha_item_mana_surge") { } - - class spell_sha_item_mana_surge_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ItemManaSurge); - } + return ValidateSpellInfo(SpellIds.ItemManaSurge); + } - bool CheckProc(ProcEventInfo eventInfo) - { - return eventInfo.GetSpellInfo() != null; - } + bool CheckProc(ProcEventInfo eventInfo) + { + return eventInfo.GetSpellInfo() != null; + } - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - SpellInfo spellInfo = eventInfo.GetSpellInfo(); - if (spellInfo == null) - return; + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + SpellInfo spellInfo = eventInfo.GetSpellInfo(); + if (spellInfo == null) + return; - var costs = eventInfo.GetDamageInfo().GetSpellInfo().CalcPowerCost(GetTarget(), eventInfo.GetDamageInfo().GetSchoolMask()); - var m = costs.Find(cost => cost.Power == PowerType.Mana); - if (m != null) - { - int mana = MathFunctions.CalculatePct(m.Amount, 35); - if (mana > 0) - GetTarget().CastCustomSpell(SpellIds.ItemManaSurge, SpellValueMod.BasePoint0, mana, GetTarget(), true, null, aurEff); - } - } - - public override void Register() + var costs = eventInfo.GetDamageInfo().GetSpellInfo().CalcPowerCost(GetTarget(), eventInfo.GetDamageInfo().GetSchoolMask()); + var m = costs.Find(cost => cost.Power == PowerType.Mana); + if (m != null) { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); + int mana = MathFunctions.CalculatePct(m.Amount, 35); + if (mana > 0) + GetTarget().CastCustomSpell(SpellIds.ItemManaSurge, SpellValueMod.BasePoint0, mana, GetTarget(), true, null, aurEff); } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_sha_item_mana_surge_AuraScript(); + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); } } [Script] // 40463 - Shaman Tier 6 Trinket - class spell_sha_item_t6_trinket : SpellScriptLoader + class spell_sha_item_t6_trinket : AuraScript { - public spell_sha_item_t6_trinket() : base("spell_sha_item_t6_trinket") { } - - class spell_sha_item_t6_trinket_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.EnergySurge, SpellIds.PowerSurge); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - SpellInfo spellInfo = eventInfo.GetSpellInfo(); - if (spellInfo == null) - return; - - uint spellId; - int chance; - - // Lesser Healing Wave - if (spellInfo.SpellFamilyFlags[0].HasAnyFlag(0x00000080u)) - { - spellId = SpellIds.EnergySurge; - chance = 10; - } - // Lightning Bolt - else if (spellInfo.SpellFamilyFlags[0].HasAnyFlag(0x00000001u)) - { - spellId = SpellIds.EnergySurge; - chance = 15; - } - // Stormstrike - else if (spellInfo.SpellFamilyFlags[1].HasAnyFlag(0x00000010u)) - { - spellId = SpellIds.PowerSurge; - chance = 50; - } - else - return; - - if (RandomHelper.randChance(chance)) - eventInfo.GetActor().CastSpell((Unit)null, spellId, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.EnergySurge, SpellIds.PowerSurge); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_sha_item_t6_trinket_AuraScript(); + PreventDefaultAction(); + SpellInfo spellInfo = eventInfo.GetSpellInfo(); + if (spellInfo == null) + return; + + uint spellId; + int chance; + + // Lesser Healing Wave + if (spellInfo.SpellFamilyFlags[0].HasAnyFlag(0x00000080u)) + { + spellId = SpellIds.EnergySurge; + chance = 10; + } + // Lightning Bolt + else if (spellInfo.SpellFamilyFlags[0].HasAnyFlag(0x00000001u)) + { + spellId = SpellIds.EnergySurge; + chance = 15; + } + // Stormstrike + else if (spellInfo.SpellFamilyFlags[1].HasAnyFlag(0x00000010u)) + { + spellId = SpellIds.PowerSurge; + chance = 50; + } + else + return; + + if (RandomHelper.randChance(chance)) + eventInfo.GetActor().CastSpell((Unit)null, spellId, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } [Script] // 70811 - Item - Shaman T10 Elemental 2P Bonus - class spell_sha_item_t10_elemental_2p_bonus : SpellScriptLoader + class spell_sha_item_t10_elemental_2p_bonus : AuraScript { - public spell_sha_item_t10_elemental_2p_bonus() : base("spell_sha_item_t10_elemental_2p_bonus") { } - - class spell_sha_item_t10_elemental_2p_bonus_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ElementalMastery); - } - - void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - Player target = GetTarget().ToPlayer(); - if (target) - target.GetSpellHistory().ModifyCooldown(SpellIds.ElementalMastery, -aurEff.GetAmount()); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.ElementalMastery); } - public override AuraScript GetAuraScript() + void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_sha_item_t10_elemental_2p_bonus_AuraScript(); + PreventDefaultAction(); + Player target = GetTarget().ToPlayer(); + if (target) + target.GetSpellHistory().ModifyCooldown(SpellIds.ElementalMastery, -aurEff.GetAmount()); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); } } [Script] // 189063 - Lightning Vortex (proc 185881 Item - Shaman T18 Elemental 4P Bonus) - class spell_sha_item_t18_elemental_4p_bonus : SpellScriptLoader + class spell_sha_item_t18_elemental_4p_bonus : AuraScript { - public spell_sha_item_t18_elemental_4p_bonus() : base("spell_sha_item_t18_elemental_4p_bonus") { } - - class spell_sha_item_t18_elemental_4p_bonus_AuraScript : AuraScript + void DiminishHaste(AuraEffect aurEff) { - void DiminishHaste(AuraEffect aurEff) - { - PreventDefaultAction(); - AuraEffect hasteBuff = GetEffect(0); - if (hasteBuff != null) - hasteBuff.ChangeAmount(hasteBuff.GetAmount() - aurEff.GetAmount()); - } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(DiminishHaste, 1, AuraType.PeriodicDummy)); - } + PreventDefaultAction(); + AuraEffect hasteBuff = GetEffect(0); + if (hasteBuff != null) + hasteBuff.ChangeAmount(hasteBuff.GetAmount() - aurEff.GetAmount()); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_sha_item_t18_elemental_4p_bonus_AuraScript(); + OnEffectPeriodic.Add(new EffectPeriodicHandler(DiminishHaste, 1, AuraType.PeriodicDummy)); } } [Script] // 51505 - Lava burst - class spell_sha_lava_burst : SpellScriptLoader + class spell_sha_lava_burst : SpellScript { - public spell_sha_lava_burst() : base("spell_sha_lava_burst") { } - - class spell_sha_lava_burst_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.PathOfFlamesTalent, SpellIds.PathOfFlamesSpread); - } + return ValidateSpellInfo(SpellIds.PathOfFlamesTalent, SpellIds.PathOfFlamesSpread); + } - void HandleScript(uint effIndex) + void HandleScript(uint effIndex) + { + Unit caster = GetCaster(); + if (caster) { - Unit caster = GetCaster(); - if (caster) - { - Unit target = GetExplTargetUnit(); - if (target) - if (caster.HasAura(SpellIds.PathOfFlamesTalent)) - caster.CastSpell(target, SpellIds.PathOfFlamesSpread, true); - } - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.SchoolDamage)); + Unit target = GetExplTargetUnit(); + if (target) + if (caster.HasAura(SpellIds.PathOfFlamesTalent)) + caster.CastSpell(target, SpellIds.PathOfFlamesSpread, true); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_sha_lava_burst_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.SchoolDamage)); } } [Script] // 77756 - Lava Surge - class spell_sha_lava_surge : SpellScriptLoader + class spell_sha_lava_surge : AuraScript { - public spell_sha_lava_surge() : base("spell_sha_lava_surge") { } - - class spell_sha_lava_surge_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.LavaSurge); - } - - void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), SpellIds.LavaSurge, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.LavaSurge); } - public override AuraScript GetAuraScript() + void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_sha_lava_surge_AuraScript(); + PreventDefaultAction(); + GetTarget().CastSpell(GetTarget(), SpellIds.LavaSurge, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); } } [Script] // 77762 - Lava Surge - class spell_sha_lava_surge_proc : SpellScriptLoader + class spell_sha_lava_surge_proc : SpellScript { - public spell_sha_lava_surge_proc() : base("spell_sha_lava_surge_proc") { } - - class spell_sha_lava_surge_proc_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.LavaBurst); - } - - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Player); - } - - void ResetCooldown() - { - GetCaster().GetSpellHistory().RestoreCharge(Global.SpellMgr.GetSpellInfo(SpellIds.LavaBurst).ChargeCategoryId); - } - - public override void Register() - { - AfterHit.Add(new HitHandler(ResetCooldown)); - } + return ValidateSpellInfo(SpellIds.LavaBurst); } - public override SpellScript GetSpellScript() + public override bool Load() { - return new spell_sha_lava_surge_proc_SpellScript(); + return GetCaster().IsTypeId(TypeId.Player); + } + + void ResetCooldown() + { + GetCaster().GetSpellHistory().RestoreCharge(Global.SpellMgr.GetSpellInfo(SpellIds.LavaBurst).ChargeCategoryId); + } + + public override void Register() + { + AfterHit.Add(new HitHandler(ResetCooldown)); } } [Script] // 210621 - Path of Flames Spread - class spell_sha_path_of_flames_spread : SpellScriptLoader + class spell_sha_path_of_flames_spread : SpellScript { - public spell_sha_path_of_flames_spread() : base("spell_sha_path_of_flames_spread") { } - - class spell_sha_path_of_flames_spread_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.FlameShockMaelstrom); - } + return ValidateSpellInfo(SpellIds.FlameShockMaelstrom); + } - void FilterTargets(List targets) + void FilterTargets(List targets) + { + targets.Remove(GetExplTargetUnit()); + targets.RandomResize(target => { - targets.Remove(GetExplTargetUnit()); - targets.RandomResize(target => - { - return target.IsTypeId(TypeId.Unit) && !target.ToUnit().HasAura(SpellIds.FlameShockMaelstrom, GetCaster().GetGUID()); - }, 1); - } + return target.IsTypeId(TypeId.Unit) && !target.ToUnit().HasAura(SpellIds.FlameShockMaelstrom, GetCaster().GetGUID()); + }, 1); + } - void HandleScript(uint effIndex) + void HandleScript(uint effIndex) + { + Unit mainTarget = GetExplTargetUnit(); + if (mainTarget) { - Unit mainTarget = GetExplTargetUnit(); - if (mainTarget) + Aura flameShock = mainTarget.GetAura(SpellIds.FlameShockMaelstrom, GetCaster().GetGUID()); + if (flameShock != null) { - Aura flameShock = mainTarget.GetAura(SpellIds.FlameShockMaelstrom, GetCaster().GetGUID()); - if (flameShock != null) + Aura newAura = GetCaster().AddAura(SpellIds.FlameShockMaelstrom, GetHitUnit()); + if (newAura != null) { - Aura newAura = GetCaster().AddAura(SpellIds.FlameShockMaelstrom, GetHitUnit()); - if (newAura != null) - { - newAura.SetDuration(flameShock.GetDuration()); - newAura.SetMaxDuration(flameShock.GetDuration()); - } + newAura.SetDuration(flameShock.GetDuration()); + newAura.SetMaxDuration(flameShock.GetDuration()); } } } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 1, Targets.UnitDestAreaEnemy)); - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 1, SpellEffectName.Dummy)); - } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_sha_path_of_flames_spread_SpellScript(); + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 1, Targets.UnitDestAreaEnemy)); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 1, SpellEffectName.Dummy)); } } [Script] // 51562 - Tidal Waves - class spell_sha_tidal_waves : SpellScriptLoader + class spell_sha_tidal_waves : AuraScript { - public spell_sha_tidal_waves() : base("spell_sha_tidal_waves") { } - - class spell_sha_tidal_waves_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.TidalWaves); - } - - void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - int basePoints0 = -aurEff.GetAmount(); - int basePoints1 = aurEff.GetAmount(); - - GetTarget().CastCustomSpell(GetTarget(), SpellIds.TidalWaves, basePoints0, basePoints1, 0, true, null, aurEff); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.TidalWaves); } - public override AuraScript GetAuraScript() + void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_sha_tidal_waves_AuraScript(); + PreventDefaultAction(); + int basePoints0 = -aurEff.GetAmount(); + int basePoints1 = aurEff.GetAmount(); + + GetTarget().CastCustomSpell(GetTarget(), SpellIds.TidalWaves, basePoints0, basePoints1, 0, true, null, aurEff); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); } } [Script] // 28823 - Totemic Power - class spell_sha_t3_6p_bonus : SpellScriptLoader + class spell_sha_t3_6p_bonus : AuraScript { - public spell_sha_t3_6p_bonus() : base("spell_sha_t3_6p_bonus") { } - - class spell_sha_t3_6p_bonus_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.TotemicPowerArmor, SpellIds.TotemicPowerAttackPower, SpellIds.TotemicPowerSpellPower, SpellIds.TotemicPowerMp5); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - uint spellId; - Unit caster = eventInfo.GetActor(); - Unit target = eventInfo.GetProcTarget(); - - switch (target.GetClass()) - { - case Class.Paladin: - case Class.Priest: - case Class.Shaman: - case Class.Druid: - spellId = SpellIds.TotemicPowerMp5; - break; - case Class.Mage: - case Class.Warlock: - spellId = SpellIds.TotemicPowerSpellPower; - break; - case Class.Hunter: - case Class.Rogue: - spellId = SpellIds.TotemicPowerAttackPower; - break; - case Class.Warrior: - spellId = SpellIds.TotemicPowerArmor; - break; - default: - return; - } - - caster.CastSpell(target, spellId, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.TotemicPowerArmor, SpellIds.TotemicPowerAttackPower, SpellIds.TotemicPowerSpellPower, SpellIds.TotemicPowerMp5); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_sha_t3_6p_bonus_AuraScript(); + PreventDefaultAction(); + + uint spellId; + Unit caster = eventInfo.GetActor(); + Unit target = eventInfo.GetProcTarget(); + + switch (target.GetClass()) + { + case Class.Paladin: + case Class.Priest: + case Class.Shaman: + case Class.Druid: + spellId = SpellIds.TotemicPowerMp5; + break; + case Class.Mage: + case Class.Warlock: + spellId = SpellIds.TotemicPowerSpellPower; + break; + case Class.Hunter: + case Class.Rogue: + spellId = SpellIds.TotemicPowerAttackPower; + break; + case Class.Warrior: + spellId = SpellIds.TotemicPowerArmor; + break; + default: + return; + } + + caster.CastSpell(target, spellId, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } [Script] // 64928 - Item - Shaman T8 Elemental 4P Bonus - class spell_sha_t8_elemental_4p_bonus : SpellScriptLoader + class spell_sha_t8_elemental_4p_bonus : AuraScript { - public spell_sha_t8_elemental_4p_bonus() : base("spell_sha_t8_elemental_4p_bonus") { } - - class spell_sha_t8_elemental_4p_bonus_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.Electrified); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - DamageInfo damageInfo = eventInfo.GetDamageInfo(); - if (damageInfo == null || damageInfo.GetDamage() == 0) - return; - - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.Electrified); - int amount = (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount()); - amount /= (int)spellInfo.GetMaxTicks(Difficulty.None); - - // Add remaining ticks to healing done - Unit caster = eventInfo.GetActor(); - Unit target = eventInfo.GetProcTarget(); - amount += (int)target.GetRemainingPeriodicAmount(caster.GetGUID(), SpellIds.Electrified, AuraType.PeriodicDamage); - - caster.CastCustomSpell(SpellIds.Electrified, SpellValueMod.BasePoint0, amount, target, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.Electrified); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_sha_t8_elemental_4p_bonus_AuraScript(); + PreventDefaultAction(); + + DamageInfo damageInfo = eventInfo.GetDamageInfo(); + if (damageInfo == null || damageInfo.GetDamage() == 0) + return; + + SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.Electrified); + int amount = (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount()); + amount /= (int)spellInfo.GetMaxTicks(Difficulty.None); + + // Add remaining ticks to healing done + Unit caster = eventInfo.GetActor(); + Unit target = eventInfo.GetProcTarget(); + amount += (int)target.GetRemainingPeriodicAmount(caster.GetGUID(), SpellIds.Electrified, AuraType.PeriodicDamage); + + caster.CastCustomSpell(SpellIds.Electrified, SpellValueMod.BasePoint0, amount, target, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } [Script] // 67228 - Item - Shaman T9 Elemental 4P Bonus (Lava Burst) - class spell_sha_t9_elemental_4p_bonus : SpellScriptLoader + class spell_sha_t9_elemental_4p_bonus : AuraScript { - public spell_sha_t9_elemental_4p_bonus() : base("spell_sha_t9_elemental_4p_bonus") { } - - class spell_sha_t9_elemental_4p_bonus_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.LavaBurstBonusDamage); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - DamageInfo damageInfo = eventInfo.GetDamageInfo(); - if (damageInfo == null || damageInfo.GetDamage() == 0) - return; - - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.LavaBurstBonusDamage); - int amount = (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount()); - amount /= (int)spellInfo.GetMaxTicks(Difficulty.None); - - // Add remaining ticks to healing done - Unit caster = eventInfo.GetActor(); - Unit target = eventInfo.GetProcTarget(); - amount += (int)target.GetRemainingPeriodicAmount(caster.GetGUID(), SpellIds.LavaBurstBonusDamage, AuraType.PeriodicDamage); - - caster.CastCustomSpell(SpellIds.LavaBurstBonusDamage, SpellValueMod.BasePoint0, amount, target, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.LavaBurstBonusDamage); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_sha_t9_elemental_4p_bonus_AuraScript(); + PreventDefaultAction(); + + DamageInfo damageInfo = eventInfo.GetDamageInfo(); + if (damageInfo == null || damageInfo.GetDamage() == 0) + return; + + SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.LavaBurstBonusDamage); + int amount = (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount()); + amount /= (int)spellInfo.GetMaxTicks(Difficulty.None); + + // Add remaining ticks to healing done + Unit caster = eventInfo.GetActor(); + Unit target = eventInfo.GetProcTarget(); + amount += (int)target.GetRemainingPeriodicAmount(caster.GetGUID(), SpellIds.LavaBurstBonusDamage, AuraType.PeriodicDamage); + + caster.CastCustomSpell(SpellIds.LavaBurstBonusDamage, SpellValueMod.BasePoint0, amount, target, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } [Script] // 70817 - Item - Shaman T10 Elemental 4P Bonus - class spell_sha_t10_elemental_4p_bonus : SpellScriptLoader + class spell_sha_t10_elemental_4p_bonus : AuraScript { - public spell_sha_t10_elemental_4p_bonus() : base("spell_sha_t10_elemental_4p_bonus") { } - - class spell_sha_t10_elemental_4p_bonus_AuraScript : AuraScript + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); + PreventDefaultAction(); - Unit caster = eventInfo.GetActor(); - Unit target = eventInfo.GetProcTarget(); + Unit caster = eventInfo.GetActor(); + Unit target = eventInfo.GetProcTarget(); - // try to find spell Flame Shock on the target - AuraEffect flameShock = target.GetAuraEffect(AuraType.PeriodicDamage, SpellFamilyNames.Shaman, new FlagArray128(0x10000000), caster.GetGUID()); - if (flameShock == null) - return; + // try to find spell Flame Shock on the target + AuraEffect flameShock = target.GetAuraEffect(AuraType.PeriodicDamage, SpellFamilyNames.Shaman, new FlagArray128(0x10000000), caster.GetGUID()); + if (flameShock == null) + return; - Aura flameShockAura = flameShock.GetBase(); + Aura flameShockAura = flameShock.GetBase(); - int maxDuration = flameShockAura.GetMaxDuration(); - int newDuration = flameShockAura.GetDuration() + aurEff.GetAmount() * Time.InMilliseconds; + int maxDuration = flameShockAura.GetMaxDuration(); + int newDuration = flameShockAura.GetDuration() + aurEff.GetAmount() * Time.InMilliseconds; - flameShockAura.SetDuration(newDuration); - // is it blizzlike to change max duration for FS? - if (newDuration > maxDuration) - flameShockAura.SetMaxDuration(newDuration); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + flameShockAura.SetDuration(newDuration); + // is it blizzlike to change max duration for FS? + if (newDuration > maxDuration) + flameShockAura.SetMaxDuration(newDuration); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_sha_t10_elemental_4p_bonus_AuraScript(); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } [Script] // 70808 - Item - Shaman T10 Restoration 4P Bonus - class spell_sha_t10_restoration_4p_bonus : SpellScriptLoader + class spell_sha_t10_restoration_4p_bonus : AuraScript { - public spell_sha_t10_restoration_4p_bonus() : base("spell_sha_t10_restoration_4p_bonus") { } - - class spell_sha_t10_restoration_4p_bonus_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ChainedHeal); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - HealInfo healInfo = eventInfo.GetHealInfo(); - if (healInfo == null || healInfo.GetHeal() == 0) - return; - - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.ChainedHeal); - int amount = (int)MathFunctions.CalculatePct(healInfo.GetHeal(), aurEff.GetAmount()); - amount /= (int)spellInfo.GetMaxTicks(Difficulty.None); - - // Add remaining ticks to healing done - Unit caster = eventInfo.GetActor(); - Unit target = eventInfo.GetProcTarget(); - amount += (int)target.GetRemainingPeriodicAmount(caster.GetGUID(), SpellIds.ChainedHeal, AuraType.PeriodicHeal); - - caster.CastCustomSpell(SpellIds.ChainedHeal, SpellValueMod.BasePoint0, amount, target, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.ChainedHeal); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_sha_t10_restoration_4p_bonus_AuraScript(); + PreventDefaultAction(); + + HealInfo healInfo = eventInfo.GetHealInfo(); + if (healInfo == null || healInfo.GetHeal() == 0) + return; + + SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.ChainedHeal); + int amount = (int)MathFunctions.CalculatePct(healInfo.GetHeal(), aurEff.GetAmount()); + amount /= (int)spellInfo.GetMaxTicks(Difficulty.None); + + // Add remaining ticks to healing done + Unit caster = eventInfo.GetActor(); + Unit target = eventInfo.GetProcTarget(); + amount += (int)target.GetRemainingPeriodicAmount(caster.GetGUID(), SpellIds.ChainedHeal, AuraType.PeriodicHeal); + + caster.CastCustomSpell(SpellIds.ChainedHeal, SpellValueMod.BasePoint0, amount, target, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } [Script] // 33757 - Windfury - class spell_sha_windfury : SpellScriptLoader + class spell_sha_windfury : AuraScript { - public spell_sha_windfury() : base("spell_sha_windfury") { } - - class spell_sha_windfury_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.WindfuryAttack); - } - - void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - for (uint i = 0; i < 2; ++i) - eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), SpellIds.WindfuryAttack, true, null, aurEff); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.WindfuryAttack); } - public override AuraScript GetAuraScript() + void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_sha_windfury_AuraScript(); + PreventDefaultAction(); + + for (uint i = 0; i < 2; ++i) + eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), SpellIds.WindfuryAttack, true, null, aurEff); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); } } } \ No newline at end of file diff --git a/Scripts/Spells/Warlock.cs b/Scripts/Spells/Warlock.cs index 05b887e46..904d82986 100644 --- a/Scripts/Spells/Warlock.cs +++ b/Scripts/Spells/Warlock.cs @@ -25,8 +25,6 @@ using System.Collections.Generic; namespace Scripts.Spells.Warlock { - using SoulSwapOverrideAuraScript = spell_warl_soul_swap_override.spell_warl_soul_swap_override_AuraScript; - struct SpellIds { public const uint BaneOfDoomEffect = 18662; @@ -81,813 +79,606 @@ namespace Scripts.Spells.Warlock } [Script] // 710 - Banish - class spell_warl_banish : SpellScriptLoader + class spell_warl_banish : SpellScript { - public spell_warl_banish() : base("spell_warl_banish") { } - - class spell_warl_banish_SpellScript : SpellScript + void HandleBanish(SpellMissInfo missInfo) { - public spell_warl_banish_SpellScript() - { } + if (missInfo != SpellMissInfo.Immune) + return; - void HandleBanish(SpellMissInfo missInfo) + Unit target = GetHitUnit(); + if (target) { - if (missInfo != SpellMissInfo.Immune) - return; - - Unit target = GetHitUnit(); - if (target) - { - // Casting Banish on a banished target will remove applied aura - Aura banishAura = target.GetAura(GetSpellInfo().Id, GetCaster().GetGUID()); - if (banishAura != null) - banishAura.Remove(); - } - } - - public override void Register() - { - BeforeHit.Add(new BeforeHitHandler(HandleBanish)); + // Casting Banish on a banished target will remove applied aura + Aura banishAura = target.GetAura(GetSpellInfo().Id, GetCaster().GetGUID()); + if (banishAura != null) + banishAura.Remove(); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_warl_banish_SpellScript(); + BeforeHit.Add(new BeforeHitHandler(HandleBanish)); } } [Script] // 17962 - Conflagrate - Updated to 4.3.4 - class spell_warl_conflagrate : SpellScriptLoader + class spell_warl_conflagrate : SpellScript { - public spell_warl_conflagrate() : base("spell_warl_conflagrate") { } - - class spell_warl_conflagrate_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.Immolate); - } - - // 6.x dmg formula in tooltip - // void HandleHit(uint effIndex) - // { - // if (AuraEffect aurEff = GetHitUnit().GetAuraEffect(SPELL_WARLOCK_IMMOLATE, 2, GetCaster().GetGUID())) - // SetHitDamage(CalculatePct(aurEff.GetAmount(), HasSpellInfo().Effects[1].CalcValue(GetCaster()))); - // } - - public override void Register() - { - //OnEffectHitTarget.Add(new EffectHandler(spell_warl_conflagrate_SpellScript::HandleHit, 0, SPELL_EFFECT_SCHOOL_DAMAGE); - } + return ValidateSpellInfo(SpellIds.Immolate); } - public override SpellScript GetSpellScript() + // 6.x dmg formula in tooltip + // void HandleHit(uint effIndex) + // { + // if (AuraEffect aurEff = GetHitUnit().GetAuraEffect(SPELL_WARLOCK_IMMOLATE, 2, GetCaster().GetGUID())) + // SetHitDamage(CalculatePct(aurEff.GetAmount(), HasSpellInfo().Effects[1].CalcValue(GetCaster()))); + // } + + public override void Register() { - return new spell_warl_conflagrate_SpellScript(); + //OnEffectHitTarget.Add(new EffectHandler(spell_warl_conflagrate_SpellScript::HandleHit, 0, SPELL_EFFECT_SCHOOL_DAMAGE); } } [Script] // 6201 - Create Healthstone - class spell_warl_create_healthstone : SpellScriptLoader + class spell_warl_create_healthstone : SpellScript { - public spell_warl_create_healthstone() : base("spell_warl_create_healthstone") { } - - class spell_warl_create_healthstone_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.CreateHealthstone); - } - - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Player); - } - - void HandleScriptEffect(uint effIndex) - { - GetCaster().CastSpell(GetCaster(), SpellIds.CreateHealthstone, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); - } + return ValidateSpellInfo(SpellIds.CreateHealthstone); } - public override SpellScript GetSpellScript() + public override bool Load() { - return new spell_warl_create_healthstone_SpellScript(); + return GetCaster().IsTypeId(TypeId.Player); + } + + void HandleScriptEffect(uint effIndex) + { + GetCaster().CastSpell(GetCaster(), SpellIds.CreateHealthstone, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); } } [Script] // 603 - Bane of Doom - class spell_warl_bane_of_doom : SpellScriptLoader + class spell_warl_curse_of_doom : AuraScript { - public spell_warl_bane_of_doom() : base("spell_warl_bane_of_doom") { } - - class spell_warl_curse_of_doom_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.BaneOfDoomEffect); - } - - public override bool Load() - { - return GetCaster() && GetCaster().IsTypeId(TypeId.Player); - } - - void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - if (!GetCaster()) - return; - - AuraRemoveMode removeMode = GetTargetApplication().GetRemoveMode(); - if (removeMode != AuraRemoveMode.ByDeath || !IsExpired()) - return; - - if (GetCaster().ToPlayer().isHonorOrXPTarget(GetTarget())) - GetCaster().CastSpell(GetTarget(), SpellIds.BaneOfDoomEffect, true, null, aurEff); - } - - public override void Register() - { - AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.PeriodicDamage, AuraEffectHandleModes.Real)); - } + return ValidateSpellInfo(SpellIds.BaneOfDoomEffect); } - public override AuraScript GetAuraScript() + public override bool Load() { - return new spell_warl_curse_of_doom_AuraScript(); + return GetCaster() && GetCaster().IsTypeId(TypeId.Player); + } + + void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + if (!GetCaster()) + return; + + AuraRemoveMode removeMode = GetTargetApplication().GetRemoveMode(); + if (removeMode != AuraRemoveMode.ByDeath || !IsExpired()) + return; + + if (GetCaster().ToPlayer().isHonorOrXPTarget(GetTarget())) + GetCaster().CastSpell(GetTarget(), SpellIds.BaneOfDoomEffect, true, null, aurEff); + } + + public override void Register() + { + AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 0, AuraType.PeriodicDamage, AuraEffectHandleModes.Real)); } } [Script] // 48018 - Demonic Circle: Summon - class spell_warl_demonic_circle_summon : SpellScriptLoader + class spell_warl_demonic_circle_summon : AuraScript { - public spell_warl_demonic_circle_summon() : base("spell_warl_demonic_circle_summon") { } - - class spell_warl_demonic_circle_summon_AuraScript : AuraScript + void HandleRemove(AuraEffect aurEff, AuraEffectHandleModes mode) { - void HandleRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - // If effect is removed by expire remove the summoned demonic circle too. - if (!mode.HasAnyFlag(AuraEffectHandleModes.Reapply)) - GetTarget().RemoveGameObject(GetId(), true); + // If effect is removed by expire remove the summoned demonic circle too. + if (!mode.HasAnyFlag(AuraEffectHandleModes.Reapply)) + GetTarget().RemoveGameObject(GetId(), true); - GetTarget().RemoveAura(SpellIds.DemonicCircleAllowCast); - } + GetTarget().RemoveAura(SpellIds.DemonicCircleAllowCast); + } - void HandleDummyTick(AuraEffect aurEff) + void HandleDummyTick(AuraEffect aurEff) + { + GameObject circle = GetTarget().GetGameObject(GetId()); + if (circle) { - GameObject circle = GetTarget().GetGameObject(GetId()); - if (circle) + // Here we check if player is in demonic circle teleport range, if so add + // WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST; allowing him to cast the WARLOCK_DEMONIC_CIRCLE_TELEPORT. + // If not in range remove the WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST. + + SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.DemonicCircleTeleport); + + if (GetTarget().IsWithinDist(circle, spellInfo.GetMaxRange(true))) { - // Here we check if player is in demonic circle teleport range, if so add - // WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST; allowing him to cast the WARLOCK_DEMONIC_CIRCLE_TELEPORT. - // If not in range remove the WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST. - - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.DemonicCircleTeleport); - - if (GetTarget().IsWithinDist(circle, spellInfo.GetMaxRange(true))) - { - if (!GetTarget().HasAura(SpellIds.DemonicCircleAllowCast)) - GetTarget().CastSpell(GetTarget(), SpellIds.DemonicCircleAllowCast, true); - } - else - GetTarget().RemoveAura(SpellIds.DemonicCircleAllowCast); + if (!GetTarget().HasAura(SpellIds.DemonicCircleAllowCast)) + GetTarget().CastSpell(GetTarget(), SpellIds.DemonicCircleAllowCast, true); } - } - - public override void Register() - { - OnEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.RealOrReapplyMask)); - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleDummyTick, 0, AuraType.PeriodicDummy)); + else + GetTarget().RemoveAura(SpellIds.DemonicCircleAllowCast); } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_warl_demonic_circle_summon_AuraScript(); + OnEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.RealOrReapplyMask)); + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleDummyTick, 0, AuraType.PeriodicDummy)); } } [Script] // 48020 - Demonic Circle: Teleport - class spell_warl_demonic_circle_teleport : SpellScriptLoader + class spell_warl_demonic_circle_teleport : AuraScript { - public spell_warl_demonic_circle_teleport() : base("spell_warl_demonic_circle_teleport") { } - - class spell_warl_demonic_circle_teleport_AuraScript : AuraScript + void HandleTeleport(AuraEffect aurEff, AuraEffectHandleModes mode) { - void HandleTeleport(AuraEffect aurEff, AuraEffectHandleModes mode) + Player player = GetTarget().ToPlayer(); + if (player) { - Player player = GetTarget().ToPlayer(); - if (player) + GameObject circle = player.GetGameObject(SpellIds.DemonicCircleSummon); + if (circle) { - GameObject circle = player.GetGameObject(SpellIds.DemonicCircleSummon); - if (circle) - { - player.NearTeleportTo(circle.GetPositionX(), circle.GetPositionY(), circle.GetPositionZ(), circle.GetOrientation()); - player.RemoveMovementImpairingAuras(); - } + player.NearTeleportTo(circle.GetPositionX(), circle.GetPositionY(), circle.GetPositionZ(), circle.GetOrientation()); + player.RemoveMovementImpairingAuras(); } } - - public override void Register() - { - OnEffectApply.Add(new EffectApplyHandler(HandleTeleport, 0, AuraType.MechanicImmunity, AuraEffectHandleModes.Real)); - } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_warl_demonic_circle_teleport_AuraScript(); + OnEffectApply.Add(new EffectApplyHandler(HandleTeleport, 0, AuraType.MechanicImmunity, AuraEffectHandleModes.Real)); } } [Script] // 77801 - Demon Soul - Updated to 4.3.4 - class spell_warl_demon_soul : SpellScriptLoader + class spell_warl_demon_soul : SpellScript { - public spell_warl_demon_soul() : base("spell_warl_demon_soul") { } - - class spell_warl_demon_soul_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.DemonSoulImp, SpellIds.DemonSoulFelhunter, SpellIds.DemonSoulFelguard, SpellIds.DemonSoulSuccubus, SpellIds.DemonSoulVoidwalker); - } + return ValidateSpellInfo(SpellIds.DemonSoulImp, SpellIds.DemonSoulFelhunter, SpellIds.DemonSoulFelguard, SpellIds.DemonSoulSuccubus, SpellIds.DemonSoulVoidwalker); + } - void OnHitTarget(uint effIndex) + void OnHitTarget(uint effIndex) + { + Unit caster = GetCaster(); + Creature targetCreature = GetHitCreature(); + if (targetCreature) { - Unit caster = GetCaster(); - Creature targetCreature = GetHitCreature(); - if (targetCreature) + if (targetCreature.IsPet()) { - if (targetCreature.IsPet()) + CreatureTemplate ci = targetCreature.GetCreatureTemplate(); + switch (ci.Family) { - CreatureTemplate ci = targetCreature.GetCreatureTemplate(); - switch (ci.Family) - { - case CreatureFamily.Succubus: - caster.CastSpell(caster, SpellIds.DemonSoulSuccubus); - break; - case CreatureFamily.Voidwalker: - caster.CastSpell(caster, SpellIds.DemonSoulVoidwalker); - break; - case CreatureFamily.Felguard: - caster.CastSpell(caster, SpellIds.DemonSoulFelguard); - break; - case CreatureFamily.Felhunter: - caster.CastSpell(caster, SpellIds.DemonSoulFelhunter); - break; - case CreatureFamily.Imp: - caster.CastSpell(caster, SpellIds.DemonSoulImp); - break; - default: - break; - } + case CreatureFamily.Succubus: + caster.CastSpell(caster, SpellIds.DemonSoulSuccubus); + break; + case CreatureFamily.Voidwalker: + caster.CastSpell(caster, SpellIds.DemonSoulVoidwalker); + break; + case CreatureFamily.Felguard: + caster.CastSpell(caster, SpellIds.DemonSoulFelguard); + break; + case CreatureFamily.Felhunter: + caster.CastSpell(caster, SpellIds.DemonSoulFelhunter); + break; + case CreatureFamily.Imp: + caster.CastSpell(caster, SpellIds.DemonSoulImp); + break; + default: + break; } } } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(OnHitTarget, 0, SpellEffectName.ScriptEffect)); - } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_warl_demon_soul_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(OnHitTarget, 0, SpellEffectName.ScriptEffect)); } } [Script] // 47193 - Demonic Empowerment - class spell_warl_demonic_empowerment : SpellScriptLoader + class spell_warl_demonic_empowerment : SpellScript { - public spell_warl_demonic_empowerment() : base("spell_warl_demonic_empowerment") { } - - class spell_warl_demonic_empowerment_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.DemonicEmpowermentSuccubus, SpellIds.DemonicEmpowermentVoidwalker, SpellIds.DemonicEmpowermentFelguard, SpellIds.DemonicEmpowermentFelhunter, SpellIds.DemonicEmpowermentImp); - } + return ValidateSpellInfo(SpellIds.DemonicEmpowermentSuccubus, SpellIds.DemonicEmpowermentVoidwalker, SpellIds.DemonicEmpowermentFelguard, SpellIds.DemonicEmpowermentFelhunter, SpellIds.DemonicEmpowermentImp); + } - void HandleScriptEffect(uint effIndex) + void HandleScriptEffect(uint effIndex) + { + Creature targetCreature = GetHitCreature(); + if (targetCreature) { - Creature targetCreature = GetHitCreature(); - if (targetCreature) + if (targetCreature.IsPet()) { - if (targetCreature.IsPet()) + CreatureTemplate ci = targetCreature.GetCreatureTemplate(); + switch (ci.Family) { - CreatureTemplate ci = targetCreature.GetCreatureTemplate(); - switch (ci.Family) - { - case CreatureFamily.Succubus: - targetCreature.CastSpell(targetCreature, SpellIds.DemonicEmpowermentSuccubus, true); + case CreatureFamily.Succubus: + targetCreature.CastSpell(targetCreature, SpellIds.DemonicEmpowermentSuccubus, true); + break; + case CreatureFamily.Voidwalker: + { + SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.DemonicEmpowermentVoidwalker); + int hp = (int)targetCreature.CountPctFromMaxHealth(GetCaster().CalculateSpellDamage(targetCreature, spellInfo, 0)); + targetCreature.CastCustomSpell(targetCreature, SpellIds.DemonicEmpowermentVoidwalker, hp, 0, 0, true); break; - case CreatureFamily.Voidwalker: - { - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.DemonicEmpowermentVoidwalker); - int hp = (int)targetCreature.CountPctFromMaxHealth(GetCaster().CalculateSpellDamage(targetCreature, spellInfo, 0)); - targetCreature.CastCustomSpell(targetCreature, SpellIds.DemonicEmpowermentVoidwalker, hp, 0, 0, true); - break; - } - case CreatureFamily.Felguard: - targetCreature.CastSpell(targetCreature, SpellIds.DemonicEmpowermentFelguard, true); - break; - case CreatureFamily.Felhunter: - targetCreature.CastSpell(targetCreature, SpellIds.DemonicEmpowermentFelhunter, true); - break; - case CreatureFamily.Imp: - targetCreature.CastSpell(targetCreature, SpellIds.DemonicEmpowermentImp, true); - break; - default: - break; - } + } + case CreatureFamily.Felguard: + targetCreature.CastSpell(targetCreature, SpellIds.DemonicEmpowermentFelguard, true); + break; + case CreatureFamily.Felhunter: + targetCreature.CastSpell(targetCreature, SpellIds.DemonicEmpowermentFelhunter, true); + break; + case CreatureFamily.Imp: + targetCreature.CastSpell(targetCreature, SpellIds.DemonicEmpowermentImp, true); + break; + default: + break; } } } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); - } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_warl_demonic_empowerment_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); } } [Script] // 67518, 19505 - Devour Magic - class spell_warl_devour_magic : SpellScriptLoader + class spell_warl_devour_magic : SpellScript { - public spell_warl_devour_magic() : base("spell_warl_devour_magic") { } - - class spell_warl_devour_magic_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) + return ValidateSpellInfo(SpellIds.GlyphOfDemonTraining, SpellIds.DevourMagicHeal); + } + + void OnSuccessfulDispel(uint effIndex) + { + SpellEffectInfo effect = GetSpellInfo().GetEffect(1); + if (effect != null) { - return ValidateSpellInfo(SpellIds.GlyphOfDemonTraining, SpellIds.DevourMagicHeal); - } + Unit caster = GetCaster(); + int heal_amount = effect.CalcValue(caster); - void OnSuccessfulDispel(uint effIndex) - { - SpellEffectInfo effect = GetSpellInfo().GetEffect(1); - if (effect != null) - { - Unit caster = GetCaster(); - int heal_amount = effect.CalcValue(caster); + caster.CastCustomSpell(caster, SpellIds.DevourMagicHeal, heal_amount, 0, 0, true); - caster.CastCustomSpell(caster, SpellIds.DevourMagicHeal, heal_amount, 0, 0, true); - - // Glyph of Felhunter - Unit owner = caster.GetOwner(); - if (owner) - if (owner.GetAura(SpellIds.GlyphOfDemonTraining) != null) - owner.CastCustomSpell(owner, SpellIds.DevourMagicHeal, heal_amount, 0, 0, true); - } - } - - public override void Register() - { - OnEffectSuccessfulDispel.Add(new EffectHandler(OnSuccessfulDispel, 0, SpellEffectName.Dispel)); + // Glyph of Felhunter + Unit owner = caster.GetOwner(); + if (owner) + if (owner.GetAura(SpellIds.GlyphOfDemonTraining) != null) + owner.CastCustomSpell(owner, SpellIds.DevourMagicHeal, heal_amount, 0, 0, true); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_warl_devour_magic_SpellScript(); + OnEffectSuccessfulDispel.Add(new EffectHandler(OnSuccessfulDispel, 0, SpellEffectName.Dispel)); } } [Script] // 47422 - Everlasting Affliction - class spell_warl_everlasting_affliction : SpellScriptLoader + class spell_warl_everlasting_affliction : SpellScript { - public spell_warl_everlasting_affliction() : base("spell_warl_everlasting_affliction") { } - - class spell_warl_everlasting_affliction_SpellScript : SpellScript + void HandleScriptEffect(uint effIndex) { - void HandleScriptEffect(uint effIndex) + Unit caster = GetCaster(); + Unit target = GetHitUnit(); + if (target) { - Unit caster = GetCaster(); - Unit target = GetHitUnit(); - if (target) + // Refresh corruption on target + AuraEffect aurEff = target.GetAuraEffect(AuraType.PeriodicDamage, SpellFamilyNames.Warlock, new FlagArray128(0x2, 0, 0), caster.GetGUID()); + if (aurEff != null) { - // Refresh corruption on target - AuraEffect aurEff = target.GetAuraEffect(AuraType.PeriodicDamage, SpellFamilyNames.Warlock, new FlagArray128(0x2, 0, 0), caster.GetGUID()); - if (aurEff != null) - { - uint damage = (uint)Math.Max(aurEff.GetAmount(), 0); - Global.ScriptMgr.ModifyPeriodicDamageAurasTick(target, caster, ref damage); - aurEff.SetDamage((int)(caster.SpellDamageBonusDone(target, aurEff.GetSpellInfo(), damage, DamageEffectType.DOT, GetEffectInfo(effIndex)) * aurEff.GetDonePct())); - aurEff.CalculatePeriodic(caster, false, false); - aurEff.GetBase().RefreshDuration(true); - } + uint damage = (uint)Math.Max(aurEff.GetAmount(), 0); + Global.ScriptMgr.ModifyPeriodicDamageAurasTick(target, caster, ref damage); + aurEff.SetDamage((int)(caster.SpellDamageBonusDone(target, aurEff.GetSpellInfo(), damage, DamageEffectType.DOT, GetEffectInfo(effIndex)) * aurEff.GetDonePct())); + aurEff.CalculatePeriodic(caster, false, false); + aurEff.GetBase().RefreshDuration(true); } } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); - } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_warl_everlasting_affliction_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ScriptEffect)); } } [Script] // -47230 - Fel Synergy - class spell_warl_fel_synergy : SpellScriptLoader + class spell_warl_fel_synergy : AuraScript { - public spell_warl_fel_synergy() : base("spell_warl_fel_synergy") { } - - class spell_warl_fel_synergy_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.FelSynergyHeal); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - return GetTarget().GetGuardianPet() && eventInfo.GetDamageInfo().GetDamage() != 0; - } - - void onProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - int heal = (int)MathFunctions.CalculatePct(eventInfo.GetDamageInfo().GetDamage(), aurEff.GetAmount()); - GetTarget().CastCustomSpell(SpellIds.FelSynergyHeal, SpellValueMod.BasePoint0, heal, (Unit)null, true, null, aurEff); // TARGET_UNIT_PET - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(onProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.FelSynergyHeal); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_warl_fel_synergy_AuraScript(); + return GetTarget().GetGuardianPet() && eventInfo.GetDamageInfo().GetDamage() != 0; + } + + void onProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + + int heal = (int)MathFunctions.CalculatePct(eventInfo.GetDamageInfo().GetDamage(), aurEff.GetAmount()); + GetTarget().CastCustomSpell(SpellIds.FelSynergyHeal, SpellValueMod.BasePoint0, heal, (Unit)null, true, null, aurEff); // TARGET_UNIT_PET + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(onProc, 0, AuraType.Dummy)); } } [Script] // 63310 - Glyph of Shadowflame - class spell_warl_glyph_of_shadowflame : SpellScriptLoader + class spell_warl_glyph_of_shadowflame : AuraScript { - public spell_warl_glyph_of_shadowflame() : base("spell_warl_glyph_of_shadowflame") { } - - class spell_warl_glyph_of_shadowflame_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.GlyphOfShadowflame); - } - - void onProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.GlyphOfShadowflame, true, null, aurEff); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(onProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.GlyphOfShadowflame); } - public override AuraScript GetAuraScript() + void onProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_warl_glyph_of_shadowflame_AuraScript(); + PreventDefaultAction(); + GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.GlyphOfShadowflame, true, null, aurEff); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(onProc, 0, AuraType.Dummy)); } } [Script] // 48181 - Haunt - class spell_warl_haunt : SpellScriptLoader + class spell_warl_haunt : SpellScript { - public spell_warl_haunt() : base("spell_warl_haunt") { } - - class spell_warl_haunt_SpellScript : SpellScript + void HandleAfterHit() { - void HandleAfterHit() + Aura aura = GetHitAura(); + if (aura != null) { - Aura aura = GetHitAura(); - if (aura != null) - { - AuraEffect aurEff = aura.GetEffect(1); - if (aurEff != null) - aurEff.SetAmount(MathFunctions.CalculatePct(aurEff.GetAmount(), GetHitDamage())); - } - } - - public override void Register() - { - AfterHit.Add(new HitHandler(HandleAfterHit)); + AuraEffect aurEff = aura.GetEffect(1); + if (aurEff != null) + aurEff.SetAmount(MathFunctions.CalculatePct(aurEff.GetAmount(), GetHitDamage())); } } - class spell_warl_haunt_AuraScript : AuraScript + public override void Register() { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.HauntHeal); - } + AfterHit.Add(new HitHandler(HandleAfterHit)); + } + } - void HandleRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Unit caster = GetCaster(); - if (caster) - { - int amount = aurEff.GetAmount(); - GetTarget().CastCustomSpell(caster, SpellIds.HauntHeal, amount, 0, 0, true, null, aurEff, GetCasterGUID()); - } - } + [Script] + class spell_warl_haunt_AuraScript : AuraScript + { + public override bool Validate(SpellInfo spellInfo) + { + return ValidateSpellInfo(SpellIds.HauntHeal); + } - public override void Register() + void HandleRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit caster = GetCaster(); + if (caster) { - OnEffectRemove.Add(new EffectApplyHandler(HandleRemove, 1, AuraType.Dummy, AuraEffectHandleModes.RealOrReapplyMask)); + int amount = aurEff.GetAmount(); + GetTarget().CastCustomSpell(caster, SpellIds.HauntHeal, amount, 0, 0, true, null, aurEff, GetCasterGUID()); } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_warl_haunt_SpellScript(); - } - - public override AuraScript GetAuraScript() - { - return new spell_warl_haunt_AuraScript(); + OnEffectRemove.Add(new EffectApplyHandler(HandleRemove, 1, AuraType.Dummy, AuraEffectHandleModes.RealOrReapplyMask)); } } [Script] // 755 - Health Funnel - class spell_warl_health_funnel : SpellScriptLoader + class spell_warl_health_funnel : AuraScript { - public spell_warl_health_funnel() : base("spell_warl_health_funnel") { } - - class spell_warl_health_funnel_AuraScript : AuraScript + void ApplyEffect(AuraEffect aurEff, AuraEffectHandleModes mode) { - void ApplyEffect(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Unit caster = GetCaster(); - if (!caster) - return; + Unit caster = GetCaster(); + if (!caster) + return; - Unit target = GetTarget(); - if (caster.HasAura(SpellIds.ImprovedHealthFunnelR2)) - target.CastSpell(target, SpellIds.ImprovedHealthFunnelBuffR2, true); - else if (caster.HasAura(SpellIds.ImprovedHealthFunnelR1)) - target.CastSpell(target, SpellIds.ImprovedHealthFunnelBuffR1, true); - } - - void RemoveEffect(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Unit target = GetTarget(); - target.RemoveAurasDueToSpell(SpellIds.ImprovedHealthFunnelBuffR1); - target.RemoveAurasDueToSpell(SpellIds.ImprovedHealthFunnelBuffR2); - } - - void OnPeriodic(AuraEffect aurEff) - { - Unit caster = GetCaster(); - if (!caster) - return; - //! HACK for self damage, is not blizz :/ - uint damage = (uint)caster.CountPctFromMaxHealth(aurEff.GetBaseAmount()); - - Player modOwner = caster.GetSpellModOwner(); - if (modOwner) - modOwner.ApplySpellMod(GetId(), SpellModOp.Cost, ref damage); - - SpellNonMeleeDamage damageInfo = new SpellNonMeleeDamage(caster, caster, GetSpellInfo().Id, GetAura().GetSpellXSpellVisualId(), GetSpellInfo().SchoolMask, GetAura().GetCastGUID()); - damageInfo.periodicLog = true; - damageInfo.damage = damage; - caster.DealSpellDamage(damageInfo, false); - caster.SendSpellNonMeleeDamageLog(damageInfo); - } - - public override void Register() - { - OnEffectApply.Add(new EffectApplyHandler(ApplyEffect, 0, AuraType.ObsModHealth, AuraEffectHandleModes.Real)); - OnEffectRemove.Add(new EffectApplyHandler(RemoveEffect, 0, AuraType.ObsModHealth, AuraEffectHandleModes.Real)); - OnEffectPeriodic.Add(new EffectPeriodicHandler(OnPeriodic, 0, AuraType.ObsModHealth)); - } + Unit target = GetTarget(); + if (caster.HasAura(SpellIds.ImprovedHealthFunnelR2)) + target.CastSpell(target, SpellIds.ImprovedHealthFunnelBuffR2, true); + else if (caster.HasAura(SpellIds.ImprovedHealthFunnelR1)) + target.CastSpell(target, SpellIds.ImprovedHealthFunnelBuffR1, true); } - public override AuraScript GetAuraScript() + void RemoveEffect(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_warl_health_funnel_AuraScript(); + Unit target = GetTarget(); + target.RemoveAurasDueToSpell(SpellIds.ImprovedHealthFunnelBuffR1); + target.RemoveAurasDueToSpell(SpellIds.ImprovedHealthFunnelBuffR2); + } + + void OnPeriodic(AuraEffect aurEff) + { + Unit caster = GetCaster(); + if (!caster) + return; + //! HACK for self damage, is not blizz :/ + uint damage = (uint)caster.CountPctFromMaxHealth(aurEff.GetBaseAmount()); + + Player modOwner = caster.GetSpellModOwner(); + if (modOwner) + modOwner.ApplySpellMod(GetId(), SpellModOp.Cost, ref damage); + + SpellNonMeleeDamage damageInfo = new SpellNonMeleeDamage(caster, caster, GetSpellInfo().Id, GetAura().GetSpellXSpellVisualId(), GetSpellInfo().SchoolMask, GetAura().GetCastGUID()); + damageInfo.periodicLog = true; + damageInfo.damage = damage; + caster.DealSpellDamage(damageInfo, false); + caster.SendSpellNonMeleeDamageLog(damageInfo); + } + + public override void Register() + { + OnEffectApply.Add(new EffectApplyHandler(ApplyEffect, 0, AuraType.ObsModHealth, AuraEffectHandleModes.Real)); + OnEffectRemove.Add(new EffectApplyHandler(RemoveEffect, 0, AuraType.ObsModHealth, AuraEffectHandleModes.Real)); + OnEffectPeriodic.Add(new EffectPeriodicHandler(OnPeriodic, 0, AuraType.ObsModHealth)); } } [Script] // 6262 - Healthstone - class spell_warl_healthstone_heal : SpellScriptLoader + class spell_warl_healthstone_heal : SpellScript { - public spell_warl_healthstone_heal() : base("spell_warl_healthstone_heal") { } - - class spell_warl_healthstone_heal_SpellScript : SpellScript + void HandleOnHit() { - void HandleOnHit() - { - int heal = (int)MathFunctions.CalculatePct(GetCaster().GetCreateHealth(), GetHitHeal()); - SetHitHeal(heal); - } - - public override void Register() - { - OnHit.Add(new HitHandler(HandleOnHit)); - } + int heal = (int)MathFunctions.CalculatePct(GetCaster().GetCreateHealth(), GetHitHeal()); + SetHitHeal(heal); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_warl_healthstone_heal_SpellScript(); + OnHit.Add(new HitHandler(HandleOnHit)); } } [Script] // -18119 - Improved Soul Fire - class spell_warl_improved_soul_fire : SpellScriptLoader + class spell_warl_improved_soul_fire : AuraScript { - public spell_warl_improved_soul_fire() : base("spell_warl_improved_soul_fire") { } - - class spell_warl_improved_soul_fire_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ImprovedSoulFirePct, SpellIds.ImprovedSoulFireState); - } - - void onProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - GetTarget().CastCustomSpell(SpellIds.ImprovedSoulFirePct, SpellValueMod.BasePoint0, aurEff.GetAmount(), GetTarget(), true, null, aurEff); - GetTarget().CastSpell(GetTarget(), SpellIds.ImprovedSoulFireState, true, null, aurEff); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(onProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.ImprovedSoulFirePct, SpellIds.ImprovedSoulFireState); } - public override AuraScript GetAuraScript() + void onProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_warl_improved_soul_fire_AuraScript(); + PreventDefaultAction(); + GetTarget().CastCustomSpell(SpellIds.ImprovedSoulFirePct, SpellValueMod.BasePoint0, aurEff.GetAmount(), GetTarget(), true, null, aurEff); + GetTarget().CastSpell(GetTarget(), SpellIds.ImprovedSoulFireState, true, null, aurEff); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(onProc, 0, AuraType.Dummy)); } } // 687 - Demon Armor [Script] // 28176 - Fel Armor - class spell_warl_nether_ward_overrride : SpellScriptLoader + class spell_warl_nether_ward_overrride : AuraScript { - public spell_warl_nether_ward_overrride() : base("spell_warl_nether_ward_overrride") { } - - class spell_warl_nether_ward_overrride_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.NetherTalent, SpellIds.NetherWard, SpellIds.ShadowWard); - } - - void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) - { - if (GetUnitOwner().HasAura(SpellIds.NetherTalent)) - amount = (int)SpellIds.NetherWard; - else - amount = (int)SpellIds.ShadowWard; - } - - public override void Register() - { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 2, AuraType.OverrideActionbarSpells)); - } + return ValidateSpellInfo(SpellIds.NetherTalent, SpellIds.NetherWard, SpellIds.ShadowWard); } - public override AuraScript GetAuraScript() + void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) { - return new spell_warl_nether_ward_overrride_AuraScript(); + if (GetUnitOwner().HasAura(SpellIds.NetherTalent)) + amount = (int)SpellIds.NetherWard; + else + amount = (int)SpellIds.ShadowWard; + } + + public override void Register() + { + DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 2, AuraType.OverrideActionbarSpells)); } } [Script] // 6358 - Seduction (Special Ability) - class spell_warl_seduction : SpellScriptLoader + class spell_warl_seduction : SpellScript { - public spell_warl_seduction() : base("spell_warl_seduction") { } - - class spell_warl_seduction_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.GlyphOfSuccubus, SpellIds.PriestShadowWordDeath); - } + return ValidateSpellInfo(SpellIds.GlyphOfSuccubus, SpellIds.PriestShadowWordDeath); + } - void HandleScriptEffect(uint effIndex) + void HandleScriptEffect(uint effIndex) + { + Unit caster = GetCaster(); + Unit target = GetHitUnit(); + if (target) { - Unit caster = GetCaster(); - Unit target = GetHitUnit(); - if (target) + if (caster.GetOwner() && caster.GetOwner().HasAura(SpellIds.GlyphOfSuccubus)) { - if (caster.GetOwner() && caster.GetOwner().HasAura(SpellIds.GlyphOfSuccubus)) - { - target.RemoveAurasByType(AuraType.PeriodicDamage, ObjectGuid.Empty, target.GetAura(SpellIds.PriestShadowWordDeath)); // SW:D shall not be removed. - target.RemoveAurasByType(AuraType.PeriodicDamagePercent); - target.RemoveAurasByType(AuraType.PeriodicLeech); - } + target.RemoveAurasByType(AuraType.PeriodicDamage, ObjectGuid.Empty, target.GetAura(SpellIds.PriestShadowWordDeath)); // SW:D shall not be removed. + target.RemoveAurasByType(AuraType.PeriodicDamagePercent); + target.RemoveAurasByType(AuraType.PeriodicLeech); } } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ApplyAura)); - } } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_warl_seduction_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScriptEffect, 0, SpellEffectName.ApplyAura)); } } [Script] // 27285 - Seed of Corruption - class spell_warl_seed_of_corruption : SpellScriptLoader + class spell_warl_seed_of_corruption : SpellScript { - public spell_warl_seed_of_corruption() : base("spell_warl_seed_of_corruption") { } - - class spell_warl_seed_of_corruption_SpellScript : SpellScript + void FilterTargets(List targets) { - void FilterTargets(List targets) - { - if (GetExplTargetUnit()) - targets.Remove(GetExplTargetUnit()); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaEnemy)); - } + if (GetExplTargetUnit()) + targets.Remove(GetExplTargetUnit()); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_warl_seed_of_corruption_SpellScript(); + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaEnemy)); } } [Script] // 27243 - Seed of Corruption - class spell_warl_seed_of_corruption_dummy : SpellScriptLoader + class spell_warl_seed_of_corruption_dummy : AuraScript { - public spell_warl_seed_of_corruption_dummy() : base("spell_warl_seed_of_corruption_dummy") { } - - class spell_warl_seed_of_corruption_dummy_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.SeedOfCorruptionDamage); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - DamageInfo damageInfo = eventInfo.GetDamageInfo(); - if (damageInfo == null) - return; - - int amount = (int)(aurEff.GetAmount() - damageInfo.GetDamage()); - if (amount > 0) - { - aurEff.SetAmount(amount); - if (!GetTarget().HealthBelowPctDamaged(1, damageInfo.GetDamage())) - return; - } - - Remove(); - - Unit caster = GetCaster(); - if (!caster) - return; - - caster.CastSpell(eventInfo.GetActionTarget(), SpellIds.SeedOfCorruptionDamage, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.SeedOfCorruptionDamage); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_warl_seed_of_corruption_dummy_AuraScript(); + PreventDefaultAction(); + DamageInfo damageInfo = eventInfo.GetDamageInfo(); + if (damageInfo == null) + return; + + int amount = (int)(aurEff.GetAmount() - damageInfo.GetDamage()); + if (amount > 0) + { + aurEff.SetAmount(amount); + if (!GetTarget().HealthBelowPctDamaged(1, damageInfo.GetDamage())) + return; + } + + Remove(); + + Unit caster = GetCaster(); + if (!caster) + return; + + caster.CastSpell(eventInfo.GetActionTarget(), SpellIds.SeedOfCorruptionDamage, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.Dummy)); } } @@ -898,450 +689,335 @@ namespace Scripts.Spells.Warlock // 44141 - Seed of Corruption // 70388 - Seed of Corruption [Script] // Monster spells, triggered only on amount drop (not on death) - class spell_warl_seed_of_corruption_generic : SpellScriptLoader + class spell_warl_seed_of_corruption_generic : AuraScript { - public spell_warl_seed_of_corruption_generic() : base("spell_warl_seed_of_corruption_generic") { } - - class spell_warl_seed_of_corruption_generic_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.SeedOfCorruptionGeneric); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - DamageInfo damageInfo = eventInfo.GetDamageInfo(); - if (damageInfo == null) - return; - - int amount = aurEff.GetAmount() - (int)damageInfo.GetDamage(); - if (amount > 0) - { - aurEff.SetAmount(amount); - return; - } - - Remove(); - - Unit caster = GetCaster(); - if (!caster) - return; - - caster.CastSpell(eventInfo.GetActionTarget(), SpellIds.SeedOfCorruptionGeneric, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.SeedOfCorruptionGeneric); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_warl_seed_of_corruption_generic_AuraScript(); + PreventDefaultAction(); + DamageInfo damageInfo = eventInfo.GetDamageInfo(); + if (damageInfo == null) + return; + + int amount = aurEff.GetAmount() - (int)damageInfo.GetDamage(); + if (amount > 0) + { + aurEff.SetAmount(amount); + return; + } + + Remove(); + + Unit caster = GetCaster(); + if (!caster) + return; + + caster.CastSpell(eventInfo.GetActionTarget(), SpellIds.SeedOfCorruptionGeneric, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 1, AuraType.Dummy)); } } [Script] // -7235 - Shadow Ward - class spell_warl_shadow_ward : SpellScriptLoader + class spell_warl_shadow_ward : AuraScript { - public spell_warl_shadow_ward() : base("spell_warl_shadow_ward") { } - - class spell_warl_shadow_ward_AuraScript : AuraScript + void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) { - void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + canBeRecalculated = false; + Unit caster = GetCaster(); + if (caster) { - canBeRecalculated = false; - Unit caster = GetCaster(); - if (caster) - { - // +80.68% from sp bonus - float bonus = 0.8068f; + // +80.68% from sp bonus + float bonus = 0.8068f; - bonus *= caster.SpellBaseHealingBonusDone(GetSpellInfo().GetSchoolMask()); - bonus *= caster.CalculateLevelPenalty(GetSpellInfo()); + bonus *= caster.SpellBaseHealingBonusDone(GetSpellInfo().GetSchoolMask()); + bonus *= caster.CalculateLevelPenalty(GetSpellInfo()); - amount += (int)bonus; - } - } - - public override void Register() - { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.SchoolAbsorb)); + amount += (int)bonus; } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_warl_shadow_ward_AuraScript(); + DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.SchoolAbsorb)); } } [Script] // -30293 - Soul Leech - class spell_warl_soul_leech : SpellScriptLoader + class spell_warl_soul_leech : AuraScript { - public spell_warl_soul_leech() : base("spell_warl_soul_leech") { } - - class spell_warl_soul_leech_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.GenReplenishment); - } - - void onProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - GetTarget().CastSpell((Unit)null, SpellIds.GenReplenishment, true, null, aurEff); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(onProc, 0, AuraType.ProcTriggerSpellWithValue)); - } + return ValidateSpellInfo(SpellIds.GenReplenishment); } - public override AuraScript GetAuraScript() + void onProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_warl_soul_leech_AuraScript(); + GetTarget().CastSpell((Unit)null, SpellIds.GenReplenishment, true, null, aurEff); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(onProc, 0, AuraType.ProcTriggerSpellWithValue)); } } [Script] // 86121 - Soul Swap - class spell_warl_soul_swap : SpellScriptLoader + class spell_warl_soul_swap : SpellScript { - public spell_warl_soul_swap() : base("spell_warl_soul_swap") { } - - class spell_warl_soul_swap_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.GlyphOfSoulSwap, SpellIds.SoulSwapCdMarker, SpellIds.SoulSwapOverride); - } - - void HandleHit(uint effIndex) - { - GetCaster().CastSpell(GetCaster(), SpellIds.SoulSwapOverride, true); - GetHitUnit().CastSpell(GetCaster(), SpellIds.SoulSwapDotMarker, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleHit, 0, SpellEffectName.SchoolDamage)); - } + return ValidateSpellInfo(SpellIds.GlyphOfSoulSwap, SpellIds.SoulSwapCdMarker, SpellIds.SoulSwapOverride); } - public override SpellScript GetSpellScript() + void HandleHit(uint effIndex) { - return new spell_warl_soul_swap_SpellScript(); + GetCaster().CastSpell(GetCaster(), SpellIds.SoulSwapOverride, true); + GetHitUnit().CastSpell(GetCaster(), SpellIds.SoulSwapDotMarker, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleHit, 0, SpellEffectName.SchoolDamage)); } } [Script] // 86211 - Soul Swap - Also acts as a dot container - class spell_warl_soul_swap_override : SpellScriptLoader + public class spell_warl_soul_swap_override : AuraScript { - public spell_warl_soul_swap_override() : base(nameof(spell_warl_soul_swap_override)) { } + //! Forced to, pure virtual functions must have a body when linking + public override void Register() { } - public class spell_warl_soul_swap_override_AuraScript : AuraScript - { - //! Forced to, pure virtual functions must have a body when linking - public override void Register() { } - - public void AddDot(uint id) { _dotList.Add(id); } - public List GetDotList() { return _dotList; } - public Unit GetOriginalSwapSource() { return _swapCaster; } - public void SetOriginalSwapSource(Unit victim) { _swapCaster = victim; } + public void AddDot(uint id) { _dotList.Add(id); } + public List GetDotList() { return _dotList; } + public Unit GetOriginalSwapSource() { return _swapCaster; } + public void SetOriginalSwapSource(Unit victim) { _swapCaster = victim; } - List _dotList = new List(); - Unit _swapCaster = null; - } - - public override AuraScript GetAuraScript() - { - return new spell_warl_soul_swap_override_AuraScript(); - } + List _dotList = new List(); + Unit _swapCaster = null; } [Script] //! Soul Swap Copy Spells - 92795 - Simply copies spell IDs. - class spell_warl_soul_swap_dot_marker : SpellScriptLoader + class spell_warl_soul_swap_dot_marker : SpellScript { - public spell_warl_soul_swap_dot_marker() : base("spell_warl_soul_swap_dot_marker") { } - - class spell_warl_soul_swap_dot_marker_SpellScript : SpellScript + void HandleHit(uint effIndex) { - void HandleHit(uint effIndex) + Unit swapVictim = GetCaster(); + Unit warlock = GetHitUnit(); + if (!warlock || !swapVictim) + return; + + var appliedAuras = swapVictim.GetAppliedAuras(); + spell_warl_soul_swap_override swapSpellScript = null; + Aura swapOverrideAura = warlock.GetAura(SpellIds.SoulSwapOverride); + if (swapOverrideAura != null) + swapSpellScript = swapOverrideAura.GetScript("spell_warl_soul_swap_override"); + + if (swapSpellScript == null) + return; + + FlagArray128 classMask = GetEffectInfo().SpellClassMask; + + foreach (var itr in appliedAuras) { - Unit swapVictim = GetCaster(); - Unit warlock = GetHitUnit(); - if (!warlock || !swapVictim) - return; - - var appliedAuras = swapVictim.GetAppliedAuras(); - SoulSwapOverrideAuraScript swapSpellScript = null; - Aura swapOverrideAura = warlock.GetAura(SpellIds.SoulSwapOverride); - if (swapOverrideAura != null) - swapSpellScript = swapOverrideAura.GetScript(nameof(spell_warl_soul_swap_override)); - - if (swapSpellScript == null) - return; - - FlagArray128 classMask = GetEffectInfo().SpellClassMask; - - foreach (var itr in appliedAuras) - { - SpellInfo spellProto = itr.Value.GetBase().GetSpellInfo(); - if (itr.Value.GetBase().GetCaster() == warlock) - if (spellProto.SpellFamilyName == SpellFamilyNames.Warlock && (spellProto.SpellFamilyFlags & classMask)) - swapSpellScript.AddDot(itr.Key); - } - - swapSpellScript.SetOriginalSwapSource(swapVictim); + SpellInfo spellProto = itr.Value.GetBase().GetSpellInfo(); + if (itr.Value.GetBase().GetCaster() == warlock) + if (spellProto.SpellFamilyName == SpellFamilyNames.Warlock && (spellProto.SpellFamilyFlags & classMask)) + swapSpellScript.AddDot(itr.Key); } - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleHit, 0, SpellEffectName.Dummy)); - } + swapSpellScript.SetOriginalSwapSource(swapVictim); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_warl_soul_swap_dot_marker_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleHit, 0, SpellEffectName.Dummy)); } } [Script] // 86213 - Soul Swap Exhale - class spell_warl_soul_swap_exhale : SpellScriptLoader + class spell_warl_soul_swap_exhale : SpellScript { - public spell_warl_soul_swap_exhale() : base("spell_warl_soul_swap_exhale") { } - - class spell_warl_soul_swap_exhale_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.SoulSwapModCost, SpellIds.SoulSwapOverride); - } - - SpellCastResult CheckCast() - { - Unit currentTarget = GetExplTargetUnit(); - Unit swapTarget = null; - Aura swapOverride = GetCaster().GetAura(SpellIds.SoulSwapOverride); - if (swapOverride != null) - { - SoulSwapOverrideAuraScript swapScript = swapOverride.GetScript(nameof(spell_warl_soul_swap_override)); - if (swapScript != null) - swapTarget = swapScript.GetOriginalSwapSource(); - } - - // Soul Swap Exhale can't be cast on the same target than Soul Swap - if (swapTarget && currentTarget && swapTarget == currentTarget) - return SpellCastResult.BadTargets; - - return SpellCastResult.SpellCastOk; - } - - void onEffectHit(uint effIndex) - { - GetCaster().CastSpell(GetCaster(), SpellIds.SoulSwapModCost, true); - bool hasGlyph = GetCaster().HasAura(SpellIds.GlyphOfSoulSwap); - - List dotList = new List(); - Unit swapSource = null; - Aura swapOverride = GetCaster().GetAura(SpellIds.SoulSwapOverride); - if (swapOverride != null) - { - SoulSwapOverrideAuraScript swapScript = swapOverride.GetScript(nameof(spell_warl_soul_swap_override)); - if (swapScript == null) - return; - dotList = swapScript.GetDotList(); - swapSource = swapScript.GetOriginalSwapSource(); - } - - if (dotList.Empty()) - return; - - foreach (var itr in dotList) - { - GetCaster().AddAura(itr, GetHitUnit()); - if (!hasGlyph && swapSource) - swapSource.RemoveAurasDueToSpell(itr); - } - - // Remove Soul Swap Exhale buff - GetCaster().RemoveAurasDueToSpell(SpellIds.SoulSwapOverride); - - if (hasGlyph) // Add a cooldown on Soul Swap if caster has the glyph - GetCaster().CastSpell(GetCaster(), SpellIds.SoulSwapCdMarker, false); - } - - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckCast)); - OnEffectHitTarget.Add(new EffectHandler(onEffectHit, 0, SpellEffectName.SchoolDamage)); - } + return ValidateSpellInfo(SpellIds.SoulSwapModCost, SpellIds.SoulSwapOverride); } - public override SpellScript GetSpellScript() + SpellCastResult CheckCast() { - return new spell_warl_soul_swap_exhale_SpellScript(); + Unit currentTarget = GetExplTargetUnit(); + Unit swapTarget = null; + Aura swapOverride = GetCaster().GetAura(SpellIds.SoulSwapOverride); + if (swapOverride != null) + { + spell_warl_soul_swap_override swapScript = swapOverride.GetScript("spell_warl_soul_swap_override"); + if (swapScript != null) + swapTarget = swapScript.GetOriginalSwapSource(); + } + + // Soul Swap Exhale can't be cast on the same target than Soul Swap + if (swapTarget && currentTarget && swapTarget == currentTarget) + return SpellCastResult.BadTargets; + + return SpellCastResult.SpellCastOk; + } + + void onEffectHit(uint effIndex) + { + GetCaster().CastSpell(GetCaster(), SpellIds.SoulSwapModCost, true); + bool hasGlyph = GetCaster().HasAura(SpellIds.GlyphOfSoulSwap); + + List dotList = new List(); + Unit swapSource = null; + Aura swapOverride = GetCaster().GetAura(SpellIds.SoulSwapOverride); + if (swapOverride != null) + { + spell_warl_soul_swap_override swapScript = swapOverride.GetScript("spell_warl_soul_swap_override"); + if (swapScript == null) + return; + dotList = swapScript.GetDotList(); + swapSource = swapScript.GetOriginalSwapSource(); + } + + if (dotList.Empty()) + return; + + foreach (var itr in dotList) + { + GetCaster().AddAura(itr, GetHitUnit()); + if (!hasGlyph && swapSource) + swapSource.RemoveAurasDueToSpell(itr); + } + + // Remove Soul Swap Exhale buff + GetCaster().RemoveAurasDueToSpell(SpellIds.SoulSwapOverride); + + if (hasGlyph) // Add a cooldown on Soul Swap if caster has the glyph + GetCaster().CastSpell(GetCaster(), SpellIds.SoulSwapCdMarker, false); + } + + public override void Register() + { + OnCheckCast.Add(new CheckCastHandler(CheckCast)); + OnEffectHitTarget.Add(new EffectHandler(onEffectHit, 0, SpellEffectName.SchoolDamage)); } } [Script] // 29858 - Soulshatter - class spell_warl_soulshatter : SpellScriptLoader + class spell_warl_soulshatter : SpellScript { - public spell_warl_soulshatter() : base("spell_warl_soulshatter") { } - - class spell_warl_soulshatter_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.Soulshatter); - } - - void HandleDummy(uint effIndex) - { - Unit caster = GetCaster(); - Unit target = GetHitUnit(); - if (target) - if (target.CanHaveThreatList() && target.GetThreatManager().getThreat(caster) > 0.0f) - caster.CastSpell(target, SpellIds.Soulshatter, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellIds.Soulshatter); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_warl_soulshatter_SpellScript(); + Unit caster = GetCaster(); + Unit target = GetHitUnit(); + if (target) + if (target.CanHaveThreatList() && target.GetThreatManager().getThreat(caster) > 0.0f) + caster.CastSpell(target, SpellIds.Soulshatter, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script("spell_warl_t4_2p_bonus_shadow", SpellIds.Flameshadow)]// 37377 - Shadowflame [Script("spell_warl_t4_2p_bonus_fire", SpellIds.Shadowflame)]// 39437 - Shadowflame Hellfire and RoF - class spell_warl_t4_2p_bonus : SpellScriptLoader + class spell_warl_t4_2p_bonus : AuraScript { - public spell_warl_t4_2p_bonus(string scriptName, uint triggerSpell) : base(scriptName) + public spell_warl_t4_2p_bonus(uint triggerSpell) { _triggerSpell = triggerSpell; } - class spell_warl_t4_2p_bonus_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public spell_warl_t4_2p_bonus_AuraScript(uint triggerSpell) - { - _triggerSpell = triggerSpell; - } - - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(_triggerSpell); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - Unit caster = eventInfo.GetActor(); - caster.CastSpell(caster, _triggerSpell, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } - - uint _triggerSpell; + return ValidateSpellInfo(_triggerSpell); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_warl_t4_2p_bonus_AuraScript(_triggerSpell); + PreventDefaultAction(); + Unit caster = eventInfo.GetActor(); + caster.CastSpell(caster, _triggerSpell, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } uint _triggerSpell; } [Script] // 30108, 34438, 34439, 35183 - Unstable Affliction - class spell_warl_unstable_affliction : SpellScriptLoader + class spell_warl_unstable_affliction : AuraScript { - public spell_warl_unstable_affliction() : base("spell_warl_unstable_affliction") { } - - class spell_warl_unstable_affliction_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.UnstableAfflictionDispel); - } + return ValidateSpellInfo(SpellIds.UnstableAfflictionDispel); + } - void HandleDispel(DispelInfo dispelInfo) + void HandleDispel(DispelInfo dispelInfo) + { + Unit caster = GetCaster(); + if (caster) { - Unit caster = GetCaster(); - if (caster) + AuraEffect aurEff = GetEffect(1); + if (aurEff != null) { - AuraEffect aurEff = GetEffect(1); - if (aurEff != null) - { - int damage = aurEff.GetAmount() * 9; - // backfire damage and silence - caster.CastCustomSpell(dispelInfo.GetDispeller(), SpellIds.UnstableAfflictionDispel, damage, 0, 0, true, null, aurEff); - } + int damage = aurEff.GetAmount() * 9; + // backfire damage and silence + caster.CastCustomSpell(dispelInfo.GetDispeller(), SpellIds.UnstableAfflictionDispel, damage, 0, 0, true, null, aurEff); } } - - public override void Register() - { - AfterDispel.Add(new AuraDispelHandler(HandleDispel)); - } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_warl_unstable_affliction_AuraScript(); + AfterDispel.Add(new AuraDispelHandler(HandleDispel)); } } [Script] // 5740 - Rain of Fire Updated 7.1.5 - class spell_warl_rain_of_fire : SpellScriptLoader + class spell_warl_rain_of_fire : AuraScript { - public spell_warl_rain_of_fire() : base("spell_warl_rain_of_fire") { } - - class spell_warl_rain_of_fire_AuraScript : AuraScript + void HandleDummyTick(AuraEffect aurEff) { - void HandleDummyTick(AuraEffect aurEff) + List rainOfFireAreaTriggers = GetTarget().GetAreaTriggers(SpellIds.RainOfFire); + List targetsInRainOfFire = new List(); + + foreach (AreaTrigger rainOfFireAreaTrigger in rainOfFireAreaTriggers) { - List rainOfFireAreaTriggers = GetTarget().GetAreaTriggers(SpellIds.RainOfFire); - List targetsInRainOfFire = new List(); - - foreach (AreaTrigger rainOfFireAreaTrigger in rainOfFireAreaTriggers) - { - var insideTargets = rainOfFireAreaTrigger.GetInsideUnits(); - targetsInRainOfFire.AddRange(insideTargets); - } - - foreach (ObjectGuid insideTargetGuid in targetsInRainOfFire) - { - Unit insideTarget = Global.ObjAccessor.GetUnit(GetTarget(), insideTargetGuid); - if (insideTarget) - if (!GetTarget().IsFriendlyTo(insideTarget)) - GetTarget().CastSpell(insideTarget, SpellIds.RainOfFireDamage, true); - } + var insideTargets = rainOfFireAreaTrigger.GetInsideUnits(); + targetsInRainOfFire.AddRange(insideTargets); } - public override void Register() + foreach (ObjectGuid insideTargetGuid in targetsInRainOfFire) { - OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleDummyTick, 3, AuraType.PeriodicDummy)); + Unit insideTarget = Global.ObjAccessor.GetUnit(GetTarget(), insideTargetGuid); + if (insideTarget) + if (!GetTarget().IsFriendlyTo(insideTarget)) + GetTarget().CastSpell(insideTarget, SpellIds.RainOfFireDamage, true); } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_warl_rain_of_fire_AuraScript(); + OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleDummyTick, 3, AuraType.PeriodicDummy)); } } } diff --git a/Scripts/Spells/Warrior.cs b/Scripts/Spells/Warrior.cs index 48be1306d..d6e7c6f49 100644 --- a/Scripts/Spells/Warrior.cs +++ b/Scripts/Spells/Warrior.cs @@ -79,1194 +79,864 @@ namespace Scripts.Spells.Warrior } [Script] // 23881 - Bloodthirst - class spell_warr_bloodthirst : SpellScriptLoader + class spell_warr_bloodthirst : SpellScript { - public spell_warr_bloodthirst() : base("spell_warr_bloodthirst") { } - - class spell_warr_bloodthirst_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.BloodthirstHeal); - } - - void HandleDummy(uint effIndex) - { - GetCaster().CastSpell(GetCaster(), SpellIds.BloodthirstHeal, true); - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(HandleDummy, 3, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellIds.BloodthirstHeal); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_warr_bloodthirst_SpellScript(); + GetCaster().CastSpell(GetCaster(), SpellIds.BloodthirstHeal, true); + } + + public override void Register() + { + OnEffectHit.Add(new EffectHandler(HandleDummy, 3, SpellEffectName.Dummy)); } } [Script] // 100 - Charge - class spell_warr_charge : SpellScriptLoader + class spell_warr_charge : SpellScript { - public spell_warr_charge() : base("spell_warr_charge") { } - - class spell_warr_charge_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ChargeEffect, SpellIds.ChargeEffectBlazingTrail); - } - - void HandleDummy(uint effIndex) - { - uint spellId = SpellIds.ChargeEffect; - if (GetCaster().HasAura(SpellIds.GlyphOfTheBlazingTrail)) - spellId = SpellIds.ChargeEffectBlazingTrail; - - GetCaster().CastSpell(GetHitUnit(), spellId, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellIds.ChargeEffect, SpellIds.ChargeEffectBlazingTrail); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_warr_charge_SpellScript(); + uint spellId = SpellIds.ChargeEffect; + if (GetCaster().HasAura(SpellIds.GlyphOfTheBlazingTrail)) + spellId = SpellIds.ChargeEffectBlazingTrail; + + GetCaster().CastSpell(GetHitUnit(), spellId, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // 126661 - Warrior Charge Drop Fire Periodic - class spell_warr_charge_drop_fire_periodic : SpellScriptLoader + class spell_warr_charge_drop_fire_periodic : AuraScript { - public spell_warr_charge_drop_fire_periodic() : base("spell_warr_charge_drop_fire_periodic") { } - - class spell_warr_charge_drop_fire_periodic_AuraScript : AuraScript + void DropFireVisual(AuraEffect aurEff) { - void DropFireVisual(AuraEffect aurEff) + PreventDefaultAction(); + if (GetTarget().IsSplineEnabled()) { - PreventDefaultAction(); - if (GetTarget().IsSplineEnabled()) + for (uint i = 0; i < 5; ++i) { - for (uint i = 0; i < 5; ++i) - { - int timeOffset = (int)(6 * i * aurEff.GetPeriod() / 25); - Vector4 loc = GetTarget().moveSpline.ComputePosition(timeOffset); - GetTarget().SendPlaySpellVisual(new Vector3(loc.X, loc.Y, loc.Z), 0.0f, Misc.SpellVisualBlazingCharge, 0, 0, 1.0f, true); - } + int timeOffset = (int)(6 * i * aurEff.GetPeriod() / 25); + Vector4 loc = GetTarget().moveSpline.ComputePosition(timeOffset); + GetTarget().SendPlaySpellVisual(new Vector3(loc.X, loc.Y, loc.Z), 0.0f, Misc.SpellVisualBlazingCharge, 0, 0, 1.0f, true); } } - - public override void Register() - { - OnEffectPeriodic.Add(new EffectPeriodicHandler(DropFireVisual, 0, AuraType.PeriodicTriggerSpell)); - } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_warr_charge_drop_fire_periodic_AuraScript(); + OnEffectPeriodic.Add(new EffectPeriodicHandler(DropFireVisual, 0, AuraType.PeriodicTriggerSpell)); } } // 198337 - Charge Effect (dropping Blazing Trail) [Script] // 218104 - Charge Effect - class spell_warr_charge_effect : SpellScriptLoader + class spell_warr_charge_effect : SpellScript { - public spell_warr_charge_effect() : base("spell_warr_charge_effect") { } - - class spell_warr_charge_effect_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ChargePauseRageDecay, SpellIds.ChargeRootEffect, SpellIds.ChargeSlowEffect); - } - - void HandleCharge(uint effIndex) - { - Unit caster = GetCaster(); - Unit target = GetHitUnit(); - caster.CastCustomSpell(SpellIds.ChargePauseRageDecay, SpellValueMod.BasePoint0, 0, caster, true); - caster.CastSpell(target, SpellIds.ChargeRootEffect, true); - caster.CastSpell(target, SpellIds.ChargeSlowEffect, true); - } - - public override void Register() - { - OnEffectLaunchTarget.Add(new EffectHandler(HandleCharge, 0, SpellEffectName.Charge)); - } + return ValidateSpellInfo(SpellIds.ChargePauseRageDecay, SpellIds.ChargeRootEffect, SpellIds.ChargeSlowEffect); } - public override SpellScript GetSpellScript() + void HandleCharge(uint effIndex) { - return new spell_warr_charge_effect_SpellScript(); + Unit caster = GetCaster(); + Unit target = GetHitUnit(); + caster.CastCustomSpell(SpellIds.ChargePauseRageDecay, SpellValueMod.BasePoint0, 0, caster, true); + caster.CastSpell(target, SpellIds.ChargeRootEffect, true); + caster.CastSpell(target, SpellIds.ChargeSlowEffect, true); + } + + public override void Register() + { + OnEffectLaunchTarget.Add(new EffectHandler(HandleCharge, 0, SpellEffectName.Charge)); } } // Updated 4.3.4 [Script] - class spell_warr_concussion_blow : SpellScriptLoader + class spell_warr_concussion_blow : SpellScript { - public spell_warr_concussion_blow() : base("spell_warr_concussion_blow") { } - - class spell_warr_concussion_blow_SpellScript : SpellScript + void HandleDummy(uint effIndex) { - void HandleDummy(uint effIndex) - { - SetHitDamage((int)MathFunctions.CalculatePct(GetCaster().GetTotalAttackPowerValue(WeaponAttackType.BaseAttack), GetEffectValue())); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 2, SpellEffectName.Dummy)); - } + SetHitDamage((int)MathFunctions.CalculatePct(GetCaster().GetTotalAttackPowerValue(WeaponAttackType.BaseAttack), GetEffectValue())); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_warr_concussion_blow_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 2, SpellEffectName.Dummy)); } } // Updated 4.3.4 [Script] // 5308 - Execute - class spell_warr_execute : SpellScriptLoader + class spell_warr_execute : SpellScript { - public spell_warr_execute() : base("spell_warr_execute") { } - - class spell_warr_execute_SpellScript : SpellScript + void HandleEffect(uint effIndex) { - void HandleEffect(uint effIndex) + /* + Unit caster = GetCaster(); + if (GetHitUnit()) { - /* - Unit caster = GetCaster(); - if (GetHitUnit()) + SpellInfo spellInfo = GetSpellInfo(); + int rageUsed = Math.Min(200 - spellInfo.CalcPowerCost(caster, spellInfo.SchoolMask), caster.GetPower(PowerType.Rage)); + int newRage = Math.Max(0, caster.GetPower(PowerType.Rage) - rageUsed); + + // Sudden Death rage save + AuraEffect aurEff = caster.GetAuraEffect(AuraType.ProcTriggerSpell, SpellFamilyNames.Generic, 1989, 0); // Icon SuddenDeath + if (aurEff != null) { - SpellInfo spellInfo = GetSpellInfo(); - int rageUsed = Math.Min(200 - spellInfo.CalcPowerCost(caster, spellInfo.SchoolMask), caster.GetPower(PowerType.Rage)); - int newRage = Math.Max(0, caster.GetPower(PowerType.Rage) - rageUsed); - - // Sudden Death rage save - AuraEffect aurEff = caster.GetAuraEffect(AuraType.ProcTriggerSpell, SpellFamilyNames.Generic, 1989, 0); // Icon SuddenDeath - if (aurEff != null) - { - int ragesave = aurEff.GetSpellInfo().GetEffect(0).CalcValue() * 10; - newRage = Math.Max(newRage, ragesave); - } - - caster.SetPower(PowerType.Rage, newRage); - - // Formula taken from the DBC: "${10+$AP*0.437*$m1/100}" - int baseDamage = (int)(10 + caster.GetTotalAttackPowerValue(WeaponAttackType.BaseAttack) * 0.437f * GetEffectValue() / 100.0f); - // Formula taken from the DBC: "${$ap*0.874*$m1/100-1} = 20 rage" - int moreDamage = (int)(rageUsed * (caster.GetTotalAttackPowerValue(WeaponAttackType.BaseAttack) * 0.874f * GetEffectValue() / 100.0f - 1) / 200); - SetHitDamage(baseDamage + moreDamage); + int ragesave = aurEff.GetSpellInfo().GetEffect(0).CalcValue() * 10; + newRage = Math.Max(newRage, ragesave); } - */ - } - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleEffect, 0, SpellEffectName.SchoolDamage)); + caster.SetPower(PowerType.Rage, newRage); + + // Formula taken from the DBC: "${10+$AP*0.437*$m1/100}" + int baseDamage = (int)(10 + caster.GetTotalAttackPowerValue(WeaponAttackType.BaseAttack) * 0.437f * GetEffectValue() / 100.0f); + // Formula taken from the DBC: "${$ap*0.874*$m1/100-1} = 20 rage" + int moreDamage = (int)(rageUsed * (caster.GetTotalAttackPowerValue(WeaponAttackType.BaseAttack) * 0.874f * GetEffectValue() / 100.0f - 1) / 200); + SetHitDamage(baseDamage + moreDamage); } + */ } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_warr_execute_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleEffect, 0, SpellEffectName.SchoolDamage)); } } // 58387 - Glyph of Sunder Armor [Script] - class spell_warr_glyph_of_sunder_armor : SpellScriptLoader + class spell_warr_glyph_of_sunder_armor : AuraScript { - public spell_warr_glyph_of_sunder_armor() : base("spell_warr_glyph_of_sunder_armor") { } - - class spell_warr_glyph_of_sunder_armor_AuraScript : AuraScript + void HandleEffectCalcSpellMod(AuraEffect aurEff, ref SpellModifier spellMod) { - void HandleEffectCalcSpellMod(AuraEffect aurEff, ref SpellModifier spellMod) + if (spellMod == null) { - if (spellMod == null) - { - spellMod = new SpellModifier(aurEff.GetBase()); - spellMod.op = (SpellModOp)aurEff.GetMiscValue(); - spellMod.type = SpellModType.Flat; - spellMod.spellId = GetId(); - spellMod.mask = GetSpellInfo().GetEffect(aurEff.GetEffIndex()).SpellClassMask; - } - - spellMod.value = aurEff.GetAmount(); + spellMod = new SpellModifier(aurEff.GetBase()); + spellMod.op = (SpellModOp)aurEff.GetMiscValue(); + spellMod.type = SpellModType.Flat; + spellMod.spellId = GetId(); + spellMod.mask = GetSpellInfo().GetEffect(aurEff.GetEffIndex()).SpellClassMask; } - public override void Register() - { - DoEffectCalcSpellMod.Add(new EffectCalcSpellModHandler(HandleEffectCalcSpellMod, 0, AuraType.Dummy)); - } + spellMod.value = aurEff.GetAmount(); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_warr_glyph_of_sunder_armor_AuraScript(); + DoEffectCalcSpellMod.Add(new EffectCalcSpellModHandler(HandleEffectCalcSpellMod, 0, AuraType.Dummy)); } } [Script] // Heroic leap - 6544 - class spell_warr_heroic_leap : SpellScriptLoader + class spell_warr_heroic_leap : SpellScript { - public spell_warr_heroic_leap() : base("spell_warr_heroic_leap") { } - - class spell_warr_heroic_leap_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.HeroicLeapJump); - } + return ValidateSpellInfo(SpellIds.HeroicLeapJump); + } - SpellCastResult CheckElevation() + SpellCastResult CheckElevation() + { + WorldLocation dest = GetExplTargetDest(); + if (dest != null) { - WorldLocation dest = GetExplTargetDest(); - if (dest != null) + if (GetCaster().HasUnitMovementFlag(MovementFlag.Root)) + return SpellCastResult.Rooted; + + if (GetCaster().GetMap().Instanceable()) { - if (GetCaster().HasUnitMovementFlag(MovementFlag.Root)) - return SpellCastResult.Rooted; + float range = GetSpellInfo().GetMaxRange(true, GetCaster()) * 1.5f; - if (GetCaster().GetMap().Instanceable()) + PathGenerator generatedPath = new PathGenerator(GetCaster()); + generatedPath.SetPathLengthLimit(range); + + bool result = generatedPath.CalculatePath(dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ(), false, true); + if (generatedPath.GetPathType().HasAnyFlag(PathType.Short)) + return SpellCastResult.OutOfRange; + else if (!result || generatedPath.GetPathType().HasAnyFlag(PathType.NoPath)) { - float range = GetSpellInfo().GetMaxRange(true, GetCaster()) * 1.5f; - - PathGenerator generatedPath = new PathGenerator(GetCaster()); - generatedPath.SetPathLengthLimit(range); - - bool result = generatedPath.CalculatePath(dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ(), false, true); + result = generatedPath.CalculatePath(dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ(), false, false); if (generatedPath.GetPathType().HasAnyFlag(PathType.Short)) return SpellCastResult.OutOfRange; else if (!result || generatedPath.GetPathType().HasAnyFlag(PathType.NoPath)) - { - result = generatedPath.CalculatePath(dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ(), false, false); - if (generatedPath.GetPathType().HasAnyFlag(PathType.Short)) - return SpellCastResult.OutOfRange; - else if (!result || generatedPath.GetPathType().HasAnyFlag(PathType.NoPath)) - return SpellCastResult.NoPath; - } + return SpellCastResult.NoPath; } - else if (dest.GetPositionZ() > GetCaster().GetPositionZ() + 4.0f) - return SpellCastResult.NoPath; - - return SpellCastResult.SpellCastOk; } + else if (dest.GetPositionZ() > GetCaster().GetPositionZ() + 4.0f) + return SpellCastResult.NoPath; - return SpellCastResult.NoValidTargets; + return SpellCastResult.SpellCastOk; } - void HandleDummy(uint effIndex) - { - WorldLocation dest = GetHitDest(); - if (dest != null) - GetCaster().CastSpell(dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ(), SpellIds.HeroicLeapJump, true); - } - - public override void Register() - { - OnCheckCast.Add(new CheckCastHandler(CheckElevation)); - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return SpellCastResult.NoValidTargets; } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_warr_heroic_leap_SpellScript(); + WorldLocation dest = GetHitDest(); + if (dest != null) + GetCaster().CastSpell(dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ(), SpellIds.HeroicLeapJump, true); + } + + public override void Register() + { + OnCheckCast.Add(new CheckCastHandler(CheckElevation)); + OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] // Heroic Leap (triggered by Heroic Leap (6544)) - 178368 - class spell_warr_heroic_leap_jump : SpellScriptLoader + class spell_warr_heroic_leap_jump : SpellScript { - public spell_warr_heroic_leap_jump() : base("spell_warr_heroic_leap_jump") { } - - class spell_warr_heroic_leap_jump_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.GlyphOfHeroicLeap, - SpellIds.GlyphOfHeroicLeapBuff, - SpellIds.ImprovedHeroicLeap, - SpellIds.Taunt); - } - - void AfterJump(uint effIndex) - { - if (GetCaster().HasAura(SpellIds.GlyphOfHeroicLeap)) - GetCaster().CastSpell(GetCaster(), SpellIds.GlyphOfHeroicLeapBuff, true); - if (GetCaster().HasAura(SpellIds.ImprovedHeroicLeap)) - GetCaster().GetSpellHistory().ResetCooldown(SpellIds.Taunt, true); - } - - public override void Register() - { - OnEffectHit.Add(new EffectHandler(AfterJump, 1, SpellEffectName.JumpDest)); - } + return ValidateSpellInfo(SpellIds.GlyphOfHeroicLeap, + SpellIds.GlyphOfHeroicLeapBuff, + SpellIds.ImprovedHeroicLeap, + SpellIds.Taunt); } - public override SpellScript GetSpellScript() + void AfterJump(uint effIndex) { - return new spell_warr_heroic_leap_jump_SpellScript(); + if (GetCaster().HasAura(SpellIds.GlyphOfHeroicLeap)) + GetCaster().CastSpell(GetCaster(), SpellIds.GlyphOfHeroicLeapBuff, true); + if (GetCaster().HasAura(SpellIds.ImprovedHeroicLeap)) + GetCaster().GetSpellHistory().ResetCooldown(SpellIds.Taunt, true); + } + + public override void Register() + { + OnEffectHit.Add(new EffectHandler(AfterJump, 1, SpellEffectName.JumpDest)); } } [Script] // 202168 - Impending Victory - class spell_warr_impending_victory : SpellScriptLoader + class spell_warr_impending_victory : SpellScript { - public spell_warr_impending_victory() : base("spell_warr_impending_victory") { } - - class spell_warr_impending_victory_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ImpendingVictoryHeal); - } - - void HandleAfterCast() - { - Unit caster = GetCaster(); - caster.CastSpell(caster, SpellIds.ImpendingVictoryHeal, true); - caster.RemoveAurasDueToSpell(SpellIds.Victorious); - } - - public override void Register() - { - AfterCast.Add(new CastHandler(HandleAfterCast)); - } + return ValidateSpellInfo(SpellIds.ImpendingVictoryHeal); } - public override SpellScript GetSpellScript() + void HandleAfterCast() { - return new spell_warr_impending_victory_SpellScript(); + Unit caster = GetCaster(); + caster.CastSpell(caster, SpellIds.ImpendingVictoryHeal, true); + caster.RemoveAurasDueToSpell(SpellIds.Victorious); + } + + public override void Register() + { + AfterCast.Add(new CastHandler(HandleAfterCast)); } } // 5246 - Intimidating Shout [Script] - class spell_warr_intimidating_shout : SpellScriptLoader + class spell_warr_intimidating_shout : SpellScript { - public spell_warr_intimidating_shout() : base("spell_warr_intimidating_shout") { } - - class spell_warr_intimidating_shout_SpellScript : SpellScript + void FilterTargets(List unitList) { - void FilterTargets(List unitList) - { - unitList.Remove(GetExplTargetWorldObject()); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 1, Targets.UnitSrcAreaEnemy)); - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 2, Targets.UnitSrcAreaEnemy)); - } + unitList.Remove(GetExplTargetWorldObject()); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_warr_intimidating_shout_SpellScript(); + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 1, Targets.UnitSrcAreaEnemy)); + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 2, Targets.UnitSrcAreaEnemy)); } } // 70844 - Item - Warrior T10 Protection 4P Bonus [Script] /// 7.1.5 - class spell_warr_item_t10_prot_4p_bonus : SpellScriptLoader + class spell_warr_item_t10_prot_4p_bonus : AuraScript { - public spell_warr_item_t10_prot_4p_bonus() : base("spell_warr_item_t10_prot_4p_bonus") { } - - class spell_warr_item_t10_prot_4p_bonus_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.Stoicism); - } - - void HandleProc(ProcEventInfo eventInfo) - { - PreventDefaultAction(); - - Unit target = eventInfo.GetActionTarget(); - int bp0 = (int)MathFunctions.CalculatePct(target.GetMaxHealth(), GetSpellInfo().GetEffect(1).CalcValue()); - target.CastCustomSpell(SpellIds.Stoicism, SpellValueMod.BasePoint0, bp0, (Unit)null, true); - } - - public override void Register() - { - OnProc.Add(new AuraProcHandler(HandleProc)); - } + return ValidateSpellInfo(SpellIds.Stoicism); } - public override AuraScript GetAuraScript() + void HandleProc(ProcEventInfo eventInfo) { - return new spell_warr_item_t10_prot_4p_bonus_AuraScript(); + PreventDefaultAction(); + + Unit target = eventInfo.GetActionTarget(); + int bp0 = (int)MathFunctions.CalculatePct(target.GetMaxHealth(), GetSpellInfo().GetEffect(1).CalcValue()); + target.CastCustomSpell(SpellIds.Stoicism, SpellValueMod.BasePoint0, bp0, (Unit)null, true); + } + + public override void Register() + { + OnProc.Add(new AuraProcHandler(HandleProc)); } } // -84583 Lambs to the Slaughter [Script] - class spell_warr_lambs_to_the_slaughter : SpellScriptLoader + class spell_warr_lambs_to_the_slaughter : AuraScript { - public spell_warr_lambs_to_the_slaughter() : base("spell_warr_lambs_to_the_slaughter") { } - - class spell_warr_lambs_to_the_slaughter_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.MortalStrike, SpellIds.Rend); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - Aura aur = eventInfo.GetProcTarget().GetAura(SpellIds.Rend, GetTarget().GetGUID()); - if (aur != null) - aur.SetDuration(aur.GetSpellInfo().GetMaxDuration(), true); - - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); - } + return ValidateSpellInfo(SpellIds.MortalStrike, SpellIds.Rend); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_warr_lambs_to_the_slaughter_AuraScript(); + Aura aur = eventInfo.GetProcTarget().GetAura(SpellIds.Rend, GetTarget().GetGUID()); + if (aur != null) + aur.SetDuration(aur.GetSpellInfo().GetMaxDuration(), true); + + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); } } // Updated 4.3.4 // 12975 - Last Stand [Script] - class spell_warr_last_stand : SpellScriptLoader + class spell_warr_last_stand : SpellScript { - public spell_warr_last_stand() : base("spell_warr_last_stand") { } - - class spell_warr_last_stand_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.LastStandTriggered); - } - - void HandleDummy(uint effIndex) - { - Unit caster = GetCaster(); - int healthModSpellBasePoints0 = (int)(caster.CountPctFromMaxHealth(GetEffectValue())); - caster.CastCustomSpell(caster, SpellIds.LastStandTriggered, healthModSpellBasePoints0, 0, 0, true, null); - } - - public override void Register() - { - // add dummy effect spell handler to Last Stand - OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellIds.LastStandTriggered); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_warr_last_stand_SpellScript(); + Unit caster = GetCaster(); + int healthModSpellBasePoints0 = (int)(caster.CountPctFromMaxHealth(GetEffectValue())); + caster.CastCustomSpell(caster, SpellIds.LastStandTriggered, healthModSpellBasePoints0, 0, 0, true, null); + } + + public override void Register() + { + // add dummy effect spell handler to Last Stand + OnEffectHit.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } // 7384 - Overpower [Script] - class spell_warr_overpower : SpellScriptLoader + class spell_warr_overpower : SpellScript { - public spell_warr_overpower() : base("spell_warr_overpower") { } - - class spell_warr_overpower_SpellScript : SpellScript + void HandleEffect(uint effIndex) { - void HandleEffect(uint effIndex) - { - uint spellId = 0; - if (GetCaster().HasAura(SpellIds.UnrelentingAssaultRank1)) - spellId = SpellIds.UnrelentingAssaultTrigger1; - else if (GetCaster().HasAura(SpellIds.UnrelentingAssaultRank2)) - spellId = SpellIds.UnrelentingAssaultTrigger2; + uint spellId = 0; + if (GetCaster().HasAura(SpellIds.UnrelentingAssaultRank1)) + spellId = SpellIds.UnrelentingAssaultTrigger1; + else if (GetCaster().HasAura(SpellIds.UnrelentingAssaultRank2)) + spellId = SpellIds.UnrelentingAssaultTrigger2; - if (spellId == 0) - return; + if (spellId == 0) + return; - Player target = GetHitPlayer(); - if (target) - if (target.IsNonMeleeSpellCast(false, false, true)) // UNIT_STATE_CASTING should not be used here, it's present during a tick for instant casts - target.CastSpell(target, spellId, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleEffect, 0, SpellEffectName.Any)); - } + Player target = GetHitPlayer(); + if (target) + if (target.IsNonMeleeSpellCast(false, false, true)) // UNIT_STATE_CASTING should not be used here, it's present during a tick for instant casts + target.CastSpell(target, spellId, true); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_warr_overpower_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleEffect, 0, SpellEffectName.Any)); } } // 97462 - Rallying Cry [Script] - class spell_warr_rallying_cry : SpellScriptLoader + class spell_warr_rallying_cry : SpellScript { - public spell_warr_rallying_cry() : base("spell_warr_rallying_cry") { } - - class spell_warr_rallying_cry_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.RallyingCry); - } - - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Player); - } - - void HandleScript(uint effIndex) - { - int basePoints0 = (int)(GetHitUnit().CountPctFromMaxHealth(GetEffectValue())); - - GetCaster().CastCustomSpell(GetHitUnit(), SpellIds.RallyingCry, basePoints0, 0, 0, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellIds.RallyingCry); } - public override SpellScript GetSpellScript() + public override bool Load() { - return new spell_warr_rallying_cry_SpellScript(); + return GetCaster().IsTypeId(TypeId.Player); + } + + void HandleScript(uint effIndex) + { + int basePoints0 = (int)(GetHitUnit().CountPctFromMaxHealth(GetEffectValue())); + + GetCaster().CastCustomSpell(GetHitUnit(), SpellIds.RallyingCry, basePoints0, 0, 0, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.Dummy)); } } // 94009 - Rend [Script] - class spell_warr_rend : SpellScriptLoader + class spell_warr_rend : AuraScript { - public spell_warr_rend() : base("spell_warr_rend") { } - - class spell_warr_rend_AuraScript : AuraScript + void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) { - void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) + Unit caster = GetCaster(); + if (caster) { - Unit caster = GetCaster(); - if (caster) - { - canBeRecalculated = false; + canBeRecalculated = false; - // $0.25 * (($MWB + $mwb) / 2 + $AP / 14 * $MWS) bonus per tick - float ap = caster.GetTotalAttackPowerValue(WeaponAttackType.BaseAttack); - int mws = (int)caster.GetBaseAttackTime(WeaponAttackType.BaseAttack); - float mwbMin = caster.GetWeaponDamageRange(WeaponAttackType.BaseAttack, WeaponDamageRange.MinDamage); - float mwbMax = caster.GetWeaponDamageRange(WeaponAttackType.BaseAttack, WeaponDamageRange.MaxDamage); - float mwb = ((mwbMin + mwbMax) / 2 + ap * mws / 14000) * 0.25f; - amount += (int)(caster.ApplyEffectModifiers(GetSpellInfo(), aurEff.GetEffIndex(), mwb)); - } - } - - public override void Register() - { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.PeriodicDamage)); + // $0.25 * (($MWB + $mwb) / 2 + $AP / 14 * $MWS) bonus per tick + float ap = caster.GetTotalAttackPowerValue(WeaponAttackType.BaseAttack); + int mws = (int)caster.GetBaseAttackTime(WeaponAttackType.BaseAttack); + float mwbMin = caster.GetWeaponDamageRange(WeaponAttackType.BaseAttack, WeaponDamageRange.MinDamage); + float mwbMax = caster.GetWeaponDamageRange(WeaponAttackType.BaseAttack, WeaponDamageRange.MaxDamage); + float mwb = ((mwbMin + mwbMax) / 2 + ap * mws / 14000) * 0.25f; + amount += (int)(caster.ApplyEffectModifiers(GetSpellInfo(), aurEff.GetEffIndex(), mwb)); } } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_warr_rend_AuraScript(); + DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 0, AuraType.PeriodicDamage)); } } // 20230 - Retaliation [Script] - class spell_warr_retaliation : SpellScriptLoader + class spell_warr_retaliation : AuraScript { - public spell_warr_retaliation() : base("spell_warr_retaliation") { } - - class spell_warr_retaliation_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.RetaliationDamage); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - // check attack comes not from behind and warrior is not stunned - return GetTarget().isInFront(eventInfo.GetProcTarget(), MathFunctions.PI) && !GetTarget().HasUnitState(UnitState.Stunned); - } - - void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.RetaliationDamage, true, null, aurEff); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.RetaliationDamage); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_warr_retaliation_AuraScript(); + // check attack comes not from behind and warrior is not stunned + return GetTarget().isInFront(eventInfo.GetProcTarget(), MathFunctions.PI) && !GetTarget().HasUnitState(UnitState.Stunned); + } + + void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.RetaliationDamage, true, null, aurEff); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleEffectProc, 0, AuraType.Dummy)); } } // 64380, 65941 - Shattering Throw [Script] - class spell_warr_shattering_throw : SpellScriptLoader + class spell_warr_shattering_throw : SpellScript { - public spell_warr_shattering_throw() : base("spell_warr_shattering_throw") { } - - class spell_warr_shattering_throw_SpellScript : SpellScript + void HandleScript(uint effIndex) { - void HandleScript(uint effIndex) - { - PreventHitDefaultEffect(effIndex); + PreventHitDefaultEffect(effIndex); - // remove shields, will still display immune to damage part - Unit target = GetHitUnit(); - if (target) - target.RemoveAurasWithMechanic(1 << (int)Mechanics.Immune_Shield, AuraRemoveMode.EnemySpell); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } + // remove shields, will still display immune to damage part + Unit target = GetHitUnit(); + if (target) + target.RemoveAurasWithMechanic(1 << (int)Mechanics.Immune_Shield, AuraRemoveMode.EnemySpell); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_warr_shattering_throw_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } // Updated 4.3.4 [Script] - class spell_warr_slam : SpellScriptLoader + class spell_warr_slam : SpellScript { - public spell_warr_slam() : base("spell_warr_slam") { } - - class spell_warr_slam_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.Slam); - } - - void HandleDummy(uint effIndex) - { - if (GetHitUnit()) - GetCaster().CastCustomSpell(SpellIds.Slam, SpellValueMod.BasePoint0, GetEffectValue(), GetHitUnit(), TriggerCastFlags.FullMask); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellIds.Slam); } - public override SpellScript GetSpellScript() + void HandleDummy(uint effIndex) { - return new spell_warr_slam_SpellScript(); + if (GetHitUnit()) + GetCaster().CastCustomSpell(SpellIds.Slam, SpellValueMod.BasePoint0, GetEffectValue(), GetHitUnit(), TriggerCastFlags.FullMask); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 0, SpellEffectName.Dummy)); } } [Script] - class spell_warr_second_wind_proc : SpellScriptLoader + class spell_warr_second_wind_proc : AuraScript { - public spell_warr_second_wind_proc() : base("spell_warr_second_wind_proc") { } - - class spell_warr_second_wind_proc_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.SecoundWindProcRank1, SpellIds.SecoundWindProcRank2, SpellIds.SecoundWindTriggerRank1, SpellIds.SecoundWindTriggerRank2); - } - - bool CheckProc(ProcEventInfo eventInfo) - { - if (eventInfo.GetProcTarget() == GetTarget()) - return false; - if (eventInfo.GetDamageInfo().GetSpellInfo() == null || - (eventInfo.GetDamageInfo().GetSpellInfo().GetAllEffectsMechanicMask() & ((1 << (int)Mechanics.Root) | (1 << (int)Mechanics.Stun))) == 0) - return false; - return true; - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - uint spellId = 0; - - if (GetSpellInfo().Id == SpellIds.SecoundWindProcRank1) - spellId = SpellIds.SecoundWindTriggerRank1; - else if (GetSpellInfo().Id == SpellIds.SecoundWindProcRank2) - spellId = SpellIds.SecoundWindTriggerRank2; - if (spellId == 0) - return; - - GetTarget().CastSpell(GetTarget(), spellId, true, null, aurEff); - - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.SecoundWindProcRank1, SpellIds.SecoundWindProcRank2, SpellIds.SecoundWindTriggerRank1, SpellIds.SecoundWindTriggerRank2); } - public override AuraScript GetAuraScript() + bool CheckProc(ProcEventInfo eventInfo) { - return new spell_warr_second_wind_proc_AuraScript(); + if (eventInfo.GetProcTarget() == GetTarget()) + return false; + if (eventInfo.GetDamageInfo().GetSpellInfo() == null || + (eventInfo.GetDamageInfo().GetSpellInfo().GetAllEffectsMechanicMask() & ((1 << (int)Mechanics.Root) | (1 << (int)Mechanics.Stun))) == 0) + return false; + return true; + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + uint spellId = 0; + + if (GetSpellInfo().Id == SpellIds.SecoundWindProcRank1) + spellId = SpellIds.SecoundWindTriggerRank1; + else if (GetSpellInfo().Id == SpellIds.SecoundWindProcRank2) + spellId = SpellIds.SecoundWindTriggerRank2; + if (spellId == 0) + return; + + GetTarget().CastSpell(GetTarget(), spellId, true, null, aurEff); + + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } [Script] - class spell_warr_second_wind_trigger : SpellScriptLoader + class spell_warr_second_wind_trigger : AuraScript { - public spell_warr_second_wind_trigger() : base("spell_warr_second_wind_trigger") { } - - class spell_warr_second_wind_trigger_AuraScript : AuraScript + void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) { - void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) - { - amount = (int)(GetUnitOwner().CountPctFromMaxHealth(amount)); - } - - public override void Register() - { - DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 1, AuraType.PeriodicHeal)); - } + amount = (int)(GetUnitOwner().CountPctFromMaxHealth(amount)); } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_warr_second_wind_trigger_AuraScript(); + DoEffectCalcAmount.Add(new EffectCalcAmountHandler(CalculateAmount, 1, AuraType.PeriodicHeal)); } } [Script] // 46968 - Shockwave - class spell_warr_shockwave : SpellScriptLoader + class spell_warr_shockwave : SpellScript { - public spell_warr_shockwave() : base("spell_warr_shockwave") { } - - class spell_warr_shockwave_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - if (!ValidateSpellInfo(SpellIds.Shockwave, SpellIds.ShockwaveStun)) - return false; + if (!ValidateSpellInfo(SpellIds.Shockwave, SpellIds.ShockwaveStun)) + return false; - return spellInfo.GetEffect(0) != null && spellInfo.GetEffect(3) != null; - } - - public override bool Load() - { - return GetCaster().IsTypeId(TypeId.Player); - } - - void HandleStun(uint effIndex) - { - GetCaster().CastSpell(GetHitUnit(), SpellIds.ShockwaveStun, true); - ++_targetCount; - } - - // Cooldown reduced by 20 sec if it strikes at least 3 targets. - void HandleAfterCast() - { - if (_targetCount >= (uint)GetSpellInfo().GetEffect(0).CalcValue()) - GetCaster().ToPlayer().GetSpellHistory().ModifyCooldown(GetSpellInfo().Id, -(GetSpellInfo().GetEffect(3).CalcValue() * Time.InMilliseconds)); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleStun, 0, SpellEffectName.Dummy)); - AfterCast.Add(new CastHandler(HandleAfterCast)); - } - - uint _targetCount = 0; + return spellInfo.GetEffect(0) != null && spellInfo.GetEffect(3) != null; } - public override SpellScript GetSpellScript() + public override bool Load() { - return new spell_warr_shockwave_SpellScript(); + return GetCaster().IsTypeId(TypeId.Player); } + + void HandleStun(uint effIndex) + { + GetCaster().CastSpell(GetHitUnit(), SpellIds.ShockwaveStun, true); + ++_targetCount; + } + + // Cooldown reduced by 20 sec if it strikes at least 3 targets. + void HandleAfterCast() + { + if (_targetCount >= (uint)GetSpellInfo().GetEffect(0).CalcValue()) + GetCaster().ToPlayer().GetSpellHistory().ModifyCooldown(GetSpellInfo().Id, -(GetSpellInfo().GetEffect(3).CalcValue() * Time.InMilliseconds)); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleStun, 0, SpellEffectName.Dummy)); + AfterCast.Add(new CastHandler(HandleAfterCast)); + } + + uint _targetCount = 0; } [Script] // 107570 - Storm Bolt - class spell_warr_storm_bolt : SpellScriptLoader + class spell_warr_storm_bolt : SpellScript { - public spell_warr_storm_bolt() : base("spell_warr_storm_bolt") { } - - class spell_warr_storm_bolt_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.StormBoltStun); - } - - void HandleOnHit(uint effIndex) - { - GetCaster().CastSpell(GetHitUnit(), SpellIds.StormBoltStun, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleOnHit, 1, SpellEffectName.Dummy)); - } + return ValidateSpellInfo(SpellIds.StormBoltStun); } - public override SpellScript GetSpellScript() + void HandleOnHit(uint effIndex) { - return new spell_warr_storm_bolt_SpellScript(); + GetCaster().CastSpell(GetHitUnit(), SpellIds.StormBoltStun, true); + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(HandleOnHit, 1, SpellEffectName.Dummy)); } } // 52437 - Sudden Death [Script] - class spell_warr_sudden_death : SpellScriptLoader + class spell_warr_sudden_death : AuraScript { - public spell_warr_sudden_death() : base("spell_warr_sudden_death") { } - - class spell_warr_sudden_death_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ColossusSmash); - } - - void HandleApply(AuraEffect aurEff, AuraEffectHandleModes mode) - { - // Remove cooldown on Colossus Smash - Player player = GetTarget().ToPlayer(); - if (player) - player.GetSpellHistory().ResetCooldown(SpellIds.ColossusSmash, true); - } - - public override void Register() - { - AfterEffectApply.Add(new EffectApplyHandler(HandleApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); // correct? - } + return ValidateSpellInfo(SpellIds.ColossusSmash); } - public override AuraScript GetAuraScript() + void HandleApply(AuraEffect aurEff, AuraEffectHandleModes mode) { - return new spell_warr_sudden_death_AuraScript(); + // Remove cooldown on Colossus Smash + Player player = GetTarget().ToPlayer(); + if (player) + player.GetSpellHistory().ResetCooldown(SpellIds.ColossusSmash, true); + } + + public override void Register() + { + AfterEffectApply.Add(new EffectApplyHandler(HandleApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real)); // correct? } } // 12328, 18765, 35429 - Sweeping Strikes [Script] - class spell_warr_sweeping_strikes : SpellScriptLoader + class spell_warr_sweeping_strikes : AuraScript { - public spell_warr_sweeping_strikes() : base("spell_warr_sweeping_strikes") { } - - class spell_warr_sweeping_strikes_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.SweepingStrikesExtraAttack); - } - - public override bool Load() - { - _procTarget = null; - return true; - } - - bool CheckProc(ProcEventInfo eventInfo) - { - _procTarget = eventInfo.GetActor().SelectNearbyTarget(eventInfo.GetProcTarget()); - return _procTarget; - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - GetTarget().CastSpell(_procTarget, SpellIds.SweepingStrikesExtraAttack, true, null, aurEff); - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } - - Unit _procTarget; + return ValidateSpellInfo(SpellIds.SweepingStrikesExtraAttack); } - public override AuraScript GetAuraScript() + public override bool Load() { - return new spell_warr_sweeping_strikes_AuraScript(); + _procTarget = null; + return true; } + + bool CheckProc(ProcEventInfo eventInfo) + { + _procTarget = eventInfo.GetActor().SelectNearbyTarget(eventInfo.GetProcTarget()); + return _procTarget; + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + GetTarget().CastSpell(_procTarget, SpellIds.SweepingStrikesExtraAttack, true, null, aurEff); + } + + public override void Register() + { + DoCheckProc.Add(new CheckProcHandler(CheckProc)); + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); + } + + Unit _procTarget; } // -46951 - Sword and Board [Script] - class spell_warr_sword_and_board : SpellScriptLoader + class spell_warr_sword_and_board : AuraScript { - public spell_warr_sword_and_board() : base("spell_warr_sword_and_board") { } - - class spell_warr_sword_and_board_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ShieldSlam); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - // Remove cooldown on Shield Slam - Player player = GetTarget().ToPlayer(); - if (player) - player.GetSpellHistory().ResetCooldown(SpellIds.ShieldSlam, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); - } + return ValidateSpellInfo(SpellIds.ShieldSlam); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_warr_sword_and_board_AuraScript(); + // Remove cooldown on Shield Slam + Player player = GetTarget().ToPlayer(); + if (player) + player.GetSpellHistory().ResetCooldown(SpellIds.ShieldSlam, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); } } [Script] // 215538 - Trauma - class spell_warr_trauma : SpellScriptLoader + class spell_warr_trauma : AuraScript { - public spell_warr_trauma() : base("spell_warr_trauma") { } - - class spell_warr_trauma_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.TraumaEffect); - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - Unit target = eventInfo.GetActionTarget(); - //Get the Remaining Damage from the aura (if exist) - int remainingDamage = (int)target.GetRemainingPeriodicAmount(target.GetGUID(), SpellIds.TraumaEffect, AuraType.PeriodicDamage); - //Get 25% of damage from the spell casted (Slam & Whirlwind) plus Remaining Damage from Aura - int damage = (int)(MathFunctions.CalculatePct(eventInfo.GetDamageInfo().GetDamage(), aurEff.GetAmount()) / Global.SpellMgr.GetSpellInfo(SpellIds.TraumaEffect).GetMaxTicks(Difficulty.None)) + remainingDamage; - GetCaster().CastCustomSpell(SpellIds.TraumaEffect, SpellValueMod.BasePoint0, damage, target, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); - } + return ValidateSpellInfo(SpellIds.TraumaEffect); } - public override AuraScript GetAuraScript() + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - return new spell_warr_trauma_AuraScript(); + Unit target = eventInfo.GetActionTarget(); + //Get the Remaining Damage from the aura (if exist) + int remainingDamage = (int)target.GetRemainingPeriodicAmount(target.GetGUID(), SpellIds.TraumaEffect, AuraType.PeriodicDamage); + //Get 25% of damage from the spell casted (Slam & Whirlwind) plus Remaining Damage from Aura + int damage = (int)(MathFunctions.CalculatePct(eventInfo.GetDamageInfo().GetDamage(), aurEff.GetAmount()) / Global.SpellMgr.GetSpellInfo(SpellIds.TraumaEffect).GetMaxTicks(Difficulty.None)) + remainingDamage; + GetCaster().CastCustomSpell(SpellIds.TraumaEffect, SpellValueMod.BasePoint0, damage, target, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.Dummy)); } } [Script] // 28845 - Cheat Death - class spell_warr_t3_prot_8p_bonus : SpellScriptLoader + class spell_warr_t3_prot_8p_bonus : AuraScript { - public spell_warr_t3_prot_8p_bonus() : base("spell_warr_t3_prot_8p_bonus") { } - - class spell_warr_t3_prot_8p_bonus_AuraScript : AuraScript + bool CheckProc(ProcEventInfo eventInfo) { - bool CheckProc(ProcEventInfo eventInfo) - { - if (eventInfo.GetActionTarget().HealthBelowPct(20)) + if (eventInfo.GetActionTarget().HealthBelowPct(20)) + return true; + + DamageInfo damageInfo = eventInfo.GetDamageInfo(); + if (damageInfo != null && damageInfo.GetDamage() != 0) + if (GetTarget().HealthBelowPctDamaged(20, damageInfo.GetDamage())) return true; - DamageInfo damageInfo = eventInfo.GetDamageInfo(); - if (damageInfo != null && damageInfo.GetDamage() != 0) - if (GetTarget().HealthBelowPctDamaged(20, damageInfo.GetDamage())) - return true; - - return false; - } - - public override void Register() - { - DoCheckProc.Add(new CheckProcHandler(CheckProc)); - } + return false; } - public override AuraScript GetAuraScript() + public override void Register() { - return new spell_warr_t3_prot_8p_bonus_AuraScript(); + DoCheckProc.Add(new CheckProcHandler(CheckProc)); } } [Script] // 32215 - Victorious State - class spell_warr_victorious_state : SpellScriptLoader + class spell_warr_victorious_state : AuraScript { - public spell_warr_victorious_state() : base("spell_warr_victorious_state") { } - - class spell_warr_victorious_state_Aurascript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.ImpendingVictory); - } - - void HandleOnProc(AuraEffect aurEff, ProcEventInfo procInfo) - { - if (procInfo.GetActor().GetTypeId() == TypeId.Player && procInfo.GetActor().GetUInt32Value(PlayerFields.CurrentSpecId) == (uint)TalentSpecialization.WarriorFury) - PreventDefaultAction(); - - procInfo.GetActor().GetSpellHistory().ResetCooldown(SpellIds.ImpendingVictory, true); - } - - public override void Register() - { - OnEffectProc.Add(new EffectProcHandler(HandleOnProc, 0, AuraType.ProcTriggerSpell)); - } + return ValidateSpellInfo(SpellIds.ImpendingVictory); } - public override AuraScript GetAuraScript() + void HandleOnProc(AuraEffect aurEff, ProcEventInfo procInfo) { - return new spell_warr_victorious_state_Aurascript(); + if (procInfo.GetActor().GetTypeId() == TypeId.Player && procInfo.GetActor().GetUInt32Value(PlayerFields.CurrentSpecId) == (uint)TalentSpecialization.WarriorFury) + PreventDefaultAction(); + + procInfo.GetActor().GetSpellHistory().ResetCooldown(SpellIds.ImpendingVictory, true); + } + + public override void Register() + { + OnEffectProc.Add(new EffectProcHandler(HandleOnProc, 0, AuraType.ProcTriggerSpell)); } } [Script] // 34428 - Victory Rush - class spell_warr_victory_rush : SpellScriptLoader + class spell_warr_victory_rush : SpellScript { - public spell_warr_victory_rush() : base("spell_warr_victory_rush") { } - - class spell_warr_victory_rush_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.Victorious, SpellIds.VictoriousRushHeal); - } - - void HandleHeal() - { - Unit caster = GetCaster(); - - caster.CastSpell(caster, SpellIds.VictoriousRushHeal, true); - caster.RemoveAurasDueToSpell(SpellIds.Victorious); - } - - public override void Register() - { - AfterCast.Add(new CastHandler(HandleHeal)); - } + return ValidateSpellInfo(SpellIds.Victorious, SpellIds.VictoriousRushHeal); } - public override SpellScript GetSpellScript() + void HandleHeal() { - return new spell_warr_victory_rush_SpellScript(); + Unit caster = GetCaster(); + + caster.CastSpell(caster, SpellIds.VictoriousRushHeal, true); + caster.RemoveAurasDueToSpell(SpellIds.Victorious); + } + + public override void Register() + { + AfterCast.Add(new CastHandler(HandleHeal)); } } // 50720 - Vigilance [Script] - class spell_warr_vigilance : SpellScriptLoader + class spell_warr_vigilance : AuraScript { - public spell_warr_vigilance() : base("spell_warr_vigilance") { } - - class spell_warr_vigilance_AuraScript : AuraScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(SpellIds.Vengeance); - } - - public override bool Load() - { - //_procTarget = null; - return true; - } - - /*bool CheckProc(ProcEventInfo eventInfo) - { - _procTarget = GetCaster(); - return _procTarget && eventInfo.GetDamageInfo() != null; - } - - void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) - { - PreventDefaultAction(); - int damage = (int)(MathFunctions.CalculatePct(eventInfo.GetDamageInfo().GetDamage(), aurEff.GetSpellInfo().GetEffect(1).CalcValue())); - - GetTarget().CastSpell(_procTarget, SpellIds.VigilanceProc, true, null, aurEff); - _procTarget.CastCustomSpell(_procTarget, SpellIds.Vengeance, damage, damage, damage, true, null, aurEff); - }*/ - - void HandleRemove(AuraEffect aurEff, AuraEffectHandleModes mode) - { - Unit caster = GetCaster(); - if (caster) - { - if (caster.HasAura(SpellIds.Vengeance)) - caster.RemoveAurasDueToSpell(SpellIds.Vengeance); - } - } - - public override void Register() - { - //DoCheckProc.Add(new CheckProcHandler(CheckProc)); - //OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); - OnEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.ProcTriggerSpell, AuraEffectHandleModes.Real)); - } - - //Unit _procTarget; + return ValidateSpellInfo(SpellIds.Vengeance); } - public override AuraScript GetAuraScript() + public override bool Load() { - return new spell_warr_vigilance_AuraScript(); + //_procTarget = null; + return true; } + + /*bool CheckProc(ProcEventInfo eventInfo) + { + _procTarget = GetCaster(); + return _procTarget && eventInfo.GetDamageInfo() != null; + } + + void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) + { + PreventDefaultAction(); + int damage = (int)(MathFunctions.CalculatePct(eventInfo.GetDamageInfo().GetDamage(), aurEff.GetSpellInfo().GetEffect(1).CalcValue())); + + GetTarget().CastSpell(_procTarget, SpellIds.VigilanceProc, true, null, aurEff); + _procTarget.CastCustomSpell(_procTarget, SpellIds.Vengeance, damage, damage, damage, true, null, aurEff); + }*/ + + void HandleRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + Unit caster = GetCaster(); + if (caster) + { + if (caster.HasAura(SpellIds.Vengeance)) + caster.RemoveAurasDueToSpell(SpellIds.Vengeance); + } + } + + public override void Register() + { + //DoCheckProc.Add(new CheckProcHandler(CheckProc)); + //OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.ProcTriggerSpell)); + OnEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.ProcTriggerSpell, AuraEffectHandleModes.Real)); + } + + //Unit _procTarget; } // 50725 Vigilance [Script] - class spell_warr_vigilance_trigger : SpellScriptLoader + class spell_warr_vigilance_trigger : SpellScript { - public spell_warr_vigilance_trigger() : base("spell_warr_vigilance_trigger") { } - - class spell_warr_vigilance_trigger_SpellScript : SpellScript + void HandleScript(uint effIndex) { - void HandleScript(uint effIndex) - { - PreventHitDefaultEffect(effIndex); + PreventHitDefaultEffect(effIndex); - // Remove Taunt cooldown - Player target = GetHitPlayer(); - if (target) - target.GetSpellHistory().ResetCooldown(SpellIds.Taunt, true); - } - - public override void Register() - { - OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); - } + // Remove Taunt cooldown + Player target = GetHitPlayer(); + if (target) + target.GetSpellHistory().ResetCooldown(SpellIds.Taunt, true); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_warr_vigilance_trigger_SpellScript(); + OnEffectHitTarget.Add(new EffectHandler(HandleScript, 0, SpellEffectName.ScriptEffect)); } } } diff --git a/Scripts/World/BossEmeraldDragons.cs b/Scripts/World/BossEmeraldDragons.cs index 7c6cfb5cc..32867d2db 100644 --- a/Scripts/World/BossEmeraldDragons.cs +++ b/Scripts/World/BossEmeraldDragons.cs @@ -155,63 +155,53 @@ namespace Scripts.World.BossEmeraldDragons } [Script] - class npc_dream_fog : CreatureScript + class npc_dream_fog : ScriptedAI { - public npc_dream_fog() : base("npc_dream_fog") { } - - class npc_dream_fogAI : ScriptedAI + public npc_dream_fog(Creature creature) : base(creature) { - public npc_dream_fogAI(Creature creature) : base(creature) - { - Initialize(); - } + Initialize(); + } - void Initialize() - { - _roamTimer = 0; - } + void Initialize() + { + _roamTimer = 0; + } - public override void Reset() - { - Initialize(); - } + public override void Reset() + { + Initialize(); + } - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; - if (_roamTimer == 0) + if (_roamTimer == 0) + { + // Chase target, but don't attack - otherwise just roam around + Unit target = SelectTarget(SelectAggroTarget.Random, 0, 0.0f, true); + if (target) { - // Chase target, but don't attack - otherwise just roam around - Unit target = SelectTarget(SelectAggroTarget.Random, 0, 0.0f, true); - if (target) - { - _roamTimer = RandomHelper.URand(15000, 30000); - me.GetMotionMaster().Clear(false); - me.GetMotionMaster().MoveChase(target, 0.2f); - } - else - { - _roamTimer = 2500; - me.GetMotionMaster().Clear(false); - me.GetMotionMaster().MoveRandom(25.0f); - } - // Seeping fog movement is slow enough for a player to be able to walk backwards and still outpace it - me.SetWalk(true); - me.SetSpeedRate(UnitMoveType.Walk, 0.75f); + _roamTimer = RandomHelper.URand(15000, 30000); + me.GetMotionMaster().Clear(false); + me.GetMotionMaster().MoveChase(target, 0.2f); } else - _roamTimer -= diff; + { + _roamTimer = 2500; + me.GetMotionMaster().Clear(false); + me.GetMotionMaster().MoveRandom(25.0f); + } + // Seeping fog movement is slow enough for a player to be able to walk backwards and still outpace it + me.SetWalk(true); + me.SetSpeedRate(UnitMoveType.Walk, 0.75f); } - - uint _roamTimer; + else + _roamTimer -= diff; } - public override CreatureAI GetAI(Creature creature) - { - return new npc_dream_fogAI(creature); - } + uint _roamTimer; } [Script] @@ -334,36 +324,26 @@ namespace Scripts.World.BossEmeraldDragons } [Script] - class npc_spirit_shade : CreatureScript + class npc_spirit_shade : PassiveAI { - public npc_spirit_shade() : base("npc_spirit_shade") { } + public npc_spirit_shade(Creature creature) : base(creature) { } - class npc_spirit_shadeAI : PassiveAI + public override void IsSummonedBy(Unit summoner) { - public npc_spirit_shadeAI(Creature creature) : base(creature) { } - - public override void IsSummonedBy(Unit summoner) - { - _summonerGuid = summoner.GetGUID(); - me.GetMotionMaster().MoveFollow(summoner, 0.0f, 0.0f); - } - - public override void MovementInform(MovementGeneratorType moveType, uint data) - { - if (moveType == MovementGeneratorType.Follow && data == _summonerGuid.GetCounter()) - { - me.CastSpell((Unit)null, Spells.DarkOffering, false); - me.DespawnOrUnsummon(1000); - } - } - - ObjectGuid _summonerGuid; + _summonerGuid = summoner.GetGUID(); + me.GetMotionMaster().MoveFollow(summoner, 0.0f, 0.0f); } - public override CreatureAI GetAI(Creature creature) + public override void MovementInform(MovementGeneratorType moveType, uint data) { - return new npc_spirit_shadeAI(creature); + if (moveType == MovementGeneratorType.Follow && data == _summonerGuid.GetCounter()) + { + me.CastSpell((Unit)null, Spells.DarkOffering, false); + me.DespawnOrUnsummon(1000); + } } + + ObjectGuid _summonerGuid; } [Script] @@ -547,75 +527,55 @@ namespace Scripts.World.BossEmeraldDragons } [Script] - class spell_dream_fog_sleep : SpellScriptLoader + class spell_dream_fog_sleep : SpellScript { - public spell_dream_fog_sleep() : base("spell_dream_fog_sleep") { } - - class spell_dream_fog_sleep_SpellScript : SpellScript + void FilterTargets(List targets) { - void FilterTargets(List targets) + targets.RemoveAll(obj => { - targets.RemoveAll(obj => - { - Unit unit = obj.ToUnit(); - if (unit) - return unit.HasAura(Spells.Sleep); - return true; - }); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaEnemy)); - } + Unit unit = obj.ToUnit(); + if (unit) + return unit.HasAura(Spells.Sleep); + return true; + }); } - public override SpellScript GetSpellScript() + public override void Register() { - return new spell_dream_fog_sleep_SpellScript(); + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitDestAreaEnemy)); } } [Script] - class spell_mark_of_nature : SpellScriptLoader + class spell_mark_of_nature : SpellScript { - public spell_mark_of_nature() : base("spell_mark_of_nature") { } - - class spell_mark_of_nature_SpellScript : SpellScript + public override bool Validate(SpellInfo spellInfo) { - public override bool Validate(SpellInfo spellInfo) - { - return ValidateSpellInfo(Spells.MarkOfNature, Spells.AuraOfNature); - } - - void FilterTargets(List targets) - { - targets.RemoveAll(obj => - { - // return those not tagged or already under the influence of Aura of Nature - Unit unit = obj.ToUnit(); - if (unit) - return !(unit.HasAura(Spells.MarkOfNature) && !unit.HasAura(Spells.AuraOfNature)); - return true; - }); - } - - void HandleEffect(uint effIndex) - { - PreventHitDefaultEffect(effIndex); - GetHitUnit().CastSpell(GetHitUnit(), Spells.AuraOfNature, true); - } - - public override void Register() - { - OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEnemy)); - OnEffectHitTarget.Add(new EffectHandler(HandleEffect, 0, SpellEffectName.ApplyAura)); - } + return ValidateSpellInfo(Spells.MarkOfNature, Spells.AuraOfNature); } - public override SpellScript GetSpellScript() + void FilterTargets(List targets) { - return new spell_mark_of_nature_SpellScript(); + targets.RemoveAll(obj => + { + // return those not tagged or already under the influence of Aura of Nature + Unit unit = obj.ToUnit(); + if (unit) + return !(unit.HasAura(Spells.MarkOfNature) && !unit.HasAura(Spells.AuraOfNature)); + return true; + }); + } + + void HandleEffect(uint effIndex) + { + PreventHitDefaultEffect(effIndex); + GetHitUnit().CastSpell(GetHitUnit(), Spells.AuraOfNature, true); + } + + public override void Register() + { + OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEnemy)); + OnEffectHitTarget.Add(new EffectHandler(HandleEffect, 0, SpellEffectName.ApplyAura)); } } } diff --git a/Scripts/World/DuelReset.cs b/Scripts/World/DuelReset.cs index 6f0bdb812..03de188ae 100644 --- a/Scripts/World/DuelReset.cs +++ b/Scripts/World/DuelReset.cs @@ -107,7 +107,7 @@ namespace Scripts.World if (onStartDuel) { // remove cooldowns on spells that have < 10 min CD > 30 sec and has no onHold - player.GetSpellHistory().ResetCooldowns(pair => + player.GetSpellHistory().ResetCooldowns(pair => { DateTime now = DateTime.Now; uint cooldownDuration = pair.Value.CooldownEnd > now ? (uint)(pair.Value.CooldownEnd - now).TotalMilliseconds : 0; diff --git a/Scripts/World/GameObjects.cs b/Scripts/World/GameObjects.cs index e70e268e4..2685c2321 100644 --- a/Scripts/World/GameObjects.cs +++ b/Scripts/World/GameObjects.cs @@ -313,7 +313,7 @@ namespace Scripts.World { FactionTemplateRecord pFaction = creature.GetFactionTemplateEntry(); if (pFaction != null) - { + { uint Spell = 0; switch (pFaction.Faction) @@ -737,11 +737,6 @@ namespace Scripts.World return false; } } - - public override GameObjectAI GetAI(GameObject go) - { - return new go_soulwellAI(go); - } } [Script] //go_dragonflayer_cage diff --git a/Scripts/World/Guards.cs b/Scripts/World/Guards.cs index a0fb85827..f7b0a5c5e 100644 --- a/Scripts/World/Guards.cs +++ b/Scripts/World/Guards.cs @@ -47,336 +47,306 @@ namespace Scripts.World } [Script] - class guard_generic : CreatureScript + class guard_generic : GuardAI { - public guard_generic() : base("guard_generic") { } + public guard_generic(Creature creature) : base(creature) { } - class guard_genericAI : GuardAI + public override void Reset() { - public guard_genericAI(Creature creature) : base(creature) { } + globalCooldown = 0; + buffTimer = 0; + } - public override void Reset() - { + public override void EnterCombat(Unit who) + { + if (me.GetEntry() == CreatureIds.CenarionHoldIndantry) + Talk(GuardsConst.SaySilAggro, who); + SpellInfo spell = me.reachWithSpellAttack(who); + if (spell != null) + DoCast(who, spell.Id); + } + + public override void UpdateAI(uint diff) + { + //Always decrease our global cooldown first + if (globalCooldown > diff) + globalCooldown -= diff; + else globalCooldown = 0; - buffTimer = 0; - } - public override void EnterCombat(Unit who) + //Buff timer (only buff when we are alive and not in combat + if (me.IsAlive() && !me.IsInCombat()) { - if (me.GetEntry() == CreatureIds.CenarionHoldIndantry) - Talk(GuardsConst.SaySilAggro, who); - SpellInfo spell = me.reachWithSpellAttack(who); - if (spell != null) - DoCast(who, spell.Id); - } - - public override void UpdateAI(uint diff) - { - //Always decrease our global cooldown first - if (globalCooldown > diff) - globalCooldown -= diff; - else - globalCooldown = 0; - - //Buff timer (only buff when we are alive and not in combat - if (me.IsAlive() && !me.IsInCombat()) + if (buffTimer <= diff) { - if (buffTimer <= diff) - { - //Find a spell that targets friendly and applies an aura (these are generally buffs) - SpellInfo info = SelectSpell(me, 0, 0, SelectTargetType.AnyFriend, 0, 0, SelectEffect.Aura); + //Find a spell that targets friendly and applies an aura (these are generally buffs) + SpellInfo info = SelectSpell(me, 0, 0, SelectTargetType.AnyFriend, 0, 0, SelectEffect.Aura); - if (info != null && globalCooldown == 0) - { - //Cast the buff spell + if (info != null && globalCooldown == 0) + { + //Cast the buff spell + DoCast(me, info.Id); + + //Set our global cooldown + globalCooldown = GuardsConst.CreatureCooldown; + + //Set our timer to 10 minutes before rebuff + buffTimer = 600000; + } //Try again in 30 seconds + else buffTimer = 30000; + } + else buffTimer -= diff; + } + + //Return since we have no target + if (!UpdateVictim()) + return; + + // Make sure our attack is ready and we arn't currently casting + if (me.isAttackReady() && !me.IsNonMeleeSpellCast(false)) + { + //If we are within range melee the target + if (me.IsWithinMeleeRange(me.GetVictim())) + { + bool healing = false; + SpellInfo info = null; + + //Select a healing spell if less than 30% hp + if (me.HealthBelowPct(30)) + info = SelectSpell(me, 0, 0, SelectTargetType.AnyFriend, 0, 0, SelectEffect.Healing); + + //No healing spell available, select a hostile spell + if (info != null) + healing = true; + else + info = SelectSpell(me.GetVictim(), 0, 0, SelectTargetType.AnyEnemy, 0, 0, SelectEffect.DontCare); + + //20% chance to replace our white hit with a spell + if (info != null && RandomHelper.IRand(0, 99) < 20 && globalCooldown == 0) + { + //Cast the spell + if (healing) DoCast(me, info.Id); + else + DoCastVictim(info.Id); - //Set our global cooldown - globalCooldown = GuardsConst.CreatureCooldown; - - //Set our timer to 10 minutes before rebuff - buffTimer = 600000; - } //Try again in 30 seconds - else buffTimer = 30000; + //Set our global cooldown + globalCooldown = GuardsConst.CreatureCooldown; } - else buffTimer -= diff; + else + me.AttackerStateUpdate(me.GetVictim()); + + me.resetAttackTimer(); } - - //Return since we have no target - if (!UpdateVictim()) - return; - - // Make sure our attack is ready and we arn't currently casting - if (me.isAttackReady() && !me.IsNonMeleeSpellCast(false)) + } + else + { + //Only run this code if we arn't already casting + if (!me.IsNonMeleeSpellCast(false)) { - //If we are within range melee the target - if (me.IsWithinMeleeRange(me.GetVictim())) + bool healing = false; + SpellInfo info = null; + + //Select a healing spell if less than 30% hp ONLY 33% of the time + if (me.HealthBelowPct(30) && 33 > RandomHelper.IRand(0, 99)) + info = SelectSpell(me, 0, 0, SelectTargetType.AnyFriend, 0, 0, SelectEffect.Healing); + + //No healing spell available, See if we can cast a ranged spell (Range must be greater than ATTACK_DISTANCE) + if (info != null) + healing = true; + else + info = SelectSpell(me.GetVictim(), 0, 0, SelectTargetType.AnyEnemy, SharedConst.NominalMeleeRange, 0, SelectEffect.DontCare); + + //Found a spell, check if we arn't on cooldown + if (info != null && globalCooldown == 0) { - bool healing = false; - SpellInfo info = null; - - //Select a healing spell if less than 30% hp - if (me.HealthBelowPct(30)) - info = SelectSpell(me, 0, 0, SelectTargetType.AnyFriend, 0, 0, SelectEffect.Healing); - - //No healing spell available, select a hostile spell - if (info != null) - healing = true; - else - info = SelectSpell(me.GetVictim(), 0, 0, SelectTargetType.AnyEnemy, 0, 0, SelectEffect.DontCare); - - //20% chance to replace our white hit with a spell - if (info != null && RandomHelper.IRand(0, 99) < 20 && globalCooldown == 0) + //If we are currently moving stop us and set the movement generator + if (me.GetMotionMaster().GetCurrentMovementGeneratorType() != MovementGeneratorType.Idle) { - //Cast the spell - if (healing) - DoCast(me, info.Id); - else - DoCastVictim(info.Id); - - //Set our global cooldown - globalCooldown = GuardsConst.CreatureCooldown; - } - else - me.AttackerStateUpdate(me.GetVictim()); - - me.resetAttackTimer(); - } - } - else - { - //Only run this code if we arn't already casting - if (!me.IsNonMeleeSpellCast(false)) - { - bool healing = false; - SpellInfo info = null; - - //Select a healing spell if less than 30% hp ONLY 33% of the time - if (me.HealthBelowPct(30) && 33 > RandomHelper.IRand(0, 99)) - info = SelectSpell(me, 0, 0, SelectTargetType.AnyFriend, 0, 0, SelectEffect.Healing); - - //No healing spell available, See if we can cast a ranged spell (Range must be greater than ATTACK_DISTANCE) - if (info != null) - healing = true; - else - info = SelectSpell(me.GetVictim(), 0, 0, SelectTargetType.AnyEnemy, SharedConst.NominalMeleeRange, 0, SelectEffect.DontCare); - - //Found a spell, check if we arn't on cooldown - if (info != null && globalCooldown == 0) - { - //If we are currently moving stop us and set the movement generator - if (me.GetMotionMaster().GetCurrentMovementGeneratorType() != MovementGeneratorType.Idle) - { - me.GetMotionMaster().Clear(false); - me.GetMotionMaster().MoveIdle(); - } - - //Cast spell - if (healing) - DoCast(me, info.Id); - else - DoCastVictim(info.Id); - - //Set our global cooldown - globalCooldown = GuardsConst.CreatureCooldown; - } //If no spells available and we arn't moving run to target - else if (me.GetMotionMaster().GetCurrentMovementGeneratorType() != MovementGeneratorType.Chase) - { - //Cancel our current spell and then mutate new movement generator - me.InterruptNonMeleeSpells(false); me.GetMotionMaster().Clear(false); - me.GetMotionMaster().MoveChase(me.GetVictim()); + me.GetMotionMaster().MoveIdle(); } + + //Cast spell + if (healing) + DoCast(me, info.Id); + else + DoCastVictim(info.Id); + + //Set our global cooldown + globalCooldown = GuardsConst.CreatureCooldown; + } //If no spells available and we arn't moving run to target + else if (me.GetMotionMaster().GetCurrentMovementGeneratorType() != MovementGeneratorType.Chase) + { + //Cancel our current spell and then mutate new movement generator + me.InterruptNonMeleeSpells(false); + me.GetMotionMaster().Clear(false); + me.GetMotionMaster().MoveChase(me.GetVictim()); } } - - DoMeleeAttackIfReady(); } - public void DoReplyToTextEmote(TextEmotes emote) - { - switch (emote) - { - case TextEmotes.Kiss: - me.HandleEmoteCommand(Emote.OneshotBow); - break; - - case TextEmotes.Wave: - me.HandleEmoteCommand(Emote.OneshotWave); - break; - - case TextEmotes.Salute: - me.HandleEmoteCommand(Emote.OneshotSalute); - break; - - case TextEmotes.Shy: - me.HandleEmoteCommand(Emote.OneshotFlex); - break; - - case TextEmotes.Rude: - case TextEmotes.Chicken: - me.HandleEmoteCommand(Emote.OneshotPoint); - break; - } - } - - public override void ReceiveEmote(Player player, TextEmotes textEmote) - { - switch (me.GetEntry()) - { - case CreatureIds.StormwindCityGuard: - case CreatureIds.StormwindCityPatroller: - case CreatureIds.OrgimmarGrunt: - break; - default: - return; - } - - if (!me.IsFriendlyTo(player)) - return; - - DoReplyToTextEmote(textEmote); - } - - uint globalCooldown; - uint buffTimer; + DoMeleeAttackIfReady(); } - public override CreatureAI GetAI(Creature creature) + public void DoReplyToTextEmote(TextEmotes emote) { - return new guard_genericAI(creature); + switch (emote) + { + case TextEmotes.Kiss: + me.HandleEmoteCommand(Emote.OneshotBow); + break; + + case TextEmotes.Wave: + me.HandleEmoteCommand(Emote.OneshotWave); + break; + + case TextEmotes.Salute: + me.HandleEmoteCommand(Emote.OneshotSalute); + break; + + case TextEmotes.Shy: + me.HandleEmoteCommand(Emote.OneshotFlex); + break; + + case TextEmotes.Rude: + case TextEmotes.Chicken: + me.HandleEmoteCommand(Emote.OneshotPoint); + break; + } } + + public override void ReceiveEmote(Player player, TextEmotes textEmote) + { + switch (me.GetEntry()) + { + case CreatureIds.StormwindCityGuard: + case CreatureIds.StormwindCityPatroller: + case CreatureIds.OrgimmarGrunt: + break; + default: + return; + } + + if (!me.IsFriendlyTo(player)) + return; + + DoReplyToTextEmote(textEmote); + } + + uint globalCooldown; + uint buffTimer; } [Script] - class guard_shattrath_scryer : CreatureScript + class guard_shattrath_scryer : GuardAI { - public guard_shattrath_scryer() : base("guard_shattrath_scryer") { } + public guard_shattrath_scryer(Creature creature) : base(creature) { } - class guard_shattrath_scryerAI : GuardAI + public override void Reset() { - public guard_shattrath_scryerAI(Creature creature) : base(creature) { } + playerGUID.Clear(); + canTeleport = false; - public override void Reset() + _scheduler.Schedule(TimeSpan.FromSeconds(5), task => { - playerGUID.Clear(); - canTeleport = false; - - _scheduler.Schedule(TimeSpan.FromSeconds(5), task => + Unit temp = me.GetVictim(); + if (temp && temp.IsTypeId(TypeId.Player)) { - Unit temp = me.GetVictim(); - if (temp && temp.IsTypeId(TypeId.Player)) - { - DoCast(temp, Spells.BanishedA); - playerGUID = temp.GetGUID(); - if (!playerGUID.IsEmpty()) - canTeleport = true; + DoCast(temp, Spells.BanishedA); + playerGUID = temp.GetGUID(); + if (!playerGUID.IsEmpty()) + canTeleport = true; - task.Repeat(TimeSpan.FromSeconds(9)); - } - }); + task.Repeat(TimeSpan.FromSeconds(9)); + } + }); - _scheduler.Schedule(TimeSpan.FromSeconds(8.5), task => - { - if (canTeleport) - { - Unit temp = Global.ObjAccessor.GetUnit(me, playerGUID); - if (temp) - { - temp.CastSpell(temp, Spells.Exile, true); - temp.CastSpell(temp, Spells.BanishTeleport, true); - } - playerGUID.Clear(); - canTeleport = false; - - task.Repeat(); - } - }); - } - - public override void UpdateAI(uint diff) + _scheduler.Schedule(TimeSpan.FromSeconds(8.5), task => { - if (!UpdateVictim()) - return; + if (canTeleport) + { + Unit temp = Global.ObjAccessor.GetUnit(me, playerGUID); + if (temp) + { + temp.CastSpell(temp, Spells.Exile, true); + temp.CastSpell(temp, Spells.BanishTeleport, true); + } + playerGUID.Clear(); + canTeleport = false; - _scheduler.Update(diff); - - DoMeleeAttackIfReady(); - } - - ObjectGuid playerGUID; - bool canTeleport; + task.Repeat(); + } + }); } - public override CreatureAI GetAI(Creature creature) + public override void UpdateAI(uint diff) { - return new guard_shattrath_scryerAI(creature); + if (!UpdateVictim()) + return; + + _scheduler.Update(diff); + + DoMeleeAttackIfReady(); } + + ObjectGuid playerGUID; + bool canTeleport; } [Script] - class guard_shattrath_aldor : CreatureScript + class guard_shattrath_aldor : GuardAI { - public guard_shattrath_aldor() : base("guard_shattrath_aldor") { } + public guard_shattrath_aldor(Creature creature) : base(creature) { } - class guard_shattrath_aldorAI : GuardAI + public override void Reset() { - public guard_shattrath_aldorAI(Creature creature) : base(creature) { } + playerGUID.Clear(); + canTeleport = false; - public override void Reset() + _scheduler.Schedule(TimeSpan.FromSeconds(5), task => { - playerGUID.Clear(); - canTeleport = false; - - _scheduler.Schedule(TimeSpan.FromSeconds(5), task => + Unit temp = me.GetVictim(); + if (temp && temp.IsTypeId(TypeId.Player)) { - Unit temp = me.GetVictim(); - if (temp && temp.IsTypeId(TypeId.Player)) - { - DoCast(temp, Spells.BanishedA); - playerGUID = temp.GetGUID(); - if (!playerGUID.IsEmpty()) - canTeleport = true; + DoCast(temp, Spells.BanishedA); + playerGUID = temp.GetGUID(); + if (!playerGUID.IsEmpty()) + canTeleport = true; - task.Repeat(TimeSpan.FromSeconds(9)); - } - }); + task.Repeat(TimeSpan.FromSeconds(9)); + } + }); - _scheduler.Schedule(TimeSpan.FromSeconds(8.5), task => - { - if (canTeleport) - { - Unit temp = Global.ObjAccessor.GetUnit(me, playerGUID); - if (temp) - { - temp.CastSpell(temp, Spells.Exile, true); - temp.CastSpell(temp, Spells.BanishTeleport, true); - } - playerGUID.Clear(); - canTeleport = false; - - task.Repeat(); - } - }); - } - - public override void UpdateAI(uint diff) + _scheduler.Schedule(TimeSpan.FromSeconds(8.5), task => { - if (!UpdateVictim()) - return; + if (canTeleport) + { + Unit temp = Global.ObjAccessor.GetUnit(me, playerGUID); + if (temp) + { + temp.CastSpell(temp, Spells.Exile, true); + temp.CastSpell(temp, Spells.BanishTeleport, true); + } + playerGUID.Clear(); + canTeleport = false; - _scheduler.Update(diff); - - DoMeleeAttackIfReady(); - } - - ObjectGuid playerGUID; - bool canTeleport; + task.Repeat(); + } + }); } - public override CreatureAI GetAI(Creature creature) + public override void UpdateAI(uint diff) { - return new guard_shattrath_aldorAI(creature); + if (!UpdateVictim()) + return; + + _scheduler.Update(diff); + + DoMeleeAttackIfReady(); } + + ObjectGuid playerGUID; + bool canTeleport; } } diff --git a/Scripts/World/ItemScripts.cs b/Scripts/World/ItemScripts.cs index 13b1d4450..580fa5938 100644 --- a/Scripts/World/ItemScripts.cs +++ b/Scripts/World/ItemScripts.cs @@ -331,9 +331,11 @@ namespace Scripts.World { pLeviroth.GetAI().AttackStart(player); return false; - } else + } + else player.SendEquipError(InventoryResult.OutOfRange, item, null); - } else + } + else player.SendEquipError(InventoryResult.ClientLockedOut, item, null); return true; } diff --git a/Scripts/World/MobGenericCreature.cs b/Scripts/World/MobGenericCreature.cs index e893c8700..a6e17d96a 100644 --- a/Scripts/World/MobGenericCreature.cs +++ b/Scripts/World/MobGenericCreature.cs @@ -23,25 +23,21 @@ using System; namespace Scripts.World { [Script] - class trigger_periodic : CreatureScript - { - public trigger_periodic() : base("trigger_periodic") { } - - class trigger_periodicAI : NullCreatureAI + class trigger_periodic : NullCreatureAI { - public trigger_periodicAI(Creature creature) : base(creature) + public trigger_periodic(Creature creature) : base(creature) + { + var interval = me.GetBaseAttackTime(Framework.Constants.WeaponAttackType.BaseAttack); + _scheduler.Schedule(TimeSpan.FromMilliseconds(interval), task => { - var interval = me.GetBaseAttackTime(Framework.Constants.WeaponAttackType.BaseAttack); - _scheduler.Schedule(TimeSpan.FromMilliseconds(interval), task => - { - me.CastSpell(me, me.m_spells[0], true); - task.Repeat(TimeSpan.FromMilliseconds(interval)); - }); - } + me.CastSpell(me, me.m_spells[0], true); + task.Repeat(TimeSpan.FromMilliseconds(interval)); + }); + } - public override void UpdateAI(uint diff) - { - _scheduler.Update(); + public override void UpdateAI(uint diff) + { + _scheduler.Update(); } } diff --git a/Scripts/World/NpcProfessions.cs b/Scripts/World/NpcProfessions.cs index 6d7e8b704..1992a9dee 100644 --- a/Scripts/World/NpcProfessions.cs +++ b/Scripts/World/NpcProfessions.cs @@ -53,87 +53,77 @@ namespace Scripts.World } [Script] //start menu multi profession trainer - class npc_multi_profession_trainer : CreatureScript + class npc_multi_profession_trainer : ScriptedAI { - public npc_multi_profession_trainer() : base("npc_multi_profession_trainer") { } + public npc_multi_profession_trainer(Creature creature) : base(creature) { } - class npc_multi_profession_trainerAI : ScriptedAI + public override void sGossipSelect(Player player, uint menuId, uint gossipListId) { - public npc_multi_profession_trainerAI(Creature creature) : base(creature) { } - - public override void sGossipSelect(Player player, uint menuId, uint gossipListId) + switch ((GossipOptionIds)gossipListId) { - switch ((GossipOptionIds)gossipListId) - { - case GossipOptionIds.Alchemy: - case GossipOptionIds.Blacksmithing: - case GossipOptionIds.Enchanting: - case GossipOptionIds.Engineering: - case GossipOptionIds.Herbalism: - case GossipOptionIds.Inscription: - case GossipOptionIds.Jewelcrafting: - case GossipOptionIds.Leatherworking: - case GossipOptionIds.Mining: - case GossipOptionIds.Skinning: - case GossipOptionIds.Tailoring: - SendTrainerList(player, (GossipOptionIds)gossipListId); - break; - case GossipOptionIds.Multi: + case GossipOptionIds.Alchemy: + case GossipOptionIds.Blacksmithing: + case GossipOptionIds.Enchanting: + case GossipOptionIds.Engineering: + case GossipOptionIds.Herbalism: + case GossipOptionIds.Inscription: + case GossipOptionIds.Jewelcrafting: + case GossipOptionIds.Leatherworking: + case GossipOptionIds.Mining: + case GossipOptionIds.Skinning: + case GossipOptionIds.Tailoring: + SendTrainerList(player, (GossipOptionIds)gossipListId); + break; + case GossipOptionIds.Multi: + { + switch ((GossipMenuIds)menuId) { - switch ((GossipMenuIds)menuId) - { - case GossipMenuIds.Herbalism: - SendTrainerList(player, GossipOptionIds.Herbalism); - break; - case GossipMenuIds.Mining: - SendTrainerList(player, GossipOptionIds.Mining); - break; - case GossipMenuIds.Skinning: - SendTrainerList(player, GossipOptionIds.Skinning); - break; - case GossipMenuIds.Alchemy: - SendTrainerList(player, GossipOptionIds.Alchemy); - break; - case GossipMenuIds.Blacksmithing: - SendTrainerList(player, GossipOptionIds.Blacksmithing); - break; - case GossipMenuIds.Enchanting: - SendTrainerList(player, GossipOptionIds.Enchanting); - break; - case GossipMenuIds.Engineering: - SendTrainerList(player, GossipOptionIds.Engineering); - break; - case GossipMenuIds.Inscription: - SendTrainerList(player, GossipOptionIds.Inscription); - break; - case GossipMenuIds.Jewelcrafting: - SendTrainerList(player, GossipOptionIds.Jewelcrafting); - break; - case GossipMenuIds.Leatherworking: - SendTrainerList(player, GossipOptionIds.Leatherworking); - break; - case GossipMenuIds.Tailoring: - SendTrainerList(player, GossipOptionIds.Tailoring); - break; - default: - break; - } + case GossipMenuIds.Herbalism: + SendTrainerList(player, GossipOptionIds.Herbalism); + break; + case GossipMenuIds.Mining: + SendTrainerList(player, GossipOptionIds.Mining); + break; + case GossipMenuIds.Skinning: + SendTrainerList(player, GossipOptionIds.Skinning); + break; + case GossipMenuIds.Alchemy: + SendTrainerList(player, GossipOptionIds.Alchemy); + break; + case GossipMenuIds.Blacksmithing: + SendTrainerList(player, GossipOptionIds.Blacksmithing); + break; + case GossipMenuIds.Enchanting: + SendTrainerList(player, GossipOptionIds.Enchanting); + break; + case GossipMenuIds.Engineering: + SendTrainerList(player, GossipOptionIds.Engineering); + break; + case GossipMenuIds.Inscription: + SendTrainerList(player, GossipOptionIds.Inscription); + break; + case GossipMenuIds.Jewelcrafting: + SendTrainerList(player, GossipOptionIds.Jewelcrafting); + break; + case GossipMenuIds.Leatherworking: + SendTrainerList(player, GossipOptionIds.Leatherworking); + break; + case GossipMenuIds.Tailoring: + SendTrainerList(player, GossipOptionIds.Tailoring); + break; + default: + break; } - break; - default: - break; - } - } - - void SendTrainerList(Player player, GossipOptionIds Index) - { - player.GetSession().SendTrainerList(me.GetGUID(), (uint)Index + 1); + } + break; + default: + break; } } - public override CreatureAI GetAI(Creature creature) + void SendTrainerList(Player player, GossipOptionIds Index) { - return new npc_multi_profession_trainerAI(creature); + player.GetSession().SendTrainerList(me.GetGUID(), (uint)Index + 1); } } -} +} \ No newline at end of file diff --git a/Scripts/World/NpcSpecial.cs b/Scripts/World/NpcSpecial.cs index 46a44faa7..b63e93d4f 100644 --- a/Scripts/World/NpcSpecial.cs +++ b/Scripts/World/NpcSpecial.cs @@ -425,150 +425,140 @@ namespace Scripts.World.NpcSpecial } [Script] - class npc_air_force_bots : CreatureScript + class npc_air_force_bots : ScriptedAI { - public npc_air_force_bots() : base("npc_air_force_bots") { } - - class npc_air_force_botsAI : ScriptedAI + public npc_air_force_bots(Creature creature) : base(creature) { - public npc_air_force_botsAI(Creature creature) : base(creature) + SpawnAssoc = null; + SpawnedGUID.Clear(); + + // find the correct spawnhandling + foreach (var association in NpcSpecialConst.spawnAssociations) { - SpawnAssoc = null; - SpawnedGUID.Clear(); - - // find the correct spawnhandling - foreach (var association in NpcSpecialConst.spawnAssociations) + if (association.thisCreatureEntry == creature.GetEntry()) { - if (association.thisCreatureEntry == creature.GetEntry()) - { - SpawnAssoc = association; - break; - } - } - - if (SpawnAssoc == null) - Log.outError(LogFilter.Sql, "TCSR: Creature template entry {0} has ScriptName npc_air_force_bots, but it's not handled by that script", creature.GetEntry()); - else - { - CreatureTemplate spawnedTemplate = Global.ObjectMgr.GetCreatureTemplate(SpawnAssoc.spawnedCreatureEntry); - if (spawnedTemplate == null) - { - Log.outError(LogFilter.Sql, "TCSR: Creature template entry {0} does not exist in DB, which is required by npc_air_force_bots", SpawnAssoc.spawnedCreatureEntry); - SpawnAssoc = null; - return; - } + SpawnAssoc = association; + break; } } - SpawnAssociation SpawnAssoc; - ObjectGuid SpawnedGUID; - - public override void Reset() { } - - Creature SummonGuard() + if (SpawnAssoc == null) + Log.outError(LogFilter.Sql, "TCSR: Creature template entry {0} has ScriptName npc_air_force_bots, but it's not handled by that script", creature.GetEntry()); + else { - Creature summoned = me.SummonCreature(SpawnAssoc.spawnedCreatureEntry, 0.0f, 0.0f, 0.0f, 0.0f, TempSummonType.TimedDespawnOOC, 300000); - - if (summoned) - SpawnedGUID = summoned.GetGUID(); - else + CreatureTemplate spawnedTemplate = Global.ObjectMgr.GetCreatureTemplate(SpawnAssoc.spawnedCreatureEntry); + if (spawnedTemplate == null) { - Log.outError(LogFilter.Sql, "npc_air_force_bots: wasn't able to spawn Creature {0}", SpawnAssoc.spawnedCreatureEntry); + Log.outError(LogFilter.Sql, "TCSR: Creature template entry {0} does not exist in DB, which is required by npc_air_force_bots", SpawnAssoc.spawnedCreatureEntry); SpawnAssoc = null; + return; } + } + } - return summoned; + SpawnAssociation SpawnAssoc; + ObjectGuid SpawnedGUID; + + public override void Reset() { } + + Creature SummonGuard() + { + Creature summoned = me.SummonCreature(SpawnAssoc.spawnedCreatureEntry, 0.0f, 0.0f, 0.0f, 0.0f, TempSummonType.TimedDespawnOOC, 300000); + + if (summoned) + SpawnedGUID = summoned.GetGUID(); + else + { + Log.outError(LogFilter.Sql, "npc_air_force_bots: wasn't able to spawn Creature {0}", SpawnAssoc.spawnedCreatureEntry); + SpawnAssoc = null; } - Creature GetSummonedGuard() - { - Creature creature = ObjectAccessor.GetCreature(me, SpawnedGUID); - if (creature && creature.IsAlive()) - return creature; + return summoned; + } - return null; - } + Creature GetSummonedGuard() + { + Creature creature = ObjectAccessor.GetCreature(me, SpawnedGUID); + if (creature && creature.IsAlive()) + return creature; - public override void MoveInLineOfSight(Unit who) + return null; + } + + public override void MoveInLineOfSight(Unit who) + { + if (SpawnAssoc == null) + return; + + if (me.IsValidAttackTarget(who)) { - if (SpawnAssoc == null) + Player playerTarget = who.ToPlayer(); + + // airforce guards only spawn for players + if (!playerTarget) return; - if (me.IsValidAttackTarget(who)) + Creature lastSpawnedGuard = SpawnedGUID.IsEmpty() ? null : GetSummonedGuard(); + + // prevent calling Unit::GetUnit at next MoveInLineOfSight call - speedup + if (!lastSpawnedGuard) + SpawnedGUID.Clear(); + + switch (SpawnAssoc.spawnType) { - Player playerTarget = who.ToPlayer(); + case SpawnType.AlarmBot: + { + if (!who.IsWithinDistInMap(me, NpcSpecialConst.RangeGuardsMark)) + return; - // airforce guards only spawn for players - if (!playerTarget) - return; - - Creature lastSpawnedGuard = SpawnedGUID.IsEmpty() ? null : GetSummonedGuard(); - - // prevent calling Unit::GetUnit at next MoveInLineOfSight call - speedup - if (!lastSpawnedGuard) - SpawnedGUID.Clear(); - - switch (SpawnAssoc.spawnType) - { - case SpawnType.AlarmBot: + Aura markAura = who.GetAura(Spells.GuardsMark); + if (markAura != null) { - if (!who.IsWithinDistInMap(me, NpcSpecialConst.RangeGuardsMark)) - return; - - Aura markAura = who.GetAura(Spells.GuardsMark); - if (markAura != null) + // the target wasn't able to move out of our range within 25 seconds + if (!lastSpawnedGuard) { - // the target wasn't able to move out of our range within 25 seconds - if (!lastSpawnedGuard) - { - lastSpawnedGuard = SummonGuard(); - - if (!lastSpawnedGuard) - return; - } - - if (markAura.GetDuration() < NpcSpecialConst.AuraDurationTimeLeft) - if (!lastSpawnedGuard.GetVictim()) - lastSpawnedGuard.GetAI().AttackStart(who); - } - else - { - if (!lastSpawnedGuard) - lastSpawnedGuard = SummonGuard(); + lastSpawnedGuard = SummonGuard(); if (!lastSpawnedGuard) return; - - lastSpawnedGuard.CastSpell(who, Spells.GuardsMark, true); } - break; - } - case SpawnType.TripwireRooftop: - { - if (!who.IsWithinDistInMap(me, NpcSpecialConst.RangeTripwire)) - return; + if (markAura.GetDuration() < NpcSpecialConst.AuraDurationTimeLeft) + if (!lastSpawnedGuard.GetVictim()) + lastSpawnedGuard.GetAI().AttackStart(who); + } + else + { if (!lastSpawnedGuard) lastSpawnedGuard = SummonGuard(); if (!lastSpawnedGuard) return; - // ROOFTOP only triggers if the player is on the ground - if (!playerTarget.IsFlying() && !lastSpawnedGuard.GetVictim()) - lastSpawnedGuard.GetAI().AttackStart(who); - - break; + lastSpawnedGuard.CastSpell(who, Spells.GuardsMark, true); } - } + break; + } + case SpawnType.TripwireRooftop: + { + if (!who.IsWithinDistInMap(me, NpcSpecialConst.RangeTripwire)) + return; + + if (!lastSpawnedGuard) + lastSpawnedGuard = SummonGuard(); + + if (!lastSpawnedGuard) + return; + + // ROOFTOP only triggers if the player is on the ground + if (!playerTarget.IsFlying() && !lastSpawnedGuard.GetVictim()) + lastSpawnedGuard.GetAI().AttackStart(who); + + break; + } } } } - - public override CreatureAI GetAI(Creature creature) - { - return new npc_air_force_botsAI(creature); - } } [Script] @@ -641,15 +631,10 @@ namespace Scripts.World.NpcSpecial } } - public override CreatureAI GetAI(Creature creature) - { - return new npc_chicken_cluckAI(creature); - } - public override bool OnQuestAccept(Player player, Creature creature, Quest quest) { if (quest.Id == QuestConst.Cluck) - ((npc_chicken_cluck.npc_chicken_cluckAI)creature.GetAI()).Reset(); + ((npc_chicken_cluckAI)creature.GetAI()).Reset(); return true; } @@ -657,174 +642,167 @@ namespace Scripts.World.NpcSpecial public override bool OnQuestReward(Player player, Creature creature, Quest quest, uint opt) { if (quest.Id == QuestConst.Cluck) - ((npc_chicken_cluck.npc_chicken_cluckAI)creature.GetAI()).Reset(); + ((npc_chicken_cluckAI)creature.GetAI()).Reset(); return true; } - } - - [Script] - class npc_dancing_flames : CreatureScript - { - public npc_dancing_flames() : base("npc_dancing_flames") { } - - class npc_dancing_flamesAI : ScriptedAI - { - public npc_dancing_flamesAI(Creature creature) : base(creature) - { - Initialize(); - } - - void Initialize() - { - Active = true; - CanIteract = 3500; - } - - bool Active; - uint CanIteract; - - public override void Reset() - { - Initialize(); - DoCast(me, Spells.Brazier, true); - DoCast(me, Spells.FieryAura, false); - float x, y, z; - me.GetPosition(out x, out y, out z); - me.Relocate(x, y, z + 0.94f); - me.SetDisableGravity(true); - me.HandleEmoteCommand(Emote.OneshotDance); - } - - public override void UpdateAI(uint diff) - { - if (!Active) - { - if (CanIteract <= diff) - { - Active = true; - CanIteract = 3500; - me.HandleEmoteCommand(Emote.OneshotDance); - } - else - CanIteract -= diff; - } - } - - public override void EnterCombat(Unit who) { } - - public override void ReceiveEmote(Player player, TextEmotes emote) - { - if (me.IsWithinLOS(player.GetPositionX(), player.GetPositionY(), player.GetPositionZ()) && me.IsWithinDistInMap(player, 30.0f)) - { - me.SetInFront(player); - Active = false; - - switch (emote) - { - case TextEmotes.Kiss: - me.HandleEmoteCommand(Emote.OneshotShy); - break; - case TextEmotes.Wave: - me.HandleEmoteCommand(Emote.OneshotWave); - break; - case TextEmotes.Bow: - me.HandleEmoteCommand(Emote.OneshotBow); - break; - case TextEmotes.Joke: - me.HandleEmoteCommand(Emote.OneshotLaugh); - break; - case TextEmotes.Dance: - if (!player.HasAura(Spells.Seduction)) - DoCast(player, Spells.Seduction, true); - break; - } - } - } - } public override CreatureAI GetAI(Creature creature) { - return new npc_dancing_flamesAI(creature); + return new npc_chicken_cluckAI(creature); } } [Script] - class npc_torch_tossing_target_bunny_controller : CreatureScript + class npc_dancing_flames : ScriptedAI { - public npc_torch_tossing_target_bunny_controller() : base("npc_torch_tossing_target_bunny_controller") { } - - class npc_torch_tossing_target_bunny_controllerAI : ScriptedAI + public npc_dancing_flames(Creature creature) : base(creature) { - public npc_torch_tossing_target_bunny_controllerAI(Creature creature) : base(creature) - { - _targetTimer = 3000; - } + Initialize(); + } - ObjectGuid DoSearchForTargets(ObjectGuid lastTargetGUID) - { - List targets = new List(); - me.GetCreatureListWithEntryInGrid(targets, CreatureIds.TorchTossingTargetBunny, 60.0f); - targets.RemoveAll(creature => { return creature.GetGUID() == lastTargetGUID; }); + void Initialize() + { + Active = true; + CanIteract = 3500; + } - if (!targets.Empty()) + bool Active; + uint CanIteract; + + public override void Reset() + { + Initialize(); + DoCast(me, Spells.Brazier, true); + DoCast(me, Spells.FieryAura, false); + float x, y, z; + me.GetPosition(out x, out y, out z); + me.Relocate(x, y, z + 0.94f); + me.SetDisableGravity(true); + me.HandleEmoteCommand(Emote.OneshotDance); + } + + public override void UpdateAI(uint diff) + { + if (!Active) + { + if (CanIteract <= diff) { - _lastTargetGUID = targets.SelectRandom().GetGUID(); - - return _lastTargetGUID; - } - return ObjectGuid.Empty; - } - - public override void UpdateAI(uint diff) - { - if (_targetTimer < diff) - { - Unit target = Global.ObjAccessor.GetUnit(me, DoSearchForTargets(_lastTargetGUID)); - if (target) - target.CastSpell(target, Spells.TargetIndicator, true); - - _targetTimer = 3000; + Active = true; + CanIteract = 3500; + me.HandleEmoteCommand(Emote.OneshotDance); } else - _targetTimer -= diff; + CanIteract -= diff; } - - uint _targetTimer; - ObjectGuid _lastTargetGUID; } - public override CreatureAI GetAI(Creature creature) + public override void EnterCombat(Unit who) { } + + public override void ReceiveEmote(Player player, TextEmotes emote) { - return new npc_torch_tossing_target_bunny_controllerAI(creature); + if (me.IsWithinLOS(player.GetPositionX(), player.GetPositionY(), player.GetPositionZ()) && me.IsWithinDistInMap(player, 30.0f)) + { + me.SetInFront(player); + Active = false; + + switch (emote) + { + case TextEmotes.Kiss: + me.HandleEmoteCommand(Emote.OneshotShy); + break; + case TextEmotes.Wave: + me.HandleEmoteCommand(Emote.OneshotWave); + break; + case TextEmotes.Bow: + me.HandleEmoteCommand(Emote.OneshotBow); + break; + case TextEmotes.Joke: + me.HandleEmoteCommand(Emote.OneshotLaugh); + break; + case TextEmotes.Dance: + if (!player.HasAura(Spells.Seduction)) + DoCast(player, Spells.Seduction, true); + break; + } + } } } [Script] - class npc_midsummer_bunny_pole : CreatureScript + class npc_torch_tossing_target_bunny_controller : ScriptedAI { - public npc_midsummer_bunny_pole() : base("npc_midsummer_bunny_pole") { } - - class npc_midsummer_bunny_poleAI : ScriptedAI + public npc_torch_tossing_target_bunny_controller(Creature creature) : base(creature) { - public npc_midsummer_bunny_poleAI(Creature creature) : base(creature) + _targetTimer = 3000; + } + + ObjectGuid DoSearchForTargets(ObjectGuid lastTargetGUID) + { + List targets = new List(); + me.GetCreatureListWithEntryInGrid(targets, CreatureIds.TorchTossingTargetBunny, 60.0f); + targets.RemoveAll(creature => { return creature.GetGUID() == lastTargetGUID; }); + + if (!targets.Empty()) { - Initialize(); + _lastTargetGUID = targets.SelectRandom().GetGUID(); + + return _lastTargetGUID; } + return ObjectGuid.Empty; + } - void Initialize() + public override void UpdateAI(uint diff) + { + if (_targetTimer < diff) { - _scheduler.CancelAll(); - running = false; + Unit target = Global.ObjAccessor.GetUnit(me, DoSearchForTargets(_lastTargetGUID)); + if (target) + target.CastSpell(target, Spells.TargetIndicator, true); + + _targetTimer = 3000; } + else + _targetTimer -= diff; + } - public override void Reset() + uint _targetTimer; + ObjectGuid _lastTargetGUID; + } + + [Script] + class npc_midsummer_bunny_pole : ScriptedAI + { + public npc_midsummer_bunny_pole(Creature creature) : base(creature) + { + Initialize(); + } + + void Initialize() + { + _scheduler.CancelAll(); + running = false; + } + + public override void Reset() + { + Initialize(); + + _scheduler.SetValidator(() => { return running; }); + + _scheduler.Schedule(TimeSpan.FromMilliseconds(1), task => { - Initialize(); + if (checkNearbyPlayers()) + { + Reset(); + return; + } - _scheduler.SetValidator(() => { return running; }); + GameObject go = me.FindNearestGameObject(GameobjectIds.RibbonPole, 10.0f); + if (go) + me.CastSpell(go, Spells.RedFireRing, true); - _scheduler.Schedule(TimeSpan.FromMilliseconds(1), task => + task.Schedule(TimeSpan.FromSeconds(5), task1 => { if (checkNearbyPlayers()) { @@ -832,63 +810,45 @@ namespace Scripts.World.NpcSpecial return; } - GameObject go = me.FindNearestGameObject(GameobjectIds.RibbonPole, 10.0f); + go = me.FindNearestGameObject(GameobjectIds.RibbonPole, 10.0f); if (go) - me.CastSpell(go, Spells.RedFireRing, true); + me.CastSpell(go, Spells.BlueFireRing, true); - task.Schedule(TimeSpan.FromSeconds(5), task1 => - { - if (checkNearbyPlayers()) - { - Reset(); - return; - } - - go = me.FindNearestGameObject(GameobjectIds.RibbonPole, 10.0f); - if (go) - me.CastSpell(go, Spells.BlueFireRing, true); - - task.Repeat(TimeSpan.FromSeconds(5)); - }); + task.Repeat(TimeSpan.FromSeconds(5)); }); - } - - public override void DoAction(int action) - { - // Don't start event if it's already running. - if (running) - return; - - running = true; - //events.ScheduleEvent(EVENT_CAST_RED_FIRE_RING, 1); - } - - bool checkNearbyPlayers() - { - // Returns true if no nearby player has aura "Test Ribbon Pole Channel". - List players = new List(); - var check = new UnitAuraCheck(true, Spells.RibbonDanceCosmetic); - var searcher = new PlayerListSearcher(me, players, check); - Cell.VisitWorldObjects(me, searcher, 10.0f); - - return players.Empty(); - } - - public override void UpdateAI(uint diff) - { - if (!running) - return; - - _scheduler.Update(diff); - } - - bool running; + }); } - public override CreatureAI GetAI(Creature creature) + public override void DoAction(int action) { - return new npc_midsummer_bunny_poleAI(creature); + // Don't start event if it's already running. + if (running) + return; + + running = true; + //events.ScheduleEvent(EVENT_CAST_RED_FIRE_RING, 1); } + + bool checkNearbyPlayers() + { + // Returns true if no nearby player has aura "Test Ribbon Pole Channel". + List players = new List(); + var check = new UnitAuraCheck(true, Spells.RibbonDanceCosmetic); + var searcher = new PlayerListSearcher(me, players, check); + Cell.VisitWorldObjects(me, searcher, 10.0f); + + return players.Empty(); + } + + public override void UpdateAI(uint diff) + { + if (!running) + return; + + _scheduler.Update(diff); + } + + bool running; } [Script] @@ -1047,8 +1007,8 @@ namespace Scripts.World.NpcSpecial Patient.SetFlag(UnitFields.Flags, UnitFlags.PvpAttackable); Patients.Add(Patient.GetGUID()); - ((npc_injured_patient.npc_injured_patientAI)Patient.GetAI()).DoctorGUID = me.GetGUID(); - ((npc_injured_patient.npc_injured_patientAI)Patient.GetAI()).Coord = Coordinates[index]; + ((npc_injured_patient)Patient.GetAI()).DoctorGUID = me.GetGUID(); + ((npc_injured_patient)Patient.GetAI()).Coord = Coordinates[index]; Coordinates.RemoveAt(index); } @@ -1091,310 +1051,280 @@ namespace Scripts.World.NpcSpecial } [Script] - class npc_injured_patient : CreatureScript + public class npc_injured_patient : ScriptedAI { - public npc_injured_patient() : base("npc_injured_patient") { } - - public class npc_injured_patientAI : ScriptedAI + public npc_injured_patient(Creature creature) : base(creature) { - public npc_injured_patientAI(Creature creature) : base(creature) - { - Initialize(); - } + Initialize(); + } - void Initialize() - { - DoctorGUID.Clear(); - Coord = null; - } + void Initialize() + { + DoctorGUID.Clear(); + Coord = null; + } - public ObjectGuid DoctorGUID; - public Position Coord; + public ObjectGuid DoctorGUID; + public Position Coord; - public override void Reset() - { - Initialize(); + public override void Reset() + { + Initialize(); - //no select - me.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable); + //no select + me.RemoveFlag(UnitFields.Flags, UnitFlags.NotSelectable); - //no regen health - me.SetFlag(UnitFields.Flags, UnitFlags.InCombat); + //no regen health + me.SetFlag(UnitFields.Flags, UnitFlags.InCombat); - //to make them lay with face down - me.SetUInt32Value(UnitFields.Bytes1, (uint)UnitStandStateType.Dead); + //to make them lay with face down + me.SetUInt32Value(UnitFields.Bytes1, (uint)UnitStandStateType.Dead); - uint mobId = me.GetEntry(); + uint mobId = me.GetEntry(); - switch (mobId) - { //lower max health - case 12923: - case 12938: //Injured Soldier - me.SetHealth(me.CountPctFromMaxHealth(75)); - break; - case 12924: - case 12936: //Badly injured Soldier - me.SetHealth(me.CountPctFromMaxHealth(50)); - break; - case 12925: - case 12937: //Critically injured Soldier - me.SetHealth(me.CountPctFromMaxHealth(25)); - break; - } - } - - public override void EnterCombat(Unit who) { } - - public override void SpellHit(Unit caster, SpellInfo spell) - { - Player player = caster.ToPlayer(); - if (!player || !me.IsAlive() || spell.Id != 20804) - return; - - if (player.GetQuestStatus(6624) == QuestStatus.Incomplete || player.GetQuestStatus(6622) == QuestStatus.Incomplete) - { - if (!DoctorGUID.IsEmpty()) - { - Creature doctor = ObjectAccessor.GetCreature(me, DoctorGUID); - if (doctor) - ((npc_doctor.npc_doctorAI)doctor.GetAI()).PatientSaved(me, player, Coord); - } - } - - //make not selectable - me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable); - - //regen health - me.RemoveFlag(UnitFields.Flags, UnitFlags.InCombat); - - //stand up - me.SetUInt32Value(UnitFields.Bytes1, (uint)UnitStandStateType.Stand); - - Talk(Texts.SayDoc); - - uint mobId = me.GetEntry(); - me.SetWalk(false); - - switch (mobId) - { - case 12923: - case 12924: - case 12925: - me.GetMotionMaster().MovePoint(0, NpcSpecialConst.DoctorHordeRunTo); - break; - case 12936: - case 12937: - case 12938: - me.GetMotionMaster().MovePoint(0, NpcSpecialConst.DoctorAllianceRunTo); - break; - } - } - - public override void UpdateAI(uint diff) - { - //lower HP on every world tick makes it a useful counter, not officlone though - if (me.IsAlive() && me.GetHealth() > 6) - me.ModifyHealth(-5); - - if (me.IsAlive() && me.GetHealth() <= 6) - { - me.RemoveFlag(UnitFields.Flags, UnitFlags.InCombat); - me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable); - me.setDeathState(DeathState.JustDied); - me.SetFlag(ObjectFields.DynamicFlags, 32); - - if (!DoctorGUID.IsEmpty()) - { - Creature doctor = ObjectAccessor.GetCreature((me), DoctorGUID); - if (doctor) - ((npc_doctor.npc_doctorAI)doctor.GetAI()).PatientDied(Coord); - } - } + switch (mobId) + { //lower max health + case 12923: + case 12938: //Injured Soldier + me.SetHealth(me.CountPctFromMaxHealth(75)); + break; + case 12924: + case 12936: //Badly injured Soldier + me.SetHealth(me.CountPctFromMaxHealth(50)); + break; + case 12925: + case 12937: //Critically injured Soldier + me.SetHealth(me.CountPctFromMaxHealth(25)); + break; } } - public override CreatureAI GetAI(Creature creature) + public override void EnterCombat(Unit who) { } + + public override void SpellHit(Unit caster, SpellInfo spell) { - return new npc_injured_patientAI(creature); + Player player = caster.ToPlayer(); + if (!player || !me.IsAlive() || spell.Id != 20804) + return; + + if (player.GetQuestStatus(6624) == QuestStatus.Incomplete || player.GetQuestStatus(6622) == QuestStatus.Incomplete) + { + if (!DoctorGUID.IsEmpty()) + { + Creature doctor = ObjectAccessor.GetCreature(me, DoctorGUID); + if (doctor) + ((npc_doctor.npc_doctorAI)doctor.GetAI()).PatientSaved(me, player, Coord); + } + } + + //make not selectable + me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable); + + //regen health + me.RemoveFlag(UnitFields.Flags, UnitFlags.InCombat); + + //stand up + me.SetUInt32Value(UnitFields.Bytes1, (uint)UnitStandStateType.Stand); + + Talk(Texts.SayDoc); + + uint mobId = me.GetEntry(); + me.SetWalk(false); + + switch (mobId) + { + case 12923: + case 12924: + case 12925: + me.GetMotionMaster().MovePoint(0, NpcSpecialConst.DoctorHordeRunTo); + break; + case 12936: + case 12937: + case 12938: + me.GetMotionMaster().MovePoint(0, NpcSpecialConst.DoctorAllianceRunTo); + break; + } + } + + public override void UpdateAI(uint diff) + { + //lower HP on every world tick makes it a useful counter, not officlone though + if (me.IsAlive() && me.GetHealth() > 6) + me.ModifyHealth(-5); + + if (me.IsAlive() && me.GetHealth() <= 6) + { + me.RemoveFlag(UnitFields.Flags, UnitFlags.InCombat); + me.SetFlag(UnitFields.Flags, UnitFlags.NotSelectable); + me.setDeathState(DeathState.JustDied); + me.SetFlag(ObjectFields.DynamicFlags, 32); + + if (!DoctorGUID.IsEmpty()) + { + Creature doctor = ObjectAccessor.GetCreature((me), DoctorGUID); + if (doctor) + ((npc_doctor.npc_doctorAI)doctor.GetAI()).PatientDied(Coord); + } + } } } [Script] - class npc_garments_of_quests : CreatureScript + class npc_garments_of_quests : npc_escortAI { - public npc_garments_of_quests() : base("npc_garments_of_quests") { } - - class npc_garments_of_questsAI : npc_escortAI + public npc_garments_of_quests(Creature creature) : base(creature) { - public npc_garments_of_questsAI(Creature creature) : base(creature) + switch (me.GetEntry()) { - switch (me.GetEntry()) - { - case CreatureIds.Shaya: - quest = QuestConst.Moon; - break; - case CreatureIds.Roberts: - quest = QuestConst.Light1; - break; - case CreatureIds.Dolf: - quest = QuestConst.Light2; - break; - case CreatureIds.Korja: - quest = QuestConst.Spirit; - break; - case CreatureIds.DgKel: - quest = QuestConst.Darkness; - break; - default: - quest = 0; - break; - } - - Reset(); + case CreatureIds.Shaya: + quest = QuestConst.Moon; + break; + case CreatureIds.Roberts: + quest = QuestConst.Light1; + break; + case CreatureIds.Dolf: + quest = QuestConst.Light2; + break; + case CreatureIds.Korja: + quest = QuestConst.Spirit; + break; + case CreatureIds.DgKel: + quest = QuestConst.Darkness; + break; + default: + quest = 0; + break; } - ObjectGuid CasterGUID; + Reset(); + } - bool IsHealed; - bool CanRun; + ObjectGuid CasterGUID; - uint RunAwayTimer; - uint quest; + bool IsHealed; + bool CanRun; - public override void Reset() + uint RunAwayTimer; + uint quest; + + public override void Reset() + { + CasterGUID.Clear(); + + IsHealed = false; + CanRun = false; + + RunAwayTimer = 5000; + + me.SetStandState(UnitStandStateType.Kneel); + // expect database to have RegenHealth=0 + me.SetHealth(me.CountPctFromMaxHealth(70)); + } + + public override void EnterCombat(Unit who) { } + + public override void SpellHit(Unit caster, SpellInfo spell) + { + if (spell.Id == Spells.LesserHealR2 || spell.Id == Spells.FortitudeR1) { - CasterGUID.Clear(); + //not while in combat + if (me.IsInCombat()) + return; - IsHealed = false; - CanRun = false; + //nothing to be done now + if (IsHealed && CanRun) + return; - RunAwayTimer = 5000; - - me.SetStandState(UnitStandStateType.Kneel); - // expect database to have RegenHealth=0 - me.SetHealth(me.CountPctFromMaxHealth(70)); - } - - public override void EnterCombat(Unit who) { } - - public override void SpellHit(Unit caster, SpellInfo spell) - { - if (spell.Id == Spells.LesserHealR2 || spell.Id == Spells.FortitudeR1) + Player player = caster.ToPlayer(); + if (player) { - //not while in combat - if (me.IsInCombat()) - return; - - //nothing to be done now - if (IsHealed && CanRun) - return; - - Player player = caster.ToPlayer(); - if (player) + if (quest != 0 && player.GetQuestStatus(quest) == QuestStatus.Incomplete) { - if (quest != 0 && player.GetQuestStatus(quest) == QuestStatus.Incomplete) + if (IsHealed && !CanRun && spell.Id == Spells.FortitudeR1) { - if (IsHealed && !CanRun && spell.Id == Spells.FortitudeR1) - { - Talk(Texts.SayThanks, caster); - CanRun = true; - } - else if (!IsHealed && spell.Id == Spells.LesserHealR2) - { - CasterGUID = caster.GetGUID(); - me.SetStandState(UnitStandStateType.Stand); - Talk(Texts.SayHealed, caster); - IsHealed = true; - } + Talk(Texts.SayThanks, caster); + CanRun = true; + } + else if (!IsHealed && spell.Id == Spells.LesserHealR2) + { + CasterGUID = caster.GetGUID(); + me.SetStandState(UnitStandStateType.Stand); + Talk(Texts.SayHealed, caster); + IsHealed = true; } - - // give quest credit, not expect any special quest objectives - if (CanRun) - player.TalkedToCreature(me.GetEntry(), me.GetGUID()); } + + // give quest credit, not expect any special quest objectives + if (CanRun) + player.TalkedToCreature(me.GetEntry(), me.GetGUID()); } } + } - public override void WaypointReached(uint waypointId) + public override void WaypointReached(uint waypointId) + { + + } + + public override void UpdateAI(uint diff) + { + if (CanRun && !me.IsInCombat()) { - - } - - public override void UpdateAI(uint diff) - { - if (CanRun && !me.IsInCombat()) + if (RunAwayTimer <= diff) { - if (RunAwayTimer <= diff) + Unit unit = Global.ObjAccessor.GetUnit(me, CasterGUID); + if (unit) { - Unit unit = Global.ObjAccessor.GetUnit(me, CasterGUID); - if (unit) + switch (me.GetEntry()) { - switch (me.GetEntry()) - { - case CreatureIds.Shaya: - case CreatureIds.Roberts: - case CreatureIds.Dolf: - case CreatureIds.Korja: - case CreatureIds.DgKel: - Talk(Texts.SayGoodbye, unit); - break; - } - - Start(false, true); + case CreatureIds.Shaya: + case CreatureIds.Roberts: + case CreatureIds.Dolf: + case CreatureIds.Korja: + case CreatureIds.DgKel: + Talk(Texts.SayGoodbye, unit); + break; } - else - EnterEvadeMode(); //something went wrong - RunAwayTimer = 30000; + Start(false, true); } else - RunAwayTimer -= diff; + EnterEvadeMode(); //something went wrong + + RunAwayTimer = 30000; } - - base.UpdateAI(diff); + else + RunAwayTimer -= diff; } - } - public override CreatureAI GetAI(Creature creature) - { - return new npc_garments_of_questsAI(creature); + base.UpdateAI(diff); } } [Script] - class npc_guardian : CreatureScript + class npc_guardian : ScriptedAI { - public npc_guardian() : base("npc_guardian") { } + public npc_guardian(Creature creature) : base(creature) { } - class npc_guardianAI : ScriptedAI + public override void Reset() { - public npc_guardianAI(Creature creature) : base(creature) { } - - public override void Reset() - { - me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable); - } - - public override void EnterCombat(Unit who) - { - } - - public override void UpdateAI(uint diff) - { - if (!UpdateVictim()) - return; - - if (me.isAttackReady()) - { - DoCastVictim(Spells.Deathtouch, true); - me.resetAttackTimer(); - } - } + me.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable); } - public override CreatureAI GetAI(Creature creature) + public override void EnterCombat(Unit who) { - return new npc_guardianAI(creature); + } + + public override void UpdateAI(uint diff) + { + if (!UpdateVictim()) + return; + + if (me.isAttackReady()) + { + DoCastVictim(Spells.Deathtouch, true); + me.resetAttackTimer(); + } } } @@ -1517,202 +1447,163 @@ namespace Scripts.World.NpcSpecial } } - [Script] - class npc_steam_tonk : CreatureScript - { - public npc_steam_tonk() : base("npc_steam_tonk") { } - - class npc_steam_tonkAI : ScriptedAI - { - public npc_steam_tonkAI(Creature creature) : base(creature) { } - - public override void Reset() { } - public override void EnterCombat(Unit who) { } - - public override void OnPossess(bool apply) - { - if (apply) - { - // Initialize the action bar without the melee attack command - me.InitCharmInfo(); - me.GetCharmInfo().InitEmptyActionBar(false); - - me.SetReactState(ReactStates.Passive); - } - else - me.SetReactState(ReactStates.Aggressive); - } - } - - public override CreatureAI GetAI(Creature creature) - { - return new npc_steam_tonkAI(creature); - } - } [Script] - class npc_tonk_mine : CreatureScript + class npc_steam_tonk : ScriptedAI { - public npc_tonk_mine() : base("npc_tonk_mine") { } + public npc_steam_tonk(Creature creature) : base(creature) { } - class npc_tonk_mineAI : ScriptedAI + public override void Reset() { } + public override void EnterCombat(Unit who) { } + + public override void OnPossess(bool apply) { - public npc_tonk_mineAI(Creature creature) : base(creature) + if (apply) { - Initialize(); + // Initialize the action bar without the melee attack command + me.InitCharmInfo(); + me.GetCharmInfo().InitEmptyActionBar(false); + me.SetReactState(ReactStates.Passive); } - - void Initialize() - { - ExplosionTimer = 3000; - } - - uint ExplosionTimer; - - public override void Reset() - { - Initialize(); - } - - public override void EnterCombat(Unit who) { } - public override void AttackStart(Unit who) { } - public override void MoveInLineOfSight(Unit who) { } - - public override void UpdateAI(uint diff) - { - if (ExplosionTimer <= diff) - { - DoCast(me, Spells.TonkMineDetonate, true); - me.setDeathState(DeathState.Dead); // unsummon it - } - else - ExplosionTimer -= diff; - } - } - - public override CreatureAI GetAI(Creature creature) - { - return new npc_tonk_mineAI(creature); + else + me.SetReactState(ReactStates.Aggressive); } } [Script] - class npc_brewfest_reveler : CreatureScript + class npc_tonk_mine : ScriptedAI { - public npc_brewfest_reveler() : base("npc_brewfest_reveler") { } - - class npc_brewfest_revelerAI : ScriptedAI + public npc_tonk_mine(Creature creature) : base(creature) { - public npc_brewfest_revelerAI(Creature creature) : base(creature) { } - - public override void ReceiveEmote(Player player, TextEmotes emote) - { - if (!Global.GameEventMgr.IsHolidayActive(HolidayIds.Brewfest)) - return; - - if (emote == TextEmotes.Dance) - me.CastSpell(player, Spells.BrewfestToast, false); - } + Initialize(); + me.SetReactState(ReactStates.Passive); } - public override CreatureAI GetAI(Creature creature) + void Initialize() { - return new npc_brewfest_revelerAI(creature); + ExplosionTimer = 3000; + } + + uint ExplosionTimer; + + public override void Reset() + { + Initialize(); + } + + public override void EnterCombat(Unit who) { } + public override void AttackStart(Unit who) { } + public override void MoveInLineOfSight(Unit who) { } + + public override void UpdateAI(uint diff) + { + if (ExplosionTimer <= diff) + { + DoCast(me, Spells.TonkMineDetonate, true); + me.setDeathState(DeathState.Dead); // unsummon it + } + else + ExplosionTimer -= diff; } } [Script] - class npc_training_dummy : CreatureScript + class npc_brewfest_reveler : ScriptedAI { - public npc_training_dummy() : base("npc_training_dummy") { } + public npc_brewfest_reveler(Creature creature) : base(creature) { } - class npc_training_dummyAI : ScriptedAI + public override void ReceiveEmote(Player player, TextEmotes emote) { - public npc_training_dummyAI(Creature creature) : base(creature) - { - SetCombatMovement(false); - } + if (!Global.GameEventMgr.IsHolidayActive(HolidayIds.Brewfest)) + return; - public override void Reset() - { - // TODO: solve this in a different way! setting them as stunned prevents dummies from parrying + if (emote == TextEmotes.Dance) + me.CastSpell(player, Spells.BrewfestToast, false); + } + } + + [Script] + class npc_training_dummy : ScriptedAI + { + public npc_training_dummy(Creature creature) : base(creature) + { + SetCombatMovement(false); + } + + public override void Reset() + { + // TODO: solve this in a different way! setting them as stunned prevents dummies from parrying + me.SetControlled(true, UnitState.Stunned);//disable rotate + + _events.Reset(); + _damageTimes.Clear(); + if (me.GetEntry() != AdvancedTargetDummy && me.GetEntry() != TargetDummy) + _events.ScheduleEvent(EventCheckCombat, 1000); + else + _events.ScheduleEvent(EventDespawn, 15000); + } + + public override void EnterEvadeMode(EvadeReason why) + { + if (!_EnterEvadeMode(why)) + return; + + Reset(); + } + + public override void DamageTaken(Unit doneBy, ref uint damage) + { + me.AddThreat(doneBy, damage); // just to create threat reference + _damageTimes[doneBy.GetGUID()] = Time.UnixTime; + damage = 0; + } + + public override void UpdateAI(uint diff) + { + if (!me.IsInCombat()) + return; + + if (!me.HasUnitState(UnitState.Stunned)) me.SetControlled(true, UnitState.Stunned);//disable rotate - _events.Reset(); - _damageTimes.Clear(); - if (me.GetEntry() != AdvancedTargetDummy && me.GetEntry() != TargetDummy) - _events.ScheduleEvent(EventCheckCombat, 1000); - else - _events.ScheduleEvent(EventDespawn, 15000); - } + _events.Update(diff); - public override void EnterEvadeMode(EvadeReason why) + _events.ExecuteEvents(eventId => { - if (!_EnterEvadeMode(why)) - return; - - Reset(); - } - - public override void DamageTaken(Unit doneBy, ref uint damage) - { - me.AddThreat(doneBy, damage); // just to create threat reference - _damageTimes[doneBy.GetGUID()] = Time.UnixTime; - damage = 0; - } - - public override void UpdateAI(uint diff) - { - if (!me.IsInCombat()) - return; - - if (!me.HasUnitState(UnitState.Stunned)) - me.SetControlled(true, UnitState.Stunned);//disable rotate - - _events.Update(diff); - - _events.ExecuteEvents(eventId => + switch (eventId) { - switch (eventId) - { - case EventCheckCombat: - long now = Time.UnixTime; - foreach (var pair in _damageTimes.ToList()) + case EventCheckCombat: + long now = Time.UnixTime; + foreach (var pair in _damageTimes.ToList()) + { + // If unit has not dealt damage to training dummy for 5 seconds, remove him from combat + if (pair.Value < now - 5) { - // If unit has not dealt damage to training dummy for 5 seconds, remove him from combat - if (pair.Value < now - 5) - { - Unit unit = Global.ObjAccessor.GetUnit(me, pair.Key); - if (unit) - unit.getHostileRefManager().deleteReference(me); + Unit unit = Global.ObjAccessor.GetUnit(me, pair.Key); + if (unit) + unit.getHostileRefManager().deleteReference(me); - _damageTimes.Remove(pair.Key); - } + _damageTimes.Remove(pair.Key); } - _events.ScheduleEvent(EventCheckCombat, 1000); - break; - case EventDespawn: - me.DespawnOrUnsummon(); - break; - } - }); - } - - public override void MoveInLineOfSight(Unit who) { } - - Dictionary _damageTimes = new Dictionary(); - - const int EventCheckCombat = 1; - const int EventDespawn = 2; - const uint AdvancedTargetDummy = 2674; - const uint TargetDummy = 2673; + } + _events.ScheduleEvent(EventCheckCombat, 1000); + break; + case EventDespawn: + me.DespawnOrUnsummon(); + break; + } + }); } - public override CreatureAI GetAI(Creature creature) - { - return new npc_training_dummyAI(creature); - } + public override void MoveInLineOfSight(Unit who) { } + + Dictionary _damageTimes = new Dictionary(); + + const int EventCheckCombat = 1; + const int EventDespawn = 2; + const uint AdvancedTargetDummy = 2674; + const uint TargetDummy = 2673; } [Script] @@ -1809,28 +1700,18 @@ namespace Scripts.World.NpcSpecial } [Script] - class npc_pet_trainer : CreatureScript + class npc_pet_trainer : ScriptedAI { - public npc_pet_trainer() : base("npc_pet_trainer") { } + public npc_pet_trainer(Creature creature) : base(creature) { } - class npc_pet_trainerAI : ScriptedAI + public override void sGossipSelect(Player player, uint menuId, uint gossipListId) { - public npc_pet_trainerAI(Creature creature) : base(creature) { } - - public override void sGossipSelect(Player player, uint menuId, uint gossipListId) + if (menuId == GossipMenus.MenuIdPetUnlearn && gossipListId == GossipMenus.OptionIdPleaseDo) { - if (menuId == GossipMenus.MenuIdPetUnlearn && gossipListId == GossipMenus.OptionIdPleaseDo) - { - player.ResetPetTalents(); - player.CLOSE_GOSSIP_MENU(); - } + player.ResetPetTalents(); + player.CLOSE_GOSSIP_MENU(); } } - - public override CreatureAI GetAI(Creature creature) - { - return new npc_pet_trainerAI(creature); - } } [Script] @@ -1873,360 +1754,330 @@ namespace Scripts.World.NpcSpecial } [Script] - class npc_firework : CreatureScript + class npc_firework : ScriptedAI { - public npc_firework() : base("npc_firework") { } + public npc_firework(Creature creature) : base(creature) { } - class npc_fireworkAI : ScriptedAI + bool isCluster() { - public npc_fireworkAI(Creature creature) : base(creature) { } - - bool isCluster() + switch (me.GetEntry()) { - switch (me.GetEntry()) - { - case CreatureIds.FireworkBlue: - case CreatureIds.FireworkGreen: - case CreatureIds.FireworkPurple: - case CreatureIds.FireworkRed: - case CreatureIds.FireworkYellow: - case CreatureIds.FireworkWhite: - case CreatureIds.FireworkBigBlue: - case CreatureIds.FireworkBigGreen: - case CreatureIds.FireworkBigPurple: - case CreatureIds.FireworkBigRed: - case CreatureIds.FireworkBigYellow: - case CreatureIds.FireworkBigWhite: - return false; - case CreatureIds.ClusterBlue: - case CreatureIds.ClusterGreen: - case CreatureIds.ClusterPurple: - case CreatureIds.ClusterRed: - case CreatureIds.ClusterYellow: - case CreatureIds.ClusterWhite: - case CreatureIds.ClusterBigBlue: - case CreatureIds.ClusterBigGreen: - case CreatureIds.ClusterBigPurple: - case CreatureIds.ClusterBigRed: - case CreatureIds.ClusterBigYellow: - case CreatureIds.ClusterBigWhite: - case CreatureIds.ClusterElune: - default: - return true; - } - } - - GameObject FindNearestLauncher() - { - GameObject launcher = null; - - if (isCluster()) - { - GameObject launcher1 = GetClosestGameObjectWithEntry(me, GameobjectIds.ClusterLauncher1, 0.5f); - GameObject launcher2 = GetClosestGameObjectWithEntry(me, GameobjectIds.ClusterLauncher2, 0.5f); - GameObject launcher3 = GetClosestGameObjectWithEntry(me, GameobjectIds.ClusterLauncher3, 0.5f); - GameObject launcher4 = GetClosestGameObjectWithEntry(me, GameobjectIds.ClusterLauncher4, 0.5f); - - if (launcher1) - launcher = launcher1; - else if (launcher2) - launcher = launcher2; - else if (launcher3) - launcher = launcher3; - else if (launcher4) - launcher = launcher4; - } - else - { - GameObject launcher1 = GetClosestGameObjectWithEntry(me, GameobjectIds.FireworkLauncher1, 0.5f); - GameObject launcher2 = GetClosestGameObjectWithEntry(me, GameobjectIds.FireworkLauncher2, 0.5f); - GameObject launcher3 = GetClosestGameObjectWithEntry(me, GameobjectIds.FireworkLauncher3, 0.5f); - - if (launcher1) - launcher = launcher1; - else if (launcher2) - launcher = launcher2; - else if (launcher3) - launcher = launcher3; - } - - return launcher; - } - - uint GetFireworkSpell(uint entry) - { - switch (entry) - { - case CreatureIds.FireworkBlue: - return Spells.RocketBlue; - case CreatureIds.FireworkGreen: - return Spells.RocketGreen; - case CreatureIds.FireworkPurple: - return Spells.RocketPurple; - case CreatureIds.FireworkRed: - return Spells.RocketRed; - case CreatureIds.FireworkYellow: - return Spells.RocketYellow; - case CreatureIds.FireworkWhite: - return Spells.RocketWhite; - case CreatureIds.FireworkBigBlue: - return Spells.RocketBigBlue; - case CreatureIds.FireworkBigGreen: - return Spells.RocketBigGreen; - case CreatureIds.FireworkBigPurple: - return Spells.RocketBigPurple; - case CreatureIds.FireworkBigRed: - return Spells.RocketBigRed; - case CreatureIds.FireworkBigYellow: - return Spells.RocketBigYellow; - case CreatureIds.FireworkBigWhite: - return Spells.RocketBigWhite; - default: - return 0; - } - } - - uint GetFireworkGameObjectId() - { - uint spellId = 0; - - switch (me.GetEntry()) - { - case CreatureIds.ClusterBlue: - spellId = GetFireworkSpell(CreatureIds.FireworkBlue); - break; - case CreatureIds.ClusterGreen: - spellId = GetFireworkSpell(CreatureIds.FireworkGreen); - break; - case CreatureIds.ClusterPurple: - spellId = GetFireworkSpell(CreatureIds.FireworkPurple); - break; - case CreatureIds.ClusterRed: - spellId = GetFireworkSpell(CreatureIds.FireworkRed); - break; - case CreatureIds.ClusterYellow: - spellId = GetFireworkSpell(CreatureIds.FireworkYellow); - break; - case CreatureIds.ClusterWhite: - spellId = GetFireworkSpell(CreatureIds.FireworkWhite); - break; - case CreatureIds.ClusterBigBlue: - spellId = GetFireworkSpell(CreatureIds.FireworkBigBlue); - break; - case CreatureIds.ClusterBigGreen: - spellId = GetFireworkSpell(CreatureIds.FireworkBigGreen); - break; - case CreatureIds.ClusterBigPurple: - spellId = GetFireworkSpell(CreatureIds.FireworkBigPurple); - break; - case CreatureIds.ClusterBigRed: - spellId = GetFireworkSpell(CreatureIds.FireworkBigRed); - break; - case CreatureIds.ClusterBigYellow: - spellId = GetFireworkSpell(CreatureIds.FireworkBigYellow); - break; - case CreatureIds.ClusterBigWhite: - spellId = GetFireworkSpell(CreatureIds.FireworkBigWhite); - break; - case CreatureIds.ClusterElune: - spellId = GetFireworkSpell(RandomHelper.URand(CreatureIds.FireworkBlue, CreatureIds.FireworkWhite)); - break; - } - - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId); - if (spellInfo != null && spellInfo.GetEffect(0).Effect == SpellEffectName.SummonObjectWild) - return (uint)spellInfo.GetEffect(0).MiscValue; - - return 0; - } - - public override void Reset() - { - GameObject launcher = FindNearestLauncher(); - if (launcher) - { - launcher.SendCustomAnim(NpcSpecialConst.AnimGoLaunchFirework); - me.SetOrientation(launcher.GetOrientation() + MathFunctions.PI / 2); - } - else - return; - - if (isCluster()) - { - // Check if we are near Elune'ara lake south, if so try to summon Omen or a minion - if (me.GetZoneId() == NpcSpecialConst.ZoneMoonglade) - { - if (!me.FindNearestCreature(CreatureIds.Omen, 100.0f) && me.GetDistance2d(NpcSpecialConst.omenSummonPos.GetPositionX(), NpcSpecialConst.omenSummonPos.GetPositionY()) <= 100.0f) - { - switch (RandomHelper.URand(0, 9)) - { - case 0: - case 1: - case 2: - case 3: - Creature minion = me.SummonCreature(CreatureIds.MinionOfOmen, me.GetPositionX() + RandomHelper.FRand(-5.0f, 5.0f), me.GetPositionY() + RandomHelper.FRand(-5.0f, 5.0f), me.GetPositionZ(), 0.0f, TempSummonType.CorpseTimedDespawn, 20000); - if (minion) - minion.GetAI().AttackStart(me.SelectNearestPlayer(20.0f)); - break; - case 9: - me.SummonCreature(CreatureIds.Omen, NpcSpecialConst.omenSummonPos); - break; - } - } - } - if (me.GetEntry() == CreatureIds.ClusterElune) - DoCast(Spells.LunarFortune); - - float displacement = 0.7f; - for (byte i = 0; i < 4; i++) - me.SummonGameObject(GetFireworkGameObjectId(), me.GetPositionX() + (i % 2 == 0 ? displacement : -displacement), me.GetPositionY() + (i > 1 ? displacement : -displacement), me.GetPositionZ() + 4.0f, me.GetOrientation(), Quaternion.WAxis, 1); - } - else - //me.CastSpell(me, GetFireworkSpell(me.GetEntry()), true); - me.CastSpell(me.GetPositionX(), me.GetPositionY(), me.GetPositionZ(), GetFireworkSpell(me.GetEntry()), true); + case CreatureIds.FireworkBlue: + case CreatureIds.FireworkGreen: + case CreatureIds.FireworkPurple: + case CreatureIds.FireworkRed: + case CreatureIds.FireworkYellow: + case CreatureIds.FireworkWhite: + case CreatureIds.FireworkBigBlue: + case CreatureIds.FireworkBigGreen: + case CreatureIds.FireworkBigPurple: + case CreatureIds.FireworkBigRed: + case CreatureIds.FireworkBigYellow: + case CreatureIds.FireworkBigWhite: + return false; + case CreatureIds.ClusterBlue: + case CreatureIds.ClusterGreen: + case CreatureIds.ClusterPurple: + case CreatureIds.ClusterRed: + case CreatureIds.ClusterYellow: + case CreatureIds.ClusterWhite: + case CreatureIds.ClusterBigBlue: + case CreatureIds.ClusterBigGreen: + case CreatureIds.ClusterBigPurple: + case CreatureIds.ClusterBigRed: + case CreatureIds.ClusterBigYellow: + case CreatureIds.ClusterBigWhite: + case CreatureIds.ClusterElune: + default: + return true; } } - public override CreatureAI GetAI(Creature creature) + GameObject FindNearestLauncher() { - return new npc_fireworkAI(creature); + GameObject launcher = null; + + if (isCluster()) + { + GameObject launcher1 = GetClosestGameObjectWithEntry(me, GameobjectIds.ClusterLauncher1, 0.5f); + GameObject launcher2 = GetClosestGameObjectWithEntry(me, GameobjectIds.ClusterLauncher2, 0.5f); + GameObject launcher3 = GetClosestGameObjectWithEntry(me, GameobjectIds.ClusterLauncher3, 0.5f); + GameObject launcher4 = GetClosestGameObjectWithEntry(me, GameobjectIds.ClusterLauncher4, 0.5f); + + if (launcher1) + launcher = launcher1; + else if (launcher2) + launcher = launcher2; + else if (launcher3) + launcher = launcher3; + else if (launcher4) + launcher = launcher4; + } + else + { + GameObject launcher1 = GetClosestGameObjectWithEntry(me, GameobjectIds.FireworkLauncher1, 0.5f); + GameObject launcher2 = GetClosestGameObjectWithEntry(me, GameobjectIds.FireworkLauncher2, 0.5f); + GameObject launcher3 = GetClosestGameObjectWithEntry(me, GameobjectIds.FireworkLauncher3, 0.5f); + + if (launcher1) + launcher = launcher1; + else if (launcher2) + launcher = launcher2; + else if (launcher3) + launcher = launcher3; + } + + return launcher; + } + + uint GetFireworkSpell(uint entry) + { + switch (entry) + { + case CreatureIds.FireworkBlue: + return Spells.RocketBlue; + case CreatureIds.FireworkGreen: + return Spells.RocketGreen; + case CreatureIds.FireworkPurple: + return Spells.RocketPurple; + case CreatureIds.FireworkRed: + return Spells.RocketRed; + case CreatureIds.FireworkYellow: + return Spells.RocketYellow; + case CreatureIds.FireworkWhite: + return Spells.RocketWhite; + case CreatureIds.FireworkBigBlue: + return Spells.RocketBigBlue; + case CreatureIds.FireworkBigGreen: + return Spells.RocketBigGreen; + case CreatureIds.FireworkBigPurple: + return Spells.RocketBigPurple; + case CreatureIds.FireworkBigRed: + return Spells.RocketBigRed; + case CreatureIds.FireworkBigYellow: + return Spells.RocketBigYellow; + case CreatureIds.FireworkBigWhite: + return Spells.RocketBigWhite; + default: + return 0; + } + } + + uint GetFireworkGameObjectId() + { + uint spellId = 0; + + switch (me.GetEntry()) + { + case CreatureIds.ClusterBlue: + spellId = GetFireworkSpell(CreatureIds.FireworkBlue); + break; + case CreatureIds.ClusterGreen: + spellId = GetFireworkSpell(CreatureIds.FireworkGreen); + break; + case CreatureIds.ClusterPurple: + spellId = GetFireworkSpell(CreatureIds.FireworkPurple); + break; + case CreatureIds.ClusterRed: + spellId = GetFireworkSpell(CreatureIds.FireworkRed); + break; + case CreatureIds.ClusterYellow: + spellId = GetFireworkSpell(CreatureIds.FireworkYellow); + break; + case CreatureIds.ClusterWhite: + spellId = GetFireworkSpell(CreatureIds.FireworkWhite); + break; + case CreatureIds.ClusterBigBlue: + spellId = GetFireworkSpell(CreatureIds.FireworkBigBlue); + break; + case CreatureIds.ClusterBigGreen: + spellId = GetFireworkSpell(CreatureIds.FireworkBigGreen); + break; + case CreatureIds.ClusterBigPurple: + spellId = GetFireworkSpell(CreatureIds.FireworkBigPurple); + break; + case CreatureIds.ClusterBigRed: + spellId = GetFireworkSpell(CreatureIds.FireworkBigRed); + break; + case CreatureIds.ClusterBigYellow: + spellId = GetFireworkSpell(CreatureIds.FireworkBigYellow); + break; + case CreatureIds.ClusterBigWhite: + spellId = GetFireworkSpell(CreatureIds.FireworkBigWhite); + break; + case CreatureIds.ClusterElune: + spellId = GetFireworkSpell(RandomHelper.URand(CreatureIds.FireworkBlue, CreatureIds.FireworkWhite)); + break; + } + + SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId); + if (spellInfo != null && spellInfo.GetEffect(0).Effect == SpellEffectName.SummonObjectWild) + return (uint)spellInfo.GetEffect(0).MiscValue; + + return 0; + } + + public override void Reset() + { + GameObject launcher = FindNearestLauncher(); + if (launcher) + { + launcher.SendCustomAnim(NpcSpecialConst.AnimGoLaunchFirework); + me.SetOrientation(launcher.GetOrientation() + MathFunctions.PI / 2); + } + else + return; + + if (isCluster()) + { + // Check if we are near Elune'ara lake south, if so try to summon Omen or a minion + if (me.GetZoneId() == NpcSpecialConst.ZoneMoonglade) + { + if (!me.FindNearestCreature(CreatureIds.Omen, 100.0f) && me.GetDistance2d(NpcSpecialConst.omenSummonPos.GetPositionX(), NpcSpecialConst.omenSummonPos.GetPositionY()) <= 100.0f) + { + switch (RandomHelper.URand(0, 9)) + { + case 0: + case 1: + case 2: + case 3: + Creature minion = me.SummonCreature(CreatureIds.MinionOfOmen, me.GetPositionX() + RandomHelper.FRand(-5.0f, 5.0f), me.GetPositionY() + RandomHelper.FRand(-5.0f, 5.0f), me.GetPositionZ(), 0.0f, TempSummonType.CorpseTimedDespawn, 20000); + if (minion) + minion.GetAI().AttackStart(me.SelectNearestPlayer(20.0f)); + break; + case 9: + me.SummonCreature(CreatureIds.Omen, NpcSpecialConst.omenSummonPos); + break; + } + } + } + if (me.GetEntry() == CreatureIds.ClusterElune) + DoCast(Spells.LunarFortune); + + float displacement = 0.7f; + for (byte i = 0; i < 4; i++) + me.SummonGameObject(GetFireworkGameObjectId(), me.GetPositionX() + (i % 2 == 0 ? displacement : -displacement), me.GetPositionY() + (i > 1 ? displacement : -displacement), me.GetPositionZ() + 4.0f, me.GetOrientation(), Quaternion.WAxis, 1); + } + else + //me.CastSpell(me, GetFireworkSpell(me.GetEntry()), true); + me.CastSpell(me.GetPositionX(), me.GetPositionY(), me.GetPositionZ(), GetFireworkSpell(me.GetEntry()), true); } } [Script] - class npc_spring_rabbit : CreatureScript + class npc_spring_rabbit : ScriptedAI { - public npc_spring_rabbit() : base("npc_spring_rabbit") { } - - public override CreatureAI GetAI(Creature creature) + public npc_spring_rabbit(Creature creature) : base(creature) { - return new npc_spring_rabbitAI(creature); + Initialize(); } - class npc_spring_rabbitAI : ScriptedAI + void Initialize() { - public npc_spring_rabbitAI(Creature creature) : base(creature) + inLove = false; + rabbitGUID.Clear(); + jumpTimer = RandomHelper.URand(5000, 10000); + bunnyTimer = RandomHelper.URand(10000, 20000); + searchTimer = RandomHelper.URand(5000, 10000); + } + + bool inLove; + uint jumpTimer; + uint bunnyTimer; + uint searchTimer; + ObjectGuid rabbitGUID; + + public override void Reset() + { + Initialize(); + Unit owner = me.GetOwner(); + if (owner) + me.GetMotionMaster().MoveFollow(owner, SharedConst.PetFollowDist, SharedConst.PetFollowAngle); + } + + public override void EnterCombat(Unit who) { } + + public override void DoAction(int param) + { + inLove = true; + Unit owner = me.GetOwner(); + if (owner) + owner.CastSpell(owner, Spells.SpringFling, true); + } + + public override void UpdateAI(uint diff) + { + if (inLove) { - Initialize(); - } - - void Initialize() - { - inLove = false; - rabbitGUID.Clear(); - jumpTimer = RandomHelper.URand(5000, 10000); - bunnyTimer = RandomHelper.URand(10000, 20000); - searchTimer = RandomHelper.URand(5000, 10000); - } - - bool inLove; - uint jumpTimer; - uint bunnyTimer; - uint searchTimer; - ObjectGuid rabbitGUID; - - public override void Reset() - { - Initialize(); - Unit owner = me.GetOwner(); - if (owner) - me.GetMotionMaster().MoveFollow(owner, SharedConst.PetFollowDist, SharedConst.PetFollowAngle); - } - - public override void EnterCombat(Unit who) { } - - public override void DoAction(int param) - { - inLove = true; - Unit owner = me.GetOwner(); - if (owner) - owner.CastSpell(owner, Spells.SpringFling, true); - } - - public override void UpdateAI(uint diff) - { - if (inLove) + if (jumpTimer <= diff) { - if (jumpTimer <= diff) - { - Unit rabbit = Global.ObjAccessor.GetUnit(me, rabbitGUID); - if (rabbit) - DoCast(rabbit, Spells.SpringRabbitJump); - jumpTimer = RandomHelper.URand(5000, 10000); - } - else jumpTimer -= diff; - - if (bunnyTimer <= diff) - { - DoCast(Spells.SummonBabyBunny); - bunnyTimer = RandomHelper.URand(20000, 40000); - } - else bunnyTimer -= diff; + Unit rabbit = Global.ObjAccessor.GetUnit(me, rabbitGUID); + if (rabbit) + DoCast(rabbit, Spells.SpringRabbitJump); + jumpTimer = RandomHelper.URand(5000, 10000); } - else + else jumpTimer -= diff; + + if (bunnyTimer <= diff) { - if (searchTimer <= diff) - { - Creature rabbit = me.FindNearestCreature(CreatureIds.SpringRabbit, 10.0f); - if (rabbit) - { - if (rabbit == me || rabbit.HasAura(Spells.SpringRabbitInLove)) - return; - - me.AddAura(Spells.SpringRabbitInLove, me); - DoAction(1); - rabbit.AddAura(Spells.SpringRabbitInLove, rabbit); - rabbit.GetAI().DoAction(1); - rabbit.CastSpell(rabbit, Spells.SpringRabbitJump, true); - rabbitGUID = rabbit.GetGUID(); - } - searchTimer = RandomHelper.URand(5000, 10000); - } - else searchTimer -= diff; + DoCast(Spells.SummonBabyBunny); + bunnyTimer = RandomHelper.URand(20000, 40000); } + else bunnyTimer -= diff; + } + else + { + if (searchTimer <= diff) + { + Creature rabbit = me.FindNearestCreature(CreatureIds.SpringRabbit, 10.0f); + if (rabbit) + { + if (rabbit == me || rabbit.HasAura(Spells.SpringRabbitInLove)) + return; + + me.AddAura(Spells.SpringRabbitInLove, me); + DoAction(1); + rabbit.AddAura(Spells.SpringRabbitInLove, rabbit); + rabbit.GetAI().DoAction(1); + rabbit.CastSpell(rabbit, Spells.SpringRabbitJump, true); + rabbitGUID = rabbit.GetGUID(); + } + searchTimer = RandomHelper.URand(5000, 10000); + } + else searchTimer -= diff; } } } [Script] - class npc_imp_in_a_ball : CreatureScript + class npc_imp_in_a_ball : ScriptedAI { - public npc_imp_in_a_ball() : base("npc_imp_in_a_ball") { } - - class npc_imp_in_a_ballAI : ScriptedAI + public npc_imp_in_a_ball(Creature creature) : base(creature) { - public npc_imp_in_a_ballAI(Creature creature) : base(creature) - { - summonerGUID.Clear(); - } + summonerGUID.Clear(); + } - public override void IsSummonedBy(Unit summoner) + public override void IsSummonedBy(Unit summoner) + { + if (summoner.IsTypeId(TypeId.Player)) { - if (summoner.IsTypeId(TypeId.Player)) + summonerGUID = summoner.GetGUID(); + + _scheduler.Schedule(TimeSpan.FromSeconds(3), task => { - summonerGUID = summoner.GetGUID(); - - _scheduler.Schedule(TimeSpan.FromSeconds(3), task => - { - Player owner = Global.ObjAccessor.GetPlayer(me, summonerGUID); - if (owner) - Global.CreatureTextMgr.SendChat(me, 0, owner, owner.GetGroup() ? ChatMsg.MonsterParty : ChatMsg.MonsterWhisper, Language.Addon, CreatureTextRange.Normal); - }); - } + Player owner = Global.ObjAccessor.GetPlayer(me, summonerGUID); + if (owner) + Global.CreatureTextMgr.SendChat(me, 0, owner, owner.GetGroup() ? ChatMsg.MonsterParty : ChatMsg.MonsterWhisper, Language.Addon, CreatureTextRange.Normal); + }); } - - public override void UpdateAI(uint diff) - { - _scheduler.Update(diff); - } - - ObjectGuid summonerGUID; } - public override CreatureAI GetAI(Creature creature) + public override void UpdateAI(uint diff) { - return new npc_imp_in_a_ballAI(creature); + _scheduler.Update(diff); } + + ObjectGuid summonerGUID; } struct TrainWrecker @@ -2241,229 +2092,209 @@ namespace Scripts.World.NpcSpecial } [Script] - class npc_train_wrecker : CreatureScript + class npc_train_wrecker : NullCreatureAI { - public npc_train_wrecker() : base("npc_train_wrecker") { } - - class npc_train_wreckerAI : NullCreatureAI + public npc_train_wrecker(Creature creature) : base(creature) { - public npc_train_wreckerAI(Creature creature) : base(creature) - { - _isSearching = true; - _nextAction = 0; - _timer = 1 * Time.InMilliseconds; - } + _isSearching = true; + _nextAction = 0; + _timer = 1 * Time.InMilliseconds; + } - GameObject VerifyTarget() - { - GameObject target = ObjectAccessor.GetGameObject(me, _target); - if (target) - return target; + GameObject VerifyTarget() + { + GameObject target = ObjectAccessor.GetGameObject(me, _target); + if (target) + return target; - me.HandleEmoteCommand(Emote.OneshotRude); - me.DespawnOrUnsummon(3 * Time.InMilliseconds); - return null; - } + me.HandleEmoteCommand(Emote.OneshotRude); + me.DespawnOrUnsummon(3 * Time.InMilliseconds); + return null; + } - public override void UpdateAI(uint diff) + public override void UpdateAI(uint diff) + { + if (_isSearching) { - if (_isSearching) - { - if (diff < _timer) - _timer -= diff; - else - { - GameObject target = me.FindNearestGameObject(GameobjectIds.ToyTrain, 15.0f); - if (target) - { - _isSearching = false; - _target = target.GetGUID(); - me.SetWalk(true); - me.GetMotionMaster().MovePoint(TrainWrecker.MoveidChase, target.GetNearPosition(3.0f, target.GetAngle(me))); - } - else - _timer = 3 * Time.InMilliseconds; - } - } + if (diff < _timer) + _timer -= diff; else { - switch (_nextAction) + GameObject target = me.FindNearestGameObject(GameobjectIds.ToyTrain, 15.0f); + if (target) { - case TrainWrecker.EventDoJump: + _isSearching = false; + _target = target.GetGUID(); + me.SetWalk(true); + me.GetMotionMaster().MovePoint(TrainWrecker.MoveidChase, target.GetNearPosition(3.0f, target.GetAngle(me))); + } + else + _timer = 3 * Time.InMilliseconds; + } + } + else + { + switch (_nextAction) + { + case TrainWrecker.EventDoJump: + { + GameObject target = VerifyTarget(); + if (target) + me.GetMotionMaster().MoveJump(target, 5.0f, 10.0f, TrainWrecker.MoveidJump); + _nextAction = 0; + } + break; + case TrainWrecker.EventDoFacing: + { + GameObject target = VerifyTarget(); + if (target) { - GameObject target = VerifyTarget(); - if (target) - me.GetMotionMaster().MoveJump(target, 5.0f, 10.0f, TrainWrecker.MoveidJump); + me.SetFacingTo(target.GetOrientation()); + me.HandleEmoteCommand(Emote.OneshotAttack1h); + _timer = (uint)(1.5 * Time.InMilliseconds); + _nextAction = TrainWrecker.EventDoWreck; + } + else _nextAction = 0; - } - break; - case TrainWrecker.EventDoFacing: - { - GameObject target = VerifyTarget(); - if (target) - { - me.SetFacingTo(target.GetOrientation()); - me.HandleEmoteCommand(Emote.OneshotAttack1h); - _timer = (uint)(1.5 * Time.InMilliseconds); - _nextAction = TrainWrecker.EventDoWreck; - } - else - _nextAction = 0; - } - break; - case TrainWrecker.EventDoWreck: - { - if (diff < _timer) - { - _timer -= diff; - break; - } - - GameObject target = VerifyTarget(); - if (target) - { - me.CastSpell(target, Spells.WreckTrain, false); - target.GetAI().DoAction(TrainWrecker.ActionWrecked); - _timer = 2 * Time.InMilliseconds; - _nextAction = TrainWrecker.EventDoDance; - } - else - _nextAction = 0; - } - break; - case TrainWrecker.EventDoDance: + } + break; + case TrainWrecker.EventDoWreck: + { if (diff < _timer) { _timer -= diff; break; } - me.UpdateEntry(CreatureIds.ExultingWindUpTrainWrecker); - me.SetUInt32Value(UnitFields.NpcEmotestate, (uint)Emote.OneshotDance); - me.DespawnOrUnsummon(5 * Time.InMilliseconds); - _nextAction = 0; + + GameObject target = VerifyTarget(); + if (target) + { + me.CastSpell(target, Spells.WreckTrain, false); + target.GetAI().DoAction(TrainWrecker.ActionWrecked); + _timer = 2 * Time.InMilliseconds; + _nextAction = TrainWrecker.EventDoDance; + } + else + _nextAction = 0; + } + break; + case TrainWrecker.EventDoDance: + if (diff < _timer) + { + _timer -= diff; break; - default: - break; - } + } + me.UpdateEntry(CreatureIds.ExultingWindUpTrainWrecker); + me.SetUInt32Value(UnitFields.NpcEmotestate, (uint)Emote.OneshotDance); + me.DespawnOrUnsummon(5 * Time.InMilliseconds); + _nextAction = 0; + break; + default: + break; } } - - public override void MovementInform(MovementGeneratorType type, uint id) - { - if (id == TrainWrecker.MoveidChase) - _nextAction = TrainWrecker.EventDoJump; - else if (id == TrainWrecker.MoveidJump) - _nextAction = TrainWrecker.EventDoFacing; - } - - bool _isSearching; - byte _nextAction; - uint _timer; - ObjectGuid _target; } - public override CreatureAI GetAI(Creature creature) + public override void MovementInform(MovementGeneratorType type, uint id) { - return new npc_train_wreckerAI(creature); + if (id == TrainWrecker.MoveidChase) + _nextAction = TrainWrecker.EventDoJump; + else if (id == TrainWrecker.MoveidJump) + _nextAction = TrainWrecker.EventDoFacing; } + + bool _isSearching; + byte _nextAction; + uint _timer; + ObjectGuid _target; } [Script] - class npc_argent_squire_gruntling : CreatureScript + class npc_argent_squire_gruntling : ScriptedAI { - public npc_argent_squire_gruntling() : base("npc_argent_squire_gruntling") { } - - class npc_argent_squire_gruntlingAI : ScriptedAI + public npc_argent_squire_gruntling(Creature creature) : base(creature) { - public npc_argent_squire_gruntlingAI(Creature creature) : base(creature) + ScheduleTasks(); + } + + void ScheduleTasks() + { + _scheduler.Schedule(TimeSpan.FromSeconds(1), task => { - ScheduleTasks(); - } - - void ScheduleTasks() - { - _scheduler.Schedule(TimeSpan.FromSeconds(1), task => + Aura ownerTired = me.GetOwner().GetAura(Spells.TiredPlayer); + if (ownerTired != null) { - Aura ownerTired = me.GetOwner().GetAura(Spells.TiredPlayer); - if (ownerTired != null) - { - Aura squireTired = me.AddAura(IsArgentSquire() ? Spells.AuraTiredS : Spells.AuraTiredG, me); - if (squireTired != null) - squireTired.SetDuration(ownerTired.GetDuration()); - } - }); - _scheduler.Schedule(TimeSpan.FromSeconds(1), task => - { - if ((me.HasAura(Spells.AuraTiredS) || me.HasAura(Spells.AuraTiredG)) && me.HasFlag(UnitFields.NpcFlags, NPCFlags.Banker | NPCFlags.Mailbox | NPCFlags.Vendor)) - me.RemoveFlag(UnitFields.NpcFlags, NPCFlags.Banker | NPCFlags.Mailbox | NPCFlags.Vendor); - task.Repeat(); - }); - } - - public override void sGossipSelect(Player player, uint menuId, uint gossipListId) - { - switch (gossipListId) - { - case GossipMenus.OptionIdBank: - { - me.SetFlag(UnitFields.NpcFlags, NPCFlags.Banker); - uint _bankAura = IsArgentSquire() ? Spells.AuraBankS : Spells.AuraBankG; - if (!me.HasAura(_bankAura)) - DoCastSelf(_bankAura); - - if (!player.HasAura(Spells.TiredPlayer)) - player.CastSpell(player, Spells.TiredPlayer, true); - break; - } - case GossipMenus.OptionIdShop: - { - me.SetFlag(UnitFields.NpcFlags, NPCFlags.Vendor); - uint _shopAura = IsArgentSquire() ? Spells.AuraShopS : Spells.AuraShopG; - if (!me.HasAura(_shopAura)) - DoCastSelf(_shopAura); - - if (!player.HasAura(Spells.TiredPlayer)) - player.CastSpell(player, Spells.TiredPlayer, true); - break; - } - case GossipMenus.OptionIdMail: - { - me.SetFlag(UnitFields.NpcFlags, NPCFlags.Mailbox); - player.GetSession().SendShowMailBox(me.GetGUID()); - - uint _mailAura = IsArgentSquire() ? Spells.AuraPostmanS : Spells.AuraPostmanG; - if (!me.HasAura(_mailAura)) - DoCastSelf(_mailAura); - - if (!player.HasAura(Spells.TiredPlayer)) - player.CastSpell(player, Spells.TiredPlayer, true); - break; - } - case GossipMenus.OptionIdDarnassusSenjinPennant: - case GossipMenus.OptionIdExodarUndercityPennant: - case GossipMenus.OptionIdGnomereganOrgrimmarPennant: - case GossipMenus.OptionIdIronforgeSilvermoonPennant: - case GossipMenus.OptionIdStormwindThunderbluffPennant: - if (IsArgentSquire()) - DoCastSelf(NpcSpecialConst.bannerSpells[gossipListId - 3].Item1, true); - else - DoCastSelf(NpcSpecialConst.bannerSpells[gossipListId - 3].Item2, true); - break; + Aura squireTired = me.AddAura(IsArgentSquire() ? Spells.AuraTiredS : Spells.AuraTiredG, me); + if (squireTired != null) + squireTired.SetDuration(ownerTired.GetDuration()); } - player.PlayerTalkClass.SendCloseGossip(); - } - - public override void UpdateAI(uint diff) + }); + _scheduler.Schedule(TimeSpan.FromSeconds(1), task => { - _scheduler.Update(diff); - } - - bool IsArgentSquire() { return me.GetEntry() == CreatureIds.ArgentSquire; } + if ((me.HasAura(Spells.AuraTiredS) || me.HasAura(Spells.AuraTiredG)) && me.HasFlag(UnitFields.NpcFlags, NPCFlags.Banker | NPCFlags.Mailbox | NPCFlags.Vendor)) + me.RemoveFlag(UnitFields.NpcFlags, NPCFlags.Banker | NPCFlags.Mailbox | NPCFlags.Vendor); + task.Repeat(); + }); } - public override CreatureAI GetAI(Creature creature) + public override void sGossipSelect(Player player, uint menuId, uint gossipListId) { - return new npc_argent_squire_gruntlingAI(creature); + switch (gossipListId) + { + case GossipMenus.OptionIdBank: + { + me.SetFlag(UnitFields.NpcFlags, NPCFlags.Banker); + uint _bankAura = IsArgentSquire() ? Spells.AuraBankS : Spells.AuraBankG; + if (!me.HasAura(_bankAura)) + DoCastSelf(_bankAura); + + if (!player.HasAura(Spells.TiredPlayer)) + player.CastSpell(player, Spells.TiredPlayer, true); + break; + } + case GossipMenus.OptionIdShop: + { + me.SetFlag(UnitFields.NpcFlags, NPCFlags.Vendor); + uint _shopAura = IsArgentSquire() ? Spells.AuraShopS : Spells.AuraShopG; + if (!me.HasAura(_shopAura)) + DoCastSelf(_shopAura); + + if (!player.HasAura(Spells.TiredPlayer)) + player.CastSpell(player, Spells.TiredPlayer, true); + break; + } + case GossipMenus.OptionIdMail: + { + me.SetFlag(UnitFields.NpcFlags, NPCFlags.Mailbox); + player.GetSession().SendShowMailBox(me.GetGUID()); + + uint _mailAura = IsArgentSquire() ? Spells.AuraPostmanS : Spells.AuraPostmanG; + if (!me.HasAura(_mailAura)) + DoCastSelf(_mailAura); + + if (!player.HasAura(Spells.TiredPlayer)) + player.CastSpell(player, Spells.TiredPlayer, true); + break; + } + case GossipMenus.OptionIdDarnassusSenjinPennant: + case GossipMenus.OptionIdExodarUndercityPennant: + case GossipMenus.OptionIdGnomereganOrgrimmarPennant: + case GossipMenus.OptionIdIronforgeSilvermoonPennant: + case GossipMenus.OptionIdStormwindThunderbluffPennant: + if (IsArgentSquire()) + DoCastSelf(NpcSpecialConst.bannerSpells[gossipListId - 3].Item1, true); + else + DoCastSelf(NpcSpecialConst.bannerSpells[gossipListId - 3].Item2, true); + break; + } + player.PlayerTalkClass.SendCloseGossip(); } + + public override void UpdateAI(uint diff) + { + _scheduler.Update(diff); + } + + bool IsArgentSquire() { return me.GetEntry() == CreatureIds.ArgentSquire; } } }