Fixes build. Scripts are still being updated.

This commit is contained in:
hondacrx
2024-01-24 12:02:23 -05:00
parent 1c6563718e
commit 6f4b7ddd9d
51 changed files with 268 additions and 268 deletions
@@ -63,7 +63,7 @@ namespace Scripts.EasternKingdoms.BaradinHold.Alizabal
if (instance != null) if (instance != null)
{ {
Creature alizabal = ObjectAccessor.GetCreature(player, instance.GetGuidData(DataTypes.Alizabal)); Creature alizabal = ObjectAccessor.GetCreature(player, instance.GetGuidData(DataTypes.Alizabal));
if (alizabal) if (alizabal != null)
alizabal.GetAI().DoAction(ActionIds.Intro); alizabal.GetAI().DoAction(ActionIds.Intro);
} }
return true; return true;
@@ -157,7 +157,7 @@ namespace Scripts.EasternKingdoms.BaradinHold.Alizabal
if (!_skewer) if (!_skewer)
{ {
Unit target = SelectTarget(SelectTargetMethod.MaxThreat, 0); Unit target = SelectTarget(SelectTargetMethod.MaxThreat, 0);
if (target) if (target != null)
{ {
DoCast(target, SpellIds.Skewer, new CastSpellExtraArgs(true)); DoCast(target, SpellIds.Skewer, new CastSpellExtraArgs(true));
Talk(TextIds.SaySkewer); Talk(TextIds.SaySkewer);
@@ -169,7 +169,7 @@ namespace Scripts.EasternKingdoms.BaradinHold.Alizabal
else if (!_hate) else if (!_hate)
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, new NonTankTargetSelector(me)); Unit target = SelectTarget(SelectTargetMethod.Random, 0, new NonTankTargetSelector(me));
if (target) if (target != null)
{ {
DoCast(target, SpellIds.SeethingHate, new CastSpellExtraArgs(true)); DoCast(target, SpellIds.SeethingHate, new CastSpellExtraArgs(true));
Talk(TextIds.SayHate); Talk(TextIds.SayHate);
@@ -191,7 +191,7 @@ namespace Scripts.EasternKingdoms.BaradinHold.Alizabal
if (!_hate) if (!_hate)
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, new NonTankTargetSelector(me)); Unit target = SelectTarget(SelectTargetMethod.Random, 0, new NonTankTargetSelector(me));
if (target) if (target != null)
{ {
DoCast(target, SpellIds.SeethingHate, new CastSpellExtraArgs(true)); DoCast(target, SpellIds.SeethingHate, new CastSpellExtraArgs(true));
Talk(TextIds.SayHate); Talk(TextIds.SayHate);
@@ -202,7 +202,7 @@ namespace Scripts.EasternKingdoms.BaradinHold.Alizabal
else if (!_skewer) else if (!_skewer)
{ {
Unit target = SelectTarget(SelectTargetMethod.MaxThreat, 0); Unit target = SelectTarget(SelectTargetMethod.MaxThreat, 0);
if (target) if (target != null)
{ {
DoCast(target, SpellIds.Skewer, new CastSpellExtraArgs(true)); DoCast(target, SpellIds.Skewer, new CastSpellExtraArgs(true));
Talk(TextIds.SaySkewer); Talk(TextIds.SaySkewer);
@@ -229,7 +229,7 @@ namespace Scripts.EasternKingdoms.BaradinHold.Alizabal
me.SetSpeedRate(UnitMoveType.Run, 4.0f); me.SetSpeedRate(UnitMoveType.Run, 4.0f);
me.SetSpeedRate(UnitMoveType.Walk, 4.0f); me.SetSpeedRate(UnitMoveType.Walk, 4.0f);
Unit target = SelectTarget(SelectTargetMethod.Random, 0, new NonTankTargetSelector(me)); Unit target = SelectTarget(SelectTargetMethod.Random, 0, new NonTankTargetSelector(me));
if (target) if (target != null)
me.GetMotionMaster().MovePoint(PointIds.Storm, target.GetPositionX(), target.GetPositionY(), target.GetPositionZ()); me.GetMotionMaster().MovePoint(PointIds.Storm, target.GetPositionX(), target.GetPositionY(), target.GetPositionZ());
_events.ScheduleEvent(EventIds.MoveStorm, TimeSpan.FromMilliseconds(4050)); _events.ScheduleEvent(EventIds.MoveStorm, TimeSpan.FromMilliseconds(4050));
break; break;
@@ -85,7 +85,7 @@ namespace Scripts.EasternKingdoms.BaradinHold.Occuthar
for (sbyte i = 0; i < MiscConst.MaxOccutharVehicleSeats; ++i) for (sbyte i = 0; i < MiscConst.MaxOccutharVehicleSeats; ++i)
{ {
Unit vehicle = _vehicle.GetPassenger(i); Unit vehicle = _vehicle.GetPassenger(i);
if (vehicle) if (vehicle != null)
vehicle.CastSpell(summon, SpellIds.FocusedFireVisual); vehicle.CastSpell(summon, SpellIds.FocusedFireVisual);
} }
} }
@@ -259,13 +259,13 @@ namespace Scripts.EasternKingdoms.BaradinHold.Occuthar
{ {
public override bool Load() public override bool Load()
{ {
return GetCaster() && GetCaster().GetTypeId() == TypeId.Unit; return GetCaster() != null && GetCaster().GetTypeId() == TypeId.Unit;
} }
void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode)
{ {
Unit caster = GetCaster(); Unit caster = GetCaster();
if (caster) if (caster != null)
{ {
if (IsExpired()) if (IsExpired())
caster.CastSpell((WorldObject)null, SpellIds.OccutharsDestuction, new CastSpellExtraArgs(aurEff)); caster.CastSpell((WorldObject)null, SpellIds.OccutharsDestuction, new CastSpellExtraArgs(aurEff));
@@ -56,7 +56,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockCaverns.RomoggBonec
Talk(TextIds.YellDeath); Talk(TextIds.YellDeath);
Creature raz = instance.GetCreature(DataTypes.RazTheCrazed); Creature raz = instance.GetCreature(DataTypes.RazTheCrazed);
if (raz) if (raz != null)
raz.GetAI().SetData(MiscConst.TypeRaz, MiscConst.DataRomoggDead); raz.GetAI().SetData(MiscConst.TypeRaz, MiscConst.DataRomoggDead);
} }
@@ -41,7 +41,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockDepths.AmbassadorFl
void SummonSpirit(Unit victim) void SummonSpirit(Unit victim)
{ {
Creature spirit = DoSpawnCreature(9178, RandomHelper.FRand(-9, 9), RandomHelper.FRand(-9, 9), 0, 0, Framework.Constants.TempSummonType.TimedOrCorpseDespawn, TimeSpan.FromSeconds(60)); Creature spirit = DoSpawnCreature(9178, RandomHelper.FRand(-9, 9), RandomHelper.FRand(-9, 9), 0, 0, Framework.Constants.TempSummonType.TimedOrCorpseDespawn, TimeSpan.FromSeconds(60));
if (spirit) if (spirit != null)
spirit.GetAI().AttackStart(victim); spirit.GetAI().AttackStart(victim);
} }
@@ -219,7 +219,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockDepths.CorenDirebre
if (!players.Empty()) if (!players.Empty())
{ {
Group group = players[0].GetGroup(); Group group = players[0].GetGroup();
if (group) if (group != null)
if (group.IsLFGGroup()) if (group.IsLFGGroup())
Global.LFGMgr.FinishDungeon(group.GetGUID(), 287, me.GetMap()); Global.LFGMgr.FinishDungeon(group.GetGUID(), 287, me.GetMap());
} }
@@ -228,7 +228,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockDepths.CorenDirebre
void SummonSister(uint entry) void SummonSister(uint entry)
{ {
Creature sister = me.SummonCreature(entry, me.GetPosition(), TempSummonType.DeadDespawn); Creature sister = me.SummonCreature(entry, me.GetPosition(), TempSummonType.DeadDespawn);
if (sister) if (sister != null)
DoZoneInCombat(sister); DoZoneInCombat(sister);
} }
@@ -275,7 +275,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockDepths.CorenDirebre
_scheduler.Schedule(TimeSpan.FromSeconds(2), mugChuck => _scheduler.Schedule(TimeSpan.FromSeconds(2), mugChuck =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, false, true, -(int)SpellIds.HasDarkBrewmaidensBrew); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, false, true, -(int)SpellIds.HasDarkBrewmaidensBrew);
if (target) if (target != null)
DoCast(target, SpellIds.ChuckMug); DoCast(target, SpellIds.ChuckMug);
mugChuck.Repeat(TimeSpan.FromSeconds(4)); mugChuck.Repeat(TimeSpan.FromSeconds(4));
}); });
@@ -305,7 +305,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockDepths.CorenDirebre
public override void IsSummonedBy(WorldObject summoner) public override void IsSummonedBy(WorldObject summoner)
{ {
Creature coren = ObjectAccessor.GetCreature(me, _instance.GetGuidData(DataTypes.DataCoren)); Creature coren = ObjectAccessor.GetCreature(me, _instance.GetGuidData(DataTypes.DataCoren));
if (coren) if (coren != null)
coren.GetAI().JustSummoned(me); coren.GetAI().JustSummoned(me);
} }
} }
@@ -356,7 +356,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockDepths.CorenDirebre
_scheduler.Schedule(TimeSpan.FromSeconds(4), context => _scheduler.Schedule(TimeSpan.FromSeconds(4), context =>
{ {
GameObject trap = me.GetLinkedTrap(); GameObject trap = me.GetLinkedTrap();
if (trap) if (trap != null)
{ {
trap.SetLootState(LootState.Activated); trap.SetLootState(LootState.Activated);
trap.UseDoorOrButton(); trap.UseDoorOrButton();
@@ -396,7 +396,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockDepths.CorenDirebre
{ {
Unit caster = GetCaster(); Unit caster = GetCaster();
targets.RemoveAll(new UnitAuraCheck<WorldObject>(true, SpellIds.HasDarkBrewmaidensBrew)); targets.RemoveAll(new UnitAuraCheck(true, SpellIds.HasDarkBrewmaidensBrew));
if (targets.Count > 1) if (targets.Count > 1)
{ {
@@ -46,7 +46,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockDepths.Draganthauri
_scheduler.Schedule(TimeSpan.FromSeconds(4), task => _scheduler.Schedule(TimeSpan.FromSeconds(4), task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0); Unit target = SelectTarget(SelectTargetMethod.Random, 0);
if (target) if (target != null)
DoCast(target, SpellIds.Handofthaurissan); DoCast(target, SpellIds.Handofthaurissan);
task.Repeat(TimeSpan.FromSeconds(5)); task.Repeat(TimeSpan.FromSeconds(5));
}); });
@@ -66,7 +66,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockDepths.Draganthauri
public override void JustDied(Unit killer) public override void JustDied(Unit killer)
{ {
Creature moira = ObjectAccessor.GetCreature(me, _instance.GetGuidData(DataTypes.DataMoira)); Creature moira = ObjectAccessor.GetCreature(me, _instance.GetGuidData(DataTypes.DataMoira));
if (moira) if (moira != null)
{ {
moira.GetAI().EnterEvadeMode(); moira.GetAI().EnterEvadeMode();
moira.SetFaction((uint)FactionTemplates.Friendly); moira.SetFaction((uint)FactionTemplates.Friendly);
@@ -77,14 +77,14 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockDepths.GeneralAnger
void SummonAdd(Unit victim) void SummonAdd(Unit victim)
{ {
Creature SummonedAdd = DoSpawnCreature(8901, RandomHelper.IRand(-14, 14), RandomHelper.IRand(-14, 14), 0, 0, TempSummonType.TimedOrCorpseDespawn, TimeSpan.FromSeconds(120)); Creature SummonedAdd = DoSpawnCreature(8901, RandomHelper.IRand(-14, 14), RandomHelper.IRand(-14, 14), 0, 0, TempSummonType.TimedOrCorpseDespawn, TimeSpan.FromSeconds(120));
if (SummonedAdd) if (SummonedAdd != null)
SummonedAdd.GetAI().AttackStart(victim); SummonedAdd.GetAI().AttackStart(victim);
} }
void SummonMedic(Unit victim) void SummonMedic(Unit victim)
{ {
Creature SummonedMedic = DoSpawnCreature(8894, RandomHelper.IRand(-9, 9), RandomHelper.IRand(-9, 9), 0, 0, TempSummonType.TimedOrCorpseDespawn, TimeSpan.FromSeconds(120)); Creature SummonedMedic = DoSpawnCreature(8894, RandomHelper.IRand(-9, 9), RandomHelper.IRand(-9, 9), 0, 0, TempSummonType.TimedOrCorpseDespawn, TimeSpan.FromSeconds(120));
if (SummonedMedic) if (SummonedMedic != null)
SummonedMedic.GetAI().AttackStart(victim); SummonedMedic.GetAI().AttackStart(victim);
} }
@@ -32,14 +32,14 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockDepths.HighInterrog
_scheduler.Schedule(TimeSpan.FromSeconds(4), task => _scheduler.Schedule(TimeSpan.FromSeconds(4), task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100.0f, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100.0f, true);
if (target) if (target != null)
DoCast(target, SpellIds.Shadowwordpain); DoCast(target, SpellIds.Shadowwordpain);
task.Repeat(TimeSpan.FromSeconds(7)); task.Repeat(TimeSpan.FromSeconds(7));
}); });
_scheduler.Schedule(TimeSpan.FromSeconds(14), task => _scheduler.Schedule(TimeSpan.FromSeconds(14), task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100.0f, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100.0f, true);
if (target) if (target != null)
DoCast(target, SpellIds.Manaburn); DoCast(target, SpellIds.Manaburn);
task.Repeat(TimeSpan.FromSeconds(10)); task.Repeat(TimeSpan.FromSeconds(10));
}); });
@@ -322,12 +322,12 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockDepths
if (GhostKillCount < MiscConst.TombOfSevenBossNum && !TombBossGUIDs[TombEventCounter].IsEmpty()) if (GhostKillCount < MiscConst.TombOfSevenBossNum && !TombBossGUIDs[TombEventCounter].IsEmpty())
{ {
Creature boss = instance.GetCreature(TombBossGUIDs[TombEventCounter]); Creature boss = instance.GetCreature(TombBossGUIDs[TombEventCounter]);
if (boss) if (boss != null)
{ {
boss.SetFaction((uint)FactionTemplates.DarkIronDwarves); boss.SetFaction((uint)FactionTemplates.DarkIronDwarves);
boss.SetImmuneToPC(false); boss.SetImmuneToPC(false);
Unit target = boss.SelectNearestTarget(500); Unit target = boss.SelectNearestTarget(500);
if (target) if (target != null)
boss.GetAI().AttackStart(target); boss.GetAI().AttackStart(target);
} }
} }
@@ -340,7 +340,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockDepths
for (byte i = 0; i < MiscConst.TombOfSevenBossNum; ++i) for (byte i = 0; i < MiscConst.TombOfSevenBossNum; ++i)
{ {
Creature boss = instance.GetCreature(TombBossGUIDs[i]); Creature boss = instance.GetCreature(TombBossGUIDs[i]);
if (boss) if (boss != null)
{ {
if (!boss.IsAlive()) if (!boss.IsAlive())
boss.Respawn(); boss.Respawn();
@@ -388,7 +388,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockDepths
for (byte i = 0; i < MiscConst.TombOfSevenBossNum; ++i) for (byte i = 0; i < MiscConst.TombOfSevenBossNum; ++i)
{ {
Creature boss = instance.GetCreature(TombBossGUIDs[i]); Creature boss = instance.GetCreature(TombBossGUIDs[i]);
if (boss) if (boss != null)
{ {
if (!boss.IsAlive()) if (!boss.IsAlive())
{ {
@@ -147,7 +147,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockDepths.TombOfSeven
_scheduler.Schedule(TimeSpan.FromSeconds(18), task => _scheduler.Schedule(TimeSpan.FromSeconds(18), task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100.0f, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100.0f, true);
if (target) if (target != null)
DoCast(target, SpellIds.Immolate); DoCast(target, SpellIds.Immolate);
task.Repeat(TimeSpan.FromSeconds(25)); task.Repeat(TimeSpan.FromSeconds(25));
}); });
@@ -92,10 +92,10 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire.Gyth
{ {
me.AddAura(SpellIds.RendMounts, me); me.AddAura(SpellIds.RendMounts, me);
GameObject portcullis = me.FindNearestGameObject(GameObjectsIds.DrPortcullis, 40.0f); GameObject portcullis = me.FindNearestGameObject(GameObjectsIds.DrPortcullis, 40.0f);
if (portcullis) if (portcullis != null)
portcullis.UseDoorOrButton(); portcullis.UseDoorOrButton();
Creature victor = me.FindNearestCreature(CreaturesIds.LordVictorNefarius, 75.0f, true); Creature victor = me.FindNearestCreature(CreaturesIds.LordVictorNefarius, 75.0f, true);
if (victor) if (victor != null)
victor.GetAI().SetData(1, 1); victor.GetAI().SetData(1, 1);
task.Schedule(TimeSpan.FromSeconds(2), summonTask2 => task.Schedule(TimeSpan.FromSeconds(2), summonTask2 =>
@@ -365,7 +365,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire
if (GetBossState(DataTypes.PyrogaurdEmberseer) == EncounterState.NotStarted) if (GetBossState(DataTypes.PyrogaurdEmberseer) == EncounterState.NotStarted)
{ {
Creature Emberseer = instance.GetCreature(PyroguardEmberseer); Creature Emberseer = instance.GetCreature(PyroguardEmberseer);
if (Emberseer) if (Emberseer != null)
Emberseer.GetAI().SetData(1, 1); Emberseer.GetAI().SetData(1, 1);
} }
break; break;
@@ -395,7 +395,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire
foreach (var itr in _incarceratorList) foreach (var itr in _incarceratorList)
{ {
Creature creature = instance.GetCreature(itr); Creature creature = instance.GetCreature(itr);
if (creature) if (creature != null)
creature.Respawn(); creature.Respawn();
} }
break; break;
@@ -513,13 +513,13 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire
runecreaturelist[i].Clear(); runecreaturelist[i].Clear();
GameObject rune = instance.GetGameObject(go_roomrunes[i]); GameObject rune = instance.GetGameObject(go_roomrunes[i]);
if (rune) if (rune != null)
{ {
for (byte j = 0; j < 3; ++j) for (byte j = 0; j < 3; ++j)
{ {
List<Creature> creatureList = rune.GetCreatureListWithEntryInGrid(BRSMiscConst.DragonspireMobs[j], 15.0f); List<Creature> creatureList = rune.GetCreatureListWithEntryInGrid(BRSMiscConst.DragonspireMobs[j], 15.0f);
foreach (var creature in creatureList) foreach (var creature in creatureList)
if (creature) if (creature != null)
runecreaturelist[i].Add(creature.GetGUID()); runecreaturelist[i].Add(creature.GetGUID());
} }
} }
@@ -535,7 +535,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire
{ {
bool _mobAlive = false; bool _mobAlive = false;
rune = instance.GetGameObject(go_roomrunes[i]); rune = instance.GetGameObject(go_roomrunes[i]);
if (!rune) if (rune == null)
continue; continue;
if (rune.GetGoState() == GameObjectState.Active) if (rune.GetGoState() == GameObjectState.Active)
@@ -543,7 +543,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire
foreach (ObjectGuid guid in runecreaturelist[i]) foreach (ObjectGuid guid in runecreaturelist[i])
{ {
mob = instance.GetCreature(guid); mob = instance.GetCreature(guid);
if (mob && mob.IsAlive()) if (mob != null && mob.IsAlive())
_mobAlive = true; _mobAlive = true;
} }
} }
@@ -587,10 +587,10 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire
{ {
SetBossState(DataTypes.DragonspireRoom, EncounterState.Done); SetBossState(DataTypes.DragonspireRoom, EncounterState.Done);
GameObject door1 = instance.GetGameObject(go_emberseerin); GameObject door1 = instance.GetGameObject(go_emberseerin);
if (door1) if (door1 != null)
HandleGameObject(ObjectGuid.Empty, true, door1); HandleGameObject(ObjectGuid.Empty, true, door1);
GameObject door2 = instance.GetGameObject(go_doors); GameObject door2 = instance.GetGameObject(go_doors);
if (door2) if (door2 != null)
HandleGameObject(ObjectGuid.Empty, true, door2); HandleGameObject(ObjectGuid.Empty, true, door2);
} }
} }
@@ -636,7 +636,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire
public override bool OnTrigger(Player player, AreaTriggerRecord areaTrigger) public override bool OnTrigger(Player player, AreaTriggerRecord areaTrigger)
{ {
if (player && player.IsAlive()) if (player != null && player.IsAlive())
{ {
InstanceScript instance = player.GetInstanceScript(); InstanceScript instance = player.GetInstanceScript();
if (instance != null) if (instance != null)
@@ -657,14 +657,14 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire
public override bool OnTrigger(Player player, AreaTriggerRecord areaTrigger) public override bool OnTrigger(Player player, AreaTriggerRecord areaTrigger)
{ {
if (player && player.IsAlive()) if (player != null && player.IsAlive())
{ {
InstanceScript instance = player.GetInstanceScript(); InstanceScript instance = player.GetInstanceScript();
if (instance == null) if (instance == null)
return false; return false;
Creature rend = player.FindNearestCreature(CreaturesIds.WarchiefRendBlackhand, 50.0f); Creature rend = player.FindNearestCreature(CreaturesIds.WarchiefRendBlackhand, 50.0f);
if (rend) if (rend != null)
{ {
rend.GetAI().SetData(BRSMiscConst.Areatrigger, BRSMiscConst.AreatriggerBlackrockStadium); rend.GetAI().SetData(BRSMiscConst.Areatrigger, BRSMiscConst.AreatriggerBlackrockStadium);
return true; return true;
@@ -688,7 +688,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire
if (instance != null) if (instance != null)
{ {
Creature infiltrator = ObjectAccessor.GetCreature(player, instance.GetGuidData(DataTypes.ScarshieldInfiltrator)); Creature infiltrator = ObjectAccessor.GetCreature(player, instance.GetGuidData(DataTypes.ScarshieldInfiltrator));
if (infiltrator) if (infiltrator != null)
{ {
if (player.GetLevel() >= 57) if (player.GetLevel() >= 57)
infiltrator.GetAI().SetData(1, 1); infiltrator.GetAI().SetData(1, 1);
@@ -86,13 +86,13 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire.OverlordWyrmt
if (!Summoned && HealthBelowPct(51)) if (!Summoned && HealthBelowPct(51))
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true);
if (target) if (target != null)
{ {
Creature warlord = me.SummonCreature(MiscConst.NpcSpirestoneWarlord, MiscConst.SummonLocation1, TempSummonType.TimedDespawn, TimeSpan.FromMinutes(5)); Creature warlord = me.SummonCreature(MiscConst.NpcSpirestoneWarlord, MiscConst.SummonLocation1, TempSummonType.TimedDespawn, TimeSpan.FromMinutes(5));
if (warlord) if (warlord != null)
warlord.GetAI().AttackStart(target); warlord.GetAI().AttackStart(target);
Creature berserker = me.SummonCreature(MiscConst.NpcSmolderthornBerserker, MiscConst.SummonLocation2, TempSummonType.TimedDespawn, TimeSpan.FromMinutes(5)); Creature berserker = me.SummonCreature(MiscConst.NpcSmolderthornBerserker, MiscConst.SummonLocation2, TempSummonType.TimedDespawn, TimeSpan.FromMinutes(5));
if (berserker) if (berserker != null)
berserker.GetAI().AttackStart(target); berserker.GetAI().AttackStart(target);
Summoned = true; Summoned = true;
} }
@@ -96,7 +96,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire.PyroguardEmbe
List<Creature> creatureList = me.GetCreatureListWithEntryInGrid(CreaturesIds.BlackhandIncarcerator, 35.0f); List<Creature> creatureList = me.GetCreatureListWithEntryInGrid(CreaturesIds.BlackhandIncarcerator, 35.0f);
foreach (var creature in creatureList) foreach (var creature in creatureList)
{ {
if (creature) if (creature != null)
{ {
creature.SetImmuneToAll(false); creature.SetImmuneToAll(false);
creature.InterruptSpell(CurrentSpellTypes.Channeled); creature.InterruptSpell(CurrentSpellTypes.Channeled);
@@ -136,7 +136,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire.PyroguardEmbe
_scheduler.Schedule(TimeSpan.FromSeconds(14), task => _scheduler.Schedule(TimeSpan.FromSeconds(14), task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true);
if (target) if (target != null)
DoCast(target, SpellIds.Pyroblast); DoCast(target, SpellIds.Pyroblast);
task.Repeat(TimeSpan.FromSeconds(15)); task.Repeat(TimeSpan.FromSeconds(15));
}); });
@@ -186,25 +186,25 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire.PyroguardEmbe
{ {
// update all runes // update all runes
GameObject rune1 = ObjectAccessor.GetGameObject(me, instance.GetGuidData(GameObjectsIds.EmberseerRune1)); GameObject rune1 = ObjectAccessor.GetGameObject(me, instance.GetGuidData(GameObjectsIds.EmberseerRune1));
if (rune1) if (rune1 != null)
rune1.SetGoState(state); rune1.SetGoState(state);
GameObject rune2 = ObjectAccessor.GetGameObject(me, instance.GetGuidData(GameObjectsIds.EmberseerRune2)); GameObject rune2 = ObjectAccessor.GetGameObject(me, instance.GetGuidData(GameObjectsIds.EmberseerRune2));
if (rune2) if (rune2 != null)
rune2.SetGoState(state); rune2.SetGoState(state);
GameObject rune3 = ObjectAccessor.GetGameObject(me, instance.GetGuidData(GameObjectsIds.EmberseerRune3)); GameObject rune3 = ObjectAccessor.GetGameObject(me, instance.GetGuidData(GameObjectsIds.EmberseerRune3));
if (rune3) if (rune3 != null)
rune3.SetGoState(state); rune3.SetGoState(state);
GameObject rune4 = ObjectAccessor.GetGameObject(me, instance.GetGuidData(GameObjectsIds.EmberseerRune4)); GameObject rune4 = ObjectAccessor.GetGameObject(me, instance.GetGuidData(GameObjectsIds.EmberseerRune4));
if (rune4) if (rune4 != null)
rune4.SetGoState(state); rune4.SetGoState(state);
GameObject rune5 = ObjectAccessor.GetGameObject(me, instance.GetGuidData(GameObjectsIds.EmberseerRune5)); GameObject rune5 = ObjectAccessor.GetGameObject(me, instance.GetGuidData(GameObjectsIds.EmberseerRune5));
if (rune5) if (rune5 != null)
rune5.SetGoState(state); rune5.SetGoState(state);
GameObject rune6 = ObjectAccessor.GetGameObject(me, instance.GetGuidData(GameObjectsIds.EmberseerRune6)); GameObject rune6 = ObjectAccessor.GetGameObject(me, instance.GetGuidData(GameObjectsIds.EmberseerRune6));
if (rune6) if (rune6 != null)
rune6.SetGoState(state); rune6.SetGoState(state);
GameObject rune7 = ObjectAccessor.GetGameObject(me, instance.GetGuidData(GameObjectsIds.EmberseerRune7)); GameObject rune7 = ObjectAccessor.GetGameObject(me, instance.GetGuidData(GameObjectsIds.EmberseerRune7));
if (rune7) if (rune7 != null)
rune7.SetGoState(state); rune7.SetGoState(state);
} }
@@ -234,7 +234,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire.PyroguardEmbe
// Had to do this because CallForHelp will ignore any npcs without Los // Had to do this because CallForHelp will ignore any npcs without Los
List<Creature> creatureList = me.GetCreatureListWithEntryInGrid(CreaturesIds.BlackhandIncarcerator, 60.0f); List<Creature> creatureList = me.GetCreatureListWithEntryInGrid(CreaturesIds.BlackhandIncarcerator, 60.0f);
foreach (var creature in creatureList) foreach (var creature in creatureList)
if (creature) if (creature != null)
DoZoneInCombat(creature); // GetAI().AttackStart(me.GetVictim()); DoZoneInCombat(creature); // GetAI().AttackStart(me.GetVictim());
_scheduler.Schedule(TimeSpan.FromSeconds(8), TimeSpan.FromSeconds(16), task => _scheduler.Schedule(TimeSpan.FromSeconds(8), TimeSpan.FromSeconds(16), task =>
@@ -224,7 +224,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire.RendBlackhand
break; break;
case 11: case 11:
Creature gyth = me.FindNearestCreature(CreaturesIds.Gyth, 10.0f, true); Creature gyth = me.FindNearestCreature(CreaturesIds.Gyth, 10.0f, true);
if (gyth) if (gyth != null)
gyth.GetAI().SetData(1, 1); gyth.GetAI().SetData(1, 1);
me.DespawnOrUnsummon(TimeSpan.FromSeconds(1), TimeSpan.FromDays(7)); me.DespawnOrUnsummon(TimeSpan.FromSeconds(1), TimeSpan.FromDays(7));
break; break;
@@ -39,7 +39,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire.ShadowHunterV
_scheduler.Schedule(TimeSpan.FromSeconds(8), task => _scheduler.Schedule(TimeSpan.FromSeconds(8), task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true);
if (target) if (target != null)
DoCast(target, SpellIds.Hex); DoCast(target, SpellIds.Hex);
task.Repeat(TimeSpan.FromSeconds(15)); task.Repeat(TimeSpan.FromSeconds(15));
}); });
@@ -38,7 +38,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackrockSpire.Thebeast
_scheduler.Schedule(TimeSpan.FromSeconds(3), task => _scheduler.Schedule(TimeSpan.FromSeconds(3), task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true);
if (target) if (target != null)
DoCast(target, SpellIds.Immolate); DoCast(target, SpellIds.Immolate);
task.Repeat(TimeSpan.FromSeconds(8)); task.Repeat(TimeSpan.FromSeconds(8));
}); });
@@ -205,7 +205,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair
var players = me.GetMap().GetPlayers(); var players = me.GetMap().GetPlayers();
foreach (var player in players) foreach (var player in players)
{ {
if (player) if (player != null)
{ {
DoCast(player, RandomHelper.RAND(SpellIds.BroodafBlue, SpellIds.BroodafBlack, SpellIds.BroodafRed, SpellIds.BroodafBronze, SpellIds.BroodafGreen), new CastSpellExtraArgs(true)); DoCast(player, RandomHelper.RAND(SpellIds.BroodafBlue, SpellIds.BroodafBlack, SpellIds.BroodafRed, SpellIds.BroodafBronze, SpellIds.BroodafGreen), new CastSpellExtraArgs(true));
@@ -265,11 +265,11 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair
_instance.SetBossState(DataTypes.Chromaggus, EncounterState.InProgress); _instance.SetBossState(DataTypes.Chromaggus, EncounterState.InProgress);
Creature creature = _instance.GetCreature(DataTypes.Chromaggus); Creature creature = _instance.GetCreature(DataTypes.Chromaggus);
if (creature) if (creature != null)
creature.GetAI().JustEngagedWith(player); creature.GetAI().JustEngagedWith(player);
GameObject go = _instance.GetGameObject(DataTypes.GoChromaggusDoor); GameObject go = _instance.GetGameObject(DataTypes.GoChromaggusDoor);
if (go) if (go != null)
_instance.HandleGameObject(ObjectGuid.Empty, true, go); _instance.HandleGameObject(ObjectGuid.Empty, true, go);
} }
@@ -253,7 +253,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair
foreach (var guid in EggList) foreach (var guid in EggList)
{ {
GameObject egg = instance.GetGameObject(guid); GameObject egg = instance.GetGameObject(guid);
if (egg) if (egg != null)
egg.SetLootState(LootState.JustDeactivated); egg.SetLootState(LootState.JustDeactivated);
} }
} }
@@ -264,7 +264,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair
{ {
case EncounterState.NotStarted: case EncounterState.NotStarted:
Creature nefarian = GetCreature(DataTypes.Nefarian); Creature nefarian = GetCreature(DataTypes.Nefarian);
if (nefarian) if (nefarian != null)
nefarian.DespawnOrUnsummon(); nefarian.DespawnOrUnsummon();
break; break;
case EncounterState.Fail: case EncounterState.Fail:
@@ -299,7 +299,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair
if (++EggCount == 15) if (++EggCount == 15)
{ {
Creature razor = GetCreature(DataTypes.RazorgoreTheUntamed); Creature razor = GetCreature(DataTypes.RazorgoreTheUntamed);
if (razor) if (razor != null)
{ {
SetData(BWLMisc.DataEggEvent, (uint)EncounterState.Done); SetData(BWLMisc.DataEggEvent, (uint)EncounterState.Done);
razor.RemoveAurasDueToSpell(42013); // MindControl razor.RemoveAurasDueToSpell(42013); // MindControl
@@ -337,7 +337,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair
for (uint i = RandomHelper.URand(2, 5); i > 0; --i) for (uint i = RandomHelper.URand(2, 5); i > 0; --i)
{ {
Creature summon = instance.SummonCreature(BWLMisc.Entry[RandomHelper.URand(0, 4)], BWLMisc.SummonPosition[RandomHelper.URand(0, 7)]); Creature summon = instance.SummonCreature(BWLMisc.Entry[RandomHelper.URand(0, 4)], BWLMisc.SummonPosition[RandomHelper.URand(0, 7)]);
if (summon) if (summon != null)
summon.GetAI().DoZoneInCombat(); summon.GetAI().DoZoneInCombat();
} }
_events.ScheduleEvent(EventIds.RazorSpawn, TimeSpan.FromSeconds(12), TimeSpan.FromSeconds(17)); _events.ScheduleEvent(EventIds.RazorSpawn, TimeSpan.FromSeconds(12), TimeSpan.FromSeconds(17));
@@ -345,12 +345,12 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair
case EventIds.RazorPhaseTwo: case EventIds.RazorPhaseTwo:
_events.CancelEvent(EventIds.RazorSpawn); _events.CancelEvent(EventIds.RazorSpawn);
Creature razor = GetCreature(DataTypes.RazorgoreTheUntamed); Creature razor = GetCreature(DataTypes.RazorgoreTheUntamed);
if (razor) if (razor != null)
razor.GetAI().DoAction(BWLMisc.ActionPhaseTwo); razor.GetAI().DoAction(BWLMisc.ActionPhaseTwo);
break; break;
case EventIds.RespawnNefarius: case EventIds.RespawnNefarius:
Creature nefarius = GetCreature(DataTypes.LordVictorNefarius); Creature nefarius = GetCreature(DataTypes.LordVictorNefarius);
if (nefarius) if (nefarius != null)
{ {
nefarius.SetActive(true); nefarius.SetActive(true);
nefarius.SetFarVisible(true); nefarius.SetFarVisible(true);
@@ -165,7 +165,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair.VictorNefarius
if (me.GetMapId() == 469) if (me.GetMapId() == 469)
{ {
if (!me.FindNearestCreature(BWLCreatureIds.Nefarian, 1000.0f, true)) if (me.FindNearestCreature(BWLCreatureIds.Nefarian, 1000.0f, true) == null)
_Reset(); _Reset();
me.SetVisible(true); me.SetVisible(true);
@@ -240,7 +240,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair.VictorNefarius
break; break;
case EventIds.Chaos1: case EventIds.Chaos1:
Creature gyth = me.FindNearestCreature(CreatureIds.Gyth, 75.0f, true); Creature gyth = me.FindNearestCreature(CreatureIds.Gyth, 75.0f, true);
if (gyth) if (gyth != null)
{ {
me.SetFacingToObject(gyth); me.SetFacingToObject(gyth);
Talk(TextIds.SayChaosSpell); Talk(TextIds.SayChaosSpell);
@@ -253,15 +253,15 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair.VictorNefarius
break; break;
case EventIds.Success1: case EventIds.Success1:
Unit player = me.SelectNearestPlayer(60.0f); Unit player = me.SelectNearestPlayer(60.0f);
if (player) if (player != null)
{ {
me.SetFacingToObject(player); me.SetFacingToObject(player);
Talk(TextIds.SaySuccess); Talk(TextIds.SaySuccess);
GameObject portcullis1 = me.FindNearestGameObject(GameObjectIds.PortcullisActive, 65.0f); GameObject portcullis1 = me.FindNearestGameObject(GameObjectIds.PortcullisActive, 65.0f);
if (portcullis1) if (portcullis1 != null)
portcullis1.SetGoState(GameObjectState.Active); portcullis1.SetGoState(GameObjectState.Active);
GameObject portcullis2 = me.FindNearestGameObject(GameObjectIds.PortcullisTobossrooms, 80.0f); GameObject portcullis2 = me.FindNearestGameObject(GameObjectIds.PortcullisTobossrooms, 80.0f);
if (portcullis2) if (portcullis2 != null)
portcullis2.SetGoState(GameObjectState.Active); portcullis2.SetGoState(GameObjectState.Active);
} }
_events.ScheduleEvent(EventIds.Success2, TimeSpan.FromSeconds(4)); _events.ScheduleEvent(EventIds.Success2, TimeSpan.FromSeconds(4));
@@ -300,7 +300,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair.VictorNefarius
break; break;
case 1: case 1:
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 40, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 40, true);
if (target) if (target != null)
DoCast(target, SpellIds.Shadowbolt); DoCast(target, SpellIds.Shadowbolt);
break; break;
} }
@@ -310,7 +310,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair.VictorNefarius
case EventIds.Fear: case EventIds.Fear:
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 40, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 40, true);
if (target) if (target != null)
DoCast(target, SpellIds.Fear); DoCast(target, SpellIds.Fear);
_events.ScheduleEvent(EventIds.Fear, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(20)); _events.ScheduleEvent(EventIds.Fear, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(20));
break; break;
@@ -318,7 +318,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair.VictorNefarius
case EventIds.MindControl: case EventIds.MindControl:
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 40, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 40, true);
if (target) if (target != null)
DoCast(target, SpellIds.ShadowCommand); DoCast(target, SpellIds.ShadowCommand);
_events.ScheduleEvent(EventIds.MindControl, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35)); _events.ScheduleEvent(EventIds.MindControl, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35));
break; break;
@@ -332,7 +332,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair.VictorNefarius
else else
CreatureID = MiscConst.Entry[RandomHelper.URand(0, 4)]; CreatureID = MiscConst.Entry[RandomHelper.URand(0, 4)];
Creature dragon = me.SummonCreature(CreatureID, MiscConst.DrakeSpawnLoc[i]); Creature dragon = me.SummonCreature(CreatureID, MiscConst.DrakeSpawnLoc[i]);
if (dragon) if (dragon != null)
{ {
dragon.SetFaction((uint)FactionTemplates.DragonflightBlack); dragon.SetFaction((uint)FactionTemplates.DragonflightBlack);
dragon.GetAI().AttackStart(me.GetVictim()); dragon.GetAI().AttackStart(me.GetVictim());
@@ -341,7 +341,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair.VictorNefarius
if (++SpawnedAdds >= 42) if (++SpawnedAdds >= 42)
{ {
Creature nefarian = me.SummonCreature(BWLCreatureIds.Nefarian, MiscConst.NefarianLoc[0]); Creature nefarian = me.SummonCreature(BWLCreatureIds.Nefarian, MiscConst.NefarianLoc[0]);
if (nefarian) if (nefarian != null)
{ {
nefarian.SetActive(true); nefarian.SetActive(true);
nefarian.SetFarVisible(true); nefarian.SetFarVisible(true);
@@ -441,7 +441,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair.VictorNefarius
if (id == 1) if (id == 1)
{ {
DoZoneInCombat(); DoZoneInCombat();
if (me.GetVictim()) if (me.GetVictim() != null)
AttackStart(me.GetVictim()); AttackStart(me.GetVictim());
} }
} }
@@ -497,7 +497,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair.VictorNefarius
break; break;
case EventIds.Classcall: case EventIds.Classcall:
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100.0f, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100.0f, true);
if (target) if (target != null)
switch (target.GetClass()) switch (target.GetClass())
{ {
case Class.Mage: case Class.Mage:
@@ -142,7 +142,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair.Razorgore
if (instance.GetData(BWLMisc.DataEggEvent) != (uint)EncounterState.Done) if (instance.GetData(BWLMisc.DataEggEvent) != (uint)EncounterState.Done)
{ {
Creature razorgore = instance.GetCreature(DataTypes.RazorgoreTheUntamed); Creature razorgore = instance.GetCreature(DataTypes.RazorgoreTheUntamed);
if (razorgore) if (razorgore != null)
{ {
razorgore.Attack(player, true); razorgore.Attack(player, true);
player.CastSpell(razorgore, SpellIds.Mindcontrol); player.CastSpell(razorgore, SpellIds.Mindcontrol);
@@ -97,7 +97,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair.Vaelastrasz
{ {
//selects a random target that isn't the current victim and is a mana user (selects mana users) but not pets //selects a random target that isn't the current victim and is a mana user (selects mana users) but not pets
//it also ignores targets who have the aura. We don't want to place the debuff on the same target twice. //it also ignores targets who have the aura. We don't want to place the debuff on the same target twice.
Unit target = SelectTarget(SelectTargetMethod.Random, 1, u => { return u && !u.IsPet() && u.GetPowerType() == PowerType.Mana && !u.HasAura(SpellIds.Burningadrenaline); }); Unit target = SelectTarget(SelectTargetMethod.Random, 1, u => { return u != null && !u.IsPet() && u.GetPowerType() == PowerType.Mana && !u.HasAura(SpellIds.Burningadrenaline); });
if (target != null) if (target != null)
me.CastSpell(target, SpellIds.Burningadrenaline, true); me.CastSpell(target, SpellIds.Burningadrenaline, true);
@@ -132,7 +132,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.BlackwingLair.Vaelastrasz
{ {
me.SetFaction((uint)FactionTemplates.DragonflightBlack); me.SetFaction((uint)FactionTemplates.DragonflightBlack);
Player player = Global.ObjAccessor.GetPlayer(me, PlayerGUID); Player player = Global.ObjAccessor.GetPlayer(me, PlayerGUID);
if (player) if (player != null)
AttackStart(player); AttackStart(player);
}); });
}); });
@@ -41,14 +41,14 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore.BaronGeddon
_scheduler.Schedule(TimeSpan.FromSeconds(30), task => _scheduler.Schedule(TimeSpan.FromSeconds(30), task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true, true, -(int)SpellIds.IgniteMana); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true, true, -(int)SpellIds.IgniteMana);
if (target) if (target != null)
DoCast(target, SpellIds.IgniteMana); DoCast(target, SpellIds.IgniteMana);
task.Repeat(TimeSpan.FromSeconds(30)); task.Repeat(TimeSpan.FromSeconds(30));
}); });
_scheduler.Schedule(TimeSpan.FromSeconds(35), task => _scheduler.Schedule(TimeSpan.FromSeconds(35), task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true);
if (target) if (target != null)
DoCast(target, SpellIds.LivingBomb); DoCast(target, SpellIds.LivingBomb);
task.Repeat(TimeSpan.FromSeconds(35)); task.Repeat(TimeSpan.FromSeconds(35));
}); });
@@ -64,7 +64,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore.Garr
_scheduler.Schedule(TimeSpan.FromSeconds(4), task => _scheduler.Schedule(TimeSpan.FromSeconds(4), task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0); Unit target = SelectTarget(SelectTargetMethod.Random, 0);
if (target) if (target != null)
DoCast(target, SpellIds.Immolate); DoCast(target, SpellIds.Immolate);
task.Repeat(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(10)); task.Repeat(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(10));
@@ -74,7 +74,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore.Garr
// ...and enrage if he is not. // ...and enrage if he is not.
_scheduler.Schedule(TimeSpan.FromSeconds(3), task => _scheduler.Schedule(TimeSpan.FromSeconds(3), task =>
{ {
if (!me.FindNearestCreature(MCCreatureIds.Garr, 20.0f)) if (me.FindNearestCreature(MCCreatureIds.Garr, 20.0f) == null)
DoCastSelf(SpellIds.SeparationAnxiety); DoCastSelf(SpellIds.SeparationAnxiety);
else if (me.HasAura(SpellIds.SeparationAnxiety)) else if (me.HasAura(SpellIds.SeparationAnxiety))
me.RemoveAurasDueToSpell(SpellIds.SeparationAnxiety); me.RemoveAurasDueToSpell(SpellIds.SeparationAnxiety);
@@ -33,14 +33,14 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore.Gehennas
_scheduler.Schedule(TimeSpan.FromSeconds(10), task => _scheduler.Schedule(TimeSpan.FromSeconds(10), task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0); Unit target = SelectTarget(SelectTargetMethod.Random, 0);
if (target) if (target != null)
DoCast(target, SpellIds.RainOfFire); DoCast(target, SpellIds.RainOfFire);
task.Repeat(TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(12)); task.Repeat(TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(12));
}); });
_scheduler.Schedule(TimeSpan.FromSeconds(6), task => _scheduler.Schedule(TimeSpan.FromSeconds(6), task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 1); Unit target = SelectTarget(SelectTargetMethod.Random, 1);
if (target) if (target != null)
DoCast(target, SpellIds.ShadowBolt); DoCast(target, SpellIds.ShadowBolt);
task.Repeat(TimeSpan.FromSeconds(7)); task.Repeat(TimeSpan.FromSeconds(7));
}); });
@@ -46,7 +46,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore.Golemagg
_scheduler.Schedule(TimeSpan.FromSeconds(7), task => _scheduler.Schedule(TimeSpan.FromSeconds(7), task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0); Unit target = SelectTarget(SelectTargetMethod.Random, 0);
if (target) if (target != null)
DoCast(target, SpellIds.Pyroblast); DoCast(target, SpellIds.Pyroblast);
task.Repeat(TimeSpan.FromSeconds(7)); task.Repeat(TimeSpan.FromSeconds(7));
}); });
@@ -104,7 +104,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore.Golemagg
return; return;
Creature pGolemagg = ObjectAccessor.GetCreature(me, _instance.GetGuidData(DataTypes.GolemaggTheIncinerator)); Creature pGolemagg = ObjectAccessor.GetCreature(me, _instance.GetGuidData(DataTypes.GolemaggTheIncinerator));
if (pGolemagg) if (pGolemagg != null)
{ {
if (pGolemagg.IsAlive()) if (pGolemagg.IsAlive())
{ {
@@ -214,7 +214,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore
else else
{ {
TempSummon summon = instance.SummonCreature(MCCreatureIds.MajordomoExecutus, MCMiscConst.RagnarosTelePos); TempSummon summon = instance.SummonCreature(MCCreatureIds.MajordomoExecutus, MCMiscConst.RagnarosTelePos);
if (summon) if (summon != null)
summon.GetAI().DoAction(ActionIds.StartRagnarosAlt); summon.GetAI().DoAction(ActionIds.StartRagnarosAlt);
} }
} }
@@ -52,7 +52,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore.Magmadar
_scheduler.Schedule(TimeSpan.FromSeconds(12), task => _scheduler.Schedule(TimeSpan.FromSeconds(12), task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true, true, -(int)SpellIds.LavaBomb); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true, true, -(int)SpellIds.LavaBomb);
if (target) if (target != null)
DoCast(target, SpellIds.LavaBomb); DoCast(target, SpellIds.LavaBomb);
task.Repeat(TimeSpan.FromSeconds(12)); task.Repeat(TimeSpan.FromSeconds(12));
}); });
@@ -69,7 +69,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore.Majordomo
_scheduler.Schedule(TimeSpan.FromSeconds(20), task => _scheduler.Schedule(TimeSpan.FromSeconds(20), task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 1); Unit target = SelectTarget(SelectTargetMethod.Random, 1);
if (target) if (target != null)
DoCast(target, SpellIds.Teleport); DoCast(target, SpellIds.Teleport);
task.Repeat(TimeSpan.FromSeconds(20)); task.Repeat(TimeSpan.FromSeconds(20));
}); });
@@ -84,7 +84,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore.Majordomo
if (!UpdateVictim()) if (!UpdateVictim())
return; return;
if (!me.FindNearestCreature(MCCreatureIds.FlamewakerHealer, 100.0f) && !me.FindNearestCreature(MCCreatureIds.FlamewakerElite, 100.0f)) if (me.FindNearestCreature(MCCreatureIds.FlamewakerHealer, 100.0f) == null && me.FindNearestCreature(MCCreatureIds.FlamewakerElite, 100.0f) == null)
{ {
instance.UpdateEncounterStateForKilledCreature(me.GetEntry(), me); instance.UpdateEncounterStateForKilledCreature(me.GetEntry(), me);
me.SetFaction((uint)FactionTemplates.Friendly); me.SetFaction((uint)FactionTemplates.Friendly);
@@ -140,7 +140,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore
case EventIds.Intro4: case EventIds.Intro4:
Talk(TextIds.SayArrival5Rag); Talk(TextIds.SayArrival5Rag);
Creature executus = ObjectAccessor.GetCreature(me, instance.GetGuidData(DataTypes.MajordomoExecutus)); Creature executus = ObjectAccessor.GetCreature(me, instance.GetGuidData(DataTypes.MajordomoExecutus));
if (executus) if (executus != null)
Unit.Kill(me, executus); Unit.Kill(me, executus);
break; break;
case EventIds.Intro5: case EventIds.Intro5:
@@ -165,7 +165,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore
me.SetEmoteState(Emote.OneshotNone); me.SetEmoteState(Emote.OneshotNone);
me.HandleEmoteCommand(Emote.OneshotEmerge); me.HandleEmoteCommand(Emote.OneshotEmerge);
Unit target = SelectTarget(SelectTargetMethod.Random, 0); Unit target = SelectTarget(SelectTargetMethod.Random, 0);
if (target) if (target != null)
AttackStart(target); AttackStart(target);
instance.SetData(MCMiscConst.DataRagnarosAdds, 0); instance.SetData(MCMiscConst.DataRagnarosAdds, 0);
@@ -70,7 +70,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore.Shazzrah
break; break;
case EventIds.ShazzrahCurse: case EventIds.ShazzrahCurse:
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true, true, -(int)SpellIds.ShazzrahCurse); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true, true, -(int)SpellIds.ShazzrahCurse);
if (target) if (target != null)
DoCast(target, SpellIds.ShazzrahCurse); DoCast(target, SpellIds.ShazzrahCurse);
_events.ScheduleEvent(EventIds.ShazzrahCurse, TimeSpan.FromSeconds(25), TimeSpan.FromSeconds(30)); _events.ScheduleEvent(EventIds.ShazzrahCurse, TimeSpan.FromSeconds(25), TimeSpan.FromSeconds(30));
break; break;
@@ -123,11 +123,11 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore.Shazzrah
void HandleScript(uint effIndex) void HandleScript(uint effIndex)
{ {
Unit target = GetHitUnit(); Unit target = GetHitUnit();
if (target) if (target != null)
{ {
target.CastSpell(GetCaster(), SpellIds.ShazzrahGate, true); target.CastSpell(GetCaster(), SpellIds.ShazzrahGate, true);
Creature creature = GetCaster().ToCreature(); Creature creature = GetCaster().ToCreature();
if (creature) if (creature != null)
creature.GetAI().AttackStart(target); // Attack the target which caster will teleport to. creature.GetAI().AttackStart(target); // Attack the target which caster will teleport to.
} }
} }
@@ -61,7 +61,7 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore.Sulfuron
_scheduler.Schedule(TimeSpan.FromSeconds(2), task => _scheduler.Schedule(TimeSpan.FromSeconds(2), task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true);
if (target) if (target != null)
DoCast(target, SpellIds.Flamespear); DoCast(target, SpellIds.Flamespear);
task.Repeat(TimeSpan.FromSeconds(12), TimeSpan.FromSeconds(16)); task.Repeat(TimeSpan.FromSeconds(12), TimeSpan.FromSeconds(16));
}); });
@@ -100,21 +100,21 @@ namespace Scripts.EasternKingdoms.BlackrockMountain.MoltenCore.Sulfuron
_scheduler.Schedule(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(30), task => _scheduler.Schedule(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(30), task =>
{ {
Unit target = DoSelectLowestHpFriendly(60.0f, 1); Unit target = DoSelectLowestHpFriendly(60.0f, 1);
if (target) if (target != null)
DoCast(target, SpellIds.Heal); DoCast(target, SpellIds.Heal);
task.Repeat(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(20)); task.Repeat(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(20));
}); });
_scheduler.Schedule(TimeSpan.FromSeconds(2), task => _scheduler.Schedule(TimeSpan.FromSeconds(2), task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true, true, -(int)SpellIds.Shadowwordpain); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true, true, -(int)SpellIds.Shadowwordpain);
if (target) if (target != null)
DoCast(target, SpellIds.Shadowwordpain); DoCast(target, SpellIds.Shadowwordpain);
task.Repeat(TimeSpan.FromSeconds(18), TimeSpan.FromSeconds(26)); task.Repeat(TimeSpan.FromSeconds(18), TimeSpan.FromSeconds(26));
}); });
_scheduler.Schedule(TimeSpan.FromSeconds(8), task => _scheduler.Schedule(TimeSpan.FromSeconds(8), task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true, true, -(int)SpellIds.Immolate); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true, true, -(int)SpellIds.Immolate);
if (target) if (target != null)
DoCast(target, SpellIds.Immolate); DoCast(target, SpellIds.Immolate);
task.Repeat(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(25)); task.Repeat(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(25));
}); });
@@ -86,7 +86,7 @@ namespace Scripts.EasternKingdoms.Deadmines
return; return;
GameObject pIronCladDoor = instance.GetGameObject(IronCladDoorGUID); GameObject pIronCladDoor = instance.GetGameObject(IronCladDoorGUID);
if (!pIronCladDoor) if (pIronCladDoor == null)
return; return;
switch (State) switch (State)
@@ -127,7 +127,7 @@ namespace Scripts.EasternKingdoms.Deadmines
void SummonCreatures() void SummonCreatures()
{ {
GameObject pIronCladDoor = instance.GetGameObject(IronCladDoorGUID); GameObject pIronCladDoor = instance.GetGameObject(IronCladDoorGUID);
if (pIronCladDoor) if (pIronCladDoor != null)
{ {
Creature DefiasPirate1 = pIronCladDoor.SummonCreature(657, pIronCladDoor.GetPositionX() - 2, pIronCladDoor.GetPositionY() - 7, pIronCladDoor.GetPositionZ(), 0, TempSummonType.CorpseTimedDespawn, TimeSpan.FromSeconds(3)); Creature DefiasPirate1 = pIronCladDoor.SummonCreature(657, pIronCladDoor.GetPositionX() - 2, pIronCladDoor.GetPositionY() - 7, pIronCladDoor.GetPositionZ(), 0, TempSummonType.CorpseTimedDespawn, TimeSpan.FromSeconds(3));
Creature DefiasPirate2 = pIronCladDoor.SummonCreature(657, pIronCladDoor.GetPositionX() + 3, pIronCladDoor.GetPositionY() - 6, pIronCladDoor.GetPositionZ(), 0, TempSummonType.CorpseTimedDespawn, TimeSpan.FromSeconds(3)); Creature DefiasPirate2 = pIronCladDoor.SummonCreature(657, pIronCladDoor.GetPositionX() + 3, pIronCladDoor.GetPositionY() - 6, pIronCladDoor.GetPositionZ(), 0, TempSummonType.CorpseTimedDespawn, TimeSpan.FromSeconds(3));
@@ -144,7 +144,7 @@ namespace Scripts.EasternKingdoms.Deadmines
Creature pDefiasPirate1 = instance.GetCreature(DefiasPirate1GUID); Creature pDefiasPirate1 = instance.GetCreature(DefiasPirate1GUID);
Creature pDefiasPirate2 = instance.GetCreature(DefiasPirate2GUID); Creature pDefiasPirate2 = instance.GetCreature(DefiasPirate2GUID);
if (!pDefiasPirate1 || !pDefiasPirate2) if (pDefiasPirate1 == null || pDefiasPirate2 == null)
return; return;
MoveCreatureInside(pDefiasPirate1); MoveCreatureInside(pDefiasPirate1);
@@ -160,7 +160,7 @@ namespace Scripts.EasternKingdoms.Deadmines
void ShootCannon() void ShootCannon()
{ {
GameObject pDefiasCannon = instance.GetGameObject(DefiasCannonGUID); GameObject pDefiasCannon = instance.GetGameObject(DefiasCannonGUID);
if (pDefiasCannon) if (pDefiasCannon != null)
{ {
pDefiasCannon.SetGoState(GameObjectState.Active); pDefiasCannon.SetGoState(GameObjectState.Active);
pDefiasCannon.PlayDirectSound(SoundIds.Cannonfire); pDefiasCannon.PlayDirectSound(SoundIds.Cannonfire);
@@ -170,7 +170,7 @@ namespace Scripts.EasternKingdoms.Deadmines
void BlastOutDoor() void BlastOutDoor()
{ {
GameObject pIronCladDoor = instance.GetGameObject(IronCladDoorGUID); GameObject pIronCladDoor = instance.GetGameObject(IronCladDoorGUID);
if (pIronCladDoor) if (pIronCladDoor != null)
{ {
pIronCladDoor.SetGoState(GameObjectState.Destroyed); pIronCladDoor.SetGoState(GameObjectState.Destroyed);
pIronCladDoor.PlayDirectSound(SoundIds.Destroydoor); pIronCladDoor.PlayDirectSound(SoundIds.Destroydoor);
@@ -180,7 +180,7 @@ namespace Scripts.EasternKingdoms.Deadmines
void LeverStucked() void LeverStucked()
{ {
GameObject pDoorLever = instance.GetGameObject(DoorLeverGUID); GameObject pDoorLever = instance.GetGameObject(DoorLeverGUID);
if (pDoorLever) if (pDoorLever != null)
pDoorLever.SetFlag(GameObjectFlags.InteractCond); pDoorLever.SetFlag(GameObjectFlags.InteractCond);
} }
@@ -218,7 +218,7 @@ namespace Scripts.EasternKingdoms.Deadmines
if (data == (uint)EncounterState.Done) if (data == (uint)EncounterState.Done)
{ {
GameObject go = instance.GetGameObject(FactoryDoorGUID); GameObject go = instance.GetGameObject(FactoryDoorGUID);
if (go) if (go != null)
go.SetGoState(GameObjectState.Active); go.SetGoState(GameObjectState.Active);
} }
break; break;
@@ -143,7 +143,7 @@ namespace Scripts.EasternKingdoms.Deadmines
break; break;
GameObject go = ObjectAccessor.GetGameObject(me, instance.GetGuidData(DataTypes.SmiteChest)); GameObject go = ObjectAccessor.GetGameObject(me, instance.GetGuidData(DataTypes.SmiteChest));
if (go) if (go != null)
{ {
me.GetMotionMaster().Clear(); me.GetMotionMaster().Clear();
me.GetMotionMaster().MovePoint(1, go.GetPositionX() - 1.5f, go.GetPositionY() + 1.4f, go.GetPositionZ()); me.GetMotionMaster().MovePoint(1, go.GetPositionX() - 1.5f, go.GetPositionY() + 1.4f, go.GetPositionZ());
@@ -93,7 +93,7 @@ namespace Scripts.EasternKingdoms.Gnomeregan
public override void OnUnitDeath(Unit unit) public override void OnUnitDeath(Unit unit)
{ {
Creature creature = unit.ToCreature(); Creature creature = unit.ToCreature();
if (creature) if (creature != null)
switch (creature.GetEntry()) switch (creature.GetEntry())
{ {
case GNOCreatureIds.ViciousFallout: case GNOCreatureIds.ViciousFallout:
@@ -68,7 +68,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Curator
_scheduler.Schedule(TimeSpan.FromSeconds(12), task => _scheduler.Schedule(TimeSpan.FromSeconds(12), task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.MaxThreat, 1); Unit target = SelectTarget(SelectTargetMethod.MaxThreat, 1);
if (target) if (target != null)
DoCast(target, SpellIds.HatefulBolt); DoCast(target, SpellIds.HatefulBolt);
task.Repeat(TimeSpan.FromSeconds(7), TimeSpan.FromSeconds(15)); task.Repeat(TimeSpan.FromSeconds(7), TimeSpan.FromSeconds(15));
}); });
@@ -175,7 +175,7 @@ namespace Scripts.EasternKingdoms.Karazhan
public override void OnUnitDeath(Unit unit) public override void OnUnitDeath(Unit unit)
{ {
Creature creature = unit.ToCreature(); Creature creature = unit.ToCreature();
if (!creature) if (creature == null)
return; return;
switch (creature.GetEntry()) switch (creature.GetEntry())
@@ -239,7 +239,7 @@ namespace Scripts.EasternKingdoms.Karazhan
HandleGameObject(StageDoorLeftGUID, true); HandleGameObject(StageDoorLeftGUID, true);
HandleGameObject(StageDoorRightGUID, true); HandleGameObject(StageDoorRightGUID, true);
GameObject sideEntrance = instance.GetGameObject(SideEntranceDoor); GameObject sideEntrance = instance.GetGameObject(SideEntranceDoor);
if (sideEntrance) if (sideEntrance != null)
sideEntrance.RemoveFlag(GameObjectFlags.Locked); sideEntrance.RemoveFlag(GameObjectFlags.Locked);
UpdateEncounterStateForKilledCreature(16812, null); UpdateEncounterStateForKilledCreature(16812, null);
} }
@@ -59,14 +59,14 @@ namespace Scripts.EasternKingdoms.Karazhan.MaidenOfVirtue
_scheduler.Schedule(TimeSpan.FromSeconds(8), task => _scheduler.Schedule(TimeSpan.FromSeconds(8), task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 50, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 50, true);
if (target) if (target != null)
DoCast(target, SpellIds.Holyfire); DoCast(target, SpellIds.Holyfire);
task.Repeat(TimeSpan.FromSeconds(8), TimeSpan.FromSeconds(19)); task.Repeat(TimeSpan.FromSeconds(8), TimeSpan.FromSeconds(19));
}); });
_scheduler.Schedule(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(25), task => _scheduler.Schedule(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(25), task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 80, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 80, true);
if (target) if (target != null)
DoCast(target, SpellIds.Holywrath); DoCast(target, SpellIds.Holywrath);
task.Repeat(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(25)); task.Repeat(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(25));
}); });
@@ -75,7 +75,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Midnight
public override void EnterEvadeMode(EvadeReason why) public override void EnterEvadeMode(EvadeReason why)
{ {
Creature midnight = ObjectAccessor.GetCreature(me, _midnightGUID); Creature midnight = ObjectAccessor.GetCreature(me, _midnightGUID);
if (midnight) if (midnight != null)
base._DespawnAtEvade(TimeSpan.FromSeconds(10), midnight); base._DespawnAtEvade(TimeSpan.FromSeconds(10), midnight);
me.DespawnOrUnsummon(); me.DespawnOrUnsummon();
@@ -92,7 +92,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Midnight
_scheduler.Schedule(TimeSpan.FromSeconds(25), TimeSpan.FromSeconds(45), task => _scheduler.Schedule(TimeSpan.FromSeconds(25), TimeSpan.FromSeconds(45), task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0); Unit target = SelectTarget(SelectTargetMethod.Random, 0);
if (target) if (target != null)
DoCast(target, SpellIds.IntangiblePresence); DoCast(target, SpellIds.IntangiblePresence);
task.Repeat(TimeSpan.FromSeconds(25), TimeSpan.FromSeconds(45)); task.Repeat(TimeSpan.FromSeconds(25), TimeSpan.FromSeconds(45));
@@ -116,7 +116,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Midnight
_phase = Phases.None; _phase = Phases.None;
Creature midnight = ObjectAccessor.GetCreature(me, _midnightGUID); Creature midnight = ObjectAccessor.GetCreature(me, _midnightGUID);
if (midnight) if (midnight != null)
midnight.GetAI().DoCastAOE(SpellIds.Mount, new CastSpellExtraArgs(true)); midnight.GetAI().DoCastAOE(SpellIds.Mount, new CastSpellExtraArgs(true));
} }
} }
@@ -131,7 +131,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Midnight
if (summon.GetEntry() == CreatureIds.AttumenMounted) if (summon.GetEntry() == CreatureIds.AttumenMounted)
{ {
Creature midnight = ObjectAccessor.GetCreature(me, _midnightGUID); Creature midnight = ObjectAccessor.GetCreature(me, _midnightGUID);
if (midnight) if (midnight != null)
{ {
if (midnight.GetHealth() > me.GetHealth()) if (midnight.GetHealth() > me.GetHealth())
summon.SetHealth(midnight.GetHealth()); summon.SetHealth(midnight.GetHealth());
@@ -164,7 +164,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Midnight
foreach (var refe in me.GetThreatManager().GetSortedThreatList()) foreach (var refe in me.GetThreatManager().GetSortedThreatList())
{ {
target = refe.GetVictim(); target = refe.GetVictim();
if (target && !target.IsWithinDist(me, 8.00f, false) && target.IsWithinDist(me, 25.0f, false)) if (target != null && !target.IsWithinDist(me, 8.00f, false) && target.IsWithinDist(me, 25.0f, false))
targetList.Add(target); targetList.Add(target);
target = null; target = null;
@@ -189,7 +189,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Midnight
{ {
Talk(TextIds.SayDeath); Talk(TextIds.SayDeath);
Unit midnight = Global.ObjAccessor.GetUnit(me, _midnightGUID); Unit midnight = Global.ObjAccessor.GetUnit(me, _midnightGUID);
if (midnight) if (midnight != null)
midnight.KillSelf(); midnight.KillSelf();
_JustDied(); _JustDied();
@@ -217,7 +217,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Midnight
if (spellInfo.Id == SpellIds.Mount) if (spellInfo.Id == SpellIds.Mount)
{ {
Creature midnight = ObjectAccessor.GetCreature(me, _midnightGUID); Creature midnight = ObjectAccessor.GetCreature(me, _midnightGUID);
if (midnight) if (midnight != null)
{ {
_phase = Phases.None; _phase = Phases.None;
_scheduler.CancelAll(); _scheduler.CancelAll();
@@ -235,25 +235,25 @@ namespace Scripts.EasternKingdoms.Karazhan.Midnight
Talk(TextIds.SayMount); Talk(TextIds.SayMount);
_scheduler.Schedule(TimeSpan.FromSeconds(1), task => _scheduler.Schedule(TimeSpan.FromSeconds(1), task =>
{ {
Creature midnight = ObjectAccessor.GetCreature(me, _midnightGUID); Creature midnight = ObjectAccessor.GetCreature(me, _midnightGUID);
if (midnight) if (midnight != null)
{ {
if (me.IsWithinDist2d(midnight, 5.0f)) if (me.IsWithinDist2d(midnight, 5.0f))
{ {
DoCastAOE(SpellIds.SummonAttumenMounted); DoCastAOE(SpellIds.SummonAttumenMounted);
me.SetVisible(false); me.SetVisible(false);
me.GetMotionMaster().Clear(); me.GetMotionMaster().Clear();
midnight.SetVisible(false); midnight.SetVisible(false);
} }
else else
{ {
midnight.GetMotionMaster().MoveFollow(me, 2.0f, 0.0f); midnight.GetMotionMaster().MoveFollow(me, 2.0f, 0.0f);
me.GetMotionMaster().MoveFollow(midnight, 2.0f, 0.0f); me.GetMotionMaster().MoveFollow(midnight, 2.0f, 0.0f);
task.Repeat(); task.Repeat();
} }
} }
}); });
} }
} }
} }
@@ -336,7 +336,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Midnight
if (_phase == Phases.AttumenEngages) if (_phase == Phases.AttumenEngages)
{ {
Unit unit = Global.ObjAccessor.GetUnit(me, _attumenGUID); Unit unit = Global.ObjAccessor.GetUnit(me, _attumenGUID);
if (unit) if (unit != null)
Talk(TextIds.SayMidnightKill, unit); Talk(TextIds.SayMidnightKill, unit);
} }
} }
@@ -122,8 +122,8 @@ namespace Scripts.EasternKingdoms.Karazhan.Moroes
if (!AddGUID[i].IsEmpty()) if (!AddGUID[i].IsEmpty())
{ {
Creature temp = ObjectAccessor.GetCreature(me, AddGUID[i]); Creature temp = ObjectAccessor.GetCreature(me, AddGUID[i]);
if (temp && temp.IsAlive()) if (temp != null && temp.IsAlive())
if (!temp.GetVictim()) if (temp.GetVictim() == null)
temp.GetAI().AttackStart(me.GetVictim()); temp.GetAI().AttackStart(me.GetVictim());
} }
} }
@@ -144,7 +144,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Moroes
Talk(TextIds.SaySpecial); Talk(TextIds.SaySpecial);
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true);
if (target) if (target != null)
target.CastSpell(target, SpellIds.Garrote, true); target.CastSpell(target, SpellIds.Garrote, true);
InVanish = false; InVanish = false;
@@ -155,7 +155,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Moroes
_scheduler.Schedule(TimeSpan.FromSeconds(35), MiscConst.GroupNonEnrage, task => _scheduler.Schedule(TimeSpan.FromSeconds(35), MiscConst.GroupNonEnrage, task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.MinDistance, 0, 0.0f, true, false); Unit target = SelectTarget(SelectTargetMethod.MinDistance, 0, 0.0f, true, false);
if (target) if (target != null)
DoCast(target, SpellIds.Blind); DoCast(target, SpellIds.Blind);
task.Repeat(TimeSpan.FromSeconds(40)); task.Repeat(TimeSpan.FromSeconds(40));
}); });
@@ -193,7 +193,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Moroes
for (var i = 0; i < 4; ++i) for (var i = 0; i < 4; ++i)
{ {
Creature creature = me.SummonCreature(AddList[i], MiscConst.Locations[i], TempSummonType.CorpseTimedDespawn, TimeSpan.FromSeconds(10)); Creature creature = me.SummonCreature(AddList[i], MiscConst.Locations[i], TempSummonType.CorpseTimedDespawn, TimeSpan.FromSeconds(10));
if (creature) if (creature != null)
{ {
AddGUID[i] = creature.GetGUID(); AddGUID[i] = creature.GetGUID();
AddId[i] = AddList[i]; AddId[i] = AddList[i];
@@ -205,7 +205,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Moroes
for (byte i = 0; i < 4; ++i) for (byte i = 0; i < 4; ++i)
{ {
Creature creature = me.SummonCreature(AddId[i], MiscConst.Locations[i], TempSummonType.CorpseTimedDespawn, TimeSpan.FromSeconds(10)); Creature creature = me.SummonCreature(AddId[i], MiscConst.Locations[i], TempSummonType.CorpseTimedDespawn, TimeSpan.FromSeconds(10));
if (creature) if (creature != null)
AddGUID[i] = creature.GetGUID(); AddGUID[i] = creature.GetGUID();
} }
} }
@@ -227,7 +227,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Moroes
if (!AddGUID[i].IsEmpty()) if (!AddGUID[i].IsEmpty())
{ {
Creature temp = ObjectAccessor.GetCreature(me, AddGUID[i]); Creature temp = ObjectAccessor.GetCreature(me, AddGUID[i]);
if (temp) if (temp != null)
temp.DespawnOrUnsummon(); temp.DespawnOrUnsummon();
} }
} }
@@ -240,7 +240,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Moroes
if (!AddGUID[i].IsEmpty()) if (!AddGUID[i].IsEmpty())
{ {
Creature temp = ObjectAccessor.GetCreature((me), AddGUID[i]); Creature temp = ObjectAccessor.GetCreature((me), AddGUID[i]);
if (temp && temp.IsAlive()) if (temp != null && temp.IsAlive())
{ {
temp.GetAI().AttackStart(me.GetVictim()); temp.GetAI().AttackStart(me.GetVictim());
DoZoneInCombat(temp); DoZoneInCombat(temp);
@@ -290,7 +290,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Moroes
public void AcquireGUID() public void AcquireGUID()
{ {
Creature Moroes = ObjectAccessor.GetCreature(me, instance.GetGuidData(DataTypes.Moroes)); Creature Moroes = ObjectAccessor.GetCreature(me, instance.GetGuidData(DataTypes.Moroes));
if (Moroes) if (Moroes != null)
{ {
for (byte i = 0; i < 4; ++i) for (byte i = 0; i < 4; ++i)
{ {
@@ -307,7 +307,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Moroes
if (!TempGUID.IsEmpty()) if (!TempGUID.IsEmpty())
{ {
Unit unit = Global.ObjAccessor.GetUnit(me, TempGUID); Unit unit = Global.ObjAccessor.GetUnit(me, TempGUID);
if (unit && unit.IsAlive()) if (unit != null && unit.IsAlive())
return unit; return unit;
} }
@@ -369,7 +369,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Moroes
if (ManaBurn_Timer <= diff) if (ManaBurn_Timer <= diff)
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true);
if (target) if (target != null)
if (target.GetPowerType() == PowerType.Mana) if (target.GetPowerType() == PowerType.Mana)
DoCast(target, SpellIds.Manaburn); DoCast(target, SpellIds.Manaburn);
ManaBurn_Timer = 5000; // 3 sec cast ManaBurn_Timer = 5000; // 3 sec cast
@@ -379,7 +379,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Moroes
if (ShadowWordPain_Timer <= diff) if (ShadowWordPain_Timer <= diff)
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true);
if (target) if (target != null)
{ {
DoCast(target, SpellIds.Swpain); DoCast(target, SpellIds.Swpain);
ShadowWordPain_Timer = 7000; ShadowWordPain_Timer = 7000;
@@ -511,7 +511,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Moroes
if (DispelMagic_Timer <= diff) if (DispelMagic_Timer <= diff)
{ {
Unit target = RandomHelper.RAND(SelectGuestTarget(), SelectTarget(SelectTargetMethod.Random, 0, 100, true)); Unit target = RandomHelper.RAND(SelectGuestTarget(), SelectTarget(SelectTargetMethod.Random, 0, 100, true));
if (target) if (target != null)
DoCast(target, SpellIds.Dispelmagic); DoCast(target, SpellIds.Dispelmagic);
DispelMagic_Timer = 25000; DispelMagic_Timer = 25000;
@@ -92,7 +92,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Netherspite
bool IsBetween(WorldObject u1, WorldObject target, WorldObject u2) // the in-line checker bool IsBetween(WorldObject u1, WorldObject target, WorldObject u2) // the in-line checker
{ {
if (!u1 || !u2 || !target) if (u1 == null || u2 == null || target == null)
return false; return false;
float xn, yn, xp, yp, xh, yh; float xn, yn, xp, yp, xh, yh;
@@ -134,7 +134,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Netherspite
for (int i = 0; i < 3; ++i) for (int i = 0; i < 3; ++i)
{ {
Creature portal = me.SummonCreature(MiscConst.PortalID[i], MiscConst.PortalCoord[pos[i]].X, MiscConst.PortalCoord[pos[i]].Y, MiscConst.PortalCoord[pos[i]].Z, 0, TempSummonType.TimedDespawn, TimeSpan.FromMinutes(1)); Creature portal = me.SummonCreature(MiscConst.PortalID[i], MiscConst.PortalCoord[pos[i]].X, MiscConst.PortalCoord[pos[i]].Y, MiscConst.PortalCoord[pos[i]].Z, 0, TempSummonType.TimedDespawn, TimeSpan.FromMinutes(1));
if (portal) if (portal != null)
{ {
PortalGUID[i] = portal.GetGUID(); PortalGUID[i] = portal.GetGUID();
portal.AddAura(MiscConst.PortalVisual[i], portal); portal.AddAura(MiscConst.PortalVisual[i], portal);
@@ -147,11 +147,11 @@ namespace Scripts.EasternKingdoms.Karazhan.Netherspite
for (int i = 0; i < 3; ++i) for (int i = 0; i < 3; ++i)
{ {
Creature portal = ObjectAccessor.GetCreature(me, PortalGUID[i]); Creature portal = ObjectAccessor.GetCreature(me, PortalGUID[i]);
if (portal) if (portal != null)
portal.DisappearAndDie(); portal.DisappearAndDie();
Creature portal1 = ObjectAccessor.GetCreature(me, BeamerGUID[i]); Creature portal1 = ObjectAccessor.GetCreature(me, BeamerGUID[i]);
if (portal1) if (portal1 != null)
portal1.DisappearAndDie(); portal1.DisappearAndDie();
PortalGUID[i].Clear(); PortalGUID[i].Clear();
@@ -164,7 +164,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Netherspite
for (int j = 0; j < 3; ++j) // j = color for (int j = 0; j < 3; ++j) // j = color
{ {
Creature portal = ObjectAccessor.GetCreature(me, PortalGUID[j]); Creature portal = ObjectAccessor.GetCreature(me, PortalGUID[j]);
if (portal) if (portal != null)
{ {
// the one who's been cast upon before // the one who's been cast upon before
Unit current = Global.ObjAccessor.GetUnit(portal, BeamTarget[j]); Unit current = Global.ObjAccessor.GetUnit(portal, BeamTarget[j]);
@@ -176,8 +176,8 @@ namespace Scripts.EasternKingdoms.Karazhan.Netherspite
// get the best suitable target // get the best suitable target
foreach (var player in players) foreach (var player in players)
{ {
if (player && player.IsAlive() // alive if (player != null && player.IsAlive() // alive
&& (!target || target.GetDistance2d(portal) > player.GetDistance2d(portal)) // closer than current best && (target == null || target.GetDistance2d(portal) > player.GetDistance2d(portal)) // closer than current best
&& !player.HasAura(MiscConst.PlayerDebuff[j]) // not exhausted && !player.HasAura(MiscConst.PlayerDebuff[j]) // not exhausted
&& !player.HasAura(MiscConst.PlayerBuff[(j + 1) % 3]) // not on another beam && !player.HasAura(MiscConst.PlayerBuff[(j + 1) % 3]) // not on another beam
&& !player.HasAura(MiscConst.PlayerBuff[(j + 2) % 3]) && !player.HasAura(MiscConst.PlayerBuff[(j + 2) % 3])
@@ -192,12 +192,12 @@ namespace Scripts.EasternKingdoms.Karazhan.Netherspite
target.AddAura(MiscConst.NetherBuff[j], target); target.AddAura(MiscConst.NetherBuff[j], target);
// cast visual beam on the chosen target if switched // cast visual beam on the chosen target if switched
// simple target switching isn't working . using BeamerGUID to cast (workaround) // simple target switching isn't working . using BeamerGUID to cast (workaround)
if (!current || target != current) if (current == null || target != current)
{ {
BeamTarget[j] = target.GetGUID(); BeamTarget[j] = target.GetGUID();
// remove currently beaming portal // remove currently beaming portal
Creature beamer = ObjectAccessor.GetCreature(portal, BeamerGUID[j]); Creature beamer = ObjectAccessor.GetCreature(portal, BeamerGUID[j]);
if (beamer) if (beamer != null)
{ {
beamer.CastSpell(target, MiscConst.PortalBeam[j], false); beamer.CastSpell(target, MiscConst.PortalBeam[j], false);
beamer.DisappearAndDie(); beamer.DisappearAndDie();
@@ -205,7 +205,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Netherspite
} }
// create new one and start beaming on the target // create new one and start beaming on the target
Creature beamer1 = portal.SummonCreature(MiscConst.PortalID[j], portal.GetPositionX(), portal.GetPositionY(), portal.GetPositionZ(), portal.GetOrientation(), TempSummonType.TimedDespawn, TimeSpan.FromMinutes(1)); Creature beamer1 = portal.SummonCreature(MiscConst.PortalID[j], portal.GetPositionX(), portal.GetPositionY(), portal.GetPositionZ(), portal.GetOrientation(), TempSummonType.TimedDespawn, TimeSpan.FromMinutes(1));
if (beamer1) if (beamer1 != null)
{ {
beamer1.CastSpell(target, MiscConst.PortalBeam[j], false); beamer1.CastSpell(target, MiscConst.PortalBeam[j], false);
BeamerGUID[j] = beamer1.GetGUID(); BeamerGUID[j] = beamer1.GetGUID();
@@ -248,7 +248,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Netherspite
void HandleDoors(bool open) // Massive Door switcher void HandleDoors(bool open) // Massive Door switcher
{ {
GameObject Door = ObjectAccessor.GetGameObject(me, instance.GetGuidData(DataTypes.GoMassiveDoor)); GameObject Door = ObjectAccessor.GetGameObject(me, instance.GetGuidData(DataTypes.GoMassiveDoor));
if (Door) if (Door != null)
Door.SetGoState(open ? GameObjectState.Active : GameObjectState.Ready); Door.SetGoState(open ? GameObjectState.Active : GameObjectState.Ready);
} }
@@ -321,7 +321,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Netherspite
if (NetherbreathTimer <= diff) if (NetherbreathTimer <= diff)
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 40, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 40, true);
if (target) if (target != null)
DoCast(target, SpellIds.Netherbreath); DoCast(target, SpellIds.Netherbreath);
NetherbreathTimer = RandomHelper.URand(5000, 7000); NetherbreathTimer = RandomHelper.URand(5000, 7000);
} }
@@ -89,7 +89,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Nightbane
me.SetDisableGravity(true); me.SetDisableGravity(true);
HandleTerraceDoors(true); HandleTerraceDoors(true);
GameObject urn = ObjectAccessor.GetGameObject(me, instance.GetGuidData(DataTypes.GoBlackenedUrn)); GameObject urn = ObjectAccessor.GetGameObject(me, instance.GetGuidData(DataTypes.GoBlackenedUrn));
if (urn) if (urn != null)
urn.RemoveFlag(GameObjectFlags.InUse); urn.RemoveFlag(GameObjectFlags.InUse);
} }
@@ -135,7 +135,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Nightbane
_scheduler.Schedule(TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(23), MiscConst.GroupGround, task => _scheduler.Schedule(TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(23), MiscConst.GroupGround, task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true);
if (target) if (target != null)
if (!me.HasInArc(MathF.PI, target)) if (!me.HasInArc(MathF.PI, target))
DoCast(target, SpellIds.TailSweep); DoCast(target, SpellIds.TailSweep);
task.Repeat(TimeSpan.FromSeconds(20), TimeSpan.FromSeconds(30)); task.Repeat(TimeSpan.FromSeconds(20), TimeSpan.FromSeconds(30));
@@ -147,7 +147,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Nightbane
_scheduler.Schedule(TimeSpan.FromSeconds(12), TimeSpan.FromSeconds(18), MiscConst.GroupGround, task => _scheduler.Schedule(TimeSpan.FromSeconds(12), TimeSpan.FromSeconds(18), MiscConst.GroupGround, task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true);
if (target) if (target != null)
DoCast(target, SpellIds.CharredEarth); DoCast(target, SpellIds.CharredEarth);
task.Repeat(TimeSpan.FromSeconds(18), TimeSpan.FromSeconds(21)); task.Repeat(TimeSpan.FromSeconds(18), TimeSpan.FromSeconds(21));
}); });
@@ -159,7 +159,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Nightbane
_scheduler.Schedule(TimeSpan.FromSeconds(82), MiscConst.GroupGround, task => _scheduler.Schedule(TimeSpan.FromSeconds(82), MiscConst.GroupGround, task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true);
if (target) if (target != null)
DoCast(target, SpellIds.DistractingAsh); DoCast(target, SpellIds.DistractingAsh);
}); });
} }
@@ -262,7 +262,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Nightbane
{ {
ResetThreatList(); ResetThreatList();
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true);
if (target) if (target != null)
{ {
me.SetFacingToObject(target); me.SetFacingToObject(target);
DoCast(target, SpellIds.RainOfBones); DoCast(target, SpellIds.RainOfBones);
@@ -272,14 +272,14 @@ namespace Scripts.EasternKingdoms.Karazhan.Nightbane
_scheduler.Schedule(TimeSpan.FromSeconds(21), MiscConst.GroupFly, task => _scheduler.Schedule(TimeSpan.FromSeconds(21), MiscConst.GroupFly, task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true);
if (target) if (target != null)
DoCast(target, SpellIds.SmokingBlastT); DoCast(target, SpellIds.SmokingBlastT);
task.Repeat(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(7)); task.Repeat(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(7));
}); });
_scheduler.Schedule(TimeSpan.FromSeconds(17), MiscConst.GroupFly, task => _scheduler.Schedule(TimeSpan.FromSeconds(17), MiscConst.GroupFly, task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true);
if (target) if (target != null)
DoCast(target, SpellIds.SmokingBlast); DoCast(target, SpellIds.SmokingBlast);
task.Repeat(TimeSpan.FromMilliseconds(1400)); task.Repeat(TimeSpan.FromMilliseconds(1400));
}); });
@@ -361,7 +361,7 @@ namespace Scripts.EasternKingdoms.Karazhan.Nightbane
return false; return false;
Creature nightbane = ObjectAccessor.GetCreature(me, instance.GetGuidData(DataTypes.Nightbane)); Creature nightbane = ObjectAccessor.GetCreature(me, instance.GetGuidData(DataTypes.Nightbane));
if (nightbane) if (nightbane != null)
{ {
me.SetFlag(GameObjectFlags.InUse); me.SetFlag(GameObjectFlags.InUse);
nightbane.GetAI().DoAction(MiscConst.ActionSummon); nightbane.GetAI().DoAction(MiscConst.ActionSummon);
@@ -137,9 +137,9 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
if (instance.GetData(DataTypes.OperaOzDeathcount) == 4) if (instance.GetData(DataTypes.OperaOzDeathcount) == 4)
{ {
Creature pCrone = creature.SummonCreature(CreatureIds.Crone, -10891.96f, -1755.95f, creature.GetPositionZ(), 4.64f, TempSummonType.TimedOrDeadDespawn, TimeSpan.FromHours(2)); Creature pCrone = creature.SummonCreature(CreatureIds.Crone, -10891.96f, -1755.95f, creature.GetPositionZ(), 4.64f, TempSummonType.TimedOrDeadDespawn, TimeSpan.FromHours(2));
if (pCrone) if (pCrone != null)
{ {
if (creature.GetVictim()) if (creature.GetVictim() != null)
pCrone.GetAI().AttackStart(creature.GetVictim()); pCrone.GetAI().AttackStart(creature.GetVictim());
} }
} }
@@ -162,7 +162,7 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
target.SetFullHealth(); target.SetFullHealth();
target.SetStandState(UnitStandStateType.Stand); target.SetStandState(UnitStandStateType.Stand);
target.CastSpell(target, SpellIds.ResVisual, true); target.CastSpell(target, SpellIds.ResVisual, true);
if (target.GetVictim()) if (target.GetVictim() != null)
{ {
target.GetMotionMaster().MoveChase(target.GetVictim()); target.GetMotionMaster().MoveChase(target.GetVictim());
target.GetAI().AttackStart(target.GetVictim()); target.GetAI().AttackStart(target.GetVictim());
@@ -291,7 +291,7 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
void SummonTito() void SummonTito()
{ {
Creature pTito = me.SummonCreature(CreatureIds.Tito, 0.0f, 0.0f, 0.0f, 0.0f, TempSummonType.TimedDespawnOutOfCombat, TimeSpan.FromSeconds(30)); Creature pTito = me.SummonCreature(CreatureIds.Tito, 0.0f, 0.0f, 0.0f, 0.0f, TempSummonType.TimedDespawnOutOfCombat, TimeSpan.FromSeconds(30));
if (pTito) if (pTito != null)
{ {
Talk(TextIds.SayDorotheeSummon); Talk(TextIds.SayDorotheeSummon);
pTito.GetAI<npc_tito>().DorotheeGUID = me.GetGUID(); pTito.GetAI<npc_tito>().DorotheeGUID = me.GetGUID();
@@ -331,7 +331,7 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
if (!DorotheeGUID.IsEmpty()) if (!DorotheeGUID.IsEmpty())
{ {
Creature Dorothee = ObjectAccessor.GetCreature(me, DorotheeGUID); Creature Dorothee = ObjectAccessor.GetCreature(me, DorotheeGUID);
if (Dorothee && Dorothee.IsAlive()) if (Dorothee != null && Dorothee.IsAlive())
{ {
Dorothee.GetAI<boss_dorothee>().TitoDied = true; Dorothee.GetAI<boss_dorothee>().TitoDied = true;
Talk(TextIds.SayDorotheeTitoDeath, Dorothee); Talk(TextIds.SayDorotheeTitoDeath, Dorothee);
@@ -451,7 +451,7 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
if (BrainWipeTimer <= diff) if (BrainWipeTimer <= diff)
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true);
if (target) if (target != null)
DoCast(target, SpellIds.BrainWipe); DoCast(target, SpellIds.BrainWipe);
BrainWipeTimer = 20000; BrainWipeTimer = 20000;
} }
@@ -737,7 +737,7 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
if (CycloneTimer <= diff) if (CycloneTimer <= diff)
{ {
Creature Cyclone = DoSpawnCreature(CreatureIds.Cyclone, RandomHelper.URand(0, 9), RandomHelper.URand(0, 9), 0, 0, TempSummonType.TimedDespawn, TimeSpan.FromSeconds(15)); Creature Cyclone = DoSpawnCreature(CreatureIds.Cyclone, RandomHelper.URand(0, 9), RandomHelper.URand(0, 9), 0, 0, TempSummonType.TimedDespawn, TimeSpan.FromSeconds(15));
if (Cyclone) if (Cyclone != null)
Cyclone.CastSpell(Cyclone, SpellIds.CycloneVisual, true); Cyclone.CastSpell(Cyclone, SpellIds.CycloneVisual, true);
CycloneTimer = 30000; CycloneTimer = 30000;
} }
@@ -808,7 +808,7 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
player.CloseGossipMenu(); player.CloseGossipMenu();
Creature pBigBadWolf = me.SummonCreature(CreatureIds.BigBadWolf, me.GetPositionX(), me.GetPositionY(), me.GetPositionZ(), me.GetOrientation(), TempSummonType.TimedOrDeadDespawn, TimeSpan.FromHours(2)); Creature pBigBadWolf = me.SummonCreature(CreatureIds.BigBadWolf, me.GetPositionX(), me.GetPositionY(), me.GetPositionZ(), me.GetOrientation(), TempSummonType.TimedOrDeadDespawn, TimeSpan.FromHours(2));
if (pBigBadWolf) if (pBigBadWolf != null)
pBigBadWolf.GetAI().AttackStart(player); pBigBadWolf.GetAI().AttackStart(player);
me.DespawnOrUnsummon(); me.DespawnOrUnsummon();
@@ -887,7 +887,7 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
if (!IsChasing) if (!IsChasing)
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true);
if (target) if (target != null)
{ {
Talk(TextIds.SayWolfHood); Talk(TextIds.SayWolfHood);
DoCast(target, SpellIds.LittleRedRidingHood, new CastSpellExtraArgs(true)); DoCast(target, SpellIds.LittleRedRidingHood, new CastSpellExtraArgs(true));
@@ -905,7 +905,7 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
IsChasing = false; IsChasing = false;
Unit target = Global.ObjAccessor.GetUnit(me, HoodGUID); Unit target = Global.ObjAccessor.GetUnit(me, HoodGUID);
if (target) if (target != null)
{ {
HoodGUID.Clear(); HoodGUID.Clear();
if (GetThreat(target) != 0f) if (GetThreat(target) != 0f)
@@ -1068,7 +1068,7 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
if (RomuloDead) if (RomuloDead)
{ {
Creature Romulo = ObjectAccessor.GetCreature(me, RomuloGUID); Creature Romulo = ObjectAccessor.GetCreature(me, RomuloGUID);
if (Romulo) if (Romulo != null)
{ {
Romulo.SetUninteractible(false); Romulo.SetUninteractible(false);
Romulo.GetMotionMaster().Clear(); Romulo.GetMotionMaster().Clear();
@@ -1082,7 +1082,7 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
//if not already returned, then romulo is alive and we can pretend die //if not already returned, then romulo is alive and we can pretend die
Creature Romulo1 = (ObjectAccessor.GetCreature((me), RomuloGUID)); Creature Romulo1 = (ObjectAccessor.GetCreature((me), RomuloGUID));
if (Romulo1) if (Romulo1 != null)
{ {
MiscConst.PretendToDie(me); MiscConst.PretendToDie(me);
IsFakingDeath = true; IsFakingDeath = true;
@@ -1148,7 +1148,7 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
if (SummonRomuloTimer <= diff) if (SummonRomuloTimer <= diff)
{ {
Creature pRomulo = me.SummonCreature(CreatureIds.Romulo, MiscConst.RomuloX, MiscConst.RomuloY, me.GetPositionZ(), 0, TempSummonType.TimedOrDeadDespawn, TimeSpan.FromHours(2)); Creature pRomulo = me.SummonCreature(CreatureIds.Romulo, MiscConst.RomuloX, MiscConst.RomuloY, me.GetPositionZ(), 0, TempSummonType.TimedOrDeadDespawn, TimeSpan.FromHours(2));
if (pRomulo) if (pRomulo != null)
{ {
RomuloGUID = pRomulo.GetGUID(); RomuloGUID = pRomulo.GetGUID();
pRomulo.GetAI<boss_romulo>().JulianneGUID = me.GetGUID(); pRomulo.GetAI<boss_romulo>().JulianneGUID = me.GetGUID();
@@ -1170,7 +1170,7 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
Phase = RAJPhase.Both; Phase = RAJPhase.Both;
IsFakingDeath = false; IsFakingDeath = false;
if (me.GetVictim()) if (me.GetVictim() != null)
AttackStart(me.GetVictim()); AttackStart(me.GetVictim());
ResurrectSelfTimer = 0; ResurrectSelfTimer = 0;
@@ -1187,7 +1187,7 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
if (ResurrectTimer <= diff) if (ResurrectTimer <= diff)
{ {
Creature Romulo = ObjectAccessor.GetCreature(me, RomuloGUID); Creature Romulo = ObjectAccessor.GetCreature(me, RomuloGUID);
if (Romulo && Romulo.GetAI<boss_romulo>().IsFakingDeath) if (Romulo != null && Romulo.GetAI<boss_romulo>().IsFakingDeath)
{ {
Talk(TextIds.SayJulianneResurrect); Talk(TextIds.SayJulianneResurrect);
MiscConst.Resurrect(Romulo); MiscConst.Resurrect(Romulo);
@@ -1202,7 +1202,7 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
if (BlindingPassionTimer <= diff) if (BlindingPassionTimer <= diff)
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true);
if (target) if (target != null)
DoCast(target, SpellIds.BlindingPassion); DoCast(target, SpellIds.BlindingPassion);
BlindingPassionTimer = RandomHelper.URand(30000, 45000); BlindingPassionTimer = RandomHelper.URand(30000, 45000);
} }
@@ -1227,7 +1227,7 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
if (RandomHelper.URand(0, 1) != 0 && SummonedRomulo) if (RandomHelper.URand(0, 1) != 0 && SummonedRomulo)
{ {
Creature Romulo = (ObjectAccessor.GetCreature((me), RomuloGUID)); Creature Romulo = (ObjectAccessor.GetCreature((me), RomuloGUID));
if (Romulo && Romulo.IsAlive() && !RomuloDead) if (Romulo != null && Romulo.IsAlive() && !RomuloDead)
DoCast(Romulo, SpellIds.EternalAffection); DoCast(Romulo, SpellIds.EternalAffection);
} }
else DoCast(me, SpellIds.EternalAffection); else DoCast(me, SpellIds.EternalAffection);
@@ -1303,7 +1303,7 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
Phase = RAJPhase.Both; Phase = RAJPhase.Both;
Creature Julianne = ObjectAccessor.GetCreature(me, JulianneGUID); Creature Julianne = ObjectAccessor.GetCreature(me, JulianneGUID);
if (Julianne) if (Julianne != null)
{ {
Julianne.GetAI<boss_julianne>().RomuloDead = true; Julianne.GetAI<boss_julianne>().RomuloDead = true;
Julianne.GetAI<boss_julianne>().ResurrectSelfTimer = 10000; Julianne.GetAI<boss_julianne>().ResurrectSelfTimer = 10000;
@@ -1318,7 +1318,7 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
if (JulianneDead) if (JulianneDead)
{ {
Creature Julianne = ObjectAccessor.GetCreature(me, JulianneGUID); Creature Julianne = ObjectAccessor.GetCreature(me, JulianneGUID);
if (Julianne) if (Julianne != null)
{ {
Julianne.SetUninteractible(false); Julianne.SetUninteractible(false);
Julianne.GetMotionMaster().Clear(); Julianne.GetMotionMaster().Clear();
@@ -1330,7 +1330,7 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
} }
Creature Julianne1 = ObjectAccessor.GetCreature(me, JulianneGUID); Creature Julianne1 = ObjectAccessor.GetCreature(me, JulianneGUID);
if (Julianne1) if (Julianne1 != null)
{ {
MiscConst.PretendToDie(me); MiscConst.PretendToDie(me);
IsFakingDeath = true; IsFakingDeath = true;
@@ -1350,7 +1350,7 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
if (!JulianneGUID.IsEmpty()) if (!JulianneGUID.IsEmpty())
{ {
Creature Julianne = ObjectAccessor.GetCreature(me, JulianneGUID); Creature Julianne = ObjectAccessor.GetCreature(me, JulianneGUID);
if (Julianne && Julianne.GetVictim()) if (Julianne != null && Julianne.GetVictim() != null)
{ {
AddThreat(Julianne.GetVictim(), 1.0f); AddThreat(Julianne.GetVictim(), 1.0f);
AttackStart(Julianne.GetVictim()); AttackStart(Julianne.GetVictim());
@@ -1387,7 +1387,7 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
if (ResurrectTimer <= diff) if (ResurrectTimer <= diff)
{ {
Creature Julianne = (ObjectAccessor.GetCreature((me), JulianneGUID)); Creature Julianne = (ObjectAccessor.GetCreature((me), JulianneGUID));
if (Julianne && Julianne.GetAI<boss_julianne>().IsFakingDeath) if (Julianne != null && Julianne.GetAI<boss_julianne>().IsFakingDeath)
{ {
Talk(TextIds.SayRomuloResurrect); Talk(TextIds.SayRomuloResurrect);
MiscConst.Resurrect(Julianne); MiscConst.Resurrect(Julianne);
@@ -1402,7 +1402,7 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
if (BackwardLungeTimer <= diff) if (BackwardLungeTimer <= diff)
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 1, 100, true); Unit target = SelectTarget(SelectTargetMethod.Random, 1, 100, true);
if (target && !me.HasInArc(MathF.PI, target)) if (target != null && !me.HasInArc(MathF.PI, target))
{ {
DoCast(target, SpellIds.BackwardLunge); DoCast(target, SpellIds.BackwardLunge);
BackwardLungeTimer = RandomHelper.URand(15000, 30000); BackwardLungeTimer = RandomHelper.URand(15000, 30000);
@@ -1420,7 +1420,7 @@ namespace Scripts.EasternKingdoms.Karazhan.EsOpera
if (DeadlySwatheTimer <= diff) if (DeadlySwatheTimer <= diff)
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true);
if (target) if (target != null)
DoCast(target, SpellIds.DeadlySwathe); DoCast(target, SpellIds.DeadlySwathe);
DeadlySwatheTimer = RandomHelper.URand(15000, 25000); DeadlySwatheTimer = RandomHelper.URand(15000, 25000);
} }
@@ -76,10 +76,10 @@ namespace Scripts.EasternKingdoms.Karazhan.PrinceMalchezaar
public override void KilledUnit(Unit who) public override void KilledUnit(Unit who)
{ {
Unit unit = Global.ObjAccessor.GetUnit(me, Malchezaar); Unit unit = Global.ObjAccessor.GetUnit(me, Malchezaar);
if (unit) if (unit != null)
{ {
Creature creature = unit.ToCreature(); Creature creature = unit.ToCreature();
if (creature) if (creature != null)
creature.GetAI().KilledUnit(who); creature.GetAI().KilledUnit(who);
} }
} }
@@ -96,7 +96,7 @@ namespace Scripts.EasternKingdoms.Karazhan.PrinceMalchezaar
{ {
Creature pMalchezaar = ObjectAccessor.GetCreature(me, Malchezaar); Creature pMalchezaar = ObjectAccessor.GetCreature(me, Malchezaar);
if (pMalchezaar && pMalchezaar.IsAlive()) if (pMalchezaar != null && pMalchezaar.IsAlive())
pMalchezaar.GetAI<boss_malchezaar>().Cleanup(me, Point); pMalchezaar.GetAI<boss_malchezaar>().Cleanup(me, Point);
}); });
} }
@@ -104,7 +104,7 @@ namespace Scripts.EasternKingdoms.Karazhan.PrinceMalchezaar
public override void DamageTaken(Unit done_by, ref uint damage, DamageEffectType damageType, SpellInfo spellInfo = null) public override void DamageTaken(Unit done_by, ref uint damage, DamageEffectType damageType, SpellInfo spellInfo = null)
{ {
if (!done_by || done_by.GetGUID() != Malchezaar) if (done_by == null || done_by.GetGUID() != Malchezaar)
damage = 0; damage = 0;
} }
} }
@@ -231,7 +231,7 @@ namespace Scripts.EasternKingdoms.Karazhan.PrinceMalchezaar
foreach (var guid in infernals) foreach (var guid in infernals)
{ {
Unit pInfernal = Global.ObjAccessor.GetUnit(me, guid); Unit pInfernal = Global.ObjAccessor.GetUnit(me, guid);
if (pInfernal && pInfernal.IsAlive()) if (pInfernal != null && pInfernal.IsAlive())
{ {
pInfernal.SetVisible(false); pInfernal.SetVisible(false);
pInfernal.SetDeathState(DeathState.JustDied); pInfernal.SetDeathState(DeathState.JustDied);
@@ -246,7 +246,7 @@ namespace Scripts.EasternKingdoms.Karazhan.PrinceMalchezaar
for (byte i = 0; i < 2; ++i) for (byte i = 0; i < 2; ++i)
{ {
Unit axe = Global.ObjAccessor.GetUnit(me, axes[i]); Unit axe = Global.ObjAccessor.GetUnit(me, axes[i]);
if (axe && axe.IsAlive()) if (axe != null && axe.IsAlive())
axe.KillSelf(); axe.KillSelf();
axes[i].Clear(); axes[i].Clear();
} }
@@ -283,7 +283,7 @@ namespace Scripts.EasternKingdoms.Karazhan.PrinceMalchezaar
uint i = 0; uint i = 0;
foreach (var target in targets) foreach (var target in targets)
{ {
if (target) if (target != null)
{ {
enfeeble_targets[i] = target.GetGUID(); enfeeble_targets[i] = target.GetGUID();
enfeeble_health[i] = target.GetHealth(); enfeeble_health[i] = target.GetHealth();
@@ -303,7 +303,7 @@ namespace Scripts.EasternKingdoms.Karazhan.PrinceMalchezaar
for (byte i = 0; i < 5; ++i) for (byte i = 0; i < 5; ++i)
{ {
Unit target = Global.ObjAccessor.GetUnit(me, enfeeble_targets[i]); Unit target = Global.ObjAccessor.GetUnit(me, enfeeble_targets[i]);
if (target && target.IsAlive()) if (target != null && target.IsAlive())
target.SetHealth(enfeeble_health[i]); target.SetHealth(enfeeble_health[i]);
enfeeble_targets[i].Clear(); enfeeble_targets[i].Clear();
enfeeble_health[i] = 0; enfeeble_health[i] = 0;
@@ -324,7 +324,7 @@ namespace Scripts.EasternKingdoms.Karazhan.PrinceMalchezaar
Creature infernal = me.SummonCreature(MiscConst.NetherspiteInfernal, pos, TempSummonType.TimedDespawn, TimeSpan.FromMinutes(3)); Creature infernal = me.SummonCreature(MiscConst.NetherspiteInfernal, pos, TempSummonType.TimedDespawn, TimeSpan.FromMinutes(3));
if (infernal) if (infernal != null)
{ {
infernal.SetDisplayId(MiscConst.InfernalModelInvisible); infernal.SetDisplayId(MiscConst.InfernalModelInvisible);
infernal.SetFaction(me.GetFaction()); infernal.SetFaction(me.GetFaction());
@@ -354,7 +354,7 @@ namespace Scripts.EasternKingdoms.Karazhan.PrinceMalchezaar
if (me.HasUnitState(UnitState.Stunned)) // While shifting to phase 2 malchezaar stuns himself if (me.HasUnitState(UnitState.Stunned)) // While shifting to phase 2 malchezaar stuns himself
return; return;
if (me.GetVictim() && me.GetTarget() != me.GetVictim().GetGUID()) if (me.GetVictim() != null && me.GetTarget() != me.GetVictim().GetGUID())
me.SetTarget(me.GetVictim().GetGUID()); me.SetTarget(me.GetVictim().GetGUID());
if (phase == 1) if (phase == 1)
@@ -400,12 +400,12 @@ namespace Scripts.EasternKingdoms.Karazhan.PrinceMalchezaar
for (byte i = 0; i < 2; ++i) for (byte i = 0; i < 2; ++i)
{ {
Creature axe = me.SummonCreature(MiscConst.MalchezarsAxe, me.GetPositionX(), me.GetPositionY(), me.GetPositionZ(), 0, TempSummonType.TimedDespawnOutOfCombat, TimeSpan.FromSeconds(1)); Creature axe = me.SummonCreature(MiscConst.MalchezarsAxe, me.GetPositionX(), me.GetPositionY(), me.GetPositionZ(), 0, TempSummonType.TimedDespawnOutOfCombat, TimeSpan.FromSeconds(1));
if (axe) if (axe != null)
{ {
axe.SetUninteractible(true); axe.SetUninteractible(true);
axe.SetFaction(me.GetFaction()); axe.SetFaction(me.GetFaction());
axes[i] = axe.GetGUID(); axes[i] = axe.GetGUID();
if (target) if (target != null)
{ {
axe.GetAI().AttackStart(target); axe.GetAI().AttackStart(target);
AddThreat(target, 10000000.0f, axe); AddThreat(target, 10000000.0f, axe);
@@ -440,14 +440,14 @@ namespace Scripts.EasternKingdoms.Karazhan.PrinceMalchezaar
AxesTargetSwitchTimer = RandomHelper.URand(7500, 20000); AxesTargetSwitchTimer = RandomHelper.URand(7500, 20000);
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true);
if (target) if (target != null)
{ {
for (byte i = 0; i < 2; ++i) for (byte i = 0; i < 2; ++i)
{ {
Unit axe = Global.ObjAccessor.GetUnit(me, axes[i]); Unit axe = Global.ObjAccessor.GetUnit(me, axes[i]);
if (axe) if (axe != null)
{ {
if (axe.GetVictim()) if (axe.GetVictim() != null)
ResetThreat(axe.GetVictim(), axe); ResetThreat(axe.GetVictim(), axe);
AddThreat(target, 1000000.0f, axe); AddThreat(target, 1000000.0f, axe);
} }
@@ -459,7 +459,7 @@ namespace Scripts.EasternKingdoms.Karazhan.PrinceMalchezaar
if (AmplifyDamageTimer <= diff) if (AmplifyDamageTimer <= diff)
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true);
if (target) if (target != null)
DoCast(target, SpellIds.AmplifyDamage); DoCast(target, SpellIds.AmplifyDamage);
AmplifyDamageTimer = RandomHelper.URand(20000, 30000); AmplifyDamageTimer = RandomHelper.URand(20000, 30000);
} }
@@ -491,7 +491,7 @@ namespace Scripts.EasternKingdoms.Karazhan.PrinceMalchezaar
else // anyone but the tank else // anyone but the tank
target = SelectTarget(SelectTargetMethod.Random, 1, 100, true); target = SelectTarget(SelectTargetMethod.Random, 1, 100, true);
if (target) if (target != null)
DoCast(target, SpellIds.SwPain); DoCast(target, SpellIds.SwPain);
SWPainTimer = 20000; SWPainTimer = 20000;
@@ -522,13 +522,13 @@ namespace Scripts.EasternKingdoms.Karazhan.PrinceMalchezaar
if (me.IsWithinMeleeRange(me.GetVictim()) && !me.IsNonMeleeSpellCast(false)) if (me.IsWithinMeleeRange(me.GetVictim()) && !me.IsNonMeleeSpellCast(false))
{ {
//Check for base attack //Check for base attack
if (me.IsAttackReady() && me.GetVictim()) if (me.IsAttackReady() && me.GetVictim() != null)
{ {
me.AttackerStateUpdate(me.GetVictim()); me.AttackerStateUpdate(me.GetVictim());
me.ResetAttackTimer(); me.ResetAttackTimer();
} }
//Check for offhand attack //Check for offhand attack
if (me.IsAttackReady(WeaponAttackType.OffAttack) && me.GetVictim()) if (me.IsAttackReady(WeaponAttackType.OffAttack) && me.GetVictim() != null)
{ {
me.AttackerStateUpdate(me.GetVictim(), WeaponAttackType.OffAttack); me.AttackerStateUpdate(me.GetVictim(), WeaponAttackType.OffAttack);
me.ResetAttackTimer(WeaponAttackType.OffAttack); me.ResetAttackTimer(WeaponAttackType.OffAttack);
@@ -182,7 +182,7 @@ namespace Scripts.EasternKingdoms.Karazhan.ShadeOfAran
uint i = 0; uint i = 0;
foreach (var unit in targets) foreach (var unit in targets)
{ {
if (unit) if (unit != null)
{ {
FlameWreathTarget[i] = unit.GetGUID(); FlameWreathTarget[i] = unit.GetGUID();
FWTargPosX[i] = unit.GetPositionX(); FWTargPosX[i] = unit.GetPositionX();
@@ -282,7 +282,7 @@ namespace Scripts.EasternKingdoms.Karazhan.ShadeOfAran
if (!me.IsNonMeleeSpellCast(false)) if (!me.IsNonMeleeSpellCast(false))
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true);
if (!target) if (target == null)
return; return;
uint[] Spells = new uint[3]; uint[] Spells = new uint[3];
@@ -325,7 +325,7 @@ namespace Scripts.EasternKingdoms.Karazhan.ShadeOfAran
break; break;
case 1: case 1:
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100, true);
if (target) if (target != null)
DoCast(target, SpellIds.Chainsofice); DoCast(target, SpellIds.Chainsofice);
break; break;
} }
@@ -387,7 +387,7 @@ namespace Scripts.EasternKingdoms.Karazhan.ShadeOfAran
Talk(TextIds.SayBlizzard); Talk(TextIds.SayBlizzard);
Creature pSpawn = me.SummonCreature(CreatureIds.AranBlizzard, 0.0f, 0.0f, 0.0f, 0.0f, TempSummonType.TimedDespawn, TimeSpan.FromSeconds(25)); Creature pSpawn = me.SummonCreature(CreatureIds.AranBlizzard, 0.0f, 0.0f, 0.0f, 0.0f, TempSummonType.TimedDespawn, TimeSpan.FromSeconds(25));
if (pSpawn) if (pSpawn != null)
{ {
pSpawn.SetFaction(me.GetFaction()); pSpawn.SetFaction(me.GetFaction());
pSpawn.CastSpell(pSpawn, SpellIds.CircularBlizzard, false); pSpawn.CastSpell(pSpawn, SpellIds.CircularBlizzard, false);
@@ -406,7 +406,7 @@ namespace Scripts.EasternKingdoms.Karazhan.ShadeOfAran
for (uint i = 0; i < 4; ++i) for (uint i = 0; i < 4; ++i)
{ {
Creature unit = me.SummonCreature(CreatureIds.WaterElemental, 0.0f, 0.0f, 0.0f, 0.0f, TempSummonType.TimedDespawn, TimeSpan.FromSeconds(90)); Creature unit = me.SummonCreature(CreatureIds.WaterElemental, 0.0f, 0.0f, 0.0f, 0.0f, TempSummonType.TimedDespawn, TimeSpan.FromSeconds(90));
if (unit) if (unit != null)
{ {
unit.Attack(me.GetVictim(), true); unit.Attack(me.GetVictim(), true);
unit.SetFaction(me.GetFaction()); unit.SetFaction(me.GetFaction());
@@ -421,7 +421,7 @@ namespace Scripts.EasternKingdoms.Karazhan.ShadeOfAran
for (uint i = 0; i < 5; ++i) for (uint i = 0; i < 5; ++i)
{ {
Creature unit = me.SummonCreature(CreatureIds.ShadowOfAran, 0.0f, 0.0f, 0.0f, 0.0f, TempSummonType.TimedDespawnOutOfCombat, TimeSpan.FromSeconds(5)); Creature unit = me.SummonCreature(CreatureIds.ShadowOfAran, 0.0f, 0.0f, 0.0f, 0.0f, TempSummonType.TimedDespawnOutOfCombat, TimeSpan.FromSeconds(5));
if (unit) if (unit != null)
{ {
unit.Attack(me.GetVictim(), true); unit.Attack(me.GetVictim(), true);
unit.SetFaction(me.GetFaction()); unit.SetFaction(me.GetFaction());
@@ -449,7 +449,7 @@ namespace Scripts.EasternKingdoms.Karazhan.ShadeOfAran
continue; continue;
Unit unit = Global.ObjAccessor.GetUnit(me, FlameWreathTarget[i]); Unit unit = Global.ObjAccessor.GetUnit(me, FlameWreathTarget[i]);
if (unit && !unit.IsWithinDist2d(FWTargPosX[i], FWTargPosY[i], 3)) if (unit != null && !unit.IsWithinDist2d(FWTargPosX[i], FWTargPosY[i], 3))
{ {
unit.CastSpell(unit, 20476, new CastSpellExtraArgs(TriggerCastFlags.FullMask) unit.CastSpell(unit, 20476, new CastSpellExtraArgs(TriggerCastFlags.FullMask)
.SetOriginalCaster(me.GetGUID())); .SetOriginalCaster(me.GetGUID()));
@@ -500,7 +500,7 @@ namespace Scripts.EasternKingdoms.Karazhan.ShadeOfAran
return; return;
Player player = who.ToPlayer(); Player player = who.ToPlayer();
if (!player) if (player == null)
return; return;
foreach (uint id in AtieshStaves) foreach (uint id in AtieshStaves)
@@ -520,7 +520,7 @@ namespace Scripts.EasternKingdoms.Karazhan.ShadeOfAran
bool PlayerHasWeaponEquipped(Player player, uint itemEntry) bool PlayerHasWeaponEquipped(Player player, uint itemEntry)
{ {
Item item = player.GetItemByPos(InventorySlots.Bag0, EquipmentSlot.MainHand); Item item = player.GetItemByPos(InventorySlots.Bag0, EquipmentSlot.MainHand);
if (item && item.GetEntry() == itemEntry) if (item != null && item.GetEntry() == itemEntry)
return true; return true;
return false; return false;
@@ -55,7 +55,7 @@ namespace Scripts.EasternKingdoms.Karazhan.TerestianIllhoof
_scheduler.Schedule(TimeSpan.FromSeconds(1), task => _scheduler.Schedule(TimeSpan.FromSeconds(1), task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.MaxThreat, 0); Unit target = SelectTarget(SelectTargetMethod.MaxThreat, 0);
if (target) if (target != null)
DoCast(target, SpellIds.ShadowBolt); DoCast(target, SpellIds.ShadowBolt);
task.Repeat(TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(10)); task.Repeat(TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(10));
}); });
@@ -67,7 +67,7 @@ namespace Scripts.EasternKingdoms.Karazhan.TerestianIllhoof
_scheduler.Schedule(TimeSpan.FromSeconds(30), task => _scheduler.Schedule(TimeSpan.FromSeconds(30), task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100.0f, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 100.0f, true);
if (target) if (target != null)
{ {
DoCast(target, SpellIds.Sacrifice, new CastSpellExtraArgs(true)); DoCast(target, SpellIds.Sacrifice, new CastSpellExtraArgs(true));
target.CastSpell(target, SpellIds.SummonDemonchains, true); target.CastSpell(target, SpellIds.SummonDemonchains, true);
@@ -176,7 +176,7 @@ namespace Scripts.EasternKingdoms.Karazhan.TerestianIllhoof
public override void JustDied(Unit killer) public override void JustDied(Unit killer)
{ {
Unit sacrifice = Global.ObjAccessor.GetUnit(me, _sacrificeGUID); Unit sacrifice = Global.ObjAccessor.GetUnit(me, _sacrificeGUID);
if (sacrifice) if (sacrifice != null)
sacrifice.RemoveAurasDueToSpell(SpellIds.Sacrifice); sacrifice.RemoveAurasDueToSpell(SpellIds.Sacrifice);
} }
} }
@@ -120,7 +120,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.FelbloodKaelthas
{ {
Talk(TextIds.SayFlameStrike); Talk(TextIds.SayFlameStrike);
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 40.0f, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 40.0f, true);
if (target) if (target != null)
DoCast(target, SpellIds.FlameStrike); DoCast(target, SpellIds.FlameStrike);
task.Repeat(); task.Repeat();
}); });
@@ -284,7 +284,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.FelbloodKaelthas
public override void SpellHitTarget(WorldObject target, SpellInfo spellInfo) public override void SpellHitTarget(WorldObject target, SpellInfo spellInfo)
{ {
Unit unitTarget = target.ToUnit(); Unit unitTarget = target.ToUnit();
if (!unitTarget) if (unitTarget == null)
return; return;
switch (spellInfo.Id) switch (spellInfo.Id)
@@ -318,7 +318,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.FelbloodKaelthas
{ {
case CreatureIds.ArcaneSphere: case CreatureIds.ArcaneSphere:
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 70.0f, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 70.0f, true);
if (target) if (target != null)
summon.GetMotionMaster().MoveFollow(target, 0.0f, 0.0f); summon.GetMotionMaster().MoveFollow(target, 0.0f, 0.0f);
break; break;
case CreatureIds.FlameStrike: case CreatureIds.FlameStrike:
@@ -382,10 +382,10 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.FelbloodKaelthas
DoCastSelf(SpellIds.EmberBlast); DoCastSelf(SpellIds.EmberBlast);
// DoCastSelf(SpellSummonPhoenixEgg); -- We do a manual summon for now. Feel free to move it to spelleffect_dbc // DoCastSelf(SpellSummonPhoenixEgg); -- We do a manual summon for now. Feel free to move it to spelleffect_dbc
Creature egg = DoSummon(CreatureIds.PhoenixEgg, me.GetPosition(), TimeSpan.FromSeconds(0)); Creature egg = DoSummon(CreatureIds.PhoenixEgg, me.GetPosition(), TimeSpan.FromSeconds(0));
if (egg) if (egg != null)
{ {
Creature kaelthas = _instance.GetCreature(DataTypes.KaelthasSunstrider); Creature kaelthas = _instance.GetCreature(DataTypes.KaelthasSunstrider);
if (kaelthas) if (kaelthas != null)
{ {
kaelthas.GetAI().JustSummoned(egg); kaelthas.GetAI().JustSummoned(egg);
_eggGUID = egg.GetGUID(); _eggGUID = egg.GetGUID();
@@ -395,7 +395,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.FelbloodKaelthas
_scheduler.Schedule(TimeSpan.FromSeconds(15), task => _scheduler.Schedule(TimeSpan.FromSeconds(15), task =>
{ {
Creature egg = ObjectAccessor.GetCreature(me, _eggGUID); Creature egg = ObjectAccessor.GetCreature(me, _eggGUID);
if (egg) if (egg != null)
egg.DespawnOrUnsummon(); egg.DespawnOrUnsummon();
me.RemoveAllAuras(); me.RemoveAllAuras();
@@ -445,7 +445,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.FelbloodKaelthas
void AfterRemove(AuraEffect aurEff, AuraEffectHandleModes mode) void AfterRemove(AuraEffect aurEff, AuraEffectHandleModes mode)
{ {
Unit target = GetTarget(); Unit target = GetTarget();
if (target) if (target != null)
target.CastSpell(target, SpellIds.FlameStrikeDamage); target.CastSpell(target, SpellIds.FlameStrikeDamage);
} }
@@ -195,7 +195,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace
if (_kaelthasPreTrashGUIDs.Count == 0) if (_kaelthasPreTrashGUIDs.Count == 0)
{ {
Creature kaelthas = GetCreature(DataTypes.KaelthasSunstrider); Creature kaelthas = GetCreature(DataTypes.KaelthasSunstrider);
if (kaelthas) if (kaelthas != null)
kaelthas.GetAI().SetData(DataTypes.KaelthasIntro, (uint)EncounterState.InProgress); kaelthas.GetAI().SetData(DataTypes.KaelthasIntro, (uint)EncounterState.InProgress);
} }
} }
@@ -223,7 +223,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace
public override void ProcessEvent(WorldObject obj, uint eventId, WorldObject invoker) public override void ProcessEvent(WorldObject obj, uint eventId, WorldObject invoker)
{ {
if (eventId == MiscConst.EventSpawnKalecgos) if (eventId == MiscConst.EventSpawnKalecgos)
if (!GetCreature(DataTypes.Kalecgos) && _events.Empty()) if (GetCreature(DataTypes.Kalecgos) == null && _events.Empty())
_events.ScheduleEvent(MiscConst.EventSpawnKalecgos, TimeSpan.FromMinutes(1)); _events.ScheduleEvent(MiscConst.EventSpawnKalecgos, TimeSpan.FromMinutes(1));
} }
@@ -234,7 +234,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace
if (_events.ExecuteEvent() == MiscConst.EventSpawnKalecgos) if (_events.ExecuteEvent() == MiscConst.EventSpawnKalecgos)
{ {
Creature kalecgos = instance.SummonCreature(CreatureIds.Kalecgos, MiscConst.KalecgosSpawnPos); Creature kalecgos = instance.SummonCreature(CreatureIds.Kalecgos, MiscConst.KalecgosSpawnPos);
if (kalecgos) if (kalecgos != null)
{ {
kalecgos.GetMotionMaster().MovePath(MiscConst.PathKalecgosFlight, false); kalecgos.GetMotionMaster().MovePath(MiscConst.PathKalecgosFlight, false);
kalecgos.GetAI().Talk(MiscConst.SayKalecgosSpawn); kalecgos.GetAI().Talk(MiscConst.SayKalecgosSpawn);
@@ -223,7 +223,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
} }
} }
if (target) if (target != null)
DoCast(target, SpellIds.DispelMagic); DoCast(target, SpellIds.DispelMagic);
task.Repeat(TimeSpan.FromSeconds(12)); task.Repeat(TimeSpan.FromSeconds(12));
@@ -261,7 +261,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
foreach (var lackeyGuid in m_auiLackeyGUID) foreach (var lackeyGuid in m_auiLackeyGUID)
{ {
Unit pAdd = Global.ObjAccessor.GetUnit(me, lackeyGuid); Unit pAdd = Global.ObjAccessor.GetUnit(me, lackeyGuid);
if (pAdd && !pAdd.IsEngaged()) if (pAdd != null && !pAdd.IsEngaged())
AddThreat(who, 0.0f, pAdd); AddThreat(who, 0.0f, pAdd);
} }
@@ -303,7 +303,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
Unit pAdd = Global.ObjAccessor.GetUnit(me, m_auiLackeyGUID[j]); Unit pAdd = Global.ObjAccessor.GetUnit(me, m_auiLackeyGUID[j]);
//object already removed, not exist //object already removed, not exist
if (!pAdd) if (pAdd == null)
{ {
pAdd = me.SummonCreature(guid, MiscConst.LackeyLocations[j][0], MiscConst.LackeyLocations[j][1], MiscConst.fZLocation, MiscConst.fOrientation, TempSummonType.CorpseDespawn); pAdd = me.SummonCreature(guid, MiscConst.LackeyLocations[j][0], MiscConst.LackeyLocations[j][1], MiscConst.fZLocation, MiscConst.fOrientation, TempSummonType.CorpseDespawn);
if (pAdd != null) if (pAdd != null)
@@ -380,7 +380,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
// in case she is not alive and Reset was for some reason called, respawn her (most likely party wipe after killing her) // in case she is not alive and Reset was for some reason called, respawn her (most likely party wipe after killing her)
Creature delrissa = instance.GetCreature(DataTypes.PriestessDelrissa); Creature delrissa = instance.GetCreature(DataTypes.PriestessDelrissa);
if (delrissa) if (delrissa != null)
{ {
if (!delrissa.IsAlive()) if (!delrissa.IsAlive())
delrissa.Respawn(); delrissa.Respawn();
@@ -389,7 +389,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
public override void JustEngagedWith(Unit who) public override void JustEngagedWith(Unit who)
{ {
if (!who) if (who == null)
return; return;
foreach (var guid in m_auiLackeyGUIDs) foreach (var guid in m_auiLackeyGUIDs)
@@ -400,7 +400,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
} }
Creature delrissa = instance.GetCreature(DataTypes.PriestessDelrissa); Creature delrissa = instance.GetCreature(DataTypes.PriestessDelrissa);
if (delrissa) if (delrissa != null)
if (delrissa.IsAlive() && !delrissa.IsEngaged()) if (delrissa.IsAlive() && !delrissa.IsEngaged())
AddThreat(who, 0.0f, delrissa); AddThreat(who, 0.0f, delrissa);
} }
@@ -410,7 +410,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
Creature delrissa = instance.GetCreature(DataTypes.PriestessDelrissa); Creature delrissa = instance.GetCreature(DataTypes.PriestessDelrissa);
uint uiLackeyDeathCount = instance.GetData(DataTypes.DelrissaDeathCount); uint uiLackeyDeathCount = instance.GetData(DataTypes.DelrissaDeathCount);
if (!delrissa) if (delrissa == null)
return; return;
//should delrissa really yell if dead? //should delrissa really yell if dead?
@@ -436,14 +436,14 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
public override void KilledUnit(Unit victim) public override void KilledUnit(Unit victim)
{ {
Creature delrissa = instance.GetCreature(DataTypes.PriestessDelrissa); Creature delrissa = instance.GetCreature(DataTypes.PriestessDelrissa);
if (delrissa) if (delrissa != null)
delrissa.GetAI().KilledUnit(victim); delrissa.GetAI().KilledUnit(victim);
} }
void AcquireGUIDs() void AcquireGUIDs()
{ {
Creature delrissa = instance.GetCreature(DataTypes.PriestessDelrissa); Creature delrissa = instance.GetCreature(DataTypes.PriestessDelrissa);
if (delrissa) if (delrissa != null)
{ {
for (byte i = 0; i < MiscConst.MaxActiveLackey; ++i) for (byte i = 0; i < MiscConst.MaxActiveLackey; ++i)
m_auiLackeyGUIDs[i] = (delrissa.GetAI() as boss_priestess_delrissa).m_auiLackeyGUID[i]; m_auiLackeyGUIDs[i] = (delrissa.GetAI() as boss_priestess_delrissa).m_auiLackeyGUID[i];
@@ -493,7 +493,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
ResetThreatList(); ResetThreatList();
if (unit) if (unit != null)
AddThreat(unit, 1000.0f); AddThreat(unit, 1000.0f);
InVanish = true; InVanish = true;
@@ -565,7 +565,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
_scheduler.Schedule(TimeSpan.FromSeconds(2), task => _scheduler.Schedule(TimeSpan.FromSeconds(2), task =>
{ {
Unit unit = SelectTarget(SelectTargetMethod.Random, 0); Unit unit = SelectTarget(SelectTargetMethod.Random, 0);
if (unit) if (unit != null)
DoCast(unit, SpellIds.SeedOfCorruption); DoCast(unit, SpellIds.SeedOfCorruption);
task.Repeat(TimeSpan.FromSeconds(10)); task.Repeat(TimeSpan.FromSeconds(10));
@@ -573,7 +573,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
_scheduler.Schedule(TimeSpan.FromSeconds(1), task => _scheduler.Schedule(TimeSpan.FromSeconds(1), task =>
{ {
Unit unit = SelectTarget(SelectTargetMethod.Random, 0); Unit unit = SelectTarget(SelectTargetMethod.Random, 0);
if (unit) if (unit != null)
DoCast(unit, SpellIds.CurseOfAgony); DoCast(unit, SpellIds.CurseOfAgony);
task.Repeat(TimeSpan.FromSeconds(13)); task.Repeat(TimeSpan.FromSeconds(13));
@@ -582,7 +582,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
_scheduler.Schedule(TimeSpan.FromSeconds(10), task => _scheduler.Schedule(TimeSpan.FromSeconds(10), task =>
{ {
Unit unit = SelectTarget(SelectTargetMethod.Random, 0); Unit unit = SelectTarget(SelectTargetMethod.Random, 0);
if (unit) if (unit != null)
DoCast(unit, SpellIds.Fear); DoCast(unit, SpellIds.Fear);
task.Repeat(); task.Repeat();
@@ -671,7 +671,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
_scheduler.Schedule(TimeSpan.FromSeconds(1), task => _scheduler.Schedule(TimeSpan.FromSeconds(1), task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0); Unit target = SelectTarget(SelectTargetMethod.Random, 0);
if (target) if (target != null)
{ {
DoCast(target, SpellIds.Polymorph); DoCast(target, SpellIds.Polymorph);
task.Repeat(TimeSpan.FromSeconds(20)); task.Repeat(TimeSpan.FromSeconds(20));
@@ -680,7 +680,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
_scheduler.Schedule(TimeSpan.FromSeconds(8), task => _scheduler.Schedule(TimeSpan.FromSeconds(8), task =>
{ {
Unit unit = SelectTarget(SelectTargetMethod.Random, 0); Unit unit = SelectTarget(SelectTargetMethod.Random, 0);
if (unit) if (unit != null)
DoCast(unit, SpellIds.Blizzard); DoCast(unit, SpellIds.Blizzard);
task.Repeat(); task.Repeat();
@@ -771,7 +771,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
if (!InMeleeRange) if (!InMeleeRange)
{ {
Unit unit = SelectTarget(SelectTargetMethod.Random, 0); Unit unit = SelectTarget(SelectTargetMethod.Random, 0);
if (unit) if (unit != null)
DoCast(unit, SpellIds.InterceptStun); DoCast(unit, SpellIds.InterceptStun);
} }
@@ -873,7 +873,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
GameObject go = me.GetGameObject(SpellIds.FreezingTrap); GameObject go = me.GetGameObject(SpellIds.FreezingTrap);
//if we have a go, we need to wait (only one trap at a time) //if we have a go, we need to wait (only one trap at a time)
if (go) if (go != null)
task.Repeat(TimeSpan.FromSeconds(2.5)); task.Repeat(TimeSpan.FromSeconds(2.5));
else else
{ {
@@ -889,7 +889,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
Initialize(); Initialize();
Unit pPet = Global.ObjAccessor.GetUnit(me, m_uiPetGUID); Unit pPet = Global.ObjAccessor.GetUnit(me, m_uiPetGUID);
if (!pPet) if (pPet == null)
me.SummonCreature(CreatureIds.Sliver, 0.0f, 0.0f, 0.0f, 0.0f, TempSummonType.CorpseDespawn); me.SummonCreature(CreatureIds.Sliver, 0.0f, 0.0f, 0.0f, 0.0f, TempSummonType.CorpseDespawn);
base.Reset(); base.Reset();
@@ -942,7 +942,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.PriestessDelrissa
_scheduler.Schedule(TimeSpan.FromSeconds(8), task => _scheduler.Schedule(TimeSpan.FromSeconds(8), task =>
{ {
Unit unit = SelectTarget(SelectTargetMethod.Random, 0); Unit unit = SelectTarget(SelectTargetMethod.Random, 0);
if (unit) if (unit != null)
DoCast(unit, SpellIds.Purge); DoCast(unit, SpellIds.Purge);
task.Repeat(TimeSpan.FromSeconds(15)); task.Repeat(TimeSpan.FromSeconds(15));
@@ -92,7 +92,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.SelinFireheart
void SelectNearestCrystal() void SelectNearestCrystal()
{ {
Creature crystal = me.FindNearestCreature(CreatureIds.FelCrystal, 250.0f); Creature crystal = me.FindNearestCreature(CreatureIds.FelCrystal, 250.0f);
if (crystal) if (crystal != null)
{ {
Talk(TextIds.SayEnergy); Talk(TextIds.SayEnergy);
Talk(TextIds.EmoteCrystal); Talk(TextIds.EmoteCrystal);
@@ -197,7 +197,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.SelinFireheart
Talk(TextIds.SayEmpowered); Talk(TextIds.SayEmpowered);
Creature CrystalChosen = ObjectAccessor.GetCreature(me, CrystalGUID); Creature CrystalChosen = ObjectAccessor.GetCreature(me, CrystalGUID);
if (CrystalChosen && CrystalChosen.IsAlive()) if (CrystalChosen != null && CrystalChosen.IsAlive())
CrystalChosen.KillSelf(); CrystalChosen.KillSelf();
CrystalGUID.Clear(); CrystalGUID.Clear();
@@ -247,7 +247,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.SelinFireheart
if (instance != null) if (instance != null)
{ {
Creature selin = instance.GetCreature(DataTypes.SelinFireheart); Creature selin = instance.GetCreature(DataTypes.SelinFireheart);
if (selin && selin.IsAlive()) if (selin != null && selin.IsAlive())
selin.GetAI().DoAction(MiscConst.ActionSwitchPhase); selin.GetAI().DoAction(MiscConst.ActionSwitchPhase);
} }
} }
@@ -73,14 +73,14 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.Vexallus
_scheduler.Schedule(TimeSpan.FromSeconds(8), task => _scheduler.Schedule(TimeSpan.FromSeconds(8), task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 0.0f, true);
if (target) if (target != null)
DoCast(target, SpellIds.ChainLightning); DoCast(target, SpellIds.ChainLightning);
task.Repeat(); task.Repeat();
}); });
_scheduler.Schedule(TimeSpan.FromSeconds(5), task => _scheduler.Schedule(TimeSpan.FromSeconds(5), task =>
{ {
Unit target = SelectTarget(SelectTargetMethod.Random, 0, 20.0f, true); Unit target = SelectTarget(SelectTargetMethod.Random, 0, 20.0f, true);
if (target) if (target != null)
DoCast(target, SpellIds.ArcaneShock); DoCast(target, SpellIds.ArcaneShock);
task.Repeat(TimeSpan.FromSeconds(8)); task.Repeat(TimeSpan.FromSeconds(8));
}); });
@@ -89,7 +89,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.Vexallus
public override void JustSummoned(Creature summoned) public override void JustSummoned(Creature summoned)
{ {
Unit temp = SelectTarget(SelectTargetMethod.Random, 0); Unit temp = SelectTarget(SelectTargetMethod.Random, 0);
if (temp) if (temp != null)
summoned.GetMotionMaster().MoveFollow(temp, 0, 0); summoned.GetMotionMaster().MoveFollow(temp, 0, 0);
summons.Summon(summoned); summons.Summon(summoned);
@@ -150,7 +150,7 @@ namespace Scripts.EasternKingdoms.MagistersTerrace.Vexallus
public override void JustDied(Unit killer) public override void JustDied(Unit killer)
{ {
if (killer) if (killer != null)
killer.CastSpell(killer, SpellIds.EnergyFeedback, true); killer.CastSpell(killer, SpellIds.EnergyFeedback, true);
me.RemoveAurasDueToSpell(SpellIds.PureEnergyPassive); me.RemoveAurasDueToSpell(SpellIds.PureEnergyPassive);
} }