Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ScriptPCH.h"
- #include "CreatureAI.h"
- #include "ObjectAccessor.h"
- #include "Player.h"
- class npc_cultist_boss : public CreatureScript
- {
- public: npc_cultist_boss() : CreatureScript("npc_cultist_boss") {}
- struct npc_cultist_bossAI : public ScriptedAI
- {
- npc_cultist_bossAI(Creature * c) : ScriptedAI(c), summons(me) { }
- bool checkStart = false;
- uint32 loadTimer;
- uint32 MainRandomVisuals;
- uint32 MainShadowCleave;
- uint32 MainTimeFreeze;
- uint32 Growandstuff;
- uint32 CheckForPhase2Main;
- uint32 MainEndVisualFinal;
- uint32 MainEndVisual;
- uint32 BringItOnMainBoss;
- uint32 MainDisorient;
- uint32 MainShroudGuys;
- uint32 MainDeathGrip;
- uint32 CheckForNextMainPhase;
- uint8 phase;
- bool cancast;
- bool canLoad;
- void Reset() override
- {
- summons.DespawnAll();
- me->SetImmuneToPC(true);
- me->SetReactState(REACT_PASSIVE);
- me->CastSpell(me, 70358);
- checkStart = false;
- canLoad = false;
- phase = 1;
- MainRandomVisuals = 7500;
- MainShadowCleave = 7000;
- MainTimeFreeze = 8000;
- Growandstuff = 10000;
- CheckForPhase2Main = 2000;
- loadTimer = 3000;
- me->SetObjectScale(1.0f);
- }
- void JustSummoned(Creature * summoned) override
- {
- summons.Summon(summoned);
- }
- void MovementInform(uint32 type, uint32 id) override
- {
- if (type == POINT_MOTION_TYPE)
- {
- switch (id)
- {
- case 1:
- me->SetDisableGravity(true);
- break;
- case 2:
- me->SetDisableGravity(false);
- break;
- }
- }
- }
- void MoveInLineOfSight(Unit * player)
- {
- if (!checkStart)
- {
- if (!player || player->isDead() || player->GetTypeId() != TYPEID_PLAYER)
- return;
- if (me->IsWithinDistInMap(player, 20.0f))
- {
- if (me->GetDistance(player) <= 20.0f)
- {
- corpseexplode = me->FindNearestCreature(5710, 30.0f, true);
- me->CastStop();
- me->Talk("Life energy, to consume...", CHAT_MSG_SAY, LANG_UNIVERSAL, 80.0f, me);
- me->PlayDirectSound(11250, nullptr);
- DoCastSelf(60427);
- DoCastSelf(39947);
- DoCastSelf(51126);
- me->SetReactState(REACT_AGGRESSIVE);
- me->SetImmuneToPC(false);
- me->GetMotionMaster()->MoveChase(player);
- me->SetInCombatWith(player);
- Position const coords = { corpseexplode->GetPositionX(), corpseexplode->GetPositionY(), corpseexplode->GetPositionZ() + 4.0f, corpseexplode->GetOrientation() };
- me->CastSpell(corpseexplode, 70572);
- corpseexplode->Talk("NONONONO WAI-GHHHHHHHH.", CHAT_MSG_YELL, LANG_UNIVERSAL, 80.0f, corpseexplode);
- corpseexplode->GetMotionMaster()->MoveTakeoff(1, coords);
- corpseexplode->SetImmuneToPC(true);
- corpseexplode->SetReactState(REACT_PASSIVE);
- corpseexplode->AddAura(70569, corpseexplode);
- checkStart = true;
- canLoad = true;
- }
- }
- }
- }
- void EnterCombat(Unit * /* who */)
- {
- }
- void JustDied(Unit* /*killer*/) override
- {
- me->Talk("No more life...", CHAT_MSG_SAY, LANG_UNIVERSAL, 80.0f, me);
- me->PlayDirectSound(11252, nullptr);
- }
- void UpdateAI(uint32 diff)
- {
- if (!UpdateVictim())
- return;
- if (loadTimer <= diff && canLoad)
- {
- corpseexplode = me->FindNearestCreature(5710, 30.0f, true);
- corpseexplode->CastSpell(corpseexplode, 49218);
- corpseexplode->CastSpell(corpseexplode, 30687);
- corpseexplode->DisappearAndDie();
- canLoad = false;
- }
- else
- loadTimer -= diff;
- if (Growandstuff <= diff)
- {
- if (cancast)
- {
- DoCast(72679);
- if (urand(0, 1) == 1)
- {
- me->Talk("Darkness consumes all.", CHAT_MSG_SAY, LANG_UNIVERSAL, 80.0f, me);
- me->PlayDirectSound(11254, nullptr);
- }
- else
- {
- me->Talk("The shadow will engulf you.", CHAT_MSG_SAY, LANG_UNIVERSAL, 80.0f, me);
- me->PlayDirectSound(11253, nullptr);
- }
- }
- }
- else
- Growandstuff -= diff;
- if (MainRandomVisuals <= diff)
- {
- if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 40.0f, true))
- DoCast(target, 73539);
- switch (phase)
- {
- case 1:
- case 2:
- MainRandomVisuals = 7500;
- break;
- case 3:
- MainRandomVisuals = 9000;
- break;
- case 4:
- MainRandomVisuals = 1000;
- break;
- }
- }
- else
- MainRandomVisuals -= diff;
- if (MainShadowCleave <= diff)
- {
- if (cancast)
- {
- if (Unit* target = SelectTarget(SELECT_TARGET_MAXTHREAT, 0, 10.0f, true))
- DoCast(target, 31629);
- }
- if (phase < 3)
- MainShadowCleave = 7000;
- else
- MainShadowCleave = 8000;
- }
- else
- MainShadowCleave -= diff;
- if (MainTimeFreeze <= diff)
- {
- if (cancast)
- {
- if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 60.0f, true))
- DoCast(target, 40951);
- }
- if (phase < 3)
- MainTimeFreeze = 8000;
- else
- MainTimeFreeze = 10000;
- }
- else
- MainTimeFreeze -= diff;
- if (CheckForPhase2Main <= diff)
- {
- if (me->GetHealthPct() < 75)
- {
- phase = 2;
- cancast = false;
- me->Talk("No More Life.", CHAT_MSG_SAY, LANG_UNIVERSAL, 80.0f, me);
- me->PlayDirectSound(11252, nullptr);
- me->SetImmuneToPC(true);
- me->StopMoving();
- me->CastStop();
- me->GetMotionMaster()->MovePoint(0, -424.966095f, -86.287300f, -88.224037f, true, 3.094177f);
- BringItOnMainBoss = 3000;
- }
- else
- CheckForPhase2Main = 2000;
- }
- else
- CheckForPhase2Main -= diff;
- if (BringItOnMainBoss <= diff)
- {
- DoCast(me, 12380);
- MainRandomVisuals = 1000;
- phase = 4;
- if (me->GetHealthPct() < 35)
- {
- MainEndVisualFinal = 15500;
- }
- else
- MainEndVisual = 15500;
- }
- if (MainEndVisual <= diff)
- {
- cancast = true;
- me->CastStop();
- me->SetImmuneToPC(false);
- me->SetReactState(REACT_AGGRESSIVE);
- phase = 2;
- if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 60.0f, true))
- DoCast(target, 40251);
- if (Unit* target = SelectTarget(SELECT_TARGET_MINDISTANCE, 0, 80.0f, true))
- me->GetMotionMaster()->MoveChase(target);
- MainDisorient = 12000;
- MainShroudGuys = 6000;
- MainDeathGrip = 8000;
- Growandstuff = 20000;
- CheckForNextMainPhase = 2000;
- }
- if (MainDisorient <= diff)
- {
- if (cancast)
- {
- if (Unit* target = SelectTarget(SELECT_TARGET_MINDISTANCE, 0, -6.0f, true))
- me->CastSpell(target, 26108);
- }
- switch (phase)
- {
- case 2:
- MainDisorient = 12000;
- break;
- case 3:
- MainDisorient = 10000;
- break;
- }
- }
- else
- MainDisorient -= diff;
- if (MainShroudGuys <= diff)
- {
- if (cancast)
- {
- if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 40.0f, true))
- me->CastSpell(target, 40251);
- }
- MainShroudGuys = 6000;
- }
- else
- MainShroudGuys -= diff;
- if (MainDeathGrip <= diff)
- {
- if (cancast)
- {
- std::list<Unit*> targets;
- SelectTargetList(targets, 2, SELECT_TARGET_RANDOM, 0, 40.0f, true);
- for (std::list<Unit*>::const_iterator i = targets.begin(); i != targets.end(); ++i)
- {
- DoCast(*i, 64429);
- DoCast(*i, 10689);
- for (Unit* target : targets)
- {
- if (Creature* reflection = me->SummonCreature(30768, *target, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 3000))
- {
- reflection->SetImmuneToPC(false);
- target->CastSpell(reflection, 69828, true);
- target->CastSpell(reflection, 69861, true);
- target->CastSpell(reflection, 69960, true);
- reflection->AI()->AttackStart(target);
- }
- break;
- }
- break;
- }
- }
- if (phase < 3)
- MainDeathGrip = 8000;
- else
- MainDeathGrip = 6000;
- }
- else
- MainDeathGrip -= diff;
- if (CheckForNextMainPhase <= diff)
- {
- if (me->GetHealthPct() < 35)
- {
- cancast = false;
- me->Talk("No More Life.", CHAT_MSG_SAY, LANG_UNIVERSAL, 80.0f, me);
- me->PlayDirectSound(11252, nullptr);
- me->SetImmuneToPC(true);
- me->SetReactState(REACT_PASSIVE);
- me->CastStop();
- me->GetMotionMaster()->MovePoint(0, -424.966095f, -86.287300f, -88.224037f, true, 3.094177f);
- BringItOnMainBoss = 3000;
- }
- else
- CheckForNextMainPhase = 2000;
- }
- else
- CheckForNextMainPhase -= diff;
- if (MainEndVisualFinal <= diff)
- {
- cancast = true;
- me->CastStop();
- me->SetImmuneToPC(false);
- me->SetReactState(REACT_AGGRESSIVE);
- phase = 3;
- Growandstuff = 10000;
- if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 60.0f, true))
- DoCast(target, 40251);
- if (Unit* target = SelectTarget(SELECT_TARGET_MINDISTANCE, 0, 80.0f, true))
- me->GetMotionMaster()->MoveChase(target);
- }
- DoMeleeAttackIfReady();
- }
- private:
- SummonList summons;
- Creature* corpseexplode;
- };
- CreatureAI * GetAI(Creature * pCreature) const override
- {
- return new npc_cultist_bossAI(pCreature);
- }
- };
- void AddSC_npc_cultist_boss()
- {
- new npc_cultist_boss;
- }
Advertisement
Add Comment
Please, Sign In to add comment