openmohaa/code/fgame/level.h

384 lines
10 KiB
C
Raw Normal View History

2016-03-27 11:49:47 +02:00
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// level.h: General Level Info
2023-01-29 20:59:31 +01:00
#pragma once
2016-03-27 11:49:47 +02:00
#include "listener.h"
2023-01-29 20:59:31 +01:00
#include "g_public.h"
#include "bg_voteoptions.h"
2016-03-27 11:49:47 +02:00
2023-08-10 03:10:51 +02:00
#define MAX_HEAD_SENTIENTS 2
#define MAX_EARTHQUAKES 10
enum INTTYPE_e {
TRANS_BSP,
TRANS_LEVEL,
TRANS_MISSION,
TRANS_MISSION_FAILED
};
enum fadetype_t {
fadein,
fadeout
};
enum fadestyle_t {
alphablend,
additive
};
2016-03-27 11:49:47 +02:00
2023-08-10 03:10:51 +02:00
enum letterboxdir_t {
letterbox_in,
letterbox_out
};
2016-03-27 11:49:47 +02:00
typedef struct earthquake_s {
2023-08-10 03:10:51 +02:00
int duration;
float magnitude;
bool no_rampup;
bool no_rampdown;
int starttime;
int endtime;
SafePtr<ScriptThread> m_Thread;
2016-03-27 11:49:47 +02:00
} earthquake_t;
struct badplace_t {
const_str m_name;
int m_iTeamSide;
Vector m_vOrigin;
float m_fRadius;
float m_fNotBadPlaceTime;
};
typedef struct {
str m_sName;
Vector m_vOrigin;
} landmark_t;
2016-03-27 11:49:47 +02:00
extern gclient_t *spawn_client;
class Camera;
class SimpleArchivedEntity;
class Level : public Listener
{
public:
2023-08-10 03:10:51 +02:00
char *current_map;
int mHealthPopCount;
// Map name stuff
str m_mapscript;
str m_precachescript;
str m_pathfile;
str m_mapfile;
// Spawning variables
int spawn_entnum;
int spawnflags;
// Level time
int framenum;
int inttime;
int intframetime;
float time;
float frametime;
// Server time
int svsTime;
float svsFloatTime;
int svsStartTime;
int svsEndTime;
float svsStartFloatTime; // Added in 2.0
2023-08-10 03:10:51 +02:00
// Level name variables
str level_name;
str mapname;
str spawnpoint;
str nextmap;
// AI variables
int m_iCuriousVoiceTime;
int m_iAttackEntryAnimTime;
// Global players variables
qboolean playerfrozen;
// Intermission variables
float intermissiontime;
INTTYPE_e intermissiontype;
int exitintermission;
2016-03-27 11:49:47 +02:00
2023-08-10 03:10:51 +02:00
// Secrets
int total_secrets;
int found_secrets;
2016-03-27 11:49:47 +02:00
2023-08-10 03:10:51 +02:00
// Trace
trace_t impact_trace;
2016-03-27 11:49:47 +02:00
2023-08-10 03:10:51 +02:00
// Earthquake stuff
float earthquake_magnitude;
2016-03-27 11:49:47 +02:00
2023-08-10 03:10:51 +02:00
// Cinematic
qboolean cinematic;
2016-03-27 11:49:47 +02:00
2023-08-10 03:10:51 +02:00
// AI variables
qboolean ai_on;
qboolean m_bAlarm;
qboolean mbNoDropHealth;
qboolean mbNoDropWeapons; // Added in 2.0
2023-08-10 03:10:51 +02:00
int m_iPapersLevel;
2016-03-27 11:49:47 +02:00
2023-08-10 03:10:51 +02:00
// Mission state
qboolean mission_failed;
qboolean died_already;
qboolean near_exit;
2016-03-27 11:49:47 +02:00
2023-08-10 03:10:51 +02:00
// Water variables
Vector water_color;
Vector lava_color;
float water_alpha;
float lava_alpha;
2016-03-27 11:49:47 +02:00
2023-08-10 03:10:51 +02:00
// Soundtrack variables
str current_soundtrack;
str saved_soundtrack;
2016-03-27 11:49:47 +02:00
2023-08-10 03:10:51 +02:00
// Screen state
Vector m_fade_color;
float m_fade_alpha;
float m_fade_time;
float m_fade_time_start;
fadetype_t m_fade_type;
fadestyle_t m_fade_style;
2016-03-27 11:49:47 +02:00
2023-08-10 03:10:51 +02:00
// Letterbox state
float m_letterbox_fraction;
float m_letterbox_time;
float m_letterbox_time_start;
letterboxdir_t m_letterbox_dir;
2016-03-27 11:49:47 +02:00
// Added in 2.0
// Bad places
Container<badplace_t> m_badPlaces;
2023-08-10 03:10:51 +02:00
Container<Camera *> automatic_cameras;
2016-03-27 11:49:47 +02:00
2023-08-10 03:10:51 +02:00
// Quake remnants ?
int m_numArenas;
2016-03-27 11:49:47 +02:00
2023-08-10 03:10:51 +02:00
// Voting variables
float m_voteTime;
int m_voteYes;
int m_voteNo;
int m_numVoters;
str m_voteString;
// Added in 2.0
str m_voteCommand;
str m_voteName;
2023-08-10 03:10:51 +02:00
// Intermission locations
Vector m_intermission_origin;
Vector m_intermission_angle;
2016-03-27 11:49:47 +02:00
2023-08-10 03:10:51 +02:00
// Skeleton variables
int frame_skel_index;
int skel_index[MAX_GENTITIES];
2016-03-27 11:49:47 +02:00
2023-08-10 03:10:51 +02:00
// script variables
qboolean m_LoopProtection;
qboolean m_LoopDrop; // kill the server in loop exception
2016-03-27 11:49:47 +02:00
2023-08-10 03:10:51 +02:00
Container<SimpleArchivedEntity *> m_SimpleArchivedEntities;
class Sentient *m_HeadSentient[MAX_HEAD_SENTIENTS];
2016-03-27 11:49:47 +02:00
2023-08-10 03:10:51 +02:00
// Earthquake stuff
earthquake_t earthquakes[MAX_EARTHQUAKES];
int num_earthquakes;
2016-03-27 11:49:47 +02:00
2023-08-10 03:10:51 +02:00
// Objective stuff
Vector m_vObjectiveLocation;
Vector m_vAlliedObjectiveLocation; // Added in 2.0
Vector m_vAxisObjectiveLocation; // Added in 2.0
2016-03-27 11:49:47 +02:00
2023-08-10 03:10:51 +02:00
// Current level state
bool spawning;
bool m_bIgnoreClock;
//====
// Added in 2.30
// Landmarks
float m_fLandmarkYDistMax;
float m_fLandmarkYDistMin;
float m_fLandmarkXDistMax;
float m_fLandmarkXDistMin;
landmark_t** m_pLandmarks;
int m_iMaxLandmarks;
int m_iLandmarksCount;
//====
void* m_pAIStats;
2016-03-27 11:49:47 +02:00
2023-08-10 03:10:51 +02:00
// New Stuff
2016-03-27 11:49:47 +02:00
2023-08-10 03:10:51 +02:00
// don't put in the game class because it can be changed in another level
2023-08-10 11:55:20 +02:00
qboolean specialgame;
2016-03-27 11:49:47 +02:00
2023-08-10 03:10:51 +02:00
bool m_bSpawnBot;
2016-03-27 11:49:47 +02:00
2023-08-10 03:10:51 +02:00
// Script stuff
bool m_bScriptSpawn;
bool m_bRejectSpawn;
2016-03-27 11:49:47 +02:00
public:
2023-08-10 03:10:51 +02:00
CLASS_PROTOTYPE(Level);
Level();
virtual ~Level();
void Init();
void CleanUp(qboolean samemap = qfalse, qboolean resetConfigStrings = qfalse);
void ResetEdicts();
gentity_t *AllocEdict(Entity *ent);
void FreeEdict(gentity_t *ent);
void InitEdict(gentity_t *ent);
void LoadAllScripts(const char *name, const char *extension);
void Precache();
void SetMap(const char *themapname);
void FindTeams();
2023-08-10 03:10:51 +02:00
void SpawnEntities(char *entities, int _svsTime_);
//====
// Added in 2.30
void ComputeDMWaypoints();
void AddLandmarkOrigin(const Vector& origin);
void AddLandmarkName(const str& name, const Vector& origin);
void FreeLandmarks();
str GetDynamicDMLocations(const Vector& origin);
str GetDMLocation(const Vector& origin);
//====
2023-08-10 03:10:51 +02:00
void PreSpawnSentient(Event *ev);
void ServerSpawned();
qboolean inhibitEntity(int spawnflags);
2023-08-10 03:10:51 +02:00
void setSkill(int value);
void setTime(int _svsTime_);
void setFrametime(int frameTime);
2023-08-10 03:10:51 +02:00
void AddAutomaticCamera(Camera *cam);
2023-08-10 03:10:51 +02:00
void GetTime(Event *ev);
void GetTotalSecrets(Event *ev);
void GetFoundSecrets(Event *ev);
//====
// Added in 2.0
void InitVoteOptions();
void SendVoteOptionsFile(gentity_t* ent);
bool GetVoteOptionMain(int index, str* outOptionCommand, voteoptiontype_t* outOptionType);
bool GetVoteOptionSub(int index, int listIndex, str* outCommand);
bool GetVoteOptionMainName(int index, str* outVoteName);
bool GetVoteOptionSubName(int index, int listIndex, str* outName);
//====
2023-08-10 03:10:51 +02:00
void CheckVote();
void SetupMaplist(); // Added in 2.0
2023-08-10 03:10:51 +02:00
void GetAlarm(Event *ev);
void SetAlarm(Event *ev);
void SetNoDropHealth(Event *ev);
void SetNoDropWeapons(Event *ev); // Added in 2.0
2023-08-10 03:10:51 +02:00
void GetLoopProtection(Event *ev);
void SetLoopProtection(Event *ev);
void GetPapersLevel(Event *ev);
void SetPapersLevel(Event *ev);
void EventGetRoundStarted(Event *ev);
2023-08-10 03:10:51 +02:00
void EventGetDMRespawning(Event *ev);
void EventSetDMRespawning(Event *ev);
void EventGetDMRoundLimit(Event *ev);
void EventSetDMRoundLimit(Event *ev);
void EventGetClockSide(Event *ev);
void EventSetClockSide(Event *ev);
void EventGetBombPlantTeam(Event *ev);
void EventSetBombPlantTeam(Event *ev);
void EventGetTargetsToDestroy(Event *ev);
void EventSetTargetsToDestroy(Event *ev);
void EventGetTargetsDestroyed(Event *ev);
void EventSetTargetsDestroyed(Event *ev);
void EventGetBombsPlanted(Event *ev);
void EventSetBombsPlanted(Event *ev);
void EventGetRoundBased(Event *ev);
void EventGetObjectiveBased(Event *ev);
2023-08-10 03:10:51 +02:00
void EventRainDensitySet(Event *ev);
void EventRainDensityGet(Event *ev);
void EventRainSpeedSet(Event *ev);
void EventRainSpeedGet(Event *ev);
void EventRainSpeedVarySet(Event *ev);
void EventRainSpeedVaryGet(Event *ev);
void EventRainSlantSet(Event *ev);
void EventRainSlantGet(Event *ev);
void EventRainLengthSet(Event *ev);
void EventRainLengthGet(Event *ev);
void EventRainMin_DistSet(Event *ev);
void EventRainMin_DistGet(Event *ev);
void EventRainWidthSet(Event *ev);
void EventRainWidthGet(Event *ev);
void EventRainShaderSet(Event *ev);
void EventRainShaderGet(Event *ev);
void EventRainNumShadersSet(Event *ev);
void EventRainNumShadersGet(Event *ev);
//====
// Added in 2.0
void EventAddBadPlace(Event *ev);
void EventRemoveBadPlace(Event *ev);
void EventIgnoreClock(Event *ev);
void UpdateBadPlaces();
badplace_t *GetNearestBadPlace(const Vector& org, float radius) const;
//====
2023-08-10 03:10:51 +02:00
str GetRandomHeadModel(const char *model);
str GetRandomHeadSkin(const char *model);
bool RoundStarted();
bool PreSpawned(void);
bool Spawned(void);
void AddEarthquake(earthquake_t *);
void DoEarthquakes(void);
void Archive(Archiver& arc) override;
2016-03-27 11:49:47 +02:00
};
// Called when a restart/change was issued
void G_BeginIntermission2(void);
// Change the current map to the specified map with the possibility to fade the screen with fadetime.
void G_BeginIntermission(const char* map_name, INTTYPE_e transtype, bool no_fade = false);
//Exit the intermission screen.
void G_ExitIntermission(void);
// Exits the level
void G_ExitLevel(void);
2016-03-27 11:49:47 +02:00
extern Level level;