mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 14:51:51 +00:00
Add current, max and average velocity as stat (#912)
* Add current, max and average velocity as stat
This commit is contained in:
parent
07f8b7f61a
commit
554eb1c813
4 changed files with 19 additions and 0 deletions
|
@ -614,6 +614,9 @@ public:
|
|||
int total_monsters;
|
||||
int killed_monsters;
|
||||
|
||||
double max_velocity;
|
||||
double avg_velocity;
|
||||
|
||||
double gravity;
|
||||
double aircontrol;
|
||||
double airfriction;
|
||||
|
|
|
@ -599,3 +599,13 @@ ADD_STAT(statistics)
|
|||
StoreLevelStats(primaryLevel); // Refresh the current level's results.
|
||||
return GetStatString();
|
||||
}
|
||||
|
||||
ADD_STAT(velocity)
|
||||
{
|
||||
FString compose;
|
||||
if (players[consoleplayer].mo != NULL && gamestate == GS_LEVEL) {
|
||||
compose.AppendFormat("Current velocity: %.2f\n", players[consoleplayer].mo->Vel.Length());
|
||||
compose.AppendFormat("Level %s - Velocity Max: %.2f, Velocity Average: %.2f\n", primaryLevel->MapName.GetChars(), primaryLevel->max_velocity, primaryLevel->avg_velocity);
|
||||
}
|
||||
return compose;
|
||||
}
|
||||
|
|
|
@ -264,6 +264,8 @@ void FLevelLocals::ClearLevelData()
|
|||
total_monsters = total_items = total_secrets =
|
||||
killed_monsters = found_items = found_secrets = 0;
|
||||
|
||||
max_velocity = avg_velocity = 0;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
UDMFKeys[i].Clear();
|
||||
|
|
|
@ -180,5 +180,9 @@ void P_Ticker (void)
|
|||
Level->maptime++;
|
||||
Level->totaltime++;
|
||||
}
|
||||
if (players[consoleplayer].mo != NULL) {
|
||||
if (players[consoleplayer].mo->Vel.Length() > primaryLevel->max_velocity) { primaryLevel->max_velocity = players[consoleplayer].mo->Vel.Length(); }
|
||||
primaryLevel->avg_velocity += (players[consoleplayer].mo->Vel.Length() - primaryLevel->avg_velocity) / primaryLevel->maptime;
|
||||
}
|
||||
StatusBar->CallTick(); // Status bar should tick AFTER the thinkers to properly reflect the level's state at this time.
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue