UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
chr_shared.h
Go to the documentation of this file.
1 
5 /*
6 Copyright (C) 2002-2020 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 */
85  /* Hits/Misses */
101  int heal;
104  inline chrScoreMission_s () {
105  init();
106  }
107  inline void init () {
108  OBJZERO(*this);
109  }
111 
119 typedef struct chrScoreGlobal_s {
125  /* Kills & Stuns */
131  int rank;
133  inline chrScoreGlobal_s () {
134  OBJZERO(*this);
135  }
137 
142 
143 public:
144 
145  inline FiremodeSettings () : _hand(ACTOR_HAND_NOT_SET), _fmIdx(0), _weapon(nullptr) {}
146  inline bool isSaneFiremode () const {
147  return _hand > ACTOR_HAND_NOT_SET && _fmIdx >= 0 && _fmIdx < MAX_FIREDEFS_PER_WEAPON && _weapon != nullptr;
148  }
149 
150  inline int getFmIdx () const {
151  return _fmIdx;
152  }
153 
154  inline const objDef_t* getWeapon () const {
155  return _weapon;
156  }
157 
158  inline actorHands_t getHand () const {
159  return _hand;
160  }
161 
162  inline void setHand (const actorHands_t hand) {
163  _hand = hand;
164  }
165 
166  inline void set (const actorHands_t hand, const fireDefIndex_t fmIdx, const objDef_t* weapon) {
167  _hand = hand;
168  _fmIdx = fmIdx;
169  _weapon = weapon;
170  }
171 };
172 
179 typedef struct chrReservations_s {
180  /* Reaction fire reservation (for current turn and next enemy turn) */
181  int reaction;
184  /* Crouch reservation (for current turn) */
185  int crouch;
187  /* Shot reservation (for current turn) */
188  int shot;
192  inline chrReservations_s () {
193  reaction = crouch = shot = 0;
194  }
196 
197 typedef enum {
205 
207 typedef enum {
212 } actorSound_t;
213 
214 /* team definitions */
215 
216 #define MAX_UGV 8
217 #define MAX_TEAMDEFS 64
218 #define MAX_CHARACTER_TEMPLATES 24
219 #define MAX_TEMPLATES_PER_TEAM 16
220 
221 typedef enum {
225 
229 
231 } nametypes_t;
232 
234 typedef struct ugv_s {
235  char* id;
236  int idx;
239  int tu;
241  int price;
242 } ugv_t;
243 
253 };
254 
255 #define BODYPART_MAXTYPE 4
256 
258 public:
259  char id[MAX_TEXPATH];
265 };
266 
267 class BodyData {
268 private:
273 
274 public:
275  BodyData(void);
276  const char* id(void) const;
277  const char* id(const short bodyPart) const;
278  const char* name(const short bodyPart) const;
279  float penalty(const short bodyPart, const modifier_types_t type) const;
280  float bleedingFactor(const short bodyPart) const;
281  float woundThreshold(const short bodyPart) const;
282  short getRandomBodyPart(void) const;
283  short numBodyParts (void) const;
284  void setId(const char* id);
285  void addBodyPart(const BodyPartData& bodyPart);
286  short getHitBodyPart(const byte direction, const float height) const;
287  float getArea(const short bodyPart) const;
288 };
289 
290 typedef struct teamNames_s {
291  char id[MAX_VAR];
294 } teamNames_t;
295 
296 typedef struct teamDef_s {
297  int idx;
298  char id[MAX_VAR];
299  char name[MAX_VAR];
300  char tech[MAX_VAR];
302 
303  linkedList_t* const* names;
304  const int* numNames;
306  struct model_t {
307  char* path;
308  char* body;
309  char* head;
310  int bodySkin;
311  int headSkin;
312  };
313 
320  int team;
322  bool robot;
323  bool armour;
324  bool weapons;
338 
340 
341  const char* getActorSound(int gender, actorSound_t soundType) const;
342 
343 // can't add this simple constructor because in scripts.cpp, teamDefValues 'offsetof' is used on teamdef_t
344 // inline teamDef_s () {
345 // OBJZERO(*this);
346 // }
347 } teamDef_t;
348 
350 typedef struct woundInfo_s {
353 
354  inline woundInfo_s () {
355  OBJZERO(woundLevel);
356  OBJZERO(treatmentLevel);
357  }
358 } woundInfo_t;
359 
360 #define MAX_CHARACTER_IMPLANTS 4
361 typedef struct implant_s {
362  const implantDef_t* def;
365  int trigger;
366 } implant_t;
367 
369 typedef struct character_s {
370  int ucn;
371  char name[MAX_VAR];
372  char path[MAX_VAR];
373  char body[MAX_VAR];
374  char head[MAX_VAR];
375  int bodySkin;
376  int headSkin;
378  int HP;
379  int minHP;
380  int maxHP;
381  int STUN;
382  int morale;
385  int state;
391 
395  int gender;
400 
401  character_s();
402  void init ();
403 } character_t;
404 
405 /* ================================ */
406 /* CHARACTER GENERATING FUNCTIONS */
407 /* ================================ */
408 
409 const chrTemplate_t* CHRSH_GetTemplateByID(const teamDef_t* teamDef, const char* templateId);
410 void CHRSH_CharGenAbilitySkills(character_t* chr, bool multiplayer, const char* templateId = "") __attribute__((nonnull));
411 const char* CHRSH_CharGetBody(const character_t* const chr) __attribute__((nonnull));
412 const char* CHRSH_CharGetHead(const character_t* const chr) __attribute__((nonnull));
413 bool CHRSH_IsTeamDefAlien(const teamDef_t* const td) __attribute__((nonnull));
414 bool CHRSH_IsTeamDefRobot(const teamDef_t* const td) __attribute__((nonnull));
415 bool CHRSH_IsArmourUseableForTeam(const objDef_t* od, const teamDef_t* teamDef);
416 const implant_t* CHRSH_ApplyImplant(character_t& chr, const implantDef_t& implant);
const objDef_t * onlyWeapon
Definition: chr_shared.h:325
short getHitBodyPart(const byte direction, const float height) const
Definition: chr_shared.cpp:404
#define BODYPART_MAXTYPE
Definition: chr_shared.h:255
const objDef_t * getWeapon() const
Definition: chr_shared.h:154
const chrTemplate_t * CHRSH_GetTemplateByID(const teamDef_t *teamDef, const char *templateId)
Definition: chr_shared.cpp:107
char path[MAX_VAR]
Definition: chr_shared.h:372
abilityskills_t
Definition: chr_shared.h:36
char hitParticle[MAX_VAR]
Definition: chr_shared.h:331
short _numBodyParts
Definition: chr_shared.h:272
chrScoreGlobal_t score
Definition: chr_shared.h:387
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:102
void init()
Definition: chr_shared.cpp:34
int tu
Definition: chr_shared.h:239
char _id[MAX_TEXPATH]
Definition: chr_shared.h:269
struct implant_s implant_t
int price
Definition: chr_shared.h:241
BodyPartData _bodyParts[BODYPART_MAXTYPE]
Definition: chr_shared.h:270
const teamDef_t * teamDef
Definition: chr_shared.h:394
int installedTime
Definition: chr_shared.h:363
int numNames[NAME_NUM_TYPES]
Definition: chr_shared.h:293
bool robot
Definition: chr_shared.h:322
int experience[SKILL_NUM_TYPES+1]
Definition: chr_shared.h:120
int idx
Definition: chr_shared.h:236
nametypes_t
Definition: chr_shared.h:221
char tech[MAX_VAR]
Definition: chr_shared.h:300
int bleedingFactor
Definition: chr_shared.h:263
void set(const actorHands_t hand, const fireDefIndex_t fmIdx, const objDef_t *weapon)
Definition: chr_shared.h:166
int removedTime
Definition: chr_shared.h:364
Defines a type of UGV/Robot.
Definition: chr_shared.h:234
int32_t actorSizeEnum_t
Definition: ufotypes.h:77
int hitsSplash[SKILL_NUM_TYPES][KILLED_NUM_TYPES]
Definition: chr_shared.h:95
struct chrScoreMission_s chrScoreMission_t
Structure of all stats collected in a mission.
const int * numNames
Definition: chr_shared.h:304
linkedList_t * names[NAME_NUM_TYPES]
Definition: chr_shared.h:292
Structure of all stats collected in a mission.
Definition: chr_shared.h:75
const implantDef_t * def
Definition: chr_shared.h:362
linkedList_t * models[NAME_LAST]
Definition: chr_shared.h:314
#define nullptr
Definition: cxx.h:53
linkedList_t *const * names
Definition: chr_shared.h:303
int stuns[KILLED_NUM_TYPES]
Definition: chr_shared.h:127
char deathTextureName[MAX_VAR]
Definition: chr_shared.h:332
int getFmIdx() const
Definition: chr_shared.h:150
bool isSaneFiremode() const
Definition: chr_shared.h:146
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:318
Defines all attributes of objects used in the inventory.
Definition: inv_shared.h:264
#define __attribute__(x)
Definition: cxx.h:37
char name[MAX_TEXPATH]
Definition: chr_shared.h:260
chrScoreMission_t * scoreMission
Definition: chr_shared.h:388
const chrTemplate_t * characterTemplates[MAX_TEMPLATES_PER_TEAM]
Definition: chr_shared.h:336
int hits[SKILL_NUM_TYPES][KILLED_NUM_TYPES]
Definition: chr_shared.h:89
void CHRSH_UpdateImplants(character_t &chr)
Updates the characters permanent implants. Called every day.
Definition: chr_shared.cpp:139
float getArea(const short bodyPart) const
Definition: chr_shared.cpp:426
char actors[MAX_VAR]
Definition: chr_shared.h:240
struct chrReservations_s chrReservations_t
How many TUs (and of what type) did a player reserve for a unit?
struct teamNames_s teamNames_t
float bleedingFactor(const short bodyPart) const
Definition: chr_shared.cpp:378
int hitsSplashDamage[SKILL_NUM_TYPES][KILLED_NUM_TYPES]
Definition: chr_shared.h:96
int kills[KILLED_NUM_TYPES]
Definition: chr_shared.h:82
int penalties[MODIFIER_MAX]
Definition: chr_shared.h:261
int firedSplash[SKILL_NUM_TYPES]
Definition: chr_shared.h:92
bool CHRSH_IsTeamDefAlien(const teamDef_t *const td) __attribute__((nonnull))
Check if a team definition is alien.
Definition: chr_shared.cpp:82
bool CHRSH_IsArmourUseableForTeam(const objDef_t *od, const teamDef_t *teamDef)
Definition: chr_shared.cpp:87
inventory definition with all its containers
Definition: inv_shared.h:525
int numSounds[SND_MAX][NAME_LAST]
Definition: chr_shared.h:318
int treatmentLevel[BODYPART_MAXTYPE]
Definition: chr_shared.h:352
#define MAX_DAMAGETYPES
Definition: inv_shared.h:258
#define MAX_TEXPATH
Definition: defines.h:95
int skills[SKILL_NUM_TYPES+1][2]
Definition: chr_shared.h:59
actorSizeEnum_t size
Definition: chr_shared.h:330
#define OBJZERO(obj)
Definition: shared.h:178
#define MAX_VAR
Definition: shared.h:36
const objDef_t * _weapon
Definition: chr_shared.h:141
int kills[KILLED_NUM_TYPES]
Definition: chr_shared.h:126
int32_t fireDefIndex_t
Definition: inv_shared.h:78
#define MAX_FIREDEFS_PER_WEAPON
Definition: inv_shared.h:42
char head[MAX_VAR]
Definition: chr_shared.h:374
reservation_types_t
Definition: chr_shared.h:197
int initialSkills[SKILL_NUM_TYPES+1]
Definition: chr_shared.h:123
short resistance[MAX_DAMAGETYPES]
Definition: chr_shared.h:334
actorHands_t
Definition: inv_shared.h:626
int woundLevel[BODYPART_MAXTYPE]
Definition: chr_shared.h:351
#define MAX_CHARACTER_IMPLANTS
Definition: chr_shared.h:360
float _totalBodyArea
Definition: chr_shared.h:271
Info on a wound.
Definition: chr_shared.h:350
char footstepSound[MAX_VAR]
Definition: chr_shared.h:301
implant_t implants[MAX_CHARACTER_IMPLANTS]
Definition: chr_shared.h:399
void addBodyPart(const BodyPartData &bodyPart)
Definition: chr_shared.cpp:398
int numModels[NAME_LAST]
Definition: chr_shared.h:315
#define MAX_TEMPLATES_PER_TEAM
Definition: chr_shared.h:219
struct character_s character_t
Describes a character with all its attributes.
struct ugv_s ugv_t
Defines a type of UGV/Robot.
float woundThreshold(const short bodyPart) const
Definition: chr_shared.cpp:383
bool firedHit[KILLED_NUM_TYPES]
Definition: chr_shared.h:88
woundInfo_t wounds
Definition: chr_shared.h:383
struct teamDef_s teamDef_t
Structure of all stats collected for an actor over time.
Definition: chr_shared.h:119
bool firedSplashHit[KILLED_NUM_TYPES]
Definition: chr_shared.h:94
linkedList_t * sounds[SND_MAX][NAME_LAST]
Definition: chr_shared.h:317
int skillKills[SKILL_NUM_TYPES]
Definition: chr_shared.h:99
vec4_t shape
Definition: chr_shared.h:262
char name[MAX_VAR]
Definition: chr_shared.h:299
FiremodeSettings RFmode
Definition: chr_shared.h:397
struct chrScoreGlobal_s chrScoreGlobal_t
Structure of all stats collected for an actor over time.
short numBodyParts(void) const
Definition: chr_shared.cpp:388
struct chrTemplate_s chrTemplate_t
void setHand(const actorHands_t hand)
Definition: chr_shared.h:162
const char * name(const short bodyPart) const
Definition: chr_shared.cpp:368
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:220
char armour[MAX_VAR]
Definition: chr_shared.h:238
actorHands_t _hand
Definition: chr_shared.h:139
modifier_types_t
Definition: chr_shared.h:244
int trigger
Definition: chr_shared.h:365
fireDefIndex_t _fmIdx
Definition: chr_shared.h:140
const BodyData * bodyTemplate
Definition: chr_shared.h:339
int firedTUs[SKILL_NUM_TYPES]
Definition: chr_shared.h:87
struct woundInfo_s woundInfo_t
Info on a wound.
char * id
Definition: chr_shared.h:235
const char * getActorSound(int gender, actorSound_t soundType) const
Returns the actor sounds for a given category.
Definition: chr_shared.cpp:54
bool armour
Definition: chr_shared.h:323
Inventory inv
Definition: chr_shared.h:392
float penalty(const short bodyPart, const modifier_types_t type) const
Definition: chr_shared.cpp:373
char weapon[MAX_VAR]
Definition: chr_shared.h:237
const implant_t * CHRSH_ApplyImplant(character_t &chr, const implantDef_t &implant)
Add a new implant to a character.
Definition: chr_shared.cpp:179
FiremodeSettings shotSettings
Definition: chr_shared.h:189
char name[MAX_VAR]
Definition: chr_shared.h:371
int firedSplashTUs[SKILL_NUM_TYPES]
Definition: chr_shared.h:93
BodyData(void)
Definition: chr_shared.cpp:335
const char * id(void) const
Definition: chr_shared.cpp:358
actorSound_t
Types of actor sounds being issued by CL_ActorPlaySound().
Definition: chr_shared.h:207
actorHands_t getHand() const
Definition: chr_shared.h:158
int fired[SKILL_NUM_TYPES]
Definition: chr_shared.h:86
void setId(const char *id)
Definition: chr_shared.cpp:393
How many TUs (and of what type) did a player reserve for a unit?
Definition: chr_shared.h:179
int woundThreshold
Definition: chr_shared.h:264
short getRandomBodyPart(void) const
Definition: chr_shared.cpp:340
bool weapons
Definition: chr_shared.h:324
uint8_t byte
Definition: ufotypes.h:34
int numTemplates
Definition: chr_shared.h:337
int stuns[KILLED_NUM_TYPES]
Definition: chr_shared.h:83
actorSizeEnum_t fieldSize
Definition: chr_shared.h:390
int skills[SKILL_NUM_TYPES]
Definition: chr_shared.h:122
char body[MAX_VAR]
Definition: chr_shared.h:373
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:296
chrReservations_t reservedTus
Definition: chr_shared.h:396
killtypes_t
Definition: chr_shared.h:27
vec_t vec4_t[4]
Definition: ufotypes.h:40
Describes a character with all its attributes.
Definition: chr_shared.h:369