Skip to content

Commit

Permalink
Semi-fixed cs hostages
Browse files Browse the repository at this point in the history
  • Loading branch information
XutaxKamay committed Sep 8, 2024
1 parent 0fbddc0 commit 4377aa7
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 36 deletions.
3 changes: 0 additions & 3 deletions game/client/NextBot/C_NextBot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions game/client/c_baseanimating.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion game/client/c_baseentity.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -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 );

Expand Down
13 changes: 0 additions & 13 deletions game/client/cstrike/c_cs_hostage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -234,7 +224,6 @@ C_CHostage::C_CHostage()
C_CHostage::~C_CHostage()
{
g_Hostages.FindAndRemove( this );
m_PlayerAnimState->Release();
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -439,8 +428,6 @@ void C_CHostage::UpdateClientSideAnimation()
return;
}

m_PlayerAnimState->Update( GetAbsAngles()[YAW], GetAbsAngles()[PITCH] );

// initialize pose parameters
char *setToZero[] =
{
Expand Down
2 changes: 0 additions & 2 deletions game/client/cstrike/c_cs_hostage.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion game/client/hl2mp/c_hl2mp_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion game/client/portal/c_portal_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions game/server/NextBot/NextBot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ NextBotCombatCharacter::NextBotCombatCharacter( void )
{
m_lastAttacker = NULL;
m_didModelChange = false;

// Left4Dead have surfaces too steep for IK to work properly
DisableServerIK();
}


Expand Down
23 changes: 14 additions & 9 deletions game/server/baseanimating.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//
//=============================================================================//

#include "ai_activity.h"
#include "cbase.h"
#include "baseanimating.h"
#include "animation.h"
Expand Down Expand Up @@ -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()


Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -387,7 +397,7 @@ void CBaseAnimating::Spawn()
//-----------------------------------------------------------------------------
void CBaseAnimating::UseClientSideAnimation()
{
m_bClientSideAnimation = false;
m_bClientSideAnimation = true;
}

#define MAX_ANIMTIME_INTERVAL 0.2f
Expand Down Expand Up @@ -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 )
Expand Down
1 change: 1 addition & 0 deletions game/server/baseanimating.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ class CBaseAnimating : public CBaseEntity

public:
COutputEvent m_OnIgnite;
CNetworkVar( bool, m_bUseIks );

protected:
CStudioHdr *m_pStudioHdr;
Expand Down
7 changes: 4 additions & 3 deletions game/server/cstrike/hostage/cs_simple_hostage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -75,8 +75,7 @@ BEGIN_DATADESC( CHostage )

DEFINE_INPUTFUNC( FIELD_VOID, "OnRescueZoneTouch", HostageRescueZoneTouch ),

DEFINE_USEFUNC( HostageUse ),
DEFINE_THINKFUNC( HostageThink ),
DEFINE_USEFUNC( HostageUse )

END_DATADESC()

Expand Down Expand Up @@ -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();
}

//-----------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 4377aa7

Please sign in to comment.