580 lines
22 KiB
C
Raw Normal View History

2013-12-02 19:31:46 -08:00
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#ifndef BASEANIMATING_H
#define BASEANIMATING_H
#ifdef _WIN32
#pragma once
#endif
#include "baseentity.h"
#include "entityoutput.h"
#include "studio.h"
#include "datacache/idatacache.h"
#include "tier0/threadtools.h"
struct animevent_t;
struct matrix3x4_t;
class CIKContext;
class KeyValues;
FORWARD_DECLARE_HANDLE( memhandle_t );
#define BCF_NO_ANIMATION_SKIP ( 1 << 0 ) // Do not allow PVS animation skipping (mostly for attachments being critical to an entity)
#define BCF_IS_IN_SPAWN ( 1 << 1 ) // Is currently inside of spawn, always evaluate animations
class CBaseAnimating : public CBaseEntity
{
public:
DECLARE_CLASS( CBaseAnimating, CBaseEntity );
CBaseAnimating();
~CBaseAnimating();
DECLARE_PREDICTABLE();
enum
{
NUM_POSEPAREMETERS = 24,
NUM_BONECTRLS = 4
};
DECLARE_DATADESC();
DECLARE_SERVERCLASS();
DECLARE_ENT_SCRIPTDESC();
2013-12-02 19:31:46 -08:00
virtual void SetModel( const char *szModelName );
virtual void Activate();
virtual void Spawn();
virtual void Precache();
virtual void SetTransmit( CCheckTransmitInfo *pInfo, bool bAlways );
virtual int Restore( IRestore &restore );
virtual void OnRestore();
CStudioHdr *GetModelPtr( void );
void InvalidateMdlCache();
virtual CStudioHdr *OnNewModel();
virtual CBaseAnimating* GetBaseAnimating() { return this; }
// Cycle access
void SetCycle( float flCycle );
float GetCycle() const;
float GetAnimTimeInterval( void ) const;
// Call this in your constructor to tell it that you will not use animtime. Then the
// interpolation will be done correctly on the client.
// This defaults to off.
void UseClientSideAnimation();
// Tells whether or not we're using client-side animation. Used for controlling
// the transmission of animtime.
bool IsUsingClientSideAnimation() { return m_bClientSideAnimation; }
// Basic NPC Animation functions
virtual float GetIdealSpeed( ) const;
virtual float GetIdealAccel( ) const;
virtual void StudioFrameAdvance(); // advance animation frame to some time in the future
void StudioFrameAdvanceManual( float flInterval );
bool IsValidSequence( int iSequence );
inline float GetPlaybackRate();
inline void SetPlaybackRate( float rate );
inline int GetSequence() { return m_nSequence; }
virtual void SetSequence(int nSequence);
/* inline */ void ResetSequence(int nSequence);
// FIXME: push transitions support down into CBaseAnimating?
virtual bool IsActivityFinished( void ) { return m_bSequenceFinished; }
inline bool IsSequenceFinished( void ) { return m_bSequenceFinished; }
inline bool SequenceLoops( void ) { return m_bSequenceLoops; }
bool IsSequenceLooping( CStudioHdr *pStudioHdr, int iSequence );
inline bool IsSequenceLooping( int iSequence ) { return IsSequenceLooping(GetModelPtr(),iSequence); }
inline float SequenceDuration( void ) { return SequenceDuration( m_nSequence ); }
float SequenceDuration( CStudioHdr *pStudioHdr, int iSequence );
inline float SequenceDuration( int iSequence ) { return SequenceDuration(GetModelPtr(), iSequence); }
vscript additions and fixes: baseanimating.h baseanimating.cpp - Added CBaseAnimating::SequenceDuration (ScriptSequenceDuration) - Added CBaseAnimating::GetPlaybackRate - Added CBaseAnimating::SetPlaybackRate - Added CBaseAnimating::GetCycle - Added CBaseAnimating::SetCycle triggers.h triggers.cpp - Fixed CTriggerCamera::ScriptSetFov setting player FOV while disabled - Added CBaseTrigger::Enable - Added CBaseTrigger::Disable - Added CBaseTrigger::TouchTest - Added CBaseTrigger::IsTouching (ScriptIsTouching) vscript_server.nut vscript_server.cpp - Added CEntities::FindByClassnameWithinBox - Added ::SendToConsoleServer - Added ::CancelEntityIOEvent - Added ::GetEntityIOEventTimeLeft - Moved ScriptDispatchParticleEffect to shared code eventqueue.h cbase.h cbase.cpp - Set entity I/O con output colour - Added (CEventQueue::CancelEventsByInput) - Added (CEventQueue::RemoveEvent) - Added (CEventQueue::GetTimeLeft) baseentity.h baseentity.cpp - Added CBaseEntity::SetTransmitState - Added CBaseEntity::GetTransmitState - Added CBaseEntity::AcceptInput (ScriptAcceptInput) - Added CBaseEntity::FireOutput (ScriptFireOutput) - Added CBaseEntity::GetMaxOutputDelay - Added CBaseEntity::CancelEventsByInput - Added player_use event on InputUse - Fixed InputKill on players ivscript.h vscript_squirrel.cpp - Added IScriptVM::ArrayAppend - Fixed buffer overflow crash - Increased print buffer to 2048 from 256 - Set vscript print output colour vscript_funcs_shared.cpp - Added CNetMsgScriptHelper (CScriptGameEventListener) - Added ::ListenToGameEvent - Added ::StopListeningToGameEvent - Added ::StopListeningToAllGameEvents - Added ::FireGameEvent - Added ::FireGameEventLocal (CScriptSaveRestoreUtil) - Added ::SaveTable - Added ::RestoreTable - Added ::ClearSavedTable - Added callbacks ::OnSave, ::OnRestore (CScriptReadWriteFile) - Added ::StringToFile - Added ::FileToString - Added GlobalSys::GetCommandLine - Added GlobalSys::CommandLineCheck - Added GlobalSys::CommandLineCheckStr - Added GlobalSys::CommandLineCheckFloat - Added GlobalSys::CommandLineCheckInt - Added ::GetCPUUsage - Added ::NXPrint - Added ::Msg (ScriptMsg) - Removed misplaced condition checks - Fixed ScriptEntitiesInBox, *AtPoint, *InSphere logic_eventlistener.cpp - Removed redundant dev msg gamestringpool.cpp - Fixed string pool dump sort
2020-10-27 02:22:18 +03:00
#ifdef MAPBASE_VSCRIPT
inline float ScriptSequenceDuration( int iSequence ) { return SequenceDuration(GetModelPtr(), iSequence); }
#endif
2013-12-02 19:31:46 -08:00
float GetSequenceCycleRate( CStudioHdr *pStudioHdr, int iSequence );
inline float GetSequenceCycleRate( int iSequence ) { return GetSequenceCycleRate(GetModelPtr(),iSequence); }
float GetLastVisibleCycle( CStudioHdr *pStudioHdr, int iSequence );
virtual float GetSequenceGroundSpeed( CStudioHdr *pStudioHdr, int iSequence );
inline float GetSequenceGroundSpeed( int iSequence ) { return GetSequenceGroundSpeed(GetModelPtr(), iSequence); }
void ResetActivityIndexes ( void );
void ResetEventIndexes ( void );
int SelectWeightedSequence ( Activity activity );
int SelectWeightedSequence ( Activity activity, int curSequence );
int SelectHeaviestSequence ( Activity activity );
int LookupActivity( const char *label );
int LookupSequence ( const char *label );
KeyValues *GetSequenceKeyValues( int iSequence );
float GetSequenceMoveYaw( int iSequence );
float GetSequenceMoveDist( CStudioHdr *pStudioHdr, int iSequence );
inline float GetSequenceMoveDist( int iSequence ) { return GetSequenceMoveDist(GetModelPtr(),iSequence);}
void GetSequenceLinearMotion( int iSequence, Vector *pVec );
const char *GetSequenceName( int iSequence );
const char *GetSequenceActivityName( int iSequence );
Activity GetSequenceActivity( int iSequence );
void ResetSequenceInfo ( );
// This will stop animation until you call ResetSequenceInfo() at some point in the future
inline void StopAnimation( void ) { m_flPlaybackRate = 0; }
virtual void ClampRagdollForce( const Vector &vecForceIn, Vector *vecForceOut ) { *vecForceOut = vecForceIn; } // Base class does nothing.
virtual bool BecomeRagdollOnClient( const Vector &force );
virtual bool IsRagdoll();
virtual bool CanBecomeRagdoll( void ); //Check if this entity will ragdoll when dead.
virtual void GetSkeleton( CStudioHdr *pStudioHdr, Vector pos[], Quaternion q[], int boneMask );
virtual void GetBoneTransform( int iBone, matrix3x4_t &pBoneToWorld );
virtual void SetupBones( matrix3x4_t *pBoneToWorld, int boneMask );
virtual void CalculateIKLocks( float currentTime );
virtual void Teleport( const Vector *newPosition, const QAngle *newAngles, const Vector *newVelocity );
bool HasAnimEvent( int nSequence, int nEvent );
virtual void DispatchAnimEvents ( CBaseAnimating *eventHandler ); // Handle events that have happend since last time called up until X seconds into the future
virtual void HandleAnimEvent( animevent_t *pEvent );
int LookupPoseParameter( CStudioHdr *pStudioHdr, const char *szName );
inline int LookupPoseParameter( const char *szName ) { return LookupPoseParameter(GetModelPtr(), szName); }
float SetPoseParameter( CStudioHdr *pStudioHdr, const char *szName, float flValue );
inline float SetPoseParameter( const char *szName, float flValue ) { return SetPoseParameter( GetModelPtr(), szName, flValue ); }
float SetPoseParameter( CStudioHdr *pStudioHdr, int iParameter, float flValue );
inline float SetPoseParameter( int iParameter, float flValue ) { return SetPoseParameter( GetModelPtr(), iParameter, flValue ); }
float GetPoseParameter( const char *szName );
float GetPoseParameter( int iParameter );
bool GetPoseParameterRange( int index, float &minValue, float &maxValue );
bool HasPoseParameter( int iSequence, const char *szName );
bool HasPoseParameter( int iSequence, int iParameter );
float EdgeLimitPoseParameter( int iParameter, float flValue, float flBase = 0.0f );
protected:
// The modus operandi for pose parameters is that you should not use the const char * version of the functions
// in general code -- it causes many many string comparisons, which is slower than you think. Better is to
// save off your pose parameters in member variables in your derivation of this function:
virtual void PopulatePoseParameters( void );
public:
int LookupBone( const char *szName );
void GetBonePosition( const char *szName, Vector &origin, QAngle &angles );
void GetBonePosition( int iBone, Vector &origin, QAngle &angles );
int GetPhysicsBone( int boneIndex );
int GetNumBones ( void );
int FindTransitionSequence( int iCurrentSequence, int iGoalSequence, int *piDir );
bool GotoSequence( int iCurrentSequence, float flCurrentCycle, float flCurrentRate, int iGoalSequence, int &iNextSequence, float &flCycle, int &iDir );
int GetEntryNode( int iSequence );
int GetExitNode( int iSequence );
void GetEyeballs( Vector &origin, QAngle &angles ); // ?? remove ??
int LookupAttachment( const char *szName );
// These return the attachment in world space
bool GetAttachment( const char *szName, Vector &absOrigin, QAngle &absAngles );
bool GetAttachment( int iAttachment, Vector &absOrigin, QAngle &absAngles );
int GetAttachmentBone( int iAttachment );
virtual bool GetAttachment( int iAttachment, matrix3x4_t &attachmentToWorld );
const Vector& ScriptGetAttachmentOrigin(int iAttachment);
const Vector& ScriptGetAttachmentAngles(int iAttachment);
#ifdef MAPBASE_VSCRIPT
HSCRIPT ScriptGetAttachmentMatrix(int iAttachment);
float ScriptGetPoseParameter(const char* szName);
void ScriptSetPoseParameter(const char* szName, float fValue);
void ScriptGetBoneTransform( int iBone, HSCRIPT hTransform );
Mapbase v4.3 - Fixed a crash with multiple trigger_look targets - Fixed an issue where some zombie submodel server ragdolls are not solid to the world - Fixed a crash with certain instance classes being loaded in a savegame before the class is registered - Added some of Tony Sergi's missing Source 2007 fixes (contributed by Kris) - Added "ClientCommand" hook for VScript to allow handling of unknown console commands - Added "PlayerRunCommand" hook for VScript to control player movement - Added new button-related script functions for players (GetButtons, DisableButtons, etc.) - Added CUserCmd accessor in VScript for the "PlayerRunCommand" hook - Added "GetWaterLevel" function for VScript - Exposed "Ignite" to VScript for controlling how a fire starts - Fixed NPCs being unable to unholster weapons - Fixed Mapbase crashing when Steam isn't running - Fixed issues with angled/updating sky_camera save/restore - Added VBSP "-skyboxcubemap" parameter to enable skybox default cubemaps + "-defaultcubemapres" to control their resolution - Added ability to disable VScript in a map (and fixed a few potential complications from disabling VScript) - Made clientside VScript only initialize after world is spawned in order to receive serverside script language in time - Added tons of VScript functions to CBaseAnimating related to bodygroups, sequences, etc. - Added VScript functions to players for getting user ID and player name, similar to logic_playerinfo - Added a few L4D2 script functions missing from the ASW SDK - Added "Localize" singleton with a single "GetTokenAsUTF8" function for getting localization strings - Disabled r_hunkalloclightmaps by the request of various users (apparently this completely removes the "Engine hunk overflow" error and allows for really high-res lightmaps) - Fixed npc_antlionguard NPC_TranslateActivity not hooking into base class (allows for VScript manipulation) - Added various unused antlion guard activities to npc_antlionguard AI, allowing for usage as registered activities - Added keyvalue to set LOS mask on combine_mine - Added +USE bounding box limiter to prop_interactable
2020-07-16 15:43:30 +00:00
int ScriptGetSequenceActivity( int iSequence ) { return GetSequenceActivity( iSequence ); }
float ScriptGetSequenceMoveDist( int iSequence ) { return GetSequenceMoveDist( GetModelPtr(), iSequence ); }
int ScriptSelectHeaviestSequence( int activity ) { return SelectHeaviestSequence( (Activity)activity ); }
int ScriptSelectWeightedSequence( int activity, int curSequence ) { return SelectWeightedSequence( (Activity)activity, curSequence ); }
HSCRIPT ScriptGetSequenceKeyValues( int iSequence );
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-14 21:21:25 +00:00
// For VScript
int GetSkin() { return m_nSkin; }
void SetSkin( int iSkin ) { m_nSkin = iSkin; }
2021-01-23 09:20:21 -06:00
static ScriptHook_t g_Hook_OnServerRagdoll;
#endif
2013-12-02 19:31:46 -08:00
// These return the attachment in the space of the entity
bool GetAttachmentLocal( const char *szName, Vector &origin, QAngle &angles );
bool GetAttachmentLocal( int iAttachment, Vector &origin, QAngle &angles );
bool GetAttachmentLocal( int iAttachment, matrix3x4_t &attachmentToLocal );
// Non-angle versions of the attachments in world space
bool GetAttachment( const char *szName, Vector &absOrigin, Vector *forward = NULL, Vector *right = NULL, Vector *up = NULL );
bool GetAttachment( int iAttachment, Vector &absOrigin, Vector *forward = NULL, Vector *right = NULL, Vector *up = NULL );
void SetBodygroup( int iGroup, int iValue );
int GetBodygroup( int iGroup );
const char *GetBodygroupName( int iGroup );
int FindBodygroupByName( const char *name );
int GetBodygroupCount( int iGroup );
int GetNumBodyGroups( void );
void SetHitboxSet( int setnum );
void SetHitboxSetByName( const char *setname );
int GetHitboxSet( void );
char const *GetHitboxSetName( void );
int GetHitboxSetCount( void );
int GetHitboxBone( int hitboxIndex );
bool LookupHitbox( const char *szName, int& outSet, int& outBox );
// Computes a box that surrounds all hitboxes
bool ComputeHitboxSurroundingBox( Vector *pVecWorldMins, Vector *pVecWorldMaxs );
bool ComputeEntitySpaceHitboxSurroundingBox( Vector *pVecWorldMins, Vector *pVecWorldMaxs );
// Clone a CBaseAnimating from another (copies model & sequence data)
void CopyAnimationDataFrom( CBaseAnimating *pSource );
int ExtractBbox( int sequence, Vector& mins, Vector& maxs );
void SetSequenceBox( void );
int RegisterPrivateActivity( const char *pszActivityName );
void ResetClientsideFrame( void );
// Controllers.
virtual void InitBoneControllers ( void );
// Return's the controller's angle/position in bone space.
float GetBoneController ( int iController );
// Maps the angle/position value you specify into the bone's start/end and sets the specified controller to the value.
float SetBoneController ( int iController, float flValue );
void GetVelocity(Vector *vVelocity, AngularImpulse *vAngVelocity);
// these two need to move somewhere else
LocalFlexController_t GetNumFlexControllers( void );
const char *GetFlexDescFacs( int iFlexDesc );
const char *GetFlexControllerName( LocalFlexController_t iFlexController );
const char *GetFlexControllerType( LocalFlexController_t iFlexController );
virtual Vector GetGroundSpeedVelocity( void );
bool GetIntervalMovement( float flIntervalUsed, bool &bMoveSeqFinished, Vector &newPosition, QAngle &newAngles );
bool GetSequenceMovement( int nSequence, float fromCycle, float toCycle, Vector &deltaPosition, QAngle &deltaAngles );
float GetInstantaneousVelocity( float flInterval = 0.0 );
float GetEntryVelocity( int iSequence );
float GetExitVelocity( int iSequence );
float GetMovementFrame( float flDist );
bool HasMovement( int iSequence );
void ReportMissingActivity( int iActivity );
virtual bool TestCollision( const Ray_t &ray, unsigned int fContentsMask, trace_t& tr );
virtual bool TestHitboxes( const Ray_t &ray, unsigned int fContentsMask, trace_t& tr );
class CBoneCache *GetBoneCache( void );
void InvalidateBoneCache();
void InvalidateBoneCacheIfOlderThan( float deltaTime );
virtual int DrawDebugTextOverlays( void );
// See note in code re: bandwidth usage!!!
void DrawServerHitboxes( float duration = 0.0f, bool monocolor = false );
void DrawRawSkeleton( matrix3x4_t boneToWorld[], int boneMask, bool noDepthTest = true, float duration = 0.0f, bool monocolor = false );
void SetModelScale( float scale, float change_duration = 0.0f );
float GetModelScale() const { return m_flModelScale; }
void UpdateModelScale();
virtual void RefreshCollisionBounds( void );
// also calculate IK on server? (always done on client)
void EnableServerIK();
void DisableServerIK();
// for ragdoll vs. car
int GetHitboxesFrontside( int *boxList, int boxMax, const Vector &normal, float dist );
void GetInputDispatchEffectPosition( const char *sInputString, Vector &pOrigin, QAngle &pAngles );
virtual void ModifyOrAppendCriteria( AI_CriteriaSet& set );
// Send a muzzle flash event to the client for this entity.
void DoMuzzleFlash();
// Fire
virtual void Ignite( float flFlameLifetime, bool bNPCOnly = true, float flSize = 0.0f, bool bCalledByLevelDesigner = false );
virtual void IgniteLifetime( float flFlameLifetime );
virtual void IgniteNumHitboxFires( int iNumHitBoxFires );
virtual void IgniteHitboxFireScale( float flHitboxFireScale );
virtual void Extinguish() { RemoveFlag( FL_ONFIRE ); }
bool IsOnFire() { return ( (GetFlags() & FL_ONFIRE) != 0 ); }
void Scorch( int rate, int floor );
void InputIgnite( inputdata_t &inputdata );
void InputIgniteLifetime( inputdata_t &inputdata );
void InputIgniteNumHitboxFires( inputdata_t &inputdata );
void InputIgniteHitboxFireScale( inputdata_t &inputdata );
void InputBecomeRagdoll( inputdata_t &inputdata );
#ifdef MAPBASE
void InputCreateSeparateRagdoll( inputdata_t &inputdata );
void InputCreateSeparateRagdollClient( inputdata_t &inputdata );
Mapbase v3.0 - Overhauled matcher system and added expanded wildcard support, meaning "text", "te?t", "blah_test", etc. are now supported instead of only trailing * - Added support for regular expression matching - Added the missing matrixinvert.h file, which prevented programmers from compiling vbsp - Fixed env_global_light brightness - Added info_player_view_proxy, an entity which mimics a player's view (created for script_intro) - New UnZoomWithRate and SetZoomRate inputs on env_zoom - New "Don't change target's angles" flag on logic_measure_movement - Fixed logic_measure_movement not using ignore origin flags correctly - Fixed filter_damage_mod secondary filter not recognizing mode correctly - Fixed DisableGeigerCounter causing NPCs to ignore player, and possibly fixed other adverse effects in similar code - Added SetEntityName input for setting an entity's targetname - Added "SetTarget" support to point_posecontroller - Added "sk_alyx_health" convar for adjustable npc_alyx health, restored/fixed "sk_barney_health" for adjustable npc_barney health - Added ignore flags and several direction-related inputs to math_vector - Added pose parameter stuff to logic_modelinfo - Fixed ChangeWeapon not changing during combat - Fixed holster/unholster on NPCs without holster/unholster animations - Fixed func_tank and other "player in the way" code ignoring notarget - Added SetPoseParameter input to animating entities - Introduced an experimental chapter system which allows for custom chapter title/restriction management - Added SetChapterTitle input to worldspawn for dynamic title changing - Fixed func_tankairboatgun damage credit, added ability to use its damage keyvalues - Fixed mapbase_rpc_enabled not actually affecting RPC - Moved some newly found Combine soldier grenade code to ai_grenade for other grenade users - Fixed some problems with the new shared activities - Restored an old Mapbase entity as "prop_interactable", an entity which contains all of the functionality of a func_button/func_door in a prop entity - Added env_microphone pitch scale for scaling the pitch of transmitted sounds - Added experimental, long-overdue code for scenes to be able to access !target#'s and other scene-related names through AI_INPUT - Added "mat_specular_disable_on_missing", which "disables" specular reflections when the cubemap texture is missing - Fixed $envmapmasktransform and $bumptransform on VertexLitGeneric and related shaders - Areaportal leaks now stop compilation in leaktest - Replaced "-nodefaultcubemap" with "-defaultcubemap" as the shader changes allow maps to compile without default cubemaps by default with little effect
2020-02-05 19:08:49 +00:00
void InputSetPoseParameter( inputdata_t &inputdata );
#endif
2013-12-02 19:31:46 -08:00
// Dissolve, returns true if the ragdoll has been created
bool Dissolve( const char *pMaterialName, float flStartTime, bool bNPCOnly = true, int nDissolveType = 0, Vector vDissolverOrigin = vec3_origin, int iMagnitude = 0 );
bool IsDissolving() { return ( (GetFlags() & FL_DISSOLVING) != 0 ); }
void TransferDissolveFrom( CBaseAnimating *pAnim );
// animation needs
float m_flGroundSpeed; // computed linear movement rate for current sequence
float m_flLastEventCheck; // cycle index of when events were last checked
virtual void SetLightingOriginRelative( CBaseEntity *pLightingOriginRelative );
#ifdef MAPBASE
void SetLightingOriginRelative( string_t strLightingOriginRelative, inputdata_t *inputdata = NULL );
#else
2013-12-02 19:31:46 -08:00
void SetLightingOriginRelative( string_t strLightingOriginRelative );
#endif
2013-12-02 19:31:46 -08:00
CBaseEntity *GetLightingOriginRelative();
virtual void SetLightingOrigin( CBaseEntity *pLightingOrigin );
#ifdef MAPBASE
void SetLightingOrigin( string_t strLightingOrigin, inputdata_t *inputdata = NULL );
#else
2013-12-02 19:31:46 -08:00
void SetLightingOrigin( string_t strLightingOrigin );
#endif
2013-12-02 19:31:46 -08:00
CBaseEntity *GetLightingOrigin();
const float* GetPoseParameterArray() { return m_flPoseParameter.Base(); }
const float* GetEncodedControllerArray() { return m_flEncodedController.Base(); }
void BuildMatricesWithBoneMerge( const CStudioHdr *pStudioHdr, const QAngle& angles,
const Vector& origin, const Vector pos[MAXSTUDIOBONES],
const Quaternion q[MAXSTUDIOBONES], matrix3x4_t bonetoworld[MAXSTUDIOBONES],
CBaseAnimating *pParent, CBoneCache *pParentCache );
void SetFadeDistance( float minFadeDist, float maxFadeDist );
int GetBoneCacheFlags( void ) { return m_fBoneCacheFlags; }
inline void SetBoneCacheFlags( unsigned short fFlag ) { m_fBoneCacheFlags |= fFlag; }
inline void ClearBoneCacheFlags( unsigned short fFlag ) { m_fBoneCacheFlags &= ~fFlag; }
bool PrefetchSequence( int iSequence );
private:
void LockStudioHdr();
void UnlockStudioHdr();
void StudioFrameAdvanceInternal( CStudioHdr *pStudioHdr, float flInterval );
void InputSetLightingOriginRelative( inputdata_t &inputdata );
void InputSetLightingOrigin( inputdata_t &inputdata );
void InputSetModelScale( inputdata_t &inputdata );
#ifdef MAPBASE
void InputSetModel( inputdata_t &inputdata );
void InputSetCycle( inputdata_t &inputdata );
void InputSetPlaybackRate( inputdata_t &inputdata );
#endif
2013-12-02 19:31:46 -08:00
bool CanSkipAnimation( void );
public:
CNetworkVar( int, m_nForceBone );
CNetworkVector( m_vecForce );
CNetworkVar( int, m_nSkin );
CNetworkVar( int, m_nBody );
CNetworkVar( int, m_nHitboxSet );
// For making things thin during barnacle swallowing, e.g.
CNetworkVar( float, m_flModelScale );
// was pev->framerate
CNetworkVar( float, m_flPlaybackRate );
public:
void InitStepHeightAdjust( void );
void SetIKGroundContactInfo( float minHeight, float maxHeight );
void UpdateStepOrigin( void );
protected:
float m_flIKGroundContactTime;
float m_flIKGroundMinHeight;
float m_flIKGroundMaxHeight;
float m_flEstIkFloor; // debounced
float m_flEstIkOffset;
CIKContext *m_pIk;
int m_iIKCounter;
public:
Vector GetStepOrigin( void ) const;
QAngle GetStepAngles( void ) const;
private:
bool m_bSequenceFinished;// flag set when StudioAdvanceFrame moves across a frame boundry
bool m_bSequenceLoops; // true if the sequence loops
bool m_bResetSequenceInfoOnLoad; // true if a ResetSequenceInfo was queued up during dynamic load
float m_flDissolveStartTime;
// was pev->frame
CNetworkVar( float, m_flCycle );
CNetworkVar( int, m_nSequence );
CNetworkArray( float, m_flPoseParameter, NUM_POSEPAREMETERS ); // must be private so manual mode works!
CNetworkArray( float, m_flEncodedController, NUM_BONECTRLS ); // bone controller setting (0..1)
// Client-side animation (useful for looping animation objects)
CNetworkVar( bool, m_bClientSideAnimation );
CNetworkVar( bool, m_bClientSideFrameReset );
CNetworkVar( int, m_nNewSequenceParity );
CNetworkVar( int, m_nResetEventsParity );
// Incremented each time the entity is told to do a muzzle flash.
// The client picks up the change and draws the flash.
CNetworkVar( unsigned char, m_nMuzzleFlashParity );
CNetworkHandle( CBaseEntity, m_hLightingOrigin );
CNetworkHandle( CBaseEntity, m_hLightingOriginRelative );
string_t m_iszLightingOriginRelative; // for reading from the file only
string_t m_iszLightingOrigin; // for reading from the file only
memhandle_t m_boneCacheHandle;
unsigned short m_fBoneCacheFlags; // Used for bone cache state on model
protected:
CNetworkVar( float, m_fadeMinDist ); // Point at which fading is absolute
CNetworkVar( float, m_fadeMaxDist ); // Point at which fading is inactive
CNetworkVar( float, m_flFadeScale ); // Scale applied to min / max
public:
COutputEvent m_OnIgnite;
#ifdef MAPBASE
COutputEHANDLE m_OnServerRagdoll;
#endif
2013-12-02 19:31:46 -08:00
private:
CStudioHdr *m_pStudioHdr;
CThreadFastMutex m_StudioHdrInitLock;
CThreadFastMutex m_BoneSetupMutex;
// FIXME: necessary so that cyclers can hack m_bSequenceFinished
friend class CFlexCycler;
friend class CCycler;
friend class CBlendingCycler;
};
//-----------------------------------------------------------------------------
// Purpose: return a pointer to an updated studiomdl cache cache
//-----------------------------------------------------------------------------
inline CStudioHdr *CBaseAnimating::GetModelPtr( void )
{
if ( IsDynamicModelLoading() )
return NULL;
#ifdef _DEBUG
// GetModelPtr() is often called before OnNewModel() so go ahead and set it up first chance.
static IDataCacheSection *pModelCache = datacache->FindSection( "ModelData" );
AssertOnce( pModelCache->IsFrameLocking() );
#endif
if ( !m_pStudioHdr && GetModel() )
{
LockStudioHdr();
}
return ( m_pStudioHdr && m_pStudioHdr->IsValid() ) ? m_pStudioHdr : NULL;
}
inline void CBaseAnimating::InvalidateMdlCache()
{
UnlockStudioHdr();
if ( m_pStudioHdr != NULL )
{
delete m_pStudioHdr;
m_pStudioHdr = NULL;
}
}
//-----------------------------------------------------------------------------
// Purpose: Serves the 90% case of calling SetSequence / ResetSequenceInfo.
//-----------------------------------------------------------------------------
/*
inline void CBaseAnimating::ResetSequence(int nSequence)
{
m_nSequence = nSequence;
ResetSequenceInfo();
}
*/
inline float CBaseAnimating::GetPlaybackRate()
{
return m_flPlaybackRate;
}
inline void CBaseAnimating::SetPlaybackRate( float rate )
{
m_flPlaybackRate = rate;
}
inline void CBaseAnimating::SetLightingOrigin( CBaseEntity *pLightingOrigin )
{
m_hLightingOrigin = pLightingOrigin;
}
inline CBaseEntity *CBaseAnimating::GetLightingOrigin()
{
return m_hLightingOrigin;
}
inline void CBaseAnimating::SetLightingOriginRelative( CBaseEntity *pLightingOriginRelative )
{
m_hLightingOriginRelative = pLightingOriginRelative;
}
inline CBaseEntity *CBaseAnimating::GetLightingOriginRelative()
{
return m_hLightingOriginRelative;
}
//-----------------------------------------------------------------------------
// Cycle access
//-----------------------------------------------------------------------------
inline float CBaseAnimating::GetCycle() const
{
return m_flCycle;
}
inline void CBaseAnimating::SetCycle( float flCycle )
{
m_flCycle = flCycle;
}
EXTERN_SEND_TABLE(DT_BaseAnimating);
#define ANIMATION_SEQUENCE_BITS 12 // 4096 sequences
#define ANIMATION_SKIN_BITS 10 // 1024 body skin selections FIXME: this seems way high
#define ANIMATION_BODY_BITS 32 // body combinations
#define ANIMATION_HITBOXSET_BITS 2 // hit box sets
#if defined( TF_DLL )
#define ANIMATION_POSEPARAMETER_BITS 8 // pose parameter resolution
#else
#define ANIMATION_POSEPARAMETER_BITS 11 // pose parameter resolution
#endif
#define ANIMATION_PLAYBACKRATE_BITS 8 // default playback rate, only used on leading edge detect sequence changes
#endif // BASEANIMATING_H