*Cleanups in nightbane script - original patch by BroodWyrm

--HG--
branch : trunk
This commit is contained in:
Blaymoira
2009-01-03 16:06:43 +01:00
parent 1eec0880b5
commit ba74539ac4
@@ -16,8 +16,8 @@
/* ScriptData /* ScriptData
SDName: Boss_Nightbane SDName: Boss_Nightbane
SD%Complete: 50 SD%Complete: 70
SDComment: skelleton adds, optimice some "if"s, timers, rain of bones applied self(!?) SDComment: SDComment: skelleton adds need 2 more, timers,
SDCategory: Karazhan SDCategory: Karazhan
EndScriptData */ EndScriptData */
@@ -35,6 +35,14 @@ EndScriptData */
#define SPELL_SMOKING_BLAST 37057 #define SPELL_SMOKING_BLAST 37057
#define SPELL_FIREBALL_BARRAGE 30282 #define SPELL_FIREBALL_BARRAGE 30282
#define SPELL_SEARING_CINDERS 30127 #define SPELL_SEARING_CINDERS 30127
#define SPELL_SUMMON_SKELETON 30170
#define EMOTE_SUMMON "An ancient being awakens in the distance..."
#define YELL_AGGRO "What fools! I shall bring a quick end to your suffering!"
#define YELL_FLY_PHASE "Miserable vermin. I shall exterminate you from the air!"
#define YELL_LAND_PHASE_1 "Enough! I shall land and crush you myself!"
#define YELL_LAND_PHASE_2 "Insects! Let me show you my strength up close!"
#define EMOTE_BREATH "takes a deep breath."
float IntroWay[8][3] = float IntroWay[8][3] =
{ {
@@ -62,78 +70,97 @@ struct TRINITY_DLL_DECL boss_nightbaneAI : public ScriptedAI
boss_nightbaneAI(Creature* c) : ScriptedAI(c) boss_nightbaneAI(Creature* c) : ScriptedAI(c)
{ {
pInstance = ((ScriptedInstance*)c->GetInstanceData()); pInstance = ((ScriptedInstance*)c->GetInstanceData());
intro = true; Intro = true;
Reset(); Reset();
} }
ScriptedInstance* pInstance; ScriptedInstance* pInstance;
uint32 phase; uint32 Phase;
bool rainbones; bool RainBones;
bool Skeletons;
uint32 bellowingroar_timer; uint32 BellowingRoarTimer;
uint32 charredearth_timer; uint32 CharredEarthTimer;
uint32 distractingash_timer; uint32 DistractingAshTimer;
uint32 smolderingbreath_timer; uint32 SmolderingBreathTimer;
uint32 tailsweep_timer; uint32 TailSweepTimer;
uint32 rainofbones_timer; uint32 RainofBonesTimer;
uint32 smokingblast_timer; uint32 SmokingBlastTimer;
uint32 fireballbarrage_timer; uint32 FireballBarrageTimer;
uint32 searingcinders_timer; uint32 SearingCindersTimer;
uint32 fly_count; uint32 FlyCount;
uint32 fly_timer; uint32 FlyTimer;
bool intro; bool Intro;
bool flying; bool Flying;
bool movement; bool Movement;
uint32 wait_timer;
uint32 WaitTimer;
uint32 MovePhase; uint32 MovePhase;
void Reset() void Reset()
{ {
phase =1; BellowingRoarTimer = 30000;
bellowingroar_timer = 30000; CharredEarthTimer = 15000;
charredearth_timer = 15000; DistractingAshTimer = 20000;
distractingash_timer = 20000; SmolderingBreathTimer = 10000;
smolderingbreath_timer = 10000; TailSweepTimer = 12000;
tailsweep_timer = 12000; RainofBonesTimer = 10000;
rainofbones_timer = 10000; SmokingBlastTimer = 20000;
smokingblast_timer = 20000; FireballBarrageTimer = 13000;
fireballbarrage_timer = 13000; SearingCindersTimer = 14000;
searingcinders_timer = 14000; WaitTimer = 1000;
fly_count = 0; Phase =1;
FlyCount = 0;
MovePhase = 0;
m_creature->SetSpeed(MOVE_RUN,2); m_creature->SetSpeed(MOVE_RUN, 2.0f);
m_creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_LEVITATING); m_creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_LEVITATING);
m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
m_creature->setActive(true); m_creature->setActive(true);
wait_timer = 1000;
MovePhase = 0;
if(pInstance) if(pInstance)
pInstance->SetData(DATA_NIGHTBANE_EVENT, NOT_STARTED); pInstance->SetData(DATA_NIGHTBANE_EVENT, NOT_STARTED);
flying = false; if(pInstance->GetData(DATA_NIGHTBANE_EVENT) == DONE)
movement = false; m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
if(!intro) HandleTerraceDoors(true);
Flying = false;
Movement = false;
if(!Intro)
{ {
m_creature->SetHomePosition(IntroWay[7][0],IntroWay[7][1],IntroWay[7][2],0); m_creature->SetHomePosition(IntroWay[7][0],IntroWay[7][1],IntroWay[7][2],0);
m_creature->GetMotionMaster()->MoveTargetedHome(); m_creature->GetMotionMaster()->MoveTargetedHome();
} }
} }
void HandleTerraceDoors(bool open)
{
//if(GameObject *Door = GameObject::GetGameObject((*m_creature),pInstance->GetData64(DATA_MASTERS_TERRACE_DOOR_1)))
// Door->SetUInt32Value(GAMEOBJECT_STATE, open ? 0 : 1);
//if(GameObject *Door = GameObject::GetGameObject((*m_creature),pInstance->GetData64(DATA_MASTERS_TERRACE_DOOR_2)))
// Door->SetUInt32Value(GAMEOBJECT_STATE, open ? 0 : 1);
}
void Aggro(Unit *who) void Aggro(Unit *who)
{ {
if(pInstance) if(pInstance)
pInstance->SetData(DATA_NIGHTBANE_EVENT, IN_PROGRESS); pInstance->SetData(DATA_NIGHTBANE_EVENT, IN_PROGRESS);
HandleTerraceDoors(false);
DoYell(YELL_AGGRO, LANG_UNIVERSAL, NULL);
} }
void AttackStart(Unit* who) void AttackStart(Unit* who)
{ {
if(!intro && !flying) if(!Intro && !Flying)
ScriptedAI::AttackStart(who); ScriptedAI::AttackStart(who);
} }
@@ -141,10 +168,13 @@ struct TRINITY_DLL_DECL boss_nightbaneAI : public ScriptedAI
{ {
if(pInstance) if(pInstance)
pInstance->SetData(DATA_NIGHTBANE_EVENT, DONE); pInstance->SetData(DATA_NIGHTBANE_EVENT, DONE);
HandleTerraceDoors(true);
} }
void MoveInLineOfSight(Unit *who) void MoveInLineOfSight(Unit *who)
{ {
if(!intro && !flying) if(!Intro && !Flying)
{ {
if(!m_creature->getVictim() && m_creature->canStartAttack(who)) if(!m_creature->getVictim() && m_creature->canStartAttack(who))
ScriptedAI::AttackStart(who); ScriptedAI::AttackStart(who);
@@ -156,50 +186,78 @@ struct TRINITY_DLL_DECL boss_nightbaneAI : public ScriptedAI
if(type != POINT_MOTION_TYPE) if(type != POINT_MOTION_TYPE)
return; return;
if(intro) if(Intro)
{ {
if(id >= 8) if(id >= 8)
{ {
intro = false; Intro = false;
m_creature->SetHomePosition(IntroWay[7][0],IntroWay[7][1],IntroWay[7][2],0); m_creature->SetHomePosition(IntroWay[7][0],IntroWay[7][1],IntroWay[7][2],0);
return; return;
} }
wait_timer = 1; WaitTimer = 1;
} }
if(flying) if(Flying)
{ {
if(id == 0) if(id == 0)
{ {
flying = false; DoTextEmote(EMOTE_BREATH, NULL, true);
phase = 2; Flying = false;
Phase = 2;
return; return;
} }
if(id == 3) if(id == 3)
{ {
MovePhase = 4; MovePhase = 4;
wait_timer = 1; WaitTimer = 1;
return;
}
if(id == 8)
{
flying = false;
phase = 1;
movement = true;
return; return;
} }
wait_timer = 1; if(id == 8)
{
Flying = false;
Phase = 1;
Movement = true;
return;
}
WaitTimer = 1;
} }
} }
void JustSummoned(Creature *summoned)
{
summoned->AI()->AttackStart(m_creature->getVictim());
}
void TakeOff()
{
DoYell(YELL_FLY_PHASE, LANG_UNIVERSAL, NULL);
m_creature->InterruptSpell(CURRENT_GENERIC_SPELL);
m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF);
m_creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_LEVITATING);
(*m_creature).GetMotionMaster()->Clear(false);
(*m_creature).GetMotionMaster()->MovePoint(0,IntroWay[2][0],IntroWay[2][1],IntroWay[2][2]);
Flying = true;
FlyTimer = 45000+rand()%15000; //timer wrong between 45 and 60 seconds
++FlyCount;
RainofBonesTimer = 5000; //timer wrong (maybe)
RainBones = false;
Skeletons = false;
}
void UpdateAI(const uint32 diff) void UpdateAI(const uint32 diff)
{ {
if(wait_timer) if(WaitTimer)
if(wait_timer < diff) if(WaitTimer < diff)
{ {
if(intro) if(Intro)
{ {
if(MovePhase >= 7) if(MovePhase >= 7)
{ {
@@ -210,12 +268,11 @@ struct TRINITY_DLL_DECL boss_nightbaneAI : public ScriptedAI
else else
{ {
m_creature->GetMotionMaster()->MovePoint(MovePhase,IntroWay[MovePhase][0],IntroWay[MovePhase][1],IntroWay[MovePhase][2]); m_creature->GetMotionMaster()->MovePoint(MovePhase,IntroWay[MovePhase][0],IntroWay[MovePhase][1],IntroWay[MovePhase][2]);
MovePhase++; ++MovePhase;
} }
} }
if(flying) if(Flying)
{ {
if(MovePhase >= 7) if(MovePhase >= 7)
{ {
@@ -226,173 +283,138 @@ struct TRINITY_DLL_DECL boss_nightbaneAI : public ScriptedAI
else else
{ {
m_creature->GetMotionMaster()->MovePoint(MovePhase,IntroWay[MovePhase][0],IntroWay[MovePhase][1],IntroWay[MovePhase][2]); m_creature->GetMotionMaster()->MovePoint(MovePhase,IntroWay[MovePhase][0],IntroWay[MovePhase][1],IntroWay[MovePhase][2]);
MovePhase++; ++MovePhase;
} }
} }
wait_timer = 0; WaitTimer = 0;
}else wait_timer -= diff; }else WaitTimer -= diff;
if(!m_creature->SelectHostilTarget()) if(!m_creature->SelectHostilTarget())
return; return;
if(flying) if(Flying)
return; return;
// Phase 1 "GROUND FIGHT" // Phase 1 "GROUND FIGHT"
if(phase == 1) if(Phase == 1)
{ {
if(movement) if(Movement)
{ {
DoStartMovement(m_creature->getVictim()); DoStartMovement(m_creature->getVictim());
movement = false; Movement = false;
} }
if (bellowingroar_timer < diff) if (BellowingRoarTimer < diff)
{ {
DoCast(m_creature->getVictim(),SPELL_BELLOWING_ROAR); DoCast(m_creature->getVictim(),SPELL_BELLOWING_ROAR);
bellowingroar_timer = 30000+rand()%10000 ; //Timer BellowingRoarTimer = 30000+rand()%10000 ; //Timer
}else bellowingroar_timer -= diff; }else BellowingRoarTimer -= diff;
if (smolderingbreath_timer < diff) if (SmolderingBreathTimer < diff)
{ {
DoCast(m_creature->getVictim(),SPELL_SMOLDERING_BREATH); DoCast(m_creature->getVictim(),SPELL_SMOLDERING_BREATH);
smolderingbreath_timer = 20000;//timer SmolderingBreathTimer = 20000;//timer
}else SmolderingBreathTimer -= diff;
}else smolderingbreath_timer -= diff; if (CharredEarthTimer < diff)
if (charredearth_timer < diff)
{ {
Unit* target = NULL; Unit* target = NULL;
target = SelectUnit(SELECT_TARGET_RANDOM,0); target = SelectUnit(SELECT_TARGET_RANDOM,0);
DoCast(target,SPELL_CHARRED_EARTH); DoCast(target,SPELL_CHARRED_EARTH);
charredearth_timer = 20000; //timer CharredEarthTimer = 20000; //timer
}else charredearth_timer -= diff; }else CharredEarthTimer -= diff;
if (tailsweep_timer < diff) if (TailSweepTimer < diff)
{ {
Unit* target = NULL; Unit* target = NULL;
target = SelectUnit(SELECT_TARGET_RANDOM,0); target = SelectUnit(SELECT_TARGET_RANDOM,0);
if (!m_creature->HasInArc( M_PI, target)) if (!m_creature->HasInArc( M_PI, target))
DoCast(target,SPELL_TAIL_SWEEP); DoCast(target,SPELL_TAIL_SWEEP);
tailsweep_timer = 15000;//timer TailSweepTimer = 15000;//timer
}else tailsweep_timer -= diff; }else TailSweepTimer -= diff;
if (searingcinders_timer < diff) if (SearingCindersTimer < diff)
{ {
Unit* target = NULL; Unit* target = NULL;
target = SelectUnit(SELECT_TARGET_RANDOM,0); target = SelectUnit(SELECT_TARGET_RANDOM,0);
DoCast(target,SPELL_SEARING_CINDERS); DoCast(target,SPELL_SEARING_CINDERS);
searingcinders_timer = 10000; //timer SearingCindersTimer = 10000; //timer
}else searingcinders_timer -= diff; }else SearingCindersTimer -= diff;
uint32 prozent; uint32 Prozent;
prozent = (m_creature->GetHealth()*100) / m_creature->GetMaxHealth(); Prozent = (m_creature->GetHealth()*100) / m_creature->GetMaxHealth();
if (prozent < 75 && fly_count == 0) // first take off 75% if (Prozent < 75 && FlyCount == 0) // first take off 75%
{ TakeOff();
m_creature->InterruptSpell(CURRENT_GENERIC_SPELL);
m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF);
m_creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_LEVITATING);
(*m_creature).GetMotionMaster()->Clear(false);
(*m_creature).GetMotionMaster()->MovePoint(0,IntroWay[2][0],IntroWay[2][1],IntroWay[2][2]);
flying = true;
fly_timer = 45000+rand()%15000; if (Prozent < 50 && FlyCount == 1) // secound take off 50%
fly_count++; TakeOff();
rainofbones_timer = 5000;
rainbones = false;
}
if (prozent < 50 && fly_count == 1) // secound take off 50%
{
m_creature->InterruptSpell(CURRENT_GENERIC_SPELL);
m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF);
m_creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_LEVITATING);
(*m_creature).GetMotionMaster()->Clear(false);
(*m_creature).GetMotionMaster()->MovePoint(0,IntroWay[2][0],IntroWay[2][1],IntroWay[2][2]);
flying = true;
fly_timer = 45000+rand()%15000;
fly_count++;
rainofbones_timer = 5000;
rainbones = false;
}
if (prozent < 25 && fly_count == 2) // third take off 25%
{
m_creature->InterruptSpell(CURRENT_GENERIC_SPELL);
m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF);
m_creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_LEVITATING);
(*m_creature).GetMotionMaster()->Clear(false);
(*m_creature).GetMotionMaster()->MovePoint(0,IntroWay[2][0],IntroWay[2][1],IntroWay[2][2]);
flying = true;
//phase = 2;
fly_timer = 45000+rand()%15000;
fly_count++;
rainofbones_timer = 5000;
rainbones = false;
}
if (Prozent < 25 && FlyCount == 2) // third take off 25%
TakeOff();
DoMeleeAttackIfReady(); DoMeleeAttackIfReady();
} }
//Phase 2 "FLYING FIGHT" //Phase 2 "FLYING FIGHT"
if (phase == 2) if (Phase == 2)
{ {
if (!rainbones) if (!RainBones)
{ {
if (rainofbones_timer < diff && !rainbones) // only once at the beginning of phase 2 if (!Skeletons)
{ {
DoCast(m_creature->getVictim(),SPELL_RAIN_OF_BONES); DoCast(m_creature->getVictim(), SPELL_SUMMON_SKELETON);
rainbones = true; DoCast(m_creature->getVictim(), SPELL_SUMMON_SKELETON);
smokingblast_timer = 20000; DoCast(m_creature->getVictim(), SPELL_SUMMON_SKELETON);
}else rainofbones_timer -= diff; Skeletons = true;
}
if (distractingash_timer < diff) if (RainofBonesTimer < diff && !RainBones) // only once at the beginning of phase 2
{
DoCast(m_creature->getVictim(),SPELL_RAIN_OF_BONES);
RainBones = true;
SmokingBlastTimer = 20000;
}else RainofBonesTimer -= diff;
if (DistractingAshTimer < diff)
{ {
Unit* target = NULL; Unit* target = NULL;
target = SelectUnit(SELECT_TARGET_RANDOM,0); target = SelectUnit(SELECT_TARGET_RANDOM,0);
DoCast(target,SPELL_DISTRACTING_ASH); DoCast(target,SPELL_DISTRACTING_ASH);
distractingash_timer = 2000;//timer wrong DistractingAshTimer = 2000;//timer wrong
}else distractingash_timer -= diff; }else DistractingAshTimer -= diff;
} }
if (rainbones) if (RainBones)
{ {
if (smokingblast_timer < diff) if (SmokingBlastTimer < diff)
{ {
DoCast(m_creature->getVictim(),SPELL_SMOKING_BLAST); DoCast(m_creature->getVictim(),SPELL_SMOKING_BLAST);
smokingblast_timer = 1500 ; //timer wrong SmokingBlastTimer = 1500 ; //timer wrong
}else smokingblast_timer -= diff; }else SmokingBlastTimer -= diff;
} }
if (fireballbarrage_timer < diff) if (FireballBarrageTimer < diff)
{ {
Unit* target = NULL; Unit* target = NULL;
target = SelectUnit(SELECT_TARGET_FARTHEST,0); target = SelectUnit(SELECT_TARGET_FARTHEST,0);
DoCast(target,SPELL_FIREBALL_BARRAGE); DoCast(target,SPELL_FIREBALL_BARRAGE);
fireballbarrage_timer = 20000; //Timer FireballBarrageTimer = 20000; //Timer
}else fireballbarrage_timer -= diff; }else FireballBarrageTimer -= diff;
if (fly_timer < diff) //landing if (FlyTimer < diff) //landing
{ {
//m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LAND); if(rand()%2 == 0)
//m_creature->SetHover(false); DoYell(YELL_LAND_PHASE_1, LANG_UNIVERSAL, NULL);
else
DoYell(YELL_LAND_PHASE_2, LANG_UNIVERSAL, NULL);
(*m_creature).GetMotionMaster()->Clear(false); (*m_creature).GetMotionMaster()->Clear(false);
m_creature->GetMotionMaster()->MovePoint(3,IntroWay[3][0],IntroWay[3][1],IntroWay[3][2]); m_creature->GetMotionMaster()->MovePoint(3,IntroWay[3][0],IntroWay[3][1],IntroWay[3][2]);
flying = true;
//wait_timer = 1; Flying = true;
//phase = 1; }else FlyTimer -= diff;
}else fly_timer -= diff;
} }
} }
}; };
@@ -407,6 +429,6 @@ void AddSC_boss_nightbane()
Script *newscript; Script *newscript;
newscript = new Script; newscript = new Script;
newscript->Name="boss_nightbane"; newscript->Name="boss_nightbane";
newscript->GetAI = GetAI_boss_nightbane; newscript->GetAI = &GetAI_boss_nightbane;
newscript->RegisterSelf(); newscript->RegisterSelf();
} }