40 #include "../shared/parse.h" 41 #include "../shared/keyvaluepair.h" 44 #define FFL_SPAWNTEMP 1 47 #define G_ValidDescription(ent) ((ent)->description && ((ent)->description[0] == '_' || strstr((ent)->description, "*msgid:") != nullptr)) 53 typedef struct spawn_temp_s {
79 typedef 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)
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");
408 gi.Error(
"G_Spawn: no free edicts");
423 const int endRound =
self->time +
self->count;
427 const bool checkVis =
self->type ==
ET_SMOKE;
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;
915 if (self->spawnflags & 1)
974 gi.DPrintf(
"No translation marker for misc_message set\n");
981 #define CAMERA_ROTATE (1 << 8)
void G_MissionAddVictoryMessage(const char *message)
Edict * G_EdictsGetFirst(void)
Returns the first entity.
Edict * G_SpawnFloor(const pos3_t pos)
Spawns a new entity at the floor.
void G_ClientPrintf(const Player &player, int printLevel, const char *fmt,...)
static const spawn_t spawns[]
static void SP_misc_item(Edict *ent)
Spawns an item to the ground container.
Edict * G_EdictsGetNextInUse(Edict *lastEnt)
Iterate through the entities that are in use.
static void SP_light(Edict *ent)
light (0 1 0) (-8 -8 -8) (8 8 8)
#define VectorCopy(src, dest)
void SP_func_rotating(Edict *ent)
Spawns a rotating solid inline brush model.
void G_AddToWayPointList(Edict *ent)
trace_t G_Trace(const Line &trLine, const Edict *passent, int contentmask)
collision detection - this version is more accurate and includes entity tests
#define VectorSet(v, x, y, z)
cvar_t * sv_maxsoldiersperplayer
A pair of strings representing a key and a value The value string can be trimmed and rendered in the ...
static void SP_misc_model(Edict *ent)
Spawns a misc_model if there is a solid state.
QGL_EXTERN GLint GLenum type
static void G_FindEdictGroups(void)
Chain together all entities with a matching team field. All but the first will have the FL_GROUPSLAVE...
int GetUsedSlots()
Calculate the number of used inventory slots.
static void G_SpawnField(Edict *ent, const char *classname, entity_type_t type, solid_t solid)
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...
Edict * G_GetEdictFromPos(const pos3_t pos, const entity_type_t type)
Searches an edict of the given type at the given grid location.
static void G_ActorSpawn(Edict *ent)
Spawn point for a 1x1 unit.
Artificial Intelligence functions.
bool isKey(const char *name) const
void SP_func_breakable(Edict *ent)
func_breakable (0.3 0.3 0.3) ? Used for breakable objects.
Misc utility functions for game module.
static void ED_CallSpawn(Edict *ent)
Finds the spawn function for the entity and calls it.
int G_EdictsGetNumber(const Edict *ent)
Get an entity's ID number.
static void SP_civilian_start(Edict *ent)
info_civilian_start (0 1 1) (-16 -16 -24) (16 16 32) Starting point for a civilian.
actorSizeEnum_t fieldSize
static void G_SpawnFieldPart(const entity_type_t fieldtype, const vec3_t vec, const char *particle, int rounds, int damage)
void SP_trigger_hurt(Edict *ent)
Trigger for grid fields if they are under fire.
Mission related code - king of the hill and so on.
void setMaxs(const vec3_t maxi)
static const char * ED_ParseEdict(const char *data, Edict *ent)
Parses an edict out of the given string, returning the new position.
bool G_MissionUse(Edict *self, Edict *activator)
Mission trigger use function.
void setTouch(bool(*touch_)(Edict *self, Edict *activator))
QGL_EXTERN GLsizei const GLvoid * data
solid_t
edict->solid values
this is only used to hold entity field values that can be set from the editor, but aren't actually pr...
static void SP_misc_fire(Edict *ent)
void Com_Printf(const char *const fmt,...)
void G_InitCamera(Edict *ent, camera_type_t cameraType, float angle, bool rotate)
static void SP_dummy(Edict *ent)
a dummy to get rid of local entities
#define CS_MAXSOLDIERSPERTEAM
entity_t entities[MAX_MAP_ENTITIES]
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.
void(* think)(Edict *self)
static void SP_misc_message(Edict *ent)
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.
Edict * G_EdictsGetNewEdict(void)
Find an entity that is not in use.
#define FL_GROUPSLAVE
not the first on the team
int AngleToDir(int angle)
Returns the index of array directionAngles[DIRECTIONS] whose value is the closest to angle...
static bool Message_Use(Edict *self, Edict *activator)
static void SP_misc_mission(Edict *ent)
Initializes the human/phalanx mission entity.
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
#define G_IsMultiPlayer()
void SP_trigger_touch(Edict *ent)
Touch trigger to call the use function of the attached target.
static spawn_temp_t spawnTemp
static char * ED_NewString(const char *string)
Allocated memory for the given string in the level context (TAG_LEVEL)
cvar_t * sv_maxsoldiersperteam
void set(const AABB &other)
Copies the values from the given aabb.
static void SP_misc_camera(Edict *ent)
void G_SpawnFireField(const vec3_t vec, const char *particle, int rounds, int damage, vec_t radius)
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.
cvar_t * ai_multiplayeraliens
void SP_trigger_nextmap(Edict *ent)
Edict * G_Spawn(const char *classname)
Either finds a free edict, or allocates a new one.
#define VecToPos(v, p)
Map boundary is +/- MAX_WORLD_WIDTH - to get into the positive area we add the possible max negative ...
void G_EventEdictPerish(playermask_t playerMask, const Edict &ent)
Send disappear event.
#define G_TagMalloc(size, tag)
#define PosToVec(p, v)
Pos boundary size is +/- 128 - to get into the positive area we add the possible max negative value a...
Player & getPlayer() const
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...
Edict * G_SpawnParticle(const vec3_t origin, int spawnflags, const char *particle)
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...
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...
playermask_t G_VisToPM(teammask_t teamMask)
Converts vis mask to player mask.
bool(* use)(Edict *self, Edict *activator)
void G_MissionReset(Edict *self, Edict *activator)
bool Touch_HurtTrigger(Edict *self, Edict *activator)
Hurt trigger.
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.
void G_ReactionFireTargetsInit(void)
free function to initialize the reaction fire table for all entities.
void getCenter(vec3_t center) const
Calculates the center of the bounding box.
QGL_EXTERN void(APIENTRY *qglActiveTexture)(GLenum texture)
void SP_func_door_sliding(Edict *ent)
void asVec3(vec3_t vec) const
#define G_ValidDescription(ent)
void G_ResetClientData(void)
Called after every player has joined.
#define PATHFINDING_HEIGHT
15 max, adjusting above 8 will require a rewrite to the DV code
pos3_t * forbiddenListPos
const char * Com_Parse(const char *data_p[], char *target, size_t size, bool replaceWhitespaces)
Parse a token out of a string.
#define G_IsSinglePlayer()
void G_MissionThink(Edict *self)
uint32_t G_GetLevelFlagsFromPos(const pos3_t pos)
Calculates the level flags for a given grid position.
static void SP_civilian_target(Edict *ent)
info_civilian_start (0 1 1) (-16 -16 -24) (16 16 32) Way point for a civilian.
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.
void setMins(const vec3_t mini)
void calcOrigin()
Calculate the edict's origin vector from it's grid position.
#define CS_MAXSOLDIERSPERPLAYER
void(* reset)(Edict *self, Edict *activator)
static void SP_misc_smokestun(Edict *ent)
Brings new objects into the world.
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 ...
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
static void G_Actor2x2Spawn(Edict *ent)
Spawn a singleplayer 2x2 unit.
functions to handle the storage and lifecycle of all edicts in the game module.
static void SP_worldspawn(Edict *ent)
Spawns the world entity.
void G_SpawnStunSmokeField(const vec3_t vec, const char *particle, int rounds, int damage, vec_t radius)
static void SP_misc_smoke(Edict *ent)
void SP_func_door(Edict *ent)
func_door (0 .5 .8) ? "health" if set, door is destroyable
void G_EdictsInit(void)
Reset the entity pointers for eg. a new game.
byte num_spawnpoints[MAX_TEAMS]
Player * AI_CreatePlayer(int team)
Spawn civilians and aliens.
byte num_2x2spawnpoints[MAX_TEAMS]
#define ACTOR_SIZE_NORMAL
#define G_ValidMessage(ent)
static void Think_SmokeAndFire(Edict *self)
#define MASK_SMOKE_AND_FIRE
static void G_BuildForbiddenListForEntity(Edict *ent)
Create a list of the grid positions the edict occupies and store it with the edict.
void G_FreeEdict(Edict *ent)
Marks the edict as free.
bool G_MissionTouch(Edict *self, Edict *activator)
Mission trigger.
Interface for g_client.cpp.
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...