- Added a new field to the Actor class which stores the amount of ticks passed since the game started on the moment the actor was spawned.

- Added a function to the Actor class to get its spawn time relative to the current level.
- Added spawn time information to the output of the "info" console command.
This commit is contained in:
Player701 2018-11-04 20:30:40 +03:00 committed by Christoph Oelckers
parent b1d35eb0b3
commit a6dbfcf9c2
4 changed files with 35 additions and 3 deletions

View File

@ -1033,6 +1033,8 @@ public:
void AttachLight(unsigned int count, const FLightDefaults *lightdef);
void SetDynamicLights();
// When was this actor spawned? (relative to the current level)
int GetLevelSpawnTime() const;
// info for drawing
// NOTE: The first member variable *must* be snext.
@ -1262,6 +1264,9 @@ public:
int PrevPortalGroup;
TArray<TObjPtr<AActor*> > AttachedLights;
// When was this actor spawned?
int SpawnTime;
// ThingIDs
static void ClearTIDHashes ();
void AddToHash ();

View File

@ -348,6 +348,7 @@ DEFINE_FIELD(AActor, BloodTranslation)
DEFINE_FIELD(AActor, RenderHidden)
DEFINE_FIELD(AActor, RenderRequired)
DEFINE_FIELD(AActor, friendlyseeblocks)
DEFINE_FIELD(AActor, SpawnTime)
//==========================================================================
//
@ -528,8 +529,9 @@ void AActor::Serialize(FSerializer &arc)
A("selfdamagefactor", SelfDamageFactor)
A("stealthalpha", StealthAlpha)
A("renderhidden", RenderHidden)
A("renderrequired", RenderRequired);
A("friendlyseeblocks", friendlyseeblocks);
A("renderrequired", RenderRequired)
A("friendlyseeblocks", friendlyseeblocks)
A("spawntime", SpawnTime);
}
#undef A
@ -5006,6 +5008,7 @@ AActor *AActor::StaticSpawn (PClassActor *type, const DVector3 &pos, replace_t a
AActor *actor;
actor = static_cast<AActor *>(const_cast<PClassActor *>(type)->CreateNew ());
actor->SpawnTime = level.totaltime;
// Set default dialogue
actor->ConversationRoot = GetConversation(actor->GetClass()->TypeName);
@ -8063,6 +8066,25 @@ void AActor::SetTranslation(FName trname)
// silently ignore if the name does not exist, this would create some insane message spam otherwise.
}
//==========================================================================
//
// AActor :: GetLevelSpawnTime
//
// Returns the time when this actor was spawned,
// relative to the current level.
//
//==========================================================================
int AActor::GetLevelSpawnTime() const
{
return SpawnTime - level.totaltime + level.time;
}
DEFINE_ACTION_FUNCTION(AActor, GetLevelSpawnTime)
{
PARAM_SELF_PROLOGUE(AActor);
ACTION_RETURN_INT(self->GetLevelSpawnTime());
}
//---------------------------------------------------------------------------
//
// PROP A_RestoreSpecialPosition
@ -8587,5 +8609,8 @@ void PrintMiscActorInfo(AActor *query)
Printf("FriendlySeeBlocks: %d\n", query->friendlyseeblocks);
Printf("Target: %s\n", query->target ? query->target->GetClass()->TypeName.GetChars() : "-");
Printf("Last enemy: %s\n", query->lastenemy ? query->lastenemy->GetClass()->TypeName.GetChars() : "-");
Printf("Spawn time: %d ticks (%f seconds) after game start, %d ticks (%f seconds) after level start\n",
query->SpawnTime, (double) query->SpawnTime / TICRATE,
query->GetLevelSpawnTime(), (double) query->GetLevelSpawnTime() / TICRATE);
}
}

View File

@ -91,7 +91,7 @@ const char *GetVersionString();
// Use 4500 as the base git save version, since it's higher than the
// SVN revision ever got.
#define SAVEVER 4552
#define SAVEVER 4553
// This is so that derivates can use the same savegame versions without worrying about engine compatibility
#define GAMESIG "GZDOOM"

View File

@ -234,6 +234,7 @@ class Actor : Thinker native
native int RenderHidden;
native int RenderRequired;
native readonly int FriendlySeeBlocks;
native readonly int SpawnTime;
meta String Obituary; // Player was killed by this actor
meta String HitObituary; // Player was killed by this actor in melee
@ -708,6 +709,7 @@ class Actor : Thinker native
native void GiveSecret(bool printmsg = true, bool playsound = true);
native clearscope double GetCameraHeight() const;
native clearscope double GetGravity() const;
native clearscope int GetLevelSpawnTime() const;
native bool CheckClass(class<Actor> checkclass, int ptr_select = AAPTR_DEFAULT, bool match_superclass = false);
native void AddInventory(Inventory inv);