mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-02-05 02:00:34 +03:00
Added weapon script keyvalues for unique dropped model and whether or not to use the separate hands model
This commit is contained in:
parent
2aa17fff22
commit
2282aedfa6
@ -125,9 +125,15 @@ void C_BaseCombatWeapon::OnRestore()
|
|||||||
|
|
||||||
int C_BaseCombatWeapon::GetWorldModelIndex( void )
|
int C_BaseCombatWeapon::GetWorldModelIndex( void )
|
||||||
{
|
{
|
||||||
|
#ifdef MAPBASE
|
||||||
|
int iIndex = GetOwner() ? m_iWorldModelIndex.Get() : m_iDroppedModelIndex.Get();
|
||||||
|
#else
|
||||||
|
int iIndex = m_iWorldModelIndex.Get();
|
||||||
|
#endif
|
||||||
|
|
||||||
if ( GameRules() )
|
if ( GameRules() )
|
||||||
{
|
{
|
||||||
const char *pBaseName = modelinfo->GetModelName( modelinfo->GetModel( m_iWorldModelIndex ) );
|
const char *pBaseName = modelinfo->GetModelName( modelinfo->GetModel( iIndex ) );
|
||||||
const char *pTranslatedName = GameRules()->TranslateEffectForVisionFilter( "weapons", pBaseName );
|
const char *pTranslatedName = GameRules()->TranslateEffectForVisionFilter( "weapons", pBaseName );
|
||||||
|
|
||||||
if ( pTranslatedName != pBaseName )
|
if ( pTranslatedName != pBaseName )
|
||||||
@ -136,7 +142,7 @@ int C_BaseCombatWeapon::GetWorldModelIndex( void )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_iWorldModelIndex;
|
return iIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -487,7 +487,11 @@ void CBaseCombatWeapon::Kill( void )
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CBaseCombatWeapon::FallInit( void )
|
void CBaseCombatWeapon::FallInit( void )
|
||||||
{
|
{
|
||||||
|
#ifdef MAPBASE
|
||||||
|
SetModel( (GetDroppedModel() && GetDroppedModel()[0]) ? GetDroppedModel() : GetWorldModel() );
|
||||||
|
#else
|
||||||
SetModel( GetWorldModel() );
|
SetModel( GetWorldModel() );
|
||||||
|
#endif
|
||||||
VPhysicsDestroyObject();
|
VPhysicsDestroyObject();
|
||||||
|
|
||||||
if ( !VPhysicsInitNormal( SOLID_BBOX, GetSolidFlags() | FSOLID_TRIGGER, false ) )
|
if ( !VPhysicsInitNormal( SOLID_BBOX, GetSolidFlags() | FSOLID_TRIGGER, false ) )
|
||||||
|
@ -186,7 +186,11 @@ void CBaseCombatWeapon::Spawn( void )
|
|||||||
|
|
||||||
if ( GetWorldModel() )
|
if ( GetWorldModel() )
|
||||||
{
|
{
|
||||||
|
#ifdef MAPBASE
|
||||||
|
SetModel( (GetDroppedModel() && GetDroppedModel()[0]) ? GetDroppedModel() : GetWorldModel() );
|
||||||
|
#else
|
||||||
SetModel( GetWorldModel() );
|
SetModel( GetWorldModel() );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined( CLIENT_DLL )
|
#if !defined( CLIENT_DLL )
|
||||||
@ -291,6 +295,18 @@ void CBaseCombatWeapon::Precache( void )
|
|||||||
{
|
{
|
||||||
m_iWorldModelIndex = CBaseEntity::PrecacheModel( GetWorldModel() );
|
m_iWorldModelIndex = CBaseEntity::PrecacheModel( GetWorldModel() );
|
||||||
}
|
}
|
||||||
|
#ifdef MAPBASE
|
||||||
|
m_iDroppedModelIndex = 0;
|
||||||
|
if ( GetDroppedModel() && GetDroppedModel()[0] )
|
||||||
|
{
|
||||||
|
m_iDroppedModelIndex = CBaseEntity::PrecacheModel( GetDroppedModel() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Use the world model index
|
||||||
|
m_iDroppedModelIndex = m_iWorldModelIndex;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Precache sounds, too
|
// Precache sounds, too
|
||||||
for ( int i = 0; i < NUM_SHOOT_SOUND_TYPES; ++i )
|
for ( int i = 0; i < NUM_SHOOT_SOUND_TYPES; ++i )
|
||||||
@ -481,6 +497,16 @@ float CBaseCombatWeapon::GetSwaySpeedScale() const
|
|||||||
{
|
{
|
||||||
return GetWpnData().m_flSwaySpeedScale;
|
return GetWpnData().m_flSwaySpeedScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *CBaseCombatWeapon::GetDroppedModel() const
|
||||||
|
{
|
||||||
|
return GetWpnData().szDroppedModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CBaseCombatWeapon::UsesHands() const
|
||||||
|
{
|
||||||
|
return GetWpnData().m_bUsesHands;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -3008,6 +3034,7 @@ BEGIN_ENT_SCRIPTDESC( CBaseCombatWeapon, CBaseAnimating, "The base class for all
|
|||||||
|
|
||||||
DEFINE_SCRIPTFUNC( GetWorldModel, "Get the weapon's world model." )
|
DEFINE_SCRIPTFUNC( GetWorldModel, "Get the weapon's world model." )
|
||||||
DEFINE_SCRIPTFUNC( GetViewModel, "Get the weapon's view model." )
|
DEFINE_SCRIPTFUNC( GetViewModel, "Get the weapon's view model." )
|
||||||
|
DEFINE_SCRIPTFUNC( GetDroppedModel, "Get the weapon's unique dropped model if it has one." )
|
||||||
|
|
||||||
DEFINE_SCRIPTFUNC( GetWeight, "Get the weapon's weight." )
|
DEFINE_SCRIPTFUNC( GetWeight, "Get the weapon's weight." )
|
||||||
|
|
||||||
@ -3302,6 +3329,9 @@ BEGIN_NETWORK_TABLE(CBaseCombatWeapon, DT_BaseCombatWeapon)
|
|||||||
SendPropDataTable("LocalActiveWeaponData", 0, &REFERENCE_SEND_TABLE(DT_LocalActiveWeaponData), SendProxy_SendActiveLocalWeaponDataTable ),
|
SendPropDataTable("LocalActiveWeaponData", 0, &REFERENCE_SEND_TABLE(DT_LocalActiveWeaponData), SendProxy_SendActiveLocalWeaponDataTable ),
|
||||||
SendPropModelIndex( SENDINFO(m_iViewModelIndex) ),
|
SendPropModelIndex( SENDINFO(m_iViewModelIndex) ),
|
||||||
SendPropModelIndex( SENDINFO(m_iWorldModelIndex) ),
|
SendPropModelIndex( SENDINFO(m_iWorldModelIndex) ),
|
||||||
|
#ifdef MAPBASE
|
||||||
|
SendPropModelIndex( SENDINFO(m_iDroppedModelIndex) ),
|
||||||
|
#endif
|
||||||
SendPropInt( SENDINFO(m_iState ), 8, SPROP_UNSIGNED ),
|
SendPropInt( SENDINFO(m_iState ), 8, SPROP_UNSIGNED ),
|
||||||
SendPropEHandle( SENDINFO(m_hOwner) ),
|
SendPropEHandle( SENDINFO(m_hOwner) ),
|
||||||
|
|
||||||
@ -3314,6 +3344,9 @@ BEGIN_NETWORK_TABLE(CBaseCombatWeapon, DT_BaseCombatWeapon)
|
|||||||
RecvPropDataTable("LocalActiveWeaponData", 0, 0, &REFERENCE_RECV_TABLE(DT_LocalActiveWeaponData)),
|
RecvPropDataTable("LocalActiveWeaponData", 0, 0, &REFERENCE_RECV_TABLE(DT_LocalActiveWeaponData)),
|
||||||
RecvPropInt( RECVINFO(m_iViewModelIndex)),
|
RecvPropInt( RECVINFO(m_iViewModelIndex)),
|
||||||
RecvPropInt( RECVINFO(m_iWorldModelIndex)),
|
RecvPropInt( RECVINFO(m_iWorldModelIndex)),
|
||||||
|
#ifdef MAPBASE
|
||||||
|
RecvPropInt( RECVINFO(m_iDroppedModelIndex) ),
|
||||||
|
#endif
|
||||||
RecvPropInt( RECVINFO(m_iState )),
|
RecvPropInt( RECVINFO(m_iState )),
|
||||||
RecvPropEHandle( RECVINFO(m_hOwner ) ),
|
RecvPropEHandle( RECVINFO(m_hOwner ) ),
|
||||||
|
|
||||||
|
@ -422,6 +422,8 @@ public:
|
|||||||
float GetBobScale() const;
|
float GetBobScale() const;
|
||||||
float GetSwayScale() const;
|
float GetSwayScale() const;
|
||||||
float GetSwaySpeedScale() const;
|
float GetSwaySpeedScale() const;
|
||||||
|
virtual const char *GetDroppedModel( void ) const;
|
||||||
|
bool UsesHands( void ) const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// derive this function if you mod uses encrypted weapon info files
|
// derive this function if you mod uses encrypted weapon info files
|
||||||
@ -681,6 +683,9 @@ public:
|
|||||||
// Weapon art
|
// Weapon art
|
||||||
CNetworkVar( int, m_iViewModelIndex );
|
CNetworkVar( int, m_iViewModelIndex );
|
||||||
CNetworkVar( int, m_iWorldModelIndex );
|
CNetworkVar( int, m_iWorldModelIndex );
|
||||||
|
#ifdef MAPBASE
|
||||||
|
CNetworkVar( int, m_iDroppedModelIndex );
|
||||||
|
#endif
|
||||||
// Sounds
|
// Sounds
|
||||||
float m_flNextEmptySoundTime; // delay on empty sound playing
|
float m_flNextEmptySoundTime; // delay on empty sound playing
|
||||||
|
|
||||||
|
@ -406,6 +406,8 @@ FileWeaponInfo_t::FileWeaponInfo_t()
|
|||||||
m_flBobScale = 1.0f;
|
m_flBobScale = 1.0f;
|
||||||
m_flSwayScale = 1.0f;
|
m_flSwayScale = 1.0f;
|
||||||
m_flSwaySpeedScale = 1.0f;
|
m_flSwaySpeedScale = 1.0f;
|
||||||
|
szDroppedModel[0] = 0;
|
||||||
|
m_bUsesHands = false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -477,6 +479,10 @@ void FileWeaponInfo_t::Parse( KeyValues *pKeyValuesData, const char *szWeaponNam
|
|||||||
m_flBobScale = pKeyValuesData->GetFloat( "bob_scale", 1.0f );
|
m_flBobScale = pKeyValuesData->GetFloat( "bob_scale", 1.0f );
|
||||||
m_flSwayScale = pKeyValuesData->GetFloat( "sway_scale", 1.0f );
|
m_flSwayScale = pKeyValuesData->GetFloat( "sway_scale", 1.0f );
|
||||||
m_flSwaySpeedScale = pKeyValuesData->GetFloat( "sway_speed_scale", 1.0f );
|
m_flSwaySpeedScale = pKeyValuesData->GetFloat( "sway_speed_scale", 1.0f );
|
||||||
|
|
||||||
|
Q_strncpy( szDroppedModel, pKeyValuesData->GetString( "droppedmodel" ), MAX_WEAPON_STRING );
|
||||||
|
|
||||||
|
m_bUsesHands = ( pKeyValuesData->GetInt( "uses_hands", 0 ) != 0 ) ? true : false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MAPBASE // Mapbase makes weapons in the same slot & position swap each other out, which is a feature mods can intentionally use.
|
#ifndef MAPBASE // Mapbase makes weapons in the same slot & position swap each other out, which is a feature mods can intentionally use.
|
||||||
|
@ -121,6 +121,10 @@ public:
|
|||||||
float m_flBobScale;
|
float m_flBobScale;
|
||||||
float m_flSwayScale;
|
float m_flSwayScale;
|
||||||
float m_flSwaySpeedScale;
|
float m_flSwaySpeedScale;
|
||||||
|
|
||||||
|
char szDroppedModel[MAX_WEAPON_STRING]; // Model of this weapon when dropped on the ground
|
||||||
|
|
||||||
|
bool m_bUsesHands;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// CLIENT DLL
|
// CLIENT DLL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user