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:
hdr88 2019-08-28 20:33:07 +02:00 committed by drfrag
parent a2d52f4958
commit f27afdb0d2
4 changed files with 21 additions and 1 deletions

View file

@ -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;

View file

@ -3146,6 +3146,8 @@ void P_FreeLevelData ()
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;

View file

@ -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;
}
}

View file

@ -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;
}