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