Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion src/game/AI/ScriptDevAI/base/BossAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,21 @@ void BossAI::AddOnAggroText(uint32 text)
m_onAggroTexts.push_back(text);
}

void BossAI::Reset()
{
CombatAI::Reset();
m_creature->SetSpellList(m_creature->GetCreatureInfo()->SpellList);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember if you fixed the need for this at some point

}

void BossAI::JustDied(Unit* killer)
{
CombatAI::JustDied(killer);
if (!m_onKilledTexts.empty())
DoBroadcastText(m_onKilledTexts[urand(0, m_onKilledTexts.size() - 1)], m_creature, killer);
if (m_instanceDataType == -1)
return;
if (ScriptedInstance* instance = static_cast<ScriptedInstance*>(m_creature->GetInstanceData()))
instance->SetData(m_instanceDataType, DONE);
CombatAI::JustDied(killer);
OpenEntrances();
OpenExits();
}
Expand Down Expand Up @@ -78,4 +84,25 @@ void BossAI::AddEntranceObject(uint32 value)
void BossAI::AddExitObject(uint32 value)
{
m_exitObjects.push_back(value);
}

void BossAI::EnterEvadeMode()
{
if (m_instanceDataType == -1)
return;
if (ScriptedInstance* instance = static_cast<ScriptedInstance*>(m_creature->GetInstanceData()))
instance->SetData(m_instanceDataType, FAIL);
OpenEntrances();
if (m_respawnDelay == -1)
{
CombatAI::EnterEvadeMode();
return;
}
m_creature->SetRespawnDelay(m_respawnDelay, true);
m_creature->ForcedDespawn();
}

void BossAI::AddRespawnOnEvade(std::chrono::seconds delay)
{
m_respawnDelay = delay.count();
}
7 changes: 7 additions & 0 deletions src/game/AI/ScriptDevAI/base/BossAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class BossAI : public CombatAI
for (auto& id : m_exitObjects)
instance->DoUseOpenableObject(id, true);
}

/**
* Adds one or more Broadcast Texts to possibly emit when Unit dies
* This function is not called if JustDied is overridden. Add CombatAI::JustDied(); to your overriding function.
Expand Down Expand Up @@ -83,6 +84,7 @@ class BossAI : public CombatAI

void SetDataType(uint32 type) { m_instanceDataType = type; }

void Reset() override;
void JustDied(Unit* killer = nullptr) override;
void JustReachedHome() override;
void Aggro(Unit* who = nullptr) override;
Expand All @@ -101,6 +103,9 @@ class BossAI : public CombatAI
AddExitObject(fargs...);
}
void SetGateDelay(std::chrono::milliseconds delay) { m_gateDelay = delay; }
void EnterEvadeMode() override;

void AddRespawnOnEvade(std::chrono::seconds delay);

std::chrono::seconds TimeSinceEncounterStart()
{
Expand All @@ -121,6 +126,8 @@ class BossAI : public CombatAI

uint32 m_instanceDataType = -1;

uint32 m_respawnDelay = -1;

std::chrono::steady_clock::time_point m_combatStartTimestamp;
};

Expand Down