diff --git a/src/g_levellocals.h b/src/g_levellocals.h index 0d7fc3cd5..0432c5aa1 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -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; diff --git a/src/p_setup.cpp b/src/p_setup.cpp index a6562f6c3..b1ecad7ed 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -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; diff --git a/src/p_tick.cpp b/src/p_tick.cpp index b15a83f01..7e37fec97 100644 --- a/src/p_tick.cpp +++ b/src/p_tick.cpp @@ -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; + } } diff --git a/src/statistics.cpp b/src/statistics.cpp index efee31d87..4c10bc1d4 100644 --- a/src/statistics.cpp +++ b/src/statistics.cpp @@ -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; +}