Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ents.hpp
Go to the documentation of this file.
1 
5 #pragma once
6 
7 #include "inexor/shared/geom.hpp"
8 
12 enum {
13  ET_EMPTY = 0,
22  // the last two are here for providing backwards compatibility with the sauerbomber maps:
23  ET_BOMBS = 14,
25 };
26 
30 enum
31 {
40 
48 
54  BASE,
56  BOX,
60  FLAG,
63 };
64 
66 struct entity
67 {
68  vec o; // position
70  uchar type; // type is one of the above
72 };
73 
76 {
77  int type;
78  int spawntime;
79  bool spawned;
80 };
81 
83 {
85  int millis;
86 
87  entitylight() : color(1, 1, 1), dir(0, 0, 1), millis(-1) {}
88 };
89 
90 enum
91 {
92  EF_NOVIS = 1<<0,
93  EF_NOSHADOW = 1<<1,
94  EF_NOCOLLIDE = 1<<2,
95  EF_ANIM = 1<<3,
96  EF_OCTA = 1<<4,
97  EF_RENDER = 1<<5,
98  EF_SOUND = 1<<6,
99  EF_SPAWNED = 1<<7
100 };
101 
102 struct extentity : entity // part of the entity that doesn't get saved to disk
103 {
104  int flags; // the only dynamic state of a map entity
107 
108  extentity() : flags(0), attached(nullptr) {}
109 
110  bool spawned() const { return (flags&EF_SPAWNED) != 0; }
111  void setspawned(bool val) { if(val) flags |= EF_SPAWNED; else flags &= ~EF_SPAWNED; }
112  void setspawned() { flags |= EF_SPAWNED; }
113  void clearspawned() { flags &= ~EF_SPAWNED; }
114 };
115 
116 #define MAXENTS 10000
117 
118 //extern vector<extentity *> ents; // map entities
119 
121 
123 
124 enum { ENT_PLAYER = 0, ENT_AI, ENT_INANIMATE, ENT_CAMERA, ENT_BOUNCE }; // ENT_INANIMATE is a moveable (e.g. moving platform)
125 
127 
128 struct physent // base entity type, can be affected by physics
129 {
130  vec o, vel, falling; // origin, velocity
131  vec deltapos, newpos; // movement interpolation
132  float yaw, pitch, roll;
133  float maxspeed; // cubes per second, 100 for player
135  float radius, eyeheight, aboveeye; // bounding box size
137  vec floor; // the normal of floor the dynent is on
138 
139  int inwater;
140  bool jumping;
141  char move, strafe;
142 
143  uchar physstate; // one of PHYS_* above
144  uchar state, editstate; // one of CS_* above
145  uchar type; // one of ENT_* above
146  uchar collidetype; // one of COLLIDE_* above
147 
148  bool blocked; // used by physics to signal ai
149 
150  physent() : o(0, 0, 0), deltapos(0, 0, 0), newpos(0, 0, 0), yaw(0), pitch(0), roll(0), maxspeed(100),
151  radius(4.1f), eyeheight(14), aboveeye(1), xradius(4.1f), yradius(4.1f), zmargin(0),
154  blocked(false)
155  { reset(); }
156 
157  void resetinterp()
158  {
159  newpos = o;
160  deltapos = vec(0, 0, 0);
161  }
162 
163  void reset()
164  {
165  inwater = 0;
166  timeinair = 0;
167  jumping = false;
168  strafe = move = 0;
170  vel = falling = vec(0, 0, 0);
171  floor = vec(0, 0, 1);
172  }
173 
174  vec feetpos(float offset = 0) const { return vec(o).add(vec(0, 0, offset - eyeheight)); }
175  vec headpos(float offset = 0) const { return vec(o).add(vec(0, 0, offset)); }
176  vec abovehead() { return vec(o).add(vec(0, 0, aboveeye+4)); }
177 
178  bool maymove() const { return timeinair || physstate < PHYS_FLOOR || vel.squaredlen() > 1e-4f || deltapos.squaredlen() > 1e-4f; }
179 };
180 
181 enum
182 {
194 };
195 
196 static const char * const animnames[] =
197 {
198  "dead", "dying", "idle",
199  "forward", "backward", "left", "right",
200  "hold 1", "hold 2", "hold 3", "hold 4", "hold 5", "hold 6", "hold 7",
201  "attack 1", "attack 2", "attack 3", "attack 4", "attack 5", "attack 6", "attack 7",
202  "pain",
203  "jump", "sink", "swim",
204  "edit", "lag", "taunt", "win", "lose",
205  "gun idle", "gun shoot",
206  "vwep idle", "vwep shoot", "shield", "powerup",
207  "mapmodel", "trigger"
208 };
209 
210 #define ANIM_ALL 0x7F
211 #define ANIM_INDEX 0x7F
212 #define ANIM_LOOP (1<<7)
213 #define ANIM_START (1<<8)
214 #define ANIM_END (1<<9)
215 #define ANIM_REVERSE (1<<10)
216 #define ANIM_CLAMP (ANIM_START|ANIM_END)
217 #define ANIM_DIR 0x780
218 #define ANIM_SECONDARY 11
219 #define ANIM_NOSKIN (1<<22)
220 #define ANIM_SETTIME (1<<23)
221 #define ANIM_FULLBRIGHT (1<<24)
222 #define ANIM_REUSE (1<<25)
223 #define ANIM_NORENDER (1<<26)
224 #define ANIM_RAGDOLL (1<<27)
225 #define ANIM_SETSPEED (1<<28)
226 #define ANIM_NOPITCH (1<<29)
227 #define ANIM_GHOST (1<<30)
228 #define ANIM_FLAGS (0x1FF<<22)
229 
230 struct animinfo // description of a character's animation
231 {
233  float speed;
235 
236  animinfo() : anim(0), frame(0), range(0), basetime(0), speed(100.0f), varseed(0) { }
237 
238  bool operator==(const animinfo &o) const { return frame==o.frame && range==o.range && (anim&(ANIM_SETTIME|ANIM_DIR))==(o.anim&(ANIM_SETTIME|ANIM_DIR)) && (anim&ANIM_SETTIME || basetime==o.basetime) && speed==o.speed; }
239  bool operator!=(const animinfo &o) const { return frame!=o.frame || range!=o.range || (anim&(ANIM_SETTIME|ANIM_DIR))!=(o.anim&(ANIM_SETTIME|ANIM_DIR)) || (!(anim&ANIM_SETTIME) && basetime!=o.basetime) || speed!=o.speed; }
240 };
241 
242 struct animinterpinfo // used for animation blending of animated characters
243 {
246  void *lastmodel;
247 
248  animinterpinfo() : lastswitch(-1), lastmodel(nullptr) {}
249 
250  void reset() { lastswitch = -1; }
251 };
252 
253 #define MAXANIMPARTS 3
254 
255 struct occludequery;
256 struct ragdolldata;
257 
258 struct dynent : physent // animated characters, or characters that can receive input
259 {
260  bool k_left, k_right, k_up, k_down; // see input code
261 
267 
268  dynent() : ragdoll(nullptr), query(nullptr), occluded(0), lastrendered(0)
269  {
270  reset();
271  }
272 
274  {
275 #ifndef STANDALONE
276  extern void cleanragdoll(dynent *d);
277  if(ragdoll) cleanragdoll(this);
278 #endif
279  }
280 
281  void stopmoving()
282  {
283  k_left = k_right = k_up = k_down = jumping = false;
284  move = strafe = 0;
285  }
286 
287  void reset()
288  {
289  physent::reset();
290  stopmoving();
292  }
293 };
294 
295 
Definition: ents.hpp:82
extentity * attached
Definition: ents.hpp:106
Definition: ents.hpp:185
ammo pickups
Definition: ents.hpp:42
Definition: ents.hpp:190
Definition: ents.hpp:185
#define ANIM_DIR
Definition: ents.hpp:217
bool maymove() const
Definition: ents.hpp:178
short attr1
Definition: ents.hpp:69
attr1 = z-angle, attr2 = team
Definition: ents.hpp:61
Definition: ents.hpp:189
void * lastmodel
Definition: ents.hpp:246
void reset()
Definition: ents.hpp:287
char strafe
Definition: ents.hpp:141
Definition: ents.hpp:186
int occluded
Definition: ents.hpp:266
int lastswitch
Definition: ents.hpp:245
unsigned int uint
Definition: cube_types.hpp:9
float maxspeed
Definition: ents.hpp:133
attr1 = z-angle, attr2 = idx
Definition: ents.hpp:51
float xradius
Definition: ents.hpp:136
vec feetpos(float offset=0) const
Definition: ents.hpp:174
Definition: ents.hpp:23
bool spawned
Definition: ents.hpp:79
bool k_left
Definition: ents.hpp:260
vec abovehead()
Definition: ents.hpp:176
Definition: ents.hpp:47
Definition: ents.hpp:120
Definition: ents.hpp:188
Definition: ents.hpp:191
int spawntime
Definition: ents.hpp:78
Definition: ents.hpp:122
animinterpinfo animinterp[MAXANIMPARTS]
Definition: ents.hpp:263
Definition: ents.hpp:41
attr1 = z-angle, attr2 = idx, attr3 = tag, attr4 = speed
Definition: ents.hpp:60
float squaredlen() const
calculate the squared length of this vector (pythagoras)
Definition: geom.hpp:159
Definition: ents.hpp:120
bool k_down
Definition: ents.hpp:260
Definition: ents.hpp:189
Definition: ents.hpp:185
Definition: ents.hpp:32
attr1 = z-angle, attr2 = monstertype
Definition: ents.hpp:52
int range
Definition: ents.hpp:232
bool operator==(const animinfo &o) const
Definition: ents.hpp:238
Definition: ents.hpp:189
bool blocked
Definition: ents.hpp:148
Definition: ents.hpp:188
int inwater
Definition: ents.hpp:139
Definition: ents.hpp:187
Definition: ents.hpp:189
physent()
Definition: ents.hpp:150
Definition: ents.hpp:97
uchar collidetype
Definition: ents.hpp:146
float pitch
Definition: ents.hpp:132
float zmargin
Definition: ents.hpp:136
int frame
Definition: ents.hpp:232
Definition: ents.hpp:21
Definition: ents.hpp:120
entity slot not in used in maps
Definition: ents.hpp:33
Definition: ents.hpp:45
char move
Definition: ents.hpp:141
int anim
Definition: ents.hpp:232
bomb radius (see bomberman game mode)
Definition: ents.hpp:44
Definition: ents.hpp:191
animinfo cur
Definition: ents.hpp:244
bomberman game mode
Definition: ents.hpp:43
Definition: ents.hpp:122
Definition: ents.hpp:186
Definition: ents.hpp:122
Definition: ents.hpp:190
Definition: ents.hpp:128
uchar type
Definition: ents.hpp:70
persistent map entity.
Definition: ents.hpp:66
Definition: ents.hpp:49
Definition: ents.hpp:184
Definition: ents.hpp:14
void reset()
Definition: ents.hpp:163
bomberman game mode
Definition: ents.hpp:45
Definition: ents.hpp:230
ICOMMAND * f(float *a, float *b), floatret(*a **b)
Definition: ents.hpp:41
Definition: ents.hpp:19
Definition: ents.hpp:122
uchar editstate
Definition: ents.hpp:144
cone-shaped spotlights
Definition: ents.hpp:41
Definition: ents.hpp:98
entitylight light
Definition: ents.hpp:105
vec newpos
Definition: ents.hpp:131
Definition: ragdoll.hpp:136
float yaw
Definition: ents.hpp:132
extentity()
Definition: ents.hpp:108
Definition: octree.hpp:101
void cleanragdoll(dynent *d)
Definition: ragdoll.cpp:315
else loopi(numargs)
Definition: command.cpp:3019
void setspawned(bool val)
Definition: ents.hpp:111
attr1 = z-angle, attr2 = idx, attr3 = weight, attr4 = health
Definition: ents.hpp:58
uint varseed
Definition: ents.hpp:234
sounds
Definition: ents.hpp:39
float yradius
Definition: ents.hpp:136
void resetinterp()
Definition: ents.hpp:157
Definition: ents.hpp:183
Definition: ents.hpp:41
float eyeheight
Definition: ents.hpp:135
attr1 = z-angle, attr2 = idx, attr3 = tag, attr4 = speed
Definition: ents.hpp:59
Definition: ents.hpp:92
Definition: ents.hpp:15
bool operator!=(const animinfo &o) const
Definition: ents.hpp:239
Definition: ents.hpp:124
Definition: ents.hpp:192
dynent()
Definition: ents.hpp:268
void stopmoving()
Definition: ents.hpp:281
Definition: ents.hpp:183
static const char *const animnames[]
Definition: ents.hpp:196
vec headpos(float offset=0) const
Definition: ents.hpp:175
Definition: ents.hpp:186
Definition: ents.hpp:102
float aboveeye
Definition: ents.hpp:135
vector with 3 floats and some useful methods.
Definition: geom.hpp:110
uchar physstate
Definition: ents.hpp:143
int lastrendered
Definition: ents.hpp:266
Definition: ents.hpp:46
bool jumping
Definition: ents.hpp:140
vec deltapos
Definition: ents.hpp:131
vec falling
Definition: ents.hpp:130
float radius
Definition: ents.hpp:135
singleplayer: respawn points ('respawnpoint set' :))
Definition: ents.hpp:56
Definition: ents.hpp:191
uchar reserved
Definition: ents.hpp:71
Definition: ents.hpp:124
Definition: ents.hpp:122
Definition: ents.hpp:120
Definition: ents.hpp:41
void reset()
Definition: ents.hpp:250
#define MAXANIMPARTS
Definition: ents.hpp:253
animinfo prev
Definition: ents.hpp:244
animinfo()
Definition: ents.hpp:236
Definition: ents.hpp:126
Definition: ents.hpp:126
uchar type
Definition: ents.hpp:145
bool k_right
Definition: ents.hpp:260
Definition: ents.hpp:184
Definition: ents.hpp:124
lightsource, attr1 = radius, attr2 = intensity
Definition: ents.hpp:34
Definition: ents.hpp:186
Definition: ents.hpp:185
Definition: ents.hpp:186
Definition: ents.hpp:126
int d
Definition: octaedit.cpp:1749
Definition: ents.hpp:93
Definition: ents.hpp:258
Definition: ents.hpp:95
particles (may becomes deprecated because of the new particle system)
Definition: ents.hpp:38
short attr3
Definition: ents.hpp:69
unsigned char uchar
Basic type definitions.
Definition: cube_types.hpp:7
occludequery * query
Definition: ents.hpp:265
attr1 = z-angle, attr2 = team
Definition: ents.hpp:36
Definition: ents.hpp:41
short attr5
Definition: ents.hpp:69
entitylight()
Definition: ents.hpp:87
Definition: ents.hpp:242
GLintptr offset
Definition: glexts.hpp:354
vec o
Definition: ents.hpp:130
void setspawned()
Definition: ents.hpp:112
attr1 = z-angle, attr2 = idx, attr3 = weight
Definition: ents.hpp:57
Definition: ents.hpp:24
Definition: ents.hpp:193
Definition: ents.hpp:184
vec & add(const vec &o)
scalar sum
Definition: geom.hpp:174
attr1 = radius
Definition: ents.hpp:37
animinterpinfo()
Definition: ents.hpp:248
Definition: ents.hpp:124
Definition: ents.hpp:13
server side version of "entity" type
Definition: ents.hpp:75
void clearspawned()
Definition: ents.hpp:113
Definition: ents.hpp:120
Definition: ents.hpp:120
Definition: ents.hpp:191
int timeinair
Definition: ents.hpp:134
int flags
Definition: ents.hpp:104
bool spawned() const
Definition: ents.hpp:110
Definition: ents.hpp:16
#define ANIM_SETTIME
Definition: ents.hpp:220
Definition: ents.hpp:122
int basetime
Definition: ents.hpp:232
float roll
Definition: ents.hpp:132
vec dir
Definition: ents.hpp:84
Definition: ents.hpp:183
Definition: ents.hpp:186
uchar state
Definition: ents.hpp:144
Definition: ents.hpp:18
short attr4
Definition: ents.hpp:69
Definition: ents.hpp:185
~dynent()
Definition: ents.hpp:273
bool k_up
Definition: ents.hpp:260
mathmatics for vectors, matrices, quaterions and more
ragdolldata * ragdoll
Definition: ents.hpp:264
int millis
Definition: ents.hpp:85
Definition: ents.hpp:96
attr1 = z-angle, attr2 = idx
Definition: ents.hpp:35
Definition: ents.hpp:192
entitylight light
Definition: ents.hpp:262
Definition: ents.hpp:122
attr1 = idx, attr2 = model, attr3 = tag
Definition: ents.hpp:50
Definition: ents.hpp:94
Definition: ents.hpp:188
vec color
Definition: ents.hpp:84
vec vel
Definition: ents.hpp:130
Definition: ents.hpp:124
vec floor
Definition: ents.hpp:137
Definition: ents.hpp:99
Definition: ents.hpp:185
Definition: ents.hpp:184
vec o
Definition: ents.hpp:68
Definition: ents.hpp:185
Definition: random.cpp:21
Definition: ents.hpp:126
Definition: ents.hpp:17
base (regencapture and capture game modes)
Definition: ents.hpp:55
attr1 = tag, attr2 = type
Definition: ents.hpp:53
attr1 = z-angle, attr2 = idx (mapmodel index), attr3 = health, attr4 = weight, attr5 = respawnmillis ...
Definition: ents.hpp:62
attr1 = z-push, attr2 = y-push, attr3 = x-push
Definition: ents.hpp:54
Definition: ents.hpp:20
Definition: ents.hpp:122
Definition: ents.hpp:189
Definition: ents.hpp:186
Definition: ents.hpp:46
float speed
Definition: ents.hpp:233
int type
Definition: ents.hpp:77
short attr2
Definition: ents.hpp:69