UFO: Alien Invasion
Doxygen documentation generating
chr_shared.h
Go to the documentation of this file.
1 
5 /*
6 Copyright (C) 2002-2023 UFO: Alien Invasion.
7 
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
12 
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 
17 See the GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 
23 */
24 
25 #pragma once
26 
27 typedef enum {
33 } killtypes_t;
34 
36 typedef enum {
41 
47  /* Pilot skills */
53 
54 #define ABILITY_NUM_TYPES SKILL_CLOSE
55 
56 typedef struct chrTemplate_s {
57  char id[MAX_VAR];
58  float rate;
59  int skills[SKILL_NUM_TYPES + 1][2];
61 
75 typedef struct chrScoreMission_s {
76  /* Movement counts. */
79 
80  /* Kills & stuns */
82  int kills[KILLED_NUM_TYPES];
83  int stuns[KILLED_NUM_TYPES];
85  /* Hits/Misses */
86  int fired[SKILL_NUM_TYPES];
87  int firedTUs[SKILL_NUM_TYPES];
88  bool firedHit[KILLED_NUM_TYPES];
92  int firedSplash[SKILL_NUM_TYPES];
93  int firedSplashTUs[SKILL_NUM_TYPES];
94  bool firedSplashHit[KILLED_NUM_TYPES];
95  int hitsSplash[SKILL_NUM_TYPES][KILLED_NUM_TYPES];
96  int hitsSplashDamage[SKILL_NUM_TYPES][KILLED_NUM_TYPES];
99  int skillKills[SKILL_NUM_TYPES];
101  int heal;
104  inline chrScoreMission_s () {
105  init();
106  }
107  inline void init () {
108  OBJZERO(*this);
109  }
111 
119 typedef struct chrScoreGlobal_s {
120  int experience[SKILL_NUM_TYPES + 1];
122  int skills[SKILL_NUM_TYPES];
123  int initialSkills[SKILL_NUM_TYPES + 1];
125  /* Kills & Stuns */
126  int kills[KILLED_NUM_TYPES];
127  int stuns[KILLED_NUM_TYPES];
131  int rank;
133  inline chrScoreGlobal_s () :
134  assignedMissions(0),
135  rank(0)
136  {
137  OBJZERO(experience);
138  OBJZERO(skills);
139  OBJZERO(initialSkills);
140  OBJZERO(kills);
141  OBJZERO(stuns);
142  }
144 
149 
150 public:
151 
153  inline bool isSaneFiremode () const {
154  return _hand > ACTOR_HAND_NOT_SET && _fmIdx >= 0 && _fmIdx < MAX_FIREDEFS_PER_WEAPON && _weapon != nullptr;
155  }
156 
157  inline int getFmIdx () const {
158  return _fmIdx;
159  }
160 
161  inline const objDef_t* getWeapon () const {
162  return _weapon;
163  }
164 
165  inline actorHands_t getHand () const {
166  return _hand;
167  }
168 
169  inline void setHand (const actorHands_t hand) {
170  _hand = hand;
171  }
172 
173  inline void set (const actorHands_t hand, const fireDefIndex_t fmIdx, const objDef_t* weapon) {
174  _hand = hand;
175  _fmIdx = fmIdx;
176  _weapon = weapon;
177  }
178 };
179 
186 typedef struct chrReservations_s {
187  /* Reaction fire reservation (for current turn and next enemy turn) */
188  int reaction;
191  /* Crouch reservation (for current turn) */
192  int crouch;
194  /* Shot reservation (for current turn) */
195  int shot;
199  inline chrReservations_s () :
200  reaction(0),
201  crouch(0),
202  shot(0),
203  shotSettings(FiremodeSettings())
204  {
205  }
207 
208 typedef enum {
216 
218 typedef enum {
223 } actorSound_t;
224 
225 /* team definitions */
226 
227 #define MAX_UGV 8
228 #define MAX_TEAMDEFS 64
229 #define MAX_CHARACTER_TEMPLATES 24
230 #define MAX_TEMPLATES_PER_TEAM 16
231 
232 typedef enum {
236 
240 
242 } nametypes_t;
243 
245 typedef struct ugv_s {
246  char* id;
247  int idx;
248  char weapon[MAX_VAR];
249  char armour[MAX_VAR];
250  int tu;
251  char actors[MAX_VAR];
252  int price;
253 } ugv_t;
254 
264 };
265 
266 #define BODYPART_MAXTYPE 4
267 
269 public:
270  char id[MAX_TEXPATH];
276 };
277 
278 class BodyData {
279 private:
284 
285 public:
286  BodyData(void);
287  const char* id(void) const;
288  const char* id(const short bodyPart) const;
289  const char* name(const short bodyPart) const;
290  float penalty(const short bodyPart, const modifier_types_t type) const;
291  float bleedingFactor(const short bodyPart) const;
292  float woundThreshold(const short bodyPart) const;
293  short getRandomBodyPart(void) const;
294  short numBodyParts (void) const;
295  void setId(const char* id);
296  void addBodyPart(const BodyPartData& bodyPart);
297  short getHitBodyPart(const byte direction, const float height) const;
298  float getArea(const short bodyPart) const;
299 };
300 
301 typedef struct teamNames_s {
302  char id[MAX_VAR];
304  int numNames[NAME_NUM_TYPES];
305 } teamNames_t;
306 
307 typedef struct teamDef_s {
308  int idx;
309  char id[MAX_VAR];
310  char name[MAX_VAR];
311  char tech[MAX_VAR];
312  char footstepSound[MAX_VAR];
313 
314  linkedList_t* const* names;
315  const int* numNames;
317  struct model_t {
318  char* path;
319  char* body;
320  char* head;
321  int bodySkin;
322  int headSkin;
323  };
324 
326  int numModels[NAME_LAST];
329  int numSounds[SND_MAX][NAME_LAST];
331  int team;
333  bool robot;
334  bool armour;
335  bool weapons;
342  char hitParticle[MAX_VAR];
343  char deathTextureName[MAX_VAR];
345  short resistance[MAX_DAMAGETYPES];
347  const chrTemplate_t* characterTemplates[MAX_TEMPLATES_PER_TEAM];
349 
351 
352  const char* getActorSound(int gender, actorSound_t soundType) const;
353 
354 // can't add this simple constructor because in scripts.cpp, teamDefValues 'offsetof' is used on teamdef_t
355 // inline teamDef_s () {
356 // OBJZERO(*this);
357 // }
358 } teamDef_t;
359 
361 typedef struct woundInfo_s {
362  int woundLevel[BODYPART_MAXTYPE];
363  int treatmentLevel[BODYPART_MAXTYPE];
364 
365  inline woundInfo_s () {
366  OBJZERO(woundLevel);
367  OBJZERO(treatmentLevel);
368  }
369 } woundInfo_t;
370 
371 #define MAX_CHARACTER_IMPLANTS 4
372 typedef struct implant_s {
373  const implantDef_t* def;
376  int trigger;
377 
378  inline implant_s () :
379  def(nullptr),
380  installedTime(0),
381  removedTime(0),
382  trigger(0)
383  {
384  }
385 } implant_t;
386 
388 typedef struct character_s {
389  int ucn;
390  char name[MAX_VAR];
391  char path[MAX_VAR];
392  char body[MAX_VAR];
393  char head[MAX_VAR];
394  int bodySkin;
395  int headSkin;
397  int HP;
398  int minHP;
399  int maxHP;
400  int STUN;
401  int morale;
404  int state;
410 
414  int gender;
419 
420  character_s();
421  void init ();
422 } character_t;
423 
424 /* ================================ */
425 /* CHARACTER GENERATING FUNCTIONS */
426 /* ================================ */
427 
428 const chrTemplate_t* CHRSH_GetTemplateByID(const teamDef_t* teamDef, const char* templateId);
429 void CHRSH_CharGenAbilitySkills(character_t* chr, bool multiplayer, const char* templateId = "") __attribute__((nonnull));
430 const char* CHRSH_CharGetBody(const character_t* const chr) __attribute__((nonnull));
431 const char* CHRSH_CharGetHead(const character_t* const chr) __attribute__((nonnull));
432 bool CHRSH_IsTeamDefAlien(const teamDef_t* const td) __attribute__((nonnull));
433 bool CHRSH_IsTeamDefRobot(const teamDef_t* const td) __attribute__((nonnull));
434 bool CHRSH_IsArmourUseableForTeam(const objDef_t* od, const teamDef_t* teamDef);
435 const implant_t* CHRSH_ApplyImplant(character_t& chr, const implantDef_t& implant);
int removedTime
Definition: chr_shared.h:375
short getHitBodyPart(const byte direction, const float height) const
Definition: chr_shared.cpp:405
bool armour
Definition: chr_shared.h:334
#define BODYPART_MAXTYPE
Definition: chr_shared.h:266
const chrTemplate_t * CHRSH_GetTemplateByID(const teamDef_t *teamDef, const char *templateId)
Definition: chr_shared.cpp:108
linkedList_t *const * names
Definition: chr_shared.h:314
abilityskills_t
Definition: chr_shared.h:36
float woundThreshold(const short bodyPart) const
Definition: chr_shared.cpp:384
const int * numNames
Definition: chr_shared.h:315
actorHands_t getHand() const
Definition: chr_shared.h:165
BodyData(void)
Definition: chr_shared.cpp:336
actorSizeEnum_t size
Definition: chr_shared.h:341
int penalties[MODIFIER_MAX]
Definition: chr_shared.h:272
QGL_EXTERN GLint GLenum type
Definition: r_gl.h:94
bool CHRSH_IsTeamDefRobot(const teamDef_t *const td) __attribute__((nonnull))
Check if a team definition is a robot.
Definition: chr_shared.cpp:103
actorHands_t _hand
Definition: chr_shared.h:146
const char * id(void) const
Definition: chr_shared.cpp:359
void addBodyPart(const BodyPartData &bodyPart)
Definition: chr_shared.cpp:399
nametypes_t
Definition: chr_shared.h:232
Structure of all stats collected in a mission.
Definition: chr_shared.h:75
int numTemplates
Definition: chr_shared.h:348
int32_t actorSizeEnum_t
Definition: ufotypes.h:77
void setHand(const actorHands_t hand)
Definition: chr_shared.h:169
const implantDef_t * def
Definition: chr_shared.h:373
Describes a character with all its attributes.
Definition: chr_shared.h:388
Structure of all stats collected for an actor over time.
Definition: chr_shared.h:119
short _numBodyParts
Definition: chr_shared.h:283
const BodyData * bodyTemplate
Definition: chr_shared.h:350
#define nullptr
Definition: cxx.h:53
const teamDef_t * teamDef
Definition: chr_shared.h:413
const char * CHRSH_CharGetHead(const character_t *const chr) __attribute__((nonnull))
Returns the head model for the soldiers for armoured and non armoured soldiers.
Definition: chr_shared.cpp:319
#define __attribute__(x)
Definition: cxx.h:37
FiremodeSettings shotSettings
Definition: chr_shared.h:196
char _id[MAX_TEXPATH]
Definition: chr_shared.h:280
chrReservations_t reservedTus
Definition: chr_shared.h:415
void CHRSH_UpdateImplants(character_t &chr)
Updates the characters permanent implants. Called every day.
Definition: chr_shared.cpp:140
char name[MAX_TEXPATH]
Definition: chr_shared.h:271
bool weapons
Definition: chr_shared.h:335
bool CHRSH_IsTeamDefAlien(const teamDef_t *const td) __attribute__((nonnull))
Check if a team definition is alien.
Definition: chr_shared.cpp:83
bool CHRSH_IsArmourUseableForTeam(const objDef_t *od, const teamDef_t *teamDef)
Definition: chr_shared.cpp:88
const objDef_t * onlyWeapon
Definition: chr_shared.h:336
#define MAX_DAMAGETYPES
Definition: inv_shared.h:258
BodyPartData _bodyParts[BODYPART_MAXTYPE]
Definition: chr_shared.h:281
#define MAX_TEXPATH
Definition: defines.h:95
float bleedingFactor(const short bodyPart) const
Definition: chr_shared.cpp:379
#define OBJZERO(obj)
Definition: shared.h:178
#define MAX_VAR
Definition: shared.h:36
bool isSaneFiremode() const
Definition: chr_shared.h:153
int32_t fireDefIndex_t
Definition: inv_shared.h:78
#define MAX_FIREDEFS_PER_WEAPON
Definition: inv_shared.h:42
reservation_types_t
Definition: chr_shared.h:208
actorHands_t
Definition: inv_shared.h:626
const objDef_t * getWeapon() const
Definition: chr_shared.h:161
Info on a wound.
Definition: chr_shared.h:361
woundInfo_t wounds
Definition: chr_shared.h:402
#define MAX_CHARACTER_IMPLANTS
Definition: chr_shared.h:371
#define MAX_TEMPLATES_PER_TEAM
Definition: chr_shared.h:230
short getRandomBodyPart(void) const
Definition: chr_shared.cpp:341
const objDef_t * _weapon
Definition: chr_shared.h:148
actorSizeEnum_t fieldSize
Definition: chr_shared.h:409
int price
Definition: chr_shared.h:252
int woundThreshold
Definition: chr_shared.h:275
int idx
Definition: chr_shared.h:247
const char * name(const short bodyPart) const
Definition: chr_shared.cpp:369
void CHRSH_CharGenAbilitySkills(character_t *chr, bool multiplayer, const char *templateId="") __attribute__((nonnull))
Generates a skill and ability set for any character.
Definition: chr_shared.cpp:221
float penalty(const short bodyPart, const modifier_types_t type) const
Definition: chr_shared.cpp:374
FiremodeSettings RFmode
Definition: chr_shared.h:416
modifier_types_t
Definition: chr_shared.h:255
int tu
Definition: chr_shared.h:250
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition: r_gl.h:110
chrScoreGlobal_t score
Definition: chr_shared.h:406
int trigger
Definition: chr_shared.h:376
inventory definition with all its containers
Definition: inv_shared.h:525
Defines all attributes of objects used in the inventory.
Definition: inv_shared.h:264
int bleedingFactor
Definition: chr_shared.h:274
vec4_t shape
Definition: chr_shared.h:273
const implant_t * CHRSH_ApplyImplant(character_t &chr, const implantDef_t &implant)
Add a new implant to a character.
Definition: chr_shared.cpp:180
float getArea(const short bodyPart) const
Definition: chr_shared.cpp:427
void setId(const char *id)
Definition: chr_shared.cpp:394
actorSound_t
Types of actor sounds being issued by CL_ActorPlaySound().
Definition: chr_shared.h:218
char * id
Definition: chr_shared.h:246
fireDefIndex_t _fmIdx
Definition: chr_shared.h:147
float _totalBodyArea
Definition: chr_shared.h:282
int installedTime
Definition: chr_shared.h:374
uint8_t byte
Definition: ufotypes.h:34
How many TUs (and of what type) did a player reserve for a unit?
Definition: chr_shared.h:186
short numBodyParts(void) const
Definition: chr_shared.cpp:389
const char * CHRSH_CharGetBody(const character_t *const chr) __attribute__((nonnull))
Returns the body model for the soldiers for armoured and non armoured soldiers.
Definition: chr_shared.cpp:297
int getFmIdx() const
Definition: chr_shared.h:157
chrScoreMission_t * scoreMission
Definition: chr_shared.h:407
Defines a type of UGV/Robot.
Definition: chr_shared.h:245
bool robot
Definition: chr_shared.h:333
Inventory inv
Definition: chr_shared.h:411
killtypes_t
Definition: chr_shared.h:27
vec_t vec4_t[4]
Definition: ufotypes.h:40