forked from ReactiveDrop/reactivedrop_public_src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasw_alien_shared.cpp
More file actions
193 lines (163 loc) · 4.73 KB
/
asw_alien_shared.cpp
File metadata and controls
193 lines (163 loc) · 4.73 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#include "cbase.h"
#ifdef CLIENT_DLL
#include "c_asw_alien.h"
#include "c_asw_player.h"
#include "igameevents.h"
#include "asw_util_shared.h"
#else
#include "asw_alien.h"
#include "asw_player.h"
#endif
#include "asw_fx_shared.h"
#include "takedamageinfo.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
#ifdef GAME_DLL
extern ConVar showhitlocation;
#endif
ConVar asw_drone_weak_from_behind( "asw_drone_weak_from_behind", "0", FCVAR_CHEAT | FCVAR_REPLICATED, "Drones take double damage from behind" );
ConVar asw_alien_mining_laser_damage_scale( "asw_alien_mining_laser_damage_scale", "0.25f", FCVAR_CHEAT | FCVAR_REPLICATED );
ConVar asw_alien_debug_death_style( "asw_alien_debug_death_style", "0", FCVAR_CHEAT | FCVAR_REPLICATED, "For debugging alien deaths" );
void CASW_Alien::TraceAttack( const CTakeDamageInfo &info, const Vector &vecDir, trace_t *ptr )
{
#ifdef GAME_DLL
m_fNoDamageDecal = false;
if ( m_takedamage == DAMAGE_NO )
return;
#endif
CTakeDamageInfo subInfo = info;
#ifdef GAME_DLL
SetLastHitGroup( ptr->hitgroup );
m_nForceBone = ptr->physicsbone; // save this bone for physics forces
#endif
Assert( m_nForceBone > -255 && m_nForceBone < 256 );
// mining laser does reduced damage
if ( info.GetDamageType() & DMG_ENERGYBEAM )
{
subInfo.ScaleDamage( asw_alien_mining_laser_damage_scale.GetFloat() );
}
if ( subInfo.GetDamage() >= 1.0 && !(subInfo.GetDamageType() & DMG_SHOCK )
&& !( subInfo.GetDamageType() & DMG_BURN ) )
{
#ifdef GAME_DLL
Bleed( subInfo, ptr->endpos + m_LagCompensation.GetLagCompensationOffset(), vecDir, ptr );
if ( ptr->hitgroup == HITGROUP_HEAD && m_iHealth - subInfo.GetDamage() > 0 )
{
m_fNoDamageDecal = true;
}
#else
Bleed( subInfo, ptr->endpos, vecDir, ptr );
//OnHurt();
#endif
}
CBaseEntity* pAttacker = info.GetAttacker();
if( !info.GetInflictor() )
{
subInfo.SetInflictor( pAttacker );
}
AddMultiDamage( subInfo, this );
#ifdef GAME_DLL
#else
CASW_Player *pPlayerAttacker = NULL;
if ( pAttacker && pAttacker->Classify() == CLASS_ASW_MARINE )
{
CASW_Marine* pMarine = assert_cast<CASW_Marine*>( pAttacker );
pPlayerAttacker = pMarine->GetCommander();
}
IGameEvent * event = gameeventmanager->CreateEvent( "alien_hurt" );
if ( event )
{
event->SetInt( "attacker", ( pPlayerAttacker ? pPlayerAttacker->GetUserID() : 0 ) );
event->SetInt( "entindex", entindex() );
event->SetInt( "amount", subInfo.GetDamage() );
gameeventmanager->FireEventClientSide( event );
}
#endif
}
void CASW_Alien::Bleed( const CTakeDamageInfo &info, const Vector &vecPos, const Vector &vecDir, trace_t *ptr )
{
UTIL_ASW_DroneBleed( vecPos, -vecDir, 4 );
DoBloodDecal( info.GetDamage(), vecPos, vecDir, ptr, info.GetDamageType() );
}
void CASW_Alien::DoBloodDecal( float flDamage, const Vector &vecPos, const Vector &vecDir, trace_t *ptr, int bitsDamageType )
{
if ( ( BloodColor() == DONT_BLEED) || ( BloodColor() == BLOOD_COLOR_MECH ) )
{
return;
}
if (flDamage == 0)
return;
if ( !( bitsDamageType & ( DMG_CRUSH | DMG_BULLET | DMG_SLASH | DMG_BLAST | DMG_CLUB | DMG_AIRBOAT ) ) )
return;
// make blood decal on the wall!
trace_t Bloodtr, Bloodtr2;
Vector vecTraceDir;
float flNoise;
int cCount;
int i;
#ifdef GAME_DLL
if ( !IsAlive() )
{
// dealing with a dead npc.
if ( GetMaxHealth() <= 0 )
{
// no blood decal for a npc that has already decalled its limit.
return;
}
else
{
m_iMaxHealth -= 1;
}
}
#endif
if (flDamage < 10)
{
flNoise = 0.1;
cCount = 1;
}
else if (flDamage < 25)
{
flNoise = 0.2;
cCount = 2;
}
else
{
flNoise = 0.3;
cCount = 4;
}
float flTraceDist = (bitsDamageType & DMG_AIRBOAT) ? 384 : 172;
for ( i = 0 ; i < cCount ; i++ )
{
vecTraceDir = vecDir * -1;// trace in the opposite direction the shot came from (the direction the shot is going)
vecTraceDir.x += random->RandomFloat( -flNoise, flNoise );
vecTraceDir.y += random->RandomFloat( -flNoise, flNoise );
vecTraceDir.z += random->RandomFloat( -flNoise, flNoise );
// Bleed on and behind the grates.
UTIL_TraceLine( vecPos, vecPos + vecTraceDir * -flTraceDist, MASK_SHOT_HULL & ~CONTENTS_GRATE, this, COLLISION_GROUP_NONE, &Bloodtr);
UTIL_TraceLine( vecPos, vecPos + vecTraceDir * -flTraceDist, MASK_SHOT_HULL, this, COLLISION_GROUP_NONE, &Bloodtr2 );
if ( Bloodtr.fraction != 1.0 )
{
UTIL_BloodDecalTrace( &Bloodtr, BloodColor() );
}
if ( Bloodtr2.fraction != 1.0 && Bloodtr.endpos != Bloodtr2.endpos )
{
UTIL_BloodDecalTrace( &Bloodtr2, BloodColor() );
}
}
}
float CASW_Alien::MaxSpeed()
{
if ( m_bInhabitedMovementAllowed )
{
return m_flAlienWalkSpeed;
}
return FLT_EPSILON;
}
float CASW_Alien::GetBasePlayerYawRate()
{
if ( m_bInhabitedMovementAllowed )
{
return 1000.0f;
}
return FLT_EPSILON;
}