OpenMoHAA 0.83.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 "../corepp/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
239 // Added in 2.0
240 bool m_bIgnoreClock;
241 //====
242 // Added in 2.30
243 // Landmarks
244 float m_fLandmarkYDistMax;
245 float m_fLandmarkYDistMin;
246 float m_fLandmarkXDistMin;
247 float m_fLandmarkXDistMax;
248 landmark_t **m_pLandmarks;
249 int m_iMaxLandmarks;
250 int m_iLandmarksCount;
251 //====
252 void *m_pAIStats;
253
254 // New Stuff
255
256 // Script stuff
257 bool m_bScriptSpawn;
258 bool m_bRejectSpawn;
259
260public:
261 CLASS_PROTOTYPE(Level);
262
263 Level();
264 virtual ~Level();
265
266 void Init();
267 void CleanUp(qboolean samemap = qfalse, qboolean resetConfigStrings = qfalse);
268 void ResetEdicts();
269 gentity_t *AllocEdict(Entity *ent);
270 void FreeEdict(gentity_t *ent);
271 void InitEdict(gentity_t *ent);
272 void LoadAllScripts(const char *name, const char *extension);
273 void Precache();
274 void SetMap(const char *themapname);
275 void FindTeams();
276
277 void SpawnEntities(char *entities, int _svsTime_);
278 //====
279 // Added in 2.30
280 void ComputeDMWaypoints();
281 void AddLandmarkOrigin(const Vector& origin);
282 void AddLandmarkName(const str& name, const Vector& origin);
283 void FreeLandmarks();
284 str GetDynamicDMLocations(const Vector& origin);
285 str GetDMLocation(const Vector& origin);
286 //====
287 void PreSpawnSentient(Event *ev);
288 void ServerSpawned();
289 qboolean inhibitEntity(int spawnflags);
290
291 void setSkill(int value);
292 void setTime(int _svsTime_);
293 void setFrametime(int frameTime);
294
295 void AddAutomaticCamera(Camera *cam);
296
297 void GetTime(Event *ev);
298 void GetTotalSecrets(Event *ev);
299 void GetFoundSecrets(Event *ev);
300
301 //====
302 // Added in 2.0
303 void InitVoteOptions();
304 void SendVoteOptionsFile(gentity_t *ent);
305 bool GetVoteOptionMain(int index, str *outOptionCommand, voteoptiontype_t *outOptionType);
306 bool GetVoteOptionSub(int index, int listIndex, str *outCommand);
307 bool GetVoteOptionMainName(int index, str *outVoteName);
308 bool GetVoteOptionSubName(int index, int listIndex, str *outName);
309 //====
310 void CheckVote();
311 void SetupMaplist(); // Added in 2.0
312
313 void GetAlarm(Event *ev);
314 void SetAlarm(Event *ev);
315 void SetNoDropHealth(Event *ev);
316 void SetNoDropWeapons(Event *ev); // Added in 2.30
317 void GetLoopProtection(Event *ev);
318 void SetLoopProtection(Event *ev);
319 void GetPapersLevel(Event *ev);
320 void SetPapersLevel(Event *ev);
321 void EventGetRoundStarted(Event *ev);
322 void EventGetDMRespawning(Event *ev);
323 void EventSetDMRespawning(Event *ev);
324 void EventGetDMRoundLimit(Event *ev);
325 void EventSetDMRoundLimit(Event *ev);
326 void EventGetClockSide(Event *ev);
327 void EventSetClockSide(Event *ev);
328 void EventGetBombPlantTeam(Event *ev);
329 void EventSetBombPlantTeam(Event *ev);
330 void EventGetTargetsToDestroy(Event *ev);
331 void EventSetTargetsToDestroy(Event *ev);
332 void EventGetTargetsDestroyed(Event *ev);
333 void EventSetTargetsDestroyed(Event *ev);
334 void EventGetBombsPlanted(Event *ev);
335 void EventSetBombsPlanted(Event *ev);
336 void EventGetRoundBased(Event *ev);
337 void EventGetObjectiveBased(Event *ev);
338 void EventRainDensitySet(Event *ev);
339 void EventRainDensityGet(Event *ev);
340 void EventRainSpeedSet(Event *ev);
341 void EventRainSpeedGet(Event *ev);
342 void EventRainSpeedVarySet(Event *ev);
343 void EventRainSpeedVaryGet(Event *ev);
344 void EventRainSlantSet(Event *ev);
345 void EventRainSlantGet(Event *ev);
346 void EventRainLengthSet(Event *ev);
347 void EventRainLengthGet(Event *ev);
348 void EventRainMin_DistSet(Event *ev);
349 void EventRainMin_DistGet(Event *ev);
350 void EventRainWidthSet(Event *ev);
351 void EventRainWidthGet(Event *ev);
352 void EventRainShaderSet(Event *ev);
353 void EventRainShaderGet(Event *ev);
354 void EventRainNumShadersSet(Event *ev);
355 void EventRainNumShadersGet(Event *ev);
356 //====
357 // Added in 2.0
358 void EventAddBadPlace(Event *ev);
359 void EventRemoveBadPlace(Event *ev);
360 void EventIgnoreClock(Event *ev);
361 void UpdateBadPlaces();
362 int GetNearestBadPlace(const Vector& org, float radius, int team) const;
363 //====
364 str GetRandomHeadModel(const char *model);
365 str GetRandomHeadSkin(const char *model);
366
367 bool RoundStarted();
368 bool PreSpawned(void);
369 bool Spawned(void);
370
371 void AddEarthquake(earthquake_t *);
372 void DoEarthquakes(void);
373
374 void OpenActorStats();
375 void WriteActorStats(Actor *actor);
376
377 //====
378 // Added in OPM
379 void SetForceTeamObjectiveLocation(Event *ev);
380 void GetForceTeamObjectiveLocation(Event *ev);
381 //====
382
383 void Archive(Archiver& arc) override;
384};
385
386// Called when a restart/change was issued
387void G_BeginIntermission2(void);
388
389// Change the current map to the specified map with the possibility to fade the screen with fadetime.
390void G_BeginIntermission(const char *map_name, INTTYPE_e transtype, bool no_fade = false);
391
392//Exit the intermission screen.
393void G_ExitIntermission(void);
394
395// Exits the level
396void G_ExitLevel(void);
397
398extern Level level;
Definition actor.h:585
Definition archive.h:86
Definition camera.h:181
Definition g_local.h:81
Definition entity.h:203
Definition level.h:90
Definition sentient.h:95
Definition simpleentity.h:119
Definition level.h:56
Definition level.h:78
Definition q_shared.h:1450