44#define FFL_SPAWNTEMP 1
47#define G_ValidDescription(ent) ((ent)->description && ((ent)->description[0] == '_' || strstr((ent)->description, "*msgid:") != nullptr))
53typedef struct spawn_temp_s {
79typedef struct spawn_s {
143 const size_t l = strlen(
string) + 1;
147 for (
int i = 0;
i < l;
i++) {
149 if (
string[
i] ==
'\\' &&
i < l - 1) {
151 if (
string[
i] ==
'n')
156 *new_p++ =
string[
i];
169 if (kvp.
isKey(
"classname"))
171 else if (kvp.
isKey(
"model"))
173 else if (kvp.
isKey(
"spawnflags"))
175 else if (kvp.
isKey(
"speed"))
177 else if (kvp.
isKey(
"dir"))
179 else if (kvp.
isKey(
"active"))
181 else if (kvp.
isKey(
"target"))
183 else if (kvp.
isKey(
"targetname"))
185 else if (kvp.
isKey(
"item"))
187 else if (kvp.
isKey(
"noise"))
189 else if (kvp.
isKey(
"particle"))
191 else if (kvp.
isKey(
"nextmap"))
193 else if (kvp.
isKey(
"frame"))
195 else if (kvp.
isKey(
"team"))
197 else if (kvp.
isKey(
"group"))
199 else if (kvp.
isKey(
"size"))
201 else if (kvp.
isKey(
"count"))
203 else if (kvp.
isKey(
"time"))
205 else if (kvp.
isKey(
"health"))
207 else if (kvp.
isKey(
"radius"))
209 else if (kvp.
isKey(
"sounds"))
211 else if (kvp.
isKey(
"material"))
213 else if (kvp.
isKey(
"light"))
217 else if (kvp.
isKey(
"maxteams"))
219 else if (kvp.
isKey(
"maxlevel"))
221 else if (kvp.
isKey(
"dmg"))
223 else if (kvp.
isKey(
"origin"))
225 else if (kvp.
isKey(
"angles"))
227 else if (kvp.
isKey(
"angle"))
229 else if (kvp.
isKey(
"message"))
231 else if (kvp.
isKey(
"desc"))
234 else if (kvp.
isKey(
"norandomspawn"))
236 else if (kvp.
isKey(
"noequipment"))
259 gi.Error(
"ED_ParseEntity: EOF without closing brace");
266 gi.Error(
"ED_ParseEntity: EOF without closing brace");
269 gi.Error(
"ED_ParseEntity: closing brace without data");
275 if (keyname[0] ==
'_')
305 Edict* groupMember = ent;
309 if (!groupMember->
group)
349 level.actualRound = 1;
360 gi.Error(
"ED_LoadFromFile: found %s when expecting {", token);
382 gi.DPrintf(
"Could not create civilian\n");
387 gi.DPrintf(
"Could not create alien\n");
390 Com_Printf(
"Used inventory slots after ai spawn: %i\n",
game.invi.GetUsedSlots());
408 gi.Error(
"G_Spawn: no free edicts");
423 const int endRound = self->
time + self->
count;
426 if (endRound <
level.actualRound || (endRound ==
level.actualRound && spawnIndex <= currentIndex)) {
442 if (ent ==
nullptr) {
444 if (std::abs(pos[2] - z) > 1)
487 for (
vec_t x = vec[0] - radius; x <= vec[0] + radius; x +=
UNIT_SIZE) {
488 for (
vec_t y = vec[1] - radius; y <= vec[1] + radius; y +=
UNIT_SIZE) {
495 if (!
gi.isOnMap(end))
584 while (ent->
pos[2] > 0 && !
gi.isOnMap(vec)) {
590 gi.DPrintf(
"G_ActorSpawn: Warning: z level is out of bounds: %i\n", ent->
pos[2]);
629 gi.DPrintf(
"G_Actor2x2Spawn: Warning: z level is out of bounds: %i\n", ent->
pos[2]);
789 gi.DPrintf(
"misc_mission given with no objective\n");
812 ent->
group =
nullptr;
835 const int xDelta = std::max(1, maxs[0] - mins[0]);
836 const int yDelta = std::max(1, maxs[1] - mins[1]);
838 int size = xDelta * yDelta;
842 for (
int i = 0;
i < xDelta;
i++) {
843 for (
int j = 0; j < yDelta; j++) {
844 const pos_t x = mins[0] +
i;
845 const pos_t y = mins[1] + j;
852#define MISC_MODEL_SOLID (1 << 8)
861 if (
gi.LoadModelAABB(ent->
model, ent->
frame, modelAabb)) {
871 gi.DPrintf(
"Could not get mins/maxs for model '%s'\n", ent->
model);
875 gi.DPrintf(
"server_solid misc_model with no model given\n");
890 gi.DPrintf(
"No item defined in misc_item\n");
903 if (!activator || !
G_IsActor(activator)) {
908 const char* msg = self->
message;
974 gi.DPrintf(
"No translation marker for misc_message set\n");
981#define CAMERA_ROTATE (1 << 8)
entity_t entities[MAX_MAP_ENTITIES]
static void SP_light(const localEntityParse_t *entData)
static const spawn_t spawns[]
static void SP_worldspawn(const localEntityParse_t *entData)
static void SP_misc_model(const localEntityParse_t *entData)
void setMaxs(const vec3_t maxi)
void getCenter(vec3_t center) const
Calculates the center of the bounding box.
void set(const AABB &other)
Copies the values from the given aabb.
void setMins(const vec3_t mini)
actorSizeEnum_t fieldSize
void(* think)(Edict *self)
pos3_t * forbiddenListPos
bool(* use)(Edict *self, Edict *activator)
void setTouch(bool(*touch_)(Edict *self, Edict *activator))
void calcOrigin()
Calculate the edict's origin vector from it's grid position.
Player & getPlayer() const
void(* reset)(Edict *self, Edict *activator)
A pair of strings representing a key and a value The value string can be trimmed and rendered in the ...
void asVec3(vec3_t vec) const
bool isKey(const char *name) const
void Com_Printf(const char *const fmt,...)
#define ACTOR_SIZE_NORMAL
#define MASK_SMOKE_AND_FIRE
#define PATHFINDING_HEIGHT
15 max, adjusting above 8 will require a rewrite to the DV code
void G_AddToWayPointList(Edict *ent)
Player * AI_CreatePlayer(int team)
Spawn civilians and aliens.
Artificial Intelligence functions.
void G_InitCamera(Edict *ent, camera_type_t cameraType, float angle, bool rotate)
void G_ResetClientData(void)
Called after every player has joined.
void G_ClientPrintf(const Player &player, int printLevel, const char *fmt,...)
playermask_t G_VisToPM(teammask_t teamMask)
Converts vis mask to player mask.
Interface for g_client.cpp.
Edict * G_EdictsGetFirst(void)
Returns the first entity.
Edict * G_EdictsGetNewEdict(void)
Find an entity that is not in use.
int G_EdictsGetNumber(const Edict *ent)
Get an entity's ID number.
Edict * G_EdictsGetNextInUse(Edict *lastEnt)
Iterate through the entities that are in use.
void G_EdictsInit(void)
Reset the entity pointers for eg. a new game.
functions to handle the storage and lifecycle of all edicts in the game module.
void G_EventEdictPerish(playermask_t playerMask, const Edict &ent)
Send disappear event.
void SP_func_breakable(Edict *ent)
func_breakable (0.3 0.3 0.3) ? Used for breakable objects.
void SP_func_door(Edict *ent)
func_door (0 .5 .8) ? "health" if set, door is destroyable
void SP_func_door_sliding(Edict *ent)
void SP_func_rotating(Edict *ent)
Spawns a rotating solid inline brush model.
bool G_AddItemToFloor(const pos3_t pos, const char *itemID)
Adds a new item to an existing or new floor container edict at the given grid location.
#define FL_GROUPSLAVE
not the first on the team
#define G_TagMalloc(size, tag)
#define G_IsMultiPlayer()
#define G_IsSinglePlayer()
cvar_t * sv_maxsoldiersperplayer
cvar_t * ai_multiplayeraliens
edictMaterial_t
e.g. used for breakable objects
cvar_t * sv_maxsoldiersperteam
bool G_MissionTouch(Edict *self, Edict *activator)
Mission trigger.
bool G_MissionUse(Edict *self, Edict *activator)
Mission trigger use function.
void G_MissionThink(Edict *self)
void G_MissionReset(Edict *self, Edict *activator)
void G_MissionAddVictoryMessage(const char *message)
Mission related code - king of the hill and so on.
void G_ReactionFireTargetsInit(void)
free function to initialize the reaction fire table for all entities.
static void SP_light(Edict *ent)
light (0 1 0) (-8 -8 -8) (8 8 8)
static void SP_2x2_start(Edict *ent)
info_2x2_start (1 1 0) (-32 -32 -24) (32 32 32) Starting point for a 2x2 unit.
static void G_Actor2x2Spawn(Edict *ent)
Spawn a singleplayer 2x2 unit.
Edict * G_Spawn(const char *classname)
Either finds a free edict, or allocates a new one.
static void SP_civilian_target(Edict *ent)
info_civilian_start (0 1 1) (-16 -16 -24) (16 16 32) Way point for a civilian.
void G_SpawnSmokeField(const vec3_t vec, const char *particle, int rounds, int damage, vec_t radius)
Spawns a smoke field that is available for some rounds.
static void SP_worldspawn(Edict *ent)
Spawns the world entity.
void G_SpawnFireField(const vec3_t vec, const char *particle, int rounds, int damage, vec_t radius)
static bool Message_Use(Edict *self, Edict *activator)
static void SP_human_start(Edict *ent)
info_human_start (1 0 0) (-16 -16 -24) (16 16 32) Starting point for a single player human.
#define G_ValidDescription(ent)
static void SP_misc_item(Edict *ent)
Spawns an item to the ground container.
static void ED_CallSpawn(Edict *ent)
Finds the spawn function for the entity and calls it.
static void G_BuildForbiddenListForEntity(Edict *ent)
Create a list of the grid positions the edict occupies and store it with the edict.
static void SP_misc_model(Edict *ent)
Spawns a misc_model if there is a solid state.
static void SP_dummy(Edict *ent)
a dummy to get rid of local entities
static void SP_misc_message(Edict *ent)
static void SP_player_start(Edict *ent)
info_player_start (1 0 0) (-16 -16 -24) (16 16 32) Starting point for a player. "team" the number of ...
static void SP_misc_mission(Edict *ent)
Initializes the human/phalanx mission entity.
Edict * G_SpawnFloor(const pos3_t pos)
Spawns a new entity at the floor.
static spawn_temp_t spawnTemp
static void G_SpawnField(Edict *ent, const char *classname, entity_type_t type, solid_t solid)
static void G_ActorSpawn(Edict *ent)
Spawn point for a 1x1 unit.
static void ED_ParseField(const char *key, const char *value, Edict *ent)
Takes a key/value pair and sets the binary values in an edict.
void G_SpawnStunSmokeField(const vec3_t vec, const char *particle, int rounds, int damage, vec_t radius)
static void G_FindEdictGroups(void)
Chain together all entities with a matching team field. All but the first will have the FL_GROUPSLAVE...
Edict * G_SpawnParticle(const vec3_t origin, int spawnflags, const char *particle)
static const char * ED_ParseEdict(const char *data, Edict *ent)
Parses an edict out of the given string, returning the new position.
static void SP_civilian_start(Edict *ent)
info_civilian_start (0 1 1) (-16 -16 -24) (16 16 32) Starting point for a civilian.
static void SP_alien_start(Edict *ent)
info_alien_start (1 0 0) (-16 -16 -24) (16 16 32) Starting point for a single player alien.
static void Think_SmokeAndFire(Edict *self)
static void SP_misc_fire(Edict *ent)
static void G_SpawnFieldGroup(const entity_type_t fieldtype, const vec3_t vec, const char *particle, int rounds, int damage, vec_t radius)
Spawns a field that is available for some rounds.
static void G_SpawnFieldPart(const entity_type_t fieldtype, const vec3_t vec, const char *particle, int rounds, int damage)
static void SP_misc_smokestun(Edict *ent)
static void SP_misc_smoke(Edict *ent)
void G_SpawnEntities(const char *mapname, bool day, const char *entities)
Creates a server's entity / program execution context by parsing textual entity definitions out of an...
static void SP_misc_camera(Edict *ent)
static char * ED_NewString(const char *string)
Allocated memory for the given string in the level context (TAG_LEVEL).
Brings new objects into the world.
#define G_ValidMessage(ent)
void SP_trigger_touch(Edict *ent)
Touch trigger to call the use function of the attached target.
void SP_trigger_nextmap(Edict *ent)
void SP_trigger_hurt(Edict *ent)
Trigger for grid fields if they are under fire.
bool Touch_HurtTrigger(Edict *self, Edict *activator)
Hurt trigger.
void SP_trigger_rescue(Edict *ent)
Rescue trigger to mark an actor to be in the rescue zone. Aborting a game would not kill the actors i...
Edict * G_GetEdictFromPos(const pos3_t pos, const entity_type_t type)
Searches an edict of the given type at the given grid location.
trace_t G_Trace(const Line &trLine, const Edict *passent, int contentmask)
collision detection - this version is more accurate and includes entity tests
uint32_t G_GetLevelFlagsFromPos(const pos3_t pos)
Calculates the level flags for a given grid position.
void G_FreeEdict(Edict *ent)
Marks the edict as free.
Misc utility functions for game module.
void G_CheckVis(Edict *check, const vischeckflags_t visFlags)
Check if the edict appears/perishes for the other teams. If they appear for other teams,...
solid_t
edict->solid values
int AngleToDir(int angle)
Returns the index of array directionAngles[DIRECTIONS] whose value is the closest to angle.
#define PosToVec(p, v)
Pos boundary size is +/- 128 - to get into the positive area we add the possible max negative value a...
#define VecToPos(v, p)
Map boundary is +/- MAX_WORLD_WIDTH - to get into the positive area we add the possible max negative ...
const char * Com_Parse(const char *data_p[], char *target, size_t size, bool replaceWhitespaces)
Parse a token out of a string.
Shared parsing functions.
#define CS_MAXSOLDIERSPERPLAYER
#define CS_MAXSOLDIERSPERTEAM
QGL_EXTERN void(APIENTRY *qglActiveTexture)(GLenum texture)
QGL_EXTERN GLsizei const GLvoid * data
QGL_EXTERN GLint GLenum type
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
this is only used to hold entity field values that can be set from the editor, but aren't actually pr...
#define VectorCopy(src, dest)
#define VectorSet(v, x, y, z)