aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/scripts')
-rw-r--r--src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp4
-rw-r--r--src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp7
-rw-r--r--src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp6
-rw-r--r--src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp28
-rw-r--r--src/server/scripts/EasternKingdoms/ScarletEnclave/zone_the_scarlet_enclave.cpp3
-rw-r--r--src/server/scripts/EasternKingdoms/Stratholme/stratholme.cpp24
-rw-r--r--src/server/scripts/EasternKingdoms/ZulAman/boss_hexlord.cpp6
-rw-r--r--src/server/scripts/EasternKingdoms/zone_eversong_woods.cpp14
-rw-r--r--src/server/scripts/EasternKingdoms/zone_ghostlands.cpp3
-rw-r--r--src/server/scripts/EasternKingdoms/zone_silvermoon_city.cpp27
-rw-r--r--src/server/scripts/EasternKingdoms/zone_stranglethorn_vale.cpp17
-rw-r--r--src/server/scripts/EasternKingdoms/zone_western_plaguelands.cpp78
-rw-r--r--src/server/scripts/EasternKingdoms/zone_wetlands.cpp3
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp10
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp2
-rw-r--r--src/server/scripts/Kalimdor/RazorfenKraul/razorfen_kraul.cpp5
-rw-r--r--src/server/scripts/Kalimdor/zone_durotar.cpp9
-rw-r--r--src/server/scripts/Kalimdor/zone_tanaris.cpp18
-rw-r--r--src/server/scripts/Kalimdor/zone_the_barrens.cpp14
-rw-r--r--src/server/scripts/Kalimdor/zone_winterspring.cpp557
-rw-r--r--src/server/scripts/Northrend/DraktharonKeep/boss_trollgore.cpp2
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp2
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp9
-rw-r--r--src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp2
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp11
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp2
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp2
-rw-r--r--src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_skarvald_dalronn.cpp4
-rw-r--r--src/server/scripts/Northrend/VioletHold/boss_ichoron.cpp4
-rw-r--r--src/server/scripts/Northrend/zone_borean_tundra.cpp43
-rw-r--r--src/server/scripts/Outland/BlackTemple/boss_illidan.cpp2
-rw-r--r--src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp6
-rw-r--r--src/server/scripts/Outland/BlackTemple/illidari_council.cpp2
-rw-r--r--src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp36
-rw-r--r--src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp6
-rw-r--r--src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warbringer_omrogg.cpp2
-rw-r--r--src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warchief_kargath_bladefist.cpp8
-rw-r--r--src/server/scripts/Outland/zone_nagrand.cpp16
-rw-r--r--src/server/scripts/Outland/zone_netherstorm.cpp38
-rw-r--r--src/server/scripts/Outland/zone_shadowmoon_valley.cpp16
-rw-r--r--src/server/scripts/Outland/zone_shattrath_city.cpp46
-rw-r--r--src/server/scripts/Outland/zone_terokkar_forest.cpp32
-rw-r--r--src/server/scripts/World/npcs_special.cpp144
43 files changed, 915 insertions, 355 deletions
diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp
index 0cbeec50f98..d0c0ded2267 100644
--- a/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp
+++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp
@@ -981,9 +981,9 @@ public:
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))
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/ScarletEnclave/chapter1.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp
index d3cb21c75f0..abaf900508c 100644
--- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp
+++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp
@@ -651,19 +651,22 @@ public:
{
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 @@ public:
{
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);
}
}
diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/zone_the_scarlet_enclave.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/zone_the_scarlet_enclave.cpp
index a2c21ebbb1f..3f95d8d0aee 100644
--- a/src/server/scripts/EasternKingdoms/ScarletEnclave/zone_the_scarlet_enclave.cpp
+++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/zone_the_scarlet_enclave.cpp
@@ -76,8 +76,7 @@ public:
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;
diff --git a/src/server/scripts/EasternKingdoms/Stratholme/stratholme.cpp b/src/server/scripts/EasternKingdoms/Stratholme/stratholme.cpp
index 7208bbbee03..f12a9c33ea9 100644
--- a/src/server/scripts/EasternKingdoms/Stratholme/stratholme.cpp
+++ b/src/server/scripts/EasternKingdoms/Stratholme/stratholme.cpp
@@ -151,14 +151,15 @@ public:
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 @@ public:
{
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;
}
}
};
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/EasternKingdoms/zone_eversong_woods.cpp b/src/server/scripts/EasternKingdoms/zone_eversong_woods.cpp
index ce62de8b368..c148d485e1a 100644
--- a/src/server/scripts/EasternKingdoms/zone_eversong_woods.cpp
+++ b/src/server/scripts/EasternKingdoms/zone_eversong_woods.cpp
@@ -243,11 +243,11 @@ public:
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 @@ public:
{
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 @@ public:
{
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 @@ public:
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();
diff --git a/src/server/scripts/EasternKingdoms/zone_ghostlands.cpp b/src/server/scripts/EasternKingdoms/zone_ghostlands.cpp
index 0703f95a22c..1a9aabcda57 100644
--- a/src/server/scripts/EasternKingdoms/zone_ghostlands.cpp
+++ b/src/server/scripts/EasternKingdoms/zone_ghostlands.cpp
@@ -138,8 +138,7 @@ public:
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);
diff --git a/src/server/scripts/EasternKingdoms/zone_silvermoon_city.cpp b/src/server/scripts/EasternKingdoms/zone_silvermoon_city.cpp
index fd36a02b8a5..0e7472fc63b 100644
--- a/src/server/scripts/EasternKingdoms/zone_silvermoon_city.cpp
+++ b/src/server/scripts/EasternKingdoms/zone_silvermoon_city.cpp
@@ -88,19 +88,22 @@ public:
}
}
- 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;
}
};
};
diff --git a/src/server/scripts/EasternKingdoms/zone_stranglethorn_vale.cpp b/src/server/scripts/EasternKingdoms/zone_stranglethorn_vale.cpp
index c11e850cbc8..66fb4819175 100644
--- a/src/server/scripts/EasternKingdoms/zone_stranglethorn_vale.cpp
+++ b/src/server/scripts/EasternKingdoms/zone_stranglethorn_vale.cpp
@@ -64,10 +64,12 @@ public:
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 @@ public:
Reset_Timer = 60000;
}
}
- return;
}
void EnterCombat(Unit* /*who*/) {}
@@ -94,14 +95,14 @@ public:
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();
diff --git a/src/server/scripts/EasternKingdoms/zone_western_plaguelands.cpp b/src/server/scripts/EasternKingdoms/zone_western_plaguelands.cpp
index 1831d9f7ff1..0692330b87a 100644
--- a/src/server/scripts/EasternKingdoms/zone_western_plaguelands.cpp
+++ b/src/server/scripts/EasternKingdoms/zone_western_plaguelands.cpp
@@ -190,46 +190,47 @@ public:
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 @@ public:
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());
}
};
};
diff --git a/src/server/scripts/EasternKingdoms/zone_wetlands.cpp b/src/server/scripts/EasternKingdoms/zone_wetlands.cpp
index c8a1fc2b2b4..ea7b995e8cf 100644
--- a/src/server/scripts/EasternKingdoms/zone_wetlands.cpp
+++ b/src/server/scripts/EasternKingdoms/zone_wetlands.cpp
@@ -116,8 +116,7 @@ public:
{
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;
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/RazorfenKraul/razorfen_kraul.cpp b/src/server/scripts/Kalimdor/RazorfenKraul/razorfen_kraul.cpp
index 7cb78718e2a..55e81f1408f 100644
--- a/src/server/scripts/Kalimdor/RazorfenKraul/razorfen_kraul.cpp
+++ b/src/server/scripts/Kalimdor/RazorfenKraul/razorfen_kraul.cpp
@@ -119,8 +119,7 @@ public:
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 @@ public:
void JustDied(Unit* /*killer*/)
{
if (Player* player = GetPlayerForEscort())
- CAST_PLR(player)->FailQuest(QUEST_WILLIX_THE_IMPORTER);
+ player->FailQuest(QUEST_WILLIX_THE_IMPORTER);
}
};
diff --git a/src/server/scripts/Kalimdor/zone_durotar.cpp b/src/server/scripts/Kalimdor/zone_durotar.cpp
index 77e78199a41..6b82ee99f0a 100644
--- a/src/server/scripts/Kalimdor/zone_durotar.cpp
+++ b/src/server/scripts/Kalimdor/zone_durotar.cpp
@@ -72,10 +72,13 @@ public:
void SpellHit(Unit* caster, const SpellInfo* spell)
{
- if (spell->Id == SPELL_AWAKEN_PEON && caster->GetTypeId() == TYPEID_PLAYER
- && CAST_PLR(caster)->GetQuestStatus(QUEST_LAZY_PEONS) == QUEST_STATUS_INCOMPLETE)
+ if (spell->Id != SPELL_AWAKEN_PEON)
+ return;
+
+ Player* player = caster->ToPlayer();
+ if (player && player->GetQuestStatus(QUEST_LAZY_PEONS) == QUEST_STATUS_INCOMPLETE)
{
- caster->ToPlayer()->KilledMonsterCredit(me->GetEntry(), me->GetGUID());
+ player->KilledMonsterCredit(me->GetEntry(), me->GetGUID());
Talk(SAY_SPELL_HIT, caster->GetGUID());
me->RemoveAllAuras();
if (GameObject* Lumberpile = me->FindNearestGameObject(GO_LUMBERPILE, 20))
diff --git a/src/server/scripts/Kalimdor/zone_tanaris.cpp b/src/server/scripts/Kalimdor/zone_tanaris.cpp
index 327d85fd2ff..7e4a1d980db 100644
--- a/src/server/scripts/Kalimdor/zone_tanaris.cpp
+++ b/src/server/scripts/Kalimdor/zone_tanaris.cpp
@@ -83,15 +83,17 @@ public:
void SendItem(Unit* receiver)
{
- if (CAST_PLR(receiver)->HasItemCount(11169, 1, false) &&
- CAST_PLR(receiver)->HasItemCount(11172, 11, false) &&
- CAST_PLR(receiver)->HasItemCount(11173, 1, false) &&
- !CAST_PLR(receiver)->HasItemCount(11522, 1, true))
+ Player* player = receiver->ToPlayer();
+
+ if (player && player->HasItemCount(11169, 1, false) &&
+ player->HasItemCount(11172, 11, false) &&
+ player->HasItemCount(11173, 1, false) &&
+ !player->HasItemCount(11522, 1, true))
{
ItemPosCountVec dest;
- uint8 msg = CAST_PLR(receiver)->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, 11522, 1, NULL);
+ uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, 11522, 1, NULL);
if (msg == EQUIP_ERR_OK)
- CAST_PLR(receiver)->StoreNewItem(dest, 11522, 1, true);
+ player->StoreNewItem(dest, 11522, 1, true);
}
}
@@ -250,9 +252,9 @@ public:
if (HasEscortState(STATE_ESCORT_ESCORTING))
return;
- if (who->GetTypeId() == TYPEID_PLAYER)
+ if (Player* player = who->ToPlayer())
{
- if (who->HasAura(34877) && CAST_PLR(who)->GetQuestStatus(10277) == QUEST_STATUS_INCOMPLETE)
+ if (who->HasAura(34877) && player->GetQuestStatus(10277) == QUEST_STATUS_INCOMPLETE)
{
float Radius = 10.0f;
if (me->IsWithinDistInMap(who, Radius))
diff --git a/src/server/scripts/Kalimdor/zone_the_barrens.cpp b/src/server/scripts/Kalimdor/zone_the_barrens.cpp
index bdbd278ce89..d21ca8c9427 100644
--- a/src/server/scripts/Kalimdor/zone_the_barrens.cpp
+++ b/src/server/scripts/Kalimdor/zone_the_barrens.cpp
@@ -380,14 +380,16 @@ public:
void MoveInLineOfSight(Unit* who)
{
- if (!who || (!who->isAlive()))
+ if (!who || !who->isAlive() || EventInProgress)
return;
- if (me->IsWithinDistInMap(who, 10.0f) && (who->GetTypeId() == TYPEID_PLAYER) && CAST_PLR(who)->GetQuestStatus(1719) == QUEST_STATUS_INCOMPLETE && !EventInProgress)
- {
- PlayerGUID = who->GetGUID();
- EventInProgress = true;
- }
+ if (who->GetTypeId() == TYPEID_PLAYER && me->IsWithinDistInMap(who, 10.0f))
+ if (Player* player = who->ToPlayer())
+ if (player->GetQuestStatus(1719) == QUEST_STATUS_INCOMPLETE)
+ {
+ PlayerGUID = who->GetGUID();
+ EventInProgress = true;
+ }
}
void KilledUnit(Unit* /*victim*/) { }
diff --git a/src/server/scripts/Kalimdor/zone_winterspring.cpp b/src/server/scripts/Kalimdor/zone_winterspring.cpp
index 06f01033a25..2b68c0a2cb6 100644
--- a/src/server/scripts/Kalimdor/zone_winterspring.cpp
+++ b/src/server/scripts/Kalimdor/zone_winterspring.cpp
@@ -19,17 +19,20 @@
/* ScriptData
SDName: Winterspring
SD%Complete: Almost Completely Emptied
-SDComment: Vendor Rivern Frostwind.
+SDComment: Vendor Rivern Frostwind. Quest Support 4901
SDCategory: Winterspring
EndScriptData */
/* ContentData
npc_rivern_frostwind
+npc_ranshalla
+go_elune_fire
EndContentData */
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "ScriptedGossip.h"
+#include "ScriptedEscortAI.h"
#include "Player.h"
#include "WorldSession.h"
@@ -63,10 +66,562 @@ public:
return true;
}
+};
+
+enum Says
+{
+ // Escort texts
+ SAY_QUEST_START = 0,
+ SAY_ENTER_OWL_THICKET = 1,
+ SAY_REACH_TORCH = 2,
+ SAY_AFTER_TORCH = 3,
+ SAY_REACH_ALTAR_1 = 4,
+ SAY_REACH_ALTAR_2 = 5,
+
+ // After lighting the altar cinematic
+ SAY_RANSHALLA_ALTAR_1 = 6,
+ SAY_RANSHALLA_ALTAR_2 = 7,
+ SAY_PRIESTESS_ALTAR_3 = 8,
+ SAY_PRIESTESS_ALTAR_4 = 9,
+ SAY_RANSHALLA_ALTAR_5 = 10,
+ SAY_RANSHALLA_ALTAR_6 = 11,
+ SAY_PRIESTESS_ALTAR_7 = 12,
+ SAY_PRIESTESS_ALTAR_8 = 13,
+ SAY_PRIESTESS_ALTAR_9 = 14,
+ SAY_PRIESTESS_ALTAR_10 = 15,
+ SAY_PRIESTESS_ALTAR_11 = 16,
+ SAY_PRIESTESS_ALTAR_12 = 17,
+ SAY_PRIESTESS_ALTAR_13 = 18,
+ SAY_PRIESTESS_ALTAR_14 = 19,
+ SAY_VOICE_ALTAR_15 = 20,
+ SAY_PRIESTESS_ALTAR_16 = 21,
+ SAY_PRIESTESS_ALTAR_17 = 22,
+ SAY_PRIESTESS_ALTAR_18 = 23,
+ SAY_PRIESTESS_ALTAR_19 = 24,
+ SAY_PRIESTESS_ALTAR_20 = 25,
+ SAY_PRIESTESS_ALTAR_21 = 26,
+ SAY_RANSHALLA_END_1 = 27,
+ SAY_RANSHALLA_END_2 = 28,
+
+ EMOTE_CHANT_SPELL = 29,
+};
+
+enum Spells
+{
+ SPELL_LIGHT_TORCH = 18953, // channeled spell by Ranshalla while waiting for the torches / altar
+};
+
+enum NPCs
+{
+ NPC_RANSHALLA = 10300,
+ NPC_PRIESTESS_ELUNE = 12116,
+ NPC_VOICE_ELUNE = 12152,
+ NPC_GUARDIAN_ELUNE = 12140,
+};
+
+enum GOs
+{
+ GO_ELUNE_ALTAR = 177404,
+ GO_ELUNE_FIRE = 177417,
+ GO_ELUNE_GEM = 177414, // is respawned in script
+ GO_ELUNE_LIGHT = 177415, // are respawned in script
+};
+
+enum Quests
+{
+ QUEST_GUARDIANS_ALTAR = 4901,
+};
+
+enum Dummies
+{
+ NPC_PRIESTESS_DATA_1 = -1, // dummy member for the first priestess (right)
+ NPC_PRIESTESS_DATA_2 = -2, // dummy member for the second priestess (left)
+ DATA_MOVE_PRIESTESS = -3, // dummy member to check the priestess movement
+ DATA_EVENT_END = -4, // dummy member to indicate the event end
+
+ EVENT_RESUME = 1, // trigger rest of event
+};
+
+// DialogueHelper (imported from SD)
+
+struct DialogueEntry
+{
+ int32 TextEntry; ///< To be said text entry
+ int32 SayerEntry; ///< Entry of the mob who should say
+ uint32 SayTimer; ///< Time delay until next text of array is said (0 stops)
+};
+
+class DialogueHelper
+{
+public:
+ // The array MUST be terminated by {0,0,0}
+ DialogueHelper(DialogueEntry const* dialogueArray) :
+ _dialogueArray(dialogueArray),
+ _currentEntry(NULL),
+ _actionTimer(0),
+ _isFirstSide(true)
+ {}
+ // The array MUST be terminated by {0,0,0,0,0}
+
+ /// Function to initialize the dialogue helper for instances. If not used with instances, GetSpeakerByEntry MUST be overwritten to obtain the speakers
+ /// Set if take first entries or second entries
+
+ void StartNextDialogueText(int32 textEntry)
+ {
+ // Find textEntry
+ bool found = false;
+
+ for (DialogueEntry const* entry = _dialogueArray; entry->TextEntry; ++entry)
+ {
+ if (entry->TextEntry == textEntry)
+ {
+ _currentEntry = entry;
+ found = true;
+ break;
+ }
+ }
+
+ if (!found)
+ {
+ return;
+ }
+
+ DoNextDialogueStep();
+ }
+
+ void DialogueUpdate(uint32 diff)
+ {
+ if (_actionTimer)
+ {
+ if (_actionTimer <= diff)
+ DoNextDialogueStep();
+ else
+ _actionTimer -= diff;
+ }
+ }
+
+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(int32 /*entry*/) { return NULL; }
+private:
+ void DoNextDialogueStep()
+ {
+ // Last Dialogue Entry done?
+ if (_currentEntry && !_currentEntry->TextEntry)
+ {
+ _actionTimer = 0;
+ return;
+ }
+
+ // Get Text, SpeakerEntry and Timer
+ int32 textEntry = _currentEntry->TextEntry;
+ uint32 sayerEntry = _currentEntry->SayerEntry;
+ _actionTimer = _currentEntry->SayTimer;
+
+ // Simulate Case
+ if (sayerEntry && textEntry >= 0)
+ {
+ // Use Speaker if directly provided
+ if (Creature* speaker = GetSpeakerByEntry(sayerEntry))
+ speaker->AI()->Talk(textEntry);
+ }
+
+ JustDidDialogueStep(_currentEntry->TextEntry);
+
+ // Increment position
+ ++_currentEntry;
+ }
+
+ DialogueEntry const* _dialogueArray;
+ DialogueEntry const* _currentEntry;
+
+ uint32 _actionTimer;
+ bool _isFirstSide;
+};
+
+const DialogueEntry introDialogue[] =
+{
+ {SAY_REACH_ALTAR_1, NPC_RANSHALLA, 2000},
+ {SAY_REACH_ALTAR_2, NPC_RANSHALLA, 3000},
+ {NPC_RANSHALLA, 0, 0}, // start the altar channeling
+ {SAY_PRIESTESS_ALTAR_3, NPC_PRIESTESS_DATA_2, 1000},
+ {SAY_PRIESTESS_ALTAR_4, NPC_PRIESTESS_DATA_1, 4000},
+ {SAY_RANSHALLA_ALTAR_5, NPC_RANSHALLA, 4000},
+ {SAY_RANSHALLA_ALTAR_6, NPC_RANSHALLA, 4000}, // start the escort here
+ {SAY_PRIESTESS_ALTAR_7, NPC_PRIESTESS_DATA_2, 4000},
+ {SAY_PRIESTESS_ALTAR_8, NPC_PRIESTESS_DATA_2, 5000}, // show the gem
+ {GO_ELUNE_GEM, 0, 5000},
+ {SAY_PRIESTESS_ALTAR_9, NPC_PRIESTESS_DATA_1, 4000}, // move priestess 1 near me
+ {NPC_PRIESTESS_DATA_1, 0, 3000},
+ {SAY_PRIESTESS_ALTAR_10, NPC_PRIESTESS_DATA_1, 5000},
+ {SAY_PRIESTESS_ALTAR_11, NPC_PRIESTESS_DATA_1, 4000},
+ {SAY_PRIESTESS_ALTAR_12, NPC_PRIESTESS_DATA_1, 5000},
+ {SAY_PRIESTESS_ALTAR_13, NPC_PRIESTESS_DATA_1, 8000}, // summon voice and guard of elune
+ {NPC_VOICE_ELUNE, 0, 12000},
+ {SAY_VOICE_ALTAR_15, NPC_VOICE_ELUNE, 5000}, // move priestess 2 near me
+ {NPC_PRIESTESS_DATA_2, 0, 3000},
+ {SAY_PRIESTESS_ALTAR_16, NPC_PRIESTESS_DATA_2, 4000},
+ {SAY_PRIESTESS_ALTAR_17, NPC_PRIESTESS_DATA_2, 6000},
+ {SAY_PRIESTESS_ALTAR_18, NPC_PRIESTESS_DATA_1, 5000},
+ {SAY_PRIESTESS_ALTAR_19, NPC_PRIESTESS_DATA_1, 3000}, // move the owlbeast
+ {NPC_GUARDIAN_ELUNE, 0, 2000},
+ {SAY_PRIESTESS_ALTAR_20, NPC_PRIESTESS_DATA_1, 4000}, // move the first priestess up
+ {SAY_PRIESTESS_ALTAR_21, NPC_PRIESTESS_DATA_2, 10000}, // move second priestess up
+ {DATA_MOVE_PRIESTESS, 0, 6000}, // despawn the gem
+ {DATA_EVENT_END, 0, 2000}, // turn towards the player
+ {SAY_RANSHALLA_END_2, NPC_RANSHALLA, 0},
+ {0, 0, 0},
+};
+
+static Position wingThicketLocations[] =
+{
+ {5515.98f, -4903.43f, 846.30f, 4.58f}, // 0 right priestess summon loc
+ {5501.94f, -4920.20f, 848.69f, 6.15f}, // 1 left priestess summon loc
+ {5497.35f, -4906.49f, 850.83f, 2.76f}, // 2 guard of elune summon loc
+ {5518.38f, -4913.47f, 845.57f, 0.00f}, // 3 right priestess move loc
+ {5510.36f, -4921.17f, 846.33f, 0.00f}, // 4 left priestess move loc
+ {5511.31f, -4913.82f, 847.17f, 0.00f}, // 5 guard of elune move loc
+ {5518.51f, -4917.56f, 845.23f, 0.00f}, // 6 right priestess second move loc
+ {5514.40f, -4921.16f, 845.49f, 0.00f} // 7 left priestess second move loc
+};
+
+/*#####
+# npc_ranshalla
+#####*/
+
+class npc_ranshalla : public CreatureScript
+{
+public:
+ npc_ranshalla() : CreatureScript("npc_ranshalla") { }
+ bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest)
+ {
+ if (quest->GetQuestId() == QUEST_GUARDIANS_ALTAR)
+ {
+ creature->AI()->Talk(SAY_QUEST_START);
+ creature->setFaction(FACTION_ESCORT_A_NEUTRAL_PASSIVE);
+
+ if (npc_ranshallaAI* escortAI = dynamic_cast<npc_ranshallaAI*>(creature->AI()))
+ escortAI->Start(false, false, player->GetGUID(), quest);
+
+ return true;
+ }
+
+ return false;
+ }
+ CreatureAI* GetAI(Creature* creature) const
+ {
+ return new npc_ranshallaAI(creature);
+ }
+
+ struct npc_ranshallaAI : public npc_escortAI, private DialogueHelper
+ {
+ npc_ranshallaAI(Creature* creature) : npc_escortAI(creature),
+ DialogueHelper(introDialogue)
+ {
+ Reset();
+ }
+
+ uint32 _delayTimer;
+
+ uint64 _firstPriestessGUID;
+ uint64 _secondPriestessGUID;
+ uint64 _guardEluneGUID;
+ uint64 _voiceEluneGUID;
+ uint64 _altarGUID;
+
+ void Reset()
+ {
+ _delayTimer = 0;
+ }
+
+ // Called when the player activates the torch / altar
+ void DoContinueEscort(bool isAltarWaypoint = false)
+ {
+ me->InterruptNonMeleeSpells(false);
+
+ if (isAltarWaypoint)
+ Talk(SAY_RANSHALLA_ALTAR_1);
+ else
+ Talk(SAY_AFTER_TORCH);
+
+ _delayTimer = 2000;
+ }
+
+ // Called when Ranshalla starts to channel on a torch / altar
+ void DoChannelTorchSpell(bool isAltarWaypoint = false)
+ {
+ // Check if we are using the fire or the altar and remove the no_interact flag
+ if (isAltarWaypoint)
+ {
+ if (GameObject* go = GetClosestGameObjectWithEntry(me, GO_ELUNE_ALTAR, 10.0f))
+ {
+ go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE);
+ me->SetFacingToObject(go);
+ _altarGUID = go->GetGUID();
+ }
+ }
+ else if (GameObject* go = GetClosestGameObjectWithEntry(me, GO_ELUNE_FIRE, 10.0f))
+ go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE);
+
+ // Yell and set escort to pause
+ Talk(SAY_REACH_TORCH);
+ Talk(EMOTE_CHANT_SPELL);
+ SetEscortPaused(true);
+ DoCast(me, SPELL_LIGHT_TORCH);
+ }
+
+ void DoSummonPriestess()
+ {
+ // Summon 2 Elune priestess and make each of them move to a different spot
+ if (Creature* priestess = me->SummonCreature(NPC_PRIESTESS_ELUNE, wingThicketLocations[0].m_positionX, wingThicketLocations[0].m_positionY, wingThicketLocations[0].m_positionZ, wingThicketLocations[0].m_orientation, TEMPSUMMON_CORPSE_DESPAWN, 0))
+ {
+ priestess->GetMotionMaster()->MovePoint(0, wingThicketLocations[3].m_positionX, wingThicketLocations[3].m_positionY, wingThicketLocations[3].m_positionZ);
+ _firstPriestessGUID = priestess->GetGUID();
+ }
+ if (Creature* priestess = me->SummonCreature(NPC_PRIESTESS_ELUNE, wingThicketLocations[1].m_positionX, wingThicketLocations[1].m_positionY, wingThicketLocations[1].m_positionZ, wingThicketLocations[1].m_orientation, TEMPSUMMON_CORPSE_DESPAWN, 0))
+ {
+ // Left priestess should have a distinct move point because she is the one who starts the dialogue at point reach
+ priestess->GetMotionMaster()->MovePoint(1, wingThicketLocations[4].m_positionX, wingThicketLocations[4].m_positionY, wingThicketLocations[4].m_positionZ);
+ _secondPriestessGUID = priestess->GetGUID();
+ }
+ }
+
+ void SummonedMovementInform(Creature* summoned, uint32 type, uint32 pointId)
+ {
+ if (type != POINT_MOTION_TYPE || summoned->GetEntry() != NPC_PRIESTESS_ELUNE || pointId != 1)
+ return;
+
+ // Start the dialogue when the priestess reach the altar (they should both reach the point in the same time)
+ StartNextDialogueText(SAY_PRIESTESS_ALTAR_3);
+ }
+
+ void WaypointReached(uint32 pointId)
+ {
+ switch(pointId)
+ {
+ case 3:
+ Talk(SAY_ENTER_OWL_THICKET);
+ break;
+ case 10: // Cavern 1
+ case 15: // Cavern 2
+ case 20: // Cavern 3
+ case 25: // Cavern 4
+ case 36: // Cavern 5
+ DoChannelTorchSpell();
+ break;
+ case 39:
+ StartNextDialogueText(SAY_REACH_ALTAR_1);
+ SetEscortPaused(true);
+ break;
+ case 41:
+ {
+ // Search for all nearest lights and respawn them
+ std::list<GameObject*> eluneLights;
+ GetGameObjectListWithEntryInGrid(eluneLights, me, GO_ELUNE_LIGHT, 20.0f);
+ for (std::list<GameObject*>::const_iterator itr = eluneLights.begin(); itr != eluneLights.end(); ++itr)
+ {
+ if ((*itr)->isSpawned())
+ continue;
+
+ (*itr)->SetRespawnTime(115);
+ (*itr)->Refresh();
+ }
+
+ if (GameObject* altar = me->GetMap()->GetGameObject(_altarGUID))
+ me->SetFacingToObject(altar);
+ break;
+ }
+ case 42:
+ // Summon the 2 priestess
+ SetEscortPaused(true);
+ DoSummonPriestess();
+ Talk(SAY_RANSHALLA_ALTAR_2);
+ events.ScheduleEvent(EVENT_RESUME,2000);
+ break;
+ case 44:
+ // Stop the escort and turn towards the altar
+ SetEscortPaused(true);
+ if (GameObject* altar = me->GetMap()->GetGameObject(_altarGUID))
+ me->SetFacingToObject(altar);
+ break;
+ }
+ }
+
+ void JustDidDialogueStep(int32 entry)
+ {
+ switch (entry)
+ {
+ case NPC_RANSHALLA:
+ // Start the altar channeling
+ DoChannelTorchSpell(true);
+ break;
+ case SAY_RANSHALLA_ALTAR_6:
+ SetEscortPaused(false);
+ break;
+ case SAY_PRIESTESS_ALTAR_8:
+ // make the gem respawn
+ if (GameObject* gem = GetClosestGameObjectWithEntry(me, GO_ELUNE_GEM, 10.0f))
+ {
+ if (gem->isSpawned())
+ break;
+
+ gem->SetRespawnTime(90);
+ gem->Refresh();
+ }
+ break;
+ case SAY_PRIESTESS_ALTAR_9:
+ // move near the escort npc
+ if (Creature* priestess = me->GetMap()->GetCreature(_firstPriestessGUID))
+ priestess->GetMotionMaster()->MovePoint(0, wingThicketLocations[6].m_positionX, wingThicketLocations[6].m_positionY, wingThicketLocations[6].m_positionZ);
+ break;
+ case SAY_PRIESTESS_ALTAR_13:
+ // summon the Guardian of Elune
+ if (Creature* guard = me->SummonCreature(NPC_GUARDIAN_ELUNE, wingThicketLocations[2].m_positionX, wingThicketLocations[2].m_positionY, wingThicketLocations[2].m_positionZ, wingThicketLocations[2].m_orientation, TEMPSUMMON_CORPSE_DESPAWN, 0))
+ {
+ guard->GetMotionMaster()->MovePoint(0, wingThicketLocations[5].m_positionX, wingThicketLocations[5].m_positionY, wingThicketLocations[5].m_positionZ);
+ _guardEluneGUID = guard->GetGUID();
+ }
+ // summon the Voice of Elune
+ if (GameObject* altar = me->GetMap()->GetGameObject(_altarGUID))
+ {
+ if (Creature* voice = me->SummonCreature(NPC_VOICE_ELUNE, altar->GetPositionX(), altar->GetPositionY(), altar->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 30000))
+ _voiceEluneGUID = voice->GetGUID();
+ }
+ break;
+ case SAY_VOICE_ALTAR_15:
+ // move near the escort npc and continue dialogue
+ if (Creature* priestess = me->GetMap()->GetCreature(_secondPriestessGUID))
+ {
+ priestess->AI()->Talk(SAY_PRIESTESS_ALTAR_14);
+ priestess->GetMotionMaster()->MovePoint(0, wingThicketLocations[7].m_positionX, wingThicketLocations[7].m_positionY, wingThicketLocations[7].m_positionZ);
+ }
+ break;
+ case SAY_PRIESTESS_ALTAR_19:
+ // make the voice of elune leave
+ if (Creature* guard = me->GetMap()->GetCreature(_guardEluneGUID))
+ {
+ guard->GetMotionMaster()->MovePoint(0, wingThicketLocations[2].m_positionX, wingThicketLocations[2].m_positionY, wingThicketLocations[2].m_positionZ);
+ guard->DespawnOrUnsummon(4000);
+ }
+ break;
+ case SAY_PRIESTESS_ALTAR_20:
+ // make the first priestess leave
+ if (Creature* priestess = me->GetMap()->GetCreature(_firstPriestessGUID))
+ {
+ priestess->GetMotionMaster()->MovePoint(0, wingThicketLocations[0].m_positionX, wingThicketLocations[0].m_positionY, wingThicketLocations[0].m_positionZ);
+ priestess->DespawnOrUnsummon(4000);
+ }
+ break;
+ case SAY_PRIESTESS_ALTAR_21:
+ // make the second priestess leave
+ if (Creature* priestess = me->GetMap()->GetCreature(_secondPriestessGUID))
+ {
+ priestess->GetMotionMaster()->MovePoint(0, wingThicketLocations[1].m_positionX, wingThicketLocations[1].m_positionY, wingThicketLocations[1].m_positionZ);
+ priestess->DespawnOrUnsummon(4000);
+ }
+ break;
+ case DATA_EVENT_END:
+ // Turn towards the player
+ if (Player* player = GetPlayerForEscort())
+ {
+ me->SetFacingToObject(player);
+ Talk(SAY_RANSHALLA_END_1, player->GetGUID());
+ }
+ break;
+ case SAY_RANSHALLA_END_2:
+ // Turn towards the altar and kneel - quest complete
+ if (GameObject* altar = me->GetMap()->GetGameObject(_altarGUID))
+ {
+ me->SetFacingToObject(altar);
+ altar->ResetDoorOrButton();
+ }
+ me->SetStandState(UNIT_STAND_STATE_KNEEL);
+ if (Player* player = GetPlayerForEscort())
+ {
+ player->GroupEventHappens(QUEST_GUARDIANS_ALTAR, me);
+ Talk(SAY_RANSHALLA_END_2, player->GetGUID());
+ }
+ me->DespawnOrUnsummon(4000);
+ break;
+ }
+ }
+
+ Creature* GetSpeakerByEntry(int32 entry)
+ {
+ switch (entry)
+ {
+ case NPC_RANSHALLA:
+ return me;
+ case NPC_VOICE_ELUNE:
+ return me->GetMap()->GetCreature(_voiceEluneGUID);
+ case NPC_PRIESTESS_DATA_1:
+ return me->GetMap()->GetCreature(_firstPriestessGUID);
+ case NPC_PRIESTESS_DATA_2:
+ return me->GetMap()->GetCreature(_secondPriestessGUID);
+ default:
+ return NULL;
+ }
+
+ }
+
+ void UpdateEscortAI(const uint32 diff)
+ {
+ DialogueUpdate(diff);
+
+ if (_delayTimer)
+ {
+ if (_delayTimer <= diff)
+ {
+ SetEscortPaused(false);
+ _delayTimer = 0;
+ }
+ else
+ _delayTimer -= diff;
+ }
+ events.Update(diff);
+ if (events.ExecuteEvent() == EVENT_RESUME)
+ StartNextDialogueText(SAY_PRIESTESS_ALTAR_3);
+
+ npc_escortAI::UpdateEscortAI(diff);
+ }
+ private:
+ EventMap events;
+ };
+};
+
+/*#####
+# go_elune_fire
+#####*/
+
+class go_elune_fire : public GameObjectScript
+{
+public:
+ go_elune_fire() : GameObjectScript("go_elune_fire") { }
+ bool OnGossipHello(Player* /*player*/, GameObject* go)
+ {
+ // Check if we are using the torches or the altar
+ bool isAltar = false;
+
+ if (go->GetEntry() == GO_ELUNE_ALTAR)
+ isAltar = true;
+
+ if (Creature* ranshalla = GetClosestCreatureWithEntry(go, NPC_RANSHALLA, 10.0f))
+ {
+ if (npc_ranshalla::npc_ranshallaAI* escortAI = dynamic_cast<npc_ranshalla::npc_ranshallaAI*>(ranshalla->AI()))
+ escortAI->DoContinueEscort(isAltar);
+ }
+ go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE);
+
+ return false;
+ }
};
void AddSC_winterspring()
{
new npc_rivern_frostwind();
+ new npc_ranshalla();
+ new go_elune_fire();
}
diff --git a/src/server/scripts/Northrend/DraktharonKeep/boss_trollgore.cpp b/src/server/scripts/Northrend/DraktharonKeep/boss_trollgore.cpp
index 3dcac3f68dc..2438273dcba 100644
--- a/src/server/scripts/Northrend/DraktharonKeep/boss_trollgore.cpp
+++ b/src/server/scripts/Northrend/DraktharonKeep/boss_trollgore.cpp
@@ -185,7 +185,7 @@ public:
void JustSummoned(Creature* summon)
{
- lSummons.push_back(summon->GetGUID());
+ lSummons.Summon(summon);
if (summon->AI())
summon->AI()->AttackStart(me);
}
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp
index e377f5f8d07..cab02c9ca75 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp
@@ -687,7 +687,7 @@ class boss_professor_putricide : public CreatureScript
me->SetFacingToObject(face);
me->HandleEmoteCommand(EMOTE_ONESHOT_KNEEL);
Talk(SAY_TRANSFORM_2);
- summons.remove_if(AbominationDespawner(me));
+ summons.DespawnIf(AbominationDespawner(me));
events.ScheduleEvent(EVENT_RESUME_ATTACK, 8500, 0, PHASE_COMBAT_3);
break;
default:
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp b/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp
index 878107ab35d..0e5941138a6 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp
@@ -89,11 +89,10 @@ class boss_sapphiron : public CreatureScript
struct boss_sapphironAI : public BossAI
{
- boss_sapphironAI(Creature* creature) : BossAI(creature, BOSS_SAPPHIRON)
- , _phase(PHASE_NULL)
- {
- _map = me->GetMap();
- }
+ boss_sapphironAI(Creature* creature) :
+ BossAI(creature, BOSS_SAPPHIRON), _phase(PHASE_NULL),
+ _map(me->GetMap())
+ { }
void InitializeAI()
{
diff --git a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp
index 47e39574690..d861343116f 100644
--- a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp
+++ b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp
@@ -621,7 +621,7 @@ public:
{
VehicleCheckPredicate pred;
summons.DoAction(ACTION_DELAYED_DESPAWN, pred);
- summons.remove_if(pred);
+ summons.DespawnIf(pred);
summons.DespawnAll();
}
else if (_phase == PHASE_THREE)
diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp
index 33a14aaa3df..3299148ea43 100644
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp
@@ -287,7 +287,6 @@ class boss_freya : public CreatureScript
void Reset()
{
_Reset();
- summons.clear();
trioWaveCount = 0;
trioWaveController = 0;
waveCount = 0;
@@ -494,7 +493,7 @@ class boss_freya : public CreatureScript
{
for (uint8 n = 0; n < 3; ++n)
{
- summons.remove(Elemental[n][i]->GetGUID());
+ summons.Despawn(Elemental[n][i]);
Elemental[n][i]->DespawnOrUnsummon(5000);
trioDefeated[i] = true;
Elemental[n][i]->CastSpell(me, SPELL_REMOVE_10STACK, true);
@@ -625,7 +624,7 @@ class boss_freya : public CreatureScript
case NPC_ANCIENT_WATER_SPIRIT:
case NPC_STORM_LASHER:
ElementalGUID[trioWaveController][trioWaveCount] = summoned->GetGUID();
- summons.push_back(summoned->GetGUID());
+ summons.Summon(summoned);
++trioWaveController;
if (trioWaveController > 2)
trioWaveController = 0;
@@ -633,7 +632,7 @@ class boss_freya : public CreatureScript
case NPC_DETONATING_LASHER:
case NPC_ANCIENT_CONSERVATOR:
default:
- summons.push_back(summoned->GetGUID());
+ summons.Summon(summoned);
break;
}
@@ -654,12 +653,12 @@ class boss_freya : public CreatureScript
summoned->CastSpell(me, SPELL_REMOVE_2STACK, true);
summoned->CastSpell(who, SPELL_DETONATE, true);
summoned->DespawnOrUnsummon(5000);
- summons.remove(summoned->GetGUID());
+ summons.Despawn(summoned);
break;
case NPC_ANCIENT_CONSERVATOR:
summoned->CastSpell(me, SPELL_REMOVE_25STACK, true);
summoned->DespawnOrUnsummon(5000);
- summons.remove(summoned->GetGUID());
+ summons.Despawn(summoned);
break;
}
}
diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp
index b970dc6d7ab..0f99ea9cc2d 100644
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp
@@ -821,7 +821,7 @@ class npc_hodir_mage : public CreatureScript
void SummonedCreatureDespawn(Creature* summoned)
{
if (summoned->GetEntry() == NPC_TOASTY_FIRE)
- summons.remove(summoned->GetGUID());
+ summons.Despawn(summoned);
}
void UpdateAI(uint32 diff)
diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp
index 5e94fc2ee5d..47fe7c8f80a 100644
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp
@@ -219,7 +219,7 @@ class boss_kologarn : public CreatureScript
summon->CastSpell(me, SPELL_FOCUSED_EYEBEAM_VISUAL_RIGHT, true);
break;
case NPC_RUBBLE:
- summons.push_back(summon->GetGUID());
+ summons.Summon(summon);
// absence of break intended
default:
return;
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/VioletHold/boss_ichoron.cpp b/src/server/scripts/Northrend/VioletHold/boss_ichoron.cpp
index cfb3c03b12c..db70177f8a0 100644
--- a/src/server/scripts/Northrend/VioletHold/boss_ichoron.cpp
+++ b/src/server/scripts/Northrend/VioletHold/boss_ichoron.cpp
@@ -306,7 +306,7 @@ public:
{
summoned->SetSpeed(MOVE_RUN, 0.3f);
summoned->GetMotionMaster()->MoveFollow(me, 0, 0);
- m_waterElements.push_back(summoned->GetGUID());
+ m_waterElements.Summon(summoned);
instance->SetData64(DATA_ADD_TRASH_MOB, summoned->GetGUID());
}
}
@@ -315,7 +315,7 @@ public:
{
if (summoned)
{
- m_waterElements.remove(summoned->GetGUID());
+ m_waterElements.Despawn(summoned);
instance->SetData64(DATA_DEL_TRASH_MOB, summoned->GetGUID());
}
}
diff --git a/src/server/scripts/Northrend/zone_borean_tundra.cpp b/src/server/scripts/Northrend/zone_borean_tundra.cpp
index fef900e1dfd..6fb1079d94c 100644
--- a/src/server/scripts/Northrend/zone_borean_tundra.cpp
+++ b/src/server/scripts/Northrend/zone_borean_tundra.cpp
@@ -79,11 +79,11 @@ public:
void SpellHit(Unit* caster, const SpellInfo* spell)
{
- if (phase)
+ if (phase || spell->Id != SPELL_SET_CART)
return;
- if (spell->Id == SPELL_SET_CART && caster->GetTypeId() == TYPEID_PLAYER
- && CAST_PLR(caster)->GetQuestStatus(11897) == QUEST_STATUS_INCOMPLETE)
+ Player* player = caster->ToPlayer();
+ if (player && player->GetQuestStatus(11897) == QUEST_STATUS_INCOMPLETE)
{
phase = 1;
casterGuid = caster->GetGUID();
@@ -190,7 +190,7 @@ public:
if (owner->GetTypeId() == TYPEID_PLAYER)
{
owner->CastSpell(owner, 46231, true);
- CAST_CRE(who)->DespawnOrUnsummon();
+ who->ToCreature()->DespawnOrUnsummon();
}
}
}
@@ -419,7 +419,7 @@ public:
me->SetReactState(REACT_PASSIVE);
- switch (CAST_PLR(me->GetOwner())->GetTeamId())
+ switch (me->GetOwner()->ToPlayer()->GetTeamId())
{
case TEAM_ALLIANCE:
me->setFaction(FACTION_ESCORT_A_NEUTRAL_ACTIVE);
@@ -475,23 +475,18 @@ public:
{
ScriptedAI::MoveInLineOfSight(who);
- if (who->GetTypeId() != TYPEID_UNIT)
+ if (who->GetEntry() != NPC_JENNY || !who->HasAura(SPELL_CRATES_CARRIED))
+ return;
+
+ Unit* owner = who->GetOwner();
+ if (!owner || !me->IsWithinDistInMap(who, 10.0f))
return;
- if (who->GetEntry() == NPC_JENNY && me->IsWithinDistInMap(who, 10.0f))
+ if (Player* player = owner->ToPlayer())
{
- if (Unit* owner = who->GetOwner())
- {
- if (owner->GetTypeId() == TYPEID_PLAYER)
- {
- if (who->HasAura(SPELL_CRATES_CARRIED))
- {
- owner->CastSpell(owner, SPELL_GIVE_JENNY_CREDIT, true); // Maybe is not working.
- CAST_PLR(owner)->CompleteQuest(QUEST_LOADER_UP);
- CAST_CRE(who)->DisappearAndDie();
- }
- }
- }
+ owner->CastSpell(owner, SPELL_GIVE_JENNY_CREDIT, true); // Maybe is not working.
+ player->CompleteQuest(QUEST_LOADER_UP);
+ who->ToCreature()->DisappearAndDie();
}
}
};
@@ -569,8 +564,8 @@ public:
if (TempSummon* summon = me->ToTempSummon())
if (summon->isSummon())
if (Unit* temp = summon->GetSummoner())
- if (temp->GetTypeId() == TYPEID_PLAYER)
- CAST_PLR(temp)->KilledMonsterCredit(me->GetEntry(), 0);
+ if (Player* player = temp->ToPlayer())
+ player->KilledMonsterCredit(me->GetEntry(), 0);
if (GameObject* go_caribou = me->GetMap()->GetGameObject(go_caribouGUID))
go_caribou->SetGoState(GO_STATE_READY);
@@ -1268,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;
}
};
@@ -1300,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;
}
};
@@ -1357,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/boss_teron_gorefiend.cpp b/src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp
index 5eb9ffcabc8..1681ecfb00e 100644
--- a/src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp
+++ b/src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp
@@ -349,10 +349,10 @@ public:
{
/*float x, y, z;
ghost->GetPosition(x, y, z);
- Creature* control = me->SummonCreature(CREATURE_GHOST, x, y, z, 0, TEMPSUMMON_TIMED_DESAWN, 30000);
- if (control)
+ if (Creature* control = me->SummonCreature(CREATURE_GHOST, x, y, z, 0, TEMPSUMMON_TIMED_DESAWN, 30000))
{
- CAST_PLR(ghost)->Possess(control);
+ if (Player* player = ghost->ToPlayer())
+ player->Possess(control);
ghost->DealDamage(ghost, ghost->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL,
false);
}*/
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_nagrand.cpp b/src/server/scripts/Outland/zone_nagrand.cpp
index fd193aa4835..148bfeaeefe 100644
--- a/src/server/scripts/Outland/zone_nagrand.cpp
+++ b/src/server/scripts/Outland/zone_nagrand.cpp
@@ -339,17 +339,15 @@ public:
if (!who)
return;
- if (who->GetTypeId() == TYPEID_PLAYER)
+ Player* player = who->ToPlayer();
+ if (player && player->GetQuestStatus(10085) == QUEST_STATUS_INCOMPLETE)
{
- if (CAST_PLR(who)->GetQuestStatus(10085) == QUEST_STATUS_INCOMPLETE)
+ uint32 creditMarkerId = me->GetEntry();
+ if (creditMarkerId >= 18840 && creditMarkerId <= 18843)
{
- uint32 creditMarkerId = me->GetEntry();
- if ((creditMarkerId >= 18840) && (creditMarkerId <= 18843))
- {
- // 18840: Sunspring, 18841: Laughing, 18842: Garadar, 18843: Bleeding
- if (!CAST_PLR(who)->GetReqKillOrCastCurrentCount(10085, creditMarkerId))
- CAST_PLR(who)->KilledMonsterCredit(creditMarkerId, me->GetGUID());
- }
+ // 18840: Sunspring, 18841: Laughing, 18842: Garadar, 18843: Bleeding
+ if (!player->GetReqKillOrCastCurrentCount(10085, creditMarkerId))
+ player->KilledMonsterCredit(creditMarkerId, me->GetGUID());
}
}
}
diff --git a/src/server/scripts/Outland/zone_netherstorm.cpp b/src/server/scripts/Outland/zone_netherstorm.cpp
index 779ab3261ed..c0adddd51fc 100644
--- a/src/server/scripts/Outland/zone_netherstorm.cpp
+++ b/src/server/scripts/Outland/zone_netherstorm.cpp
@@ -118,36 +118,33 @@ public:
if (someplayer)
{
- Unit* p = Unit::GetUnit(*me, someplayer);
- if (p && p->GetTypeId() == TYPEID_PLAYER)
+ if (Player* player = ObjectAccessor::GetPlayer(*me, someplayer))
{
switch (me->GetEntry())
{
case ENTRY_BNAAR_C_CONSOLE:
- CAST_PLR(p)->FailQuest(10299);
- CAST_PLR(p)->FailQuest(10329);
+ player->FailQuest(10299);
+ player->FailQuest(10329);
break;
case ENTRY_CORUU_C_CONSOLE:
- CAST_PLR(p)->FailQuest(10321);
- CAST_PLR(p)->FailQuest(10330);
+ player->FailQuest(10321);
+ player->FailQuest(10330);
break;
case ENTRY_DURO_C_CONSOLE:
- CAST_PLR(p)->FailQuest(10322);
- CAST_PLR(p)->FailQuest(10338);
+ player->FailQuest(10322);
+ player->FailQuest(10338);
break;
case ENTRY_ARA_C_CONSOLE:
- CAST_PLR(p)->FailQuest(10323);
- CAST_PLR(p)->FailQuest(10365);
+ player->FailQuest(10323);
+ player->FailQuest(10365);
break;
}
}
}
if (goConsole)
- {
if (GameObject* go = GameObject::GetGameObject(*me, goConsole))
go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
- }
}
void DoWaveSpawnForCreature(Creature* creature)
@@ -275,27 +272,30 @@ public:
Talk(EMOTE_COMPLETE);
if (someplayer)
{
- Unit* u = Unit::GetUnit(*me, someplayer);
- if (u && u->GetTypeId() == TYPEID_PLAYER)
- CAST_PLR(u)->KilledMonsterCredit(me->GetEntry(), me->GetGUID());
+ if (Player* player = ObjectAccessor::GetPlayer(*me, someplayer))
+ player->KilledMonsterCredit(me->GetEntry(), me->GetGUID());
DoCast(me, SPELL_DISABLE_VISUAL);
}
+
if (goConsole)
- {
if (GameObject* go = GameObject::GetGameObject(*me, goConsole))
go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
- }
+
++Phase;
break;
}
- } else Event_Timer -= diff;
+ }
+ else
+ Event_Timer -= diff;
if (Wave)
{
if (Wave_Timer <= diff)
{
DoWaveSpawnForCreature(me);
- } else Wave_Timer -= diff;
+ }
+ else
+ Wave_Timer -= diff;
}
}
};
diff --git a/src/server/scripts/Outland/zone_shadowmoon_valley.cpp b/src/server/scripts/Outland/zone_shadowmoon_valley.cpp
index b8f96e373f3..644fd71e7a2 100644
--- a/src/server/scripts/Outland/zone_shadowmoon_valley.cpp
+++ b/src/server/scripts/Outland/zone_shadowmoon_valley.cpp
@@ -1377,20 +1377,19 @@ public:
{
case TYPEID_UNIT:
if (Unit* owner = killer->GetOwner())
- if (owner->GetTypeId() == TYPEID_PLAYER)
- CAST_PLR(owner)->GroupEventHappens(QUEST_BATTLE_OF_THE_CRIMSON_WATCH, me);
+ if (Player* player = owner->ToPlayer())
+ player->GroupEventHappens(QUEST_BATTLE_OF_THE_CRIMSON_WATCH, me);
break;
case TYPEID_PLAYER:
- CAST_PLR(killer)->GroupEventHappens(QUEST_BATTLE_OF_THE_CRIMSON_WATCH, me);
+ if (Player* player = killer->ToPlayer())
+ player->GroupEventHappens(QUEST_BATTLE_OF_THE_CRIMSON_WATCH, me);
break;
default:
break;
}
if (Creature* LordIllidan = (Unit::GetCreature(*me, LordIllidanGUID)))
- {
LordIllidan->AI()->EnterEvadeMode();
- }
}
};
};
@@ -1865,10 +1864,9 @@ public:
Summoned->setFaction(ENRAGED_SOUL_FRIENDLY);
Summoned->GetMotionMaster()->MovePoint(0, totemOspirits->GetPositionX(), totemOspirits->GetPositionY(), Summoned->GetPositionZ());
- Unit* Owner = totemOspirits->GetOwner();
- if (Owner && Owner->GetTypeId() == TYPEID_PLAYER)
- // DoCast(Owner, credit); -- not working!
- CAST_PLR(Owner)->KilledMonsterCredit(credit, 0);
+ if (Unit* owner = totemOspirits->GetOwner())
+ if (Player* player = owner->ToPlayer())
+ player->KilledMonsterCredit(credit, 0);
DoCast(totemOspirits, SPELL_SOUL_CAPTURED);
}
}
diff --git a/src/server/scripts/Outland/zone_shattrath_city.cpp b/src/server/scripts/Outland/zone_shattrath_city.cpp
index 14553be0ef4..95ba9476905 100644
--- a/src/server/scripts/Outland/zone_shattrath_city.cpp
+++ b/src/server/scripts/Outland/zone_shattrath_city.cpp
@@ -167,10 +167,9 @@ public:
void DamageTaken(Unit* done_by, uint32 &damage)
{
- if (done_by->GetTypeId() == TYPEID_PLAYER)
- if (me->HealthBelowPctDamaged(20, damage))
+ if (done_by->GetTypeId() == TYPEID_PLAYER && me->HealthBelowPctDamaged(20, damage))
{
- CAST_PLR(done_by)->GroupEventHappens(QUEST_10004, me);
+ done_by->ToPlayer()->GroupEventHappens(QUEST_10004, me);
damage = 0;
EnterEvadeMode();
}
@@ -410,20 +409,18 @@ public:
if (HasEscortState(STATE_ESCORT_ESCORTING))
return;
- if (who->GetTypeId() == TYPEID_PLAYER)
+ Player* player = who->ToPlayer();
+ if (player && player->GetQuestStatus(10211) == QUEST_STATUS_INCOMPLETE)
{
- if (CAST_PLR(who)->GetQuestStatus(10211) == QUEST_STATUS_INCOMPLETE)
+ float Radius = 10.0f;
+ if (me->IsWithinDistInMap(who, Radius))
{
- float Radius = 10.0f;
- if (me->IsWithinDistInMap(who, Radius))
- {
- Start(false, false, who->GetGUID());
- }
+ Start(false, false, who->GetGUID());
}
}
}
- void Reset() {}
+ void Reset() { }
};
};
@@ -477,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);
}
@@ -561,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);
@@ -583,9 +578,8 @@ public:
me->DeleteThreatList();
me->CombatStop();
me->GetMotionMaster()->MoveTargetedHome();
- Player* player = Unit::GetPlayer(*me, PlayerGUID);
- if (player)
- CAST_PLR(player)->GroupEventHappens(QUEST_WBI, me);
+ if (Player* player = Unit::GetPlayer(*me, PlayerGUID))
+ player->GroupEventHappens(QUEST_WBI, me);
}
DoMeleeAttackIfReady();
}
diff --git a/src/server/scripts/Outland/zone_terokkar_forest.cpp b/src/server/scripts/Outland/zone_terokkar_forest.cpp
index caa31ed472c..85a45193931 100644
--- a/src/server/scripts/Outland/zone_terokkar_forest.cpp
+++ b/src/server/scripts/Outland/zone_terokkar_forest.cpp
@@ -98,10 +98,11 @@ public:
void DamageTaken(Unit* done_by, uint32 &damage)
{
- if (done_by->GetTypeId() == TYPEID_PLAYER)
- if (me->HealthBelowPctDamaged(30, damage))
+ Player* player = done_by->ToPlayer();
+
+ if (player && me->HealthBelowPctDamaged(30, damage))
{
- if (Group* group = CAST_PLR(done_by)->GetGroup())
+ if (Group* group = player->GetGroup())
{
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
@@ -115,11 +116,11 @@ public:
CanDoQuest = true;
}
}
- } else
- if (CAST_PLR(done_by)->GetQuestStatus(QUEST_DONTKILLTHEFATONE) == QUEST_STATUS_INCOMPLETE &&
- CAST_PLR(done_by)->GetReqKillOrCastCurrentCount(QUEST_DONTKILLTHEFATONE, 18260) == 10)
+ }
+ else if (player->GetQuestStatus(QUEST_DONTKILLTHEFATONE) == QUEST_STATUS_INCOMPLETE &&
+ player->GetReqKillOrCastCurrentCount(QUEST_DONTKILLTHEFATONE, 18260) == 10)
{
- CAST_PLR(done_by)->AreaExploredOrEventHappens(QUEST_DONTKILLTHEFATONE);
+ player->AreaExploredOrEventHappens(QUEST_DONTKILLTHEFATONE);
CanDoQuest = true;
}
}
@@ -229,20 +230,13 @@ public:
if (HasEscortState(STATE_ESCORT_ESCORTING))
return;
- if (who->GetTypeId() == TYPEID_PLAYER)
- {
- if (CAST_PLR(who)->GetQuestStatus(10898) == QUEST_STATUS_INCOMPLETE)
- {
- float Radius = 10.0f;
- if (me->IsWithinDistInMap(who, Radius))
- {
- Start(false, false, who->GetGUID());
- }
- }
- }
+ Player* player = who->ToPlayer();
+ if (player && player->GetQuestStatus(10898) == QUEST_STATUS_INCOMPLETE)
+ if (me->IsWithinDistInMap(who, 10.0f))
+ Start(false, false, who->GetGUID());
}
- void Reset() {}
+ void Reset() { }
void UpdateAI(uint32 diff)
{
diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp
index 4c913d8c42e..59d49f50c8d 100644
--- a/src/server/scripts/World/npcs_special.cpp
+++ b/src/server/scripts/World/npcs_special.cpp
@@ -761,40 +761,41 @@ public:
void SpellHit(Unit* caster, SpellInfo const* spell)
{
- if (caster->GetTypeId() == TYPEID_PLAYER && me->isAlive() && spell->Id == 20804)
- {
- if ((CAST_PLR(caster)->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE) || (CAST_PLR(caster)->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE))
- if (DoctorGUID)
- if (Creature* doctor = Unit::GetCreature(*me, DoctorGUID))
- CAST_AI(npc_doctor::npc_doctorAI, doctor->AI())->PatientSaved(me, CAST_PLR(caster), Coord);
+ Player* player = caster->ToPlayer();
+ if (!player || !me->isAlive() || spell->Id != 20804)
+ return;
- //make not selectable
- me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+ if (player->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE)
+ if (DoctorGUID)
+ if (Creature* doctor = Unit::GetCreature(*me, DoctorGUID))
+ CAST_AI(npc_doctor::npc_doctorAI, doctor->AI())->PatientSaved(me, player, Coord);
- //regen health
- me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
+ //make not selectable
+ me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
- //stand up
- me->SetUInt32Value(UNIT_FIELD_BYTES_1, UNIT_STAND_STATE_STAND);
+ //regen health
+ me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
- Talk(SAY_DOC);
+ //stand up
+ me->SetUInt32Value(UNIT_FIELD_BYTES_1, UNIT_STAND_STATE_STAND);
- uint32 mobId = me->GetEntry();
- me->SetWalk(false);
+ Talk(SAY_DOC);
- switch (mobId)
- {
- case 12923:
- case 12924:
- case 12925:
- me->GetMotionMaster()->MovePoint(0, H_RUNTOX, H_RUNTOY, H_RUNTOZ);
- break;
- case 12936:
- case 12937:
- case 12938:
- me->GetMotionMaster()->MovePoint(0, A_RUNTOX, A_RUNTOY, A_RUNTOZ);
- break;
- }
+ uint32 mobId = me->GetEntry();
+ me->SetWalk(false);
+
+ switch (mobId)
+ {
+ case 12923:
+ case 12924:
+ case 12925:
+ me->GetMotionMaster()->MovePoint(0, H_RUNTOX, H_RUNTOY, H_RUNTOZ);
+ break;
+ case 12936:
+ case 12937:
+ case 12938:
+ me->GetMotionMaster()->MovePoint(0, A_RUNTOX, A_RUNTOY, A_RUNTOZ);
+ break;
}
}
@@ -1749,52 +1750,53 @@ public:
void ReceiveEmote(Player* player, uint32 emote)
{
me->HandleEmoteCommand(emote);
- Unit* own = me->GetOwner();
- if (!own || own->GetTypeId() != TYPEID_PLAYER || CAST_PLR(own)->GetTeam() != player->GetTeam())
- return;
- if (emote == TEXT_EMOTE_KISS)
+ Unit* owner = me->GetOwner();
+ if (emote != TEXT_EMOTE_KISS || owner || owner->GetTypeId() != TYPEID_PLAYER ||
+ owner->ToPlayer()->GetTeam() != player->GetTeam())
{
- std::string whisp = "";
- switch (rand() % 8)
- {
- case 0:
- whisp.append(SAY_RANDOM_MOJO0);
- break;
- case 1:
- whisp.append(SAY_RANDOM_MOJO1);
- break;
- case 2:
- whisp.append(SAY_RANDOM_MOJO2);
- break;
- case 3:
- whisp.append(SAY_RANDOM_MOJO3);
- break;
- case 4:
- whisp.append(SAY_RANDOM_MOJO4);
- break;
- case 5:
- whisp.append(SAY_RANDOM_MOJO5);
- break;
- case 6:
- whisp.append(SAY_RANDOM_MOJO6a);
- whisp.append(player->GetName());
- whisp.append(SAY_RANDOM_MOJO6b);
- break;
- case 7:
- whisp.append(SAY_RANDOM_MOJO7);
- break;
- }
+ return;
+ }
- me->MonsterWhisper(whisp.c_str(), player->GetGUID());
- if (victimGUID)
- if (Player* victim = Unit::GetPlayer(*me, victimGUID))
- victim->RemoveAura(43906);//remove polymorph frog thing
- me->AddAura(43906, player);//add polymorph frog thing
- victimGUID = player->GetGUID();
- DoCast(me, 20372, true);//tag.hearts
- me->GetMotionMaster()->MoveFollow(player, 0, 0);
- hearts = 15000;
+ std::string whisp = "";
+ switch (rand() % 8)
+ {
+ case 0:
+ whisp.append(SAY_RANDOM_MOJO0);
+ break;
+ case 1:
+ whisp.append(SAY_RANDOM_MOJO1);
+ break;
+ case 2:
+ whisp.append(SAY_RANDOM_MOJO2);
+ break;
+ case 3:
+ whisp.append(SAY_RANDOM_MOJO3);
+ break;
+ case 4:
+ whisp.append(SAY_RANDOM_MOJO4);
+ break;
+ case 5:
+ whisp.append(SAY_RANDOM_MOJO5);
+ break;
+ case 6:
+ whisp.append(SAY_RANDOM_MOJO6a);
+ whisp.append(player->GetName());
+ whisp.append(SAY_RANDOM_MOJO6b);
+ break;
+ case 7:
+ whisp.append(SAY_RANDOM_MOJO7);
+ break;
}
+
+ me->MonsterWhisper(whisp.c_str(), player->GetGUID());
+ if (victimGUID)
+ if (Player* victim = Unit::GetPlayer(*me, victimGUID))
+ victim->RemoveAura(43906); // remove polymorph frog thing
+ me->AddAura(43906, player); // add polymorph frog thing
+ victimGUID = player->GetGUID();
+ DoCast(me, 20372, true); // tag.hearts
+ me->GetMotionMaster()->MoveFollow(player, 0, 0);
+ hearts = 15000;
}
};