OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
level.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// level.h: General Level Info
24
25#pragma once
26
27#include "listener.h"
28#include "g_public.h"
29#include "bg_voteoptions.h"
30
31#define MAX_HEAD_SENTIENTS 2
32#define MAX_EARTHQUAKES 10
33
34enum INTTYPE_e {
35 TRANS_BSP,
36 TRANS_LEVEL,
37 TRANS_MISSION,
38 TRANS_MISSION_FAILED
39};
40
41enum fadetype_t {
42 fadein,
43 fadeout
44};
45
46enum fadestyle_t {
47 alphablend,
48 additive
49};
50
51enum letterboxdir_t {
52 letterbox_in,
53 letterbox_out
54};
55
56typedef struct earthquake_s {
57 int duration;
58 float magnitude;
59 bool no_rampup;
60 bool no_rampdown;
61
62 int starttime;
63 int endtime;
64 SafePtr<ScriptThread> m_Thread;
65} earthquake_t;
66
67struct badplace_t {
68 const_str m_name;
69 int m_iTeamSide;
70 Vector m_vOrigin;
71 float m_fRadius;
72 float m_fLifespan;
73
74public:
75 badplace_t();
76};
77
78typedef struct {
79 str m_sName;
80 Vector m_vOrigin;
82
83extern gclient_t *spawn_client;
84
85class Camera;
87class Actor;
88
89class Level : public Listener
90{
91public:
92 char *current_map;
93
94 int mHealthPopCount;
95
96 // Map name stuff
97 str m_mapscript;
98 str m_precachescript;
99 str m_pathfile;
100 str m_mapfile;
101
102 // Spawning variables
103 int spawn_entnum;
104 int spawnflags;
105
106 // Level time
107 int framenum;
108 int inttime;
109 int intframetime;
110
111 float time;
112 float frametime;
113
114 // Server time
115 int svsTime;
116 float svsFloatTime;
117 int svsStartTime;
118 int svsEndTime;
119 float svsStartFloatTime; // Added in 2.0
120
121 // Level name variables
122 str level_name;
123 str mapname;
124 str spawnpoint;
125 str nextmap;
126
127 // AI variables
128 int m_iCuriousVoiceTime;
129 int m_iAttackEntryAnimTime;
130
131 // Global players variables
132 qboolean playerfrozen;
133
134 // Intermission variables
135 float intermissiontime;
136 INTTYPE_e intermissiontype;
137 int exitintermission;
138
139 // Secrets
140 int total_secrets;
141 int found_secrets;
142
143 // Trace
144 trace_t impact_trace;
145
146 // Earthquake stuff
147 float earthquake_magnitude;
148
149 // Cinematic
150 qboolean cinematic;
151
152 // AI variables
153 qboolean ai_on;
154 qboolean m_bAlarm;
155 qboolean mbNoDropHealth;
156 qboolean mbNoDropWeapons; // Added in 2.0
157 int m_iPapersLevel;
158
159 // Mission state
160 qboolean mission_failed;
161 qboolean died_already;
162 qboolean near_exit;
163
164 // Water variables
165 Vector water_color;
166 Vector lava_color;
167 float water_alpha;
168 float lava_alpha;
169
170 // Soundtrack variables
171 str current_soundtrack;
172 str saved_soundtrack;
173
174 // Screen state
175 Vector m_fade_color;
176 float m_fade_alpha;
177 float m_fade_time;
178 float m_fade_time_start;
179 fadetype_t m_fade_type;
180 fadestyle_t m_fade_style;
181
182 // Letterbox state
183 float m_letterbox_fraction;
184 float m_letterbox_time;
185 float m_letterbox_time_start;
186 letterboxdir_t m_letterbox_dir;
187
188 // Added in 2.0
189 // Bad places
190 Container<badplace_t> m_badPlaces;
191
192 Container<Camera *> automatic_cameras;
193
194 // Quake remnants ?
195 int m_numArenas;
196
197 // Voting variables
198 int m_voteTime;
199 int m_nextVoteTime;
200 int m_voteYes;
201 int m_voteNo;
202 int m_numVoters;
203 // Added in 2.0
204 str m_voteString;
205 str m_voteName;
206 VoteOptions m_voteOptions;
207
208 // Intermission locations
209 Vector m_intermission_origin;
210 Vector m_intermission_angle;
211
212 // Skeleton variables
213 int frame_skel_index;
214 int skel_index[MAX_GENTITIES];
215
216 // script variables
217 qboolean m_LoopProtection;
218 qboolean m_LoopDrop; // kill the server in loop exception
219
220 Container<SimpleArchivedEntity *> m_SimpleArchivedEntities;
221 class Sentient *m_HeadSentient[MAX_HEAD_SENTIENTS];
222
223 // Earthquake stuff
224 earthquake_t earthquakes[MAX_EARTHQUAKES];
225 int num_earthquakes;
226
227 // Objective stuff
228 Vector m_vObjectiveLocation;
229 Vector m_vAlliedObjectiveLocation; // Added in 2.0
230 Vector m_vAxisObjectiveLocation; // Added in 2.0
231 // Added in OPM
232 // Forces axis/allied objectives location to be used
233 // even if the gametype is not TOW
234 bool m_bForceTeamObjectiveLocation;
235
236 // Current level state
237 bool spawning;
238 bool m_bIgnoreClock;
239 //====
240 // Added in 2.30
241 // Landmarks
242 float m_fLandmarkYDistMax;
243 float m_fLandmarkYDistMin;
244 float m_fLandmarkXDistMin;
245 float m_fLandmarkXDistMax;
246 landmark_t **m_pLandmarks;
247 int m_iMaxLandmarks;
248 int m_iLandmarksCount;
249 //====
250 void *m_pAIStats;
251
252 // New Stuff
253
254 // Script stuff
255 bool m_bScriptSpawn;
256 bool m_bRejectSpawn;
257
258public:
259 CLASS_PROTOTYPE(Level);
260
261 Level();
262 virtual ~Level();
263
264 void Init();
265 void CleanUp(qboolean samemap = qfalse, qboolean resetConfigStrings = qfalse);
266 void ResetEdicts();
267 gentity_t *AllocEdict(Entity *ent);
268 void FreeEdict(gentity_t *ent);
269 void InitEdict(gentity_t *ent);
270 void LoadAllScripts(const char *name, const char *extension);
271 void Precache();
272 void SetMap(const char *themapname);
273 void FindTeams();
274
275 void SpawnEntities(char *entities, int _svsTime_);
276 //====
277 // Added in 2.30
278 void ComputeDMWaypoints();
279 void AddLandmarkOrigin(const Vector& origin);
280 void AddLandmarkName(const str& name, const Vector& origin);
281 void FreeLandmarks();
282 str GetDynamicDMLocations(const Vector& origin);
283 str GetDMLocation(const Vector& origin);
284 //====
285 void PreSpawnSentient(Event *ev);
286 void ServerSpawned();
287 qboolean inhibitEntity(int spawnflags);
288
289 void setSkill(int value);
290 void setTime(int _svsTime_);
291 void setFrametime(int frameTime);
292
293 void AddAutomaticCamera(Camera *cam);
294
295 void GetTime(Event *ev);
296 void GetTotalSecrets(Event *ev);
297 void GetFoundSecrets(Event *ev);
298
299 //====
300 // Added in 2.0
301 void InitVoteOptions();
302 void SendVoteOptionsFile(gentity_t *ent);
303 bool GetVoteOptionMain(int index, str *outOptionCommand, voteoptiontype_t *outOptionType);
304 bool GetVoteOptionSub(int index, int listIndex, str *outCommand);
305 bool GetVoteOptionMainName(int index, str *outVoteName);
306 bool GetVoteOptionSubName(int index, int listIndex, str *outName);
307 //====
308 void CheckVote();
309 void SetupMaplist(); // Added in 2.0
310
311 void GetAlarm(Event *ev);
312 void SetAlarm(Event *ev);
313 void SetNoDropHealth(Event *ev);
314 void SetNoDropWeapons(Event *ev); // Added in 2.0
315 void GetLoopProtection(Event *ev);
316 void SetLoopProtection(Event *ev);
317 void GetPapersLevel(Event *ev);
318 void SetPapersLevel(Event *ev);
319 void EventGetRoundStarted(Event *ev);
320 void EventGetDMRespawning(Event *ev);
321 void EventSetDMRespawning(Event *ev);
322 void EventGetDMRoundLimit(Event *ev);
323 void EventSetDMRoundLimit(Event *ev);
324 void EventGetClockSide(Event *ev);
325 void EventSetClockSide(Event *ev);
326 void EventGetBombPlantTeam(Event *ev);
327 void EventSetBombPlantTeam(Event *ev);
328 void EventGetTargetsToDestroy(Event *ev);
329 void EventSetTargetsToDestroy(Event *ev);
330 void EventGetTargetsDestroyed(Event *ev);
331 void EventSetTargetsDestroyed(Event *ev);
332 void EventGetBombsPlanted(Event *ev);
333 void EventSetBombsPlanted(Event *ev);
334 void EventGetRoundBased(Event *ev);
335 void EventGetObjectiveBased(Event *ev);
336 void EventRainDensitySet(Event *ev);
337 void EventRainDensityGet(Event *ev);
338 void EventRainSpeedSet(Event *ev);
339 void EventRainSpeedGet(Event *ev);
340 void EventRainSpeedVarySet(Event *ev);
341 void EventRainSpeedVaryGet(Event *ev);
342 void EventRainSlantSet(Event *ev);
343 void EventRainSlantGet(Event *ev);
344 void EventRainLengthSet(Event *ev);
345 void EventRainLengthGet(Event *ev);
346 void EventRainMin_DistSet(Event *ev);
347 void EventRainMin_DistGet(Event *ev);
348 void EventRainWidthSet(Event *ev);
349 void EventRainWidthGet(Event *ev);
350 void EventRainShaderSet(Event *ev);
351 void EventRainShaderGet(Event *ev);
352 void EventRainNumShadersSet(Event *ev);
353 void EventRainNumShadersGet(Event *ev);
354 //====
355 // Added in 2.0
356 void EventAddBadPlace(Event *ev);
357 void EventRemoveBadPlace(Event *ev);
358 void EventIgnoreClock(Event *ev);
359 void UpdateBadPlaces();
360 int GetNearestBadPlace(const Vector& org, float radius, int team) const;
361 //====
362 str GetRandomHeadModel(const char *model);
363 str GetRandomHeadSkin(const char *model);
364
365 bool RoundStarted();
366 bool PreSpawned(void);
367 bool Spawned(void);
368
369 void AddEarthquake(earthquake_t *);
370 void DoEarthquakes(void);
371
372 void OpenActorStats();
373 void WriteActorStats(Actor *actor);
374
375 //====
376 // Added in OPM
377 void SetForceTeamObjectiveLocation(Event *ev);
378 void GetForceTeamObjectiveLocation(Event *ev);
379 //====
380
381 void Archive(Archiver& arc) override;
382};
383
384// Called when a restart/change was issued
385void G_BeginIntermission2(void);
386
387// Change the current map to the specified map with the possibility to fade the screen with fadetime.
388void G_BeginIntermission(const char *map_name, INTTYPE_e transtype, bool no_fade = false);
389
390//Exit the intermission screen.
391void G_ExitIntermission(void);
392
393// Exits the level
394void G_ExitLevel(void);
395
396extern Level level;
Definition actor.h:585
Definition archive.h:86
Definition camera.h:182
Definition container.h:85
Definition entity.h:203
Definition listener.h:246
Definition level.h:90
Definition safeptr.h:160
Definition sentient.h:95
Definition simpleentity.h:119
Definition vector.h:61
Definition str.h:77
Definition level.h:56
Definition level.h:78
Definition q_shared.h:1452