mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 17:54:48 +01:00
Core/Smartscripts: Add respawn timer to smartscript despawn (#20070)
This commit is contained in:
@@ -95,7 +95,7 @@ void SmartAI::UpdateDespawn(const uint32 diff)
|
||||
mDespawnState++;
|
||||
}
|
||||
else
|
||||
me->DespawnOrUnsummon();
|
||||
me->DespawnOrUnsummon(0, Seconds(mRespawnTime));
|
||||
} else mDespawnTime -= diff;
|
||||
}
|
||||
|
||||
@@ -532,6 +532,7 @@ bool SmartAI::AssistPlayerInCombatAgainst(Unit* who)
|
||||
void SmartAI::JustRespawned()
|
||||
{
|
||||
mDespawnTime = 0;
|
||||
mRespawnTime = 0;
|
||||
mDespawnState = 0;
|
||||
mEscortState = SMART_ESCORT_NONE;
|
||||
me->SetVisible(true);
|
||||
|
||||
@@ -185,11 +185,13 @@ class TC_GAME_API SmartAI : public CreatureAI
|
||||
|
||||
uint32 mEscortQuestID;
|
||||
|
||||
void SetDespawnTime (uint32 t)
|
||||
void SetDespawnTime (uint32 t, uint32 r = 0)
|
||||
{
|
||||
mDespawnTime = t;
|
||||
mRespawnTime = r;
|
||||
mDespawnState = t ? 1 : 0;
|
||||
}
|
||||
|
||||
void StartDespawn() { mDespawnState = 2; }
|
||||
|
||||
void OnSpellClick(Unit* clicker, bool& result) override;
|
||||
@@ -226,6 +228,7 @@ class TC_GAME_API SmartAI : public CreatureAI
|
||||
bool AssistPlayerInCombatAgainst(Unit* who);
|
||||
|
||||
uint32 mDespawnTime;
|
||||
uint32 mRespawnTime;
|
||||
uint32 mDespawnState;
|
||||
void UpdateDespawn(const uint32 diff);
|
||||
uint32 mEscortInvokerCheckTimer;
|
||||
|
||||
@@ -1237,11 +1237,11 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
if (target->IsAlive() && IsSmart(target))
|
||||
{
|
||||
ENSURE_AI(SmartAI, target->AI())->SetDespawnTime(e.action.forceDespawn.delay + 1); // Next tick
|
||||
ENSURE_AI(SmartAI, target->AI())->SetDespawnTime(e.action.forceDespawn.delay + 1, e.action.forceDespawn.respawn); // Next tick
|
||||
ENSURE_AI(SmartAI, target->AI())->StartDespawn();
|
||||
}
|
||||
else
|
||||
target->DespawnOrUnsummon(e.action.forceDespawn.delay);
|
||||
target->DespawnOrUnsummon(e.action.forceDespawn.delay, Seconds(e.action.forceDespawn.respawn));
|
||||
}
|
||||
else if (GameObject* goTarget = (*itr)->ToGameObject())
|
||||
goTarget->SetRespawnTime(e.action.forceDespawn.delay + 1);
|
||||
|
||||
@@ -777,6 +777,7 @@ struct SmartAction
|
||||
struct
|
||||
{
|
||||
uint32 delay;
|
||||
uint32 respawn;
|
||||
} forceDespawn;
|
||||
|
||||
struct
|
||||
|
||||
Reference in New Issue
Block a user