|
43 | 43 | #include "GameStats.h" |
44 | 44 | #include "vehicle_base.h" |
45 | 45 | #include "tier0/icommandline.h" |
| 46 | +//includes used for improved autoclose |
| 47 | +#include "asw_gameresource.h" |
| 48 | +#include "asw_marine_resource.h" |
| 49 | +#include "asw_marine.h" |
| 50 | + |
46 | 51 |
|
47 | 52 |
|
48 | 53 |
|
@@ -4690,28 +4695,55 @@ void CBasePropDoor::DoorOpenMoveDone(void) |
4690 | 4695 | //----------------------------------------------------------------------------- |
4691 | 4696 | // Purpose: Think function that tries to close the door. Used for autoreturn. |
4692 | 4697 | //----------------------------------------------------------------------------- |
4693 | | -void CBasePropDoor::DoorAutoCloseThink(void) |
4694 | | -{ |
4695 | | - // When autoclosing, we check both sides so that we don't close in the player's |
4696 | | - // face, or in an NPC's face for that matter, because they might be shooting |
4697 | | - // through the doorway. |
4698 | | - if ( !DoorCanClose( true ) ) |
4699 | | - { |
4700 | | - if (m_flAutoReturnDelay == -1) |
4701 | | - { |
4702 | | - SetNextThink( TICK_NEVER_THINK ); |
4703 | | - } |
4704 | | - else |
4705 | | - { |
4706 | | - // In flWait seconds, DoorClose will fire, unless wait is -1, then door stays open |
4707 | | - SetMoveDoneTime(m_flAutoReturnDelay + 0.1); |
4708 | | - SetMoveDone(&CBasePropDoor::DoorAutoCloseThink); |
4709 | | - } |
4710 | | - |
4711 | | - return; |
4712 | | - } |
| 4698 | +void CASW_Door::DoorAutoCloseThink() |
| 4699 | +{ |
| 4700 | + //aprox distance of bigger then jags ff with gl plus a safety marign |
| 4701 | + const float CLOSE_DIST = 350.0f; |
| 4702 | + bool bMarineNearby = false; |
| 4703 | + |
| 4704 | + if (ASWGameResource()) |
| 4705 | + { |
| 4706 | + for (int i = 0; i < ASWGameResource()->GetMaxMarineResources(); i++) |
| 4707 | + { |
| 4708 | + CASW_Marine_Resource *pMR = ASWGameResource()->GetMarineResource(i); |
| 4709 | + CASW_Marine *pMarine = pMR ? pMR->GetMarineEntity() : NULL; |
| 4710 | + if (pMarine && pMarine->GetHealth() > 0) |
| 4711 | + { |
| 4712 | + float dist = (pMarine->GetAbsOrigin() - GetAbsOrigin()).Length(); |
| 4713 | + if (dist < CLOSE_DIST) |
| 4714 | + { |
| 4715 | + bMarineNearby = true; |
| 4716 | + break; |
| 4717 | + } |
| 4718 | + } |
| 4719 | + } |
| 4720 | + } |
| 4721 | + |
| 4722 | + if (bMarineNearby) |
| 4723 | + { |
| 4724 | + // Don't auto-close if a marine is nearby. Try again soon. |
| 4725 | + SetNextThink(gpGlobals->curtime + 0.1); |
| 4726 | + return; |
| 4727 | + } |
| 4728 | + |
| 4729 | + if ( !DoorCanClose( true ) ) |
| 4730 | + { |
| 4731 | + if (m_flAutoReturnDelay == -1) |
| 4732 | + { |
| 4733 | + SetNextThink( TICK_NEVER_THINK ); |
| 4734 | + } |
| 4735 | + else |
| 4736 | + { |
| 4737 | + // In flWait seconds, DoorClose will fire, unless wait is -1, then door stays open |
| 4738 | + SetMoveDoneTime(m_flAutoReturnDelay + 0.1); |
| 4739 | + SetMoveDone(&CBasePropDoor::DoorAutoCloseThink); |
| 4740 | + } |
| 4741 | + |
| 4742 | + return; |
| 4743 | + } |
| 4744 | + |
| 4745 | + DoorClose(); |
4713 | 4746 |
|
4714 | | - DoorClose(); |
4715 | 4747 | } |
4716 | 4748 |
|
4717 | 4749 |
|
|
0 commit comments