mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 17:54:48 +01:00
Core/SAI: added missing changes for SMART_ACTION_FORCE_DESPAWN that was causing broken despawn actions
This commit is contained in:
@@ -1046,22 +1046,18 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_FORCE_DESPAWN:
|
||||
{
|
||||
// there should be at least a world update tick before despawn, to avoid breaking linked actions
|
||||
int32 const respawnDelay = std::max<int32>(e.action.forceDespawn.delay, 1);
|
||||
Milliseconds despawnDelay(e.action.forceDespawn.delay);
|
||||
if (despawnDelay <= 0ms)
|
||||
despawnDelay = 1ms;
|
||||
|
||||
Seconds forceRespawnTimer(e.action.forceDespawn.forceRespawnTimer);
|
||||
|
||||
for (WorldObject* target : targets)
|
||||
{
|
||||
if (Creature* creatureTarget = target->ToCreature())
|
||||
{
|
||||
if (SmartAI* smartAI = CAST_AI(SmartAI, creatureTarget->AI()))
|
||||
{
|
||||
smartAI->SetDespawnTime(respawnDelay);
|
||||
smartAI->StartDespawn();
|
||||
}
|
||||
else
|
||||
creatureTarget->DespawnOrUnsummon(respawnDelay);
|
||||
}
|
||||
if (Creature* creature = target->ToCreature())
|
||||
creature->DespawnOrUnsummon(despawnDelay, forceRespawnTimer);
|
||||
else if (GameObject* goTarget = target->ToGameObject())
|
||||
goTarget->DespawnOrUnsummon(Milliseconds(respawnDelay));
|
||||
goTarget->DespawnOrUnsummon(despawnDelay, forceRespawnTimer);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -784,6 +784,7 @@ struct SmartAction
|
||||
struct
|
||||
{
|
||||
uint32 delay;
|
||||
uint32 forceRespawnTimer;
|
||||
} forceDespawn;
|
||||
|
||||
struct
|
||||
|
||||
@@ -389,7 +389,7 @@ void GameObject::Update(uint32 diff)
|
||||
else
|
||||
{
|
||||
m_despawnDelay = 0;
|
||||
DespawnOrUnsummon(0ms, m_despawnRespawnTime);;
|
||||
DespawnOrUnsummon(0ms, m_despawnRespawnTime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -809,7 +809,7 @@ void GameObject::AddUniqueUse(Player* player)
|
||||
m_unique_users.insert(player->GetGUID());
|
||||
}
|
||||
|
||||
void GameObject::DespawnOrUnsummon(Milliseconds delay, Seconds forceRespawnTime)
|
||||
void GameObject::DespawnOrUnsummon(Milliseconds const& delay, Seconds const& forceRespawnTime)
|
||||
{
|
||||
if (delay > 0ms)
|
||||
{
|
||||
@@ -821,11 +821,9 @@ void GameObject::DespawnOrUnsummon(Milliseconds delay, Seconds forceRespawnTime)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_goData)
|
||||
{
|
||||
uint32 const respawnDelay = (forceRespawnTime > 0s) ? forceRespawnTime.count() : m_goData->spawntimesecs;
|
||||
uint32 const respawnDelay = (forceRespawnTime > 0s) ? forceRespawnTime.count() : m_respawnDelayTime;
|
||||
if (m_goData && respawnDelay)
|
||||
SaveRespawnTime(respawnDelay);
|
||||
}
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject>
|
||||
void SetSpawnedByDefault(bool b) { m_spawnedByDefault = b; }
|
||||
uint32 GetRespawnDelay() const { return m_respawnDelayTime; }
|
||||
void Refresh();
|
||||
void DespawnOrUnsummon(Milliseconds delay = 0ms, Seconds forceRespawnTime = 0s);
|
||||
void DespawnOrUnsummon(Milliseconds const& delay = 0ms, Seconds const& forceRespawnTime = 0s);
|
||||
void Delete();
|
||||
void SendGameObjectDespawn();
|
||||
void getFishLoot(Loot* loot, Player* loot_owner);
|
||||
|
||||
Reference in New Issue
Block a user