From 4377aa7b81e1d01a3b0951f3275e80ac6a6bf864 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 8 Sep 2024 22:37:08 +0200 Subject: [PATCH] Semi-fixed cs hostages --- game/client/NextBot/C_NextBot.cpp | 3 --- game/client/c_baseanimating.cpp | 7 +++--- game/client/c_baseentity.h | 2 +- game/client/cstrike/c_cs_hostage.cpp | 13 ----------- game/client/cstrike/c_cs_hostage.h | 2 -- game/client/hl2mp/c_hl2mp_player.cpp | 2 +- game/client/portal/c_portal_player.cpp | 2 +- game/server/NextBot/NextBot.cpp | 3 +++ game/server/baseanimating.cpp | 23 +++++++++++-------- game/server/baseanimating.h | 1 + .../cstrike/hostage/cs_simple_hostage.cpp | 7 +++--- 11 files changed, 29 insertions(+), 36 deletions(-) diff --git a/game/client/NextBot/C_NextBot.cpp b/game/client/NextBot/C_NextBot.cpp index 13d55012f7..dd1ff2bf65 100644 --- a/game/client/NextBot/C_NextBot.cpp +++ b/game/client/NextBot/C_NextBot.cpp @@ -24,9 +24,6 @@ END_RECV_TABLE() //----------------------------------------------------------------------------- C_NextBotCombatCharacter::C_NextBotCombatCharacter() { - // Left4Dead have surfaces too steep for IK to work properly - m_EntClientFlags |= ENTCLIENTFLAG_DONTUSEIK; - m_shadowType = SHADOWS_SIMPLE; m_forcedShadowType = SHADOWS_NONE; m_bForceShadowType = false; diff --git a/game/client/c_baseanimating.cpp b/game/client/c_baseanimating.cpp index 5edd016f0c..f52370d74b 100644 --- a/game/client/c_baseanimating.cpp +++ b/game/client/c_baseanimating.cpp @@ -181,7 +181,8 @@ IMPLEMENT_CLIENTCLASS_DT(C_BaseAnimating, DT_BaseAnimating, CBaseAnimating) RecvPropFloat( RECVINFO( m_fadeMinDist ) ), RecvPropFloat( RECVINFO( m_fadeMaxDist ) ), - RecvPropFloat( RECVINFO( m_flFadeScale ) ) + RecvPropFloat( RECVINFO( m_flFadeScale ) ), + RecvPropBool( RECVINFO(m_bUseIks) ) END_RECV_TABLE() @@ -2877,12 +2878,12 @@ bool C_BaseAnimating::SetupBones( matrix3x4_t *pBoneToWorldOut, int nMaxBones, i AddFlag( EFL_SETTING_UP_BONES ); // NOTE: For model scaling, we need to opt out of IK because it will mark the bones as already being calculated - if ( !IsModelScaled() ) + if ( !IsModelScaled() && m_bUseIks ) { // only allocate an ik block if the npc can use it // The flag is now completely ignored to match server bones! // If it doesn't work well, blame models. - if ( !m_pIk && hdr->numikchains() > 0 && !(m_EntClientFlags & ENTCLIENTFLAG_DONTUSEIK) ) + if ( !m_pIk && hdr->numikchains() > 0 ) { m_pIk = new CIKContext; } diff --git a/game/client/c_baseentity.h b/game/client/c_baseentity.h index efffc14d37..b739759dd6 100644 --- a/game/client/c_baseentity.h +++ b/game/client/c_baseentity.h @@ -178,7 +178,6 @@ struct thinkfunc_t // Entity flags that only exist on the client. #define ENTCLIENTFLAG_GETTINGSHADOWRENDERBOUNDS 0x0001 // Tells us if we're getting the real ent render bounds or the shadow render bounds. -#define ENTCLIENTFLAG_DONTUSEIK 0x0002 // Don't use IK on this entity even if its model has IK. #define ENTCLIENTFLAG_ALWAYS_INTERPOLATE 0x0004 // Used by view models. //----------------------------------------------------------------------------- @@ -1286,6 +1285,7 @@ class C_BaseEntity : public IClientEntity // Entity flags that are only for the client (ENTCLIENTFLAG_ defines). unsigned short m_EntClientFlags; + bool m_bUseIks; CNetworkColor32( m_clrRender ); diff --git a/game/client/cstrike/c_cs_hostage.cpp b/game/client/cstrike/c_cs_hostage.cpp index 6dfbd0d100..2796f4b021 100644 --- a/game/client/cstrike/c_cs_hostage.cpp +++ b/game/client/cstrike/c_cs_hostage.cpp @@ -202,16 +202,6 @@ C_CHostage::C_CHostage() m_flDeadOrRescuedTime = 0.0; m_flLastBodyYaw = 0; m_createdLowViolenceRagdoll = false; - - // TODO: Get IK working on the steep slopes CS has, then enable it on characters. - // Breaks server side setup bones ! - // m_EntClientFlags |= ENTCLIENTFLAG_DONTUSEIK; - - // set the model so the PlayerAnimState uses the Hostage activities/sequences - SetModelName( "models/Characters/Hostage_01.mdl" ); - - m_PlayerAnimState = CreateHostageAnimState( this, this, LEGANIM_8WAY, false ); - m_leader = NULL; m_blinkTimer.Invalidate(); m_seq = -1; @@ -234,7 +224,6 @@ C_CHostage::C_CHostage() C_CHostage::~C_CHostage() { g_Hostages.FindAndRemove( this ); - m_PlayerAnimState->Release(); } //----------------------------------------------------------------------------- @@ -439,8 +428,6 @@ void C_CHostage::UpdateClientSideAnimation() return; } - m_PlayerAnimState->Update( GetAbsAngles()[YAW], GetAbsAngles()[PITCH] ); - // initialize pose parameters char *setToZero[] = { diff --git a/game/client/cstrike/c_cs_hostage.h b/game/client/cstrike/c_cs_hostage.h index 35ba2f970a..1f3863e00e 100644 --- a/game/client/cstrike/c_cs_hostage.h +++ b/game/client/cstrike/c_cs_hostage.h @@ -65,8 +65,6 @@ class C_CHostage : public C_BaseCombatCharacter, public ICSPlayerAnimStateHelper int m_OldLifestate; int m_iMaxHealth; - ICSPlayerAnimState *m_PlayerAnimState; - CNetworkVar( EHANDLE, m_leader ); // who we are following, or NULL CNetworkVar( bool, m_isRescued ); diff --git a/game/client/hl2mp/c_hl2mp_player.cpp b/game/client/hl2mp/c_hl2mp_player.cpp index 49e55e293f..59915121cd 100644 --- a/game/client/hl2mp/c_hl2mp_player.cpp +++ b/game/client/hl2mp/c_hl2mp_player.cpp @@ -54,7 +54,7 @@ C_HL2MP_Player::C_HL2MP_Player() : m_PlayerAnimState( this ), m_iv_angEyeAngles( AddVar( &m_angEyeAngles, &m_iv_angEyeAngles, LATCH_SIMULATION_VAR ); - m_EntClientFlags |= ENTCLIENTFLAG_DONTUSEIK; + DisableServerIK(); m_blinkTimer.Invalidate(); m_pFlashlightBeam = NULL; diff --git a/game/client/portal/c_portal_player.cpp b/game/client/portal/c_portal_player.cpp index 59ce85bfdc..1b4e59e00e 100644 --- a/game/client/portal/c_portal_player.cpp +++ b/game/client/portal/c_portal_player.cpp @@ -324,7 +324,7 @@ C_Portal_Player::C_Portal_Player() AddVar( &m_angEyeAngles, &m_iv_angEyeAngles, LATCH_SIMULATION_VAR ); - m_EntClientFlags |= ENTCLIENTFLAG_DONTUSEIK; + DisableServerIK(); m_blinkTimer.Invalidate(); m_CCDeathHandle = INVALID_CLIENT_CCHANDLE; diff --git a/game/server/NextBot/NextBot.cpp b/game/server/NextBot/NextBot.cpp index 0165a0339d..1358eac65b 100644 --- a/game/server/NextBot/NextBot.cpp +++ b/game/server/NextBot/NextBot.cpp @@ -215,6 +215,9 @@ NextBotCombatCharacter::NextBotCombatCharacter( void ) { m_lastAttacker = NULL; m_didModelChange = false; + + // Left4Dead have surfaces too steep for IK to work properly + DisableServerIK(); } diff --git a/game/server/baseanimating.cpp b/game/server/baseanimating.cpp index 3eecf9a0fc..20c1239c90 100644 --- a/game/server/baseanimating.cpp +++ b/game/server/baseanimating.cpp @@ -4,6 +4,7 @@ // //=============================================================================// +#include "ai_activity.h" #include "cbase.h" #include "baseanimating.h" #include "animation.h" @@ -261,7 +262,8 @@ IMPLEMENT_SERVERCLASS_ST(CBaseAnimating, DT_BaseAnimating) // Fading SendPropFloat( SENDINFO( m_fadeMinDist ), 0, SPROP_NOSCALE ), SendPropFloat( SENDINFO( m_fadeMaxDist ), 0, SPROP_NOSCALE ), - SendPropFloat( SENDINFO( m_flFadeScale ), 0, SPROP_NOSCALE ) + SendPropFloat( SENDINFO( m_flFadeScale ), 0, SPROP_NOSCALE ), + SendPropBool( SENDINFO( m_bUseIks ) ) END_SEND_TABLE() @@ -289,6 +291,14 @@ CBaseAnimating::CBaseAnimating() m_fadeMaxDist = 0; m_flFadeScale = 0.0f; m_fBoneCacheFlags = 0; + m_bUseIks = true; + + int sequence = SelectWeightedSequence( ACT_IDLE ); + + if (GetSequence() != sequence) + { + SetSequence( sequence ); + } } CBaseAnimating::~CBaseAnimating() @@ -387,7 +397,7 @@ void CBaseAnimating::Spawn() //----------------------------------------------------------------------------- void CBaseAnimating::UseClientSideAnimation() { - m_bClientSideAnimation = false; + m_bClientSideAnimation = true; } #define MAX_ANIMTIME_INTERVAL 0.2f @@ -3499,17 +3509,12 @@ int CBaseAnimating::GetHitboxesFrontside( int *boxList, int boxMax, const Vector void CBaseAnimating::EnableServerIK() { - if (!m_pIk) - { - m_pIk = new CIKContext; - m_iIKCounter = 0; - } + m_bUseIks = true; } void CBaseAnimating::DisableServerIK() { - delete m_pIk; - m_pIk = NULL; + m_bUseIks = false; } Activity CBaseAnimating::GetSequenceActivity( int iSequence ) diff --git a/game/server/baseanimating.h b/game/server/baseanimating.h index c54984b6f1..92a8d752cf 100644 --- a/game/server/baseanimating.h +++ b/game/server/baseanimating.h @@ -424,6 +424,7 @@ class CBaseAnimating : public CBaseEntity public: COutputEvent m_OnIgnite; + CNetworkVar( bool, m_bUseIks ); protected: CStudioHdr *m_pStudioHdr; diff --git a/game/server/cstrike/hostage/cs_simple_hostage.cpp b/game/server/cstrike/hostage/cs_simple_hostage.cpp index 1bc4f3984c..e30b9dcc12 100644 --- a/game/server/cstrike/hostage/cs_simple_hostage.cpp +++ b/game/server/cstrike/hostage/cs_simple_hostage.cpp @@ -35,7 +35,7 @@ // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" -#define HOSTAGE_THINK_INTERVAL 0.1f +#define HOSTAGE_THINK_INTERVAL gpGlobals->interval_per_tick #define DrawLine( from, to, duration, red, green, blue ) NDebugOverlay::Line( from, to, red, green, blue, true, 0.1f ) #define HOSTAGE_PUSHAWAY_THINK_CONTEXT "HostagePushawayThink" @@ -75,8 +75,7 @@ BEGIN_DATADESC( CHostage ) DEFINE_INPUTFUNC( FIELD_VOID, "OnRescueZoneTouch", HostageRescueZoneTouch ), - DEFINE_USEFUNC( HostageUse ), - DEFINE_THINKFUNC( HostageThink ), + DEFINE_USEFUNC( HostageUse ) END_DATADESC() @@ -104,6 +103,8 @@ CHostage::CHostage() g_Hostages.AddToTail( this ); m_PlayerAnimState = CreateHostageAnimState( this, this, LEGANIM_8WAY, false ); SetBloodColor( BLOOD_COLOR_RED ); + // TODO_ENHANCED: Get IK working on the steep slopes CS has, then enable it on characters. + DisableServerIK(); } //-----------------------------------------------------------------------------------------------------