Permalink
Browse files

Core/Scripts: Removed CAST_PLR define

  • Loading branch information...
1 parent d091097 commit 355029fb4f30a3d535a7c360b896b728eee330b6 @Spp- Spp- committed Mar 21, 2013
Showing with 304 additions and 291 deletions.
  1. +0 −1 src/server/game/AI/ScriptedAI/ScriptedCreature.h
  2. +2 −2 src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp
  3. +16 −12 src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp
  4. +1 −2 src/server/scripts/EasternKingdoms/ScarletEnclave/zone_the_scarlet_enclave.cpp
  5. +14 −10 src/server/scripts/EasternKingdoms/Stratholme/stratholme.cpp
  6. +2 −1 src/server/scripts/EasternKingdoms/zone_burning_steppes.cpp
  7. +7 −7 src/server/scripts/EasternKingdoms/zone_eversong_woods.cpp
  8. +1 −2 src/server/scripts/EasternKingdoms/zone_ghostlands.cpp
  9. +15 −12 src/server/scripts/EasternKingdoms/zone_silvermoon_city.cpp
  10. +2 −2 src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp
  11. +9 −8 src/server/scripts/EasternKingdoms/zone_stranglethorn_vale.cpp
  12. +40 −38 src/server/scripts/EasternKingdoms/zone_western_plaguelands.cpp
  13. +1 −2 src/server/scripts/EasternKingdoms/zone_wetlands.cpp
  14. +2 −3 src/server/scripts/Kalimdor/RazorfenKraul/razorfen_kraul.cpp
  15. +21 −8 src/server/scripts/Kalimdor/zone_azshara.cpp
  16. +6 −3 src/server/scripts/Kalimdor/zone_durotar.cpp
  17. +10 −8 src/server/scripts/Kalimdor/zone_tanaris.cpp
  18. +8 −6 src/server/scripts/Kalimdor/zone_the_barrens.cpp
  19. +15 −20 src/server/scripts/Northrend/zone_borean_tundra.cpp
  20. +3 −3 src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp
  21. +7 −9 src/server/scripts/Outland/zone_nagrand.cpp
  22. +19 −19 src/server/scripts/Outland/zone_netherstorm.cpp
  23. +7 −9 src/server/scripts/Outland/zone_shadowmoon_valley.cpp
  24. +10 −14 src/server/scripts/Outland/zone_shattrath_city.cpp
  25. +13 −19 src/server/scripts/Outland/zone_terokkar_forest.cpp
  26. +73 −71 src/server/scripts/World/npcs_special.cpp
@@ -24,7 +24,6 @@
#include "CreatureAIImpl.h"
#include "InstanceScript.h"
-#define CAST_PLR(a) (dynamic_cast<Player*>(a))
#define CAST_CRE(a) (dynamic_cast<Creature*>(a))
#define CAST_AI(a, b) (dynamic_cast<a*>(b))
@@ -981,9 +981,9 @@ class npc_marshal_reginald_windsor : public CreatureScript
if (HasEscortState(STATE_ESCORT_ESCORTING))
return;
- if (who->GetTypeId() == TYPEID_PLAYER)
+ if (Player* player = who->ToPlayer())
{
- if (CAST_PLR(who)->GetQuestStatus(4322) == QUEST_STATUS_INCOMPLETE)
+ if (player->GetQuestStatus(4322) == QUEST_STATUS_INCOMPLETE)
{
float Radius = 10.0f;
if (me->IsWithinDistInMap(who, Radius))
@@ -651,19 +651,22 @@ class npc_salanar_the_horseman : public CreatureScript
{
if (Unit* charmer = who->GetCharmer())
{
- if (charmer->GetTypeId() == TYPEID_PLAYER)
+ if (Player* player = charmer->ToPlayer())
{
// for quest Into the Realm of Shadows(12687)
- if (me->GetEntry() == 28788 && CAST_PLR(charmer)->GetQuestStatus(12687) == QUEST_STATUS_INCOMPLETE)
+ if (me->GetEntry() == 28788 && player->GetQuestStatus(12687) == QUEST_STATUS_INCOMPLETE)
{
- CAST_PLR(charmer)->GroupEventHappens(12687, me);
+ player->GroupEventHappens(12687, me);
charmer->RemoveAurasDueToSpell(SPELL_EFFECT_OVERTAKE);
- CAST_CRE(who)->DespawnOrUnsummon();
- //CAST_CRE(who)->Respawn(true);
+ if (Creature* creature = who->ToCreature())
+ {
+ creature->DespawnOrUnsummon();
+ //creature->Respawn(true);
+ }
}
- if (CAST_PLR(charmer)->HasAura(SPELL_REALM_OF_SHADOWS))
- charmer->RemoveAurasDueToSpell(SPELL_REALM_OF_SHADOWS);
+ if (player->HasAura(SPELL_REALM_OF_SHADOWS))
+ player->RemoveAurasDueToSpell(SPELL_REALM_OF_SHADOWS);
}
}
}
@@ -753,17 +756,18 @@ class npc_dkc1_gothik : public CreatureScript
{
if (Unit* owner = who->GetOwner())
{
- if (owner->GetTypeId() == TYPEID_PLAYER)
+ if (Player* player = owner->ToPlayer())
{
- if (CAST_PLR(owner)->GetQuestStatus(12698) == QUEST_STATUS_INCOMPLETE)
- CAST_CRE(who)->CastSpell(owner, 52517, true);
+ Creature* creature = who->ToCreature();
+ if (player->GetQuestStatus(12698) == QUEST_STATUS_INCOMPLETE)
+ creature->CastSpell(owner, 52517, true);
/// @todo Creatures must not be removed, but, must instead
// stand next to Gothik and be commanded into the pit
// and dig into the ground.
- CAST_CRE(who)->DespawnOrUnsummon();
+ creature->DespawnOrUnsummon();
- if (CAST_PLR(owner)->GetQuestStatus(12698) == QUEST_STATUS_COMPLETE)
+ if (player->GetQuestStatus(12698) == QUEST_STATUS_COMPLETE)
owner->RemoveAllMinionsByEntry(NPC_GHOSTS);
}
}
@@ -76,8 +76,7 @@ class npc_valkyr_battle_maiden : public CreatureScript
Player* player = NULL;
if (me->isSummon())
if (Unit* summoner = me->ToTempSummon()->GetSummoner())
- if (summoner->GetTypeId() == TYPEID_PLAYER)
- player = CAST_PLR(summoner);
+ player = summoner->ToPlayer();
if (!player)
phase = 3;
@@ -151,14 +151,15 @@ class mob_restless_soul : public CreatureScript
void SpellHit(Unit* caster, const SpellInfo* spell)
{
- if (caster->GetTypeId() == TYPEID_PLAYER)
- {
- if (!Tagged && spell->Id == SPELL_EGAN_BLASTER && CAST_PLR(caster)->GetQuestStatus(QUEST_RESTLESS_SOUL) == QUEST_STATUS_INCOMPLETE)
- {
- Tagged = true;
- Tagger = caster->GetGUID();
- }
- }
+ if (Tagged || spell->Id != SPELL_EGAN_BLASTER)
+ return;
+
+ Player* player = caster->ToPlayer();
+ if (!player || player->GetQuestStatus(QUEST_RESTLESS_SOUL) != QUEST_STATUS_INCOMPLETE)
+ return;
+
+ Tagged = true;
+ Tagger = caster->GetGUID();
}
void JustSummoned(Creature* summoned)
@@ -180,10 +181,13 @@ class mob_restless_soul : public CreatureScript
{
if (Unit* temp = Unit::GetUnit(*me, Tagger))
{
- CAST_PLR(temp)->KilledMonsterCredit(ENTRY_RESTLESS, me->GetGUID());
+ if (Player* player = temp->ToPlayer())
+ player->KilledMonsterCredit(ENTRY_RESTLESS, me->GetGUID());
me->Kill(me);
}
- } else Die_Timer -= diff;
+ }
+ else
+ Die_Timer -= diff;
}
}
};
@@ -141,7 +141,8 @@ class npc_ragged_john : public CreatureScript
if (who->GetTypeId() == TYPEID_PLAYER && me->IsWithinDistInMap(who, 15) && who->isInAccessiblePlaceFor(me))
{
DoCast(who, 16472);
- CAST_PLR(who)->AreaExploredOrEventHappens(4866);
+ if (Player* player = who->ToPlayer())
+ player->AreaExploredOrEventHappens(4866);
}
}
@@ -243,11 +243,11 @@ class npc_second_trial_paladin : public CreatureScript
summonerGuid = summonerguid;
}
- void KilledUnit(Unit* Killed)
+ void KilledUnit(Unit* unit)
{
- if (Killed->GetTypeId() == TYPEID_PLAYER)
- if (CAST_PLR(Killed)->GetQuestStatus(QUEST_SECOND_TRIAL) == QUEST_STATUS_INCOMPLETE)
- CAST_PLR(Killed)->FailQuest(QUEST_SECOND_TRIAL);
+ if (Player* player = unit->ToPlayer())
+ if (player->GetQuestStatus(QUEST_SECOND_TRIAL) == QUEST_STATUS_INCOMPLETE)
+ player->FailQuest(QUEST_SECOND_TRIAL);
}
void JustDied(Unit* killer);
@@ -577,7 +577,7 @@ class npc_infused_crystal : public CreatureScript
{
if (!Progress && who->GetTypeId() == TYPEID_PLAYER && me->IsWithinDistInMap(who, 10.0f))
{
- if (CAST_PLR(who)->GetQuestStatus(QUEST_POWERING_OUR_DEFENSES) == QUEST_STATUS_INCOMPLETE)
+ if (who->ToPlayer()->GetQuestStatus(QUEST_POWERING_OUR_DEFENSES) == QUEST_STATUS_INCOMPLETE)
{
PlayerGUID = who->GetGUID();
WaveTimer = 1000;
@@ -596,7 +596,7 @@ class npc_infused_crystal : public CreatureScript
{
if (PlayerGUID && !Completed)
if (Player* player = Unit::GetPlayer(*me, PlayerGUID))
- CAST_PLR(player)->FailQuest(QUEST_POWERING_OUR_DEFENSES);
+ player->FailQuest(QUEST_POWERING_OUR_DEFENSES);
}
void UpdateAI(uint32 diff)
@@ -607,7 +607,7 @@ class npc_infused_crystal : public CreatureScript
Completed = true;
if (PlayerGUID)
if (Player* player = Unit::GetPlayer(*me, PlayerGUID))
- CAST_PLR(player)->CompleteQuest(QUEST_POWERING_OUR_DEFENSES);
+ player->CompleteQuest(QUEST_POWERING_OUR_DEFENSES);
me->DealDamage(me, me->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
me->RemoveCorpse();
@@ -175,8 +175,7 @@ class npc_ranger_lilatha : public CreatureScript
me->SetWalk(true);
break;
case 30:
- if (player->GetTypeId() == TYPEID_PLAYER)
- CAST_PLR(player)->GroupEventHappens(QUEST_ESCAPE_FROM_THE_CATACOMBS, me);
+ player->GroupEventHappens(QUEST_ESCAPE_FROM_THE_CATACOMBS, me);
break;
case 32:
me->SetOrientation(2.978281f);
@@ -88,19 +88,22 @@ class npc_blood_knight_stillblade : public CreatureScript
}
}
- void SpellHit(Unit* Hitter, const SpellInfo* Spellkind)
+ void SpellHit(Unit* caster, const SpellInfo* Spellkind)
{
- if ((Spellkind->Id == SPELL_SHIMMERING_VESSEL) && !spellHit &&
- (Hitter->GetTypeId() == TYPEID_PLAYER) && (CAST_PLR(Hitter)->IsActiveQuest(QUEST_REDEEMING_THE_DEAD)))
- {
- CAST_PLR(Hitter)->AreaExploredOrEventHappens(QUEST_REDEEMING_THE_DEAD);
- DoCast(me, SPELL_REVIVE_SELF);
- me->SetStandState(UNIT_STAND_STATE_STAND);
- me->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 0);
- //me->RemoveAllAuras();
- Talk(SAY_HEAL);
- spellHit = true;
- }
+ if (Spellkind->Id != SPELL_SHIMMERING_VESSEL || spellHit)
+ return;
+
+ Player* player = caster->ToPlayer();
+ if (!player || !player->IsActiveQuest(QUEST_REDEEMING_THE_DEAD))
+ return;
+
+ player->AreaExploredOrEventHappens(QUEST_REDEEMING_THE_DEAD);
+ DoCast(me, SPELL_REVIVE_SELF);
+ me->SetStandState(UNIT_STAND_STATE_STAND);
+ me->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 0);
+ //me->RemoveAllAuras();
+ Talk(SAY_HEAL);
+ spellHit = true;
}
};
};
@@ -139,8 +139,8 @@ class npc_bartleby : public CreatureScript
//Take 0 damage
uiDamage = 0;
- if (pDoneBy->GetTypeId() == TYPEID_PLAYER)
- CAST_PLR(pDoneBy)->AreaExploredOrEventHappens(QUEST_BEAT);
+ if (Player* player = pDoneBy->ToPlayer())
+ player->AreaExploredOrEventHappens(QUEST_BEAT);
EnterEvadeMode();
}
}
@@ -64,10 +64,12 @@ class mob_yenniku : public CreatureScript
void SpellHit(Unit* caster, const SpellInfo* spell)
{
- if (caster->GetTypeId() == TYPEID_PLAYER)
+ if (bReset || spell->Id != 3607)
+ return;
+
+ if (Player* player = caster->ToPlayer())
{
- //Yenniku's Release
- if (!bReset && CAST_PLR(caster)->GetQuestStatus(592) == QUEST_STATUS_INCOMPLETE && spell->Id == 3607)
+ if (player->GetQuestStatus(592) == QUEST_STATUS_INCOMPLETE) //Yenniku's Release
{
me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_STUN);
me->CombatStop(); //stop combat
@@ -78,7 +80,6 @@ class mob_yenniku : public CreatureScript
Reset_Timer = 60000;
}
}
- return;
}
void EnterCombat(Unit* /*who*/) {}
@@ -94,14 +95,14 @@ class mob_yenniku : public CreatureScript
me->setFaction(28); //troll, bloodscalp
return;
}
- else Reset_Timer -= diff;
+
+ Reset_Timer -= diff;
if (me->isInCombat() && me->getVictim())
{
- if (me->getVictim()->GetTypeId() == TYPEID_PLAYER)
+ if (Player* player = me->getVictim()->ToPlayer())
{
- Unit* victim = me->getVictim();
- if (CAST_PLR(victim)->GetTeam() == HORDE)
+ if (player->GetTeam() == HORDE)
{
me->CombatStop();
me->DeleteThreatList();
@@ -190,46 +190,47 @@ class npc_the_scourge_cauldron : public CreatureScript
void MoveInLineOfSight(Unit* who)
{
- if (!who || who->GetTypeId() != TYPEID_PLAYER)
+ if (!who)
+ return;
+
+ Player* player = who->ToPlayer();
+ if (!player)
return;
- if (who->GetTypeId() == TYPEID_PLAYER)
+ switch (me->GetAreaId())
{
- switch (me->GetAreaId())
- {
- case 199: //felstone
- if (CAST_PLR(who)->GetQuestStatus(5216) == QUEST_STATUS_INCOMPLETE ||
- CAST_PLR(who)->GetQuestStatus(5229) == QUEST_STATUS_INCOMPLETE)
- {
- me->SummonCreature(11075, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000);
- DoDie();
- }
- break;
- case 200: //dalson
- if (CAST_PLR(who)->GetQuestStatus(5219) == QUEST_STATUS_INCOMPLETE ||
- CAST_PLR(who)->GetQuestStatus(5231) == QUEST_STATUS_INCOMPLETE)
- {
- me->SummonCreature(11077, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000);
- DoDie();
- }
- break;
- case 201: //gahrron
- if (CAST_PLR(who)->GetQuestStatus(5225) == QUEST_STATUS_INCOMPLETE ||
- CAST_PLR(who)->GetQuestStatus(5235) == QUEST_STATUS_INCOMPLETE)
- {
- me->SummonCreature(11078, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000);
- DoDie();
- }
- break;
- case 202: //writhing
- if (CAST_PLR(who)->GetQuestStatus(5222) == QUEST_STATUS_INCOMPLETE ||
- CAST_PLR(who)->GetQuestStatus(5233) == QUEST_STATUS_INCOMPLETE)
- {
- me->SummonCreature(11076, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000);
- DoDie();
- }
- break;
- }
+ case 199: //felstone
+ if (player->GetQuestStatus(5216) == QUEST_STATUS_INCOMPLETE ||
+ player->GetQuestStatus(5229) == QUEST_STATUS_INCOMPLETE)
+ {
+ me->SummonCreature(11075, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000);
+ DoDie();
+ }
+ break;
+ case 200: //dalson
+ if (player->GetQuestStatus(5219) == QUEST_STATUS_INCOMPLETE ||
+ player->GetQuestStatus(5231) == QUEST_STATUS_INCOMPLETE)
+ {
+ me->SummonCreature(11077, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000);
+ DoDie();
+ }
+ break;
+ case 201: //gahrron
+ if (player->GetQuestStatus(5225) == QUEST_STATUS_INCOMPLETE ||
+ player->GetQuestStatus(5235) == QUEST_STATUS_INCOMPLETE)
+ {
+ me->SummonCreature(11078, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000);
+ DoDie();
+ }
+ break;
+ case 202: //writhing
+ if (player->GetQuestStatus(5222) == QUEST_STATUS_INCOMPLETE ||
+ player->GetQuestStatus(5233) == QUEST_STATUS_INCOMPLETE)
+ {
+ me->SummonCreature(11076, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000);
+ DoDie();
+ }
+ break;
}
}
};
@@ -267,7 +268,8 @@ class npc_andorhal_tower : public CreatureScript
return;
if (me->FindNearestGameObject(GO_BEACON_TORCH, 10.0f))
- CAST_PLR(who)->KilledMonsterCredit(me->GetEntry(), me->GetGUID());
+ if (Player* player = who->ToPlayer())
+ player->KilledMonsterCredit(me->GetEntry(), me->GetGUID());
}
};
};
@@ -116,8 +116,7 @@ class npc_tapoke_slim_jahn : public CreatureScript
{
if (Player* player = GetPlayerForEscort())
{
- if (player->GetTypeId() == TYPEID_PLAYER)
- CAST_PLR(player)->GroupEventHappens(QUEST_MISSING_DIPLO_PT11, me);
+ player->GroupEventHappens(QUEST_MISSING_DIPLO_PT11, me);
uiDamage = 0;
@@ -119,8 +119,7 @@ class npc_willix : public CreatureScript
case 45:
Talk(SAY_WIN, player->GetGUID());
me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
- if (player->GetTypeId() == TYPEID_PLAYER)
- CAST_PLR(player)->GroupEventHappens(QUEST_WILLIX_THE_IMPORTER, me);
+ player->GroupEventHappens(QUEST_WILLIX_THE_IMPORTER, me);
break;
case 46:
Talk(SAY_END, player->GetGUID());
@@ -143,7 +142,7 @@ class npc_willix : public CreatureScript
void JustDied(Unit* /*killer*/)
{
if (Player* player = GetPlayerForEscort())
- CAST_PLR(player)->FailQuest(QUEST_WILLIX_THE_IMPORTER);
+ player->FailQuest(QUEST_WILLIX_THE_IMPORTER);
}
};
Oops, something went wrong.

0 comments on commit 355029f

Please sign in to comment.