Fixed issues with hand viewmodels not working upon weapon holster + Added a way to set the hand viewmodel bodygroup

This commit is contained in:
Blixibon 2021-10-09 15:09:48 -05:00
parent f880e95e47
commit 35f941d6d0
3 changed files with 36 additions and 1 deletions

View File

@ -142,7 +142,7 @@ void respawn( CBaseEntity *pEdict, bool fCopyCorpse )
{ {
// In SP respawns, only create corpse if drawing externally // In SP respawns, only create corpse if drawing externally
CBasePlayer *pPlayer = (CBasePlayer*)pEdict; CBasePlayer *pPlayer = (CBasePlayer*)pEdict;
if ( fCopyCorpse && pPlayer->m_bDrawPlayerModelExternally ) if ( fCopyCorpse && pPlayer->GetDrawPlayerModelExternally() )
{ {
// make a copy of the dead body for appearances sake // make a copy of the dead body for appearances sake
pPlayer->CreateCorpse(); pPlayer->CreateCorpse();

View File

@ -259,6 +259,7 @@ public:
void InputSetHandModel( inputdata_t &inputdata ); void InputSetHandModel( inputdata_t &inputdata );
void InputSetHandModelSkin( inputdata_t &inputdata ); void InputSetHandModelSkin( inputdata_t &inputdata );
void InputSetHandModelBodyGroup( inputdata_t &inputdata );
void InputSetPlayerModel( inputdata_t &inputdata ); void InputSetPlayerModel( inputdata_t &inputdata );
void InputSetPlayerDrawExternally( inputdata_t &inputdata ); void InputSetPlayerDrawExternally( inputdata_t &inputdata );
@ -4617,6 +4618,7 @@ BEGIN_DATADESC( CLogicPlayerProxy )
DEFINE_INPUTFUNC( FIELD_STRING, "GetAmmoOnWeapon", InputGetAmmoOnWeapon ), DEFINE_INPUTFUNC( FIELD_STRING, "GetAmmoOnWeapon", InputGetAmmoOnWeapon ),
DEFINE_INPUTFUNC( FIELD_STRING, "SetHandModel", InputSetHandModel ), DEFINE_INPUTFUNC( FIELD_STRING, "SetHandModel", InputSetHandModel ),
DEFINE_INPUTFUNC( FIELD_INTEGER, "SetHandModelSkin", InputSetHandModelSkin ), DEFINE_INPUTFUNC( FIELD_INTEGER, "SetHandModelSkin", InputSetHandModelSkin ),
DEFINE_INPUTFUNC( FIELD_INTEGER, "SetHandModelBodyGroup", InputSetHandModelBodyGroup ),
DEFINE_INPUTFUNC( FIELD_STRING, "SetPlayerModel", InputSetPlayerModel ), DEFINE_INPUTFUNC( FIELD_STRING, "SetPlayerModel", InputSetPlayerModel ),
DEFINE_INPUTFUNC( FIELD_BOOLEAN, "SetPlayerDrawExternally", InputSetPlayerDrawExternally ), DEFINE_INPUTFUNC( FIELD_BOOLEAN, "SetPlayerDrawExternally", InputSetPlayerDrawExternally ),
DEFINE_INPUT( m_MaxArmor, FIELD_INTEGER, "SetMaxInputArmor" ), DEFINE_INPUT( m_MaxArmor, FIELD_INTEGER, "SetMaxInputArmor" ),
@ -4659,6 +4661,8 @@ bool CLogicPlayerProxy::KeyValue( const char *szKeyName, const char *szValue )
vm->SetModel(szValue); vm->SetModel(szValue);
else if (FStrEq(szKeyName, "Skin")) // HandsVMSkin else if (FStrEq(szKeyName, "Skin")) // HandsVMSkin
vm->m_nSkin = atoi(szValue); vm->m_nSkin = atoi(szValue);
else if (FStrEq(szKeyName, "Body")) // HandsVMBody
vm->m_nBody = atoi(szValue);
} }
return true; return true;
} }
@ -5062,6 +5066,17 @@ void CLogicPlayerProxy::InputSetHandModelSkin( inputdata_t &inputdata )
vm->m_nSkin = inputdata.value.Int(); vm->m_nSkin = inputdata.value.Int();
} }
void CLogicPlayerProxy::InputSetHandModelBodyGroup( inputdata_t &inputdata )
{
if (!m_hPlayer)
return;
CBasePlayer *pPlayer = static_cast<CBasePlayer*>( m_hPlayer.Get() );
CBaseViewModel *vm = pPlayer->GetViewModel(1);
if (vm)
vm->m_nBody = inputdata.value.Int();
}
void CLogicPlayerProxy::InputSetPlayerModel( inputdata_t &inputdata ) void CLogicPlayerProxy::InputSetPlayerModel( inputdata_t &inputdata )
{ {
if (!m_hPlayer) if (!m_hPlayer)

View File

@ -289,6 +289,16 @@ void CBaseViewModel::AddEffects( int nEffects )
SetControlPanelsActive( false ); SetControlPanelsActive( false );
} }
#ifdef MAPBASE
// Apply effect changes to any viewmodel children as well
// (fixes hand models)
for (CBaseEntity *pChild = FirstMoveChild(); pChild != NULL; pChild = pChild->NextMovePeer())
{
if (pChild->GetClassname()[0] == 'h')
pChild->AddEffects( nEffects );
}
#endif
BaseClass::AddEffects( nEffects ); BaseClass::AddEffects( nEffects );
} }
@ -302,6 +312,16 @@ void CBaseViewModel::RemoveEffects( int nEffects )
SetControlPanelsActive( true ); SetControlPanelsActive( true );
} }
#ifdef MAPBASE
// Apply effect changes to any viewmodel children as well
// (fixes hand models)
for (CBaseEntity *pChild = FirstMoveChild(); pChild != NULL; pChild = pChild->NextMovePeer())
{
if (pChild->GetClassname()[0] == 'h')
pChild->RemoveEffects( nEffects );
}
#endif
BaseClass::RemoveEffects( nEffects ); BaseClass::RemoveEffects( nEffects );
} }