mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-16 09:31:14 +00:00
Add current, max and average velocity as stat (#912)
* Add current, max and average velocity as stat # Conflicts: # src/p_setup.cpp # src/p_tick.cpp # Conflicts: # src/p_setup.cpp # src/statistics.cpp
This commit is contained in:
parent
a2d52f4958
commit
f27afdb0d2
4 changed files with 21 additions and 1 deletions
|
@ -151,6 +151,9 @@ struct FLevelLocals : public FLevelData
|
|||
int total_monsters;
|
||||
int killed_monsters;
|
||||
|
||||
double max_velocity;
|
||||
double avg_velocity;
|
||||
|
||||
double gravity;
|
||||
double aircontrol;
|
||||
double airfriction;
|
||||
|
|
|
@ -3145,7 +3145,9 @@ void P_FreeLevelData ()
|
|||
tagManager.Clear();
|
||||
level.total_monsters = level.total_items = level.total_secrets =
|
||||
level.killed_monsters = level.found_items = level.found_secrets = 0;
|
||||
|
||||
|
||||
level.max_velocity = level.avg_velocity = 0;
|
||||
|
||||
if (level.sectors.Size() > 0)
|
||||
{
|
||||
delete[] level.sectors[0].e;
|
||||
|
|
|
@ -181,4 +181,8 @@ void P_Ticker (void)
|
|||
level.time++;
|
||||
level.maptime++;
|
||||
level.totaltime++;
|
||||
if (players[consoleplayer].mo != NULL) {
|
||||
if (players[consoleplayer].mo->Vel.Length() > level.max_velocity) { level.max_velocity = players[consoleplayer].mo->Vel.Length(); }
|
||||
level.avg_velocity += (players[consoleplayer].mo->Vel.Length() - level.avg_velocity) / level.maptime;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "g_level.h"
|
||||
#include "gstrings.h"
|
||||
#include "doomstat.h"
|
||||
#include "d_player.h"
|
||||
#include "configfile.h"
|
||||
#include "c_dispatch.h"
|
||||
#include "c_console.h"
|
||||
|
@ -614,3 +615,13 @@ ADD_STAT(statistics)
|
|||
StoreLevelStats(); // 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", level.MapName.GetChars(), level.max_velocity, level.avg_velocity);
|
||||
}
|
||||
return compose;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue