OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
Entities.h
1/*
2===========================================================================
3Copyright (C) 2023 the OpenMoHAA team
4
5This file is part of OpenMoHAA source code.
6
7OpenMoHAA source code is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 2 of the License,
10or (at your option) any later version.
11
12OpenMoHAA source code is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with OpenMoHAA source code; if not, write to the Free Software
19Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20===========================================================================
21*/
22
23#pragma once
24
25#include "entity.h"
26#include "animate.h"
27
28typedef enum {
29 CONTROLLER_AXIS,
30 CONTROLLER_ALLIES,
31 CONTROLLER_DRAW
32} eController;
33
34#define PT_SPAWNFLAG_PLAY_FIRE_SOUND 1
35#define PT_SPAWNFLAG_PLAY_MOTION_SOUND 2
36#define PT_SPAWNFLAG_TARGET_RANDOM 4
37#define PT_SPAWNFLAG_TURN_ON 8
38#define PT_SPAWNFLAG_ROTATE_YAW 16
39#define PT_SPAWNFLAG_ROTATE_ROLL 32
40#define PT_SPAWNFLAG_TARGET_PLAYER 64
41#define PT_SPAWNFLAG_HIDDEN 128
42
43void ClearProjectileTargets();
44
45class ProjectileTarget : public Entity
46{
47private:
48 int m_iID;
49
50public:
51 CLASS_PROTOTYPE(ProjectileTarget);
52
53 ProjectileTarget();
54
55 void EventSetId(Event *ev);
56 int GetId() const;
57
58 void Archive(Archiver& arc) override;
59};
60
61#define MAX_PROJECTILE_GENERATOR_TARGETS 16
62
63class ProjectileGenerator : public Animate
64{
65protected:
66 int m_iId;
67 int m_iCycles;
68 float m_fMinDuration;
69 float m_fMaxDuration;
70 int m_iMinNumShots;
71 int m_iMaxNumShots;
72 float m_fMinDelay;
73 float m_fMaxDelay;
74 float m_fAccuracy;
75 str m_sLaunchSound;
76 bool m_bFireOnStartUp;
77 qboolean m_bIsDonut;
78 float m_fArcDonut;
79 float m_fMinDonut;
80 float m_fMaxDonut;
81 float m_fCycleTime;
82 float m_fShotsPerSec;
83 float m_fCurrentTime;
84 int m_iTargetIndex;
85 float m_fLastShotTime;
86 int m_iAnimSlot;
87 bool m_bIsTurnedOn;
88 int m_iCurrentCycle;
89 Entity *m_pTarget;
90 Container<ProjectileTarget *> m_projectileTargets;
91 Entity *m_pCurrent;
92 Vector m_vTargetOrg;
93
94public:
95 CLASS_PROTOTYPE(ProjectileGenerator);
96
97 ProjectileGenerator();
98
99 virtual void SetupNextCycle();
100 virtual void BeginCycle(Event *ev);
101 virtual void TickCycle(Event *ev);
102 virtual void EndCycle(Event *ev);
103
104 bool ShouldStartOn() const;
105 bool ShouldHideModel() const;
106 bool ShouldPlayFireSound() const;
107 bool ShouldPlayMotionSound() const;
108 bool ShouldRotateYaw() const;
109 bool ShouldRotateRoll() const;
110
111 void EventIsTurnedOn(Event *ev);
112 void EventGetTargetEntity(Event *ev);
113 void EventLaunchSound(Event *ev);
114 void SetTarget(Event *ev);
115 void SetTarget(Entity *ent);
116 void OnInitialize(Event *ev);
117 void TurnOff(Event *ev);
118 void TurnOn(Event *ev);
119 bool ShouldTargetRandom() const;
120 Entity *ChooseTarget();
121
122 void GetLocalTargets();
123 bool ShouldTargetPlayer() const;
124 Vector GetTargetPos(Entity *target);
125 void GetMuzzlePos(Vector& pos);
126 void Fire();
127 void TryLaunchSound();
128 void SetWeaponAnim(const char *name, Event *ev);
129 void EventAccuracy(Event *ev);
130 void EventMaxDelay(Event *ev);
131 void EventMinDelay(Event *ev);
132 void EventFireOnStartUp(Event *ev);
133 void EventMaxNumShots(Event *ev);
134 void EventMinNumShots(Event *ev);
135 void EventCycles(Event *ev);
136 void EventMaxDuration(Event *ev);
137 void EventMinDuration(Event *ev);
138 void SetWeaponModel(Event *ev);
139 void EventSetId(Event *ev);
140 void EventmaxDonut(Event *ev);
141 void EventminDonut(Event *ev);
142 void EventarcDonut(Event *ev);
143 void EventisDonut(Event *ev);
144 virtual bool Attack(int count);
145
146 void Archive(Archiver& arc) override;
147};
148
149class ProjectileGenerator_Projectile : public ProjectileGenerator
150{
151private:
152 str m_sProjectileModel;
153 str m_sPreImpactSound;
154 float m_fImpactSoundTime;
155 float m_fImpactSoundProbability;
156
157public:
158 CLASS_PROTOTYPE(ProjectileGenerator_Projectile);
159
160 ProjectileGenerator_Projectile();
161
162 void SetPreImpactSoundProbability(Event *ev);
163 void SetPreImpactSoundTime(Event *ev);
164 void SetPreImpactSound(Event *ev);
165 void PlayPreImpactSound(Event *ev);
166 void SetProjectileModel(Event *ev);
167
168 float EstimateImpactTime(const Vector& targetOrigin, const Vector& fromOrigin, float speed) const;
169 bool Attack(int count) override;
170 void Archive(Archiver& arc) override;
171};
172
173class ProjectileGenerator_Gun : public ProjectileGenerator
174{
175private:
176 float m_fBulletRange;
177 float m_fBulletDamage;
178 int m_iBulletCount;
179 Vector m_vBulletSpread;
180 int m_iTracerFrequency;
181 int m_iBulletLarge;
182 qboolean m_bFakeBullets;
183 int m_iMeansOfDeath;
184 float m_fBulletThroughWood;
185 float m_fBulletThroughMetal;
186 float m_iBulletKnockback;
187 int m_iAttackCount;
188 float m_fFireDelay;
189 float m_fTracerSpeed;
190
191public:
192 CLASS_PROTOTYPE(ProjectileGenerator_Gun);
193
194 ProjectileGenerator_Gun();
195
196 void SetFireDelay(Event *ev);
197 void SetMeansOfDeath(Event *ev);
198 void SetBulletThroughWood(Event *ev);
199 void SetBulletThroughMetal(Event *ev);
200 void SetBulletKnockback(Event *ev);
201 void SetTracerSpeed(Event *ev);
202 void SetBulletLarge(Event *ev);
203 void SetFakeBullets(Event *ev);
204 void SetBulletCount(Event *ev);
205 void SetBulletDamage(Event *ev);
206 void SetTracerFrequency(Event *ev);
207 void SetBulletSpread(Event *ev);
208 void SetBulletRange(Event *ev);
209
210 bool Attack(int count) override;
211 bool TickWeaponAnim();
212 void TickCycle(Event *ev) override;
213 void Archive(Archiver& arc) override;
214};
215
216class ProjectileGenerator_Heavy : public ProjectileGenerator
217{
218private:
219 str m_sProjectileModel;
220
221public:
222 CLASS_PROTOTYPE(ProjectileGenerator_Heavy);
223
224 ProjectileGenerator_Heavy();
225
226 void SetProjectileModel(Event *ev);
227
228 bool Attack(int count) override;
229 void Archive(Archiver& arc) override;
230};
231
232class ThrobbingBox_Explosive : public Animate
233{
234protected:
235 str m_sUsedModel;
236 str m_sSound;
237 bool m_bUsed;
238 float m_fExplosionDamage;
239 float m_fRadius;
240 float m_fStopwatchDuration;
241 str m_sActivateSound;
242 str m_sTickSound;
243 str m_sDestroyedModel;
244 ScriptThreadLabel m_thread;
245 ScriptThreadLabel m_useThread;
246 str m_sEffect;
247 Vector m_vOffset;
248
249public:
250 CLASS_PROTOTYPE(ThrobbingBox_Explosive);
251
252 ThrobbingBox_Explosive();
253
254 bool ShouldDoExplosion();
255
256 void SetExplosionOffset(Event *ev);
257 void SetExplosionEffect(Event *ev);
258 void SetTriggered(Event *ev);
259 void DoExplosion(Event *ev);
260 void SetUseThread(Event *ev);
261 void SetThread(Event *ev);
262 void SetStopWatchDuration(Event *ev);
263 void SetRadius(Event *ev);
264 void SetDamage(Event *ev);
265 void TickSound(Event *ev);
266 void ActivateSound(Event *ev);
267 void ExplosionSound(Event *ev);
268 void UsedModel(Event *ev);
269 void SetDestroyModel(Event *ev);
270 void OnBlowUp(Event *ev);
271 void OnUse(Event *ev);
272
273 void Archive(Archiver& arc) override;
274};
275
276class ThrobbingBox_ExplodePlayerFlak88 : public ThrobbingBox_Explosive
277{
278public:
279 CLASS_PROTOTYPE(ThrobbingBox_ExplodePlayerFlak88);
280
281public:
282 ThrobbingBox_ExplodePlayerFlak88();
283};
284
285class ThrobbingBox_ExplodeFlak88 : public ThrobbingBox_Explosive
286{
287public:
288 CLASS_PROTOTYPE(ThrobbingBox_ExplodeFlak88);
289
290public:
291 ThrobbingBox_ExplodeFlak88();
292};
293
294class ThrobbingBox_ExplodeNebelwerfer : public ThrobbingBox_Explosive
295{
296public:
297 CLASS_PROTOTYPE(ThrobbingBox_ExplodeNebelwerfer);
298
299public:
300 ThrobbingBox_ExplodeNebelwerfer();
301};
302
303class ThrobbingBox_ExplodePlayerNebelwerfer : public ThrobbingBox_Explosive
304{
305public:
306 CLASS_PROTOTYPE(ThrobbingBox_ExplodePlayerNebelwerfer);
307
308public:
309 ThrobbingBox_ExplodePlayerNebelwerfer();
310};
311
312#define TBE_SPAWNFLAG_DESTROYED_MODEL 1
313#define TBE_SPAWNFLAG_MAKE_WET 2
314
315class ThrobbingBox_Stickybomb : public ThrobbingBox_Explosive
316{
317private:
318 float m_fStopwatchStartTime;
319
320public:
321 CLASS_PROTOTYPE(ThrobbingBox_Stickybomb);
322
323 ThrobbingBox_Stickybomb();
324
325 void OnStickyBombWet(Event *ev);
326 void OnStickyBombUse(Event *ev);
327
328 void Archive(Archiver& arc) override;
329};
330
331#define OBJECTIVE_SPAWNFLAG_TURN_ON 1
332
333class Objective : public Entity
334{
335private:
336 str m_sText;
337 int m_iObjectiveIndex;
338
339public:
340 CLASS_PROTOTYPE(Objective);
341
342 Objective();
343
344 void Archive(Archiver& arc) override;
345 void TurnOn(Event *ev);
346 void TurnOff(Event *ev);
347 void Complete(Event *ev);
348 void SetCurrent(Event *ev);
349 Vector GetOrigin() const;
350 void SetObjectiveNbr(Event *ev);
351 void SetText(Event *ev);
352 int GetObjectiveIndex() const;
353};
354
355class FencePost : public Entity
356{
357public:
358 CLASS_PROTOTYPE(FencePost);
359
360 FencePost();
361
362 void Killed(Event* ev) override;
363};
364
365class AISpawnPoint : public SimpleArchivedEntity
366{
367private:
368 str m_sModel;
369 int m_iHealth;
370 str m_sEnemyName;
371 float m_iAccuracy;
372 int m_iAmmoGrenade;
373 float m_iBalconyHeight;
374 int m_iDisguiseLevel;
375 float m_fDisguisePeriod;
376 float m_fDisguiseRange;
377 float m_fEnemyShareRange;
378 float m_fFixedLeash;
379 float m_fGrenadeAwareness;
380 str m_sGun;
381 float m_fMaxNoticeTimeScale;
382 float m_fSoundAwareness;
383 str m_sTypeAttack;
384 str m_sTypeDisguise;
385 str m_sTypeGrenade;
386 str m_sTypeIdle;
387 bool m_bPatrolWaitTrigger;
388 float m_fHearing;
389 float m_fSight;
390 float m_fFov;
391 float m_fLeash;
392 float m_fMinDist;
393 float m_fMaxDist;
394 float m_fInterval;
395 bool m_bDontDropWeapons;
396 bool m_bDontDropHealth;
397 str m_sFavoriteEnemy;
398 bool m_bNoSurprise;
399 str m_sPatrolPath;
400 str m_sTurret;
401 str m_sAlarmNode;
402 str m_sWeapon;
403 str m_sTarget;
404 str m_sVoiceType;
405 bool m_bForceDropWeapon;
406 bool m_bForceDropHealth;
407
408public:
409 CLASS_PROTOTYPE(AISpawnPoint);
410
411 AISpawnPoint();
412
413 void GetForceDropHealth(Event *ev);
414 void SetForceDropHealth(Event *ev);
415 void GetForceDropWeapon(Event *ev);
416 void SetForceDropWeapon(Event *ev);
417 void GetVoiceType(Event *ev);
418 void SetVoiceType(Event *ev);
419 void GetTarget(Event *ev);
420 void SetTarget(Event *ev);
421 void GetWeapon(Event *ev);
422 void SetWeapon(Event *ev);
423 void GetAlarmNode(Event *ev);
424 void SetAlarmNode(Event *ev);
425 void GetTurret(Event *ev);
426 void SetTurret(Event *ev);
427 void GetPatrolPath(Event *ev);
428 void SetPatrolPath(Event *ev);
429 void GetNoSurprise(Event *ev);
430 void SetNoSurprise(Event *ev);
431 void SetFavoriteEnemy(Event *ev);
432 void GetFavoriteEnemy(Event *ev);
433 void GetDontDropHealth(Event *ev);
434 void SetDontDropHealth(Event *ev);
435 void GetDontDropWeapons(Event *ev);
436 void SetDontDropWeapons(Event *ev);
437 void GetInterval(Event *ev);
438 void SetInterval(Event *ev);
439 void GetMaxDistance(Event *ev);
440 void SetMaxDistance(Event *ev);
441 void GetMinDistance(Event *ev);
442 void SetMinDistance(Event *ev);
443 void GetLeash(Event *ev);
444 void SetLeash(Event *ev);
445 void GetFov(Event *ev);
446 void SetFov(Event *ev);
447 void SetSight(Event *ev);
448 void GetSight(Event *ev);
449 void GetHearing(Event *ev);
450 void SetHearing(Event *ev);
451 void GetPatrolWaitTrigger(Event *ev);
452 void SetPatrolWaitTrigger(Event *ev);
453 void GetTypeIdle(Event *ev);
454 void SetTypeIdle(Event *ev);
455 void GetTypeGrenade(Event *ev);
456 void SetTypeGrenade(Event *ev);
457 void GetTypeDisguise(Event *ev);
458 void SetTypeDisguise(Event *ev);
459 void GetTypeAttack(Event *ev);
460 void SetTypeAttack(Event *ev);
461 void SetSoundAwareness(Event *ev);
462 void GetSoundAwareness(Event *ev);
463 void SetMaxNoticeTimeScale(Event *ev);
464 void GetMaxNoticeTimeScale(Event *ev);
465 void GetGun(Event *ev);
466 void SetGun(Event *ev);
467 void GetGrenadeAwareness(Event *ev);
468 void SetGrenadeAwareness(Event *ev);
469 void SetFixedLeash(Event *ev);
470 void GetFixedLeash(Event *ev);
471 void GetEnemyShareRange(Event *ev);
472 void SetEnemyShareRange(Event *ev);
473 void GetDisguiseRange(Event *ev);
474 void SetDisguiseRange(Event *ev);
475 void GetDisguisePeriod(Event *ev);
476 void SetDisguisePeriod(Event *ev);
477 void GetDisguiseLevel(Event *ev);
478 void SetDisguiseLevel(Event *ev);
479 void GetBalconyHeight(Event *ev);
480 void SetBalconyHeight(Event *ev);
481 void GetAmmoGrenade(Event *ev);
482 void SetAmmoGrenade(Event *ev);
483 void GetAccuracy(Event *ev);
484 void SetAccuracy(Event *ev);
485 void GetEnemyName(Event *ev);
486 void SetEnemyName(Event *ev);
487 void GetHealth(Event *ev);
488 void SetHealth(Event *ev);
489 void GetModel(Event *ev);
490 void SetModel(Event *ev);
491
492 void Archive(Archiver& arc) override;
493};
Definition archive.h:86
Definition container.h:85
Definition listener.h:246
Definition gamescript.h:165
Definition vector.h:61
Definition str.h:77