Skip to content
Closed
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
74 changes: 53 additions & 21 deletions src/game/server/props.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
#include "GameStats.h"
#include "vehicle_base.h"
#include "tier0/icommandline.h"
//includes used for improved autoclose
#include "asw_gameresource.h"
#include "asw_marine_resource.h"
#include "asw_marine.h"




Expand Down Expand Up @@ -4690,28 +4695,55 @@ void CBasePropDoor::DoorOpenMoveDone(void)
//-----------------------------------------------------------------------------
// Purpose: Think function that tries to close the door. Used for autoreturn.
//-----------------------------------------------------------------------------
void CBasePropDoor::DoorAutoCloseThink(void)
{
// When autoclosing, we check both sides so that we don't close in the player's
// face, or in an NPC's face for that matter, because they might be shooting
// through the doorway.
if ( !DoorCanClose( true ) )
{
if (m_flAutoReturnDelay == -1)
{
SetNextThink( TICK_NEVER_THINK );
}
else
{
// In flWait seconds, DoorClose will fire, unless wait is -1, then door stays open
SetMoveDoneTime(m_flAutoReturnDelay + 0.1);
SetMoveDone(&CBasePropDoor::DoorAutoCloseThink);
}

return;
}
void CASW_Door::DoorAutoCloseThink()
{
//aprox distance of bigger then jags ff with gl plus a safety marign
const float CLOSE_DIST = 350.0f;
bool bMarineNearby = false;

if (ASWGameResource())
{
for (int i = 0; i < ASWGameResource()->GetMaxMarineResources(); i++)
{
CASW_Marine_Resource *pMR = ASWGameResource()->GetMarineResource(i);
CASW_Marine *pMarine = pMR ? pMR->GetMarineEntity() : NULL;
if (pMarine && pMarine->GetHealth() > 0)
{
float dist = (pMarine->GetAbsOrigin() - GetAbsOrigin()).Length();
if (dist < CLOSE_DIST)
{
bMarineNearby = true;
break;
}
}
}
}

if (bMarineNearby)
{
// Don't auto-close if a marine is nearby. Try again soon.
SetNextThink(gpGlobals->curtime + 0.1);
return;
}

if ( !DoorCanClose( true ) )
{
if (m_flAutoReturnDelay == -1)
{
SetNextThink( TICK_NEVER_THINK );
}
else
{
// In flWait seconds, DoorClose will fire, unless wait is -1, then door stays open
SetMoveDoneTime(m_flAutoReturnDelay + 0.1);
SetMoveDone(&CBasePropDoor::DoorAutoCloseThink);
}

return;
}

DoorClose();

DoorClose();
}


Expand Down
Loading