OpenMoHAA 0.82.1
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{
37private:
38 int damage;
39
40 void MakeExplosion(Event *ev);
41 void SetDmg(Event *ev);
42
43public:
44 CLASS_PROTOTYPE(Exploder);
45
46 Exploder();
47 void Archive(Archiver& arc) override;
48};
49
50inline void Exploder::Archive(Archiver& arc)
51{
52 Trigger::Archive(arc);
53
54 arc.ArchiveInteger(&damage);
55}
56
57class MultiExploder : public Trigger
58{
59protected:
60 float explodewait;
61 float explode_time;
62 float duration;
63 int damage;
64 float randomness;
65
66 void MakeExplosion(Event *ev);
67 void SetDmg(Event *ev);
68 void SetDuration(Event *ev);
69 void SetWait(Event *ev);
70 void SetRandom(Event *ev);
71
72public:
73 CLASS_PROTOTYPE(MultiExploder);
74
75 MultiExploder();
76 void Archive(Archiver& arc) override;
77};
78
79inline void MultiExploder::Archive(Archiver& arc)
80{
81 Trigger::Archive(arc);
82
83 arc.ArchiveFloat(&explodewait);
84 arc.ArchiveFloat(&explode_time);
85 arc.ArchiveFloat(&duration);
86 arc.ArchiveInteger(&damage);
87 arc.ArchiveFloat(&randomness);
88}
89
90void CreateExplosion(
91 Vector pos,
92 float damage = 120,
93 Entity *inflictor = NULL,
94 Entity *attacker = NULL,
95 Entity *ignore = NULL,
96 const char *explosionModel = NULL,
97 float scale = 1.0f
98);
99
100class ExplodeObject : public MultiExploder
101{
102private:
103 Container<str> debrismodels;
104 int debrisamount;
105 float severity;
106
107 void SetDebrisModel(Event *ev);
108 void SetSeverity(Event *ev);
109 void SetDebrisAmount(Event *ev);
110 void MakeExplosion(Event *ev);
111
112public:
113 CLASS_PROTOTYPE(ExplodeObject);
114
115 ExplodeObject();
116 void Archive(Archiver& arc) override;
117};
118
119inline void ExplodeObject::Archive(Archiver& arc)
120{
121 MultiExploder::Archive(arc);
122
123 arc.ArchiveFloat(&severity);
124 arc.ArchiveInteger(&debrisamount);
125 debrismodels.Archive(arc);
126}
Definition archive.h:86
Definition container.h:85
Definition entity.h:203
Definition listener.h:246
Definition vector.h:61