-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExotechLarvaCharger.es
More file actions
255 lines (206 loc) · 8.04 KB
/
ExotechLarvaCharger.es
File metadata and controls
255 lines (206 loc) · 8.04 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
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
/* Copyright (c) 2002-2012 Croteam Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as published by
the Free Software Foundation
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
351
%{
#include "StdH.h"
#include "ModelsMP/Enemies/ExotechLarva/Charger/FloorCharger.h"
%}
uses "Entities/BloodSpray";
uses "Entities/Projectile";
uses "Entities/ExotechLarvaBattery";
event EActivateBeam {
BOOL bTurnOn,
};
class CExotechLarvaCharger : CRationalEntity {
name "ExotechLarvaCharger";
thumbnail "Thumbnails\\ExotechLarvaCharger.tbn";
features "HasName", "IsTargetable";
properties:
1 BOOL m_bActive = TRUE,
2 BOOL m_bBeamActive = FALSE,
3 FLOAT m_fStretch "Stretch" 'S' = 1.0f,
7 CTString m_strName "Name" 'N' = "ExotechLarva Floor Charger",
8 RANGE m_rSound "Sound Range" = 100.0f,
10 CEntityPointer m_penBattery01 "Wall Battery 01",
11 CEntityPointer m_penBattery02 "Wall Battery 02",
12 CEntityPointer m_penBattery03 "Wall Battery 03",
13 CEntityPointer m_penBattery04 "Wall Battery 04",
14 CEntityPointer m_penBattery05 "Wall Battery 05",
15 CEntityPointer m_penBattery06 "Wall Battery 06",
20 BOOL m_bCustomShading "Custom Shading" = FALSE,
21 ANGLE3D m_aShadingDirection "Light direction" 'D' = ANGLE3D( AngleDeg(45.0f),AngleDeg(45.0f),AngleDeg(45.0f)),
22 COLOR m_colLight "Light Color" = C_WHITE,
23 COLOR m_colAmbient "Ambient Light Color" = C_BLACK,
50 CSoundObject m_soSound,
components:
1 class CLASS_BASIC_EFFECT "Classes\\BasicEffect.ecl",
2 class CLASS_BLOOD_SPRAY "Classes\\BloodSpray.ecl",
5 model MODEL_CHARGER "ModelsMP\\Enemies\\ExotechLarva\\Charger\\FloorCharger.mdl",
6 texture TEXTURE_CHARGER "ModelsMP\\Enemies\\ExotechLarva\\Charger\\FloorCharger.tex",
7 model MODEL_BEAM "ModelsMP\\Enemies\\ExotechLarva\\Charger\\Beam.mdl",
8 texture TEXTURE_BEAM "ModelsMP\\Enemies\\ExotechLarva\\Charger\\Beam.tex",
9 model MODEL_ELECTRICITY "ModelsMP\\Enemies\\ExotechLarva\\Charger\\ElectricityBeams.mdl",
10 texture TEXTURE_ELECTRICITY "ModelsMP\\Effects\\Laser\\Laser_Red.tex",
50 sound SOUND_HUM "ModelsMP\\Enemies\\ExotechLarva\\Charger\\Sounds\\FloorChargerHum.wav",
51 sound SOUND_SHUTDOWN "ModelsMP\\Enemies\\ExotechLarva\\Charger\\Sounds\\FloorChargerShutdown.wav",
functions:
BOOL IsTargetValid(SLONG slPropertyOffset, CEntity *penTarget)
{
if( slPropertyOffset == offsetof(CExotechLarvaCharger, m_penBattery01) ||
slPropertyOffset == offsetof(CExotechLarvaCharger, m_penBattery02) ||
slPropertyOffset == offsetof(CExotechLarvaCharger, m_penBattery03) ||
slPropertyOffset == offsetof(CExotechLarvaCharger, m_penBattery04) ||
slPropertyOffset == offsetof(CExotechLarvaCharger, m_penBattery05) ||
slPropertyOffset == offsetof(CExotechLarvaCharger, m_penBattery06))
{
if (IsOfClass(penTarget, "ExotechLarvaBattery")) { return TRUE; }
else { return FALSE; }
}
return CEntity::IsTargetValid(slPropertyOffset, penTarget);
}
void Precache(void) {
CRationalEntity::Precache();
PrecacheModel (MODEL_ELECTRICITY );
PrecacheTexture (TEXTURE_ELECTRICITY );
PrecacheModel (MODEL_BEAM );
PrecacheTexture (TEXTURE_BEAM );
PrecacheSound (SOUND_HUM );
PrecacheSound (SOUND_SHUTDOWN );
}
/* Adjust model shading parameters if needed. */
BOOL AdjustShadingParameters(FLOAT3D &vLightDirection, COLOR &colLight, COLOR &colAmbient)
{
if (m_bCustomShading)
{
colLight = m_colLight;
colAmbient = m_colAmbient;
AnglesToDirectionVector(m_aShadingDirection, vLightDirection);
vLightDirection = -vLightDirection;
}
return TRUE;
};
void UpdateOperationalState(void) {
CEntityPointer *penFirst = &m_penBattery01;
for (INDEX i=0; i<6; i++) {
CExotechLarvaBattery *penBattery = (CExotechLarvaBattery *)&(*penFirst[i]);
// if model pointer is valid
if (penBattery) {
if (penBattery->m_bActive) {
// at least one exists, so we are still active
m_bActive = TRUE;
return;
}
}
}
// if no batteries found, change the state to inactive
m_bActive = FALSE;
EActivateBeam eab;
eab.bTurnOn = FALSE;
SendEvent(eab);
PlaySound(m_soSound, SOUND_SHUTDOWN, SOF_3D);
RemoveAttachmentFromModel(*GetModelObject(), FLOORCHARGER_ATTACHMENT_ELECTRICITY);
}
void ReceiveDamage(CEntity *penInflictor, enum DamageType dmtType,
FLOAT fDamageAmmount, const FLOAT3D &vHitPoint, const FLOAT3D &vDirection)
{
NOTHING;
};
void RenderParticles(void)
{
if (m_bBeamActive)
{
CEntityPointer *penFirst = &m_penBattery01;
for (INDEX i=0; i<6; i++) {
CExotechLarvaBattery *penBattery = (CExotechLarvaBattery *)&(*penFirst[i]);
// if model pointer is valid
if (penBattery) {
if (penBattery->m_bActive) {
// render electricity
FLOAT tmNow = _pTimer->GetLerpedCurrentTick();
Particles_Ghostbuster(GetPlacement().pl_PositionVector + FLOAT3D(0.0f, 0.2f, 0.0f),
penBattery->GetPlacement().pl_PositionVector + FLOAT3D(0.0f, 0.2f, 0.0f),
32, 1.0f);
Particles_ModelGlow(penBattery, 1e6, PT_STAR05, 1.0f+0.5f*sin(4.0f*tmNow), 4, 0.0f, C_WHITE);
}
}
}
}
};
procedures:
ActivateBeam()
{
AddAttachmentToModel(this, *GetModelObject(), FLOORCHARGER_ATTACHMENT_BEAM, MODEL_BEAM, TEXTURE_BEAM, 0, 0, 0);
CModelObject &amo = GetModelObject()->GetAttachmentModel(FLOORCHARGER_ATTACHMENT_BEAM)->amo_moModelObject;
amo.StretchModelRelative(FLOAT3D(m_fStretch, m_fStretch, m_fStretch));
m_bBeamActive = TRUE;
return;
}
DeactivateBeam()
{
RemoveAttachmentFromModel(*GetModelObject(), FLOORCHARGER_ATTACHMENT_BEAM);
m_bBeamActive = FALSE;
return;
}
Main()
{
InitAsModel();
SetPhysicsFlags(EPF_MODEL_FIXED);
SetCollisionFlags(ECF_IMMATERIAL);
SetFlags(GetFlags()|ENF_ALIVE);
// set your appearance
SetModel(MODEL_CHARGER);
SetModelMainTexture(TEXTURE_CHARGER);
// set stretch factors for height and width
GetModelObject()->StretchModel(FLOAT3D(m_fStretch, m_fStretch, m_fStretch));
ModelChangeNotify();
autowait(0.05f);
m_soSound.Set3DParameters(m_rSound, m_rSound/2.0f, 2.0f, 1.0f);
m_bActive = FALSE;
m_bBeamActive = FALSE;
// wait to be triggered
wait() {
on (EBegin) : { resume; }
on (ETrigger) : { stop; }
otherwise (): { resume; }
}
UpdateOperationalState();
if (m_bActive) {
AddAttachmentToModel(this, *GetModelObject(), FLOORCHARGER_ATTACHMENT_ELECTRICITY, MODEL_ELECTRICITY, TEXTURE_ELECTRICITY, 0, 0, 0);
CAttachmentModelObject *amo = GetModelObject()->GetAttachmentModel(FLOORCHARGER_ATTACHMENT_ELECTRICITY);
amo->amo_moModelObject.StretchModel(FLOAT3D(m_fStretch, m_fStretch, m_fStretch));
PlaySound(m_soSound, SOUND_HUM, SOF_3D|SOF_LOOP);
}
while (TRUE) {
wait(0.5f)
{
on (EBegin) : {
resume;
}
on (ETimer) : {
if (m_bActive) {
UpdateOperationalState();
}
stop;
}
on (EActivateBeam eab) : {
if (eab.bTurnOn==TRUE && m_bBeamActive!=TRUE) {
call ActivateBeam();
} else if (eab.bTurnOn==FALSE && m_bBeamActive!=FALSE) {
call DeactivateBeam();
}
resume;
}
}
}
return;
}
};