Skip to content
Browse files

Core/Scripts: Removed CAST_CRE define

  • Loading branch information...
1 parent 355029f commit 156fb824a437ea01b207cce37405bfa8a24624e5 @Spp- Spp- committed Mar 21, 2013
View
1 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;
View
7 src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp
@@ -569,7 +569,8 @@ class boss_grubbis : public CreatureScript
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 @@ class boss_grubbis : public CreatureScript
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);
}
};
View
6 src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp
@@ -145,9 +145,9 @@ class netherspite_infernal : public CreatureScript
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)
View
6 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();
View
10 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
View
2 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)
View
2 src/server/scripts/Kalimdor/zone_winterspring.cpp
@@ -204,7 +204,7 @@ class DialogueHelper
/// 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()
View
4 src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_skarvald_dalronn.cpp
@@ -113,7 +113,7 @@ class boss_skarvald_the_constructor : public CreatureScript
{
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 @@ class boss_dalronn_the_controller : public CreatureScript
{
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);
}
View
8 src/server/scripts/Northrend/zone_borean_tundra.cpp
@@ -190,7 +190,7 @@ class npc_khunok_the_behemoth : public CreatureScript
if (owner->GetTypeId() == TYPEID_PLAYER)
{
owner->CastSpell(owner, 46231, true);
- CAST_CRE(who)->DespawnOrUnsummon();
+ who->ToCreature()->DespawnOrUnsummon();
}
}
}
@@ -1263,7 +1263,7 @@ class npc_image_lich_king : public CreatureScript
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 @@ class npc_general_arlos : public CreatureScript
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 @@ class npc_counselor_talbot : public CreatureScript
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)
View
2 src/server/scripts/Outland/BlackTemple/boss_illidan.cpp
@@ -2264,7 +2264,7 @@ class mob_parasitic_shadowfiend : public CreatureScript
if (CheckTimer <= diff)
{
GETUNIT(Illidan, IllidanGUID);
- if (!Illidan || CAST_CRE(Illidan)->IsInEvadeMode())
+ if (!Illidan || Illidan->ToCreature()->IsInEvadeMode())
{
me->SetVisible(false);
me->setDeathState(JUST_DIED);
View
2 src/server/scripts/Outland/BlackTemple/illidari_council.cpp
@@ -305,7 +305,7 @@ class mob_illidari_council : public CreatureScript
{
Unit* member = Unit::GetUnit(*me, Council[i]);
if (member && member->isAlive())
- CAST_CRE(member)->AI()->AttackStart(target);
+ member->ToCreature()->AI()->AttackStart(target);
}
}
View
36 src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp
@@ -542,27 +542,31 @@ class boss_fathomguard_tidalvess : public CreatureScript
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 @@ class boss_fathomguard_caribdis : public CreatureScript
{
//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);
@armano2
armano2 added a note Mar 23, 2013

why u use ToCreature(), Cyclone has Creature type

@Subv
Subv added a note Mar 23, 2013

@armano2 Probably a typo.

@Shauren
TrinityCore member
Shauren added a note Mar 24, 2013

Looks like automatic conversion to me (also the original script author is an idiot)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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 @@ class boss_fathomguard_caribdis : public CreatureScript
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();
}
View
6 src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp
@@ -786,7 +786,7 @@ class mob_toxic_sporebat : public CreatureScript
{
// 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 @@ class mob_toxic_sporebat : public CreatureScript
}
CheckTimer = 1000;
- } else CheckTimer -= diff;
+ }
+ else
+ CheckTimer -= diff;
}
};
View
2 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);
View
8 ...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();
@armano2
armano2 added a note Mar 23, 2013

better way will be

Creature* temp = Unit::GetCreature(*me, *itr);

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
}
}
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();
View
22 src/server/scripts/Outland/zone_shattrath_city.cpp
@@ -474,17 +474,16 @@ class npc_dirty_larry : public CreatureScript
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))
@armano2
armano2 added a note Mar 23, 2013

this return Creature*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
{
- 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))
@armano2
armano2 added a note Mar 23, 2013

this return Creature*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
{
- 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 @@ class npc_dirty_larry : public CreatureScript
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))
@armano2
armano2 added a note Mar 23, 2013

this return Creature*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
{
- CAST_CRE(Malone)->AI()->EnterEvadeMode();
+ Malone->ToCreature()->AI()->EnterEvadeMode();
Malone->setFaction(1194);
Malone->GetMotionMaster()->MoveTargetedHome();
Malone->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);

0 comments on commit 156fb82

Please sign in to comment.
Something went wrong with that request. Please try again.