Index: Makefile.am =================================================================== --- Makefile.am (revision 1718) +++ Makefile.am (working copy) @@ -253,6 +253,13 @@ scripts/kalimdor/winterspring.cpp \ scripts/kalimdor/blackfathom_deeps/blackfathom_deeps.h \ scripts/kalimdor/blackfathom_deeps/instance_blackfathom_deeps.cpp \ +scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_infinite_corruptor.cpp \ +scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_lord_epoch.cpp \ +scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_malganis.cpp \ +scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_meathook.cpp \ +scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_salramm.cpp \ +scripts/kalimdor/caverns_of_time/culling_of_stratholme/culling_of_stratholmeAI.cpp \ +scripts/kalimdor/caverns_of_time/culling_of_stratholme/trash_culling_of_stratholme.cpp \ scripts/kalimdor/caverns_of_time/culling_of_stratholme/culling_of_stratholme.h \ scripts/kalimdor/caverns_of_time/culling_of_stratholme/culling_of_stratholme.cpp \ scripts/kalimdor/caverns_of_time/culling_of_stratholme/instance_culling_of_stratholme.cpp \ Index: scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_infinite_corruptor.cpp =================================================================== --- scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_infinite_corruptor.cpp (revision 0) +++ scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_infinite_corruptor.cpp (revision 0) @@ -0,0 +1,97 @@ +#include "precompiled.h" +#include "culling_of_stratholme.h" + +enum +{ + SPELL_COURSE = 60588, + SPELL_STRIKE = 60590 +}; + +struct MANGOS_DLL_DECL boss_infinite_corruptorAI : public ScriptedAI +{ + boss_infinite_corruptorAI(Creature *pCreature) : ScriptedAI(pCreature) + { + m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); + Reset(); + } + + ScriptedInstance* m_pInstance; + + uint32 m_uiStrikeTimer; + uint32 m_uiCourseTimer; + + void Reset() + { + m_uiCourseTimer = 7000; + m_uiStrikeTimer = 5000; + } + + void Aggro(Unit* who) + { + if(m_pInstance) + m_pInstance->SetData(TYPE_BONUS, SPECIAL); + } + + void JustDied(Unit *killer) + { + if(m_pInstance) + m_pInstance->SetData(TYPE_BONUS, DONE); + } + + void EnterEvadeMode() + { + if(!m_pInstance) return; + + m_creature->RemoveAllAuras(); + m_creature->DeleteThreatList(); + m_creature->CombatStop(true); + m_creature->LoadCreaturesAddon(); + if(m_pInstance) + m_pInstance->SetData(TYPE_BONUS, IN_PROGRESS); + + if(m_creature->isAlive()) + m_creature->GetMotionMaster()->MoveTargetedHome(); + + m_creature->SetLootRecipient(NULL); + + Reset(); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) + return; + + DoMeleeAttackIfReady(); + + if (m_uiCourseTimer < diff) + { + if (Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0)) + DoCast(target, SPELL_COURSE); + + m_uiCourseTimer = 17000; + }else m_uiCourseTimer -= diff; + + if (m_uiStrikeTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_STRIKE); + + m_uiStrikeTimer = 5000; + }else m_uiStrikeTimer -= diff; + } +}; + +CreatureAI* GetAI_boss_infinite_corruptor(Creature* pCreature) +{ + return new boss_infinite_corruptorAI(pCreature); +} + +void AddSC_boss_infinite_corruptor() +{ + Script *newscript; + + newscript = new Script; + newscript->Name = "boss_infinite_corruptor"; + newscript->GetAI = &GetAI_boss_infinite_corruptor; + newscript->RegisterSelf(); +} Index: scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_lord_epoch.cpp =================================================================== --- scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_lord_epoch.cpp (revision 0) +++ scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_lord_epoch.cpp (revision 0) @@ -0,0 +1,123 @@ +#include "precompiled.h" +#include "culling_of_stratholme.h" + +enum +{ + SPELL_COURSE = 52772, + SPELL_TIME_STOP = 58848, + SPELL_TIME_WARP = 52766, + SPELL_SPIKE_N = 52771, + SPELL_SPIKE_H = 58830, + + SAY_EPOCH_DEATH = -1594119, + SAY_EPOCH_SLAY01 = -1594120, + SAY_EPOCH_SLAY02 = -1594121, + SAY_EPOCH_SLAY03 = -1594122, + SAY_EPOCH_WARP01 = -1594123, + SAY_EPOCH_WARP02 = -1594124, + SAY_EPOCH_WARP03 = -1594125 +}; + +struct MANGOS_DLL_DECL boss_lord_epochAI : public ScriptedAI +{ + boss_lord_epochAI(Creature *pCreature) : ScriptedAI(pCreature) + { + m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); + m_bIsHeroic = pCreature->GetMap()->IsRaidOrHeroicDungeon(); + Reset(); + } + + ScriptedInstance* m_pInstance; + bool m_bIsHeroic; + + uint32 Spike_Timer; + uint32 Warp_Timer; + uint32 Stop_Timer; + uint32 Course_Timer; + uint64 m_uiArthasGUID; + + void Reset() + { + Course_Timer = 9300; + Stop_Timer = 21300; + Warp_Timer = 25300; + Spike_Timer = 5300; + } + + void JustDied(Unit *killer) + { + DoScriptText(SAY_EPOCH_DEATH, m_creature); + } + + void KilledUnit(Unit* pVictim) + { + switch(rand()%3) + { + case 0: DoScriptText(SAY_EPOCH_SLAY01, m_creature); break; + case 1: DoScriptText(SAY_EPOCH_SLAY02, m_creature); break; + case 2: DoScriptText(SAY_EPOCH_SLAY03, m_creature); break; + } + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) + return; + + DoMeleeAttackIfReady(); + + if (Course_Timer < diff) + { + if (Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0)) + DoCast(target, SPELL_COURSE); + + Course_Timer = 9300; + }else Course_Timer -= diff; + + if (Spike_Timer < diff) + { + + DoCast(m_creature->getVictim(),m_bIsHeroic ? SPELL_SPIKE_H : SPELL_SPIKE_N); + + Spike_Timer = 5300; + }else Spike_Timer -= diff; + + if (Stop_Timer < diff) + { + if (Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0)) + DoCast(target, SPELL_TIME_STOP); + + Stop_Timer = 21300; + }else Stop_Timer -= diff; + + if (Warp_Timer < diff) + { + if (Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0)) + DoCast(target, SPELL_TIME_WARP); + switch(rand()%3) + { + case 0: DoScriptText(SAY_EPOCH_WARP01, m_creature); break; + case 1: DoScriptText(SAY_EPOCH_WARP02, m_creature); break; + case 2: DoScriptText(SAY_EPOCH_WARP03, m_creature); break; + } + + Warp_Timer = 25300; + }else Warp_Timer -= diff; + + } +}; + +CreatureAI* GetAI_boss_lord_epoch(Creature* pCreature) +{ + return new boss_lord_epochAI(pCreature); +} + +void AddSC_boss_lord_epoch() +{ + Script *newscript; + + newscript = new Script; + newscript->Name = "boss_lord_epoch"; + newscript->GetAI = &GetAI_boss_lord_epoch; + newscript->RegisterSelf(); +} Index: scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_malganis.cpp =================================================================== --- scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_malganis.cpp (revision 0) +++ scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_malganis.cpp (revision 0) @@ -0,0 +1,218 @@ +#include "precompiled.h" +#include "culling_of_stratholme.h" + +enum +{ + SAY_MALGANIS_AGGRO = -1594170, + SAY_MALGANIS_SLAY01 = -1594172, + SAY_MALGANIS_SLAY02 = -1594173, + SAY_MALGANIS_SLAY03 = -1594174, + SAY_MALGANIS_SLAY04 = -1594175, + SAY_MALGANIS_SLAY05 = -1594176, + SAY_MALGANIS_SLAY06 = -1594177, + SAY_MALGANIS_SLAY07 = -1594166, + SAY_MALGANIS_SLEEP01 = -1594185, + SAY_MALGANIS_SLEEP02 = -1594186, + SAY_MALGANIS_Sleep = -1594178, + SAY_MALGANIS_15HP = -1594179, + + SPELL_SWAMP_N = 52720, + SPELL_SWAMP_H = 58852, + SPELL_MIND_BLAST_N = 52722, + SPELL_MIND_BLAST_H = 58850, + SPELL_SLEEP_N = 52721, + SPELL_SLEEP_H = 58849, + SPELL_VAMPIRE = 52723 +}; + +struct MANGOS_DLL_DECL boss_malganisAI : public ScriptedAI +{ + boss_malganisAI(Creature *pCreature) : ScriptedAI(pCreature) + { + m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); + m_bIsHeroic = pCreature->GetMap()->IsRaidOrHeroicDungeon(); + Reset(); + } + + ScriptedInstance* m_pInstance; + bool m_bIsHeroic; + + Unit* pTarget; + bool Sleep; + bool Vampire; + uint32 Phase; + Creature* Malganis; + Creature* Arthas; + + uint32 Swamp_Timer; + uint32 MindBlast_Timer; + uint32 Sleep_Timer; + uint32 Vampire_Timer; + + void Reset() + { + Sleep = false; + Vampire = false; + Swamp_Timer = 6300; + MindBlast_Timer = 11300; + Sleep_Timer = 17300; + Vampire_Timer = 30000; + } + + void AttackStart(Unit* who) + { + if(m_pInstance->GetData(TYPE_PHASE) > 9) return; + + if(m_pInstance->GetData(TYPE_MALGANIS) != IN_PROGRESS) return; + + if(!who || who == m_creature) + return; + + ScriptedAI::AttackStart(who); + } + + void KillCreditMalganis() + { + Map *map = m_creature->GetMap(); + Map::PlayerList const& players = map->GetPlayers(); + if (!players.isEmpty() && map->IsDungeon()) + { + for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) + { + if(Player* pPlayer = itr->getSource()) + pPlayer->KilledMonsterCredit(31006, m_creature->GetGUID()); + } + } + } + + void EnterEvadeMode() + { + m_creature->RemoveAllAuras(); + m_creature->DeleteThreatList(); + m_creature->CombatStop(true); + m_creature->LoadCreaturesAddon(); + + if(m_pInstance->GetData(TYPE_PHASE) > 9) + { + KillCreditMalganis(); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + if (Creature* pArthas = m_pInstance->instance->GetCreature(m_pInstance->GetData64(NPC_ARTHAS))) + m_creature->SetInCombatWith(pArthas); + } + else + m_creature->RemoveFromWorld(); + + m_creature->SetLootRecipient(NULL); + } + + void Aggro(Unit* who) + { + if(m_pInstance->GetData(TYPE_PHASE) > 9) return; + + DoScriptText(SAY_MALGANIS_AGGRO, m_creature); + } + + void KilledUnit(Unit* pVictim) + { + switch(rand()%7) + { + case 0: DoScriptText(SAY_MALGANIS_SLAY01, m_creature); break; + case 1: DoScriptText(SAY_MALGANIS_SLAY02, m_creature); break; + case 2: DoScriptText(SAY_MALGANIS_SLAY03, m_creature); break; + case 3: DoScriptText(SAY_MALGANIS_SLAY04, m_creature); break; + case 4: DoScriptText(SAY_MALGANIS_SLAY05, m_creature); break; + case 5: DoScriptText(SAY_MALGANIS_SLAY06, m_creature); break; + case 6: DoScriptText(SAY_MALGANIS_SLAY07, m_creature); break; + } + } + + void UpdateAI(const uint32 diff) + { + if(m_pInstance->GetData(TYPE_PHASE) > 9) return; + + if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) + return; + + DoMeleeAttackIfReady(); + + if (Swamp_Timer < diff) + { + if (Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0)) + DoCast(target, m_bIsHeroic ? SPELL_SWAMP_H : SPELL_SWAMP_N); + + Swamp_Timer = 7300; + }else Swamp_Timer -= diff; + + if (MindBlast_Timer < diff) + { + if (Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0)) + DoCast(target, m_bIsHeroic ? SPELL_MIND_BLAST_H : SPELL_MIND_BLAST_N); + + MindBlast_Timer = 11300; + }else MindBlast_Timer -= diff; + + if(m_creature->GetHealthPercent() < 40.0f) + { + if(Sleep == false) + { + Sleep = true; + DoScriptText(SAY_MALGANIS_Sleep, m_creature); + } + + if (Sleep_Timer < diff) + { + if (Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0)) + DoCast(target, m_bIsHeroic ? SPELL_SLEEP_H : SPELL_SLEEP_N); + switch(rand()%2) + { + case 0: DoScriptText(SAY_MALGANIS_SLEEP01, m_creature); break; + case 1: DoScriptText(SAY_MALGANIS_SLEEP02, m_creature); break; + } + + Sleep_Timer = 17300; + }else Sleep_Timer -= diff; + } + + if(m_creature->GetHealthPercent() < 25.0f) + { + if(Vampire == false) + { + Vampire = true; + DoScriptText(SAY_MALGANIS_15HP, m_creature); + DoCast(m_creature, SPELL_VAMPIRE); + } + + if (Vampire_Timer < diff) + { + DoCast(m_creature, SPELL_VAMPIRE); + + Vampire_Timer = 30000; + }else Vampire_Timer -= diff; + + } + + if(m_creature->GetHealthPercent() < 5.0f) + { + m_pInstance->SetData(TYPE_PHASE, 10); + m_pInstance->SetData(TYPE_MALGANIS, DONE); + EnterEvadeMode(); + } + + } +}; + +CreatureAI* GetAI_boss_malganis(Creature* pCreature) +{ + return new boss_malganisAI(pCreature); +} + +void AddSC_boss_malganis() +{ + Script *newscript; + + newscript = new Script; + newscript->Name = "boss_malganis"; + newscript->GetAI = &GetAI_boss_malganis; + newscript->RegisterSelf(); + +} Index: scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_meathook.cpp =================================================================== --- scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_meathook.cpp (revision 0) +++ scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_meathook.cpp (revision 0) @@ -0,0 +1,112 @@ +#include "precompiled.h" +#include "culling_of_stratholme.h" + +enum +{ + SPELL_CHAIN_N = 52696, + SPELL_CHAIN_H = 58823, + SPELL_EXPLODED_N = 52666, + SPELL_EXPLODED_H = 58824, + SPELL_FRENZY = 58841, + + SAY_MEATHOOK_AGGRO = -1594111, + SAY_MEATHOOK_DEATH = -1594112, + SAY_MEATHOOK_SLAY01 = -1594113, + SAY_MEATHOOK_SLAY02 = -1594114, + SAY_MEATHOOK_SLAY03 = -1594115 +}; + +struct MANGOS_DLL_DECL boss_meathookAI : public ScriptedAI +{ + boss_meathookAI(Creature *pCreature) : ScriptedAI(pCreature) + { + m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); + m_bIsHeroic = pCreature->GetMap()->IsRaidOrHeroicDungeon(); + Reset(); + } + + ScriptedInstance* m_pInstance; + bool m_bIsHeroic; + + uint32 Chain_Timer; + uint32 Exploded_Timer; + uint32 Frenzy_Timer; + + void Reset() + { + Chain_Timer = 6300; + Exploded_Timer = 5000; + Frenzy_Timer = 22300; + } + + void Aggro(Unit* who) + { + DoScriptText(SAY_MEATHOOK_AGGRO, m_creature); + } + + void JustDied(Unit *killer) + { + DoScriptText(SAY_MEATHOOK_DEATH, m_creature); + if(m_pInstance) + m_pInstance->SetData(TYPE_PHASE, 3); + } + + void KilledUnit(Unit* pVictim) + { + switch(rand()%3) + { + case 0: DoScriptText(SAY_MEATHOOK_SLAY01, m_creature); break; + case 1: DoScriptText(SAY_MEATHOOK_SLAY02, m_creature); break; + case 2: DoScriptText(SAY_MEATHOOK_SLAY03, m_creature); break; + } + } + + void UpdateAI(const uint32 diff) + { + + if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) + return; + + DoMeleeAttackIfReady(); + + if (Chain_Timer < diff) + { + if (Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0)) + DoCast(target, m_bIsHeroic ? SPELL_CHAIN_H : SPELL_CHAIN_N); + + Chain_Timer = 6300; + }else Chain_Timer -= diff; + + if (Exploded_Timer < diff) + { + if (Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0)) + DoCast(target, m_bIsHeroic ? SPELL_EXPLODED_H : SPELL_EXPLODED_N); + + Exploded_Timer = 5000; + }else Exploded_Timer -= diff; + + if (Frenzy_Timer < diff) + { + m_creature->InterruptNonMeleeSpells(false); + DoCast(m_creature,SPELL_FRENZY); + + Frenzy_Timer = 23300; + }else Frenzy_Timer -= diff; + + } +}; + +CreatureAI* GetAI_boss_meathook(Creature* pCreature) +{ + return new boss_meathookAI(pCreature); +} + +void AddSC_boss_meathook() +{ + Script *newscript; + + newscript = new Script; + newscript->Name = "boss_meathook"; + newscript->GetAI = &GetAI_boss_meathook; + newscript->RegisterSelf(); +} Index: scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_salramm.cpp =================================================================== --- scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_salramm.cpp (revision 0) +++ scripts/kalimdor/caverns_of_time/culling_of_stratholme/boss_salramm.cpp (revision 0) @@ -0,0 +1,241 @@ +#include "precompiled.h" +#include "culling_of_stratholme.h" + +enum +{ + SAY_SALRAMM_AGGRO = -1594130, + SAY_SALRAMM_DEATH = -1594131, + SAY_SALRAMM_SLAY01 = -1594132, + SAY_SALRAMM_SLAY02 = -1594133, + SAY_SALRAMM_SLAY03 = -1594134, + SAY_SALRAMM_STEAL01 = -1594135, + SAY_SALRAMM_STEAL02 = -1594136, + SAY_SALRAMM_STEAL03 = -1594137, + SAY_SUMMON01 = -1594138, + SAY_SUMMON02 = -1594139, + SAY_BOOM01 = -1594140, + SAY_BOOM02 = -1594141, + + SPELL_SB_N = 57725, + SPELL_SB_H = 58827, + SPELL_FLESH = 58845, + SPELL_STEAL = 52708, + SPELL_GNOUL_BLOW = 58825, + SPELL_SUMMON_GNOUL = 52451, + + NPC_GNOUL = 27733 +}; + +struct MANGOS_DLL_DECL boss_salrammAI : public ScriptedAI +{ + boss_salrammAI(Creature *pCreature) : ScriptedAI(pCreature) + { + m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); + m_bIsHeroic = pCreature->GetMap()->IsRaidOrHeroicDungeon(); + Reset(); + } + + ScriptedInstance* m_pInstance; + bool m_bIsHeroic; + + uint32 ShadowBoltTimer; + uint32 FleshTimer; + uint32 StealTimer; + uint32 SummonTimer; + + void Reset() + { + ShadowBoltTimer = 5000; + FleshTimer = (urand(7000, 9000)); + StealTimer = (urand(9000, 17000)); + SummonTimer = (urand(12000, 17000)); + if(m_pInstance) + m_pInstance->SetData64(NPC_SALRAMM, m_creature->GetGUID()); + } + + void Aggro(Unit* who) + { + DoScriptText(SAY_SALRAMM_AGGRO, m_creature); + } + + void JustDied(Unit *killer) + { + DoScriptText(SAY_SALRAMM_DEATH, m_creature); + if(m_pInstance) + m_pInstance->SetData(TYPE_ENCOUNTER, DONE); + } + + void KilledUnit(Unit* pVictim) + { + switch(rand()%3) + { + case 0: DoScriptText(SAY_SALRAMM_SLAY01, m_creature); break; + case 1: DoScriptText(SAY_SALRAMM_SLAY02, m_creature); break; + case 2: DoScriptText(SAY_SALRAMM_SLAY03, m_creature); break; + } + } + + void SpellHitTarget(Unit *target, const SpellEntry *spell) + { + if(spell->Id == SPELL_GNOUL_BLOW) + if(target->GetTypeId() != TYPEID_PLAYER && target->GetEntry() == NPC_GNOUL) + target->SetDisplayId(11686); + } + + void UpdateAI(const uint32 diff) + { + + if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) + return; + + if (ShadowBoltTimer < diff) + { + DoCast(m_creature->getVictim(), m_bIsHeroic ? SPELL_SB_H : SPELL_SB_N); + + ShadowBoltTimer = (urand(5000, 6000)); + }else ShadowBoltTimer -= diff; + + if (FleshTimer < diff) + { + if (Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0)) + DoCast(target,SPELL_FLESH); + + FleshTimer = 7300; + }else FleshTimer -= diff; + + if (StealTimer < diff) + { + if (Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0)) + DoCast(target,SPELL_STEAL); + + switch(rand()%3) + { + case 0: DoScriptText(SAY_SALRAMM_STEAL01, m_creature); break; + case 1: DoScriptText(SAY_SALRAMM_STEAL02, m_creature); break; + case 2: DoScriptText(SAY_SALRAMM_STEAL03, m_creature); break; + } + + StealTimer = (urand(8000, 11000)); + }else StealTimer -= diff; + + if (SummonTimer < diff) + { + switch(rand()%2) + { + case 0: DoScriptText(SAY_SUMMON01, m_creature); break; + case 1: DoScriptText(SAY_SUMMON02, m_creature); break; + } + + m_creature->InterruptNonMeleeSpells(false); + DoCast(m_creature,SPELL_SUMMON_GNOUL); + + SummonTimer = (urand(12000, 17000)); + }else SummonTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +/*### +## npc_salramm_gnoul +###*/ + +struct MANGOS_DLL_DECL npc_salramm_gnoulAI : public ScriptedAI +{ + npc_salramm_gnoulAI(Creature *pCreature) : ScriptedAI(pCreature) + { + m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); + m_bIsHeroic = pCreature->GetMap()->IsRaidOrHeroicDungeon(); + Reset(); + } + + ScriptedInstance* m_pInstance; + bool m_bIsHeroic; + + uint32 m_uiBlowTimer; + + void Reset() + { + m_uiBlowTimer = (urand(3000, 15000)); + } + + void MoveInLineOfSight(Unit* pWho) + { + if (!pWho) + return; + + if (!m_creature->hasUnitState(UNIT_STAT_STUNNED) && pWho->isTargetableForAttack() && + m_creature->IsHostileTo(pWho) && pWho->isInAccessablePlaceFor(m_creature)) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(pWho) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(pWho); + if (m_creature->IsWithinDistInMap(pWho, attackRadius) && m_creature->IsWithinLOSInMap(pWho)) + { + if (!m_creature->getVictim()) + { + AttackStart(pWho); + pWho->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + } + else if (m_creature->GetMap()->IsDungeon()) + { + pWho->SetInCombatWith(m_creature); + m_creature->AddThreat(pWho, 0.0f); + } + } + } + } + + void UpdateAI(const uint32 uiDiff) + { + if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) + return; + + if(m_uiBlowTimer < uiDiff) + { + if(Creature* pSalramm = m_pInstance->instance->GetCreature(m_pInstance->GetData64(NPC_SALRAMM))) + { + if(pSalramm->isDead()) return; + + switch(rand()%2) + { + case 0: DoScriptText(SAY_BOOM01, pSalramm); break; + case 1: DoScriptText(SAY_BOOM02, pSalramm); break; + } + pSalramm->InterruptNonMeleeSpells(false); + pSalramm->CastSpell(m_creature, SPELL_GNOUL_BLOW, false); + } + } + else m_uiBlowTimer -= uiDiff; + + DoMeleeAttackIfReady(); + + return; + } +}; + +CreatureAI* GetAI_boss_salramm(Creature* pCreature) +{ + return new boss_salrammAI(pCreature); +} + +CreatureAI* GetAI_npc_salramm_gnoul(Creature* pCreature) +{ + return new npc_salramm_gnoulAI(pCreature); +} + +void AddSC_boss_salramm() +{ + Script *newscript; + + newscript = new Script; + newscript->Name = "boss_salramm"; + newscript->GetAI = &GetAI_boss_salramm; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_salramm_gnoul"; + newscript->GetAI = &GetAI_npc_salramm_gnoul; + newscript->RegisterSelf(); +} Index: scripts/kalimdor/caverns_of_time/culling_of_stratholme/culling_of_stratholme.cpp =================================================================== --- scripts/kalimdor/caverns_of_time/culling_of_stratholme/culling_of_stratholme.cpp (revision 1718) +++ scripts/kalimdor/caverns_of_time/culling_of_stratholme/culling_of_stratholme.cpp (working copy) @@ -1,228 +1,1748 @@ -/* Copyright (C) 2006 - 2010 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: culling_of_stratholme -SD%Complete: 5% -SDComment: Placeholder -SDCategory: Culling of Stratholme -EndScriptData */ - #include "precompiled.h" #include "culling_of_stratholme.h" +#include "escort_ai.h" +#include "WorldPacket.h" +#include "Weather.h" -/* ************* -** npc_chromie (gossip, quest-accept) -************* */ +/*### +## npc_arthas +###*/ enum { - QUEST_DISPELLING_ILLUSIONS = 13149, - QUEST_A_ROYAL_ESCORT = 13151, + SAY_INTRO01 = -1594071, //Arthas + SAY_INTRO02 = -1594072, //Uther + SAY_INTRO03 = -1594073, //Arthas + SAY_INTRO04 = -1594074, //Arthas + SAY_INTRO05 = -1594075, //Uther + SAY_INTRO06 = -1594076, //Arthas + SAY_INTRO07 = -1594077, //Uther + SAY_INTRO08 = -1594078, //Arthas + SAY_INTRO09 = -1594079, //Arthas + SAY_INTRO10 = -1594080, //Uther + SAY_INTRO11 = -1594081, //Arthas + SAY_INTRO12 = -1594082, //Uther + SAY_INTRO13 = -1594083, //Jaina + SAY_INTRO14 = -1594084, //Arthas + SAY_INTRO15 = -1594085, //Uther + SAY_INTRO16 = -1594086, //Arthas + SAY_INTRO17 = -1594087, //Jaina + SAY_INTRO18 = -1594088, //Arthas - ITEM_ARCANE_DISRUPTOR = 37888, + SAY_ENTER01 = -1594089, //Arthas + SAY_ENTER02 = -1594090, //Cityman + SAY_ENTER03 = -1594091, //Arthas + SAY_ENTER04 = -1594092, //Crazyman + SAY_ENTER05 = -1594093, //Crazyman2 + SAY_ENTER06 = -1594094, //Arthas + SAY_ENTER07 = -1594095, //Malganis + SAY_ENTER08 = -1594096, //Malganis + SAY_ENTER09 = -1594097, //Arthas + SAY_ENTER10 = -1594098, //Arthas - GOSSIP_MENU_INN_1 = 12939, - GOSSIP_MENU_INN_2 = 12949, - GOSSIP_MENU_INN_3 = 12950, - GOSSIP_MENU_INN_4 = 12952, + SAY_SALRAMM_SPAWN = -1594129, + SAY_MEATHOOK_SPAWN = -1594110, - GOSSIP_MENU_ENTRANCE_1 = 12992, - GOSSIP_MENU_ENTRANCE_2 = 12993, - GOSSIP_MENU_ENTRANCE_3 = 12994, - GOSSIP_MENU_ENTRANCE_4 = 12995, -}; + SAY_PHASE501 = -1594142, //Arthas + SAY_PHASE502 = -1594143, //Arthas + SAY_PHASE503 = -1594144, //Human + SAY_PHASE504 = -1594145, //Arthas + SAY_PHASE505 = -1594146, //Arthas + SAY_PHASE506 = -1594147, //Human + SAY_PHASE507 = -1594148, //Arthas + SAY_PHASE508 = -1594149, //Arthas + SAY_PHASE509 = -1594150, //Arthas + SAY_PHASE510 = -1594151, //Arthas + SAY_PHASE511 = -1594152, //Arthas + SAY_PHASE512 = -1594153, //Arthas + SAY_PHASE513 = -1594154, //Arthas -const std::string GOSSIP_ITEM_INN_1 = "Why have I been sent back to this particular place and time?"; -const std::string GOSSIP_ITEM_INN_2 = "What was this decision?"; -const std::string GOSSIP_ITEM_INN_3 = "So how does the Infinite Dragonflight plan to interfere?"; + SAY_EPOCH_INTRO = -1594155, + SAY_ARTHAS_INTRO = -1594156, + SAY_EPOCH_AGGRO = -1594157, -const std::string GOSSIP_ITEM_ENTRANCE_1 = "What do you think they're up to?"; -const std::string GOSSIP_ITEM_ENTRANCE_2 = "You want me to do what?"; -const std::string GOSSIP_ITEM_ENTRANCE_3 = "Very well, Chromie"; + SAY_PHASE514 = -1594158, //Arthas Shkaf 01 + SAY_PHASE515 = -1594159, //Arthas Shkaf 02 + SAY_PHASE601 = -1594160, //Arthas Fire + SAY_PHASE602 = -1594161, //Arthas Picnic + SAY_PHASE603 = -1594162, //Arthas Picnic End + SAY_PHASE604 = -1594163, + SAY_PHASE605 = -1594164, //Arthas mall start + SAY_MALGANIS_ESCAPE02 = -1594180, + SAY_MALGANIS_ESCAPE01 = -1594187, + SAY_MALGANIS_OUTRO = -1594182, + SAY_ARTHAS_OUTRO01 = -1594181, + SAY_ARTHAS_OUTRO02 = -1594183, + SAY_ARTHAS_OUTRO03 = -1594184, -bool GossipHello_npc_chromie(Player *pPlayer, Creature *pCreature) + /*SPELL*/ + SPELL_EXORCISM_N = 52445, + SPELL_EXORCISM_H = 58822, + SPELL_HOLY_LIGHT = 52444, + SPELL_ARTHAS_AURA = 52442, + + /*NPC*/ + NPC_CITYMAN = 28167, + NPC_CRAZYMAN = 28169, + NPC_MALGANIS_INTRO = 26533, + + /*OTHER*/ + POINT_LAST_POINT = 0xFFFFFF, + FACTION = 2076 +}; + +const float SummonScourge[2][4] = { - if (pCreature->isQuestGiver()) - pPlayer->PrepareQuestMenu(pCreature->GetGUID()); + {2340.058f, 1253.570f, 132.733f, 5.09f}, //right wing + {2272.773f, 1331.824f, 124.171f, 3.12f}, //left wing +}; - if (instance_culling_of_stratholme* m_pInstance = (instance_culling_of_stratholme*)pCreature->GetInstanceData()) +struct MANGOS_DLL_DECL npc_arthasAI : public npc_escortAI +{ + npc_arthasAI(Creature* pCreature) : npc_escortAI(pCreature) { - switch (pCreature->GetEntry()) + m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); + m_bIsHeroic = pCreature->GetMap()->IsRaidOrHeroicDungeon(); + m_creature->SetSpeedRate(MOVE_RUN, 1); + Reset(); + } + + ScriptedInstance* m_pInstance; + bool m_bIsHeroic; + + uint64 m_uiUtherGUID; + uint64 m_uiJainaGUID; + uint64 m_uiPeople01GUID; + uint64 m_uiPeople02GUID; + uint64 m_uiMalganisGUID; + uint64 m_uiMarine01GUID; + uint64 m_uiMarine02GUID; + uint64 m_uiMarine03GUID; + uint64 m_uiMarine04GUID; + uint64 m_uiPriest01GUID; + uint64 m_uiPriest02GUID; + uint64 m_uiHuman01GUID; + uint64 m_uiHuman02GUID; + uint64 m_uiHuman03GUID; + + uint32 culling_faction; + uint32 m_uiStep; + uint32 m_uiStepTimer; + uint32 m_uiMoveTimer; + uint32 m_uiHealTimer; + uint32 m_uiExorcismTimer; + uint32 m_uiSummonTimer; + uint32 m_uiWaveCount; + + Creature* Malganis; + Creature* pEpoch; + bool StartEvent; + bool MoveSoldier; + + float LastX; + float LastY; + float LastZ; + + void Reset() + { + m_creature->SetSpeedRate(MOVE_RUN, 1); + if(!m_pInstance) return; + + if(m_pInstance->GetData(TYPE_INTRO) == NOT_STARTED) { - case NPC_CHROMIE_INN: - if (m_pInstance->GetData(TYPE_GRAIN_EVENT) != DONE) + m_creature->setFaction(35); + RemoveGossip(); + } + + if(m_pInstance->GetData(TYPE_PHASE) == 11) + { + m_creature->SetVisibility(VISIBILITY_OFF); + } + } + + void RemoveGossip() + { + m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); + m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + } + + void MoveSoldiers() + { + if(Unit* Marine01 = Unit::GetUnit((*m_creature), m_uiMarine01GUID)) + { + Marine01->GetMotionMaster()->MovePoint(0, 2083.483f,1282.313f,141.198f); + Marine01->setFaction(culling_faction); + } + if(Unit* Marine02 = Unit::GetUnit((*m_creature), m_uiMarine02GUID)) + { + Marine02->GetMotionMaster()->MovePoint(0, 2083.681f,1292.809f,141.141f); + Marine02->setFaction(culling_faction); + } + if(Unit* Marine03 = Unit::GetUnit((*m_creature), m_uiMarine03GUID)) + { + Marine03->GetMotionMaster()->MovePoint(0, 2082.158f,1290.406f,141.261f); + Marine03->setFaction(culling_faction); + } + if(Unit* Marine04 = Unit::GetUnit((*m_creature), m_uiMarine04GUID)) + { + Marine04->GetMotionMaster()->MovePoint(0, 2081.899f,1285.122f,141.302f); + Marine04->setFaction(culling_faction); + } + if(Unit* Priest01 = Unit::GetUnit((*m_creature), m_uiPriest01GUID)) + { + Priest01->GetMotionMaster()->MovePoint(0, 2081.072f,1292.233f,141.329f); + Priest01->setFaction(culling_faction); + } + if(Unit* Priest02 = Unit::GetUnit((*m_creature), m_uiPriest02GUID)) + { + Priest02->GetMotionMaster()->MovePoint(0, 2080.632f,1283.004f,141.358f); + Priest02->setFaction(culling_faction); + } + } + + void EnableEscort() + { + SetEscortPaused(false); + } + + void SummonPeople() + { + if(Creature* Cityman = m_creature->SummonCreature(NPC_CITYMAN,2091.977f,1275.021f,140.757f,0.558f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,30000)) + m_uiPeople01GUID = Cityman->GetGUID(); + if(Creature* Crazyman = m_creature->SummonCreature(NPC_CRAZYMAN,2093.514f,1275.842f,140.408f,3.801f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,30000)) + m_uiPeople02GUID = Crazyman->GetGUID(); + } + + void StartAI() + { + SummonPeople(); + m_uiStep = 0; + m_uiStepTimer = 100; + StartEvent = true; + } + + void Aggro(Unit* who) + { + DoCast(m_creature, SPELL_ARTHAS_AURA); + } + + void EnterEvadeMode() + { + if(!m_pInstance) return; + + m_creature->RemoveAllAuras(); + m_creature->DeleteThreatList(); + m_creature->CombatStop(true); + m_creature->LoadCreaturesAddon(); + m_uiExorcismTimer = 7400; + m_uiHealTimer = 100; + + m_creature->SetLootRecipient(NULL); + + if(m_pInstance->GetData(TYPE_PHASE) > 4) + { + npc_escortAI::EnterEvadeMode(); + } + + if(m_pInstance->GetData(TYPE_PHASE) > 2 && m_pInstance->GetData(TYPE_PHASE) < 5) + { + m_creature->GetMotionMaster()->MovePoint(POINT_LAST_POINT, LastX, LastY, LastZ); + } + } + + void AttackStart(Unit* pWho) + { + if(!pWho || pWho == m_creature) + return; + + if(m_pInstance && m_pInstance->GetData(TYPE_PHASE) == 4) return; + + npc_escortAI::AttackStart(pWho); + } + + void MoveInLineOfSight(Unit* pWho) + { + if (!pWho) + return; + + if (!m_creature->hasUnitState(UNIT_STAT_STUNNED) && pWho->isTargetableForAttack() && + m_creature->IsHostileTo(pWho) && pWho->isInAccessablePlaceFor(m_creature)) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(pWho) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(pWho); + if (m_creature->IsWithinDistInMap(pWho, attackRadius) && m_creature->IsWithinLOSInMap(pWho)) + { + if (!m_creature->getVictim()) { - if (pPlayer->GetQuestRewardStatus(QUEST_DISPELLING_ILLUSIONS) && !pPlayer->HasItemCount(ITEM_ARCANE_DISRUPTOR, 1)) - pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_INN_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + AttackStart(pWho); + pWho->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); } - pPlayer->SEND_GOSSIP_MENU(GOSSIP_MENU_INN_1, pCreature->GetGUID()); + else if (m_creature->GetMap()->IsDungeon()) + { + pWho->SetInCombatWith(m_creature); + m_creature->AddThreat(pWho, 0.0f); + } + } + } + } + + void WaypointReached(uint32 uiPointId) + { + switch(uiPointId) + { + case 2: + DoScriptText(SAY_INTRO18, m_creature); + SetRun(true); + break; + case 8: + GetSoldier(); + SetEscortPaused(true); + m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); + m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + m_pInstance->SetData(TYPE_INTRO, DONE); + SetRun(false); + break; + case 9: + DoScriptText(SAY_ENTER01, m_creature); + MoveSoldier = true; + m_uiMoveTimer = 12000; + break; + case 10: + SetEscortPaused(true); + m_pInstance->SetData(TYPE_PHASE, 2); + ResetStep(2000); + if(Unit* Cityman = Unit::GetUnit((*m_creature), m_uiPeople01GUID)) + { + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, Cityman->GetGUID()); + Cityman->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->GetGUID()); + Cityman->GetMotionMaster()->MovePoint(0, 2088.625f,1279.191f,140.743f); + } + break; + case 14: + if(Creature* Human01 = m_creature->SummonCreature(NPC_CITY,2397.308f,1207.565f,134.038f,5.593f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,30000)) + m_uiHuman01GUID = Human01->GetGUID(); + if(Creature* Human02 = m_creature->SummonCreature(NPC_CITY,2400.770f,1207.362f,134.038f,3.454f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,30000)) + m_uiHuman02GUID = Human02->GetGUID(); + if(Creature* Human03 = m_creature->SummonCreature(NPC_CITY,2400.547f,1204.892f,134.038f,2.479f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,30000)) + m_uiHuman03GUID = Human03->GetGUID(); + break; + case 20: + SetEscortPaused(true); + m_creature->setFaction(35); + m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); + m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + SetRun(false); + break; + case 21: + DoScriptText(SAY_PHASE502, m_creature); + break; + case 22: + SetEscortPaused(true); + m_pInstance->SetData(TYPE_PHASE, 6); + ResetStep(1000); + break; + case 25: + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_READY1H); + m_creature->SummonCreature(NPC_TIME_RIFT,2428.901f, 1192.164f, 148.076f, 5.09f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + DoScriptText(SAY_PHASE508, m_creature); + break; + case 26: + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_STAND); + DoScriptText(SAY_PHASE509, m_creature); + break; + case 29: + m_creature->SummonCreature(NPC_TIME_RIFT,2413.773f, 1137.820f, 148.076f, 5.09f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + m_creature->SummonCreature(NPC_TIME_RIFT,2404.990f, 1175.121f, 148.076f, 5.09f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + DoScriptText(SAY_PHASE510, m_creature); + break; + case 30: + DoScriptText(SAY_PHASE513, m_creature); + break; + case 31: + ResetStep(1000); + m_pInstance->SetData(TYPE_PHASE, 7); + break; + case 32: + SetEscortPaused(true); + m_pInstance->SetData(TYPE_PHASE, 8); + m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); + m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + SetRun(false); + break; + case 36: + DoScriptText(SAY_PHASE514, m_creature); + break; + case 37: + if(GameObject* pGate = m_pInstance->instance->GetGameObject(m_pInstance->GetData64(GO_SHKAF_GATE))) + pGate->SetGoState(GO_STATE_ACTIVE); + SetRun(true); + DoScriptText(SAY_PHASE515, m_creature); + break; + case 45: + DoScriptText(SAY_PHASE601, m_creature); + break; + case 48: + DoScriptText(SAY_PHASE602, m_creature); + break; + case 51: + SetEscortPaused(true); + m_pInstance->SetData(TYPE_PHASE, 9); + DoScriptText(SAY_PHASE604, m_creature); + m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); + m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + break; + case 53: + SetEscortPaused(true); + m_creature->StopMoving(); + m_creature->GetMotionMaster()->MovementExpired(false); + m_creature->setFaction(FACTION); + DoScriptText(SAY_PHASE605, m_creature); + if(Creature* Malganis = m_pInstance->instance->GetCreature(m_pInstance->GetData64(NPC_MALGANIS))) + { + m_pInstance->SetData(TYPE_MALGANIS, IN_PROGRESS); + Malganis->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + m_creature->AI()->AttackStart(Malganis); + Malganis->AI()->AttackStart(m_creature); + } + break; + } + } + + void JumpNextStep(uint32 Timer) + { + m_uiStepTimer = Timer; + m_uiStep++; + } + + void GetSoldier() //huck + { + //Marine Close Left + if(Creature* pEscort01 = GetClosestCreatureWithEntry(m_creature, NPC_MARINE, 50.0f)) + { + m_uiMarine01GUID = pEscort01->GetGUID(); + pEscort01->UpdateEntry(NPC_CITYMAN); + if(Creature* pEscort02 = GetClosestCreatureWithEntry(m_creature, NPC_MARINE, 50.0f)) + { + m_uiMarine02GUID = pEscort02->GetGUID(); + pEscort02->UpdateEntry(NPC_CITYMAN); + // Right marine 2 + if(Creature* pEscort03 = GetClosestCreatureWithEntry(m_creature, NPC_MARINE, 50.0f)) + { + m_uiMarine03GUID = pEscort03->GetGUID(); + pEscort03->UpdateEntry(NPC_CITYMAN); + if(Creature* pEscort04 = GetClosestCreatureWithEntry(m_creature, NPC_MARINE, 50.0f)) + { + m_uiMarine04GUID = pEscort04->GetGUID(); + pEscort01->UpdateEntry(NPC_MARINE); + pEscort02->UpdateEntry(NPC_MARINE); + pEscort03->UpdateEntry(NPC_MARINE); + } + } + } + } + + if(Creature* pEscort05 = GetClosestCreatureWithEntry(m_creature, NPC_PRIEST, 50.0f)) + { + m_uiPriest01GUID = pEscort05->GetGUID(); + pEscort05->UpdateEntry(NPC_CITYMAN); + if(Creature* pEscort06 = GetClosestCreatureWithEntry(m_creature, NPC_PRIEST, 50.0f)) + { + m_uiPriest02GUID = pEscort06->GetGUID(); + pEscort05->UpdateEntry(NPC_PRIEST); + } + } + } + + void ResetStep(uint32 Timer) + { + m_uiStep = 0; + m_uiStepTimer = Timer; + } + + void IntroEvent() + { + switch(m_uiStep) + { + case 0: + DoScriptText(SAY_INTRO01, m_creature); + JumpNextStep(2000); + break; + case 1: + m_uiUtherGUID = m_pInstance->GetData64(NPC_UTHER); + m_uiJainaGUID = m_pInstance->GetData64(NPC_JAINA); + if(Creature* pUther = m_pInstance->instance->GetCreature(m_uiUtherGUID)) + DoScriptText(SAY_INTRO02, pUther); + JumpNextStep(8000); + break; + case 2: + m_creature->AddSplineFlag(SPLINEFLAG_WALKMODE); + DoScriptText(SAY_INTRO03, m_creature); + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0); + m_creature->GetMotionMaster()->MovePoint(0, 1908.334f, 1315.354f, 149.551f); + if(Creature* pUther = m_pInstance->instance->GetCreature(m_uiUtherGUID)) + pUther->GetMotionMaster()->MovePoint(0, 1903.600f, 1296.678f, 143.383f); + JumpNextStep(2000); + break; + case 3: + if(Creature* pJaina = m_pInstance->instance->GetCreature(m_uiJainaGUID)) + pJaina->GetMotionMaster()->MovePoint(0, 1899.641f, 1298.684f, 143.831f); + JumpNextStep(7000); + break; + case 4: + m_creature->GetMotionMaster()->MovementExpired(false); + m_creature->GetMotionMaster()->MovePoint(0, 1911.087f, 1314.263f, 150.026f); + JumpNextStep(1000); + break; + case 5: + DoScriptText(SAY_INTRO04, m_creature); + JumpNextStep(10000); + break; + case 6: + if(Creature* pUther = m_pInstance->instance->GetCreature(m_uiUtherGUID)) + DoScriptText(SAY_INTRO05, pUther); + JumpNextStep(1000); + break; + case 7: + if(Creature* pUther = m_pInstance->instance->GetCreature(m_uiUtherGUID)) + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, pUther->GetGUID()); + DoScriptText(SAY_INTRO06, m_creature); + JumpNextStep(4000); + break; + case 8: + if(Creature* pUther = m_pInstance->instance->GetCreature(m_uiUtherGUID)) + DoScriptText(SAY_INTRO07, pUther); + JumpNextStep(6000); + break; + case 9: + DoScriptText(SAY_INTRO08, m_creature); + JumpNextStep(4000); + break; + case 10: + if(Creature* pUther = m_pInstance->instance->GetCreature(m_uiUtherGUID)) + DoScriptText(SAY_INTRO09, pUther); + JumpNextStep(8000); + break; + case 11: + DoScriptText(SAY_INTRO10, m_creature); + JumpNextStep(4000); + break; + case 12: + if(Creature* pUther = m_pInstance->instance->GetCreature(m_uiUtherGUID)) + DoScriptText(SAY_INTRO11, pUther); + JumpNextStep(4000); + break; + case 13: + DoScriptText(SAY_INTRO12, m_creature); + JumpNextStep(11000); + break; + case 14: + if(Creature* pJaina = m_pInstance->instance->GetCreature(m_uiJainaGUID)) + DoScriptText(SAY_INTRO13, pJaina); + JumpNextStep(3000); + break; + case 15: + DoScriptText(SAY_INTRO14, m_creature); + JumpNextStep(9000); + break; + case 16: + if(Creature* pUther = m_pInstance->instance->GetCreature(m_uiUtherGUID)) + DoScriptText(SAY_INTRO15, pUther); + JumpNextStep(5000); + break; + case 17: + if(Creature* pJaina = m_pInstance->instance->GetCreature(m_uiJainaGUID)) + { + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, pJaina->GetGUID()); + pJaina->GetMotionMaster()->MovePoint(0, 1794.357f,1272.183f,140.558f); + } + JumpNextStep(1000); + break; + case 18: + DoScriptText(SAY_INTRO16, m_creature); + JumpNextStep(1000); + break; + case 19: + if(Creature* pJaina = m_pInstance->instance->GetCreature(m_uiJainaGUID)) + DoScriptText(SAY_INTRO17, pJaina); + JumpNextStep(3000); + break; + case 20: + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0); + ((npc_arthasAI*)m_creature->AI())->Start(true, false); + JumpNextStep(3000); + break; + } + } + + void EnterEvent() + { + switch(m_uiStep) + { + case 0: + if(Unit* Cityman = Unit::GetUnit((*m_creature), m_uiPeople01GUID)) + DoScriptText(SAY_ENTER02, Cityman); + JumpNextStep(4000); + break; + case 1: + m_creature->GetMotionMaster()->MovePoint(0, 2087.689f,1280.344f,140.73f); + DoScriptText(SAY_ENTER03, m_creature); + JumpNextStep(3000); + break; + case 2: + if(Unit* Cityman = Unit::GetUnit((*m_creature), m_uiPeople01GUID)) + DoScriptText(SAY_ENTER04, Cityman); + m_creature->HandleEmoteCommand(37); + JumpNextStep(1000); + break; + case 3: + if(Unit* Cityman = Unit::GetUnit((*m_creature), m_uiPeople01GUID)) + m_creature->DealDamage(Cityman, Cityman->GetMaxHealth(),NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + if(Unit* Crazyman = Unit::GetUnit((*m_creature), m_uiPeople02GUID)) + { + DoScriptText(SAY_ENTER05, Crazyman); + Crazyman->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->GetGUID()); + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, Crazyman->GetGUID()); + m_creature->GetMotionMaster()->MovePoint(0, 2092.154f,1276.645f,140.52f); + } + JumpNextStep(3000); + break; + case 4: + m_creature->HandleEmoteCommand(37); + JumpNextStep(1000); + break; + case 5: + if(Unit* Crazyman = Unit::GetUnit((*m_creature), m_uiPeople02GUID)) + Crazyman->DealDamage(Crazyman, Crazyman->GetMaxHealth(),NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + JumpNextStep(1000); + break; + case 6: + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0); + m_creature->GetMotionMaster()->MovePoint(0, 2091.179f,1278.065f,140.476f); + DoScriptText(SAY_ENTER06, m_creature); + JumpNextStep(3000); + break; + case 7: + if(Creature* StalkerM = m_creature->SummonCreature(20562,2117.349f,1288.624f,136.271f,1.37f,TEMPSUMMON_TIMED_DESPAWN,60000)) + StalkerM->CastSpell(StalkerM,63793,false); + JumpNextStep(1000); + break; + case 8: + m_pInstance->SetData(TYPE_ENCOUNTER, IN_PROGRESS); + if(Creature* TempMalganis = m_creature->SummonCreature(NPC_MALGANIS_INTRO,2117.349f,1288.624f,136.271f,1.37f,TEMPSUMMON_TIMED_DESPAWN,29000)) + { + m_uiMalganisGUID = TempMalganis->GetGUID(); + DoScriptText(SAY_ENTER07, TempMalganis); + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, TempMalganis->GetGUID()); + TempMalganis->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->GetGUID()); + TempMalganis->setFaction(35); + } + JumpNextStep(11000); + break; + case 9: + if(Unit* TempMalganis = Unit::GetUnit((*m_creature), m_uiMalganisGUID)) + DoScriptText(SAY_ENTER08, TempMalganis); + JumpNextStep(17000); + break; + case 10: + DoScriptText(SAY_ENTER09, m_creature); + JumpNextStep(7000); + break; + case 11: + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0); + DoScriptText(SAY_ENTER10, m_creature); + JumpNextStep(12000); + break; + case 12: + m_creature->GetMotionMaster()->MovePoint(0, 2084.584f,1278.331f,141.479f); + JumpNextStep(4000); + break; + case 13: + m_creature->GetMotionMaster()->MovementExpired(false); + m_creature->GetMotionMaster()->MovePoint(0, 2087.414f,1279.293f,140.933f); + JumpNextStep(2000); + break; + case 14: + LastX = m_creature->GetPositionX(); + LastY = m_creature->GetPositionY(); + LastZ = m_creature->GetPositionZ(); + if(m_bIsHeroic) + m_pInstance->SetData(TYPE_BONUS, IN_PROGRESS); + m_uiWaveCount = 0; + SetRun(true); + m_pInstance->SetData(TYPE_WING, RIGHT); + m_creature->setFaction(FACTION); + m_uiSummonTimer = 100; + m_pInstance->SetData(TYPE_PHASE, 3); + break; + } + } + + void SummonWing() + { + m_uiWaveCount++; + m_pInstance->DoUpdateWorldState(WORLD_STATE_COS_WAVE_COUNT, m_uiWaveCount); + + switch(m_uiWaveCount) + { + case 1: + m_creature->SummonCreature(NPC_GHOUL,2340.058f, 1253.570f, 132.733f, 5.09f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + m_creature->SummonCreature(NPC_GHOUL,2340.058f, 1253.570f, 132.733f, 5.09f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + break; + case 2: + m_creature->SummonCreature(NPC_GHOUL,2340.058f, 1253.570f, 132.733f, 5.09f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + m_creature->SummonCreature(NPC_GHOUL,2340.058f, 1253.570f, 132.733f, 5.09f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + m_creature->SummonCreature(NPC_NECROMANCER,2340.058f, 1253.570f, 132.733f, 5.09f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + m_creature->SummonCreature(NPC_FIEND,2340.058f, 1253.570f, 132.733f, 5.09f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + break; + case 3: + m_pInstance->SetData(TYPE_WING, LEFT); + m_creature->SummonCreature(NPC_GHOUL,2272.773f, 1331.824f, 124.171f, 3.12f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + m_creature->SummonCreature(NPC_NECROMANCER,2272.773f, 1331.824f, 124.171f, 3.12f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + m_creature->SummonCreature(NPC_NECROMANCER,2272.773f, 1331.824f, 124.171f, 3.12f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + m_creature->SummonCreature(NPC_FIEND,2272.773f, 1331.824f, 124.171f, 3.12f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + break; + case 4: + m_pInstance->SetData(TYPE_WING, RIGHT); + m_creature->SummonCreature(NPC_ACOLYTE,2340.058f, 1253.570f, 132.733f, 5.09f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + m_creature->SummonCreature(NPC_NECROMANCER,2340.058f, 1253.570f, 132.733f, 5.09f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + m_creature->SummonCreature(NPC_ACOLYTE,2340.058f, 1253.570f, 132.733f, 5.09f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + m_creature->SummonCreature(NPC_FIEND,2340.058f, 1253.570f, 132.733f, 5.09f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + break; + case 5: + m_pInstance->SetData(TYPE_PHASE, 4); + if(Creature* pMeathook = m_creature->SummonCreature(NPC_MEATHOOK, 2203.64f, 1334.09f, 129.68f, 2.91f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 29000)) + { + DoScriptText(SAY_MEATHOOK_SPAWN, pMeathook); + pMeathook->RemoveSplineFlag(SPLINEFLAG_WALKMODE); + pMeathook->GetMotionMaster()->MovePoint(0, 2161.47f, 1280.15f, 133.57f); + } + break; + case 6: + m_pInstance->SetData(TYPE_WING, LEFT); + m_creature->SummonCreature(NPC_GHOUL,2272.773f, 1331.824f, 124.171f, 3.12f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + m_creature->SummonCreature(NPC_NECROMANCER,2272.773f, 1331.824f, 124.171f, 3.12f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + m_creature->SummonCreature(NPC_NECROMANCER,2272.773f, 1331.824f, 124.171f, 3.12f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + m_creature->SummonCreature(NPC_FIEND,2272.773f, 1331.824f, 124.171f, 3.12f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + m_creature->SummonCreature(NPC_FIEND,2272.773f, 1331.824f, 124.171f, 3.12f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + break; + case 7: + m_pInstance->SetData(TYPE_WING, RIGHT); + m_creature->SummonCreature(NPC_CONSTRUCT,2340.058f, 1253.570f, 132.733f, 5.09f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + m_creature->SummonCreature(NPC_GHOUL,2340.058f, 1253.570f, 132.733f, 5.09f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + m_creature->SummonCreature(NPC_GHOUL,2340.058f, 1253.570f, 132.733f, 5.09f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + m_creature->SummonCreature(NPC_GHOUL,2340.058f, 1253.570f, 132.733f, 5.09f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + break; + case 8: + m_pInstance->SetData(TYPE_WING, LEFT); + m_creature->SummonCreature(NPC_CONSTRUCT,2272.773f, 1331.824f, 124.171f, 3.12f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + m_creature->SummonCreature(NPC_NECROMANCER,2272.773f, 1331.824f, 124.171f, 3.12f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + m_creature->SummonCreature(NPC_GHOUL,2272.773f, 1331.824f, 124.171f, 3.12f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + m_creature->SummonCreature(NPC_GHOUL,2272.773f, 1331.824f, 124.171f, 3.12f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + m_creature->SummonCreature(NPC_NECROMANCER,2272.773f, 1331.824f, 124.171f, 3.12f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + break; + case 9: + m_pInstance->SetData(TYPE_WING, RIGHT); + m_creature->SummonCreature(NPC_CONSTRUCT,2340.058f, 1253.570f, 132.733f, 5.09f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + m_creature->SummonCreature(NPC_FIEND,2340.058f, 1253.570f, 132.733f, 5.09f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + m_creature->SummonCreature(NPC_NECROMANCER,2340.058f, 1253.570f, 132.733f, 5.09f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + m_creature->SummonCreature(NPC_NECROMANCER,2340.058f, 1253.570f, 132.733f, 5.09f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + m_creature->SummonCreature(NPC_GHOUL,2340.058f, 1253.570f, 132.733f, 5.09f,TEMPSUMMON_CORPSE_TIMED_DESPAWN,29000); + break; + case 10: + m_pInstance->SetData(TYPE_PHASE, 4); + if(Creature* pSalramm = m_creature->SummonCreature(NPC_SALRAMM, 2203.64f, 1334.09f, 129.68f, 2.91f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 29000)) + { + DoScriptText(SAY_SALRAMM_SPAWN, pSalramm); + pSalramm->RemoveSplineFlag(SPLINEFLAG_WALKMODE); + pSalramm->GetMotionMaster()->MovePoint(0, 2161.47f, 1280.15f, 133.57f); + } + break; + } + } + + void HouseEvent() + { + switch(m_uiStep) + { + case 0: + if(Creature* Human = m_pInstance->instance->GetCreature(m_uiHuman01GUID)) + { + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, Human->GetGUID()); + Human->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->GetGUID()); + DoScriptText(SAY_PHASE503, Human); + } + JumpNextStep(4000); + break; + case 1: + DoScriptText(SAY_PHASE504, m_creature); + m_creature->GetMotionMaster()->MovePoint(0, 2396.035f, 1206.942f, 134.038f); + JumpNextStep(3000); + break; + case 2: + m_creature->HandleEmoteCommand(37); + JumpNextStep(2000); + break; + case 3: + DoScriptText(SAY_PHASE505, m_creature); + JumpNextStep(2000); + break; + case 4: + if(Creature* Human = m_pInstance->instance->GetCreature(m_uiHuman01GUID)) + DoScriptText(SAY_PHASE506, Human); + JumpNextStep(6000); + break; + case 5: + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0); + if(Creature* Human = m_pInstance->instance->GetCreature(m_uiHuman01GUID)) + { + Human->SetUInt64Value(UNIT_FIELD_TARGET, 0); + Human->UpdateEntry(NPC_INFINITE_ADVERSARY); + } + if(Creature* Human2 = m_pInstance->instance->GetCreature(m_uiHuman02GUID)) + Human2->UpdateEntry(NPC_INFINITE_HUNTER); + if(Creature* Human3 = m_pInstance->instance->GetCreature(m_uiHuman03GUID)) + Human3->UpdateEntry(NPC_INFINITE_AGENT); + JumpNextStep(1000); + break; + case 6: + SetRun(true); + m_creature->GetMotionMaster()->MovePoint(0, 2384.320f, 1202.779f, 134.040f); + DoScriptText(SAY_PHASE507, m_creature); + JumpNextStep(5000); + break; + case 7: + SetEscortPaused(false); + m_creature->setFaction(FACTION); + m_pInstance->SetData(TYPE_PHASE, 5); + JumpNextStep(1000); + break; + } + } + + void EpochEvent() + { + switch(m_uiStep) + { + case 0: + m_creature->SummonCreature(NPC_TIME_RIFT_2,2445.629f,1111.500f,148.076f,3.229f,TEMPSUMMON_TIMED_DESPAWN,9000); + JumpNextStep(2000); + break; + case 1: + pEpoch = m_creature->SummonCreature(NPC_EPOCH,2445.629f,1111.500f,148.076f,3.229f,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,900000); + if(pEpoch) + { + pEpoch->setFaction(35); + DoScriptText(SAY_EPOCH_INTRO, pEpoch); + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, pEpoch->GetGUID()); + } + JumpNextStep(20000); + break; + case 2: + DoScriptText(SAY_ARTHAS_INTRO, m_creature); + JumpNextStep(6000); + break; + case 3: + if(pEpoch) + { + DoScriptText(SAY_EPOCH_AGGRO, pEpoch); + m_creature->AI()->AttackStart(pEpoch); + pEpoch->AI()->AttackStart(m_creature); + pEpoch->setFaction(14); + } + m_pInstance->SetData(TYPE_PHASE, 5); + SetRun(false); + JumpNextStep(6000); + break; + } + } + + void MalganisEvent() + { + Map::PlayerList const &PlayerList = m_pInstance->instance->GetPlayers(); + bool bNeedSpawn = false; + + switch(m_uiStep) + { + case 0: + m_creature->setFaction(35); + m_creature->GetMotionMaster()->MovePoint(0, 2302.326f, 1491.386f, 128.362f); + if(Creature* Malganis = m_pInstance->instance->GetCreature(m_pInstance->GetData64(NPC_MALGANIS))) + { + DoScriptText(SAY_MALGANIS_ESCAPE01, Malganis); + Malganis->InterruptNonMeleeSpells(false); + Malganis->GetMotionMaster()->MovePoint(0, 2296.665f,1502.362f,128.362f); + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, Malganis->GetGUID()); + Malganis->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->GetGUID()); + } + JumpNextStep(10000); break; - case NPC_CHROMIE_ENTRANCE: - if (m_pInstance->GetData(TYPE_GRAIN_EVENT) == DONE && m_pInstance->GetData(TYPE_ARTHAS_INTRO_EVENT) == NOT_STARTED && pPlayer->GetQuestRewardStatus(QUEST_A_ROYAL_ESCORT)) - pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_ENTRANCE_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - pPlayer->SEND_GOSSIP_MENU(GOSSIP_MENU_ENTRANCE_1, pCreature->GetGUID()); + case 1: + if(Creature* Malganis = m_pInstance->instance->GetCreature(m_pInstance->GetData64(NPC_MALGANIS))) + DoScriptText(SAY_MALGANIS_ESCAPE02, Malganis); + JumpNextStep(10000); break; - } + case 2: + DoScriptText(SAY_ARTHAS_OUTRO01, m_creature); + JumpNextStep(5000); + break; + case 3: + if(Creature* Malganis = m_pInstance->instance->GetCreature(m_pInstance->GetData64(NPC_MALGANIS))) + DoScriptText(SAY_MALGANIS_OUTRO, Malganis); + JumpNextStep(20000); + break; + case 4: + if(Creature* Malganis = m_pInstance->instance->GetCreature(m_pInstance->GetData64(NPC_MALGANIS))) + { + Malganis->SetVisibility(VISIBILITY_OFF); + m_creature->GetMotionMaster()->MovePoint(0, Malganis->GetPositionX(), Malganis->GetPositionY(), Malganis->GetPositionZ()); + } + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0); + m_creature->RemoveSplineFlag(SPLINEFLAG_WALKMODE); + JumpNextStep(3000); + break; + case 5: + DoScriptText(SAY_ARTHAS_OUTRO02, m_creature); + JumpNextStep(6000); + break; + case 6: + m_creature->GetMotionMaster()->MovePoint(0, 2298.298f,1500.362f,128.362f); + DoScriptText(SAY_ARTHAS_OUTRO03, m_creature); + JumpNextStep(11000); + break; + case 7: + m_creature->GetMotionMaster()->MovePoint(0, 2243.311f, 1476.025f, 132.352f); + + if (!PlayerList.isEmpty()) + for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) + if (i->getSource()->GetQuestStatus(QUEST_A_ROYAL_ESCORT) == QUEST_STATUS_INCOMPLETE || + i->getSource()->GetQuestStatus(QUEST_A_ROYAL_ESCORT) == QUEST_STATUS_COMPLETE) + { + bNeedSpawn = true; + break; + } + + if (bNeedSpawn) + m_creature->SummonCreature(30997, 2311.61f, 1497.85f, 128.01f, 4.14f, TEMPSUMMON_TIMED_DESPAWN, 1800000); + JumpNextStep(11000); + break; + case 8: + m_pInstance->SetData(TYPE_PHASE, 12); + m_creature->SetVisibility(VISIBILITY_OFF); + break; + } } - return true; -} -bool GossipSelect_npc_chromie(Player* pPlayer, Creature* pCreature, uint32 sender, uint32 uiAction) -{ - switch (pCreature->GetEntry()) + void UpdateAI(const uint32 uiDiff) { - case NPC_CHROMIE_INN: - switch (uiAction) + npc_escortAI::UpdateAI(uiDiff); + + if(!m_pInstance) return; + + if(StartEvent == true) + { + if(m_pInstance->GetData(TYPE_INTRO) != DONE) + { + if(m_uiStepTimer < uiDiff) { - case GOSSIP_ACTION_INFO_DEF+1: - pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_INN_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - pPlayer->SEND_GOSSIP_MENU(GOSSIP_MENU_INN_2, pCreature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_INN_3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - pPlayer->SEND_GOSSIP_MENU(GOSSIP_MENU_INN_3, pCreature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - pPlayer->SEND_GOSSIP_MENU(GOSSIP_MENU_INN_4, pCreature->GetGUID()); - if (!pPlayer->HasItemCount(ITEM_ARCANE_DISRUPTOR, 1)) - { - if (Item* pItem = pPlayer->StoreNewItemInInventorySlot(ITEM_ARCANE_DISRUPTOR, 1)) - { - pPlayer->SendNewItem(pItem, 1, true, false); - if (instance_culling_of_stratholme* m_pInstance = (instance_culling_of_stratholme*)pCreature->GetInstanceData()) - if (m_pInstance->GetData(TYPE_GRAIN_EVENT) == NOT_STARTED) - m_pInstance->SetData(TYPE_GRAIN_EVENT, SPECIAL); - } - } - break; + IntroEvent(); } - break; - case NPC_CHROMIE_ENTRANCE: - switch (uiAction) + else m_uiStepTimer -= uiDiff; + } + + if(m_pInstance->GetData(TYPE_PHASE) == 2) + { + if(m_uiStepTimer < uiDiff) { - case GOSSIP_ACTION_INFO_DEF+1: - pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_ENTRANCE_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - pPlayer->SEND_GOSSIP_MENU(GOSSIP_MENU_ENTRANCE_2, pCreature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_ENTRANCE_3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - pPlayer->SEND_GOSSIP_MENU(GOSSIP_MENU_ENTRANCE_3, pCreature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - pPlayer->SEND_GOSSIP_MENU(GOSSIP_MENU_ENTRANCE_4, pCreature->GetGUID()); - if (instance_culling_of_stratholme* m_pInstance = (instance_culling_of_stratholme*)pCreature->GetInstanceData()) - if (m_pInstance->GetData(TYPE_ARTHAS_INTRO_EVENT) == NOT_STARTED) - m_pInstance->DoSpawnArthasIfNeeded(); - break; + EnterEvent(); } - break; + else m_uiStepTimer -= uiDiff; + } + + if(MoveSoldier == true) + { + if(m_uiMoveTimer < uiDiff) + { + MoveSoldiers(); + MoveSoldier = false; + } + else m_uiMoveTimer -= uiDiff; + } + + if(m_pInstance->GetData(TYPE_PHASE) == 3) + { + if(m_uiSummonTimer < uiDiff) + { + SummonWing(); + m_uiSummonTimer = 70000; + } + else m_uiSummonTimer -= uiDiff; + } + + if(m_pInstance->GetData(TYPE_PHASE) == 4 && m_pInstance->GetData(TYPE_ENCOUNTER) == DONE) + { + m_pInstance->SetData(TYPE_PHASE, 5); + SetRun(true); + EnableEscort(); + DoScriptText(SAY_PHASE501, m_creature); + } + + if(m_pInstance->GetData(TYPE_PHASE) == 6) + { + if(m_uiStepTimer < uiDiff) + { + HouseEvent(); + } + else m_uiStepTimer -= uiDiff; + } + + if(m_pInstance->GetData(TYPE_PHASE) == 7) + { + if(m_uiStepTimer < uiDiff) + { + EpochEvent(); + } + else m_uiStepTimer -= uiDiff; + } + + } //close event! + + if(m_pInstance->GetData(TYPE_PHASE) == 10) + { + SetEscortPaused(true); + ResetStep(1000); + m_creature->AttackStop(); + m_pInstance->SetData(TYPE_PHASE, 11); + } + + if(m_pInstance->GetData(TYPE_PHASE) == 11) + { + if(m_uiStepTimer < uiDiff) + { + MalganisEvent(); + } + else m_uiStepTimer -= uiDiff; + } + + //} //close event! + + if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) + return; + + if(m_pInstance->GetData(TYPE_PHASE) > 9) return; + + if (m_uiExorcismTimer < uiDiff) + { + if (Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0)) + DoCast(target, m_bIsHeroic ? SPELL_EXORCISM_H : SPELL_EXORCISM_N); + + m_uiExorcismTimer = 7300; + }else m_uiExorcismTimer -= uiDiff; + + if (m_uiHealTimer < uiDiff) + { + if(m_creature->GetHealthPercent() < 40.0f) + { + DoCast(m_creature, SPELL_HOLY_LIGHT); + m_uiHealTimer = 20000; + } + } else m_uiHealTimer -= uiDiff; + + return; } - return true; +}; + +/*### +## npc_uther +###*/ + +struct MANGOS_DLL_DECL npc_utherAI : public npc_escortAI +{ + npc_utherAI(Creature* pCreature) : npc_escortAI(pCreature) + { + m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); + Reset(); + } + + ScriptedInstance* m_pInstance; + + uint64 m_uiArthasGUID; + uint32 m_uiStep; + uint32 m_uiStepTimer; + bool StartEvent; + + uint64 m_uiKnightGUID01; + uint64 m_uiKnightGUID02; + uint64 m_uiKnightGUID03; + + void Reset() + { + m_creature->SetVisibility(VISIBILITY_OFF); + m_uiStep = 0; + m_uiStepTimer = 100; + } + + void StartAI() + { + //m_pInstance->SetWeather(WEATHER_STATE_MEDIUM_RAIN, 0.9999f); + StartEvent = true; + m_creature->SetVisibility(VISIBILITY_ON); + ((npc_utherAI*)m_creature->AI())->Start(false, true); + + if(Creature* Knight01 = m_creature->SummonCreature(NPC_KNIGHT,m_creature->GetPositionX(),m_creature->GetPositionY(),m_creature->GetPositionZ(),m_creature->GetOrientation(),TEMPSUMMON_TIMED_DESPAWN,110000)) + { + m_uiKnightGUID01 = Knight01->GetGUID(); + Knight01->RemoveSplineFlag(SPLINEFLAG_WALKMODE); + Knight01->GetMotionMaster()->MoveFollow(m_creature,PET_FOLLOW_DIST,M_PI_F/2); + } + + if(Creature* Knight02 = m_creature->SummonCreature(NPC_KNIGHT,m_creature->GetPositionX(),m_creature->GetPositionY(),m_creature->GetPositionZ(),m_creature->GetOrientation(),TEMPSUMMON_TIMED_DESPAWN,110000)) + { + m_uiKnightGUID02 = Knight02->GetGUID(); + Knight02->RemoveSplineFlag(SPLINEFLAG_WALKMODE); + Knight02->GetMotionMaster()->MoveFollow(m_creature,PET_FOLLOW_DIST,M_PI_F/4); + } + + if(Creature* Knight03 = m_creature->SummonCreature(NPC_KNIGHT,m_creature->GetPositionX(),m_creature->GetPositionY(),m_creature->GetPositionZ(),m_creature->GetOrientation(),TEMPSUMMON_TIMED_DESPAWN,110000)) + { + m_uiKnightGUID03 = Knight03->GetGUID(); + Knight03->RemoveSplineFlag(SPLINEFLAG_WALKMODE); + Knight03->GetMotionMaster()->MoveFollow(m_creature,PET_FOLLOW_DIST,M_PI_F/3); + } + } + + void WaypointReached(uint32 uiPointId) + { + switch(uiPointId) + { + case 3: + m_uiArthasGUID = m_pInstance->GetData64(NPC_ARTHAS); + if(Creature* pArthas = m_pInstance->instance->GetCreature(m_uiArthasGUID)) + { + pArthas->RemoveSplineFlag(SPLINEFLAG_WALKMODE); + pArthas->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->GetGUID()); + pArthas->GetMotionMaster()->MovePoint(0, 1902.974f, 1291.635f, 143.337f); + } + break; + case 4: + SetRun(false); + if(Creature *pArthas = m_pInstance->instance->GetCreature(m_pInstance->GetData64(NPC_ARTHAS))) + ((npc_arthasAI*)pArthas->AI())->StartAI(); + break; + case 6: + m_creature->SetVisibility(VISIBILITY_OFF); + uint64 m_uiJainaGUID = m_pInstance->GetData64(NPC_JAINA); + if(Creature* pJaina = m_pInstance->instance->GetCreature(m_uiJainaGUID)) + pJaina->SetVisibility(VISIBILITY_OFF); + break; + } + } + + void UpdateAI(const uint32 uiDiff) + { + npc_escortAI::UpdateAI(uiDiff); + + if(!m_pInstance) return; + + return; + } +}; + +/*### +## npc_chromi_middle +###*/ + +#define GOSSIP_ITEM_CHROMI1 "What do you think they're up to?" +#define GOSSIP_ITEM_CHROMI2 "What want me to do what?" +#define GOSSIP_ITEM_CHROMI3 "Very well, Chromie." + +enum +{ + GOSSIP_TEXTID_CHROMI1 = 12953, + GOSSIP_TEXTID_CHROMI2 = 12949, + GOSSIP_TEXTID_CHROMI3 = 12950, + GOSSIP_TEXTID_CHROMI4 = 12952 +}; + +bool GossipHello_npc_chromi_middle(Player* pPlayer, Creature* pCreature) +{ + if (pCreature->isQuestGiver()) + pPlayer->PrepareQuestMenu(pCreature->GetGUID()); + + ScriptedInstance* pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); + if (pPlayer && pPlayer->GetQuestStatus(QUEST_A_ROYAL_ESCORT) == QUEST_STATUS_COMPLETE && pInstance && pInstance->GetData(TYPE_INTRO) == NOT_STARTED) + pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_CHROMI1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + pPlayer->SEND_GOSSIP_MENU(GOSSIP_TEXTID_CHROMI1, pCreature->GetGUID()); + + return true; } -bool QuestAccept_npc_chromie(Player* pPlayer, Creature* pCreature, const Quest* pQuest) +bool GossipSelect_npc_chromi_middle(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction) { - switch (pQuest->GetQuestId()) + if(ScriptedInstance* m_pInstance = ((ScriptedInstance*)pCreature->GetInstanceData())) + if(m_pInstance->GetData(TYPE_INTRO) != NOT_STARTED) return true; + + if (uiAction == GOSSIP_ACTION_INFO_DEF+1) + { + pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_CHROMI2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + + pPlayer->SEND_GOSSIP_MENU(GOSSIP_TEXTID_CHROMI2, pCreature->GetGUID()); + } + + if (uiAction == GOSSIP_ACTION_INFO_DEF+2) + { + pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_CHROMI3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); + + pPlayer->SEND_GOSSIP_MENU(GOSSIP_TEXTID_CHROMI3, pCreature->GetGUID()); + } + + if (uiAction == GOSSIP_ACTION_INFO_DEF+3) + { + if (ScriptedInstance* m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData()) + { + m_pInstance->DoUpdateWorldState(WORLD_STATE_COS_CRATE_ON, 0); + m_pInstance->SetData(TYPE_INTRO, IN_PROGRESS); + if (Creature *pUther = m_pInstance->instance->GetCreature(m_pInstance->GetData64(NPC_UTHER))) + ((npc_utherAI*)pUther->AI())->StartAI(); + } + + pPlayer->SEND_GOSSIP_MENU(GOSSIP_TEXTID_CHROMI4, pCreature->GetGUID()); + } + + return true; +} + +struct MANGOS_DLL_DECL npc_chromi_middleAI : public ScriptedAI +{ + npc_chromi_middleAI(Creature* pCreature) : ScriptedAI(pCreature) { - case QUEST_DISPELLING_ILLUSIONS: - if (instance_culling_of_stratholme* m_pInstance = (instance_culling_of_stratholme*)pCreature->GetInstanceData()) - if (m_pInstance->GetData(TYPE_GRAIN_EVENT) == NOT_STARTED) - m_pInstance->SetData(TYPE_GRAIN_EVENT, SPECIAL); - break; - case QUEST_A_ROYAL_ESCORT: - if (instance_culling_of_stratholme* m_pInstance = (instance_culling_of_stratholme*)pCreature->GetInstanceData()) - if (m_pInstance->GetData(TYPE_ARTHAS_INTRO_EVENT) == NOT_STARTED) - m_pInstance->DoSpawnArthasIfNeeded(); - break; + m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); + m_bUtherHere = false; + Reset(); } - return true; + + ScriptedInstance* m_pInstance; + + bool m_bUtherHere; + + void Reset() + { + m_bUtherHere = false; + } + + void MoveInLineOfSight(Unit* pWho) + { + if (!m_bUtherHere && m_pInstance && pWho && pWho->GetTypeId() == TYPEID_PLAYER && m_creature->GetDistance2d(pWho) <= 15 && ((Player*)pWho)->GetQuestStatus(QUEST_A_ROYAL_ESCORT) == QUEST_STATUS_INCOMPLETE) + { + m_pInstance->DoUpdateWorldState(WORLD_STATE_COS_CRATE_ON, 0); + m_pInstance->SetData(TYPE_INTRO, IN_PROGRESS); + if (Creature *pUther = m_pInstance->instance->GetCreature(m_pInstance->GetData64(NPC_UTHER))) + ((npc_utherAI*)pUther->AI())->StartAI(); + m_bUtherHere = true; + } + } +}; + +/*### +## npc_arthas_dialog +###*/ + +enum +{ + GOSSIP_MENU_ARTHAS_1 = 100001, + GOSSIP_MENU_ARTHAS_2 = 100002, + GOSSIP_MENU_ARTHAS_3 = 100003, + GOSSIP_MENU_ARTHAS_4 = 100004, + GOSSIP_MENU_ARTHAS_5 = 100005 +}; + +#define GOSSIP_ITEM_ARTHAS_0 "I'm ready to start Culling of Stratholme." +#define GOSSIP_ITEM_ARTHAS_1 "Yes, my Prince. We're ready." +#define GOSSIP_ITEM_ARTHAS_2 "We're only doing what is best for Loarderon your Highness." +#define GOSSIP_ITEM_ARTHAS_3 "I'm ready." +#define GOSSIP_ITEM_ARTHAS_4 "For Lordaeron!" +#define GOSSIP_ITEM_ARTHAS_5 "I'm ready to battle the dreadlord, sire." + +bool GossipHello_npc_arthas(Player* pPlayer, Creature* pCreature) +{ + ScriptedInstance* pInstance = ((ScriptedInstance*)pCreature->GetInstanceData()); + + if(pInstance && pInstance->GetData(TYPE_PHASE) == 0) + { + pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_ARTHAS_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + pPlayer->SEND_GOSSIP_MENU(GOSSIP_MENU_ARTHAS_1, pCreature->GetGUID()); + } + + if(pInstance && pInstance->GetData(TYPE_PHASE) == 5) + { + pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_ARTHAS_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + pPlayer->SEND_GOSSIP_MENU(GOSSIP_MENU_ARTHAS_2, pCreature->GetGUID()); + } + + if(pInstance && pInstance->GetData(TYPE_PHASE) == 8) + { + pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_ARTHAS_3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + pPlayer->SEND_GOSSIP_MENU(GOSSIP_MENU_ARTHAS_3, pCreature->GetGUID()); + } + + if(pInstance && pInstance->GetData(TYPE_PHASE) == 9) + { + pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_ARTHAS_4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + pPlayer->SEND_GOSSIP_MENU(GOSSIP_MENU_ARTHAS_4, pCreature->GetGUID()); + } + + return true; } -/* ************* -** npc_crates_bunny (spell aura effect dummy) -************* */ +bool GossipSelect_npc_arthas(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction) +{ + ScriptedInstance* m_pInstance = ((ScriptedInstance*)pCreature->GetInstanceData()); + if(m_pInstance && m_pInstance->GetData(TYPE_PHASE) == 0) + { + m_pInstance->SetData(TYPE_PHASE, 1); + ((npc_arthasAI*)pCreature->AI())->EnableEscort(); + ((npc_arthasAI*)pCreature->AI())->RemoveGossip(); + ((npc_arthasAI*)pCreature->AI())->culling_faction = pPlayer->getFaction(); + } + + if(m_pInstance && m_pInstance->GetData(TYPE_PHASE) == 5) + { + ((npc_arthasAI*)pCreature->AI())->EnableEscort(); + ((npc_arthasAI*)pCreature->AI())->RemoveGossip(); + } + + if(m_pInstance && m_pInstance->GetData(TYPE_PHASE) == 8) + { + ((npc_arthasAI*)pCreature->AI())->EnableEscort(); + ((npc_arthasAI*)pCreature->AI())->RemoveGossip(); + } + + if(m_pInstance && m_pInstance->GetData(TYPE_PHASE) == 9) + { + ((npc_arthasAI*)pCreature->AI())->EnableEscort(); + ((npc_arthasAI*)pCreature->AI())->RemoveGossip(); + if(Creature* pMalganis = pCreature->SummonCreature(NPC_MALGANIS,2296.665f,1502.362f,128.362f,4.961f,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,900000)) + { + m_pInstance->SetData64(NPC_MALGANIS, pMalganis->GetGUID()); + pMalganis->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + } + } + + return true; +} + +/*### +## npc_arthas_priest +###*/ + enum { - SPELL_ARCANE_DISRUPTION = 49590 + SPELL_SMITE = 61923, + SPELL_HEAL = 62442 }; -bool EffectAuraDummy_spell_aura_dummy_npc_crates_dummy(const Aura* pAura, bool bApply) +struct MANGOS_DLL_DECL npc_arthas_priestAI : public ScriptedAI { - if (pAura->GetId() == SPELL_ARCANE_DISRUPTION && pAura->GetEffIndex() == EFFECT_INDEX_0 && bApply) + npc_arthas_priestAI(Creature *c) : ScriptedAI(c) + { + SetCombatMovement(false); + Reset(); + } + + uint32 m_uiSmiteTimer; + uint32 m_uiHealTimer; + + void Reset() + { + m_uiSmiteTimer = 100; + m_uiHealTimer = 1000; + } + + void AttackStart(Unit* pWho) + { + if (!pWho) + return; + + if (m_creature->Attack(pWho, true)) + { + m_creature->AddThreat(pWho); + m_creature->SetInCombatWith(pWho); + pWho->SetInCombatWith(m_creature); + } + } + + void EnterEvadeMode() + { + m_creature->RemoveAllAuras(); + m_creature->DeleteThreatList(); + m_creature->CombatStop(true); + m_creature->LoadCreaturesAddon(); + + m_creature->SetLootRecipient(NULL); + + Reset(); + } + + void MoveInLineOfSight(Unit* pWho) { - if (Creature* pTarget = (Creature*)pAura->GetTarget()) + if (!pWho) + return; + + if (!m_creature->hasUnitState(UNIT_STAT_STUNNED) && pWho->isTargetableForAttack() && + m_creature->IsHostileTo(pWho) && pWho->isInAccessablePlaceFor(m_creature)) { - std::list lCrateBunnyList; - if (instance_culling_of_stratholme* pInstance = (instance_culling_of_stratholme*)pTarget->GetInstanceData()) + if (!m_creature->canFly() && m_creature->GetDistanceZ(pWho) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(pWho); + if (m_creature->IsWithinDistInMap(pWho, attackRadius) && m_creature->IsWithinLOSInMap(pWho)) { - pInstance->GetCratesBunnyOrderedList(lCrateBunnyList); - uint8 i = 0; - for (std::list::const_iterator itr = lCrateBunnyList.begin(); itr != lCrateBunnyList.end(); ++itr) + if (!m_creature->getVictim()) { - i++; - if (*itr == pTarget) - break; + AttackStart(pWho); + pWho->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); } + else if (m_creature->GetMap()->IsDungeon()) + { + pWho->SetInCombatWith(m_creature); + m_creature->AddThreat(pWho, 0.0f); + } + } + } + } - switch (i) + void UpdateAI(const uint32 uiDiff) + { + + if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) + return; + + if(m_uiSmiteTimer < uiDiff) + { + DoCast(m_creature->getVictim(), SPELL_SMITE); + m_uiSmiteTimer = 3000; + } + else m_uiSmiteTimer -= uiDiff; + + if(m_uiHealTimer < uiDiff) + { + if(m_creature->GetHealthPercent() <= 40.0f) + { + m_creature->InterruptNonMeleeSpells(false); + DoCast(m_creature, SPELL_HEAL); + m_uiHealTimer = 3000; + } + } + else m_uiHealTimer -= uiDiff; + + DoMeleeAttackIfReady(); + + return; + } +}; + +/*### +## npc_arthas_marine +###*/ + +struct MANGOS_DLL_DECL npc_arthas_marineAI : public ScriptedAI +{ + npc_arthas_marineAI(Creature *c) : ScriptedAI(c) + { + Reset(); + } + + float LastX; + float LastY; + float LastZ; + + uint32 m_uiHealTimer; + + void Reset() + { + m_uiHealTimer = 3000; + } + + void Aggro(Unit* who) + { + LastX = m_creature->GetPositionX(); + LastY = m_creature->GetPositionY(); + LastZ = m_creature->GetPositionZ(); + } + + void AttackStart(Unit* pWho) + { + if (!pWho) + return; + + if (m_creature->Attack(pWho, true)) + { + m_creature->AddThreat(pWho); + m_creature->SetInCombatWith(pWho); + pWho->SetInCombatWith(m_creature); + + if (IsCombatMovement()) + m_creature->GetMotionMaster()->MoveChase(pWho); + } + } + + void EnterEvadeMode() + { + m_creature->RemoveAllAuras(); + m_creature->DeleteThreatList(); + m_creature->CombatStop(true); + m_creature->LoadCreaturesAddon(); + + m_creature->SetLootRecipient(NULL); + m_creature->GetMotionMaster()->MovePoint(POINT_LAST_POINT, LastX, LastY, LastZ); + + Reset(); + } + + void MoveInLineOfSight(Unit* pWho) + { + if (!pWho) + return; + + if (!m_creature->hasUnitState(UNIT_STAT_STUNNED) && pWho->isTargetableForAttack() && + m_creature->IsHostileTo(pWho) && pWho->isInAccessablePlaceFor(m_creature)) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(pWho) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(pWho); + if (m_creature->IsWithinDistInMap(pWho, attackRadius) && m_creature->IsWithinLOSInMap(pWho)) + { + if (!m_creature->getVictim()) { - case 1: - // Start NPC_ROGER_OWENS Event - break; - case 2: - // Start NPC_SERGEANT_MORIGAN Event - break; - case 3: - // Start NPC_JENA_ANDERSON Event - break; - case 4: - // Start NPC_MALCOM_MOORE Event - break; - case 5: - // Start NPC_BARTLEBY_BATTSON Event - break; + AttackStart(pWho); + pWho->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); } - - if (pInstance->GetData(TYPE_GRAIN_EVENT) != DONE) - pInstance->SetData(TYPE_GRAIN_EVENT, IN_PROGRESS); - // pTarget->ForcedDespawn(); // direct despawn has influence on visual effects, - // but despawning makes it impossible to multi-use the spell at the same place - // perhaps some add. GO-Visual + else if (m_creature->GetMap()->IsDungeon()) + { + pWho->SetInCombatWith(m_creature); + m_creature->AddThreat(pWho, 0.0f); + } } } } - return true; + + void UpdateAI(const uint32 uiDiff) + { + + if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) + return; + + if(m_uiHealTimer < uiDiff) + { + if(m_creature->GetHealthPercent() <= 40.0f) + { + if(Creature* pHeal = GetClosestCreatureWithEntry(m_creature, NPC_PRIEST, 50.0f)) + { + if(pHeal->GetHealthPercent() > 40.0f) + { + pHeal->InterruptNonMeleeSpells(false); + pHeal->CastSpell(m_creature, SPELL_HEAL, false); + m_uiHealTimer = 3000; + } + } + } + } + else m_uiHealTimer -= uiDiff; + + DoMeleeAttackIfReady(); + + return; + } +}; + +/*### +## npc_dark_conversion +###*/ + +/*enum +{ + SAY_PEOPLE01 = -1594099, + SAY_PEOPLE02 = -1594100, + SAY_PEOPLE03 = -1594101, + SAY_PEOPLE04 = -1594102, + SAY_PEOPLE05 = -1594103, +};*/ + +struct MANGOS_DLL_DECL npc_dark_conversionAI : public ScriptedAI +{ + npc_dark_conversionAI(Creature *pCreature) : ScriptedAI(pCreature) + { + m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); + + m_creature->SetActiveObjectState(true); + + if (m_pInstance && m_pInstance->GetData(TYPE_ENCOUNTER) == IN_PROGRESS) + m_creature->UpdateEntry(NPC_ZOMBIE); + + Reset(); + } + + ScriptedInstance* m_pInstance; + + bool Special; + bool Conversion; + uint32 m_uiStep; + uint32 m_uiStepTimer; + + void Reset() + { + m_creature->setFaction(35); + Conversion = false; + Special = false; + m_uiStep = 1; + m_uiStepTimer = 5000; + + if (m_pInstance && m_pInstance->GetData(TYPE_ENCOUNTER) == IN_PROGRESS) + m_creature->UpdateEntry(NPC_ZOMBIE); + } + + void MalganisScared(Creature* target, float horizontalSpeed, float verticalSpeed) + { + float angle = target->GetAngle(m_creature); + float vsin = sin(angle); + float vcos = cos(angle); + + float ox, oy, oz; + m_creature->GetPosition(ox, oy, oz); + + float g = 19.23f;// seems that physic constant g(earth's gravity) in world of warcraft is about 2 times larger than real + float dh = verticalSpeed*verticalSpeed / (2*g); // maximum parabola height + float time = sqrtf(dh/(0.124976 * verticalSpeed)); //full move time in seconds // should be time = 2*Vert_speed/g, but.. + + float dis = time * horizontalSpeed; + float fx = ox + dis * vcos; + float fy = oy + dis * vsin; + float fz = oz; + + m_creature->UpdateGroundPositionZ(fx, fy, fz); + + m_creature->RemoveSplineFlag(SPLINEFLAG_WALKMODE); + m_creature->GetMotionMaster()->MovePoint(0, fx, fy, fz); + } + + void DarkConversion(bool Move) + { + m_creature->UpdateEntry(NPC_ZOMBIE); + if(Move == true) + { + uint64 m_uiArthasGUID = m_pInstance->GetData64(NPC_ARTHAS); + if(Creature* pArthas = m_pInstance->instance->GetCreature(m_uiArthasGUID)) + m_creature->GetMotionMaster()->MovePoint(0, pArthas->GetPositionX(), pArthas->GetPositionY(), pArthas->GetPositionZ()); + } + } + + void UpdateAI(const uint32 uiDiff) + { + if(!m_pInstance) return; + + if(m_pInstance->GetData(TYPE_ENCOUNTER) == IN_PROGRESS) + { + if(Creature* pMalganis = GetClosestCreatureWithEntry(m_creature, NPC_MALGANIS_INTRO, 20.0f)) + { + if(Special == false) + { + float Dist = m_creature->GetDistance2d(pMalganis->GetPositionX(), pMalganis->GetPositionY()); + Dist = Dist + 2.0f; + MalganisScared(pMalganis, Dist, 1.0f); + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_COWER); + m_uiStepTimer = 5000; + Special = true; + } + } + + if(m_uiStepTimer < uiDiff && Conversion != true) + { + Conversion = true; + if(Special != false) + DarkConversion(true); + else + DarkConversion(false); + } + else m_uiStepTimer -= uiDiff; + + } + + DoMeleeAttackIfReady(); + + return; + } +}; + +CreatureAI* GetAI_npc_chromi_middle(Creature* pCreature) +{ + return new npc_chromi_middleAI(pCreature); } +CreatureAI* GetAI_npc_uther(Creature* pCreature) +{ + return new npc_utherAI(pCreature); +} + +CreatureAI* GetAI_npc_arthas(Creature* pCreature) +{ + return new npc_arthasAI(pCreature); +} + +CreatureAI* GetAI_npc_arthas_priest(Creature* pCreature) +{ + return new npc_arthas_priestAI(pCreature); +} + +CreatureAI* GetAI_npc_arthas_marine(Creature* pCreature) +{ + return new npc_arthas_marineAI(pCreature); +} + +CreatureAI* GetAI_npc_dark_conversion(Creature* pCreature) +{ + return new npc_dark_conversionAI(pCreature); +} + void AddSC_culling_of_stratholme() { - Script* newscript; + Script *newscript; newscript = new Script; - newscript->Name = "npc_chromie"; - newscript->pGossipHello = &GossipHello_npc_chromie; - newscript->pGossipSelect = &GossipSelect_npc_chromie; - newscript->pQuestAccept = &QuestAccept_npc_chromie; + newscript->Name = "npc_chromi_middle"; + newscript->pGossipHello = &GossipHello_npc_chromi_middle; + newscript->pGossipSelect = &GossipSelect_npc_chromi_middle; + newscript->GetAI = &GetAI_npc_chromi_middle; newscript->RegisterSelf(); newscript = new Script; - newscript->Name = "spell_dummy_npc_crates_bunny"; - newscript->pEffectAuraDummy = &EffectAuraDummy_spell_aura_dummy_npc_crates_dummy; + newscript->Name = "npc_uther"; + newscript->GetAI = &GetAI_npc_uther; newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_arthas"; + newscript->GetAI = &GetAI_npc_arthas; + newscript->pGossipHello = &GossipHello_npc_arthas; + newscript->pGossipSelect = &GossipSelect_npc_arthas; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_arthas_priest"; + newscript->GetAI = &GetAI_npc_arthas_priest; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_arthas_marine"; + newscript->GetAI = &GetAI_npc_arthas_marine; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_dark_conversion"; + newscript->GetAI = &GetAI_npc_dark_conversion; + newscript->RegisterSelf(); } Index: scripts/kalimdor/caverns_of_time/culling_of_stratholme/culling_of_stratholme.h =================================================================== --- scripts/kalimdor/caverns_of_time/culling_of_stratholme/culling_of_stratholme.h (revision 1718) +++ scripts/kalimdor/caverns_of_time/culling_of_stratholme/culling_of_stratholme.h (working copy) @@ -1,194 +1,88 @@ -/* Copyright (C) 2006 - 2010 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ #ifndef DEF_CULLING_OF_STRATHOLME_H #define DEF_CULLING_OF_STRATHOLME_H -enum +enum Data { - MAX_ENCOUNTER = 9, + TYPE_QUEST = 1, + TYPE_INTRO = 2, + TYPE_CRATES_COUNT = 3, + TYPE_PHASE = 4, + TYPE_ENCOUNTER = 5, + TYPE_WAVE_COUNT = 6, + TYPE_WING = 7, + TYPE_BONUS = 8, + TYPE_MALGANIS = 9, - TYPE_GRAIN_EVENT = 0, // crates with plagued grain identified - TYPE_ARTHAS_INTRO_EVENT = 1, // Arhas Speech and Walk to Gates and short intro with MalGanis - TYPE_MEATHOOK_EVENT = 2, // Waves 1-5 - TYPE_SALRAMM_EVENT = 3, // Waves 6-10 - TYPE_EPOCH_EVENT = 4, // Townhall Event, Boss Killed - TYPE_ARTHAS_ESCORT_EVENT = 5, // Townhall to Malganis - TYPE_MALGANIS_EVENT = 6, // Malganis - TYPE_INFINITE_CORRUPTER_TIME = 7, // Time for 25min Timer - TYPE_INFINITE_CORRUPTER = 8, + DATA_TEMPSUMMON = 10, - // Main Encounter NPCs - NPC_CHROMIE_INN = 26527, - NPC_CHROMIE_ENTRANCE = 27915, - NPC_CHROMIE_END = 30997, - NPC_HOURGLASS = 28656, - NPC_ARTHAS = 26499, - NPC_MEATHOOK = 26529, - NPC_SALRAMM_THE_FLESHCRAFTER = 26530, - NPC_CHRONO_LORD_EPOCH = 26532, - NPC_MALGANIS = 26533, - NPC_INFINITE_CORRUPTER = 32273, - NPC_LORDAERON_CRIER = 27913, - NPC_ZOMBIE = 27737, + QUEST_DISPELLING_ILLUSIONS = 13149, + QUEST_A_ROYAL_ESCORT = 13151, - // Inn Event related NPC - NPC_MICHAEL_BELFAST = 30571, - NPC_HEARTHSINGER_FORRESTEN = 30551, - NPC_FRAS_SIABI = 30552, - NPC_FOOTMAN_JAMES = 30553, - NPC_MAL_CORRICKS = 31017, - NPC_GRYAN_STOUTMANTLE = 30561, - - // Grain Event NPCs - NPC_ROGER_OWENS = 27903, - NPC_SERGEANT_MORIGAN = 27877, - NPC_JENA_ANDERSON = 27885, - NPC_MALCOM_MOORE = 27891, // Not (yet?) spawned - NPC_BARTLEBY_BATTSON = 27907, - NPC_CRATES_BUNNY = 30996, + ITEM_ARCANE_DISRUPTOR = 37888, - // Intro Event NPCs - NPC_LORDAERON_FOOTMAN = 27745, - NPC_STRATHOLME_CITIZEN = 28167, - NPC_STRATHOLME_RESIDENT = 28169, + NPC_CHROMI01 = 26527, + NPC_CHROMI02 = 27915, + NPC_ARTHAS = 26499, + NPC_JAINA = 26497, + NPC_UTHER = 26528, + NPC_KNIGHT = 28612, + NPC_MIKE = 30571, + NPC_MAL_CORICS = 31017, + NPC_GRIAN_STONE = 30561, + NPC_JAMES = 30553, + NPC_FRAS_FRASIABI = 30552, + NPC_FORRESTER = 30551, + NPC_ROGER = 27903, + NPC_CRATE = 30996, + NPC_MORIGAN = 27877, + NPC_PERELLI = 27876, + NPC_JENA = 27885, + NPC_MARTHA = 27884, + NPC_MALCOLM = 27891, + NPC_DOG = 27892, + NPC_BARTLEBY = 27907, + NPC_MARINE = 27745, + NPC_PRIEST = 27747, - // Mobs in Stratholme (to despawn) -- only here for sake of completeness handling remains open (mangos feature) - NPC_MAGISTRATE_BARTHILAS = 30994, - NPC_STEPHANIE_SINDREE = 31019, - NPC_LEEKA_TURNER = 31027, - NPC_SOPHIE_AAREN = 31021, - NPC_ROBERT_PIERCE = 31025, - NPC_GEORGE_GOODMAN = 31022, - - // Others NPCs in Stratholme - NPC_EMERY_NEILL = 30570, - NPC_EDWARD_ORRICK = 31018, - NPC_OLIVIA_ZENITH = 31020, + NPC_INFINITE_ADVERSARY = 27742, + NPC_INFINITE_HUNTER = 27743, + NPC_INFINITE_AGENT = 27744, + NPC_TIME_RIFT = 28409, + NPC_TIME_RIFT_2 = 28439, + NPC_ZOMBIE = 27737, + NPC_GHOUL = 28249, + NPC_NECROMANCER = 28200, + NPC_STALKER = 28199, + NPC_FIEND = 27734, + NPC_GOLEM = 28201, + NPC_EGHOUL = 27729, + NPC_CONSTRUCT = 27736, + NPC_ACOLYTE = 27731, + NPC_MEATHOOK = 26529, + NPC_SALRAMM = 26530, + NPC_EPOCH = 26532, + NPC_MALGANIS = 26533, + NPC_CITY = 28167, + NPC_INFINITE_CORRUPTOR = 32273, - // Townhall Event NPCs - NPC_AGIATED_STRATHOLME_CITIZEN = 31126, - NPC_AGIATED_STRATHOLME_RESIDENT = 31127, - NPC_PATRICIA_O_REILLY = 31028, + GO_CRATE_LIGHT = 190117, + GO_SHKAF_GATE = 188686, + GO_MALGANIS_GATE1 = 187711, + GO_MALGANIS_GATE2 = 187723, + GO_MALGANIS_CHEST = 190663, + GO_MALGANIS_CHEST_H = 193597, + GO_EXIT = 191788, - // Gameobjects - GO_DOOR_BOOKCASE = 188686, - GO_DARK_RUNED_CHEST = 190663, - GO_DARK_RUNED_CHEST_H = 193597, - - // World States - WORLD_STATE_CRATES = 3479, - WORLD_STATE_CRATES_COUNT = 3480, - WORLD_STATE_WAVE = 3504, - WORLD_STATE_TIME = 3932, - WORLD_STATE_TIME_COUNTER = 3931, - // Areatrigger - AREATRIGGER_INN = 5291, - /* - 5085 before bridge - could be Uther SpawnPos - 5148 ini entrance - 5181 ini exit - 5249 fras siabis store - 5250 leeking shields...(store) - 5251 bar in stratholme - 5252 Aaren flowers - 5253 Angelicas boutique - 5256 townhall - 5291 Inn */ -}; + WORLD_STATE_COS_TIME_ON = 3932, + WORLD_STATE_COS_TIME_COUNT = 3931, + WORLD_STATE_COS_WAVE_COUNT = 3504, + WORLD_STATE_COS_CRATE_ON = 3479, + WORLD_STATE_COS_CRATE_COUNT = 3480, -enum eInstancePosition -{ - POS_ARTHAS_INTRO = 1, - POS_ARTHAS_WAVES = 2, - POS_ARTHAS_TOWNHALL = 3, - POS_ARTHAS_ESCORTING = 4, - POS_ARTHAS_MALGANIS = 5, - POS_INSTANCE_FINISHED = 6 + RIGHT = 1, + LEFT = 2 }; -class MANGOS_DLL_DECL instance_culling_of_stratholme : public ScriptedInstance -{ - public: - instance_culling_of_stratholme(Map* pMap); - ~instance_culling_of_stratholme() {} - - void Initialize(); - - void OnCreatureCreate(Creature* pCreature); - void OnObjectCreate(GameObject* pGo); - - void SetData(uint32 uiType, uint32 uiData); - uint32 GetData(uint32 uiType); - uint64 GetData64(uint32 uiData); - - const char* Save() { return strInstData.c_str(); } - void Load(const char* chrIn); - - void Update(uint32 uiDiff); - - void GetStratAgiatedCitizenList(std::list &lList){ lList = m_lAgiatedCitizenGUIDList; }; - void GetStratAgiatedResidentList(std::list &lList){ lList = m_lAgiatedResidentGUIDList; }; - - void GetCratesBunnyOrderedList(std::list &lList); - Creature* GetStratIntroFootman(); - void GetResidentOrderedList(std::list &lList); - void DoSpawnArthasIfNeeded(); - void DoSpawnChromieIfNeeded(); - uint8 GetInstancePosition(); - void ArthasJustDied(); - - protected: - void OnPlayerEnter(Player* pPlayer); - Player* GetPlayerInMap(); - void UpdateQuestCredit(); - void DoChromieHurrySpeech(); - - uint32 m_auiEncounter[MAX_ENCOUNTER]; - std::string strInstData; - - uint8 m_uiGrainCrateCount; - uint32 m_uiRemoveCrateStateTimer; - uint32 m_uiArthasRespawnTimer; - - uint64 m_uiChromieInnGUID; - uint64 m_uiChromieEntranceGUID; - uint64 m_uiChromieEndGUID; - uint64 m_uiHourglassGUID; - uint64 m_uiArthasGUID; - uint64 m_uiMeathookGUID; - uint64 m_uiSalrammGUID; - uint64 m_uiEpochGUID; - uint64 m_uiMalganisGUID; - uint64 m_uiCorrupterGUID; - uint64 m_uiLordaeronCrierGUID; - - uint64 m_uiBelfastGUID; - uint64 m_uiForrestenGUID; - uint64 m_uiSiabiGUID; - uint64 m_uiJamesGUID; - uint64 m_uiCorricksGUID; - uint64 m_uiStoutmantleGUID; - - uint64 m_uiOwensGUID; - uint64 m_uiMoriganGUID; - uint64 m_uiAndersonGUID; - uint64 m_uiMooreGUID; - uint64 m_uiBattsonGUID; - - uint64 m_uiOReillyGUID; - - std::list m_lCratesBunnyList; - std::list m_lFootmanList; - std::list m_lResidentList; - - std::list m_lAgiatedCitizenGUIDList; - std::list m_lAgiatedResidentGUIDList; - - uint64 m_uiDoorBookcaseGUID; - uint64 m_uiDarkRunedChestGUID; -}; - #endif Index: scripts/kalimdor/caverns_of_time/culling_of_stratholme/culling_of_stratholmeAI.cpp =================================================================== --- scripts/kalimdor/caverns_of_time/culling_of_stratholme/culling_of_stratholmeAI.cpp (revision 0) +++ scripts/kalimdor/caverns_of_time/culling_of_stratholme/culling_of_stratholmeAI.cpp (revision 0) @@ -0,0 +1,1260 @@ +#include "precompiled.h" +#include "culling_of_stratholme.h" +#include "escort_ai.h" +#include "WorldPacket.h" + +/*### +## npc_chromi_start +###*/ + +#define GOSSIP_ITEM_CHROMI1 "Why have I been sent back to this particular place and time?" +#define GOSSIP_ITEM_CHROMI2 "What was this decision?" +#define GOSSIP_ITEM_CHROMI3 "So how does the infinite Dragonflight plan to Interfere?" + +enum +{ + GOSSIP_TEXTID_CHROMI1 = 12939, + GOSSIP_TEXTID_CHROMI2 = 12949, + GOSSIP_TEXTID_CHROMI3 = 12950, + GOSSIP_TEXTID_CHROMI4 = 12952 +}; + +bool GossipHello_npc_chromi_start(Player* pPlayer, Creature* pCreature) +{ + if (pCreature->isQuestGiver()) + pPlayer->PrepareQuestMenu(pCreature->GetGUID()); + + ScriptedInstance* pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); + if (pPlayer && pPlayer->GetQuestStatus(QUEST_DISPELLING_ILLUSIONS) == QUEST_STATUS_COMPLETE && pInstance && pInstance->GetData(TYPE_QUEST) == NOT_STARTED) + pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_CHROMI1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + pPlayer->SEND_GOSSIP_MENU(GOSSIP_TEXTID_CHROMI1, pCreature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_chromi_start(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction) +{ + if (uiAction == GOSSIP_ACTION_INFO_DEF+1) + { + pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_CHROMI2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + + pPlayer->SEND_GOSSIP_MENU(GOSSIP_TEXTID_CHROMI2, pCreature->GetGUID()); + } + + if (uiAction == GOSSIP_ACTION_INFO_DEF+2) + { + pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_CHROMI3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); + + pPlayer->SEND_GOSSIP_MENU(GOSSIP_TEXTID_CHROMI3, pCreature->GetGUID()); + } + + if (uiAction == GOSSIP_ACTION_INFO_DEF+3) + { + // START COUNTER HERE + if (ScriptedInstance* pInstance = (ScriptedInstance*)pCreature->GetInstanceData()) + { + pInstance->DoUpdateWorldState(WORLD_STATE_COS_CRATE_ON, 1); + pInstance->SetData(TYPE_QUEST, IN_PROGRESS); + } + + if (pPlayer) + if (Item* pItem = pPlayer->StoreNewItemInInventorySlot(ITEM_ARCANE_DISRUPTOR, 1)) + pPlayer->SendNewItem(pItem, 1, true, false); + + pPlayer->SEND_GOSSIP_MENU(GOSSIP_TEXTID_CHROMI4, pCreature->GetGUID()); + } + + return true; +} + +struct MANGOS_DLL_DECL npc_chromi_startAI : public ScriptedAI +{ + npc_chromi_startAI(Creature* pCreature) : ScriptedAI(pCreature) + { + m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); + m_bCounterHere = false; + Reset(); + } + + ScriptedInstance* m_pInstance; + + bool m_bCounterHere; + + void Reset() + { + m_bCounterHere = false; + } + + void MoveInLineOfSight(Unit* pWho) + { + if (!m_bCounterHere && m_pInstance && pWho && pWho->GetTypeId() == TYPEID_PLAYER && m_creature->GetDistance2d(pWho) <= 15 && ((Player*)pWho)->GetQuestStatus(QUEST_DISPELLING_ILLUSIONS) == QUEST_STATUS_INCOMPLETE) + { + m_pInstance->DoUpdateWorldState(WORLD_STATE_COS_CRATE_ON, 1); + m_pInstance->SetData(TYPE_QUEST, IN_PROGRESS); + m_bCounterHere = true; + } + } +}; + +/*### +## npc_mike +###*/ + +enum +{ + SAY_MIKE01 = -1557270, + SAY_FORRESTER02 = -1557271, + SAY_JAMES03 = -1557272, + SAY_SIABI04 = -1557273, + SAY_MIKE05 = -1557274, + SAY_CORICKS06 = -1557275, + SAY_GRIAN07 = -1557276, + SAY_CORICKS08 = -1557277, + SAY_JAMES09 = -1557278, + SAY_FORRESTER10 = -1557279, + + EMOTE_SHOT = 5, + EMOTE_TALK = 1, + EMOTE_POINT = 25, + EMOTE_NO = 274, + EMOTE_LAUGH = 11 +}; + +struct MANGOS_DLL_DECL npc_mikeAI : public ScriptedAI +{ + npc_mikeAI(Creature* pCreature) : ScriptedAI(pCreature) + { + m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); + Reset(); + } + + ScriptedInstance* m_pInstance; + + uint32 m_uiStep; + uint32 m_uiStepTimer; + uint32 m_uiPhase; + + uint64 m_uiForesterGUID; + uint64 m_uiJamesGUID; + uint64 m_uiSiabiGUID; + uint64 m_uiCorricksGUID; + uint64 m_uiGryanGUID; + + void Reset() + { + if(m_uiPhase != 2) + { + m_uiStep = 0; + m_uiStepTimer = 100; + m_uiPhase = 0; + } + } + + void MoveInLineOfSight(Unit* who) + { + if (!who) + return; + + if(!m_pInstance) return; + + if (who->GetTypeId() == TYPEID_PLAYER && m_creature->GetDistance2d(who) <= 15 && who->GetPositionZ() > 99.50f && m_uiPhase == 0) + { + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, who->GetGUID()); + m_uiPhase = 1; + } + } + + void TavernEvent() + { + switch(m_uiStep) + { + case 0: + DoScriptText(SAY_MIKE01, m_creature); + m_uiStepTimer = 4000; + break; + case 1: + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0); + m_uiStepTimer = 5000; + break; + case 2: + m_uiForesterGUID = m_pInstance->GetData64(NPC_FORRESTER); + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiForesterGUID)) + DoScriptText(SAY_FORRESTER02, pTemp); + m_uiStepTimer = 6000; + break; + case 3: + m_uiJamesGUID = m_pInstance->GetData64(NPC_JAMES); + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiJamesGUID)) + DoScriptText(SAY_JAMES03, pTemp); + m_uiStepTimer = 5000; + break; + case 4: + m_uiSiabiGUID = m_pInstance->GetData64(NPC_FRAS_FRASIABI); + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiSiabiGUID)) + DoScriptText(SAY_SIABI04, pTemp); + m_uiStepTimer = 2000; + break; + case 5: + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiSiabiGUID)) + pTemp->HandleEmoteCommand(EMOTE_SHOT); + m_uiStepTimer = 5000; + break; + case 6: + m_creature->GetMotionMaster()->MovePoint(0, 1554.849f, 588.465f, 99.775f); + m_uiStepTimer = 3000; + break; + case 7: + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiSiabiGUID)) + pTemp->HandleEmoteCommand(EMOTE_LAUGH); + m_uiStepTimer = 3000; + break; + case 8: + DoScriptText(SAY_MIKE05, m_creature); + m_uiStepTimer = 2000; + break; + case 9: + m_creature->HandleEmoteCommand(EMOTE_SHOT); + m_uiStepTimer = 1000; + break; + case 10: + m_uiCorricksGUID = m_pInstance->GetData64(NPC_MAL_CORICS); + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiCorricksGUID)) + DoScriptText(SAY_CORICKS06, pTemp); + m_uiStepTimer = 4000; + break; + case 11: + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiCorricksGUID)) + pTemp->HandleEmoteCommand(EMOTE_TALK); + m_uiGryanGUID = m_pInstance->GetData64(NPC_GRIAN_STONE); + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiGryanGUID)) + DoScriptText(SAY_GRIAN07, pTemp); + m_uiStepTimer = 11000; + break; + case 12: + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiCorricksGUID)) + DoScriptText(SAY_CORICKS08, pTemp); + m_creature->GetMotionMaster()->MovePoint(0, 1549.609f, 575.544f, 100.052f); + m_uiStepTimer = 2000; + break; + case 13: + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiJamesGUID)) + DoScriptText(SAY_JAMES09, pTemp); + m_uiStepTimer = 2000; + break; + case 14: + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiJamesGUID)) + pTemp->HandleEmoteCommand(EMOTE_TALK); + m_uiStepTimer = 5000; + break; + case 15: + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiForesterGUID)) + DoScriptText(SAY_FORRESTER10, pTemp); + m_uiPhase = 2; + break; + } + } + + void UpdateAI(const uint32 uiDiff) + { + if(m_uiPhase == 1) + { + if(m_uiStepTimer < uiDiff) + { + TavernEvent(); + m_uiStep++; + } + else m_uiStepTimer -= uiDiff; + } + + return; + } +}; + +/*### +## npc_roger +###*/ + +enum +{ + SAY_ROGER01 = -1557280, + SAY_ROGER02 = -1557281, + SAY_ROGER03 = -1557282, + SAY_ROGER04 = -1557283, +}; + +struct MANGOS_DLL_DECL npc_rogerAI : public ScriptedAI +{ + npc_rogerAI(Creature* pCreature) : ScriptedAI(pCreature) + { + m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); + Reset(); + } + + ScriptedInstance* m_pInstance; + + uint32 m_uiStep; + uint32 m_uiStepTimer; + uint32 m_uiPhase; + + void Reset() + { + if(m_uiPhase != 2) + { + m_creature->SetStandState(UNIT_STAND_STATE_KNEEL); + m_uiStep = 0; + m_uiStepTimer = 100; + m_uiPhase = 0; + } + } + + void StartRoger() + { + m_uiPhase = 1; + } + + void FirstCrateEvent() + { + switch(m_uiStep) + { + case 0: + m_creature->SetStandState(UNIT_STAND_STATE_STAND); + m_uiStepTimer = 7000; + break; + case 1: + MoveToPoint(m_creature, 1590.055f, 615.727f, 99.795f, 7000); + m_uiStepTimer = 6900; + break; + case 2: + MoveToPoint(m_creature, 1584.039f, 622.049f, 99.907f, 4000); + m_uiStepTimer = 3900; + break; + case 3: + MoveToPoint(m_creature, 1578.787f, 623.924f, 99.855f, 2000); + m_uiStepTimer = 2500; + break; + case 4: + DoScriptText(SAY_ROGER01, m_creature); + m_uiStepTimer = 6000; + break; + case 5: + MoveToPoint(m_creature, 1579.393f, 624.018f, 99.886f, 900); + m_uiStepTimer = 2000; + break; + case 6: + DoScriptText(SAY_ROGER02, m_creature); + m_uiStepTimer = 6000; + break; + case 7: + MoveToPoint(m_creature, 1579.387f, 623.198f, 99.837f, 300); + m_uiStepTimer = 1000; + break; + case 8: + DoScriptText(SAY_ROGER03, m_creature); + m_uiStepTimer = 4000; + break; + case 9: + MoveToPoint(m_creature, 1575.576f, 619.935f, 99.422f, 1500); + m_uiStepTimer = 2000; + break; + case 10: + MoveToPoint(m_creature, 1575.833f, 620.471f, 99.466f, 300); + m_uiStepTimer = 1000; + break; + case 11: + DoScriptText(SAY_ROGER04, m_creature); + m_uiStepTimer = 6000; + break; + case 12: + MoveToPoint(m_creature, 1580.215f, 624.368f, 99.924f, 2000); + m_uiStepTimer = 1900; + break; + case 13: + MoveToPoint(m_creature, 1587.471f, 618.181f, 99.850f, 4000); + m_uiStepTimer = 3900; + break; + case 14: + MoveToPoint(m_creature, 1592.646f, 590.888f, 99.151f, 11000); + m_uiStepTimer = 13000; + break; + case 15: + m_uiPhase = 2; + m_creature->SetVisibility(VISIBILITY_OFF); + break; + } + } + + void MoveToPoint(Creature* unit, float X, float Y, float Z, uint32 Timer) + { + unit->GetMotionMaster()->MovementExpired(false); + unit->GetMap()->CreatureRelocation(unit, X, Y, Z, unit->GetOrientation()); + unit->SendMonsterMove(X, Y, Z, SPLINETYPE_NORMAL , unit->GetSplineFlags(), Timer); + } + + void UpdateAI(const uint32 uiDiff) + { + if(m_uiPhase == 1) + { + if(m_uiStepTimer < uiDiff) + { + FirstCrateEvent(); + m_uiStep++; + } + else m_uiStepTimer -= uiDiff; + } + + return; + } +}; + +/*### +## npc_morigan +###*/ + +enum +{ + SAY_MORIGAN01 = -1557284, + SAY_PERELLI02 = -1557285, + SAY_MORIGAN03 = -1557286, + SAY_PERELLI04 = -1557287, + SAY_MORIGAN05 = -1557288, + SAY_PERELLI06 = -1557289, + SAY_MORIGAN07 = -1557290, +}; + +struct MANGOS_DLL_DECL npc_moriganAI : public ScriptedAI +{ + npc_moriganAI(Creature* pCreature) : ScriptedAI(pCreature) + { + m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); + Reset(); + } + + ScriptedInstance* m_pInstance; + + uint64 m_uiPerelliGUID; + uint32 m_uiStep; + uint32 m_uiStepTimer; + uint32 m_uiPhase; + + void Reset() + { + if(m_uiPhase != 2) + { + m_uiStep = 0; + m_uiStepTimer = 100; + m_uiPhase = 0; + } + } + + void StartMorigan() + { + m_uiPhase = 1; + } + + void SecondCrateEvent() + { + switch(m_uiStep) + { + case 0: + DoScriptText(SAY_MORIGAN01, m_creature); + m_uiStepTimer = 6000; + break; + case 1: + m_uiPerelliGUID = m_pInstance->GetData64(NPC_PERELLI); + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiPerelliGUID)) + DoScriptText(SAY_PERELLI02, pTemp); + m_uiStepTimer = 2000; + break; + case 2: + m_creature->GetMotionMaster()->MovePoint(0, 1564.138f, 668.343f, 102.058f); + m_uiStepTimer = 2000; + break; + case 3: + m_creature->GetMotionMaster()->MovePoint(0, 1567.956f, 667.776f, 102.094f); + m_uiStepTimer = 1500; + break; + case 4: + m_creature->GetMotionMaster()->MovementExpired(false); + m_creature->GetMotionMaster()->MovePoint(0, 1569.615f, 668.859f, 102.180f); + m_uiStepTimer = 2000; + break; + case 5: + m_creature->SetStandState(UNIT_STAND_STATE_KNEEL); + m_uiStepTimer = 1000; + break; + case 6: + DoScriptText(SAY_MORIGAN03, m_creature); + m_uiStepTimer = 3000; + break; + case 7: + m_creature->SetStandState(UNIT_STAND_STATE_STAND); + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiPerelliGUID)) + { + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, pTemp->GetGUID()); + pTemp->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->GetGUID()); + } + m_uiStepTimer = 3000; + break; + case 8: + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiPerelliGUID)) + DoScriptText(SAY_PERELLI04, pTemp); + m_uiStepTimer = 3000; + break; + case 9: + DoScriptText(SAY_MORIGAN05, m_creature); + m_uiStepTimer = 9000; + break; + case 10: + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiPerelliGUID)) + DoScriptText(SAY_PERELLI06, pTemp); + m_uiStepTimer = 6000; + break; + case 11: + DoScriptText(SAY_MORIGAN07, m_creature); + m_uiStepTimer = 4000; + break; + case 12: + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0); + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiPerelliGUID)) + pTemp->SetUInt64Value(UNIT_FIELD_TARGET, 0); + MoveToPoint(m_creature, 1576.119f, 657.675f, 102.09f, 5000); + m_uiStepTimer = 4900; + break; + case 13: + MoveToPoint(m_creature, 1586.040f, 646.113f, 100.910f, 6000); + m_uiStepTimer = 5900; + break; + case 14: + MoveToPoint(m_creature, 1609.189f, 697.134f, 106.902f, 23000); + m_uiStepTimer = 24900; + break; + case 15: + m_uiPhase = 2; + m_creature->SetVisibility(VISIBILITY_OFF); + break; + } + } + + void MoveToPoint(Creature* unit, float X, float Y, float Z, uint32 Timer) + { + unit->GetMap()->CreatureRelocation(unit, X, Y, Z, unit->GetOrientation()); + unit->SendMonsterMove(X, Y, Z, SPLINETYPE_NORMAL , unit->GetSplineFlags(), Timer); + } + + void UpdateAI(const uint32 uiDiff) + { + if(m_uiPhase == 1) + { + if(m_uiStepTimer < uiDiff) + { + SecondCrateEvent(); + m_uiStep++; + } + else m_uiStepTimer -= uiDiff; + } + + return; + } +}; + +/*### +## npc_jena +###*/ + +enum +{ + SAY_JENA01 = -1557291, + SAY_MARTHA02 = -1557292, + SAY_JENA03 = -1557293, + SAY_JENA04 = -1557294, + SAY_MARTHA05 = -1557295, + +}; + +struct MANGOS_DLL_DECL npc_jenaAI : public ScriptedAI +{ + npc_jenaAI(Creature* pCreature) : ScriptedAI(pCreature) + { + m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); + Reset(); + } + + ScriptedInstance* m_pInstance; + + uint64 m_uiMarthaGUID; + uint32 m_uiStep; + uint32 m_uiStepTimer; + uint32 m_uiPhase; + + void Reset() + { + if(m_uiPhase != 2) + { + m_uiStep = 0; + m_uiStepTimer = 100; + m_uiPhase = 0; + } + } + + void StartJena() + { + m_uiPhase = 1; + } + + void ThirdCrateEvent() + { + switch(m_uiStep) + { + case 0: + m_creature->GetMotionMaster()->MovementExpired(false); + m_creature->GetMotionMaster()->MovePoint(0, 1605.546f, 744.869f, 114.731f); + m_uiStepTimer = 1900; + break; + case 1: + m_creature->GetMotionMaster()->MovementExpired(false); + m_creature->GetMotionMaster()->MovePoint(0, 1614.967f, 743.673f, 114.063f); + m_uiStepTimer = 4900; + break; + case 2: + m_creature->GetMotionMaster()->MovementExpired(false); + m_creature->GetMotionMaster()->MovePoint(0, 1623.848f, 729.251f, 112.410f); + m_uiStepTimer = 6900; + break; + case 3: + m_creature->GetMotionMaster()->MovementExpired(false); + m_creature->GetMotionMaster()->MovePoint(0, 1633.460f, 726.261f, 113.518f); + m_uiStepTimer = 4000; + break; + case 4: + m_uiMarthaGUID = m_pInstance->GetData64(NPC_MARTHA); + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiMarthaGUID)) + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, pTemp->GetGUID()); + DoScriptText(SAY_JENA01, m_creature); + m_uiStepTimer = 3000; + break; + case 5: + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiMarthaGUID)) + { + pTemp->RemoveAurasDueToSpell(58925); + pTemp->GetMotionMaster()->MovePoint(0, 1635.918f, 724.357f, 113.561f); + } + m_uiStepTimer = 1000; + break; + case 6: + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiMarthaGUID)) + { + pTemp->GetMotionMaster()->MovementExpired(false); + pTemp->GetMotionMaster()->MovePoint(0, 1636.721f, 725.88f, 113.561f); + pTemp->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->GetGUID()); + } + m_uiStepTimer = 1000; + break; + case 7: + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiMarthaGUID)) + DoScriptText(SAY_MARTHA02, pTemp); + m_uiStepTimer = 4000; + break; + case 8: + DoScriptText(SAY_JENA03, m_creature); + m_uiStepTimer = 3000; + break; + case 9: + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0); + m_creature->GetMotionMaster()->MovePoint(0, 1629.278f, 727.894f, 112.636f); + m_uiStepTimer = 1500; + break; + case 10: + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiMarthaGUID)) + { + pTemp->SetUInt64Value(UNIT_FIELD_TARGET, 0); + pTemp->GetMap()->CreatureRelocation(pTemp, 1640.089f, 725.766f, 113.561f, 4.77f); + pTemp->SendMonsterMove(1640.089f, 725.766f, 113.561f, SPLINETYPE_NORMAL , pTemp->GetSplineFlags(), 1500); + } + m_creature->GetMotionMaster()->MovementExpired(false); + m_creature->GetMotionMaster()->MovePoint(0, 1629.452f, 729.416f, 112.712f); + m_uiStepTimer = 1000; + break; + case 11: + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiMarthaGUID)) + pTemp->GetMotionMaster()->MovePoint(0, 1640.103f, 725.522f, 113.561f); + m_uiStepTimer = 500; + break; + case 12: + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiMarthaGUID)) + pTemp->CastSpell(pTemp, 58925, false); + m_creature->SetStandState(UNIT_STAND_STATE_KNEEL); + m_uiStepTimer = 1500; + break; + case 13: + m_creature->SetStandState(UNIT_STAND_STATE_STAND); + m_uiStepTimer = 1000; + break; + case 14: + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiMarthaGUID)) + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, pTemp->GetGUID()); + DoScriptText(SAY_JENA04, m_creature); + m_uiStepTimer = 3000; + break; + case 15: + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiMarthaGUID)) + { + pTemp->RemoveAurasDueToSpell(58925); + DoScriptText(SAY_MARTHA05, pTemp); + MoveToPoint(pTemp, 1638.196f, 726.171f, 113.561f, 1000); + } + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0); + MoveToPoint(m_creature, 1615.590f, 719.509f, 110.311f, 2000); + m_uiStepTimer = 2000; + break; + case 16: + MoveToPoint(m_creature, 1596.436f, 670.809f, 103.747f, 7000); + m_uiStepTimer = 6900; + break; + case 17: + MoveToPoint(m_creature, 1571.549f, 609.837f, 99.767f, 9000); + m_uiStepTimer = 11000; + break; + case 18: + m_uiPhase = 2; + m_creature->SetVisibility(VISIBILITY_OFF); + break; + } + } + + void MoveToPoint(Creature* unit, float X, float Y, float Z, uint32 Timer) + { + unit->GetMap()->CreatureRelocation(unit, X, Y, Z, unit->GetOrientation()); + unit->SendMonsterMove(X, Y, Z, SPLINETYPE_NORMAL , unit->GetSplineFlags(), Timer); + } + + void UpdateAI(const uint32 uiDiff) + { + if(m_uiPhase == 1) + { + if(m_uiStepTimer < uiDiff) + { + ThirdCrateEvent(); + m_uiStep++; + } + else m_uiStepTimer -= uiDiff; + } + + return; + } +}; + +/*### +## npc_malcolm +###*/ + +enum +{ + SOUND_ID_DOG_GROWL = 1108, + SOUND_ID_DOG_HOWL = 1018, + EMOTE_DOG_HOWL = 393, + + SAY_MALCOLM01 = -1557296, + SAY_MALCOLM02 = -1557297, + SAY_MALCOLM03 = -1557298, + SAY_MALCOLM04 = -1557299, +}; + +struct MANGOS_DLL_DECL npc_malcolmAI : public ScriptedAI +{ + npc_malcolmAI(Creature* pCreature) : ScriptedAI(pCreature) + { + m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); + Reset(); + } + + ScriptedInstance* m_pInstance; + + uint64 m_uiDogGUID; + uint32 m_uiStep; + uint32 m_uiStepTimer; + uint32 m_uiPhase; + + void Reset() + { + if(m_uiPhase != 2) + { + m_uiStep = 0; + m_uiStepTimer = 100; + m_uiPhase = 0; + } + } + + void StartMalcolm() + { + m_uiPhase = 1; + } + + void FourCrateEvent() + { + switch(m_uiStep) + { + case 0: + MoveToPoint(m_creature, 1614.066f, 796.722f, 121.739f, 5500); + m_uiDogGUID = m_pInstance->GetData64(NPC_DOG); + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiDogGUID)) + MoveToPoint(pTemp, 1611.459f, 793.274f, 121.928f, 5500); + m_uiStepTimer = 5400; + break; + case 1: + DoScriptText(SAY_MALCOLM01, m_creature); + MoveToPoint(m_creature, 1622.820f, 798.816f, 120.570f, 3500); + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiDogGUID)) + MoveToPoint(pTemp, 1621.467f, 794.323f, 120.323f, 3500); + m_uiStepTimer = 3400; + break; + case 2: + MoveToPoint(m_creature, 1626.574f, 806.781f, 120.270f, 3500); + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiDogGUID)) + MoveToPoint(pTemp, 1629.232f, 803.629f, 120.011f, 3500); + m_uiStepTimer = 3400; + break; + case 3: + MoveToPoint(m_creature, 1622.782f, 808.533f, 121.249f, 1500); + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiDogGUID)) + MoveToPoint(pTemp, 1629.265f, 805.245f, 120.070f, 300); + m_uiStepTimer = 300; + break; + case 4: + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiDogGUID)) + pTemp->PlayDirectSound(SOUND_ID_DOG_GROWL); + m_uiStepTimer = 500; + break; + case 5: + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiDogGUID)) + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, pTemp->GetGUID()); + DoScriptText(SAY_MALCOLM02, m_creature); + m_uiStepTimer = 2000; + break; + case 6: + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiDogGUID)) + MoveToPoint(pTemp, 1629.163f, 809.738f, 120.369f, 1500); + m_uiStepTimer = 2000; + break; + case 7: + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiDogGUID)) + { + pTemp->HandleEmoteCommand(EMOTE_DOG_HOWL); + pTemp->PlayDirectSound(SOUND_ID_DOG_HOWL); + } + m_uiStepTimer = 4000; + break; + case 8: + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0); + MoveToPoint(m_creature, 1629.922f, 807.799f, 120.122f, 3000); + m_uiStepTimer = 2900; + break; + case 9: + MoveToPoint(m_creature, 1632.169f, 809.851f, 120.047f, 1000); + m_uiStepTimer = 900; + break; + case 10: + MoveToPoint(m_creature, 1630.651f, 811.149f, 120.307f, 800); + m_uiStepTimer = 800; + break; + case 11: + m_creature->SetStandState(UNIT_STAND_STATE_KNEEL); + DoScriptText(SAY_MALCOLM03, m_creature); + m_uiStepTimer = 4000; + break; + case 12: + m_creature->SetStandState(UNIT_STAND_STATE_STAND); + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiDogGUID)) + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, pTemp->GetGUID()); + DoScriptText(SAY_MALCOLM04, m_creature); + m_uiStepTimer = 7000; + break; + case 13: + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiDogGUID)) + MoveToPoint(pTemp, 1630.692f, 808.011f, 120.083f, 400); + m_uiStepTimer = 600; + break; + case 14: + if(Creature* pTemp = m_pInstance->instance->GetCreature(m_uiDogGUID)) + pTemp->SetStandState(UNIT_STAND_STATE_SIT); + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0); + MoveToPoint(m_creature, 1641.452f, 812.600f, 119.948f, 4000); + m_uiStepTimer = 3900; + break; + case 15: + MoveToPoint(m_creature, 1657.975f, 857.352f, 119.097f, 18000); + m_uiStepTimer = 17900; + break; + case 16: + MoveToPoint(m_creature, 1679.852f, 912.245f, 120.533f, 23000); + m_uiStepTimer = 22900; + break; + case 17: + MoveToPoint(m_creature, 1699.915f, 967.110f, 121.643f, 23000); + m_uiStepTimer = 22900; + break; + case 18: + MoveToPoint(m_creature, 1678.393f, 1026.890f, 125.431f, 25000); + m_uiStepTimer = 24900; + break; + case 19: + MoveToPoint(m_creature, 1678.943f, 1093.130f, 126.899f, 26000); + m_uiStepTimer = 25900; + break; + case 20: + MoveToPoint(m_creature, 1700.042f, 1103.880f, 130.872f, 9000); + m_uiStepTimer = 10900; + break; + case 21: + m_uiPhase = 2; + m_creature->SetVisibility(VISIBILITY_OFF); + break; + } + } + + void MoveToPoint(Creature* unit, float X, float Y, float Z, uint32 Timer) + { + unit->GetMap()->CreatureRelocation(unit, X, Y, Z, unit->GetOrientation()); + unit->SendMonsterMove(X, Y, Z, SPLINETYPE_NORMAL , unit->GetSplineFlags(), Timer); + } + + void UpdateAI(const uint32 uiDiff) + { + if(m_uiPhase == 1) + { + if(m_uiStepTimer < uiDiff) + { + FourCrateEvent(); + m_uiStep++; + } + else m_uiStepTimer -= uiDiff; + } + + return; + } +}; + +/*### +## npc_bartleby +###*/ + +enum +{ + SAY_BARTLEBY01 = -1557300, + SAY_BARTLEBY02 = -1557301, + SAY_BARTLEBY03 = -1557302, + SAY_BARTLEBY04 = -1557303, + SAY_BARTLEBY05 = -1557304, +}; + +struct MANGOS_DLL_DECL npc_bartleby_csAI : public ScriptedAI +{ + npc_bartleby_csAI(Creature* pCreature) : ScriptedAI(pCreature) + { + m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); + Reset(); + } + + ScriptedInstance* m_pInstance; + + uint32 m_uiStep; + uint32 m_uiStepTimer; + uint32 m_uiPhase; + + void Reset() + { + if(m_uiPhase != 4) + { + m_uiStep = 0; + m_uiStepTimer = 100; + m_uiPhase = 0; + } + } + + void MoveInLineOfSight(Unit* who) + { + if (!who) + return; + + if(!m_pInstance) return; + + if (who->GetTypeId() == TYPEID_PLAYER && m_creature->GetDistance2d(who) <= 20 && m_uiPhase == 0) + { + m_uiPhase = 1; + } + } + + void StartBartleby() + { + m_uiPhase = 3; + } + + void FifthCrateEvent() + { + switch(m_uiStep) + { + case 0: + DoScriptText(SAY_BARTLEBY03, m_creature); + MoveToPoint(m_creature, 1672.539f, 872.277f, 120.113f, 1000); + m_uiStepTimer = 1000; + break; + case 1: + m_creature->SetStandState(UNIT_STAND_STATE_KNEEL); + m_uiStepTimer = 3000; + break; + case 2: + DoScriptText(SAY_BARTLEBY04, m_creature); + m_uiStepTimer = 7000; + break; + case 3: + m_creature->SetStandState(UNIT_STAND_STATE_STAND); + m_uiStepTimer = 1000; + break; + case 4: + DoScriptText(SAY_BARTLEBY05, m_creature); + MoveToPoint(m_creature, 1663.054f, 869.959f, 119.734f, 3000); + m_uiStepTimer = 2900; + break; + case 5: + MoveToPoint(m_creature, 1640.732f, 812.422f, 119.933f, 24000); + m_uiStepTimer = 23900; + break; + case 6: + MoveToPoint(m_creature, 1623.704f, 755.741f, 115.710f, 23000); + m_uiStepTimer = 22900; + break; + case 7: + MoveToPoint(m_creature, 1607.108f, 699.637f, 106.971f, 23000); + m_uiStepTimer = 22900; + break; + case 8: + MoveToPoint(m_creature, 1587.750f, 646.929f, 100.990f, 21000); + m_uiStepTimer = 20900; + break; + case 9: + MoveToPoint(m_creature, 1571.103f, 660.949f, 102.084f, 8000); + m_uiStepTimer = 10900; + break; + case 10: + m_uiPhase = 4; + m_creature->SetVisibility(VISIBILITY_OFF); + break; + } + } + + void SpeechEvent() + { + switch(m_uiStep) + { + case 0: + DoScriptText(SAY_BARTLEBY01, m_creature); + m_uiStepTimer = 5000; + break; + case 1: + DoScriptText(SAY_BARTLEBY02, m_creature); + if(m_uiPhase == 1) + m_uiPhase = 2; + break; + } + } + + void MoveToPoint(Creature* unit, float X, float Y, float Z, uint32 Timer) + { + unit->GetMap()->CreatureRelocation(unit, X, Y, Z, unit->GetOrientation()); + unit->SendMonsterMove(X, Y, Z, SPLINETYPE_NORMAL , unit->GetSplineFlags(), Timer); + } + + void UpdateAI(const uint32 uiDiff) + { + if(m_uiPhase == 3) + { + if(m_uiStepTimer < uiDiff) + { + FifthCrateEvent(); + m_uiStep++; + } + else m_uiStepTimer -= uiDiff; + } + + if(m_uiPhase == 1) + { + if(m_uiStepTimer < uiDiff) + { + SpeechEvent(); + m_uiStep++; + } + else m_uiStepTimer -= uiDiff; + } + + return; + } +}; + +/*### +## npc_crates +###*/ + +enum +{ + SPELL_LIGHT = 49590 +}; + +struct MANGOS_DLL_DECL npc_stratholme_cratesAI : public ScriptedAI +{ + npc_stratholme_cratesAI(Creature* pCreature) : ScriptedAI(pCreature) + { + m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); + Reset(); + } + + ScriptedInstance* m_pInstance; + + bool Active; + + void Reset() + { + } + + void UpdateAI(const uint32 uiDiff) + { + if(!m_pInstance) return; + + if(m_creature->HasAura(SPELL_LIGHT) && Active != true) + { + if(Creature* pRoger = m_pInstance->instance->GetCreature(m_pInstance->GetData64(NPC_ROGER))) + { + if(m_creature->GetDistance2d(pRoger->GetPositionX(), pRoger->GetPositionY()) < 50.0f) + { + ((npc_rogerAI*)pRoger->AI())->StartRoger(); + } + } + + if(Creature* pMorigan = m_pInstance->instance->GetCreature(m_pInstance->GetData64(NPC_MORIGAN))) + { + if(m_creature->GetDistance2d(pMorigan->GetPositionX(), pMorigan->GetPositionY()) < 50.0f) + { + ((npc_moriganAI*)pMorigan->AI())->StartMorigan(); + } + } + + if(Creature* pJena = m_pInstance->instance->GetCreature(m_pInstance->GetData64(NPC_JENA))) + { + if(m_creature->GetDistance2d(pJena->GetPositionX(), pJena->GetPositionY()) < 50.0f) + { + ((npc_jenaAI*)pJena->AI())->StartJena(); + } + } + + if(Creature* pMalcolm = m_pInstance->instance->GetCreature(m_pInstance->GetData64(NPC_MALCOLM))) + { + if(m_creature->GetDistance2d(pMalcolm->GetPositionX(), pMalcolm->GetPositionY()) < 50.0f) + { + ((npc_malcolmAI*)pMalcolm->AI())->StartMalcolm(); + } + } + + if(Creature* pBartleby = m_pInstance->instance->GetCreature(m_pInstance->GetData64(NPC_BARTLEBY))) + { + if(m_creature->GetDistance2d(pBartleby->GetPositionX(), pBartleby->GetPositionY()) < 50.0f) + { + ((npc_bartleby_csAI*)pBartleby->AI())->StartBartleby(); + } + } + + m_pInstance->SetData(TYPE_CRATES_COUNT, 1); + if(GameObject* pLight = GetClosestGameObjectWithEntry(m_creature, GO_CRATE_LIGHT, 5.0f)) + pLight->SetPhaseMask(0, true); + //m_creature->SetPhaseMask(0, true); + Active = true; + } + + return; + } +}; + +CreatureAI* GetAI_npc_chromi_start(Creature* pCreature) +{ + return new npc_chromi_startAI(pCreature); +} + +CreatureAI* GetAI_npc_mike(Creature* pCreature) +{ + return new npc_mikeAI(pCreature); +} + +CreatureAI* GetAI_npc_roger(Creature* pCreature) +{ + return new npc_rogerAI(pCreature); +} + +CreatureAI* GetAI_npc_morigan(Creature* pCreature) +{ + return new npc_moriganAI(pCreature); +} + +CreatureAI* GetAI_npc_jena(Creature* pCreature) +{ + return new npc_jenaAI(pCreature); +} + +CreatureAI* GetAI_npc_malcolm(Creature* pCreature) +{ + return new npc_malcolmAI(pCreature); +} + +CreatureAI* GetAI_npc_bartleby_cs(Creature* pCreature) +{ + return new npc_bartleby_csAI(pCreature); +} + +CreatureAI* GetAI_npc_stratholme_crates(Creature* pCreature) +{ + return new npc_stratholme_cratesAI(pCreature); +} + +void AddSC_culling_of_stratholmeAI() +{ + Script *newscript; + + newscript = new Script; + newscript->Name = "npc_chromi_start"; + newscript->pGossipHello = &GossipHello_npc_chromi_start; + newscript->pGossipSelect = &GossipSelect_npc_chromi_start; + newscript->GetAI = &GetAI_npc_chromi_start; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_mike"; + newscript->GetAI = &GetAI_npc_mike; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_roger"; + newscript->GetAI = &GetAI_npc_roger; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_morigan"; + newscript->GetAI = &GetAI_npc_morigan; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_jena"; + newscript->GetAI = &GetAI_npc_jena; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_malcolm"; + newscript->GetAI = &GetAI_npc_malcolm; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_bartleby_cs"; + newscript->GetAI = &GetAI_npc_bartleby_cs; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_stratholme_crates"; + newscript->GetAI = &GetAI_npc_stratholme_crates; + newscript->RegisterSelf(); +} Index: scripts/kalimdor/caverns_of_time/culling_of_stratholme/instance_culling_of_stratholme.cpp =================================================================== --- scripts/kalimdor/caverns_of_time/culling_of_stratholme/instance_culling_of_stratholme.cpp (revision 1718) +++ scripts/kalimdor/caverns_of_time/culling_of_stratholme/instance_culling_of_stratholme.cpp (working copy) @@ -1,536 +1,353 @@ -/* Copyright (C) 2006 - 2010 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Instance_culling_of_stratholme -SD%Complete: 80% -SDComment: -SDCategory: Culling of Stratholme -EndScriptData */ - #include "precompiled.h" #include "culling_of_stratholme.h" -enum +struct MANGOS_DLL_DECL instance_culling_of_stratholme : public ScriptedInstance { - MAX_ARTHAS_SPAWN_POS = 5, - SAY_CHROMIE_HURRY = -1000000 // TODO -}; + instance_culling_of_stratholme(Map* pMap) : ScriptedInstance(pMap) {Initialize();}; -struct sSpawnLocation -{ - float m_fX, m_fY, m_fZ, m_fO; -}; + uint8 m_uiCratesCount; + uint32 m_auiEncounter[7]; + uint32 m_uiHeroicTimer; + uint32 m_uiLastTimer; -static sSpawnLocation m_aArthasSpawnLocs[] = // need tuning -{ - {1969.73f, 1287.12f, 145.48f, 3.14f}, - {2049.43f, 1287.43f, 142.75f, 0.06f}, - {2365.54f, 1194.85f, 131.98f, 0.47f}, - {2534.46f, 1125.99f, 130.75f, 0.27f}, - {2363.77f, 1406.31f, 128.64f, 3.23f} -}; + uint64 m_uiChromi01GUID; + uint64 m_uiChromi02GUID; + uint64 m_uiMikeGUID; + uint64 m_uiMalCoricsGUID; + uint64 m_uiGrianStoneGUID; + uint64 m_uiJamesGUID; + uint64 m_uiFrasCiabiGUID; + uint64 m_uiForrestenGUID; + uint64 m_uiRogerGUID; + uint64 m_uiMoriganGUID; + uint64 m_uiPerelliGUID; + uint64 m_uiJenaGUID; + uint64 m_uiMarthaGUID; + uint64 m_uiMalcolmGUID; + uint64 m_uiDogGUID; + uint64 m_uiBartlebyGUID; + uint64 m_uiArthasGUID; + uint64 m_uiUtherGUID; + uint64 m_uiJainaGUID; + uint64 m_uiSalrammGUID; + uint64 m_uiMalganisGUID; + uint64 m_uiCorruptorGUID; -static sSpawnLocation m_aChromieSpawnLocs[] = // need tuning, escpecially EndPositions! -{ - {1814.46f, 1283.97f, 142.30f, 4.32f}, // near bridge - {2311.0f, 1502.4f, 127.9f, 0.0f}, // End - {1811.52f, 1285.92f, 142.37f, 4.47f}, // Hourglass, near bridge - {2186.42f, 1323.77f, 129.91f, 0.0f}, // Hourglass, End -}; + uint64 m_uiShkafGateGUID; + uint64 m_uiMalGate1GUID; + uint64 m_uiMalGate2GUID; + uint64 m_uiMalChestGUID; + uint64 m_uiExitGUID; -instance_culling_of_stratholme::instance_culling_of_stratholme(Map* pMap) : ScriptedInstance(pMap), - m_uiGrainCrateCount(0), - m_uiRemoveCrateStateTimer(0), - m_uiArthasRespawnTimer(0), - - m_uiChromieInnGUID(0), - m_uiChromieEntranceGUID(0), - m_uiChromieEndGUID(0), - m_uiHourglassGUID(0), - m_uiArthasGUID(0), - m_uiMeathookGUID(0), - m_uiSalrammGUID(0), - m_uiEpochGUID(0), - m_uiCorrupterGUID(0), - m_uiLordaeronCrierGUID(0), - - m_uiBelfastGUID(0), - m_uiForrestenGUID(0), - m_uiSiabiGUID(0), - m_uiJamesGUID(0), - m_uiCorricksGUID(0), - m_uiStoutmantleGUID(0), - - m_uiOwensGUID(0), - m_uiMoriganGUID(0), - m_uiAndersonGUID(0), - m_uiMooreGUID(0), - m_uiBattsonGUID(0), - - m_uiOReillyGUID(0), - - m_uiDoorBookcaseGUID(0), - m_uiDarkRunedChestGUID(0) -{ - Initialize(); -} - -void instance_culling_of_stratholme::Initialize() -{ - memset(&m_auiEncounter, 0, sizeof(m_auiEncounter)); -} - -void instance_culling_of_stratholme::OnCreatureCreate(Creature* pCreature) -{ - switch(pCreature->GetEntry()) + void Initialize() { - case NPC_CHROMIE_INN: m_uiChromieInnGUID = pCreature->GetGUID(); break; - case NPC_CHROMIE_ENTRANCE: m_uiChromieEntranceGUID = pCreature->GetGUID(); break; - case NPC_CHROMIE_END: m_uiChromieEndGUID = pCreature->GetGUID(); break; - case NPC_HOURGLASS: m_uiHourglassGUID = pCreature->GetGUID(); break; - case NPC_ARTHAS: m_uiArthasGUID = pCreature->GetGUID(); break; - case NPC_MEATHOOK: m_uiMeathookGUID = pCreature->GetGUID(); break; - case NPC_SALRAMM_THE_FLESHCRAFTER: m_uiSalrammGUID = pCreature->GetGUID(); break; - case NPC_CHRONO_LORD_EPOCH: m_uiEpochGUID = pCreature->GetGUID(); break; - case NPC_MALGANIS: m_uiMalganisGUID = pCreature->GetGUID(); break; - case NPC_MICHAEL_BELFAST: m_uiBelfastGUID = pCreature->GetGUID(); break; - case NPC_HEARTHSINGER_FORRESTEN: m_uiForrestenGUID = pCreature->GetGUID(); break; - case NPC_FRAS_SIABI: m_uiSiabiGUID = pCreature->GetGUID(); break; - case NPC_FOOTMAN_JAMES: m_uiJamesGUID = pCreature->GetGUID(); break; - case NPC_MAL_CORRICKS: m_uiCorricksGUID = pCreature->GetGUID(); break; - case NPC_GRYAN_STOUTMANTLE: m_uiStoutmantleGUID = pCreature->GetGUID(); break; - case NPC_ROGER_OWENS: m_uiOwensGUID = pCreature->GetGUID(); break; - case NPC_SERGEANT_MORIGAN: m_uiMoriganGUID = pCreature->GetGUID(); break; - case NPC_JENA_ANDERSON: m_uiAndersonGUID = pCreature->GetGUID(); break; - case NPC_MALCOM_MOORE: m_uiMooreGUID = pCreature->GetGUID(); break; - case NPC_BARTLEBY_BATTSON: m_uiBattsonGUID = pCreature->GetGUID(); break; - case NPC_PATRICIA_O_REILLY: m_uiOReillyGUID = pCreature->GetGUID(); break; - case NPC_LORDAERON_CRIER: m_uiLordaeronCrierGUID = pCreature->GetGUID(); break; - case NPC_INFINITE_CORRUPTER: m_uiCorrupterGUID = pCreature->GetGUID(); break; + m_uiHeroicTimer = 1500000; + m_uiLastTimer = 1500000; + m_auiEncounter[0] = NOT_STARTED; + m_auiEncounter[1] = NOT_STARTED; + m_auiEncounter[2] = 0; + m_auiEncounter[3] = NOT_STARTED; + m_auiEncounter[4] = 0; + m_auiEncounter[5] = NOT_STARTED; + m_auiEncounter[6] = NOT_STARTED; - case NPC_CRATES_BUNNY: m_lCratesBunnyList.push_back(pCreature); break; - case NPC_LORDAERON_FOOTMAN: m_lFootmanList.push_back(pCreature); break; + DoUpdateWorldState(WORLD_STATE_COS_CRATE_COUNT, 0); + DoUpdateWorldState(WORLD_STATE_COS_CRATE_ON, 0); + DoUpdateWorldState(WORLD_STATE_COS_WAVE_COUNT, 0); + DoUpdateWorldState(WORLD_STATE_COS_TIME_COUNT, 0); + DoUpdateWorldState(WORLD_STATE_COS_TIME_ON, 0); - case NPC_STRATHOLME_CITIZEN: - case NPC_STRATHOLME_RESIDENT: - if (m_auiEncounter[TYPE_ARTHAS_INTRO_EVENT] == DONE) - pCreature->UpdateEntry(NPC_ZOMBIE); - else - m_lResidentList.push_back(pCreature); - break; - case NPC_AGIATED_STRATHOLME_CITIZEN: m_lAgiatedCitizenGUIDList.push_back(pCreature->GetGUID()); break; - case NPC_AGIATED_STRATHOLME_RESIDENT: m_lAgiatedResidentGUIDList.push_back(pCreature->GetGUID()); break; + m_uiCratesCount = 0; + m_uiMikeGUID = 0; + m_uiChromi01GUID = 0; + m_uiChromi02GUID = 0; + m_uiMalCoricsGUID = 0; + m_uiGrianStoneGUID = 0; + m_uiJamesGUID = 0; + m_uiFrasCiabiGUID = 0; + m_uiForrestenGUID = 0; + m_uiRogerGUID = 0; + m_uiMoriganGUID = 0; + m_uiPerelliGUID = 0; + m_uiJenaGUID = 0; + m_uiMarthaGUID = 0; + m_uiMalcolmGUID = 0; + m_uiDogGUID = 0; + m_uiBartlebyGUID = 0; + m_uiArthasGUID = 0; + m_uiUtherGUID = 0; + m_uiJainaGUID = 0; + m_uiShkafGateGUID = 0; + m_uiSalrammGUID = 0; + m_uiCorruptorGUID = 0; + m_uiMalganisGUID = 0; + m_uiMalGate1GUID = 0; + m_uiMalGate2GUID = 0; + m_uiMalChestGUID = 0; + m_uiExitGUID = 0; } -} -void instance_culling_of_stratholme::OnObjectCreate(GameObject* pGo) -{ - switch(pGo->GetEntry()) + void OnCreatureCreate(Creature* pCreature) { - case GO_DOOR_BOOKCASE: - m_uiDoorBookcaseGUID = pGo->GetGUID(); - if (m_auiEncounter[TYPE_EPOCH_EVENT] == DONE) - pGo->SetGoState(GO_STATE_ACTIVE); - break; - case GO_DARK_RUNED_CHEST: - case GO_DARK_RUNED_CHEST_H: - m_uiDarkRunedChestGUID = pGo->GetGUID(); - } -} - -Player* instance_culling_of_stratholme::GetPlayerInMap() -{ - Map::PlayerList const& players = instance->GetPlayers(); - - if (!players.isEmpty()) - { - for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) + switch(pCreature->GetEntry()) { - if (Player* plr = itr->getSource()) - return plr; + case NPC_CHROMI01: + m_uiChromi01GUID = pCreature->GetGUID(); + break; + case NPC_CHROMI02: + m_uiChromi02GUID = pCreature->GetGUID(); + if (m_auiEncounter[0] == DONE) + pCreature->SetVisibility(VISIBILITY_ON); + else + pCreature->SetVisibility(VISIBILITY_OFF); + break; + case NPC_MIKE: + m_uiMikeGUID = pCreature->GetGUID(); + break; + case NPC_MAL_CORICS: + m_uiMalCoricsGUID = pCreature->GetGUID(); + break; + case NPC_GRIAN_STONE: + pCreature->SetStandState(UNIT_STAND_STATE_SIT_MEDIUM_CHAIR); + m_uiGrianStoneGUID = pCreature->GetGUID(); + break; + case NPC_JAMES: + pCreature->SetStandState(UNIT_STAND_STATE_SIT_MEDIUM_CHAIR); + m_uiJamesGUID = pCreature->GetGUID(); + break; + case NPC_FRAS_FRASIABI: + pCreature->SetStandState(UNIT_STAND_STATE_SIT_MEDIUM_CHAIR); + m_uiFrasCiabiGUID = pCreature->GetGUID(); + break; + case NPC_FORRESTER: + pCreature->SetStandState(UNIT_STAND_STATE_SIT_MEDIUM_CHAIR); + m_uiForrestenGUID = pCreature->GetGUID(); + break; + case NPC_ROGER: + m_uiRogerGUID = pCreature->GetGUID(); + break; + case NPC_MORIGAN: + m_uiMoriganGUID = pCreature->GetGUID(); + break; + case NPC_PERELLI: + m_uiPerelliGUID = pCreature->GetGUID(); + break; + case NPC_JENA: + m_uiJenaGUID = pCreature->GetGUID(); + break; + case NPC_MARTHA: + pCreature->CastSpell(pCreature, 58925, false); + m_uiMarthaGUID = pCreature->GetGUID(); + break; + case NPC_MALCOLM: + m_uiMalcolmGUID = pCreature->GetGUID(); + break; + case NPC_DOG: + m_uiDogGUID = pCreature->GetGUID(); + break; + case NPC_BARTLEBY: + m_uiBartlebyGUID = pCreature->GetGUID(); + break; + case NPC_UTHER: + m_uiUtherGUID = pCreature->GetGUID(); + break; + case NPC_ARTHAS: + m_uiArthasGUID = pCreature->GetGUID(); + pCreature->SetActiveObjectState(true); + break; + case NPC_JAINA: + m_uiJainaGUID = pCreature->GetGUID(); + break; + case NPC_INFINITE_CORRUPTOR: + pCreature->SetPhaseMask(0, true); + m_uiCorruptorGUID = pCreature->GetGUID(); + break; } } - return NULL; -} -void instance_culling_of_stratholme::UpdateQuestCredit() -{ - Map::PlayerList const& players = instance->GetPlayers(); - if (!players.isEmpty()) + void OnObjectCreate(GameObject* pGo) { - for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) - { - if (Player* pPlayer = itr->getSource()) - pPlayer->KilledMonsterCredit(NPC_CRATES_BUNNY, 0); - } + if (pGo->GetEntry() == GO_SHKAF_GATE) + m_uiShkafGateGUID = pGo->GetGUID(); + + if (pGo->GetEntry() == GO_MALGANIS_GATE1) + m_uiMalGate1GUID = pGo->GetGUID(); + + if (pGo->GetEntry() == GO_MALGANIS_GATE2) + m_uiMalGate2GUID = pGo->GetGUID(); + + if (pGo->GetEntry() == GO_MALGANIS_CHEST || pGo->GetEntry() == GO_MALGANIS_CHEST_H) + m_uiMalChestGUID = pGo->GetGUID(); + + if (pGo->GetEntry() == GO_EXIT) + m_uiExitGUID = pGo->GetGUID(); } -} -void instance_culling_of_stratholme::DoChromieHurrySpeech() -{ - if (Creature* pChromie = instance->GetCreature(m_uiChromieEntranceGUID)) + void ChromiWhispers() { - Map::PlayerList const& players = instance->GetPlayers(); - if (!players.isEmpty()) + Map::PlayerList const &PlayerList = instance->GetPlayers(); + + if (PlayerList.isEmpty()) + return; + + if (Creature* pChromi = instance->GetCreature(m_uiChromi01GUID)) { - for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) + for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) { - if (Player* pPlayer = itr->getSource()) - DoScriptText(SAY_CHROMIE_HURRY, pChromie, pPlayer); + pChromi->MonsterWhisper("Good work with crates! Come to me in front of Stratholme for your next assignment!", i->getSource()->GetGUID(), false); + i->getSource()->KilledMonsterCredit(30996, pChromi->GetGUID()); + i->getSource()->DestroyItemCount(ITEM_ARCANE_DISRUPTOR, 1, true); } + pChromi->SetVisibility(VISIBILITY_OFF); } + if (Creature* pChromi2 = instance->GetCreature(m_uiChromi02GUID)) + pChromi2->SetVisibility(VISIBILITY_ON); } -} -void instance_culling_of_stratholme::SetData(uint32 uiType, uint32 uiData) -{ - switch(uiType) + void SetData(uint32 uiType, uint32 uiData) { - case TYPE_GRAIN_EVENT: - m_auiEncounter[TYPE_GRAIN_EVENT] = uiData; - if (uiData == SPECIAL) - DoUpdateWorldState(WORLD_STATE_CRATES, 1); - else if (uiData == IN_PROGRESS) - { - if (m_uiGrainCrateCount >= 5) - return; - - ++m_uiGrainCrateCount; - DoUpdateWorldState(WORLD_STATE_CRATES_COUNT, m_uiGrainCrateCount); - - if (m_uiGrainCrateCount == 5) + switch(uiType) + { + case TYPE_QUEST: + m_auiEncounter[0] = uiData; + break; + case TYPE_CRATES_COUNT: + m_uiCratesCount = m_uiCratesCount + uiData; + if(m_uiCratesCount == 5) { - UpdateQuestCredit(); - m_uiRemoveCrateStateTimer = 20000; - SetData(TYPE_GRAIN_EVENT, DONE); + m_auiEncounter[0] = DONE; + ChromiWhispers(); } - } - break; - case TYPE_ARTHAS_INTRO_EVENT: - m_auiEncounter[TYPE_ARTHAS_INTRO_EVENT] = uiData; - break; - case TYPE_ARTHAS_ESCORT_EVENT: - m_auiEncounter[TYPE_ARTHAS_ESCORT_EVENT] = uiData; - break; - case TYPE_MEATHOOK_EVENT: - m_auiEncounter[TYPE_MEATHOOK_EVENT] = uiData; - if (uiData == DONE) - SetData(TYPE_SALRAMM_EVENT, IN_PROGRESS); - break; - case TYPE_SALRAMM_EVENT: - m_auiEncounter[TYPE_SALRAMM_EVENT] = uiData; - if (uiData == DONE) - DoUpdateWorldState(WORLD_STATE_WAVE, 0); // Remove WaveCounter - break; - case TYPE_EPOCH_EVENT: - m_auiEncounter[TYPE_EPOCH_EVENT] = uiData; - break; - case TYPE_MALGANIS_EVENT: - m_auiEncounter[TYPE_MALGANIS_EVENT] = uiData; - if (uiData == DONE) - { - DoRespawnGameObject(m_uiDarkRunedChestGUID, 30*MINUTE); - DoSpawnChromieIfNeeded(); - } - break; - case TYPE_INFINITE_CORRUPTER_TIME: - m_auiEncounter[TYPE_INFINITE_CORRUPTER_TIME] = uiData; - if (!uiData) - { - DoUpdateWorldState(WORLD_STATE_TIME, 0); // Remove Timer - DoUpdateWorldState(WORLD_STATE_TIME_COUNTER, 0); - } - else - DoUpdateWorldState(WORLD_STATE_TIME_COUNTER, uiData/(MINUTE*IN_MILLISECONDS)); - break; - case TYPE_INFINITE_CORRUPTER: - m_auiEncounter[TYPE_INFINITE_CORRUPTER] = uiData; - switch(uiData) - { - case IN_PROGRESS: - if (!m_auiEncounter[TYPE_INFINITE_CORRUPTER_TIME]) - SetData(TYPE_INFINITE_CORRUPTER_TIME, MINUTE*25*IN_MILLISECONDS); - DoUpdateWorldState(WORLD_STATE_TIME, 1);// Show Timer - break; - case DONE: - SetData(TYPE_INFINITE_CORRUPTER_TIME, 0); - break; - case SPECIAL: - DoChromieHurrySpeech(); - break; - case FAIL: - SetData(TYPE_INFINITE_CORRUPTER_TIME, 0); - if (Creature* pCorrupter = instance->GetCreature(m_uiCorrupterGUID)) - if (pCorrupter->isAlive()) - pCorrupter->ForcedDespawn(); - break; - } - break; + DoUpdateWorldState(WORLD_STATE_COS_CRATE_COUNT, m_uiCratesCount); + break; + case TYPE_INTRO: + m_auiEncounter[1] = uiData; + break; + case TYPE_PHASE: + m_auiEncounter[2] = uiData; + break; + case TYPE_ENCOUNTER: + m_auiEncounter[3] = uiData; + break; + case TYPE_WING: + m_auiEncounter[4] = uiData; + break; + case TYPE_BONUS: + m_auiEncounter[5] = uiData; + if(uiData == IN_PROGRESS) + { + if(Creature* Corruptor = instance->GetCreature(m_uiCorruptorGUID)) + Corruptor->SetPhaseMask(1, true); + DoUpdateWorldState(WORLD_STATE_COS_TIME_ON, 1); + DoUpdateWorldState(WORLD_STATE_COS_TIME_COUNT, 25); + } + break; + case TYPE_MALGANIS: + m_auiEncounter[6] = uiData; + if (uiData == DONE) + { + DoRespawnGameObject(m_uiMalChestGUID, 30*MINUTE); + if (GameObject* pGo = instance->GetGameObject(m_uiMalChestGUID)) + pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); + if (Creature* pChromi2 = instance->GetCreature(m_uiChromi02GUID)) + pChromi2->SetVisibility(VISIBILITY_OFF); + } + break; + } } - if (uiData == DONE || (uiType == TYPE_INFINITE_CORRUPTER && uiData == FAIL)) + void SetData64(uint32 uiData, uint64 uiGuid) { - OUT_SAVE_INST_DATA; - - std::ostringstream saveStream; - saveStream << m_auiEncounter[0] << " " << m_auiEncounter[1] << " " << m_auiEncounter[2] << " " - << m_auiEncounter[3] << " " << m_auiEncounter[4] << " " << m_auiEncounter[5] << " " - << m_auiEncounter[6] << " " << m_auiEncounter[7] << " " << m_auiEncounter[8]; - - strInstData = saveStream.str(); - - SaveToDB(); - OUT_SAVE_INST_DATA_COMPLETE; + switch(uiData) + { + case NPC_SALRAMM: + m_uiSalrammGUID = uiGuid; + break; + case NPC_MALGANIS: + m_uiMalganisGUID = uiGuid; + break; + } } -} -void instance_culling_of_stratholme::Load(const char* chrIn) -{ - if (!chrIn) + uint32 GetData(uint32 uiType) { - OUT_LOAD_INST_DATA_FAIL; - return; - } - - OUT_LOAD_INST_DATA(chrIn); - - std::istringstream loadStream(chrIn); - loadStream >> m_auiEncounter[0] >> m_auiEncounter[1] >> m_auiEncounter[2] >> m_auiEncounter[3] - >> m_auiEncounter[4] >> m_auiEncounter[5] >> m_auiEncounter[6] >> m_auiEncounter[7] >> m_auiEncounter[8]; - - for(uint8 i = 0; i < MAX_ENCOUNTER; ++i) - if (i != TYPE_INFINITE_CORRUPTER_TIME) - if (m_auiEncounter[i] == IN_PROGRESS) - m_auiEncounter[i] = NOT_STARTED; - - // If already started counting down time, the event is "in progress" - if (m_auiEncounter[TYPE_INFINITE_CORRUPTER_TIME]) - m_auiEncounter[TYPE_INFINITE_CORRUPTER] = IN_PROGRESS; - - OUT_LOAD_INST_DATA_COMPLETE; -} - -void instance_culling_of_stratholme::OnPlayerEnter(Player* pPlayer) -{ - if (instance->GetPlayersCountExceptGMs() == 0) - { - DoSpawnArthasIfNeeded(); - DoSpawnChromieIfNeeded(); - - // Show World States if needed, TODO verify if needed and if this is the right way - if (m_auiEncounter[TYPE_GRAIN_EVENT] == IN_PROGRESS || m_auiEncounter[TYPE_GRAIN_EVENT] == SPECIAL) - DoUpdateWorldState(WORLD_STATE_CRATES, 1); // Show Crates Counter - else - DoUpdateWorldState(WORLD_STATE_CRATES, 0); // Remove Crates Counter - - if (m_auiEncounter[TYPE_MEATHOOK_EVENT] == IN_PROGRESS) - DoUpdateWorldState(WORLD_STATE_WAVE, 1); // Add WaveCounter - else if (m_auiEncounter[TYPE_SALRAMM_EVENT] == IN_PROGRESS) - DoUpdateWorldState(WORLD_STATE_WAVE, 6); // Add WaveCounter - else - DoUpdateWorldState(WORLD_STATE_WAVE, 0); // Remove WaveCounter - - if (m_auiEncounter[TYPE_INFINITE_CORRUPTER_TIME]) - DoUpdateWorldState(WORLD_STATE_TIME, 1); // Show Timer - else - DoUpdateWorldState(WORLD_STATE_TIME, 0); // Remove Timer - } -} - -uint32 instance_culling_of_stratholme::GetData(uint32 uiType) -{ - switch(uiType) - { - case TYPE_GRAIN_EVENT: return m_auiEncounter[0]; - case TYPE_ARTHAS_INTRO_EVENT: return m_auiEncounter[1]; - case TYPE_MEATHOOK_EVENT: return m_auiEncounter[2]; - case TYPE_SALRAMM_EVENT: return m_auiEncounter[3]; - case TYPE_EPOCH_EVENT: return m_auiEncounter[4]; - case TYPE_ARTHAS_ESCORT_EVENT: return m_auiEncounter[5]; - case TYPE_MALGANIS_EVENT: return m_auiEncounter[6]; - case TYPE_INFINITE_CORRUPTER_TIME: return m_auiEncounter[7]; - case TYPE_INFINITE_CORRUPTER: return m_auiEncounter[8]; - } - return 0; -} - -uint64 instance_culling_of_stratholme::GetData64(uint32 uiData) -{ - switch(uiData) - { - case NPC_CHROMIE_INN: return m_uiChromieInnGUID; - case NPC_CHROMIE_ENTRANCE: return m_uiChromieEntranceGUID; - case NPC_CHROMIE_END: return m_uiChromieEndGUID; - case NPC_HOURGLASS: return m_uiHourglassGUID; - case NPC_ARTHAS: return m_uiArthasGUID; - case NPC_MEATHOOK: return m_uiMeathookGUID; - case NPC_SALRAMM_THE_FLESHCRAFTER: return m_uiSalrammGUID; - case NPC_CHRONO_LORD_EPOCH: return m_uiEpochGUID; - case NPC_MALGANIS: return m_uiMalganisGUID; - case NPC_INFINITE_CORRUPTER: return m_uiCorrupterGUID; - case NPC_MICHAEL_BELFAST: return m_uiBelfastGUID; - case NPC_HEARTHSINGER_FORRESTEN: return m_uiForrestenGUID; - case NPC_FRAS_SIABI: return m_uiSiabiGUID; - case NPC_FOOTMAN_JAMES: return m_uiJamesGUID; - case NPC_MAL_CORRICKS: return m_uiCorricksGUID; - case NPC_GRYAN_STOUTMANTLE: return m_uiStoutmantleGUID; - case NPC_ROGER_OWENS: return m_uiOwensGUID; - case NPC_SERGEANT_MORIGAN: return m_uiMoriganGUID; - case NPC_JENA_ANDERSON: return m_uiAndersonGUID; - case NPC_MALCOM_MOORE: return m_uiMooreGUID; - case NPC_BARTLEBY_BATTSON: return m_uiBattsonGUID; - case NPC_PATRICIA_O_REILLY: return m_uiOReillyGUID; - case GO_DOOR_BOOKCASE: return m_uiDoorBookcaseGUID; - } - return 0; -} - -uint8 instance_culling_of_stratholme::GetInstancePosition() -{ - if (m_auiEncounter[TYPE_MALGANIS_EVENT] == DONE) - return POS_INSTANCE_FINISHED; - else if (m_auiEncounter[TYPE_ARTHAS_ESCORT_EVENT] == DONE) - return POS_ARTHAS_MALGANIS; - else if (m_auiEncounter[TYPE_EPOCH_EVENT] == DONE) - return POS_ARTHAS_ESCORTING; - else if (m_auiEncounter[TYPE_SALRAMM_EVENT] == DONE) - return POS_ARTHAS_TOWNHALL; - else if (m_auiEncounter[TYPE_MEATHOOK_EVENT] == DONE) - return POS_ARTHAS_WAVES; - else if (m_auiEncounter[TYPE_ARTHAS_INTRO_EVENT] == DONE) - return POS_ARTHAS_WAVES; - else if (m_auiEncounter[TYPE_GRAIN_EVENT] == DONE) - return POS_ARTHAS_INTRO; - else + switch(uiType) + { + case TYPE_QUEST: + return m_auiEncounter[0]; + case TYPE_INTRO: + return m_auiEncounter[1]; + case TYPE_PHASE: + return m_auiEncounter[2]; + case TYPE_ENCOUNTER: + return m_auiEncounter[3]; + case TYPE_WING: + return m_auiEncounter[4]; + case TYPE_BONUS: + return m_auiEncounter[5]; + case TYPE_MALGANIS: + return m_auiEncounter[6]; + } return 0; -} - -static bool sortFromEastToWest(Creature* pFirst, Creature* pSecond) -{ - return pFirst && pSecond && pFirst->GetPositionY() < pSecond->GetPositionY(); -} - -static bool sortFromSouthToNorth(Creature* pFirst, Creature* pSecond) -{ - return pFirst && pSecond && pFirst->GetPositionX() < pSecond->GetPositionX(); -} - -void instance_culling_of_stratholme::GetCratesBunnyOrderedList(std::list &lList) -{ - m_lCratesBunnyList.sort(sortFromEastToWest); - lList = m_lCratesBunnyList; -} - -Creature* instance_culling_of_stratholme::GetStratIntroFootman() -{ - m_lFootmanList.sort(sortFromSouthToNorth); - if (m_lFootmanList.empty()) - return NULL; - else - return *m_lFootmanList.begin(); -} - -void instance_culling_of_stratholme::GetResidentOrderedList(std::list &lList) -{ - m_lResidentList.sort(sortFromSouthToNorth); - lList = m_lResidentList; -} - -void instance_culling_of_stratholme::ArthasJustDied() -{ - m_uiArthasRespawnTimer = 10000; // TODO, could be instant -} - -void instance_culling_of_stratholme::DoSpawnArthasIfNeeded() -{ - Creature* pArthas = instance->GetCreature(m_uiArthasGUID); - if (pArthas && pArthas->isAlive()) - return; - - uint8 uiPosition = GetInstancePosition(); - if (uiPosition && uiPosition <= MAX_ARTHAS_SPAWN_POS) - if (Player* pPlayer = GetPlayerInMap()) - pPlayer->SummonCreature(NPC_ARTHAS, m_aArthasSpawnLocs[uiPosition-1].m_fX, m_aArthasSpawnLocs[uiPosition-1].m_fY, m_aArthasSpawnLocs[uiPosition-1].m_fZ, m_aArthasSpawnLocs[uiPosition-1].m_fO, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000); -} - -// Atm here only new Chromies are spawned - despawning depends on Mangos featuring such a thing -// The hourglass also is not yet spawned/ relocated. -void instance_culling_of_stratholme::DoSpawnChromieIfNeeded() -{ - Player* pPlayer = GetPlayerInMap(); - if (!pPlayer) - return; - - if (GetInstancePosition() == POS_INSTANCE_FINISHED) - { - Creature* pChromie = instance->GetCreature(m_uiChromieEndGUID); - if (!pChromie) - pPlayer->SummonCreature(NPC_CHROMIE_END, m_aChromieSpawnLocs[1].m_fX, m_aChromieSpawnLocs[1].m_fY, m_aChromieSpawnLocs[1].m_fZ, m_aChromieSpawnLocs[1].m_fO, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000); } - else if (GetInstancePosition() >= POS_ARTHAS_INTRO) + + uint64 GetData64(uint32 uiData) { - Creature* pChromie = instance->GetCreature(m_uiChromieEntranceGUID); - if (!pChromie) - pPlayer->SummonCreature(NPC_CHROMIE_ENTRANCE, m_aChromieSpawnLocs[0].m_fX, m_aChromieSpawnLocs[0].m_fY, m_aChromieSpawnLocs[0].m_fZ, m_aChromieSpawnLocs[0].m_fO, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000); - } -} - -void instance_culling_of_stratholme::Update(uint32 uiDiff) -{ - // 25min Run - decrease time, update worldstate every ~20s - // as the time is always saved by m_auiEncounter[TYPE_INFINITE_CORRUPTER_TIME], there is no need for an extra timer - if (m_auiEncounter[TYPE_INFINITE_CORRUPTER_TIME]) - { - if (m_auiEncounter[TYPE_INFINITE_CORRUPTER_TIME] <= uiDiff) - SetData(TYPE_INFINITE_CORRUPTER, FAIL); - else + switch(uiData) { - m_auiEncounter[TYPE_INFINITE_CORRUPTER_TIME] -= uiDiff; - if (m_auiEncounter[TYPE_INFINITE_CORRUPTER_TIME]/IN_MILLISECONDS % 20 == 0) - SetData(TYPE_INFINITE_CORRUPTER_TIME, m_auiEncounter[TYPE_INFINITE_CORRUPTER_TIME]); + case NPC_FORRESTER: return m_uiForrestenGUID; + case NPC_JAMES: return m_uiJamesGUID; + case NPC_FRAS_FRASIABI: return m_uiFrasCiabiGUID; + case NPC_MAL_CORICS: return m_uiMalCoricsGUID; + case NPC_GRIAN_STONE: return m_uiGrianStoneGUID; + case NPC_ROGER: return m_uiRogerGUID; + case NPC_MORIGAN: return m_uiMoriganGUID; + case NPC_PERELLI: return m_uiPerelliGUID; + case NPC_JENA: return m_uiJenaGUID; + case NPC_MARTHA: return m_uiMarthaGUID; + case NPC_MALCOLM: return m_uiMalcolmGUID; + case NPC_DOG: return m_uiDogGUID; + case NPC_BARTLEBY: return m_uiBartlebyGUID; + case NPC_UTHER: return m_uiUtherGUID; + case NPC_ARTHAS: return m_uiArthasGUID; + case NPC_JAINA: return m_uiJainaGUID; + case NPC_SALRAMM: return m_uiSalrammGUID; + case NPC_MALGANIS: return m_uiMalganisGUID; + case GO_SHKAF_GATE: return m_uiShkafGateGUID; + case GO_MALGANIS_GATE1: return m_uiMalGate1GUID; + case GO_MALGANIS_GATE2: return m_uiMalGate2GUID; + case GO_MALGANIS_CHEST: return m_uiMalChestGUID; + case GO_EXIT: return m_uiExitGUID; } - // This part is needed for a small "hurry up guys" note, TODO, verify 20min - if (m_auiEncounter[TYPE_INFINITE_CORRUPTER] == IN_PROGRESS && m_auiEncounter[TYPE_INFINITE_CORRUPTER_TIME] <= 24*MINUTE*IN_MILLISECONDS) - SetData(TYPE_INFINITE_CORRUPTER, SPECIAL); + return 0; } - // Small Timer, to remove Grain-Crate WorldState and Spawn Second Chromie - if (m_uiRemoveCrateStateTimer) - if (m_uiRemoveCrateStateTimer <= uiDiff) - { - DoUpdateWorldState(WORLD_STATE_CRATES, 0); - DoSpawnChromieIfNeeded(); - m_uiRemoveCrateStateTimer = 0; - } - else - m_uiRemoveCrateStateTimer -= uiDiff; + void Update(uint32 uiDiff) + { + if(m_auiEncounter[5] == IN_PROGRESS) + { + if(m_uiHeroicTimer < uiDiff) + { + m_auiEncounter[5] = FAIL; + DoUpdateWorldState(WORLD_STATE_COS_TIME_ON, 0); + if(Creature* Corruptor = instance->GetCreature(m_uiCorruptorGUID)) + Corruptor->SetPhaseMask(0, true); - // Respawn Arthas after some time - if (m_uiArthasRespawnTimer) - if (m_uiArthasRespawnTimer <= uiDiff) - { - DoSpawnArthasIfNeeded(); - m_uiArthasRespawnTimer = 0; - } - else - m_uiArthasRespawnTimer -= uiDiff; -} + }else m_uiHeroicTimer -= uiDiff; + if(m_uiHeroicTimer < m_uiLastTimer - 60000) + { + m_uiLastTimer = m_uiHeroicTimer; + uint32 tMinutes = m_uiHeroicTimer / 60000; + DoUpdateWorldState(WORLD_STATE_COS_TIME_COUNT, tMinutes); + } + } + + return; + } +}; + InstanceData* GetInstanceData_instance_culling_of_stratholme(Map* pMap) { return new instance_culling_of_stratholme(pMap); @@ -538,10 +355,9 @@ void AddSC_instance_culling_of_stratholme() { - Script* pNewScript; - - pNewScript = new Script; - pNewScript->Name = "instance_culling_of_stratholme"; - pNewScript->GetInstanceData = &GetInstanceData_instance_culling_of_stratholme; - pNewScript->RegisterSelf(); + Script *newscript; + newscript = new Script; + newscript->Name = "instance_culling_of_stratholme"; + newscript->GetInstanceData = &GetInstanceData_instance_culling_of_stratholme; + newscript->RegisterSelf(); } Index: scripts/kalimdor/caverns_of_time/culling_of_stratholme/trash_culling_of_stratholme.cpp =================================================================== --- scripts/kalimdor/caverns_of_time/culling_of_stratholme/trash_culling_of_stratholme.cpp (revision 0) +++ scripts/kalimdor/caverns_of_time/culling_of_stratholme/trash_culling_of_stratholme.cpp (revision 0) @@ -0,0 +1,1064 @@ +#include "precompiled.h" +#include "culling_of_stratholme.h" + +/*### +## npc_cs_gnoul +###*/ + +enum +{ + SPELL_FLESH = 52352 +}; + +struct MANGOS_DLL_DECL npc_cs_gnoulAI : public ScriptedAI +{ + npc_cs_gnoulAI(Creature *pCreature) : ScriptedAI(pCreature) + { + m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); + m_bIsHeroic = pCreature->GetMap()->IsRaidOrHeroicDungeon(); + Reset(); + } + + ScriptedInstance* m_pInstance; + bool m_bIsHeroic; + + uint32 m_uiFleshTimer; + + uint32 WaypointId; + uint32 MoveTimer; + + void Reset() + { + m_creature->RemoveSplineFlag(SPLINEFLAG_WALKMODE); + MoveTimer = (urand(100, 5000)); + m_uiFleshTimer = (urand(3000, 10000)); + WaypointId = 1; + } + + void MoveToPoint(float X, float Y, float Z) + { + m_creature->GetMotionMaster()->MovementExpired(false); + m_creature->GetMotionMaster()->MovePoint(0, X, Y, Z); + } + + void AttackStart(Unit* pWho) + { + if (!pWho) + return; + + if (m_creature->Attack(pWho, true)) + { + m_creature->AddThreat(pWho); + m_creature->SetInCombatWith(pWho); + pWho->SetInCombatWith(m_creature); + + if (IsCombatMovement()) + m_creature->GetMotionMaster()->MoveChase(pWho); + } + } + + void EnterEvadeMode() + { + m_creature->RemoveAllAuras(); + m_creature->DeleteThreatList(); + m_creature->CombatStop(true); + m_creature->LoadCreaturesAddon(); + m_uiFleshTimer = (urand(3000, 10000)); + + m_creature->SetLootRecipient(NULL); + } + + void MoveInLineOfSight(Unit* pWho) + { + if (!pWho) + return; + + if (!m_creature->hasUnitState(UNIT_STAT_STUNNED) && pWho->isTargetableForAttack() && + m_creature->IsHostileTo(pWho) && pWho->isInAccessablePlaceFor(m_creature)) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(pWho) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(pWho); + if (m_creature->IsWithinDistInMap(pWho, attackRadius) && m_creature->IsWithinLOSInMap(pWho)) + { + if (!m_creature->getVictim()) + { + AttackStart(pWho); + pWho->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + } + else if (m_creature->GetMap()->IsDungeon()) + { + pWho->SetInCombatWith(m_creature); + m_creature->AddThreat(pWho, 0.0f); + } + } + } + } + + void JumpNextStep(uint32 Time) + { + MoveTimer = Time; + WaypointId++; + } + + void UpdateAI(const uint32 uiDiff) + { + if (!m_creature->SelectHostileTarget() || !m_creature->getVictim() && m_creature->isTemporarySummon()) + { + if(MoveTimer < uiDiff) + { + if(m_pInstance->GetData(TYPE_WING) == RIGHT) + { + switch(WaypointId) + { + case 1: + MoveToPoint(2356.659f, 1185.501f, 130.636f); + JumpNextStep(10000); + break; + case 2: + MoveToPoint(2301.735f, 1179.265f, 136.944f); + JumpNextStep(8000); + break; + case 3: + MoveToPoint(2234.787f, 1180.638f, 136.344f); + JumpNextStep(9000); + break; + case 4: + MoveToPoint(2178.313f, 1244.350f, 136.107f); + JumpNextStep(12000); + break; + case 5: + MoveToPoint(2163.553f, 1277.814f, 133.444f); + JumpNextStep(5000); + break; + case 6: + MoveToPoint(2083.952f, 1287.716f, 141.146f); + JumpNextStep(5000); + break; + } + } + + if(m_pInstance->GetData(TYPE_WING) == LEFT) + { + switch(WaypointId) + { + case 1: + MoveToPoint(2188.318f, 1331.410f, 130.003f); + JumpNextStep(10000); + break; + case 2: + MoveToPoint(2165.351f, 1279.156f, 133.388f); + JumpNextStep(8000); + break; + case 3: + MoveToPoint(2083.952f, 1287.716f, 141.146f); + JumpNextStep(9000); + break; + } + } + + } else MoveTimer -= uiDiff; + } + + if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) + return; + + if(m_uiFleshTimer < uiDiff) + { + DoCast(m_creature->getVictim(), SPELL_FLESH); + m_uiFleshTimer = (urand(3000, 10000)); + } + else m_uiFleshTimer -= uiDiff; + + DoMeleeAttackIfReady(); + + return; + } +}; + +/*### +## npc_cs_necromancer +###*/ + +enum +{ + SPELL_SHADOW_BOLT = 15472, + SPELL_COURSE = 20812, + SPELL_DRAIN_MANA = 58770 +}; + +struct MANGOS_DLL_DECL npc_cs_necromancerAI : public ScriptedAI +{ + npc_cs_necromancerAI(Creature *pCreature) : ScriptedAI(pCreature) + { + m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); + m_bIsHeroic = pCreature->GetMap()->IsRaidOrHeroicDungeon(); + SetCombatMovement(false); + Reset(); + } + + ScriptedInstance* m_pInstance; + bool m_bIsHeroic; + + uint32 m_uiShadowBoltTimer; + uint32 m_uiCourseTimer; + + uint32 WaypointId; + uint32 MoveTimer; + + void Reset() + { + m_creature->RemoveSplineFlag(SPLINEFLAG_WALKMODE); + MoveTimer = (urand(100, 5000)); + m_uiCourseTimer = (urand(7000, 17000)); + m_uiShadowBoltTimer = (urand(3000, 10000)); + WaypointId = 1; + } + + void Aggro(Unit* pWho) + { + m_creature->GetMotionMaster()->MovementExpired(false); + m_creature->StopMoving(); + } + + void MoveToPoint(float X, float Y, float Z) + { + m_creature->GetMotionMaster()->MovementExpired(false); + m_creature->GetMotionMaster()->MovePoint(0, X, Y, Z); + } + + void AttackStart(Unit* pWho) + { + if (!pWho) + return; + + if (m_creature->Attack(pWho, true)) + { + m_creature->AddThreat(pWho); + m_creature->SetInCombatWith(pWho); + pWho->SetInCombatWith(m_creature); + } + m_creature->GetMotionMaster()->MovementExpired(false); + } + + void EnterEvadeMode() + { + m_creature->RemoveAllAuras(); + m_creature->DeleteThreatList(); + m_creature->CombatStop(true); + m_creature->LoadCreaturesAddon(); + m_uiShadowBoltTimer = (urand(3000, 10000)); + m_uiCourseTimer = (urand(7000, 17000)); + + m_creature->SetLootRecipient(NULL); + } + + void MoveInLineOfSight(Unit* pWho) + { + if (!pWho) + return; + + if (!m_creature->hasUnitState(UNIT_STAT_STUNNED) && pWho->isTargetableForAttack() && + m_creature->IsHostileTo(pWho) && pWho->isInAccessablePlaceFor(m_creature)) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(pWho) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(pWho); + if (m_creature->IsWithinDistInMap(pWho, attackRadius) && m_creature->IsWithinLOSInMap(pWho)) + { + if (!m_creature->getVictim()) + { + AttackStart(pWho); + pWho->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + } + else if (m_creature->GetMap()->IsDungeon()) + { + pWho->SetInCombatWith(m_creature); + m_creature->AddThreat(pWho, 0.0f); + } + } + } + } + + void JumpNextStep(uint32 Time) + { + MoveTimer = Time; + WaypointId++; + } + + void UpdateAI(const uint32 uiDiff) + { + if (!m_creature->SelectHostileTarget() || !m_creature->getVictim() && m_creature->isTemporarySummon()) + { + if(MoveTimer < uiDiff) + { + if(m_pInstance->GetData(TYPE_WING) == RIGHT) + { + switch(WaypointId) + { + case 1: + MoveToPoint(2356.659f, 1185.501f, 130.636f); + JumpNextStep(10000); + break; + case 2: + MoveToPoint(2301.735f, 1179.265f, 136.944f); + JumpNextStep(8000); + break; + case 3: + MoveToPoint(2234.787f, 1180.638f, 136.344f); + JumpNextStep(9000); + break; + case 4: + MoveToPoint(2178.313f, 1244.350f, 136.107f); + JumpNextStep(12000); + break; + case 5: + MoveToPoint(2163.553f, 1277.814f, 133.444f); + JumpNextStep(5000); + break; + case 6: + MoveToPoint(2083.952f, 1287.716f, 141.146f); + JumpNextStep(5000); + break; + } + } + + if(m_pInstance->GetData(TYPE_WING) == LEFT) + { + switch(WaypointId) + { + case 1: + MoveToPoint(2188.318f, 1331.410f, 130.003f); + JumpNextStep(10000); + break; + case 2: + MoveToPoint(2165.351f, 1279.156f, 133.388f); + JumpNextStep(8000); + break; + case 3: + MoveToPoint(2083.952f, 1287.716f, 141.146f); + JumpNextStep(9000); + break; + } + } + + } else MoveTimer -= uiDiff; + } + + if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) + return; + + if(m_uiShadowBoltTimer < uiDiff) + { + DoCast(m_creature->getVictim(), SPELL_SHADOW_BOLT); + m_uiShadowBoltTimer = (urand(3000, 5000)); + } + else m_uiShadowBoltTimer -= uiDiff; + + if(m_uiCourseTimer < uiDiff) + { + m_creature->InterruptNonMeleeSpells(false); + if(Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0)) + DoCast(target, SPELL_COURSE); + m_uiCourseTimer = (urand(7000, 17000)); + } + else m_uiCourseTimer -= uiDiff; + + DoMeleeAttackIfReady(); + + return; + } +}; + +/*### +## npc_cs_field +###*/ + +enum +{ + SPELL_BLOW = 52491, + SPELL_SCARAB = 52496 +}; + +struct MANGOS_DLL_DECL npc_cs_fieldAI : public ScriptedAI +{ + npc_cs_fieldAI(Creature *pCreature) : ScriptedAI(pCreature) + { + m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); + m_bIsHeroic = pCreature->GetMap()->IsRaidOrHeroicDungeon(); + Reset(); + } + + ScriptedInstance* m_pInstance; + bool m_bIsHeroic; + + uint32 m_uiScarabTimer; + uint32 m_uiBlowTimer; + + uint32 WaypointId; + uint32 MoveTimer; + + void Reset() + { + m_creature->RemoveSplineFlag(SPLINEFLAG_WALKMODE); + MoveTimer = (urand(100, 5000)); + m_uiBlowTimer = (urand(7000, 17000)); + m_uiScarabTimer = (urand(3000, 10000)); + WaypointId = 1; + } + + void MoveToPoint(float X, float Y, float Z) + { + m_creature->GetMotionMaster()->MovementExpired(false); + m_creature->GetMotionMaster()->MovePoint(0, X, Y, Z); + } + + void AttackStart(Unit* pWho) + { + if (!pWho) + return; + + if (m_creature->Attack(pWho, true)) + { + m_creature->AddThreat(pWho); + m_creature->SetInCombatWith(pWho); + pWho->SetInCombatWith(m_creature); + + if (IsCombatMovement()) + m_creature->GetMotionMaster()->MoveChase(pWho); + } + } + + void EnterEvadeMode() + { + m_creature->RemoveAllAuras(); + m_creature->DeleteThreatList(); + m_creature->CombatStop(true); + m_creature->LoadCreaturesAddon(); + m_uiScarabTimer = (urand(3000, 10000)); + m_uiBlowTimer = (urand(7000, 17000)); + + m_creature->SetLootRecipient(NULL); + } + + void MoveInLineOfSight(Unit* pWho) + { + if (!pWho) + return; + + if (!m_creature->hasUnitState(UNIT_STAT_STUNNED) && pWho->isTargetableForAttack() && + m_creature->IsHostileTo(pWho) && pWho->isInAccessablePlaceFor(m_creature)) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(pWho) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(pWho); + if (m_creature->IsWithinDistInMap(pWho, attackRadius) && m_creature->IsWithinLOSInMap(pWho)) + { + if (!m_creature->getVictim()) + { + AttackStart(pWho); + pWho->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + } + else if (m_creature->GetMap()->IsDungeon()) + { + pWho->SetInCombatWith(m_creature); + m_creature->AddThreat(pWho, 0.0f); + } + } + } + } + + void JumpNextStep(uint32 Time) + { + MoveTimer = Time; + WaypointId++; + } + + void UpdateAI(const uint32 uiDiff) + { + if (!m_creature->SelectHostileTarget() || !m_creature->getVictim() && m_creature->isTemporarySummon()) + { + if(MoveTimer < uiDiff) + { + if(m_pInstance->GetData(TYPE_WING) == RIGHT) + { + switch(WaypointId) + { + case 1: + MoveToPoint(2356.659f, 1185.501f, 130.636f); + JumpNextStep(10000); + break; + case 2: + MoveToPoint(2301.735f, 1179.265f, 136.944f); + JumpNextStep(8000); + break; + case 3: + MoveToPoint(2234.787f, 1180.638f, 136.344f); + JumpNextStep(9000); + break; + case 4: + MoveToPoint(2178.313f, 1244.350f, 136.107f); + JumpNextStep(12000); + break; + case 5: + MoveToPoint(2163.553f, 1277.814f, 133.444f); + JumpNextStep(5000); + break; + case 6: + MoveToPoint(2083.952f, 1287.716f, 141.146f); + JumpNextStep(5000); + break; + } + } + + if(m_pInstance->GetData(TYPE_WING) == LEFT) + { + switch(WaypointId) + { + case 1: + MoveToPoint(2188.318f, 1331.410f, 130.003f); + JumpNextStep(10000); + break; + case 2: + MoveToPoint(2165.351f, 1279.156f, 133.388f); + JumpNextStep(8000); + break; + case 3: + MoveToPoint(2083.952f, 1287.716f, 141.146f); + JumpNextStep(9000); + break; + } + } + + } else MoveTimer -= uiDiff; + } + + if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) + return; + + if(m_uiScarabTimer < uiDiff) + { + if(Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0)) + DoCast(target, SPELL_SCARAB); + m_uiScarabTimer = (urand(3000, 5000)); + } + else m_uiScarabTimer -= uiDiff; + + if(m_uiBlowTimer < uiDiff) + { + m_creature->InterruptNonMeleeSpells(false); + if(Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0)) + DoCast(target, SPELL_BLOW); + m_uiBlowTimer = (urand(7000, 17000)); + } + else m_uiBlowTimer -= uiDiff; + + DoMeleeAttackIfReady(); + + return; + } +}; + +/*### +## npc_cs_alocyte +###*/ + +enum +{ + SPELL_SHADOW = 17234, + SPELL_COLD = 15244, + SPELL_FIRE = 14145, + SPELL_COURSEA = 39621 +}; + +struct MANGOS_DLL_DECL npc_cs_acolyteAI : public ScriptedAI +{ + npc_cs_acolyteAI(Creature *pCreature) : ScriptedAI(pCreature) + { + m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); + m_bIsHeroic = pCreature->GetMap()->IsRaidOrHeroicDungeon(); + SetCombatMovement(false); + Reset(); + } + + ScriptedInstance* m_pInstance; + bool m_bIsHeroic; + + uint32 m_uiColdTimer; + uint32 m_uiFireTimer; + uint32 m_uiCourseTimer; + uint32 m_uiShadowTimer; + + uint32 WaypointId; + uint32 MoveTimer; + + void Reset() + { + m_creature->RemoveSplineFlag(SPLINEFLAG_WALKMODE); + MoveTimer = (urand(100, 5000)); + m_uiColdTimer = (urand(7000, 17000)); + m_uiFireTimer = (urand(3000, 10000)); + m_uiCourseTimer = (urand(5000, 12000)); + m_uiShadowTimer = (urand(1000, 3000)); + WaypointId = 1; + } + + void MoveToPoint(float X, float Y, float Z) + { + m_creature->GetMotionMaster()->MovementExpired(false); + m_creature->GetMotionMaster()->MovePoint(0, X, Y, Z); + } + + void Aggro(Unit* pWho) + { + m_creature->GetMotionMaster()->MovementExpired(false); + m_creature->StopMoving(); + } + + void AttackStart(Unit* pWho) + { + if (!pWho) + return; + + if (m_creature->Attack(pWho, true)) + { + m_creature->AddThreat(pWho); + m_creature->SetInCombatWith(pWho); + pWho->SetInCombatWith(m_creature); + } + m_creature->GetMotionMaster()->MovementExpired(false); + } + + void EnterEvadeMode() + { + m_creature->RemoveAllAuras(); + m_creature->DeleteThreatList(); + m_creature->CombatStop(true); + m_creature->LoadCreaturesAddon(); + m_uiColdTimer = (urand(7000, 17000)); + m_uiFireTimer = (urand(3000, 10000)); + m_uiCourseTimer = (urand(5000, 12000)); + m_uiShadowTimer = (urand(1000, 3000)); + + m_creature->SetLootRecipient(NULL); + } + + void MoveInLineOfSight(Unit* pWho) + { + if (!pWho) + return; + + if (!m_creature->hasUnitState(UNIT_STAT_STUNNED) && pWho->isTargetableForAttack() && + m_creature->IsHostileTo(pWho) && pWho->isInAccessablePlaceFor(m_creature)) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(pWho) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(pWho); + if (m_creature->IsWithinDistInMap(pWho, attackRadius) && m_creature->IsWithinLOSInMap(pWho)) + { + if (!m_creature->getVictim()) + { + AttackStart(pWho); + pWho->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + } + else if (m_creature->GetMap()->IsDungeon()) + { + pWho->SetInCombatWith(m_creature); + m_creature->AddThreat(pWho, 0.0f); + } + } + } + } + + void JumpNextStep(uint32 Time) + { + MoveTimer = Time; + WaypointId++; + } + + void UpdateAI(const uint32 uiDiff) + { + if (!m_creature->SelectHostileTarget() || !m_creature->getVictim() && m_creature->isTemporarySummon()) + { + if(MoveTimer < uiDiff) + { + if(m_pInstance->GetData(TYPE_WING) == RIGHT) + { + switch(WaypointId) + { + case 1: + MoveToPoint(2356.659f, 1185.501f, 130.636f); + JumpNextStep(10000); + break; + case 2: + MoveToPoint(2301.735f, 1179.265f, 136.944f); + JumpNextStep(8000); + break; + case 3: + MoveToPoint(2234.787f, 1180.638f, 136.344f); + JumpNextStep(9000); + break; + case 4: + MoveToPoint(2178.313f, 1244.350f, 136.107f); + JumpNextStep(12000); + break; + case 5: + MoveToPoint(2163.553f, 1277.814f, 133.444f); + JumpNextStep(5000); + break; + case 6: + MoveToPoint(2083.952f, 1287.716f, 141.146f); + JumpNextStep(5000); + break; + } + } + + if(m_pInstance->GetData(TYPE_WING) == LEFT) + { + switch(WaypointId) + { + case 1: + MoveToPoint(2188.318f, 1331.410f, 130.003f); + JumpNextStep(10000); + break; + case 2: + MoveToPoint(2165.351f, 1279.156f, 133.388f); + JumpNextStep(8000); + break; + case 3: + MoveToPoint(2083.952f, 1287.716f, 141.146f); + JumpNextStep(9000); + break; + } + } + + } else MoveTimer -= uiDiff; + } + + if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) + return; + + if(m_uiShadowTimer < uiDiff) + { + DoCast(m_creature->getVictim(), SPELL_SHADOW); + m_uiShadowTimer = (urand(3000, 8000)); + } + else m_uiShadowTimer -= uiDiff; + + if(m_uiCourseTimer < uiDiff) + { + if(Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0)) + DoCast(target, SPELL_COURSEA); + m_uiCourseTimer = (urand(7000, 13000)); + } + else m_uiCourseTimer -= uiDiff; + + if(m_uiColdTimer < uiDiff) + { + if(Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0)) + DoCast(target, SPELL_COLD); + m_uiColdTimer = (urand(13000, 17000)); + } + else m_uiColdTimer -= uiDiff; + + if(m_uiFireTimer < uiDiff) + { + if(Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0)) + DoCast(target, SPELL_FIRE); + m_uiFireTimer = (urand(6000, 11000)); + } + else m_uiFireTimer -= uiDiff; + + DoMeleeAttackIfReady(); + + return; + } +}; + +/*### +## npc_cs_butcher +###*/ + +enum +{ + SPELL_CLOUD = 52525 +}; + +struct MANGOS_DLL_DECL npc_cs_butcherAI : public ScriptedAI +{ + npc_cs_butcherAI(Creature *pCreature) : ScriptedAI(pCreature) + { + m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); + m_bIsHeroic = pCreature->GetMap()->IsRaidOrHeroicDungeon(); + Reset(); + } + + ScriptedInstance* m_pInstance; + bool m_bIsHeroic; + + uint32 WaypointId; + uint32 MoveTimer; + + void Reset() + { + DoCast(m_creature, SPELL_CLOUD); + m_creature->RemoveSplineFlag(SPLINEFLAG_WALKMODE); + MoveTimer = (urand(100, 5000)); + WaypointId = 1; + } + + void MoveToPoint(float X, float Y, float Z) + { + m_creature->GetMotionMaster()->MovementExpired(false); + m_creature->GetMotionMaster()->MovePoint(0, X, Y, Z); + } + + void AttackStart(Unit* pWho) + { + if (!pWho) + return; + + if (m_creature->Attack(pWho, true)) + { + m_creature->AddThreat(pWho); + m_creature->SetInCombatWith(pWho); + pWho->SetInCombatWith(m_creature); + + if (IsCombatMovement()) + m_creature->GetMotionMaster()->MoveChase(pWho); + } + } + + void EnterEvadeMode() + { + m_creature->RemoveAllAuras(); + m_creature->DeleteThreatList(); + m_creature->CombatStop(true); + m_creature->LoadCreaturesAddon(); + + m_creature->SetLootRecipient(NULL); + DoCast(m_creature, SPELL_CLOUD); + } + + void MoveInLineOfSight(Unit* pWho) + { + if (!pWho) + return; + + if (!m_creature->hasUnitState(UNIT_STAT_STUNNED) && pWho->isTargetableForAttack() && + m_creature->IsHostileTo(pWho) && pWho->isInAccessablePlaceFor(m_creature)) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(pWho) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(pWho); + if (m_creature->IsWithinDistInMap(pWho, attackRadius) && m_creature->IsWithinLOSInMap(pWho)) + { + if (!m_creature->getVictim()) + { + AttackStart(pWho); + pWho->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + } + else if (m_creature->GetMap()->IsDungeon()) + { + pWho->SetInCombatWith(m_creature); + m_creature->AddThreat(pWho, 0.0f); + } + } + } + } + + void JumpNextStep(uint32 Time) + { + MoveTimer = Time; + WaypointId++; + } + + void UpdateAI(const uint32 uiDiff) + { + if (!m_creature->SelectHostileTarget() || !m_creature->getVictim() && m_creature->isTemporarySummon()) + { + if(MoveTimer < uiDiff) + { + if(m_pInstance->GetData(TYPE_WING) == RIGHT) + { + switch(WaypointId) + { + case 1: + MoveToPoint(2356.659f, 1185.501f, 130.636f); + JumpNextStep(10000); + break; + case 2: + MoveToPoint(2301.735f, 1179.265f, 136.944f); + JumpNextStep(8000); + break; + case 3: + MoveToPoint(2234.787f, 1180.638f, 136.344f); + JumpNextStep(9000); + break; + case 4: + MoveToPoint(2178.313f, 1244.350f, 136.107f); + JumpNextStep(12000); + break; + case 5: + MoveToPoint(2163.553f, 1277.814f, 133.444f); + JumpNextStep(5000); + break; + case 6: + MoveToPoint(2083.952f, 1287.716f, 141.146f); + JumpNextStep(5000); + break; + } + } + + if(m_pInstance->GetData(TYPE_WING) == LEFT) + { + switch(WaypointId) + { + case 1: + MoveToPoint(2188.318f, 1331.410f, 130.003f); + JumpNextStep(10000); + break; + case 2: + MoveToPoint(2165.351f, 1279.156f, 133.388f); + JumpNextStep(8000); + break; + case 3: + MoveToPoint(2083.952f, 1287.716f, 141.146f); + JumpNextStep(9000); + break; + } + } + + } else MoveTimer -= uiDiff; + } + + if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) + return; + + DoMeleeAttackIfReady(); + + return; + } +}; + +struct MANGOS_DLL_DECL npc_time_riftCSAI : public ScriptedAI +{ + npc_time_riftCSAI(Creature *pCreature) : ScriptedAI(pCreature) + { + m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); + m_bIsHeroic = pCreature->GetMap()->IsRaidOrHeroicDungeon(); + Reset(); + } + + ScriptedInstance* m_pInstance; + bool m_bIsHeroic; + + uint32 Step; + uint32 m_uiStepTimer; + Creature* Drakonian01; + Creature* Drakonian02; + Creature* Drakonian03; + + void Reset() + { + m_uiStepTimer = 1000; + Step = 1; + } + + void UpdateAI(const uint32 uiDiff) + { + if (m_uiStepTimer < uiDiff) + { + switch(Step) + { + case 1: + if (Creature* pArthas = m_pInstance->instance->GetCreature(m_pInstance->GetData64(NPC_ARTHAS))) + { + Drakonian01 = m_creature->SummonCreature(NPC_INFINITE_ADVERSARY,(m_creature->GetPositionX()-2)+rand()%4, (m_creature->GetPositionY()-2)+rand()%4, m_creature->GetPositionZ(),3.229f,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,900000); + Drakonian01->GetMotionMaster()->MovePoint(0, pArthas->GetPositionX(), pArthas->GetPositionY(), pArthas->GetPositionZ()); + Drakonian02 = m_creature->SummonCreature(NPC_INFINITE_HUNTER,(m_creature->GetPositionX()-2)+rand()%4, (m_creature->GetPositionY()-2)+rand()%4, m_creature->GetPositionZ(),3.229f,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,900000); + Drakonian02->GetMotionMaster()->MovePoint(0, pArthas->GetPositionX(), pArthas->GetPositionY(), pArthas->GetPositionZ()); + Drakonian03 = m_creature->SummonCreature(NPC_INFINITE_AGENT,(m_creature->GetPositionX()-2)+rand()%4, (m_creature->GetPositionY()-2)+rand()%4, m_creature->GetPositionZ(),3.229f,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,900000); + Drakonian03->GetMotionMaster()->MovePoint(0, pArthas->GetPositionX(), pArthas->GetPositionY(), pArthas->GetPositionZ()); + } + m_uiStepTimer = 3000; + Step++; + break; + case 2: + m_creature->RemoveFromWorld(); + Step++; + break; + } + } else m_uiStepTimer -= uiDiff; + } +}; + +CreatureAI* GetAI_npc_cs_gnoul(Creature* pCreature) +{ + return new npc_cs_gnoulAI(pCreature); +} + +CreatureAI* GetAI_npc_cs_necromancer(Creature* pCreature) +{ + return new npc_cs_necromancerAI(pCreature); +} + +CreatureAI* GetAI_npc_cs_field(Creature* pCreature) +{ + return new npc_cs_fieldAI(pCreature); +} + +CreatureAI* GetAI_npc_cs_acolyte(Creature* pCreature) +{ + return new npc_cs_acolyteAI(pCreature); +} + +CreatureAI* GetAI_npc_cs_butcher(Creature* pCreature) +{ + return new npc_cs_butcherAI(pCreature); +} + +CreatureAI* GetAI_npc_time_riftCS(Creature* pCreature) +{ + return new npc_time_riftCSAI(pCreature); +} + +void AddSC_trash_culling_of_stratholme() +{ + Script *newscript; + + newscript = new Script; + newscript->Name = "npc_cs_gnoul"; + newscript->GetAI = &GetAI_npc_cs_gnoul; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_cs_necromancer"; + newscript->GetAI = &GetAI_npc_cs_necromancer; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_cs_field"; + newscript->GetAI = &GetAI_npc_cs_field; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_cs_acolyte"; + newscript->GetAI = &GetAI_npc_cs_acolyte; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_cs_butcher"; + newscript->GetAI = &GetAI_npc_cs_butcher; + newscript->RegisterSelf(); + + newscript = new Script; + newscript->Name = "npc_time_riftCS"; + newscript->GetAI = &GetAI_npc_time_riftCS; + newscript->RegisterSelf(); +} Index: system/ScriptLoader.cpp =================================================================== --- system/ScriptLoader.cpp (revision 1718) +++ system/ScriptLoader.cpp (working copy) @@ -210,6 +210,13 @@ extern void AddSC_old_hillsbrad(); extern void AddSC_culling_of_stratholme(); //Culling of Stratholme extern void AddSC_instance_culling_of_stratholme(); +extern void AddSC_boss_infinite_corruptor(); +extern void AddSC_boss_lord_epoch(); +extern void AddSC_boss_malganis(); +extern void AddSC_boss_meathook(); +extern void AddSC_boss_salramm(); +extern void AddSC_culling_of_stratholmeAI(); +extern void AddSC_trash_culling_of_stratholme(); extern void AddSC_boss_celebras_the_cursed(); //maraudon extern void AddSC_boss_landslide(); extern void AddSC_boss_noxxion(); @@ -619,6 +626,13 @@ AddSC_old_hillsbrad(); AddSC_culling_of_stratholme(); // Culling of Stratholme AddSC_instance_culling_of_stratholme(); + AddSC_boss_infinite_corruptor(); + AddSC_boss_lord_epoch(); + AddSC_boss_malganis(); + AddSC_boss_meathook(); + AddSC_boss_salramm(); + AddSC_culling_of_stratholmeAI(); + AddSC_trash_culling_of_stratholme(); AddSC_boss_celebras_the_cursed(); //maraudon AddSC_boss_landslide(); AddSC_boss_noxxion(); Index: VC100/100ScriptDev2.vcxproj =================================================================== --- VC100/100ScriptDev2.vcxproj (revision 1718) +++ VC100/100ScriptDev2.vcxproj (working copy) @@ -404,6 +404,13 @@ + + + + + + + Index: VC80/80ScriptDev2.vcproj =================================================================== --- VC80/80ScriptDev2.vcproj (revision 1718) +++ VC80/80ScriptDev2.vcproj (working copy) @@ -1323,6 +1323,34 @@ Name="culling_of_stratholme" > + + + + + + + + + + + + + + Index: VC90/90ScriptDev2.vcproj =================================================================== --- VC90/90ScriptDev2.vcproj (revision 1718) +++ VC90/90ScriptDev2.vcproj (working copy) @@ -1322,6 +1322,34 @@ Name="culling_of_stratholme" > + + + + + + + + + + + + + +