UFO: Alien Invasion
chr_shared.h
Go to the documentation of this file.
1
5/*
6Copyright (C) 2002-2022 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
27typedef enum {
34
36typedef enum {
41
47 /* Pilot skills */
53
54#define ABILITY_NUM_TYPES SKILL_CLOSE
55
56typedef struct chrTemplate_s {
57 char id[MAX_VAR];
58 float rate;
59 int skills[SKILL_NUM_TYPES + 1][2];
61
75typedef 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];
96 int hitsSplashDamage[SKILL_NUM_TYPES][KILLED_NUM_TYPES];
99 int skillKills[SKILL_NUM_TYPES];
101 int heal;
105 init();
106 }
107 inline void init () {
108 OBJZERO(*this);
109 }
111
119typedef 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;
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
150public:
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
186typedef struct chrReservations_s {
187 /* Reaction fire reservation (for current turn and next enemy turn) */
191 /* Crouch reservation (for current turn) */
192 int crouch;
194 /* Shot reservation (for current turn) */
195 int shot;
200 reaction(0),
201 crouch(0),
202 shot(0),
203 shotSettings(FiremodeSettings())
204 {
205 }
207
208typedef enum {
214 RES_TYPES
216
218typedef enum {
222 SND_MAX
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
232typedef enum {
236
240
243
245typedef 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
265
266#define BODYPART_MAXTYPE 4
267
269public:
270 char id[MAX_TEXPATH];
276};
277
278class BodyData {
279private:
284
285public:
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
301typedef struct teamNames_s {
302 char id[MAX_VAR];
304 int numNames[NAME_NUM_TYPES];
306
307typedef 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
315 const int* numNames;
317 struct model_t {
318 char* path;
319 char* body;
320 char* head;
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
361typedef 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 }
370
371#define MAX_CHARACTER_IMPLANTS 4
372typedef struct implant_s {
377
378 inline implant_s () :
379 def(nullptr),
380 installedTime(0),
381 removedTime(0),
382 trigger(0)
383 {
384 }
385} implant_t;
386
388typedef 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];
397 int HP;
398 int minHP;
399 int maxHP;
400 int STUN;
404 int state;
410
414 int gender;
419
421 void init ();
423
424/* ================================ */
425/* CHARACTER GENERATING FUNCTIONS */
426/* ================================ */
427
428const chrTemplate_t* CHRSH_GetTemplateByID(const teamDef_t* teamDef, const char* templateId);
429void CHRSH_CharGenAbilitySkills(character_t* chr, bool multiplayer, const char* templateId = "") __attribute__((nonnull));
430const char* CHRSH_CharGetBody(const character_t* const chr) __attribute__((nonnull));
431const char* CHRSH_CharGetHead(const character_t* const chr) __attribute__((nonnull));
432bool CHRSH_IsTeamDefAlien(const teamDef_t* const td) __attribute__((nonnull));
433bool CHRSH_IsTeamDefRobot(const teamDef_t* const td) __attribute__((nonnull));
434bool CHRSH_IsArmourUseableForTeam(const objDef_t* od, const teamDef_t* teamDef);
435const implant_t* CHRSH_ApplyImplant(character_t& chr, const implantDef_t& implant);
#define MAX_TEMPLATES_PER_TEAM
Definition: chr_shared.h:230
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
#define MAX_CHARACTER_IMPLANTS
Definition: chr_shared.h:371
abilityskills_t
Definition: chr_shared.h:36
@ SKILL_PILOTING
Definition: chr_shared.h:48
@ SKILL_HEAVY
Definition: chr_shared.h:43
@ ABILITY_POWER
Definition: chr_shared.h:37
@ ABILITY_SPEED
Definition: chr_shared.h:38
@ SKILL_NUM_TYPES
Definition: chr_shared.h:51
@ SKILL_EVADING
Definition: chr_shared.h:50
@ SKILL_SNIPER
Definition: chr_shared.h:45
@ ABILITY_MIND
Definition: chr_shared.h:40
@ SKILL_CLOSE
Definition: chr_shared.h:42
@ SKILL_EXPLOSIVE
Definition: chr_shared.h:46
@ SKILL_TARGETING
Definition: chr_shared.h:49
@ ABILITY_ACCURACY
Definition: chr_shared.h:39
@ SKILL_ASSAULT
Definition: chr_shared.h:44
bool CHRSH_IsTeamDefAlien(const teamDef_t *const td) __attribute__((nonnull))
Check if a team definition is alien.
Definition: chr_shared.cpp:83
nametypes_t
Definition: chr_shared.h:232
@ NAME_LAST
Definition: chr_shared.h:237
@ NAME_NUM_TYPES
Definition: chr_shared.h:241
@ NAME_FEMALE_LAST
Definition: chr_shared.h:238
@ NAME_MALE_LAST
Definition: chr_shared.h:239
@ NAME_NEUTRAL
Definition: chr_shared.h:233
@ NAME_MALE
Definition: chr_shared.h:235
@ NAME_FEMALE
Definition: chr_shared.h:234
void CHRSH_UpdateImplants(character_t &chr)
Updates the characters permanent implants. Called every day.
Definition: chr_shared.cpp:140
reservation_types_t
Definition: chr_shared.h:208
@ RES_ALL
Definition: chr_shared.h:212
@ RES_TYPES
Definition: chr_shared.h:214
@ RES_REACTION
Definition: chr_shared.h:209
@ RES_ALL_ACTIVE
Definition: chr_shared.h:213
@ RES_CROUCH
Definition: chr_shared.h:210
@ RES_SHOT
Definition: chr_shared.h:211
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
killtypes_t
Definition: chr_shared.h:27
@ KILLED_TEAM
Definition: chr_shared.h:30
@ KILLED_ENEMIES
Definition: chr_shared.h:28
@ KILLED_CIVILIANS
Definition: chr_shared.h:29
@ KILLED_NUM_TYPES
Definition: chr_shared.h:32
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
bool CHRSH_IsTeamDefRobot(const teamDef_t *const td) __attribute__((nonnull))
Check if a team definition is a robot.
Definition: chr_shared.cpp:103
actorSound_t
Types of actor sounds being issued by CL_ActorPlaySound().
Definition: chr_shared.h:218
@ SND_MAX
Definition: chr_shared.h:222
@ SND_HURT
Definition: chr_shared.h:220
@ SND_DEATH
Definition: chr_shared.h:219
bool CHRSH_IsArmourUseableForTeam(const objDef_t *od, const teamDef_t *teamDef)
Definition: chr_shared.cpp:88
modifier_types_t
Definition: chr_shared.h:255
@ MODIFIER_REACTION
Definition: chr_shared.h:260
@ MODIFIER_ACCURACY
Definition: chr_shared.h:256
@ MODIFIER_SIGHT
Definition: chr_shared.h:259
@ MODIFIER_MOVEMENT
Definition: chr_shared.h:258
@ MODIFIER_TU
Definition: chr_shared.h:261
@ MODIFIER_SHOOTING
Definition: chr_shared.h:257
@ MODIFIER_MAX
Definition: chr_shared.h:263
const implant_t * CHRSH_ApplyImplant(character_t &chr, const implantDef_t &implant)
Add a new implant to a character.
Definition: chr_shared.cpp:180
#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
float getArea(const short bodyPart) const
Definition: chr_shared.cpp:427
void setId(const char *id)
Definition: chr_shared.cpp:394
void addBodyPart(const BodyPartData &bodyPart)
Definition: chr_shared.cpp:399
BodyData(void)
Definition: chr_shared.cpp:336
BodyPartData _bodyParts[BODYPART_MAXTYPE]
Definition: chr_shared.h:281
float woundThreshold(const short bodyPart) const
Definition: chr_shared.cpp:384
const char * name(const short bodyPart) const
Definition: chr_shared.cpp:369
short getHitBodyPart(const byte direction, const float height) const
Definition: chr_shared.cpp:405
short _numBodyParts
Definition: chr_shared.h:283
char _id[MAX_TEXPATH]
Definition: chr_shared.h:280
short numBodyParts(void) const
Definition: chr_shared.cpp:389
float _totalBodyArea
Definition: chr_shared.h:282
float penalty(const short bodyPart, const modifier_types_t type) const
Definition: chr_shared.cpp:374
const char * id(void) const
Definition: chr_shared.cpp:359
float bleedingFactor(const short bodyPart) const
Definition: chr_shared.cpp:379
short getRandomBodyPart(void) const
Definition: chr_shared.cpp:341
char name[MAX_TEXPATH]
Definition: chr_shared.h:271
int penalties[MODIFIER_MAX]
Definition: chr_shared.h:272
int bleedingFactor
Definition: chr_shared.h:274
int woundThreshold
Definition: chr_shared.h:275
vec4_t shape
Definition: chr_shared.h:273
fireDefIndex_t _fmIdx
Definition: chr_shared.h:147
const objDef_t * _weapon
Definition: chr_shared.h:148
void set(const actorHands_t hand, const fireDefIndex_t fmIdx, const objDef_t *weapon)
Definition: chr_shared.h:173
actorHands_t getHand() const
Definition: chr_shared.h:165
const objDef_t * getWeapon() const
Definition: chr_shared.h:161
int getFmIdx() const
Definition: chr_shared.h:157
actorHands_t _hand
Definition: chr_shared.h:146
void setHand(const actorHands_t hand)
Definition: chr_shared.h:169
bool isSaneFiremode() const
Definition: chr_shared.h:153
inventory definition with all its containers
Definition: inv_shared.h:525
#define __attribute__(x)
Definition: cxx.h:37
#define nullptr
Definition: cxx.h:53
#define MAX_TEXPATH
Definition: defines.h:95
int32_t fireDefIndex_t
Definition: inv_shared.h:78
#define MAX_FIREDEFS_PER_WEAPON
Definition: inv_shared.h:42
#define MAX_DAMAGETYPES
Definition: inv_shared.h:258
actorHands_t
Definition: inv_shared.h:626
@ ACTOR_HAND_NOT_SET
Definition: inv_shared.h:627
QGL_EXTERN GLint GLenum type
Definition: r_gl.h:94
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition: r_gl.h:110
#define OBJZERO(obj)
Definition: shared.h:178
#define MAX_VAR
Definition: shared.h:36
Describes a character with all its attributes.
Definition: chr_shared.h:388
chrReservations_t reservedTus
Definition: chr_shared.h:415
const teamDef_t * teamDef
Definition: chr_shared.h:413
chrScoreMission_t * scoreMission
Definition: chr_shared.h:407
chrScoreGlobal_t score
Definition: chr_shared.h:406
FiremodeSettings RFmode
Definition: chr_shared.h:416
actorSizeEnum_t fieldSize
Definition: chr_shared.h:409
woundInfo_t wounds
Definition: chr_shared.h:402
Inventory inv
Definition: chr_shared.h:411
How many TUs (and of what type) did a player reserve for a unit?
Definition: chr_shared.h:186
FiremodeSettings shotSettings
Definition: chr_shared.h:196
Structure of all stats collected for an actor over time.
Definition: chr_shared.h:119
Structure of all stats collected in a mission.
Definition: chr_shared.h:75
int removedTime
Definition: chr_shared.h:375
int trigger
Definition: chr_shared.h:376
const implantDef_t * def
Definition: chr_shared.h:373
int installedTime
Definition: chr_shared.h:374
Defines all attributes of objects used in the inventory.
Definition: inv_shared.h:264
bool robot
Definition: chr_shared.h:333
bool weapons
Definition: chr_shared.h:335
const objDef_t * onlyWeapon
Definition: chr_shared.h:336
const char * getActorSound(int gender, actorSound_t soundType) const
actorSizeEnum_t size
Definition: chr_shared.h:341
const int * numNames
Definition: chr_shared.h:315
linkedList_t *const * names
Definition: chr_shared.h:314
bool armour
Definition: chr_shared.h:334
int numTemplates
Definition: chr_shared.h:348
const BodyData * bodyTemplate
Definition: chr_shared.h:350
Defines a type of UGV/Robot.
Definition: chr_shared.h:245
int price
Definition: chr_shared.h:252
int idx
Definition: chr_shared.h:247
int tu
Definition: chr_shared.h:250
char * id
Definition: chr_shared.h:246
Info on a wound.
Definition: chr_shared.h:361
int32_t actorSizeEnum_t
Definition: ufotypes.h:77
vec_t vec4_t[4]
Definition: ufotypes.h:40