fix(Creature/Core): Boss phased reset (#7828)
Co-authored-by: Si1ker <Si1ker@users.noreply.github.com> Co-authored-by: lineagedr <lineagedr@users.noreply.github.com> Co-authored-by: Footman <footman@hotmail.de>
This commit is contained in:
@@ -14,6 +14,21 @@
|
|||||||
#include "SpellMgr.h"
|
#include "SpellMgr.h"
|
||||||
#include "Vehicle.h"
|
#include "Vehicle.h"
|
||||||
|
|
||||||
|
class PhasedRespawn : public BasicEvent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PhasedRespawn(Creature& owner) : BasicEvent(), _owner(owner) {}
|
||||||
|
|
||||||
|
bool Execute(uint64 /*eventTime*/, uint32 /*updateTime*/) override
|
||||||
|
{
|
||||||
|
_owner.RespawnOnEvade();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Creature& _owner;
|
||||||
|
};
|
||||||
|
|
||||||
//Disable CreatureAI when charmed
|
//Disable CreatureAI when charmed
|
||||||
void CreatureAI::OnCharmed(bool /*apply*/)
|
void CreatureAI::OnCharmed(bool /*apply*/)
|
||||||
{
|
{
|
||||||
@@ -170,10 +185,50 @@ void CreatureAI::EnterEvadeMode()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Reset();
|
// @todo: Turn into a flags_extra in creature_template
|
||||||
|
// despawn bosses at reset - only verified tbc/woltk bosses with this reset type - add bosses in last line respectively (dungeon/raid) and increase array limit
|
||||||
|
static constexpr std::array<uint32, 24> bosses = {
|
||||||
|
/* dungeons */
|
||||||
|
28684, /* Krik'thir the Gatewatcher */
|
||||||
|
36502, /* Devourer of Souls */
|
||||||
|
36658, /* Scourgelord Tyrannus */
|
||||||
|
/* raids */
|
||||||
|
32871, /* Algalon */
|
||||||
|
39863, /* Halion */
|
||||||
|
33186, /* Razorscale */
|
||||||
|
36626, /* Festergut */
|
||||||
|
32867, /* Steelbreaker - Assembly of Iron */
|
||||||
|
32927, /* Runemaster Molgeim - Assembly of Iron */
|
||||||
|
32857, /* Stormcaller Brundir - Assembly of Iron */
|
||||||
|
33350, /* Mimiron */
|
||||||
|
16060, /* Gothik the Harvester */
|
||||||
|
36678, /* Professor Putricide */
|
||||||
|
15990, /* Kel'Thuzad */
|
||||||
|
33993, /* Emalon the Storm Watcher */
|
||||||
|
17257, /* Magtheridon */
|
||||||
|
25315, /* Kil'jaeden */
|
||||||
|
15928, /* Thaddius */
|
||||||
|
32930, /* Kologarn */
|
||||||
|
32906, /* Freya */
|
||||||
|
36597, /* The Lich King */
|
||||||
|
36853, /* Sindragosa */
|
||||||
|
36855, /* Lady Deathwhisper */
|
||||||
|
37955 /* Blood-Queen Lana'thel */
|
||||||
|
};
|
||||||
|
|
||||||
if (me->IsVehicle()) // use the same sequence of addtoworld, aireset may remove all summons!
|
if (std::find(std::begin(bosses), std::end(bosses), me->GetEntry()) != std::end(bosses))
|
||||||
me->GetVehicleKit()->Reset(true);
|
{
|
||||||
|
me->DespawnOnEvade();
|
||||||
|
me->m_Events.AddEvent(new PhasedRespawn(*me), me->m_Events.CalculateTime(20000));
|
||||||
|
}
|
||||||
|
else // bosses will run back to the spawnpoint at reset
|
||||||
|
{
|
||||||
|
Reset();
|
||||||
|
if (me->IsVehicle()) // use the same sequence of addtoworld, aireset may remove all summons!
|
||||||
|
{
|
||||||
|
me->GetVehicleKit()->Reset(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*void CreatureAI::AttackedBy(Unit* attacker)
|
/*void CreatureAI::AttackedBy(Unit* attacker)
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ public:
|
|||||||
|
|
||||||
virtual void SummonedCreatureDespawn(Creature* /*summon*/) {}
|
virtual void SummonedCreatureDespawn(Creature* /*summon*/) {}
|
||||||
virtual void SummonedCreatureDies(Creature* /*summon*/, Unit* /*killer*/) {}
|
virtual void SummonedCreatureDies(Creature* /*summon*/, Unit* /*killer*/) {}
|
||||||
|
virtual void SummonedCreatureDespawnAll() {}
|
||||||
|
|
||||||
// Called when hit by a spell
|
// Called when hit by a spell
|
||||||
virtual void SpellHit(Unit* /*caster*/, SpellInfo const* /*spell*/) {}
|
virtual void SpellHit(Unit* /*caster*/, SpellInfo const* /*spell*/) {}
|
||||||
|
|||||||
@@ -604,6 +604,11 @@ void BossAI::SummonedCreatureDespawn(Creature* summon)
|
|||||||
summons.Despawn(summon);
|
summons.Despawn(summon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BossAI::SummonedCreatureDespawnAll()
|
||||||
|
{
|
||||||
|
summons.DespawnAll();
|
||||||
|
}
|
||||||
|
|
||||||
void BossAI::UpdateAI(uint32 diff)
|
void BossAI::UpdateAI(uint32 diff)
|
||||||
{
|
{
|
||||||
if (!UpdateVictim())
|
if (!UpdateVictim())
|
||||||
|
|||||||
@@ -418,6 +418,7 @@ public:
|
|||||||
|
|
||||||
void JustSummoned(Creature* summon) override;
|
void JustSummoned(Creature* summon) override;
|
||||||
void SummonedCreatureDespawn(Creature* summon) override;
|
void SummonedCreatureDespawn(Creature* summon) override;
|
||||||
|
void SummonedCreatureDespawnAll() override;
|
||||||
|
|
||||||
void UpdateAI(uint32 diff) override;
|
void UpdateAI(uint32 diff) override;
|
||||||
|
|
||||||
|
|||||||
@@ -1921,6 +1921,36 @@ void Creature::DespawnOrUnsummon(uint32 msTimeToDespawn /*= 0*/)
|
|||||||
ForcedDespawn(msTimeToDespawn);
|
ForcedDespawn(msTimeToDespawn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Creature::DespawnOnEvade()
|
||||||
|
{
|
||||||
|
SetVisible(false);
|
||||||
|
AI()->SummonedCreatureDespawnAll();
|
||||||
|
RemoveEvadeAuras();
|
||||||
|
|
||||||
|
float x, y, z, o;
|
||||||
|
GetRespawnPosition(x, y, z, &o);
|
||||||
|
SetHomePosition(x, y, z, o);
|
||||||
|
SetPosition(x, y, z, o);
|
||||||
|
|
||||||
|
if (IsFalling())
|
||||||
|
{
|
||||||
|
RemoveUnitMovementFlag(MOVEMENTFLAG_FALLING);
|
||||||
|
}
|
||||||
|
StopMoving();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Creature::RespawnOnEvade()
|
||||||
|
{
|
||||||
|
SetVisible(true);
|
||||||
|
UpdateMovementFlags();
|
||||||
|
AI()->Reset();
|
||||||
|
AI()->JustReachedHome();
|
||||||
|
if (IsVehicle()) // use the same sequence of addtoworld, aireset may remove all summons!
|
||||||
|
{
|
||||||
|
GetVehicleKit()->Reset(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Creature::InitializeReactState()
|
void Creature::InitializeReactState()
|
||||||
{
|
{
|
||||||
if ((IsTotem() || IsTrigger() || IsCritter() || IsSpiritService()) && GetAIName() != "SmartAI" && !GetScriptId())
|
if ((IsTotem() || IsTrigger() || IsCritter() || IsSpiritService()) && GetAIName() != "SmartAI" && !GetScriptId())
|
||||||
|
|||||||
@@ -257,6 +257,8 @@ public:
|
|||||||
void RemoveCorpse(bool setSpawnTime = true, bool skipVisibility = false);
|
void RemoveCorpse(bool setSpawnTime = true, bool skipVisibility = false);
|
||||||
|
|
||||||
void DespawnOrUnsummon(uint32 msTimeToDespawn = 0);
|
void DespawnOrUnsummon(uint32 msTimeToDespawn = 0);
|
||||||
|
void DespawnOnEvade();
|
||||||
|
void RespawnOnEvade();
|
||||||
|
|
||||||
[[nodiscard]] time_t const& GetRespawnTime() const { return m_respawnTime; }
|
[[nodiscard]] time_t const& GetRespawnTime() const { return m_respawnTime; }
|
||||||
[[nodiscard]] time_t GetRespawnTimeEx() const;
|
[[nodiscard]] time_t GetRespawnTimeEx() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user