From 172417867b8f475dab0b31de0c221c115156d1dc Mon Sep 17 00:00:00 2001 From: Arbab Ahmed Date: Sun, 19 Feb 2023 20:01:32 +1100 Subject: [PATCH 1/3] add mins and maxs to point_bugbait --- sp/src/game/server/hl2/grenade_bugbait.cpp | 49 ++++++++++++++++++---- sp/src/game/server/hl2/grenade_bugbait.h | 28 +++++++++++++ 2 files changed, 70 insertions(+), 7 deletions(-) diff --git a/sp/src/game/server/hl2/grenade_bugbait.cpp b/sp/src/game/server/hl2/grenade_bugbait.cpp index 7d5d7a4746..5480a9809d 100644 --- a/sp/src/game/server/hl2/grenade_bugbait.cpp +++ b/sp/src/game/server/hl2/grenade_bugbait.cpp @@ -50,10 +50,21 @@ BEGIN_DATADESC( CBugBaitSensor ) DEFINE_KEYFIELD( m_bEnabled, FIELD_BOOLEAN, "Enabled" ), DEFINE_KEYFIELD( m_flRadius, FIELD_FLOAT, "radius" ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_bUseRadius, FIELD_BOOLEAN, "useradius" ), + DEFINE_KEYFIELD( m_vecMins, FIELD_VECTOR, "bmins" ), + DEFINE_KEYFIELD( m_vecMaxs, FIELD_VECTOR, "bmaxs" ), +#endif + DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ), DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), DEFINE_INPUTFUNC( FIELD_VOID, "Toggle", InputToggle ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_VOID, "EnableRadius", InputEnableRadius ), + DEFINE_INPUTFUNC( FIELD_VOID, "DisableRadius", InputDisableRadius ), +#endif + // Function Pointers DEFINE_OUTPUT( m_OnBaited, "OnBaited" ), @@ -267,18 +278,42 @@ bool CGrenadeBugBait::ActivateBugbaitTargets( CBaseEntity *pOwner, Vector vecOri continue; //Make sure we're within range of the sensor - if ( pSensor->GetRadius() > ( pSensor->GetAbsOrigin() - vecOrigin ).Length() ) - { - //Tell the sensor it's been hit - if ( pSensor->Baited( pOwner ) ) +#ifdef MAPBASE + if ( pSensor->UsesRadius() ){ +#endif + if ( pSensor->GetRadius() > (pSensor->GetAbsOrigin() - vecOrigin).Length() ) { - //If we're suppressing the call to antlions, then don't make a bugbait sound - if ( pSensor->SuppressCall() ) + //Tell the sensor it's been hit + if ( pSensor->Baited( pOwner ) ) { - suppressCall = true; + //If we're suppressing the call to antlions, then don't make a bugbait sound + if ( pSensor->SuppressCall() ) + { + suppressCall = true; + } } } +#ifdef MAPBASE } + else{ + Vector vMins = pSensor->GetAbsMins(); + Vector vMaxs = pSensor->GetAbsMaxs(); + bool inBox = ((vecOrigin.x >= vMins.x && vecOrigin.x <= vMaxs.x) && + (vecOrigin.y >= vMins.y && vecOrigin.y <= vMaxs.y) && + (vecOrigin.z >= vMins.z && vecOrigin.z <= vMaxs.z)); + if ( inBox ){ + //Tell the sensor it's been hit + if ( pSensor->Baited( pOwner ) ) + { + //If we're suppressing the call to antlions, then don't make a bugbait sound + if ( pSensor->SuppressCall() ) + { + suppressCall = true; + } + } + } + } +#endif } return suppressCall; diff --git a/sp/src/game/server/hl2/grenade_bugbait.h b/sp/src/game/server/hl2/grenade_bugbait.h index 7a5df99366..af89657a14 100644 --- a/sp/src/game/server/hl2/grenade_bugbait.h +++ b/sp/src/game/server/hl2/grenade_bugbait.h @@ -63,6 +63,16 @@ class CBugBaitSensor : public CPointEntity m_bEnabled = !m_bEnabled; } +#ifdef MAPBASE + void InputEnableRadius( inputdata_t &data ){ + m_bUseRadius = true; + } + + void InputDisableRadius( inputdata_t &data ){ + m_bUseRadius = false; + } +#endif + bool SuppressCall( void ) { return ( HasSpawnFlags( SF_BUGBAIT_SUPPRESS_CALL ) ); @@ -91,10 +101,28 @@ class CBugBaitSensor : public CPointEntity return !m_bEnabled; } +#ifdef MAPBASE + bool UsesRadius( void ) const { + return m_bUseRadius; + } + + Vector GetAbsMins( void ) const { + return GetAbsOrigin() + m_vecMins; + } + Vector GetAbsMaxs( void ) const { + return GetAbsOrigin() + m_vecMaxs; + } +#endif + protected: float m_flRadius; bool m_bEnabled; +#ifdef MAPBASE + bool m_bUseRadius; + Vector m_vecMins; + Vector m_vecMaxs; +#endif COutputEvent m_OnBaited; public: From 1ff5d61d4f3c0886678ed556fcf32a2e007410e0 Mon Sep 17 00:00:00 2001 From: Arbab Ahmed Date: Mon, 20 Feb 2023 23:21:09 +1100 Subject: [PATCH 2/3] Add new inputs for the new functionality --- sp/src/game/server/hl2/grenade_bugbait.cpp | 3 +++ sp/src/game/server/hl2/grenade_bugbait.h | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/sp/src/game/server/hl2/grenade_bugbait.cpp b/sp/src/game/server/hl2/grenade_bugbait.cpp index 5480a9809d..0f054d57b0 100644 --- a/sp/src/game/server/hl2/grenade_bugbait.cpp +++ b/sp/src/game/server/hl2/grenade_bugbait.cpp @@ -63,6 +63,9 @@ BEGIN_DATADESC( CBugBaitSensor ) #ifdef MAPBASE DEFINE_INPUTFUNC( FIELD_VOID, "EnableRadius", InputEnableRadius ), DEFINE_INPUTFUNC( FIELD_VOID, "DisableRadius", InputDisableRadius ), + DEFINE_INPUTFUNC( FIELD_INTEGER, "SetRadius", InputSetRadius ), + DEFINE_INPUTFUNC( FIELD_VECTOR, "SetMins", InputSetMins ), + DEFINE_INPUTFUNC( FIELD_VECTOR, "SetMaxs", InputSetMaxs ), #endif // Function Pointers diff --git a/sp/src/game/server/hl2/grenade_bugbait.h b/sp/src/game/server/hl2/grenade_bugbait.h index af89657a14..fb2a68ccc6 100644 --- a/sp/src/game/server/hl2/grenade_bugbait.h +++ b/sp/src/game/server/hl2/grenade_bugbait.h @@ -71,6 +71,18 @@ class CBugBaitSensor : public CPointEntity void InputDisableRadius( inputdata_t &data ){ m_bUseRadius = false; } + + void InputSetRadius( inputdata_t &data ){ + m_flRadius = data.value.Int(); + } + + void InputSetMins( inputdata_t &data ){ + data.value.Vector3D( m_vecMins ); + } + + void InputSetMaxs( inputdata_t &data ){ + data.value.Vector3D( m_vecMaxs ); + } #endif bool SuppressCall( void ) From 8c338156e0bd513177b68db5e73f21ec739e6fa8 Mon Sep 17 00:00:00 2001 From: Blixibon Date: Tue, 24 Oct 2023 21:33:01 -0500 Subject: [PATCH 3/3] Fix existing point_bugbaits not using radius --- sp/src/game/server/hl2/grenade_bugbait.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sp/src/game/server/hl2/grenade_bugbait.cpp b/sp/src/game/server/hl2/grenade_bugbait.cpp index 0f054d57b0..feddcd5666 100644 --- a/sp/src/game/server/hl2/grenade_bugbait.cpp +++ b/sp/src/game/server/hl2/grenade_bugbait.cpp @@ -35,6 +35,9 @@ CBugBaitSensor* GetBugBaitSensorList() CBugBaitSensor::CBugBaitSensor( void ) { g_BugBaitSensorList.Insert( this ); +#ifdef MAPBASE + m_bUseRadius = true; +#endif } CBugBaitSensor::~CBugBaitSensor( void )