Added I/O/KV to point_viewcontrol inspired by later games

This commit is contained in:
Blixibon 2021-07-26 13:08:20 -05:00
parent 04687e03e9
commit 2b1a8762bd
2 changed files with 70 additions and 0 deletions

View File

@ -3100,6 +3100,7 @@ BEGIN_DATADESC( CTriggerCamera )
#ifdef MAPBASE
DEFINE_KEYFIELD( m_fov, FIELD_FLOAT, "fov" ),
DEFINE_KEYFIELD( m_fovSpeed, FIELD_FLOAT, "fov_rate" ),
DEFINE_KEYFIELD( m_flTrackSpeed, FIELD_FLOAT, "trackspeed" ),
DEFINE_KEYFIELD( m_bDontSetPlayerView, FIELD_BOOLEAN, "DontSetPlayerView" ),
#endif
@ -3110,6 +3111,10 @@ BEGIN_DATADESC( CTriggerCamera )
#ifdef MAPBASE
DEFINE_INPUTFUNC( FIELD_FLOAT, "SetFOV", InputSetFOV ),
DEFINE_INPUTFUNC( FIELD_FLOAT, "SetFOVRate", InputSetFOVRate ),
//DEFINE_INPUTFUNC( FIELD_STRING, "SetTarget", InputSetTarget ), // Defined by base class
DEFINE_INPUTFUNC( FIELD_STRING, "SetTargetAttachment", InputSetTargetAttachment ),
DEFINE_INPUTFUNC( FIELD_FLOAT, "SetTrackSpeed", InputSetTrackSpeed ),
#endif
// Function Pointers
@ -3138,6 +3143,7 @@ CTriggerCamera::CTriggerCamera()
{
m_fov = 90;
m_fovSpeed = 1;
m_flTrackSpeed = 40.0f;
}
//------------------------------------------------------------------------------
@ -3259,6 +3265,61 @@ void CTriggerCamera::InputSetFOVRate( inputdata_t &inputdata )
{
m_fovSpeed = inputdata.value.Float();
}
//------------------------------------------------------------------------------
// Purpose:
//------------------------------------------------------------------------------
void CTriggerCamera::InputSetTarget( inputdata_t &inputdata )
{
BaseClass::InputSetTarget( inputdata );
if ( FStrEq(STRING(m_target), "!player") )
{
AddSpawnFlags( SF_CAMERA_PLAYER_TARGET );
m_hTarget = m_hPlayer;
}
else
{
RemoveSpawnFlags( SF_CAMERA_PLAYER_TARGET );
m_hTarget = GetNextTarget();
}
}
//------------------------------------------------------------------------------
// Purpose:
//------------------------------------------------------------------------------
void CTriggerCamera::InputSetTargetAttachment( inputdata_t &inputdata )
{
m_iszTargetAttachment = inputdata.value.StringID();
m_iAttachmentIndex = 0;
if (m_hTarget)
{
if ( m_iszTargetAttachment != NULL_STRING )
{
if ( !m_hTarget->GetBaseAnimating() )
{
Warning("%s tried to target an attachment (%s) on target %s, which has no model.\n", GetClassname(), STRING(m_iszTargetAttachment), STRING(m_hTarget->GetEntityName()) );
}
else
{
m_iAttachmentIndex = m_hTarget->GetBaseAnimating()->LookupAttachment( STRING(m_iszTargetAttachment) );
if ( m_iAttachmentIndex <= 0 )
{
Warning("%s could not find attachment %s on target %s.\n", GetClassname(), STRING(m_iszTargetAttachment), STRING(m_hTarget->GetEntityName()) );
}
}
}
}
}
//------------------------------------------------------------------------------
// Purpose:
//------------------------------------------------------------------------------
void CTriggerCamera::InputSetTrackSpeed( inputdata_t &inputdata )
{
m_flTrackSpeed = inputdata.value.Float();
}
#endif
//-----------------------------------------------------------------------------
@ -3626,7 +3687,11 @@ void CTriggerCamera::FollowTarget( )
dy = dy - 360;
QAngle vecAngVel;
#ifdef MAPBASE
vecAngVel.Init( dx * m_flTrackSpeed * gpGlobals->frametime, dy * m_flTrackSpeed * gpGlobals->frametime, GetLocalAngularVelocity().z );
#else
vecAngVel.Init( dx * 40 * gpGlobals->frametime, dy * 40 * gpGlobals->frametime, GetLocalAngularVelocity().z );
#endif
SetLocalAngularVelocity(vecAngVel);
}

View File

@ -300,6 +300,10 @@ public:
#ifdef MAPBASE
void InputSetFOV( inputdata_t &inputdata );
void InputSetFOVRate( inputdata_t &inputdata );
void InputSetTarget( inputdata_t &inputdata );
void InputSetTargetAttachment( inputdata_t &inputdata );
void InputSetTrackSpeed( inputdata_t &inputdata );
#endif
private:
@ -323,6 +327,7 @@ private:
#ifdef MAPBASE
float m_fov;
float m_fovSpeed;
float m_flTrackSpeed;
bool m_bDontSetPlayerView;
#endif