Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions src/game/server/triggers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3821,6 +3821,7 @@ class CTriggerWind : public CBaseVPhysicsTrigger
// Input handlers
void InputEnable( inputdata_t &inputdata );
void InputSetSpeed( inputdata_t &inputdata );
void InputSetWindAngle( inputdata_t &inputdata);

private:
int m_nSpeedBase; // base line for how hard the wind blows
Expand Down Expand Up @@ -3849,7 +3850,7 @@ BEGIN_DATADESC( CTriggerWind )

DEFINE_FIELD( m_nSpeedCurrent, FIELD_INTEGER),
DEFINE_FIELD( m_nSpeedTarget, FIELD_INTEGER),
DEFINE_FIELD( m_nDirBase, FIELD_INTEGER),
DEFINE_KEYFIELD( m_nDirBase, FIELD_INTEGER, "WindAngle"),
DEFINE_FIELD( m_nDirCurrent, FIELD_INTEGER),
DEFINE_FIELD( m_nDirTarget, FIELD_INTEGER),
DEFINE_FIELD( m_bSwitch, FIELD_BOOLEAN),
Expand All @@ -3866,18 +3867,38 @@ BEGIN_DATADESC( CTriggerWind )
DEFINE_FUNCTION( WindThink ),

DEFINE_INPUTFUNC( FIELD_INTEGER, "SetSpeed", InputSetSpeed ),
DEFINE_INPUTFUNC( FIELD_INTEGER, "SetWindAngle", InputSetWindAngle ),

END_DATADESC()

//------------------------------------------------------------------------------
// Purpose: Constructor for trigger_wind
//------------------------------------------------------------------------------
CTriggerWind::CTriggerWind()
{
// assign default values
m_nDirBase = -1;
}

//------------------------------------------------------------------------------
// Purpose:
//------------------------------------------------------------------------------
void CTriggerWind::Spawn( void )
{
m_bSwitch = true;
m_nDirBase = GetLocalAngles().y;

if (m_nDirBase >= 0)
{
// negative "WindAngle" (default) means use the old method and grab
// from "angles" instead (has the unintended side effect of rotating
// the trigger; not fixing in order to not break existing maps)
m_nDirBase = GetLocalAngles().y;
}
else
{
// rotate wind to match brush rotation. fixes rotated instances,
// as long as they're only rotated around Z (yaw) axis
m_nDirBase += (GetLocalAngles().y);
}
BaseClass::Spawn();

m_nSpeedCurrent = m_nSpeedBase;
Expand Down Expand Up @@ -4055,6 +4076,14 @@ void CTriggerWind::InputSetSpeed( inputdata_t &inputdata )
m_bSwitch = true;
}

//------------------------------------------------------------------------------
// Purpose: set new wind angle and mark to switch next think
//------------------------------------------------------------------------------
void CTriggerWind::InputSetWindAngle( inputdata_t &inputdata )
{
m_nDirBase = (inputdata.value.Int() + GetLocalAngles().y);
m_bSwitch = true;
}

//-----------------------------------------------------------------------------
// Purpose: Draw any debug text overlays
Expand Down