-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathasw_door_area.cpp
More file actions
135 lines (114 loc) · 3.14 KB
/
Copy pathasw_door_area.cpp
File metadata and controls
135 lines (114 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include "cbase.h"
#include "asw_door_area.h"
#include "asw_door.h"
#include "asw_marine.h"
#include "asw_game_resource.h"
#include "asw_marine_resource.h"
#include "asw_weapon_welder_shared.h"
#include "asw_marine_speech.h"
#include "asw_fail_advice.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
LINK_ENTITY_TO_CLASS( trigger_asw_door_area, CASW_Door_Area );
BEGIN_DATADESC( CASW_Door_Area )
END_DATADESC()
IMPLEMENT_SERVERCLASS_ST(CASW_Door_Area, DT_ASW_Door_Area)
END_SEND_TABLE()
CASW_Door_Area::CASW_Door_Area()
{
AddEFlags( EFL_FORCE_CHECK_TRANSMIT );
m_fNextCutCheck = 0;
}
CASW_Door_Area::~CASW_Door_Area()
{
CASW_Door *pDoor = GetDoor();
if ( pDoor )
{
pDoor->m_AttachedDoorAreas.FindAndRemove( this );
}
}
void CASW_Door_Area::Spawn( void )
{
BaseClass::Spawn();
CASW_Door *pDoor = GetDoor();
if ( pDoor )
{
pDoor->m_AttachedDoorAreas.AddToTail( this );
}
}
bool CASW_Door_Area::HasWelder( CASW_Marine *pMarine )
{
CASW_Weapon *pExtra = pMarine->GetASWWeapon( ASW_INVENTORY_SLOT_EXTRA );
if ( pExtra && pExtra->Classify() == CLASS_ASW_WELDER )
return true;
return false;
}
void CASW_Door_Area::ActivateMultiTrigger( CBaseEntity *pActivator )
{
if ( GetNextThink() > gpGlobals->curtime )
return; // still waiting for reset time
BaseClass::ActivateMultiTrigger( pActivator );
CASW_Door *pDoor = GetDoor();
if ( !pDoor || !m_bUseAreaEnabled )
return;
// check for shouting out about a sealed door
if ( pDoor->m_bDoCutShout )
{
if ( gpGlobals->curtime > m_fNextCutCheck )
{
CASW_Marine *pMarine = CASW_Marine::AsMarine( pActivator );
if ( pMarine )
{
// check if there's another marine nearby with a welder
CASW_Game_Resource *pGameResource = ASWGameResource();
if ( pGameResource )
{
bool bFound = false;
for ( int i = 0; i < pGameResource->GetMaxMarineResources(); i++ )
{
CASW_Marine_Resource *pMR = pGameResource->GetMarineResource( i );
CASW_Marine *pOtherMarine = pMR ? pMR->GetMarineEntity() : NULL;
if ( pOtherMarine && pActivator != pOtherMarine
&& ( pMarine->GetAbsOrigin().DistTo( pOtherMarine->GetAbsOrigin() ) < 800 )
&& HasWelder( pOtherMarine ) )
bFound = true;
}
if ( bFound )
{
if ( pMarine->GetMarineSpeech()->Chatter( CHATTER_REQUEST_CUT_DOOR ) )
{
pDoor->m_bDoCutShout = false;
if ( pDoor->m_bDoAutoShootChatter )
pDoor->m_bDoAutoShootChatter = false; // don't need to automatic shout about shooting a door if we've already shouted about cutting it
}
m_fNextCutCheck = gpGlobals->curtime + 2.0f; // check again sooner if we tried to say the line but couldn't for some reason
}
else
{
m_fNextCutCheck = gpGlobals->curtime + 10.0f;
}
}
}
}
}
if ( pDoor->m_bDoAutoShootChatter )
{
CASW_Marine *pMarine = CASW_Marine::AsMarine( pActivator );
if ( pMarine )
{
pDoor->DoAutoDoorShootChatter( pMarine );
}
}
if ( !RequirementsMet( pActivator ) )
{
return;
}
if ( pDoor->IsAutoOpen() )
{
pDoor->AutoOpen( pActivator );
if ( pDoor->CanWeld() )
{
ASWFailAdvice()->OnAlienOpenDoor();
}
}
}