Skip to content

Commit

Permalink
StaticFlags: Implement FOREVER_CORPSE_DURATION (#535)
Browse files Browse the repository at this point in the history
* StaticFlags: Implement FOREVER_CORPSE_DURATION

* StaticFlags: Guard against CorpseDuration interference
  • Loading branch information
insunaa authored Oct 7, 2024
1 parent 018e87f commit 081d066
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/game/Entities/Creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1900,7 +1900,10 @@ void Creature::SetDeathState(DeathState s)
else if (m_respawnOverrideOnce)
m_respawnOverriden = false;

m_corpseExpirationTime = GetMap()->GetCurrentClockTime() + std::chrono::milliseconds(m_corpseDelay * IN_MILLISECONDS); // the max/default time for corpse decay (before creature is looted/AllLootRemovedFromCorpse() is called)
if (m_settings.HasFlag(CreatureStaticFlags3::FOREVER_CORPSE_DURATION))
m_corpseExpirationTime = GetMap()->GetCurrentClockTime() + std::chrono::hours(24*7);
else
m_corpseExpirationTime = GetMap()->GetCurrentClockTime() + std::chrono::seconds(m_corpseDelay); // the max/default time for corpse decay (before creature is looted/AllLootRemovedFromCorpse() is called)
m_respawnTime = time(nullptr) + m_respawnDelay; // respawn delay (spawntimesecs)

// always save boss respawn time at death to prevent crash cheating
Expand Down Expand Up @@ -2781,6 +2784,8 @@ void Creature::InspectingLoot()
{
// until multiple corpse for creature is not supported
// this will not have effect after re spawn delay (corpse will be removed anyway)
if (m_settings.HasFlag(CreatureStaticFlags3::FOREVER_CORPSE_DURATION))
return;

// check if player have enough time to inspect loot
if (m_corpseExpirationTime < GetMap()->GetCurrentClockTime() + std::chrono::milliseconds(m_corpseAccelerationDecayDelay))
Expand All @@ -2793,6 +2798,9 @@ void Creature::ReduceCorpseDecayTimer()
if (!IsInWorld())
return;

if (m_settings.HasFlag(CreatureStaticFlags3::FOREVER_CORPSE_DURATION))
return;

if (m_corpseExpirationTime > GetMap()->GetCurrentClockTime() + std::chrono::milliseconds(m_corpseAccelerationDecayDelay))
m_corpseExpirationTime = GetMap()->GetCurrentClockTime() + std::chrono::milliseconds(m_corpseAccelerationDecayDelay); // 2 minutes for a creature
}
Expand Down

0 comments on commit 081d066

Please sign in to comment.