2013-12-03 07:31:46 +04:00
|
|
|
//========= Copyright Valve Corporation, All rights reserved. ============//
|
|
|
|
//
|
|
|
|
// Purpose:
|
|
|
|
//
|
|
|
|
// $NoKeywords: $
|
|
|
|
//
|
|
|
|
//=============================================================================//
|
|
|
|
#if !defined( USERCMD_H )
|
|
|
|
#define USERCMD_H
|
|
|
|
#ifdef _WIN32
|
|
|
|
#pragma once
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "mathlib/vector.h"
|
|
|
|
#include "utlvector.h"
|
|
|
|
#include "imovehelper.h"
|
|
|
|
#include "checksum_crc.h"
|
|
|
|
|
|
|
|
|
|
|
|
class bf_read;
|
|
|
|
class bf_write;
|
|
|
|
|
|
|
|
class CEntityGroundContact
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
int entindex;
|
|
|
|
float minheight;
|
|
|
|
float maxheight;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CUserCmd
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CUserCmd()
|
|
|
|
{
|
|
|
|
Reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~CUserCmd() { };
|
|
|
|
|
|
|
|
void Reset()
|
|
|
|
{
|
|
|
|
command_number = 0;
|
|
|
|
tick_count = 0;
|
|
|
|
viewangles.Init();
|
|
|
|
forwardmove = 0.0f;
|
|
|
|
sidemove = 0.0f;
|
|
|
|
upmove = 0.0f;
|
|
|
|
buttons = 0;
|
|
|
|
impulse = 0;
|
|
|
|
weaponselect = 0;
|
|
|
|
weaponsubtype = 0;
|
|
|
|
random_seed = 0;
|
|
|
|
mousedx = 0;
|
|
|
|
mousedy = 0;
|
|
|
|
|
|
|
|
hasbeenpredicted = false;
|
|
|
|
#if defined( HL2_DLL ) || defined( HL2_CLIENT_DLL )
|
|
|
|
entitygroundcontact.RemoveAll();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
CUserCmd& operator =( const CUserCmd& src )
|
|
|
|
{
|
|
|
|
if ( this == &src )
|
|
|
|
return *this;
|
|
|
|
|
|
|
|
command_number = src.command_number;
|
|
|
|
tick_count = src.tick_count;
|
|
|
|
viewangles = src.viewangles;
|
|
|
|
forwardmove = src.forwardmove;
|
|
|
|
sidemove = src.sidemove;
|
|
|
|
upmove = src.upmove;
|
|
|
|
buttons = src.buttons;
|
|
|
|
impulse = src.impulse;
|
|
|
|
weaponselect = src.weaponselect;
|
|
|
|
weaponsubtype = src.weaponsubtype;
|
|
|
|
random_seed = src.random_seed;
|
|
|
|
mousedx = src.mousedx;
|
|
|
|
mousedy = src.mousedy;
|
|
|
|
|
|
|
|
hasbeenpredicted = src.hasbeenpredicted;
|
|
|
|
|
|
|
|
#if defined( HL2_DLL ) || defined( HL2_CLIENT_DLL )
|
|
|
|
entitygroundcontact = src.entitygroundcontact;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
CUserCmd( const CUserCmd& src )
|
|
|
|
{
|
|
|
|
*this = src;
|
|
|
|
}
|
|
|
|
|
|
|
|
CRC32_t GetChecksum( void ) const
|
|
|
|
{
|
|
|
|
CRC32_t crc;
|
|
|
|
|
|
|
|
CRC32_Init( &crc );
|
|
|
|
CRC32_ProcessBuffer( &crc, &command_number, sizeof( command_number ) );
|
|
|
|
CRC32_ProcessBuffer( &crc, &tick_count, sizeof( tick_count ) );
|
|
|
|
CRC32_ProcessBuffer( &crc, &viewangles, sizeof( viewangles ) );
|
|
|
|
CRC32_ProcessBuffer( &crc, &forwardmove, sizeof( forwardmove ) );
|
|
|
|
CRC32_ProcessBuffer( &crc, &sidemove, sizeof( sidemove ) );
|
|
|
|
CRC32_ProcessBuffer( &crc, &upmove, sizeof( upmove ) );
|
|
|
|
CRC32_ProcessBuffer( &crc, &buttons, sizeof( buttons ) );
|
|
|
|
CRC32_ProcessBuffer( &crc, &impulse, sizeof( impulse ) );
|
|
|
|
CRC32_ProcessBuffer( &crc, &weaponselect, sizeof( weaponselect ) );
|
|
|
|
CRC32_ProcessBuffer( &crc, &weaponsubtype, sizeof( weaponsubtype ) );
|
|
|
|
CRC32_ProcessBuffer( &crc, &random_seed, sizeof( random_seed ) );
|
|
|
|
CRC32_ProcessBuffer( &crc, &mousedx, sizeof( mousedx ) );
|
|
|
|
CRC32_ProcessBuffer( &crc, &mousedy, sizeof( mousedy ) );
|
|
|
|
CRC32_Final( &crc );
|
|
|
|
|
|
|
|
return crc;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Allow command, but negate gameplay-affecting values
|
|
|
|
void MakeInert( void )
|
|
|
|
{
|
|
|
|
viewangles = vec3_angle;
|
|
|
|
forwardmove = 0.f;
|
|
|
|
sidemove = 0.f;
|
|
|
|
upmove = 0.f;
|
|
|
|
buttons = 0;
|
|
|
|
impulse = 0;
|
|
|
|
}
|
|
|
|
|
Mapbase v5.0
- Added keyvalue to hl2_gamerules which allows respawning in singleplayer
- Added the game instructor system (including env_instructor_hint) from later Valve games using a VDC tutorial which adjusts the version from the Alien Swarm SDK to FPS rules and a Source 2013 environment; Also added new KV and icons for further control from mappers (tutorial mentioned by Maestra Fenix)
- Added L4D/TF2 glows + point_glow entity as an all-purpose SDK-based off-shoot of tf_glow
- Fixed weapon pickup sound not playing (reported by Sl0th and later Cvoxulary)
- Fixed env_projectedtextures not updating on save/load
- Added func_fake_worldportal, a spatial point_camera inspired by linked_portal_door based on SDK code alone (WIP, may be changed a lot in future updates)
- Added option for point_camera and func_reflective_glass to use different render targets, therefore allowing multiple cameras and mirrors to be active at the same time
- Added additional RT camera textures to choose from with a default of 3, but also controllable through a -numcameratextures command line param
- Added adjustable convars for main view NearZ and skybox NearZ (suggested by someone recently, also suggested by Klems over a year ago)
- Fixed map-specific localization files, cleaned up map-specific file code
- Added a new block to gameinfo.txt which allows mods to automatically append their own command line parameters
- Fixed math_lightpattern corruption when setting pattern/style while active
- Fixed the "Touch" input crashing when given no entity
- Added a way to add EFlags via keyvalue (suggested by Niker107)
- Fixed ai_script_conditions not working without a NPC actor (reported by MetroHam)
- Fixed point_radiation_source causing huge problems when intensity is 0, even though it was already advised against (reported by beefbacon)
- Added "Mapbase" header to Mapbase-specific code files
- Fixed an issue with updating sky_camera not obtaining area correctly, causing some entities to not draw in the skybox
- Added "CopyFogController" and "CopyFogControllerWithScale" inputs to sky_camera, which copy fog parameters directly from a fog controller
- Added "SetScale" input to sky_camera for live scale changing
- Added convar to control player crouch speed multiplier (suggested by ArtyIF)
- Added a ton of fixes for people running the Debug configuration of the codebase (partial credit to stepa2)
- Added support for pre-defined enums and constants in VScript, starting with various values from the SDK code (damage types, trace masks, etc.)
- Added limited support for Valve's Quaternion class in VScript
- Added new instance helper capabilities, destructible game instances, and other misc. changes to VScript library
- Replaced most of the VScript "accessor" classes with direct references to the original classes, as they were getting complicated fast and adding new VScript-only functions to the original classes might not be as bad as previously thought
- Added base NPC hooks for AI sensing in VScript (allows control over sight and hearing), also exposed CSound for it
- Added various functions and hooks for VPhysics integration in VScript
- Added VScript-based custom suit devices
- Expanded trace info exposed to VScript to allow plane and surface access (suggested by krassell)
- Added ability to insert localization strings through VScript
- Added various misc. VScript functions with various purposes, including reading/writing EFlags, movetypes, collision groups, etc.
- Fixed VBSP not being able to correctly parse parallax corrected cubemaps in maps with instances
2020-08-15 00:21:25 +03:00
|
|
|
#ifdef MAPBASE_VSCRIPT // These functions are needed for exposing CUserCmd to VScript.
|
|
|
|
int GetCommandNumber() { return command_number; }
|
|
|
|
|
|
|
|
int ScriptGetTickCount() { return tick_count; }
|
|
|
|
|
|
|
|
const QAngle& GetViewAngles() { return viewangles; }
|
|
|
|
void SetViewAngles( const QAngle& val ) { viewangles = val; }
|
|
|
|
|
|
|
|
float GetForwardMove() { return forwardmove; }
|
|
|
|
void SetForwardMove( float val ) { forwardmove = val; }
|
|
|
|
float GetSideMove() { return sidemove; }
|
|
|
|
void SetSideMove( float val ) { sidemove = val; }
|
|
|
|
float GetUpMove() { return upmove; }
|
|
|
|
void SetUpMove( float val ) { upmove = val; }
|
|
|
|
|
|
|
|
int GetButtons() { return buttons; }
|
|
|
|
void SetButtons( int val ) { buttons = val; }
|
|
|
|
int GetImpulse() { return impulse; }
|
|
|
|
void SetImpulse( int val ) { impulse = val; }
|
|
|
|
|
|
|
|
int GetWeaponSelect() { return weaponselect; }
|
|
|
|
void SetWeaponSelect( int val ) { weaponselect = val; }
|
|
|
|
int GetWeaponSubtype() { return weaponsubtype; }
|
|
|
|
void SetWeaponSubtype( int val ) { weaponsubtype = val; }
|
|
|
|
|
|
|
|
int GetRandomSeed() { return random_seed; }
|
|
|
|
|
|
|
|
int GetMouseX() { return mousedx; }
|
|
|
|
void SetMouseX( int val ) { mousedx = val; }
|
|
|
|
int GetMouseY() { return mousedy; }
|
|
|
|
void SetMouseY( int val ) { mousedy = val; }
|
|
|
|
#endif
|
|
|
|
|
2013-12-03 07:31:46 +04:00
|
|
|
// For matching server and client commands for debugging
|
|
|
|
int command_number;
|
|
|
|
|
|
|
|
// the tick the client created this command
|
|
|
|
int tick_count;
|
|
|
|
|
|
|
|
// Player instantaneous view angles.
|
|
|
|
QAngle viewangles;
|
|
|
|
// Intended velocities
|
|
|
|
// forward velocity.
|
|
|
|
float forwardmove;
|
|
|
|
// sideways velocity.
|
|
|
|
float sidemove;
|
|
|
|
// upward velocity.
|
|
|
|
float upmove;
|
|
|
|
// Attack button states
|
|
|
|
int buttons;
|
|
|
|
// Impulse command issued.
|
|
|
|
byte impulse;
|
|
|
|
// Current weapon id
|
|
|
|
int weaponselect;
|
|
|
|
int weaponsubtype;
|
|
|
|
|
|
|
|
int random_seed; // For shared random functions
|
|
|
|
|
|
|
|
short mousedx; // mouse accum in x from create move
|
|
|
|
short mousedy; // mouse accum in y from create move
|
|
|
|
|
|
|
|
// Client only, tracks whether we've predicted this command at least once
|
|
|
|
bool hasbeenpredicted;
|
|
|
|
|
|
|
|
// Back channel to communicate IK state
|
|
|
|
#if defined( HL2_DLL ) || defined( HL2_CLIENT_DLL )
|
|
|
|
CUtlVector< CEntityGroundContact > entitygroundcontact;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2020-12-25 23:07:46 +03:00
|
|
|
#if defined( MAPBASE_VSCRIPT ) && defined( GAME_DLL )
|
|
|
|
void ReadUsercmd( bf_read *buf, CUserCmd *move, CUserCmd *from, CBaseEntity *pPlayer );
|
|
|
|
#else
|
2013-12-03 07:31:46 +04:00
|
|
|
void ReadUsercmd( bf_read *buf, CUserCmd *move, CUserCmd *from );
|
2020-12-25 23:07:46 +03:00
|
|
|
#endif
|
2013-12-03 07:31:46 +04:00
|
|
|
void WriteUsercmd( bf_write *buf, const CUserCmd *to, const CUserCmd *from );
|
|
|
|
|
|
|
|
#endif // USERCMD_H
|