UFO: Alien Invasion
Loading...
Searching...
No Matches
chr_shared.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
34
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
111
119typedef struct chrScoreGlobal_s {
121
124
125 /* Kills & Stuns */
128
130
131 int rank;
132
135 rank(0)
136 {
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) */
190
191 /* Crouch reservation (for current turn) */
192 int crouch;
193
194 /* Shot reservation (for current turn) */
195 int shot;
198
200 reaction(0),
201 crouch(0),
202 shot(0),
204 {
205 }
207
216
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
243
245typedef struct ugv_s {
246 char* id;
247 int idx;
250 int tu;
252 int price;
253} ugv_t;
254
265
266#define BODYPART_MAXTYPE 4
267
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];
306
307typedef struct teamDef_s {
308 int idx;
309 char id[MAX_VAR];
310 char name[MAX_VAR];
311 char tech[MAX_VAR];
313
315 const int* numNames;
316
317 struct model_t {
318 char* path;
319 char* body;
320 char* head;
323 };
324
327
330
331 int team;
332
333 bool robot;
334 bool armour;
335 bool weapons;
340
344
346
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
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
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);
const implant_t * CHRSH_ApplyImplant(character_t &chr, const implantDef_t &def)
Add a new implant to a character.
bool CHRSH_IsTeamDefRobot(const teamDef_t *const td)
Check if a team definition is a robot.
bool CHRSH_IsTeamDefAlien(const teamDef_t *const td)
Check if a team definition is alien.
const char * CHRSH_CharGetBody(const character_t *const chr)
Returns the body model for the soldiers for armoured and non armoured soldiers.
void CHRSH_UpdateImplants(character_t &chr)
Updates the characters permanent implants. Called every day.
bool CHRSH_IsArmourUseableForTeam(const objDef_t *od, const teamDef_t *teamDef)
const char * CHRSH_CharGetHead(const character_t *const chr)
Returns the head model for the soldiers for armoured and non armoured soldiers.
#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.
#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
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
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
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
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
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
#define BODYPART_MAXTYPE
Definition chr_shared.h:266
const chrTemplate_t * CHRSH_GetTemplateByID(const teamDef_t *teamDef, const char *templateId)
float getArea(const short bodyPart) const
void setId(const char *id)
void addBodyPart(const BodyPartData &bodyPart)
BodyData(void)
BodyPartData _bodyParts[BODYPART_MAXTYPE]
Definition chr_shared.h:281
float woundThreshold(const short bodyPart) const
short getHitBodyPart(const byte direction, const float height) const
short _numBodyParts
Definition chr_shared.h:283
char _id[MAX_TEXPATH]
Definition chr_shared.h:280
short numBodyParts(void) const
float _totalBodyArea
Definition chr_shared.h:282
float penalty(const short bodyPart, const modifier_types_t type) const
const char * id(void) const
float bleedingFactor(const short bodyPart) const
short getRandomBodyPart(void) const
char name[MAX_TEXPATH]
Definition chr_shared.h:271
int penalties[MODIFIER_MAX]
Definition chr_shared.h:272
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
char head[MAX_VAR]
Definition chr_shared.h:393
char path[MAX_VAR]
Definition chr_shared.h:391
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
char body[MAX_VAR]
Definition chr_shared.h:392
char name[MAX_VAR]
Definition chr_shared.h:390
Inventory inv
Definition chr_shared.h:411
implant_t implants[MAX_CHARACTER_IMPLANTS]
Definition chr_shared.h:418
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
int initialSkills[SKILL_NUM_TYPES+1]
Definition chr_shared.h:123
int stuns[KILLED_NUM_TYPES]
Definition chr_shared.h:127
int kills[KILLED_NUM_TYPES]
Definition chr_shared.h:126
int skills[SKILL_NUM_TYPES]
Definition chr_shared.h:122
int experience[SKILL_NUM_TYPES+1]
Definition chr_shared.h:120
Structure of all stats collected in a mission.
Definition chr_shared.h:75
int hitsSplashDamage[SKILL_NUM_TYPES][KILLED_NUM_TYPES]
Definition chr_shared.h:96
int fired[SKILL_NUM_TYPES]
Definition chr_shared.h:86
int firedSplash[SKILL_NUM_TYPES]
Definition chr_shared.h:92
bool firedHit[KILLED_NUM_TYPES]
Definition chr_shared.h:88
int hitsSplash[SKILL_NUM_TYPES][KILLED_NUM_TYPES]
Definition chr_shared.h:95
int hits[SKILL_NUM_TYPES][KILLED_NUM_TYPES]
Definition chr_shared.h:89
int firedTUs[SKILL_NUM_TYPES]
Definition chr_shared.h:87
int stuns[KILLED_NUM_TYPES]
Definition chr_shared.h:83
int skillKills[SKILL_NUM_TYPES]
Definition chr_shared.h:99
int kills[KILLED_NUM_TYPES]
Definition chr_shared.h:82
bool firedSplashHit[KILLED_NUM_TYPES]
Definition chr_shared.h:94
int firedSplashTUs[SKILL_NUM_TYPES]
Definition chr_shared.h:93
int skills[SKILL_NUM_TYPES+1][2]
Definition chr_shared.h:59
int removedTime
Definition chr_shared.h:375
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 weapons
Definition chr_shared.h:335
short resistance[MAX_DAMAGETYPES]
Definition chr_shared.h:345
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
int numSounds[SND_MAX][NAME_LAST]
Definition chr_shared.h:329
linkedList_t *const * names
Definition chr_shared.h:314
int numModels[NAME_LAST]
Definition chr_shared.h:326
linkedList_t * sounds[SND_MAX][NAME_LAST]
Definition chr_shared.h:328
const chrTemplate_t * characterTemplates[MAX_TEMPLATES_PER_TEAM]
Definition chr_shared.h:347
char deathTextureName[MAX_VAR]
Definition chr_shared.h:343
linkedList_t * models[NAME_LAST]
Definition chr_shared.h:325
char tech[MAX_VAR]
Definition chr_shared.h:311
bool armour
Definition chr_shared.h:334
int numTemplates
Definition chr_shared.h:348
char hitParticle[MAX_VAR]
Definition chr_shared.h:342
char footstepSound[MAX_VAR]
Definition chr_shared.h:312
const BodyData * bodyTemplate
Definition chr_shared.h:350
char name[MAX_VAR]
Definition chr_shared.h:310
linkedList_t * names[NAME_NUM_TYPES]
Definition chr_shared.h:303
int numNames[NAME_NUM_TYPES]
Definition chr_shared.h:304
Defines a type of UGV/Robot.
Definition chr_shared.h:245
int price
Definition chr_shared.h:252
char weapon[MAX_VAR]
Definition chr_shared.h:248
int idx
Definition chr_shared.h:247
int tu
Definition chr_shared.h:250
char actors[MAX_VAR]
Definition chr_shared.h:251
char armour[MAX_VAR]
Definition chr_shared.h:249
char * id
Definition chr_shared.h:246
Info on a wound.
Definition chr_shared.h:361
int woundLevel[BODYPART_MAXTYPE]
Definition chr_shared.h:362
int treatmentLevel[BODYPART_MAXTYPE]
Definition chr_shared.h:363
int32_t actorSizeEnum_t
Definition ufotypes.h:77
vec_t vec4_t[4]
Definition ufotypes.h:40