UFO: Alien Invasion
Loading...
Searching...
No Matches
cl_localentity.h
Go to the documentation of this file.
1
4
5/*
6Copyright (C) 2002-2025 UFO: Alien Invasion.
7
8This program is free software; you can redistribute it and/or
9modify it under the terms of the GNU General Public License
10as published by the Free Software Foundation; either version 2
11of the License, or (at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
17See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23*/
24
25#pragma once
26
28
39
40#define IS_MODE_FIRE_RIGHT(x) ((x) == M_FIRE_R || (x) == M_PEND_FIRE_R)
41#define IS_MODE_FIRE_LEFT(x) ((x) == M_FIRE_L || (x) == M_PEND_FIRE_L)
42#define IS_MODE_FIRE_HEADGEAR(x) ((x) == M_FIRE_HEADGEAR)
43#define IS_MODE_FIRE_PENDING(x) ((x) == M_PEND_FIRE_L || (x) == M_PEND_FIRE_R)
44
45typedef bool (*localEntitiyAddFunc_t) (struct le_s* le, entity_t* ent);
46typedef void (*localEntityThinkFunc_t) (struct le_s* le);
47
48#define LE_CHECK_LEVELFLAGS 0x0001
49#define LE_ALWAYS_VISIBLE 0x0002
50#define LE_LOCKED 0x0004
52#define LE_REMOVE_NEXT_FRAME 0x0008
53#define LE_INVISIBLE 0x0010
54#define LE_SELECTED 0x0020
55
56typedef struct leStep_s {
57 int steps;
61 struct leStep_s* next;
62} leStep_t;
63
65typedef struct le_s {
66 bool inuse;
68 int entnum;
69
72 int angle;
75 int dir;
76
77 int TU, maxTU;
79 int HP, maxHP;
80 int STUN;
81 int state;
83
84 float angles[3];
85 float alpha;
86
87 int team;
88 int pnum;
89 int ucn;
90
91 int flags;
92
94
104
105 struct le_s* clientAction;
106
110
112 unsigned int modelnum1;
113 unsigned int modelnum2;
114 unsigned int bodySkin;
115 unsigned int headSkin;
119
124
137
138 inline bool isMoving () const
139 {
140 return pathLength > 0;
141 }
142
146 float volume;
147
150 const char* particleID;
153 const char* ref1, *ref2;
154 const struct le_s* ref3;
158
160
162 int gender;
163 const fireDef_t* fd;
164
167
168 inline Item* getRightHandItem () const
169 {
170 return inv.getRightHandContainer();
171 }
172 inline Item* getLeftHandItem () const
173 {
174 return inv.getLeftHandContainer();
175 }
176 inline Item* getHandItem (actorHands_t hand) const
177 {
178 if (hand == ACTOR_HAND_RIGHT)
179 return inv.getRightHandContainer();
180 else if (hand == ACTOR_HAND_LEFT)
181 return inv.getLeftHandContainer();
182 return nullptr;
183 }
184 inline Item* getFloorContainer () const
185 {
186 return inv.getFloorContainer();
187 }
188 inline void setFloorContainer (Item* il)
189 {
190 inv.setFloorContainer(il);
191 }
192 inline void setFloor (le_s* other)
193 {
194 inv.setFloorContainer(other->getFloorContainer());
195 }
196 inline void resetFloor ()
197 {
198 inv.setFloorContainer(nullptr);
199 }
200 void init ();
201} le_t;
202
203#define MAX_LOCALMODELS 1024
204
206typedef struct localModel_s {
207 char id[MAX_VAR];
213
214 struct localModel_s* parent;
215 bool inuse;
216
220
221 int entnum;
223 int skin;
225 int frame;
229
231 void (*think) (struct localModel_s* localModel);
232
234
235 inline void setScale(const vec3_t scale_) {
236 VectorCopy(scale_, scale);
237 }
239
243
244extern cvar_t* cl_le_debug;
245extern cvar_t* cl_trace_debug;
246extern cvar_t* cl_leshowinvis;
248
249const char* LE_GetAnim(const char* anim, int right, int left, int state);
250void LE_AddProjectile(const fireDef_t* fd, int flags, const vec3_t muzzle, const vec3_t impact, int normal, le_t* leVictim);
251void LE_AddGrenade(const fireDef_t* fd, int flags, const vec3_t muzzle, const vec3_t v0, int dt, le_t* leVictim);
252void LE_AddAmbientSound(const char* sound, const vec3_t origin, int levelflags, float volume, float attenuation);
253int LE_ActorGetStepTime(const le_t* le, const pos3_t pos, const pos3_t oldPos, const int dir, const int sped);
254
255#define LE_IsStunned(le) (((le)->state & STATE_STUN) & ~STATE_DEAD)
257#define LE_IsDead(le) ((le)->state & STATE_DEAD)
258#define LE_IsPanicked(le) ((le)->state & STATE_PANIC)
259#define LE_IsRaged(le) ((le)->state & STATE_RAGE)
260#define LE_IsInsane(le) ((le)->state & STATE_INSANE)
261#define LE_IsShaken(le) ((le)->state & STATE_SHAKEN)
262#define LE_IsCrouched(le) ((le)->state & STATE_CROUCHED)
263#define LE_IsDazed(le) ((le)->state & STATE_DAZED)
264
265#define LE_IsInvisible(le) ((le)->flags & LE_INVISIBLE)
266#define LE_IsSelected(le) ((le)->flags & LE_SELECTED)
267
268#define LE_SetInvisible(le) do { if (cl_leshowinvis->integer) le->flags &= ~LE_INVISIBLE; else le->flags |= LE_INVISIBLE; } while (0)
269
270#define LE_IsItem(le) ((le)->type == ET_ITEM)
271#define LE_IsCamera(le) ((le)->type == ET_CAMERA)
272#define LE_IsCivilian(le) ((le)->team == TEAM_CIVILIAN)
273#define LE_IsAlien(le) ((le)->team == TEAM_ALIEN)
274#define LE_IsPhalanx(le) ((le)->team == TEAM_PHALANX)
275#define LE_IsRotating(le) ((le)->type == ET_ROTATING)
276#define LE_IsDoor(le) ((le)->type == ET_DOOR || (le)->type == ET_DOOR_SLIDING)
277#define LE_IsBreakable(le) ((le)->type == ET_BREAKABLE)
278#define LE_IsBrushModel(le) (LE_IsBreakable(le) || LE_IsDoor(le) || LE_IsRotating(le))
279#define LE_IsNotSolid(le) ((le)->type == ET_TRIGGER_RESCUE || (le)->type == ET_TRIGGER_NEXTMAP)
280
282#define LE_GetAnimationIndexForDeath(le) ((le)->state & MAX_DEATH)
283
284#ifdef DEBUG
285void LE_List_f(void);
286void LM_List_f(void);
287#endif
288
290void LE_ExecuteThink(le_t* le);
291void LE_Think(void);
292/* think functions */
293void LET_StartIdle(le_t* le);
294void LET_Appear(le_t* le);
295void LET_StartPathMove(le_t* le);
296void LET_HiddenMove(le_t* le);
297void LET_BrushModel(le_t* le);
298void LE_DoEndPathMove(le_t* le);
299
300/* local model functions */
301void LM_Think(void);
302void LMT_Init(localModel_t* localModel);
303localModel_t* LM_AddModel(const char* model, const vec3_t origin, const vec3_t angles, int entnum, int levelflags, int flags, const vec3_t scale);
305void LM_AddToScene(void);
306
307bool LE_BrushModelAction(le_t* le, entity_t* ent);
308void CL_RecalcRouting(const le_t* le);
309void CL_CompleteRecalcRouting(void);
310
312bool LE_IsLivingAndVisibleActor(const le_t* le);
313bool LE_IsLivingActor(const le_t* le);
314bool LE_IsActor(const le_t* le);
315le_t* LE_Add(int entnum);
316le_t* LE_Get(int entnum);
317le_t* LE_GetNextInUse(le_t* lastLE);
318le_t* LE_GetNext(le_t* lastLE);
319void LE_Lock(le_t* le);
320void LE_Unlock(le_t* le);
321bool LE_IsLocked(int entnum);
322#define LE_NotFoundError(entnum) _LE_NotFoundError(entnum, -1, __FILE__, __LINE__)
323#define LE_NotFoundWithTypeError(entnum, type) _LE_NotFoundError(entnum, type, __FILE__, __LINE__)
324void _LE_NotFoundError(int entnum, int type, const char* file, const int line) __attribute__((noreturn));
326le_t* LE_FindRadius(le_t* from, const vec3_t org, float rad, entity_type_t type);
327le_t* LE_GetFromPos(const pos3_t pos);
328void LE_PlaceItem(le_t* le);
329void LE_Cleanup(void);
330void LE_AddToScene(void);
331void LE_CenterView(const le_t* le);
332const cBspModel_t* LE_GetClipModel(const le_t* le);
333model_t* LE_GetDrawModel(unsigned int modelIndex);
334void LET_SlideDoor(le_t* le, int speed);
335void LET_RotateDoor(le_t* le, int speed);
336
337trace_t CL_Trace(const Line& traceLine, const AABB& box, const le_t* passle, le_t* passle2, int contentmask, int worldLevel);
338
339void LM_Register(void);
340localModel_t* LM_GetByID(const char* id);
cvar_t * cl_trace_debug
cvar_t * cl_map_draw_rescue_zone
cvar_t * cl_le_debug
void LET_StartPathMove(le_t *le)
Change the actors animation to walking.
void(* localEntityThinkFunc_t)(struct le_s *le)
bool(* localEntitiyAddFunc_t)(struct le_s *le, entity_t *ent)
le_t * LE_GetNextInUse(le_t *lastLE)
Iterate through the entities that are in use.
void LE_Cleanup(void)
Cleanup unused LE inventories that the server sent to the client also free some unused LE memory.
void LE_CenterView(const le_t *le)
Center the camera on the local entity's origin.
void LET_RotateDoor(le_t *le, int speed)
Rotates a door in the given speed.
void LE_AddAmbientSound(const char *sound, const vec3_t origin, int levelflags, float volume, float attenuation)
Adds ambient sounds from misc_sound entities.
le_t * LE_GetNext(le_t *lastLE)
Iterate through the list of entities.
trace_t CL_Trace(const Line &traceLine, const AABB &box, const le_t *passle, le_t *passle2, int contentmask, int worldLevel)
Moves the given mins/maxs volume through the world from start to end.
void LE_AddGrenade(const fireDef_t *fd, int flags, const vec3_t muzzle, const vec3_t v0, int dt, le_t *leVictim)
void LM_Perish(dbuffer *msg)
void LM_AddToScene(void)
Add the local models to the scene.
void CL_RecalcRouting(const le_t *le)
void LM_Register(void)
Register misc_models.
static const vec3_t player_mins
void LM_Think(void)
localModel_t * LM_GetByID(const char *id)
void LMT_Init(localModel_t *localModel)
int LE_ActorGetStepTime(const le_t *le, const pos3_t pos, const pos3_t oldPos, const int dir, const int sped)
void _LE_NotFoundError(int entnum, int type, const char *file, const int line) __attribute__((noreturn))
void LE_Unlock(le_t *le)
Unlocks a previously locked le_t struct.
bool LE_IsLivingAndVisibleActor(const le_t *le)
Checks whether the given le is a living and visible actor.
bool LE_BrushModelAction(le_t *le, entity_t *ent)
Add function for brush models.
void CL_CompleteRecalcRouting(void)
void LET_HiddenMove(le_t *le)
Handle move for invisible actors.
le_t * LE_FindRadius(le_t *from, const vec3_t org, float rad, entity_type_t type)
Returns entities that have origins within a spherical area.
localModel_t * LM_AddModel(const char *model, const vec3_t origin, const vec3_t angles, int entnum, int levelflags, int flags, const vec3_t scale)
Prepares local (not known or handled by the server) models to the map, which will be added later in L...
bool LE_IsLivingActor(const le_t *le)
Checks whether the given le is a living actor (but might be hidden).
void LET_BrushModel(le_t *le)
le_t * LE_GetFromPos(const pos3_t pos)
Searches a local entity on a given grid field.
const cBspModel_t * LE_GetClipModel(const le_t *le)
void LE_DoEndPathMove(le_t *le)
Ends the move of an actor.
le_t * LE_Add(int entnum)
Add a new local entity to the scene.
static const vec3_t player_maxs
void LE_SetThink(le_t *le, localEntityThinkFunc_t think)
actorModes_t
Actor actions.
@ M_PEND_FIRE_L
@ M_MOVE
@ M_FIRE_R
@ M_FIRE_HEADGEAR
@ M_PEND_FIRE_R
@ M_FIRE_L
@ M_PEND_MOVE
void LET_SlideDoor(le_t *le, int speed)
Slides a door.
void LET_Appear(le_t *le)
void LE_LinkFloorContainer(le_t *le)
link any floor container into the actor temp floor container
void LE_PlaceItem(le_t *le)
void LE_AddToScene(void)
void LET_StartIdle(le_t *le)
Change the animation of an actor to the idle animation (which can be panic, dead or stand).
static const vec3_t player_dead_maxs
void LE_AddProjectile(const fireDef_t *fd, int flags, const vec3_t muzzle, const vec3_t impact, int normal, le_t *leVictim)
void LE_Lock(le_t *le)
Markes a le_t struct as locked. Should be called at the beginning of an event handler on this le_t,...
model_t * LE_GetDrawModel(unsigned int modelIndex)
le_t * LE_Find(entity_type_t type, const pos3_t pos)
Searches a local entity on a given grid field.
void LE_ExecuteThink(le_t *le)
Call think function for the given local entity if its still in use.
bool LE_IsLocked(int entnum)
Checks if a given le_t structure is locked, i.e., used by another event at this time.
void LE_Think(void)
Calls the le think function and updates the animation. The animation updated even if the particular l...
le_t * LE_Get(int entnum)
Searches all local entities for the one with the searched entnum.
cvar_t * cl_leshowinvis
Definition cl_main.cpp:72
bool LE_IsActor(const le_t *le)
Checks whether the given le is a living actor.
const char * LE_GetAnim(const char *anim, int right, int left, int state)
Get the correct animation for the given actor state and weapons.
Definition aabb.h:42
inventory definition with all its containers
Definition inv_shared.h:525
item instance data, with linked list capability
Definition inv_shared.h:402
Definition line.h:31
#define __attribute__(x)
Definition cxx.h:37
#define MAX_ROUTE
Definition defines.h:84
#define MAX_QPATH
Definition filesys.h:40
int32_t fireDefIndex_t
Definition inv_shared.h:78
actorHands_t
Definition inv_shared.h:626
@ ACTOR_HAND_LEFT
Definition inv_shared.h:629
@ ACTOR_HAND_RIGHT
Definition inv_shared.h:628
voidpf uLong int origin
Definition ioapi.h:45
short dvec_t
The direction vector tells us where the actor came from (in his previous step). The pathing table hol...
Definition mathlib.h:236
entity_type_t
Definition q_shared.h:145
#define PLAYER_DEAD
Definition q_sizes.h:8
#define PLAYER_MIN
Definition q_sizes.h:9
#define PLAYER_STAND
Definition q_sizes.h:6
#define PLAYER_WIDTH
Definition q_sizes.h:10
QGL_EXTERN void(APIENTRY *qglActiveTexture)(GLenum texture)
QGL_EXTERN GLint GLenum type
Definition r_gl.h:94
#define MAX_VAR
Definition shared.h:36
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
Definition cvar.h:71
this is a fire definition for our weapons/ammo
Definition inv_shared.h:110
a local entity
const char * ref1
int state
Item * getLeftHandItem() const
lighting_t lighting
int slidingSpeed
int flags
int positionContents
int sampleIdx
fireDefIndex_t currentSelectedFiremode
int contents
float angles[3]
int startTime
void resetFloor()
ptl_t * ptl
actorModes_t actorMode
float volume
int morale
vec3_t origin
int thinkDelay
actorSizeEnum_t fieldSize
dvec_t dvtab[MAX_ROUTE]
leStep_t * stepList
Item * getRightHandItem() const
int speed[MAX_ROUTE]
int maxMorale
int maxTU
const struct le_s * ref3
int angle
float alpha
localEntitiyAddFunc_t addFunc
unsigned int modelnum1
vec3_t oldOrigin
pos3_t pos
animState_t as
localEntityThinkFunc_t think
void setFloorContainer(Item *il)
int pathContents[MAX_ROUTE]
const fireDef_t * fd
int pathPos
int stepIndex
const char * particleID
model_t * model1
float rotationSpeed
byte actorMoveLength
The TUs that the current selected actor needs to walk to the current grid position marked by the mous...
unsigned int headSkin
teamDef_t * teamDef
pos3_t mousePendPos
int pathLength
struct le_s * clientAction
int entnum
model_t * model2
const char * ref2
AABB aabb
vec3_t size
float attenuation
pos3_t oldPos
int maxHP
unsigned int modelnum2
void setFloor(le_s *other)
Item * getFloorContainer() const
char inlineModelName[8]
Item * getHandItem(actorHands_t hand) const
bool inuse
pos3_t newPos
unsigned int bodySkin
entity_type_t type
int headgear
Inventory inv
int levelflags
int endTime
woundInfo_t wounds
bool isMoving() const
int stepTimes[MAX_ROUTE]
int lastMoveDuration
struct leStep_s * next
lighting structure which contains static and dynamic lighting info for entities
Definition r_lighting.h:29
local models
model_t * model
lighting_t lighting
void(* think)(struct localModel_s *localModel)
void setScale(const vec3_t scale_)
char target[MAX_VAR]
animState_t as
struct localModel_s * parent
char animname[MAX_QPATH]
char name[MAX_QPATH]
char tagname[MAX_VAR]
Info on a wound.
Definition chr_shared.h:361
pos_t pos3_t[3]
Definition ufotypes.h:58
vec_t vec3_t[3]
Definition ufotypes.h:39
int32_t actorSizeEnum_t
Definition ufotypes.h:77
static const vec3_t scale
static int oldPos
#define VectorCopy(src, dest)
Definition vector.h:51