mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-01-26 05:37:58 +03:00
dc7f20acc8
- Added custom map compile tools (vbsp, vvis, vrad) - Changed blink fix (shouldn't change anything in-game) - Added auto-completion to ent_create, npc_create, and the main set of "npc_" debug commands - Added ent_create_aimed, an ent_create equivalent of npc_create_aimed - Made hunters start using the "vs. player" melee animation against smaller NPCs that look weird with the "stab" attack - Added "explosion_sparks" convar, which fixes broken code for giving explosions sparks (disabled by default because of how different it looks) - Made interaction code capable of being dispatched on any entity, not just combat characters - Added npc_barnacle_ignite convar, which lets barnacles be ignited by flares - Fixed certain NPCs getting out of the way for the player when they hate them - Fixed auto-generated "speak" scene responses not using parameters that work on real VCDs - Made "stop_on_nonidle" capable of being used in any mod, not just HL2 episodic mods - Selectable color for ragdoll boogie/point_ragdollboogie - Fixed PickupWeaponInstant not firing weapon pickup outputs - Introduced inputs and keyvalues for "lerping" to math_counter_advanced - Fixed ClearConsole on logic_console - logic_convar should now detect client convars correctly - New NormalizeAngles input on math_vector - logic_modelinfo LookupActivity input - math_generate fixed and expanded to be more like math_counter - Added a WIP game logging system for playtesting maps - Introduced logic_playerinfo, an entity that can read a player's name or ID - Fixed some new filters not working with filter_multi - Added radius pickup spawnflag to func_physbox - Added "Preserve name" spawnflag to weapons - Added cc_achievement_debug message for when an achievement doesn't exist - Made npc_combine_s not speak while in logic_choreographed_scenes - Fixed zombie torsos/legs/headcrabs not being serverside when zombie is forced to server ragdoll - Expanded and cleaned up npc_zombie_custom - Fixed func_commandredirects not cleaning up correctly and sometimes crashing the game - Allowed player squad commands to go through +USE-held objects - Added a bunch of I/O/KV to trigger_waterydeath for better configuration - Changed save comment system to use the chapter title from world properties, and the ability to suppress the title popup that normally results from it - Adjusted game_convar_mod for MP planning - Removed the func_precipitation custom particle/splash code for now, as it was causing problems - Fixed env_global_light not accepting lightcolor - Added "Additional Buttons" to player_speedmod - Added save comment to RPC - Added env_projectedtexture attenuation - Added scripted_sequence OnPreIdleSequence - Added OnCrab to zombies - Added skill_changed game event (may need further testing) - Added a fix for viewmodels flipping under extreme FOV values - Added code that allows mappers to change the skin on shotgunners without it usually flipping back randomly - Fixed a very, very, very major shader performance issue - New SetAbsOrigin/Angles inputs on all entities, analogous to SetLocalOrigin/Angles - Code improvements for I/O involving angles - logic_entity_position improvements/fixes, including a new OutAngles output that outputs the angles on position calls - Alternate collision/player avoidance spawnflag obsoletion enforcement disabled - Enable/DisableHazardLights inputs on the EP2 jalopy, equivalent to the keyvalue - Miscellaneous shader formatting adjustments and fixes - Fixed AlwaysDrawOff on env_projectedtexture not being a valid input
244 lines
7.0 KiB
C++
244 lines
7.0 KiB
C++
//========= Copyright Valve Corporation, All rights reserved. ============//
|
|
//
|
|
// Purpose: A special system designed to record game information for map testing.
|
|
//
|
|
// $NoKeywords: $
|
|
//=============================================================================//
|
|
|
|
#include "cbase.h"
|
|
|
|
#include "tier0/icommandline.h"
|
|
#include "igamesystem.h"
|
|
#include "filesystem.h"
|
|
#include "utlbuffer.h"
|
|
#ifdef CLIENT_DLL
|
|
#else
|
|
#include "ammodef.h"
|
|
#include "ai_basenpc.h"
|
|
#include "ai_squad.h"
|
|
#include "fmtstr.h"
|
|
#include "GameEventListener.h"
|
|
#include "saverestore_utlvector.h"
|
|
#endif
|
|
|
|
// memdbgon must be the last include file in a .cpp file!!!
|
|
#include "tier0/memdbgon.h"
|
|
|
|
#ifdef GAME_DLL
|
|
// ------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------
|
|
|
|
class CMapbaseGameLogger : public CLogicalEntity, public CGameEventListener
|
|
{
|
|
public:
|
|
DECLARE_DATADESC();
|
|
DECLARE_CLASS( CMapbaseGameLogger, CLogicalEntity );
|
|
|
|
CMapbaseGameLogger()
|
|
{
|
|
pGameLoggerEnt = this;
|
|
}
|
|
|
|
void Activate()
|
|
{
|
|
BaseClass::Activate();
|
|
|
|
ListenForGameEvent("skill_changed");
|
|
}
|
|
|
|
void FireGameEvent( IGameEvent *event )
|
|
{
|
|
if (FStrEq(event->GetName(), "skill_changed"))
|
|
{
|
|
m_ListSkillChanged.AddToTail(event->GetInt("skill_level"));
|
|
m_ListSkillChangedTime.AddToTail(gpGlobals->curtime);
|
|
}
|
|
}
|
|
|
|
float m_flLastLogTime;
|
|
int m_iSaveID;
|
|
|
|
CUtlVector<int> m_ListSkillChanged;
|
|
CUtlVector<float> m_ListSkillChangedTime;
|
|
|
|
static CMapbaseGameLogger *GetGameLoggerEnt()
|
|
{
|
|
if (!pGameLoggerEnt)
|
|
pGameLoggerEnt = static_cast<CMapbaseGameLogger*>(CBaseEntity::Create("mapbase_game_logger", vec3_origin, vec3_angle));
|
|
|
|
return pGameLoggerEnt;
|
|
}
|
|
|
|
private:
|
|
static CHandle<CMapbaseGameLogger> pGameLoggerEnt;
|
|
};
|
|
|
|
LINK_ENTITY_TO_CLASS( mapbase_game_logger, CMapbaseGameLogger );
|
|
|
|
BEGIN_DATADESC( CMapbaseGameLogger )
|
|
|
|
DEFINE_FIELD( m_flLastLogTime, FIELD_TIME ),
|
|
DEFINE_FIELD( m_iSaveID, FIELD_INTEGER ),
|
|
|
|
DEFINE_UTLVECTOR( m_ListSkillChanged, FIELD_INTEGER ),
|
|
DEFINE_UTLVECTOR( m_ListSkillChangedTime, FIELD_TIME ),
|
|
|
|
END_DATADESC()
|
|
|
|
CHandle<CMapbaseGameLogger> CMapbaseGameLogger::pGameLoggerEnt;
|
|
|
|
void MapbaseGameLog_CVarToggle( IConVar *var, const char *pOldString, float flOldValue );
|
|
ConVar mapbase_game_log_on_autosave( "mapbase_game_log_on_autosave", "0", FCVAR_NONE, "Logs information to %mapname%_log_%number%.txt on each autosave", MapbaseGameLog_CVarToggle );
|
|
|
|
void MapbaseGameLog_Init()
|
|
{
|
|
if (mapbase_game_log_on_autosave.GetBool())
|
|
{
|
|
// Create the game logger ent
|
|
CMapbaseGameLogger::GetGameLoggerEnt();
|
|
}
|
|
}
|
|
|
|
void MapbaseGameLog_Record( const char *szContext )
|
|
{
|
|
CMapbaseGameLogger *pGameLoggerEnt = CMapbaseGameLogger::GetGameLoggerEnt();
|
|
if (!pGameLoggerEnt)
|
|
{
|
|
Warning("Failed to get game logger ent\n");
|
|
return;
|
|
}
|
|
|
|
KeyValues *pKV = new KeyValues( "Log" );
|
|
|
|
KeyValues *pKVLogInfo = pKV->FindKey( "logging_info", true );
|
|
if ( pKVLogInfo )
|
|
{
|
|
pKVLogInfo->SetString("context", szContext);
|
|
pKVLogInfo->SetFloat("last_log", pGameLoggerEnt->m_flLastLogTime > 0.0f ? gpGlobals->curtime - pGameLoggerEnt->m_flLastLogTime : -1.0f);
|
|
}
|
|
|
|
KeyValues *pKVGameInfo = pKV->FindKey( "game_info", true );
|
|
if ( pKVGameInfo )
|
|
{
|
|
pKVGameInfo->SetInt("skill", g_pGameRules->GetSkillLevel());
|
|
|
|
if (pGameLoggerEnt->m_ListSkillChanged.Count() > 0)
|
|
{
|
|
KeyValues *pKVSkill = pKVGameInfo->FindKey("skill_changes", true);
|
|
for (int i = 0; i < pGameLoggerEnt->m_ListSkillChanged.Count(); i++)
|
|
{
|
|
float flTime = pGameLoggerEnt->m_ListSkillChangedTime[i];
|
|
switch (pGameLoggerEnt->m_ListSkillChanged[i])
|
|
{
|
|
case SKILL_EASY: pKVSkill->SetString(CNumStr(flTime), "easy"); break;
|
|
case SKILL_MEDIUM: pKVSkill->SetString(CNumStr(flTime), "normal"); break;
|
|
case SKILL_HARD: pKVSkill->SetString(CNumStr(flTime), "hard"); break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
KeyValues *pKVPlayer = pKV->FindKey( "player", true );
|
|
if ( pKVPlayer )
|
|
{
|
|
CBasePlayer *pPlayer = UTIL_GetLocalPlayer();
|
|
|
|
if ( pPlayer )
|
|
{
|
|
pKVPlayer->SetInt("health", pPlayer->GetHealth());
|
|
pKVPlayer->SetInt("armor", pPlayer->ArmorValue());
|
|
|
|
pKVPlayer->SetString("position", CFmtStrN<128>("[%f %f %f]", pPlayer->GetAbsOrigin().x, pPlayer->GetAbsOrigin().y, pPlayer->GetAbsOrigin().z));
|
|
pKVPlayer->SetString("angles", CFmtStrN<128>("[%f %f %f]", pPlayer->EyeAngles().x, pPlayer->EyeAngles().y, pPlayer->EyeAngles().z));
|
|
|
|
KeyValues *pKVWeapons = pKVPlayer->FindKey( "weapons", true );
|
|
if ( pKVWeapons )
|
|
{
|
|
// Cycle through all of the player's weapons
|
|
for ( int i = 0; i < pPlayer->WeaponCount(); i++ )
|
|
{
|
|
CBaseCombatWeapon *pWeapon = pPlayer->GetWeapon(i);
|
|
if ( !pWeapon )
|
|
continue;
|
|
|
|
if ( pPlayer->GetActiveWeapon() == pWeapon )
|
|
pKVWeapons->SetString(pWeapon->GetClassname(), CFmtStrN<32>("%i; %i (active)", pWeapon->m_iClip1, pWeapon->m_iClip2));
|
|
else
|
|
pKVWeapons->SetString(pWeapon->GetClassname(), CFmtStrN<32>("%i; %i", pWeapon->m_iClip1, pWeapon->m_iClip2));
|
|
}
|
|
}
|
|
|
|
KeyValues *pKVAmmo = pKVPlayer->FindKey( "ammo", true );
|
|
if ( pKVAmmo )
|
|
{
|
|
// Cycle through all of the player's ammo
|
|
for ( int i = 0; i < GetAmmoDef()->m_nAmmoIndex; i++ )
|
|
{
|
|
int iAmmo = pPlayer->GetAmmoCount( i );
|
|
if ( iAmmo > 0 )
|
|
pKVAmmo->SetInt( GetAmmoDef()->m_AmmoType[i].pName, iAmmo );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
CAI_BaseNPC **ppAIs = g_AI_Manager.AccessAIs();
|
|
int nAIs = g_AI_Manager.NumAIs();
|
|
for (int i = 0; i < nAIs; i++)
|
|
{
|
|
CAI_BaseNPC *pNPC = ppAIs[i];
|
|
|
|
if (!pNPC->IsAlive() || pNPC->GetSleepState() != AISS_AWAKE)
|
|
continue;
|
|
|
|
KeyValues *pKVNPC = pKV->FindKey( CNumStr( pNPC->entindex() ), true );
|
|
if (pKVNPC)
|
|
{
|
|
pKVNPC->SetString("classname", pNPC->GetClassname());
|
|
pKVNPC->SetString("name", STRING(pNPC->GetEntityName()));
|
|
|
|
pKVNPC->SetString("position", CFmtStrN<128>("[%f %f %f]", pNPC->GetAbsOrigin().x, pNPC->GetAbsOrigin().y, pNPC->GetAbsOrigin().z));
|
|
|
|
pKVNPC->SetInt("health", pNPC->GetHealth());
|
|
|
|
if (pNPC->GetActiveWeapon())
|
|
pKVNPC->SetString("weapon", pNPC->GetActiveWeapon()->GetClassname());
|
|
|
|
if (pNPC->GetSquad())
|
|
pKVNPC->SetString("squad", pNPC->GetSquad()->GetName());
|
|
}
|
|
}
|
|
|
|
CFmtStrN<MAX_PATH> pathfmt("map_logs/%s_log_%i.txt", gpGlobals->mapname, pGameLoggerEnt->m_iSaveID);
|
|
|
|
pGameLoggerEnt->m_flLastLogTime = gpGlobals->curtime;
|
|
pGameLoggerEnt->m_iSaveID++;
|
|
|
|
// Create the folder first, since "map_logs" is not standard and is unlikely to exist
|
|
g_pFullFileSystem->CreateDirHierarchy( "map_logs", "MOD" );
|
|
|
|
if (pKV->SaveToFile( g_pFullFileSystem, pathfmt, "MOD" ))
|
|
{
|
|
Msg("Saved game log file to \"%s\"\n", pathfmt);
|
|
}
|
|
|
|
pKV->deleteThis();
|
|
}
|
|
|
|
static void CC_Mapbase_GameLogRecord( const CCommand& args )
|
|
{
|
|
MapbaseGameLog_Record( "command" );
|
|
}
|
|
|
|
static ConCommand mapbase_game_log_record("mapbase_game_log_record", CC_Mapbase_GameLogRecord, "Records game data to %mapname%_log_%number%." );
|
|
|
|
void MapbaseGameLog_CVarToggle( IConVar *var, const char *pOldString, float flOldValue )
|
|
{
|
|
if (mapbase_game_log_on_autosave.GetBool())
|
|
{
|
|
// Create the game logger ent
|
|
CMapbaseGameLogger::GetGameLoggerEnt();
|
|
}
|
|
}
|
|
#endif
|