OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
explosion.h
1/*
2===========================================================================
3Copyright (C) 2024 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// explosion.h: Standard explosion object that is spawned by other entites and not map designers.
24// Explosion is used by many of the weapons for the blast effect, but is also used
25// by the Exploder and MultiExploder triggers. These triggers create one or more
26// explosions each time they are activated.
27//
28
29#pragma once
30
31#include "g_local.h"
32#include "entity.h"
33#include "trigger.h"
34
35class Exploder : public Trigger
36 {
37 private:
38 int damage;
39
40 void MakeExplosion( Event *ev );
41 void SetDmg( Event *ev );
42
43 public:
44 CLASS_PROTOTYPE( Exploder );
45
46 Exploder();
47 void Archive( Archiver &arc ) override;
48 };
49
50inline void Exploder::Archive
51 (
52 Archiver &arc
53 )
54
55 {
56 Trigger::Archive( arc );
57
58 arc.ArchiveInteger( &damage );
59 }
60
61class MultiExploder : public Trigger
62 {
63 protected:
64 float explodewait;
65 float explode_time;
66 float duration;
67 int damage;
68 float randomness;
69
70 void MakeExplosion( Event *ev );
71 void SetDmg( Event *ev );
72 void SetDuration( Event *ev );
73 void SetWait( Event *ev );
74 void SetRandom( Event *ev );
75
76 public:
77 CLASS_PROTOTYPE( MultiExploder );
78
79 MultiExploder();
80 void Archive( Archiver &arc ) override;
81 };
82
83inline void MultiExploder::Archive
84 (
85 Archiver &arc
86 )
87 {
88 Trigger::Archive( arc );
89
90 arc.ArchiveFloat( &explodewait );
91 arc.ArchiveFloat( &explode_time );
92 arc.ArchiveFloat( &duration );
93 arc.ArchiveInteger( &damage );
94 arc.ArchiveFloat( &randomness );
95 }
96
97void CreateExplosion
98 (
99 Vector pos,
100 float damage = 120,
101 Entity *inflictor = NULL,
102 Entity *attacker = NULL,
103 Entity *ignore = NULL,
104 const char *explosionModel = NULL,
105 float scale = 1.0f
106 );
107
108class ExplodeObject : public MultiExploder
109 {
110 private:
111 Container<str> debrismodels;
112 int debrisamount;
113 float severity;
114
115 void SetDebrisModel( Event *ev );
116 void SetSeverity( Event *ev );
117 void SetDebrisAmount( Event *ev );
118 void MakeExplosion( Event *ev );
119
120 public:
121 CLASS_PROTOTYPE( ExplodeObject );
122
123 ExplodeObject();
124 void Archive( Archiver &arc ) override;
125 };
126
127inline void ExplodeObject::Archive
128 (
129 Archiver &arc
130 )
131 {
132 MultiExploder::Archive( arc );
133
134 arc.ArchiveFloat( &severity );
135 arc.ArchiveInteger( &debrisamount );
136 debrismodels.Archive( arc );
137 }
Definition archive.h:86
Definition container.h:85
Definition entity.h:203
Definition listener.h:246
Definition vector.h:61