Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spotlight "Ignore solid" keyvalue from MP branch #309

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
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
32 changes: 26 additions & 6 deletions sp/src/game/server/point_spotlight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class CPointSpotlight : public CPointEntity
private:
bool m_bSpotlightOn;
bool m_bEfficientSpotlight;
bool m_bIgnoreSolid;
Vector m_vSpotlightTargetPos;
Vector m_vSpotlightCurrentPos;
Vector m_vSpotlightDir;
Expand Down Expand Up @@ -100,6 +101,7 @@ BEGIN_DATADESC( CPointSpotlight )
DEFINE_FIELD( m_vSpotlightDir, FIELD_VECTOR ),
DEFINE_FIELD( m_nHaloSprite, FIELD_INTEGER ),

DEFINE_KEYFIELD( m_bIgnoreSolid, FIELD_BOOLEAN, "IgnoreSolid" ),
DEFINE_KEYFIELD( m_flSpotlightMaxLength,FIELD_FLOAT, "SpotlightLength"),
DEFINE_KEYFIELD( m_flSpotlightGoalWidth,FIELD_FLOAT, "SpotlightWidth"),
DEFINE_KEYFIELD( m_flHDRColorScale, FIELD_FLOAT, "HDRColorScale" ),
Expand Down Expand Up @@ -138,6 +140,7 @@ CPointSpotlight::CPointSpotlight()
#endif
m_flHDRColorScale = 1.0f;
m_nMinDXLevel = 0;
m_bIgnoreSolid = false;
#ifdef MAPBASE
m_flHaloScale = 60.0f;
#endif
Expand Down Expand Up @@ -380,12 +383,21 @@ void CPointSpotlight::SpotlightCreate(void)

AngleVectors( GetAbsAngles(), &m_vSpotlightDir );

trace_t tr;
UTIL_TraceLine( GetAbsOrigin(), GetAbsOrigin() + m_vSpotlightDir * m_flSpotlightMaxLength, MASK_SOLID_BRUSHONLY, this, COLLISION_GROUP_NONE, &tr);
Vector vTargetPos;
if ( m_bIgnoreSolid )
{
vTargetPos = GetAbsOrigin() + m_vSpotlightDir * m_flSpotlightMaxLength;
}
else
{
trace_t tr;
UTIL_TraceLine( GetAbsOrigin(), GetAbsOrigin() + m_vSpotlightDir * m_flSpotlightMaxLength, MASK_SOLID_BRUSHONLY, this, COLLISION_GROUP_NONE, &tr );
vTargetPos = tr.endpos;
}

m_hSpotlightTarget = (CSpotlightEnd*)CreateEntityByName( "spotlight_end" );
m_hSpotlightTarget->Spawn();
m_hSpotlightTarget->SetAbsOrigin( tr.endpos );
m_hSpotlightTarget->SetAbsOrigin( vTargetPos );
m_hSpotlightTarget->SetOwnerEntity( this );
m_hSpotlightTarget->m_clrRender = m_clrRender;
m_hSpotlightTarget->m_Radius = m_flSpotlightMaxLength;
Expand Down Expand Up @@ -437,9 +449,17 @@ Vector CPointSpotlight::SpotlightCurrentPos(void)
AngleVectors( GetAbsAngles(), &m_vSpotlightDir );

// Get beam end point. Only collide with solid objects, not npcs
trace_t tr;
UTIL_TraceLine( GetAbsOrigin(), GetAbsOrigin() + (m_vSpotlightDir * 2 * m_flSpotlightMaxLength), MASK_SOLID_BRUSHONLY, this, COLLISION_GROUP_NONE, &tr );
return tr.endpos;
Vector vEndPos = GetAbsOrigin() + ( m_vSpotlightDir * 2 * m_flSpotlightMaxLength );
if ( m_bIgnoreSolid )
{
return vEndPos;
}
else
{
trace_t tr;
UTIL_TraceLine( GetAbsOrigin(), vEndPos, MASK_SOLID_BRUSHONLY, this, COLLISION_GROUP_NONE, &tr );
return tr.endpos;
}
}

//------------------------------------------------------------------------------
Expand Down
Loading