OpenMoHAA 0.82.1
Loading...
Searching...
No Matches
spawners.h
1/*
2===========================================================================
3Copyright (C) 2015 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// spawners.h: Various spawning entities
24
25#pragma once
26
27#include "g_local.h"
28#include "scriptslave.h"
29
30class SpawnArgs;
31
32class Spawn : public ScriptSlave
33{
34private:
35 str modelname;
36 str spawntargetname;
37 str spawntarget;
38 str pickup_thread;
39 str spawnitem;
40 float spawnchance;
41 int attackmode;
42
43 void SetAngleEvent(Event *ev);
44 void SetPickupThread(Event *ev);
45 void ModelName(Event *ev);
46 void SpawnTargetName(Event *ev);
47 void SpawnTarget(Event *ev);
48 void AttackMode(Event *ev);
49 void SetSpawnItem(Event *ev);
50 void SetSpawnChance(Event *ev);
51
52protected:
53 void SetArgs(SpawnArgs& args);
54 virtual void DoSpawn(Event *ev);
55
56public:
57 CLASS_PROTOTYPE(Spawn);
58
59 Spawn();
60 void Archive(Archiver& arc) override;
61};
62
63inline void Spawn::Archive(Archiver& arc)
64{
65 ScriptSlave::Archive(arc);
66
67 arc.ArchiveString(&modelname);
68 arc.ArchiveString(&spawntargetname);
69 arc.ArchiveString(&spawntarget);
70 arc.ArchiveString(&pickup_thread);
71 arc.ArchiveString(&spawnitem);
72 arc.ArchiveFloat(&spawnchance);
73 arc.ArchiveInteger(&attackmode);
74}
75
76class RandomSpawn : public Spawn
77{
78private:
79 float min_time;
80 float max_time;
81
82 void MinTime(Event *ev);
83 void MaxTime(Event *ev);
84 void ToggleSpawn(Event *ev);
85 void Think(Event *ev);
86
87public:
88 CLASS_PROTOTYPE(RandomSpawn);
89
90 RandomSpawn();
91 void Archive(Archiver& arc) override;
92};
93
94inline void RandomSpawn::Archive(Archiver& arc)
95{
96 Spawn::Archive(arc);
97
98 arc.ArchiveFloat(&min_time);
99 arc.ArchiveFloat(&max_time);
100}
101
102class ReSpawn : public Spawn
103{
104protected:
105 void DoSpawn(Event *ev) override;
106
107public:
108 CLASS_PROTOTYPE(ReSpawn);
109};
110
111class SpawnOutOfSight : public Spawn
112{
113protected:
114 void DoSpawn(Event *ev) override;
115
116public:
117 CLASS_PROTOTYPE(SpawnOutOfSight);
118};
119
120class SpawnChain : public Spawn
121{
122protected:
123 void DoSpawn(Event *ev) override;
124
125public:
126 CLASS_PROTOTYPE(SpawnChain);
127};
Definition archive.h:86
Definition listener.h:246
Definition spawners.h:103
Definition g_spawn.h:44
Definition spawners.h:121
Definition spawners.h:112
Definition str.h:77