From 9ea20a89256ba29bc570e931fd3f535efb992673 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Tue, 11 Oct 2022 17:09:56 -0400 Subject: [PATCH] Fixes some crashes. --- Source/Game/AI/CoreAI/UnitAI.cs | 2 ++ Source/Scripts/EasternKingdoms/Karazhan/Moroes.cs | 11 +++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Source/Game/AI/CoreAI/UnitAI.cs b/Source/Game/AI/CoreAI/UnitAI.cs index 997e3febd..fc1dc39ee 100644 --- a/Source/Game/AI/CoreAI/UnitAI.cs +++ b/Source/Game/AI/CoreAI/UnitAI.cs @@ -334,6 +334,8 @@ namespace Game.AI public SpellCastResult DoCast(Unit victim, uint spellId, CastSpellExtraArgs args = null) { + args = args ?? new CastSpellExtraArgs(); + if (me.HasUnitState(UnitState.Casting) && !args.TriggerFlags.HasAnyFlag(TriggerCastFlags.IgnoreCastInProgress)) return SpellCastResult.SpellInProgress; diff --git a/Source/Scripts/EasternKingdoms/Karazhan/Moroes.cs b/Source/Scripts/EasternKingdoms/Karazhan/Moroes.cs index 9ea27aedb..467dd922b 100644 --- a/Source/Scripts/EasternKingdoms/Karazhan/Moroes.cs +++ b/Source/Scripts/EasternKingdoms/Karazhan/Moroes.cs @@ -122,7 +122,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Moroes if (me.IsAlive()) SpawnAdds(); - base.Reset(); + instance.SetBossState(DataTypes.Moroes, EncounterState.NotStarted); } public override void JustEngagedWith(Unit who) @@ -203,15 +203,14 @@ namespace Scripts.EasternKingdoms.Karazhan.Moroes { List AddList = MiscConst.Adds.ToList(); AddList.RandomResize(4); - - byte i = 0; - foreach (var entry in AddList) + + for (var i = 0; i < 4; ++i) { - Creature creature = me.SummonCreature(entry, MiscConst.Locations[i], TempSummonType.CorpseTimedDespawn, TimeSpan.FromSeconds(10)); + Creature creature = me.SummonCreature(AddList[i], MiscConst.Locations[i], TempSummonType.CorpseTimedDespawn, TimeSpan.FromSeconds(10)); if (creature) { AddGUID[i] = creature.GetGUID(); - AddId[i] = entry; + AddId[i] = AddList[i]; } } }