This repository has been archived by the owner on May 4, 2022. It is now read-only.
forked from FWGS/hlsdk-portable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
h_cine.cpp
240 lines (201 loc) · 5.87 KB
/
h_cine.cpp
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access,
* use or distribution of this code by or to any unlicensed person is illegal.
*
****/
/*
===== h_cine.cpp ========================================================
The Halflife hard coded "scripted sequence".
I'm pretty sure all this code is obsolete
*/
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "monsters.h"
#include "decals.h"
class CLegacyCineMonster : public CBaseMonster
{
public:
void CineSpawn( const char *szModel );
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
void EXPORT CineThink( void );
void Pain( void );
void Die( void );
};
class CCineScientist : public CLegacyCineMonster
{
public:
void Spawn( void ) { CineSpawn("models/cine-scientist.mdl"); }
};
class CCine2Scientist : public CLegacyCineMonster
{
public:
void Spawn( void ) { CineSpawn("models/cine2-scientist.mdl"); }
};
class CCinePanther : public CLegacyCineMonster
{
public:
void Spawn( void ) { CineSpawn("models/cine-panther.mdl"); }
};
class CCineBarney : public CLegacyCineMonster
{
public:
void Spawn( void ) { CineSpawn("models/cine-barney.mdl"); }
};
class CCine2HeavyWeapons : public CLegacyCineMonster
{
public:
void Spawn( void ) { CineSpawn("models/cine2_hvyweapons.mdl"); }
};
class CCine2Slave : public CLegacyCineMonster
{
public:
void Spawn( void ) { CineSpawn("models/cine2_slave.mdl"); }
};
class CCine3Scientist : public CLegacyCineMonster
{
public:
void Spawn( void ) { CineSpawn("models/cine3-scientist.mdl"); }
};
class CCine3Barney : public CLegacyCineMonster
{
public:
void Spawn( void ) { CineSpawn("models/cine3-barney.mdl"); }
};
//
// ********** Scientist SPAWN **********
//
LINK_ENTITY_TO_CLASS( monster_cine_scientist, CCineScientist )
LINK_ENTITY_TO_CLASS( monster_cine_panther, CCinePanther )
LINK_ENTITY_TO_CLASS( monster_cine_barney, CCineBarney )
LINK_ENTITY_TO_CLASS( monster_cine2_scientist, CCine2Scientist )
LINK_ENTITY_TO_CLASS( monster_cine2_hvyweapons, CCine2HeavyWeapons )
LINK_ENTITY_TO_CLASS( monster_cine2_slave, CCine2Slave )
LINK_ENTITY_TO_CLASS( monster_cine3_scientist, CCine3Scientist )
LINK_ENTITY_TO_CLASS( monster_cine3_barney, CCine3Barney )
//
// ********** Scientist SPAWN **********
//
void CLegacyCineMonster :: CineSpawn( const char *szModel )
{
PRECACHE_MODEL(szModel);
SET_MODEL(ENT(pev), szModel);
UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 64));
pev->solid = SOLID_SLIDEBOX;
pev->movetype = MOVETYPE_STEP;
pev->effects = 0;
pev->health = 1;
pev->yaw_speed = 10;
// ugly alpha hack, can't set ints from the bsp.
pev->sequence = (int)pev->impulse;
ResetSequenceInfo( );
pev->framerate = 0.0;
m_bloodColor = BLOOD_COLOR_RED;
// if no targetname, start now
if ( FStringNull(pev->targetname) )
{
SetThink( &CLegacyCineMonster::CineThink );
pev->nextthink += 1.0f;
}
}
//
// CineStart
//
void CLegacyCineMonster :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
pev->animtime = 0; // reset the sequence
SetThink( &CLegacyCineMonster::CineThink );
pev->nextthink = gpGlobals->time;
}
//
// ********** Scientist DIE **********
//
void CLegacyCineMonster :: Die( void )
{
SetThink( &CBaseEntity::SUB_Remove );
}
//
// ********** Scientist PAIN **********
//
void CLegacyCineMonster :: Pain( void )
{
EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/pain3.wav", 1, ATTN_NORM);
}
void CLegacyCineMonster :: CineThink( void )
{
// DBG_CheckMonsterData(pev);
// Emit particles from origin (double check animator's placement of model)
// THIS is a test feature
//UTIL_ParticleEffect(pev->origin, g_vecZero, 255, 20);
if (!pev->animtime)
ResetSequenceInfo( );
pev->nextthink = gpGlobals->time + 1.0f;
if (pev->spawnflags != 0 && m_fSequenceFinished)
{
Die();
return;
}
StudioFrameAdvance ( );
}
//
// cine_blood
//
// e3/prealpha only.
class CCineBlood : public CBaseEntity
{
public:
void Spawn( void );
void EXPORT BloodStart ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
void EXPORT BloodGush ( void );
};
LINK_ENTITY_TO_CLASS( cine_blood, CCineBlood )
void CCineBlood :: BloodGush ( void )
{
Vector vecSplatDir;
TraceResult tr;
pev->nextthink = gpGlobals->time + 0.1f;
UTIL_MakeVectors( pev->angles );
if( pev->health-- < 0 )
REMOVE_ENTITY( ENT( pev ) );
// CHANGE_METHOD ( ENT(pev), em_think, SUB_Remove );
if ( RANDOM_FLOAT ( 0.0f, 1.0f ) < 0.7f )// larger chance of globs
{
UTIL_BloodDrips( pev->origin, UTIL_RandomBloodVector(), BLOOD_COLOR_RED, 10 );
}
else // slim chance of geyser
{
UTIL_BloodStream( pev->origin, UTIL_RandomBloodVector(), BLOOD_COLOR_RED, RANDOM_LONG(50, 150) );
}
if ( RANDOM_FLOAT ( 0, 1 ) < 0.75f )
{
// decals the floor with blood.
vecSplatDir = Vector ( 0 , 0 , -1 );
vecSplatDir = vecSplatDir + (RANDOM_FLOAT(-1,1) * 0.6f * gpGlobals->v_right) + (RANDOM_FLOAT(-1,1) * 0.6f * gpGlobals->v_forward);// randomize a bit
UTIL_TraceLine( pev->origin + Vector ( 0, 0 , 64) , pev->origin + vecSplatDir * 256, ignore_monsters, ENT(pev), &tr);
if ( tr.flFraction != 1.0f )
{
// Decal with a bloodsplat
UTIL_BloodDecalTrace( &tr, BLOOD_COLOR_RED );
}
}
}
void CCineBlood :: BloodStart ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
SetThink( &CCineBlood::BloodGush );
pev->nextthink = gpGlobals->time;// now!
}
void CCineBlood :: Spawn ( void )
{
pev->solid = SOLID_NOT;
SetUse( &CCineBlood::BloodStart );
pev->health = 20;//hacked health to count iterations
}