- Added a function to get the actor's age in ticks.

This commit is contained in:
Player701 2018-11-04 20:55:52 +03:00 committed by Christoph Oelckers
parent a6dbfcf9c2
commit 56f76a141e
3 changed files with 21 additions and 0 deletions

View file

@ -1035,6 +1035,8 @@ public:
// When was this actor spawned? (relative to the current level)
int GetLevelSpawnTime() const;
// How many ticks passed since this actor was spawned?
int GetAge() const;
// info for drawing
// NOTE: The first member variable *must* be snext.

View file

@ -8085,6 +8085,24 @@ DEFINE_ACTION_FUNCTION(AActor, GetLevelSpawnTime)
ACTION_RETURN_INT(self->GetLevelSpawnTime());
}
//==========================================================================
//
// AActor :: GetAge
//
// Returns the number of ticks passed since this actor was spawned.
//
//==========================================================================
int AActor::GetAge() const
{
return level.totaltime - SpawnTime;
}
DEFINE_ACTION_FUNCTION(AActor, GetAge)
{
PARAM_SELF_PROLOGUE(AActor);
ACTION_RETURN_INT(self->GetAge());
}
//---------------------------------------------------------------------------
//
// PROP A_RestoreSpecialPosition

View file

@ -710,6 +710,7 @@ class Actor : Thinker native
native clearscope double GetCameraHeight() const;
native clearscope double GetGravity() const;
native clearscope int GetLevelSpawnTime() const;
native clearscope int GetAge() const;
native bool CheckClass(class<Actor> checkclass, int ptr_select = AAPTR_DEFAULT, bool match_superclass = false);
native void AddInventory(Inventory inv);