diff options
16 files changed, 65 insertions, 59 deletions
diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.h b/src/server/game/AI/ScriptedAI/ScriptedCreature.h index 71b6461e94d..4523080adbd 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.h +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.h @@ -24,7 +24,6 @@ #include "CreatureAIImpl.h" #include "InstanceScript.h" -#define CAST_CRE(a) (dynamic_cast<Creature*>(a)) #define CAST_AI(a, b) (dynamic_cast<a*>(b)) class InstanceScript; diff --git a/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp b/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp index 558ffaf7135..cd4eaa78e9d 100644 --- a/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp +++ b/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp @@ -569,7 +569,8 @@ public: return; if (Unit* summon = me->ToTempSummon()->GetSummoner()) - CAST_CRE(summon)->AI()->SetData(2, 1); + if (Creature* creature = summon->ToCreature()) + creature->AI()->SetData(2, 1); } void UpdateAI(uint32 /*diff*/) @@ -586,8 +587,8 @@ public: return; if (Unit* summoner = me->ToTempSummon()->GetSummoner()) - if (Creature* summonerCre = summoner->ToCreature()) - summonerCre->AI()->SetData(2, 2); + if (Creature* creature = summoner->ToCreature()) + creature->AI()->SetData(2, 2); } }; diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp index 4ef91b93b43..e2227c3f304 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp @@ -145,9 +145,9 @@ public: void KilledUnit(Unit* who) { - Unit* pMalchezaar = Unit::GetUnit(*me, malchezaar); - if (pMalchezaar) - CAST_CRE(pMalchezaar)->AI()->KilledUnit(who); + if (Unit* unit = Unit::GetUnit(*me, malchezaar)) + if (Creature* creature = unit->ToCreature()) + creature->AI()->KilledUnit(who); } void SpellHit(Unit* /*who*/, const SpellInfo* spell) diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp index 332baa29b51..6fa7e94e55e 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp @@ -274,9 +274,9 @@ class boss_hexlord_malacrass : public CreatureScript for (uint8 i = 0; i < 4; ++i) { - Unit* Temp = Unit::GetUnit(*me, AddGUID[i]); - if (Temp && Temp->isAlive()) - CAST_CRE(Temp)->AI()->AttackStart(me->getVictim()); + Creature* creature = Unit::GetCreature(*me, AddGUID[i]); + if (creature && creature->isAlive()) + creature->AI()->AttackStart(me->getVictim()); else { EnterEvadeMode(); diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp index 3f186c96d40..a7d4a7087f8 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp @@ -960,12 +960,12 @@ void hyjalAI::WaypointReached(uint32 waypointId) DoCast(me, SPELL_MASS_TELEPORT, false); if (me->GetEntry() == THRALL && DummyGuid) { - Unit* Dummy = Unit::GetUnit(*me, DummyGuid); - if (Dummy) + if (Creature* creature = Unit::GetCreature(*me, DummyGuid)) { - CAST_AI(hyjalAI, CAST_CRE(Dummy)->AI())->DoMassTeleport = true; - CAST_AI(hyjalAI, CAST_CRE(Dummy)->AI())->MassTeleportTimer = 20000; - Dummy->CastSpell(me, SPELL_MASS_TELEPORT, false); + hyjalAI* ai = CAST_AI(hyjalAI, creature->AI()); + ai->DoMassTeleport = true; + ai->MassTeleportTimer = 20000; + creature->CastSpell(me, SPELL_MASS_TELEPORT, false); } } //do some talking diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp index adb89ba5a69..630c379e71e 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp @@ -191,7 +191,7 @@ hyjal_trashAI::hyjal_trashAI(Creature* creature) : npc_escortAI(creature) void hyjal_trashAI::DamageTaken(Unit* done_by, uint32 &damage) { - if (done_by->GetTypeId() == TYPEID_PLAYER || (done_by->GetTypeId() == TYPEID_UNIT && CAST_CRE(done_by)->isPet())) + if (done_by->GetTypeId() == TYPEID_PLAYER || done_by->isPet()) { damageTaken += damage; if (instance) diff --git a/src/server/scripts/Kalimdor/zone_winterspring.cpp b/src/server/scripts/Kalimdor/zone_winterspring.cpp index b48fbb2f1ae..2b68c0a2cb6 100644 --- a/src/server/scripts/Kalimdor/zone_winterspring.cpp +++ b/src/server/scripts/Kalimdor/zone_winterspring.cpp @@ -204,7 +204,7 @@ protected: /// Will be called when a dialogue step was done virtual void JustDidDialogueStep(int32 /*entry*/) {} /// Will be called to get a speaker, MUST be implemented if not used in instances - virtual Creature* GetSpeakerByEntry(uint32 /*entry*/) { return NULL; } + virtual Creature* GetSpeakerByEntry(int32 /*entry*/) { return NULL; } private: void DoNextDialogueStep() diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_skarvald_dalronn.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_skarvald_dalronn.cpp index ef7ad659a24..75f643286b2 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_skarvald_dalronn.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_skarvald_dalronn.cpp @@ -113,7 +113,7 @@ public: { Unit* dalronn = Unit::GetUnit(*me, instance->GetData64(DATA_DALRONN)); if (dalronn && dalronn->isDead()) - CAST_CRE(dalronn)->Respawn(); + dalronn->ToCreature()->Respawn(); instance->SetData(DATA_SKARVALD_DALRONN_EVENT, NOT_STARTED); } @@ -280,7 +280,7 @@ public: { Unit* skarvald = Unit::GetUnit(*me, instance->GetData64(DATA_SKARVALD)); if (skarvald && skarvald->isDead()) - CAST_CRE(skarvald)->Respawn(); + skarvald->ToCreature()->Respawn(); instance->SetData(DATA_SKARVALD_DALRONN_EVENT, NOT_STARTED); } diff --git a/src/server/scripts/Northrend/zone_borean_tundra.cpp b/src/server/scripts/Northrend/zone_borean_tundra.cpp index 46ac11e8357..6fb1079d94c 100644 --- a/src/server/scripts/Northrend/zone_borean_tundra.cpp +++ b/src/server/scripts/Northrend/zone_borean_tundra.cpp @@ -190,7 +190,7 @@ public: if (owner->GetTypeId() == TYPEID_PLAYER) { owner->CastSpell(owner, 46231, true); - CAST_CRE(who)->DespawnOrUnsummon(); + who->ToCreature()->DespawnOrUnsummon(); } } } @@ -1263,7 +1263,7 @@ public: if (me->isSummon()) if (Unit* summoner = me->ToTempSummon()->GetSummoner()) - CAST_AI(npc_thassarian::npc_thassarianAI, CAST_CRE(summoner)->AI())->arthasInPosition = true; + CAST_AI(npc_thassarian::npc_thassarianAI, summoner->ToCreature()->AI())->arthasInPosition = true; } }; @@ -1295,7 +1295,7 @@ public: me->CastSpell(me, SPELL_STUN, true); if (me->isSummon()) if (Unit* summoner = me->ToTempSummon()->GetSummoner()) - CAST_AI(npc_thassarian::npc_thassarianAI, CAST_CRE(summoner)->AI())->arlosInPosition = true; + CAST_AI(npc_thassarian::npc_thassarianAI, summoner->ToCreature()->AI())->arlosInPosition = true; } }; @@ -1352,7 +1352,7 @@ public: if (me->isSummon()) if (Unit* summoner = me->ToTempSummon()->GetSummoner()) - CAST_AI(npc_thassarian::npc_thassarianAI, CAST_CRE(summoner)->AI())->talbotInPosition = true; + CAST_AI(npc_thassarian::npc_thassarianAI, summoner->ToCreature()->AI())->talbotInPosition = true; } void UpdateAI(uint32 uiDiff) diff --git a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp index e990a6f6825..5d18026c1ca 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp @@ -2264,7 +2264,7 @@ public: if (CheckTimer <= diff) { GETUNIT(Illidan, IllidanGUID); - if (!Illidan || CAST_CRE(Illidan)->IsInEvadeMode()) + if (!Illidan || Illidan->ToCreature()->IsInEvadeMode()) { me->SetVisible(false); me->setDeathState(JUST_DIED); diff --git a/src/server/scripts/Outland/BlackTemple/illidari_council.cpp b/src/server/scripts/Outland/BlackTemple/illidari_council.cpp index d63e8ee20b0..57b7d484004 100644 --- a/src/server/scripts/Outland/BlackTemple/illidari_council.cpp +++ b/src/server/scripts/Outland/BlackTemple/illidari_council.cpp @@ -305,7 +305,7 @@ public: { Unit* member = Unit::GetUnit(*me, Council[i]); if (member && member->isAlive()) - CAST_CRE(member)->AI()->AttackStart(target); + member->ToCreature()->AI()->AttackStart(target); } } diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp index b9df26d11c6..38f02622e5a 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp @@ -542,27 +542,31 @@ public: if (Spitfire_Timer <= diff) { DoCast(me, SPELL_SPITFIRE_TOTEM); - Unit* SpitfireTotem = Unit::GetUnit(*me, CREATURE_SPITFIRE_TOTEM); - if (SpitfireTotem) - { - CAST_CRE(SpitfireTotem)->AI()->AttackStart(me->getVictim()); - } + if (Unit* SpitfireTotem = Unit::GetUnit(*me, CREATURE_SPITFIRE_TOTEM)) + SpitfireTotem->ToCreature()->AI()->AttackStart(me->getVictim()); + Spitfire_Timer = 60000; - } else Spitfire_Timer -= diff; + } + else + Spitfire_Timer -= diff; //PoisonCleansing_Timer if (PoisonCleansing_Timer <= diff) { DoCast(me, SPELL_POISON_CLEANSING_TOTEM); PoisonCleansing_Timer = 30000; - } else PoisonCleansing_Timer -= diff; + } + else + PoisonCleansing_Timer -= diff; //Earthbind_Timer if (Earthbind_Timer <= diff) { DoCast(me, SPELL_EARTHBIND_TOTEM); Earthbind_Timer = 45000; - } else Earthbind_Timer -= diff; + } + else + Earthbind_Timer -= diff; DoMeleeAttackIfReady(); } @@ -665,17 +669,19 @@ public: { //DoCast(me, SPELL_SUMMON_CYCLONE); // Doesn't work Cyclone_Timer = 30000+rand()%10000; - Creature* Cyclone = me->SummonCreature(CREATURE_CYCLONE, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), float(rand()%5), TEMPSUMMON_TIMED_DESPAWN, 15000); - if (Cyclone) + + if (Creature* Cyclone = me->SummonCreature(CREATURE_CYCLONE, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), float(rand()%5), TEMPSUMMON_TIMED_DESPAWN, 15000)) { - CAST_CRE(Cyclone)->SetObjectScale(3.0f); + Cyclone->ToCreature()->SetObjectScale(3.0f); Cyclone->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); Cyclone->setFaction(me->getFaction()); Cyclone->CastSpell(Cyclone, SPELL_CYCLONE_CYCLONE, true); if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) Cyclone->AI()->AttackStart(target); } - } else Cyclone_Timer -= diff; + } + else + Cyclone_Timer -= diff; //Heal_Timer if (Heal_Timer <= diff) @@ -684,14 +690,14 @@ public: Unit* unit = NULL; while (unit == NULL || !unit->isAlive()) - { unit = selectAdvisorUnit(); - } if (unit && unit->isAlive()) DoCast(unit, SPELL_HEAL); Heal_Timer = 60000; - } else Heal_Timer -= diff; + } + else + Heal_Timer -= diff; DoMeleeAttackIfReady(); } diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp index 19b57509093..ae63ed67af1 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp @@ -786,7 +786,7 @@ public: { // check if vashj is death Unit* Vashj = Unit::GetUnit(*me, instance->GetData64(DATA_LADYVASHJ)); - if (!Vashj || (Vashj && !Vashj->isAlive()) || (Vashj && CAST_AI(boss_lady_vashj::boss_lady_vashjAI, CAST_CRE(Vashj)->AI())->Phase != 3)) + if (!Vashj || !Vashj->isAlive() || CAST_AI(boss_lady_vashj::boss_lady_vashjAI, Vashj->ToCreature()->AI())->Phase != 3) { // remove me->setDeathState(DEAD); @@ -796,7 +796,9 @@ public: } CheckTimer = 1000; - } else CheckTimer -= diff; + } + else + CheckTimer -= diff; } }; diff --git a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warbringer_omrogg.cpp b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warbringer_omrogg.cpp index ac261cc5936..89a585e415f 100644 --- a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warbringer_omrogg.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warbringer_omrogg.cpp @@ -306,7 +306,7 @@ class boss_warbringer_omrogg : public CreatureScript pLeftHead->AI()->Talk(YELL_DIE_L); - CAST_AI(mob_omrogg_heads::mob_omrogg_headsAI, CAST_CRE(pRightHead)->AI())->DoDeathYell(); + CAST_AI(mob_omrogg_heads::mob_omrogg_headsAI, pRightHead->ToCreature()->AI())->DoDeathYell(); if (instance) instance->SetData(TYPE_OMROGG, DONE); diff --git a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warchief_kargath_bladefist.cpp b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warchief_kargath_bladefist.cpp index 13f47b276ef..2cfe73ea719 100644 --- a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warchief_kargath_bladefist.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warchief_kargath_bladefist.cpp @@ -167,9 +167,9 @@ class boss_warchief_kargath_bladefist : public CreatureScript Unit* temp = Unit::GetUnit(*me, *itr); if (temp && temp->isAlive()) { - (*temp).GetMotionMaster()->Clear(true); + temp->GetMotionMaster()->Clear(true); me->DealDamage(temp, temp->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - CAST_CRE(temp)->RemoveCorpse(); + temp->ToCreature()->RemoveCorpse(); } } adds.clear(); @@ -179,9 +179,9 @@ class boss_warchief_kargath_bladefist : public CreatureScript Unit* temp = Unit::GetUnit(*me, *itr); if (temp && temp->isAlive()) { - (*temp).GetMotionMaster()->Clear(true); + temp->GetMotionMaster()->Clear(true); me->DealDamage(temp, temp->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - CAST_CRE(temp)->RemoveCorpse(); + temp->ToCreature()->RemoveCorpse(); } } assassins.clear(); diff --git a/src/server/scripts/Outland/zone_shattrath_city.cpp b/src/server/scripts/Outland/zone_shattrath_city.cpp index bb9f0d80d12..95ba9476905 100644 --- a/src/server/scripts/Outland/zone_shattrath_city.cpp +++ b/src/server/scripts/Outland/zone_shattrath_city.cpp @@ -474,17 +474,16 @@ public: me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); me->setFaction(1194); - Unit* Creepjack = me->FindNearestCreature(NPC_CREEPJACK, 20); - if (Creepjack) + if (Unit* Creepjack = me->FindNearestCreature(NPC_CREEPJACK, 20)) { - CAST_CRE(Creepjack)->AI()->EnterEvadeMode(); + Creepjack->ToCreature()->AI()->EnterEvadeMode(); Creepjack->setFaction(1194); Creepjack->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); } - Unit* Malone = me->FindNearestCreature(NPC_MALONE, 20); - if (Malone) + + if (Unit* Malone = me->FindNearestCreature(NPC_MALONE, 20)) { - CAST_CRE(Malone)->AI()->EnterEvadeMode(); + Malone->ToCreature()->AI()->EnterEvadeMode(); Malone->setFaction(1194); Malone->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); } @@ -558,18 +557,17 @@ public: me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); me->RemoveAllAuras(); - Unit* Creepjack = me->FindNearestCreature(NPC_CREEPJACK, 20); - if (Creepjack) + if (Unit* Creepjack = me->FindNearestCreature(NPC_CREEPJACK, 20)) { - CAST_CRE(Creepjack)->AI()->EnterEvadeMode(); + Creepjack->ToCreature()->AI()->EnterEvadeMode(); Creepjack->setFaction(1194); Creepjack->GetMotionMaster()->MoveTargetedHome(); Creepjack->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); } - Unit* Malone = me->FindNearestCreature(NPC_MALONE, 20); - if (Malone) + + if (Unit* Malone = me->FindNearestCreature(NPC_MALONE, 20)) { - CAST_CRE(Malone)->AI()->EnterEvadeMode(); + Malone->ToCreature()->AI()->EnterEvadeMode(); Malone->setFaction(1194); Malone->GetMotionMaster()->MoveTargetedHome(); Malone->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); |