mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-02-26 13:41:11 +03:00
Added gameinfo keyvalues for default hands models + code to hide custom hands on weapons which don't support them
This commit is contained in:
parent
2282aedfa6
commit
dbb0ed6f46
@ -632,6 +632,10 @@ void CBasePlayer::DestroyViewModels( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MAPBASE
|
#ifdef MAPBASE
|
||||||
|
extern char g_szDefaultHandsModel[MAX_PATH];
|
||||||
|
extern int g_iDefaultHandsSkin;
|
||||||
|
extern int g_iDefaultHandsBody;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -648,6 +652,11 @@ void CBasePlayer::CreateHandModel(int index, int iOtherVm)
|
|||||||
vm->SetAbsOrigin(GetAbsOrigin());
|
vm->SetAbsOrigin(GetAbsOrigin());
|
||||||
vm->SetOwner(this);
|
vm->SetOwner(this);
|
||||||
vm->SetIndex(index);
|
vm->SetIndex(index);
|
||||||
|
|
||||||
|
vm->SetModel( g_szDefaultHandsModel );
|
||||||
|
vm->m_nSkin = g_iDefaultHandsSkin;
|
||||||
|
vm->m_nBody = g_iDefaultHandsBody;
|
||||||
|
|
||||||
DispatchSpawn(vm);
|
DispatchSpawn(vm);
|
||||||
vm->FollowEntity(GetViewModel(iOtherVm), true);
|
vm->FollowEntity(GetViewModel(iOtherVm), true);
|
||||||
m_hViewModel.Set(index, vm);
|
m_hViewModel.Set(index, vm);
|
||||||
@ -5418,6 +5427,10 @@ void CBasePlayer::Precache( void )
|
|||||||
m_iTrain = TRAIN_NEW;
|
m_iTrain = TRAIN_NEW;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
PrecacheModel( g_szDefaultHandsModel );
|
||||||
|
#endif
|
||||||
|
|
||||||
m_iClientBattery = -1;
|
m_iClientBattery = -1;
|
||||||
|
|
||||||
m_iUpdateTime = 5; // won't update for 1/2 a second
|
m_iUpdateTime = 5; // won't update for 1/2 a second
|
||||||
|
@ -290,12 +290,15 @@ void CBaseViewModel::AddEffects( int nEffects )
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MAPBASE
|
#ifdef MAPBASE
|
||||||
// Apply effect changes to any viewmodel children as well
|
if (GetOwningWeapon() && GetOwningWeapon()->UsesHands())
|
||||||
// (fixes hand models)
|
|
||||||
for (CBaseEntity *pChild = FirstMoveChild(); pChild != NULL; pChild = pChild->NextMovePeer())
|
|
||||||
{
|
{
|
||||||
if (pChild->GetClassname()[0] == 'h')
|
// If using hands, apply effect changes to any viewmodel children as well
|
||||||
pChild->AddEffects( nEffects );
|
// (fixes hand models)
|
||||||
|
for (CBaseEntity *pChild = FirstMoveChild(); pChild != NULL; pChild = pChild->NextMovePeer())
|
||||||
|
{
|
||||||
|
if (pChild->GetClassname()[0] == 'h')
|
||||||
|
pChild->AddEffects( nEffects );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -313,12 +316,15 @@ void CBaseViewModel::RemoveEffects( int nEffects )
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MAPBASE
|
#ifdef MAPBASE
|
||||||
// Apply effect changes to any viewmodel children as well
|
if (GetOwningWeapon() && GetOwningWeapon()->UsesHands())
|
||||||
// (fixes hand models)
|
|
||||||
for (CBaseEntity *pChild = FirstMoveChild(); pChild != NULL; pChild = pChild->NextMovePeer())
|
|
||||||
{
|
{
|
||||||
if (pChild->GetClassname()[0] == 'h')
|
// If using hands, apply effect changes to any viewmodel children as well
|
||||||
pChild->RemoveEffects( nEffects );
|
// (fixes hand models)
|
||||||
|
for (CBaseEntity *pChild = FirstMoveChild(); pChild != NULL; pChild = pChild->NextMovePeer())
|
||||||
|
{
|
||||||
|
if (pChild->GetClassname()[0] == 'h')
|
||||||
|
pChild->RemoveEffects( nEffects );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -359,6 +365,18 @@ void CBaseViewModel::SetWeaponModel( const char *modelname, CBaseCombatWeapon *w
|
|||||||
SetControlPanelsActive( showControlPanels );
|
SetControlPanelsActive( showControlPanels );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// If our owning weapon doesn't support hands, disable the hands viewmodel(s)
|
||||||
|
bool bSupportsHands = weapon->UsesHands();
|
||||||
|
for (CBaseEntity *pChild = FirstMoveChild(); pChild != NULL; pChild = pChild->NextMovePeer())
|
||||||
|
{
|
||||||
|
if (pChild->GetClassname()[0] == 'h')
|
||||||
|
{
|
||||||
|
bSupportsHands ? pChild->RemoveEffects( EF_NODRAW ) : pChild->AddEffects( EF_NODRAW );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -754,7 +772,13 @@ class CHandViewModel : public CBaseViewModel
|
|||||||
DECLARE_CLASS( CHandViewModel, CBaseViewModel );
|
DECLARE_CLASS( CHandViewModel, CBaseViewModel );
|
||||||
public:
|
public:
|
||||||
DECLARE_NETWORKCLASS();
|
DECLARE_NETWORKCLASS();
|
||||||
|
|
||||||
|
CBaseViewModel *GetVMOwner();
|
||||||
|
|
||||||
|
CBaseCombatWeapon *GetOwningWeapon( void );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
CHandle<CBaseViewModel> m_hVMOwner;
|
||||||
};
|
};
|
||||||
|
|
||||||
LINK_ENTITY_TO_CLASS(hand_viewmodel, CHandViewModel);
|
LINK_ENTITY_TO_CLASS(hand_viewmodel, CHandViewModel);
|
||||||
@ -770,4 +794,26 @@ BEGIN_NETWORK_TABLE(CHandViewModel, DT_HandViewModel)
|
|||||||
RecvPropInt(RECVINFO_NAME(m_hNetworkMoveParent, moveparent), 0, RecvProxy_IntToMoveParent),
|
RecvPropInt(RECVINFO_NAME(m_hNetworkMoveParent, moveparent), 0, RecvProxy_IntToMoveParent),
|
||||||
#endif
|
#endif
|
||||||
END_NETWORK_TABLE()
|
END_NETWORK_TABLE()
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
CBaseViewModel *CHandViewModel::GetVMOwner()
|
||||||
|
{
|
||||||
|
if (!m_hVMOwner)
|
||||||
|
m_hVMOwner = assert_cast<CBaseViewModel*>(GetMoveParent());
|
||||||
|
return m_hVMOwner;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
CBaseCombatWeapon *CHandViewModel::GetOwningWeapon()
|
||||||
|
{
|
||||||
|
CBaseViewModel *pVM = GetVMOwner();
|
||||||
|
if (pVM)
|
||||||
|
return pVM->GetOwningWeapon();
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -86,6 +86,10 @@ char g_iszGameName[128];
|
|||||||
// Default player configuration
|
// Default player configuration
|
||||||
char g_szDefaultPlayerModel[MAX_PATH];
|
char g_szDefaultPlayerModel[MAX_PATH];
|
||||||
bool g_bDefaultPlayerDrawExternally;
|
bool g_bDefaultPlayerDrawExternally;
|
||||||
|
|
||||||
|
char g_szDefaultHandsModel[MAX_PATH];
|
||||||
|
int g_iDefaultHandsSkin;
|
||||||
|
int g_iDefaultHandsBody;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -226,6 +230,10 @@ public:
|
|||||||
#ifdef GAME_DLL
|
#ifdef GAME_DLL
|
||||||
Q_strncpy( g_szDefaultPlayerModel, gameinfo->GetString( "player_default_model", "models/player.mdl" ), sizeof( g_szDefaultPlayerModel ) );
|
Q_strncpy( g_szDefaultPlayerModel, gameinfo->GetString( "player_default_model", "models/player.mdl" ), sizeof( g_szDefaultPlayerModel ) );
|
||||||
g_bDefaultPlayerDrawExternally = gameinfo->GetBool( "player_default_draw_externally", false );
|
g_bDefaultPlayerDrawExternally = gameinfo->GetBool( "player_default_draw_externally", false );
|
||||||
|
|
||||||
|
Q_strncpy( g_szDefaultHandsModel, gameinfo->GetString( "player_default_hands", "models/weapons/v_hands.mdl" ), sizeof( g_szDefaultHandsModel ) );
|
||||||
|
g_iDefaultHandsSkin = gameinfo->GetInt( "player_default_hands_skin", 0 );
|
||||||
|
g_iDefaultHandsBody = gameinfo->GetInt( "player_default_hands_body", 0 );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
gameinfo->deleteThis();
|
gameinfo->deleteThis();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user