Skip to content

Commit

Permalink
Mechanar: Rework sepethrea using spell lists and combat ai
Browse files Browse the repository at this point in the history
  • Loading branch information
killerwife committed Sep 16, 2023
1 parent 5ccc38c commit 329ad4f
Showing 1 changed file with 37 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ EndScriptData */
#include "AI/ScriptDevAI/include/sc_common.h"
#include "mechanar.h"
#include "Entities/TemporarySpawn.h"
#include "AI/ScriptDevAI/base/CombatAI.h"

enum
{
Expand All @@ -44,135 +45,89 @@ enum
NPC_RAGING_FLAMES = 20481,
};

struct boss_nethermancer_sepethreaAI : public ScriptedAI
struct boss_nethermancer_sepethreaAI : public CombatAI
{
boss_nethermancer_sepethreaAI(Creature* pCreature) : ScriptedAI(pCreature)
boss_nethermancer_sepethreaAI(Creature* creature) : CombatAI(creature, 0), m_instance(static_cast<ScriptedInstance*>(creature->GetInstanceData())),
m_isRegularMode(creature->GetMap()->IsRegularDifficulty())
{
m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData();
m_bIsRegularMode = pCreature->GetMap()->IsRegularDifficulty();
m_creature->GetCombatManager().SetLeashingCheck([&](Unit* /*unit*/, float x, float /*y*/, float /*z*/)->bool
{
return x < 266.0f;
});
Reset();
AddOnKillText(SAY_SLAY1, SAY_SLAY2);
}

ScriptedInstance* m_pInstance;
bool m_bIsRegularMode;
ScriptedInstance* m_instance;
bool m_isRegularMode;

uint32 m_uiArcaneBlastTimer;
uint32 m_uiDragonsBreathTimer;

void Reset() override
{
m_uiArcaneBlastTimer = urand(14000, 25000);
m_uiDragonsBreathTimer = urand(20000, 26000);
}

void Aggro(Unit* /*pWho*/) override
void Aggro(Unit* /*who*/) override
{
m_creature->SetInCombatWithZone();
DoBroadcastText(SAY_AGGRO, m_creature);
DoCastSpellIfCan(nullptr, SPELL_FROST_ATTACK, CAST_TRIGGERED | CAST_AURA_NOT_PRESENT);
DoCastSpellIfCan(m_creature, m_bIsRegularMode ? SPELL_SUMMON_RAGING_FLAMES : SPELL_SUMMON_RAGING_FLAMES_H);

if (m_pInstance)
m_pInstance->SetData(TYPE_SEPETHREA, IN_PROGRESS);
}
DoCastSpellIfCan(nullptr, m_isRegularMode ? SPELL_SUMMON_RAGING_FLAMES : SPELL_SUMMON_RAGING_FLAMES_H);

void KilledUnit(Unit* /*pVictim*/) override
{
DoBroadcastText(urand(0, 1) ? SAY_SLAY1 : SAY_SLAY2, m_creature);
if (m_instance)
m_instance->SetData(TYPE_SEPETHREA, IN_PROGRESS);
}

void JustDied(Unit* /*pKiller*/) override
void JustDied(Unit* /*killer*/) override
{
DoBroadcastText(SAY_DEATH, m_creature);

if (m_pInstance)
m_pInstance->SetData(TYPE_SEPETHREA, DONE);
if (m_instance)
m_instance->SetData(TYPE_SEPETHREA, DONE);
}

void JustReachedHome() override
{
if (m_pInstance)
m_pInstance->SetData(TYPE_SEPETHREA, FAIL);
if (m_instance)
m_instance->SetData(TYPE_SEPETHREA, FAIL);
}

void UpdateAI(const uint32 uiDiff) override
void OnSpellCast(SpellEntry const* spellInfo, Unit* target) override
{
// Return since we have no target
if (!m_creature->SelectHostileTarget() || !m_creature->GetVictim())
return;

// Arcane Blast
if (m_uiArcaneBlastTimer < uiDiff)
{
if (DoCastSpellIfCan(m_creature->GetVictim(), SPELL_ARCANE_BLAST) == CAST_OK)
{
m_uiArcaneBlastTimer = urand(15000, 30000);
m_creature->getThreatManager().modifyThreatPercent(m_creature->GetVictim(), -50.0f);
}
}
else
m_uiArcaneBlastTimer -= uiDiff;

// Dragons Breath
if (m_uiDragonsBreathTimer < uiDiff)
switch (spellInfo->Id)
{
if (DoCastSpellIfCan(m_creature, SPELL_DRAGONS_BREATH) == CAST_OK)
{
case SPELL_ARCANE_BLAST:
m_creature->getThreatManager().modifyThreatPercent(target, -50.0f);
break;
case SPELL_DRAGONS_BREATH:
if (urand(0, 1))
DoBroadcastText(urand(0, 1) ? SAY_DRAGONS_BREATH_1 : SAY_DRAGONS_BREATH_2, m_creature);

m_uiDragonsBreathTimer = urand(20000, 35000);
}
break;
}
else
m_uiDragonsBreathTimer -= uiDiff;

DoMeleeAttackIfReady();
}
};

UnitAI* GetAI_boss_nethermancer_sepethrea(Creature* pCreature)
{
return new boss_nethermancer_sepethreaAI(pCreature);
}

enum
{
SPELL_RAGING_FLAMES = 35281,
SPELL_INFERNO = 35268,
SPELL_INFERNO_H = 39346,
SPELL_INFERNO = 35268,
SPELL_INFERNO_H = 39346,
};

struct npc_raging_flamesAI : public ScriptedAI
struct npc_raging_flamesAI : public CombatAI
{
npc_raging_flamesAI(Creature* pCreature) : ScriptedAI(pCreature)
npc_raging_flamesAI(Creature* creature) : CombatAI(creature, 0), m_instance(static_cast<ScriptedInstance*>(creature->GetInstanceData())),
m_isRegularMode(creature->GetMap()->IsRegularDifficulty())
{
m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData();
m_bIsRegularMode = pCreature->GetMap()->IsRegularDifficulty();
if (m_creature->IsTemporarySummon())
m_summonerGuid = m_creature->GetSpawnerGuid();

Reset();
}

ScriptedInstance* m_pInstance;
bool m_bIsRegularMode;

uint32 m_uiInfernoTimer;
ScriptedInstance* m_instance;
bool m_isRegularMode;

ObjectGuid m_summonerGuid;

void Reset() override
{
m_uiInfernoTimer = urand(15700, 30000);
CombatAI::Reset();
DoCastSpellIfCan(nullptr, SPELL_RAGING_FLAMES, CAST_TRIGGERED | CAST_AURA_NOT_PRESENT);
}

void Aggro(Unit* /*pWho*/) override
void Aggro(Unit* /*who*/) override
{
FixateRandomTarget();
}
Expand All @@ -181,47 +136,21 @@ struct npc_raging_flamesAI : public ScriptedAI
{
DoResetThreat();

if (Creature* pSummoner = m_creature->GetMap()->GetCreature(m_summonerGuid))
if (Unit* pNewTarget = pSummoner->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1, nullptr, SELECT_FLAG_PLAYER))
m_creature->AddThreat(pNewTarget, 10000000.0f);
}

void UpdateAI(const uint32 uiDiff) override
{
// Return since we have no target
if (!m_creature->SelectHostileTarget() || !m_creature->GetVictim())
return;

// Inferno
if (m_uiInfernoTimer < uiDiff)
{
if (DoCastSpellIfCan(m_creature, m_bIsRegularMode ? SPELL_INFERNO : SPELL_INFERNO_H) == CAST_OK)
{
m_uiInfernoTimer = urand(15700, 28900);
FixateRandomTarget();
}
}
else
m_uiInfernoTimer -= uiDiff;

DoMeleeAttackIfReady();
if (Creature* summoner = m_creature->GetMap()->GetCreature(m_summonerGuid))
if (Unit* newTarget = summoner->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1, nullptr, SELECT_FLAG_PLAYER))
m_creature->AddThreat(newTarget, 10000000.0f);
}
};

UnitAI* GetAI_npc_raging_flames(Creature* pCreature)
{
return new npc_raging_flamesAI(pCreature);
}

void AddSC_boss_nethermancer_sepethrea()
{
Script* pNewScript = new Script;
pNewScript->Name = "boss_nethermancer_sepethrea";
pNewScript->GetAI = &GetAI_boss_nethermancer_sepethrea;
pNewScript->GetAI = &GetNewAIInstance<boss_nethermancer_sepethreaAI>;
pNewScript->RegisterSelf();

pNewScript = new Script;
pNewScript->Name = "npc_raging_flames";
pNewScript->GetAI = &GetAI_npc_raging_flames;
pNewScript->GetAI = &GetNewAIInstance<npc_raging_flamesAI>;
pNewScript->RegisterSelf();
}

0 comments on commit 329ad4f

Please sign in to comment.