Skip to content
Open
Show file tree
Hide file tree
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
48 changes: 24 additions & 24 deletions src/game/server/tf/entity_currencypack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,59 +174,59 @@ void CCurrencyPack::BlinkThink( void )


//-----------------------------------------------------------------------------
// Become touchable when we are at rest
// Purpose: Collect this pack when it comes to rest if it is outside the playable space.
//-----------------------------------------------------------------------------
void CCurrencyPack::ComeToRest( void )
{
BaseClass::ComeToRest();

if ( IsClaimed() || m_bDistributed )
// I'm not sure when this should ever actually return true, but it doesn't seem to cause any issues so I'm not touching it.
if ( IsClaimed() )
return;

// if we've come to rest in an area with no nav, just grant the money to the player
if ( TheNavMesh->GetNavArea( GetAbsOrigin() ) == NULL )
{
TFGameRules()->DistributeCurrencyAmount( m_nAmount );
m_bTouched = true;
UTIL_Remove( this );

AutoCollect();
return;
}

// See if we've come to rest in a trigger_hurt
for ( int i = 0; i < ITriggerHurtAutoList::AutoList().Count(); i++ )
{
CTriggerHurt *pTrigger = static_cast<CTriggerHurt*>( ITriggerHurtAutoList::AutoList()[i] );
if ( !pTrigger->m_bDisabled )
CTriggerHurt *pTrigger = static_cast<CTriggerHurt *>( ITriggerHurtAutoList::AutoList()[ i ] );
if ( !pTrigger->m_bDisabled && pTrigger->PointIsWithin( GetAbsOrigin() ) )
{
Vector vecMins, vecMaxs;
pTrigger->GetCollideable()->WorldSpaceSurroundingBounds( &vecMins, &vecMaxs );
if ( IsPointInBox( GetCollideable()->GetCollisionOrigin(), vecMins, vecMaxs ) )
{
TFGameRules()->DistributeCurrencyAmount( m_nAmount );

m_bTouched = true;
UTIL_Remove( this );
}
AutoCollect();
return;
}
}

// Or a func_respawnroom (robots can drop money in their own spawn)
for ( int i = 0; i < IFuncRespawnRoomAutoList::AutoList().Count(); i++ )
{
CFuncRespawnRoom *pRespawnRoom = static_cast<CFuncRespawnRoom *>( IFuncRespawnRoomAutoList::AutoList()[ i ] );
Vector vecMins, vecMaxs;
pRespawnRoom->GetCollideable()->WorldSpaceSurroundingBounds( &vecMins, &vecMaxs );
if ( IsPointInBox( GetCollideable()->GetCollisionOrigin(), vecMins, vecMaxs ) )
if ( !pRespawnRoom->m_bDisabled && pRespawnRoom->PointIsWithin( GetAbsOrigin() ) )
Copy link
Contributor

@FlaminSarge FlaminSarge May 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the respawn room gets disabled before the money comes to rest, will this result in the money not autocollecting? Some maps may disable certain respawn rooms for robots mid-game but may not make those areas walkable for players.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would indeed happen, but I'm operating on the assumption that there's not really much reason to disable spawnroom entities in MvM except for making an area walkable and using RecomputeBlockers, given that robots won't attempt to hotswap their loadouts and their actual spawnpoints will continue to function as the mission maker directs independent of the spawnroom's status. Though of course if there's any maps this change would break, it would be worth reviewing this part again.

Copy link
Contributor

@Mentrillum Mentrillum Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ( !pRespawnRoom->m_bDisabled && pRespawnRoom->PointIsWithin( GetAbsOrigin() ) )
if ( !pRespawnRoom->m_bDisabled && ( pRespawnRoom->PointIsWithin( GetAbsOrigin() ) || pRespawnRoom->IsTouching( this ) )

Correct me if I'm wrong but couldn't we also double check to see if the cash entity is touching the trigger using IsTouching?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IsTouching() would require the spawnroom to have spawnflags set that allow cash entities to register as touching to return true, but they usually only have SF_TRIGGER_ALLOW_CLIENTS set.

{
TFGameRules()->DistributeCurrencyAmount( m_nAmount );

m_bTouched = true;
UTIL_Remove( this );
AutoCollect();
return;
}
}
}

//-----------------------------------------------------------------------------
// Purpose: Collects the pack, crediting the player team appropriately. Intended for when a pack lands outside the playable space.
//-----------------------------------------------------------------------------
void CCurrencyPack::AutoCollect( void )
{
if ( !m_bDistributed )
{
TFGameRules()->DistributeCurrencyAmount( m_nAmount );
}
m_bTouched = true;
UTIL_Remove( this );
}

//-----------------------------------------------------------------------------
// Purpose: Sets the value of a custom pack
//-----------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions src/game/server/tf/entity_currencypack.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class CCurrencyPack : public CTFPowerup, public ICurrencyPackAutoList
bool MyTouch( CBasePlayer *pPlayer );
virtual bool AffectedByRadiusCollection() const { return true; }

void AutoCollect( void );
void SetAmount( float flAmount );
void SetClaimed( void ) { m_bClaimed = true; } // Radius collection code "steers" packs toward the player
bool IsClaimed( void ) { return m_bClaimed; } // So don't allow other players to interfere
Expand Down