UFO: Alien Invasion
Loading...
Searching...
No Matches
cp_character.cpp File Reference

Character (soldier, alien) related campaign functions. More...

#include "../../cl_shared.h"
#include "cp_character.h"
#include "cp_campaign.h"
Include dependency graph for cp_character.cpp:

Go to the source code of this file.

Data Structures

struct  updateCharacter_t

Functions

int CHAR_GetMaxExperiencePerMission (const abilityskills_t skill)
 Determines the maximum amount of XP per skill that can be gained from any one mission.
void CHAR_UpdateSkills (character_t *chr)
 Updates the character skills after a mission.
void CHAR_UpdateData (linkedList_t *updateCharacters)
 Transforms the battlescape values to the character.
void CHAR_ParseData (dbuffer *msg, linkedList_t **updateCharacters)
 Parses the character data which was send by G_MatchSendResults using G_SendCharacterData.
static bool CHAR_ShouldUpdateSoldierRank (const rank_t *rank, const character_t *chr)
 Checks whether a soldier should be promoted.
void CHAR_UpdateStats (const base_t *base, const aircraft_t *aircraft)
 Update employees stats after mission.
void CHAR_InitStartup (void)
 Campaign initialization actions for the character module.
void CHAR_Shutdown (void)
 Campaign closing actions for the character module.

Detailed Description

Character (soldier, alien) related campaign functions.

Definition in file cp_character.cpp.

Function Documentation

◆ CHAR_GetMaxExperiencePerMission()

int CHAR_GetMaxExperiencePerMission ( const abilityskills_t skill)

Determines the maximum amount of XP per skill that can be gained from any one mission.

Parameters
[in]skillThe skill for which to fetch the maximum amount of XP.
See also
G_UpdateCharacterExperience
G_GetEarnedExperience
Note
Explanation of the values here: There is a maximum speed at which skills may rise over the course of the predicted career length of a veteran soldier. Because the increase is given as experience^0.6, that means that the maximum XP cap x per mission is given as log predictedStatGrowth / log x = 0.6 log x = log predictedStatGrowth / 0.6 x = 10 ^ (log predictedStatGrowth / 0.6)

Definition at line 55 of file cp_character.cpp.

References ABILITY_ACCURACY, ABILITY_MIND, ABILITY_POWER, ABILITY_SPEED, cgi, ERR_DROP, SKILL_ASSAULT, SKILL_CLOSE, SKILL_EVADING, SKILL_EXPLOSIVE, SKILL_HEAVY, SKILL_NUM_TYPES, SKILL_PILOTING, SKILL_SNIPER, and SKILL_TARGETING.

Referenced by AM_UpdateSurivorsAfterBattle(), and CHAR_UpdateData().

◆ CHAR_InitStartup()

void CHAR_InitStartup ( void )

Campaign initialization actions for the character module.

Definition at line 288 of file cp_character.cpp.

References cgi.

Referenced by CP_InitStartup().

◆ CHAR_ParseData()

void CHAR_ParseData ( dbuffer * msg,
linkedList_t ** updateCharacters )

Parses the character data which was send by G_MatchSendResults using G_SendCharacterData.

Parameters
[in]msgThe network buffer message. If this is nullptr the character is updated, if this is not nullptr the data is stored in a temp buffer because the player can choose to retry the mission and we have to catch this situation to not update the character data in this case.
updateCharactersA LinkedList where to store the character data. One listitem per character.
See also
G_SendCharacterData
GAME_SendCurrentTeamSpawningInfo
E_Save

Definition at line 151 of file cp_character.cpp.

References chrScoreGlobal_t::assignedMissions, BODYPART_MAXTYPE, cgi, updateCharacter_t::chrscore, ERR_DROP, chrScoreGlobal_t::experience, updateCharacter_t::HP, i, KILLED_NUM_TYPES, chrScoreGlobal_t::kills, LIST_Add(), updateCharacter_t::morale, SKILL_NUM_TYPES, updateCharacter_t::STUN, chrScoreGlobal_t::stuns, woundInfo_t::treatmentLevel, updateCharacter_t::ucn, and updateCharacter_t::wounds.

Referenced by GAME_CP_Results().

◆ CHAR_ShouldUpdateSoldierRank()

bool CHAR_ShouldUpdateSoldierRank ( const rank_t * rank,
const character_t * chr )
static

Checks whether a soldier should be promoted.

Parameters
[in]rankThe rank to check for
[in]chrThe character to check a potential promotion for
Todo
(Zenerka 20080301) extend ranks and change calculations here.

Definition at line 186 of file cp_character.cpp.

References ABILITY_MIND, EMPL_SOLDIER, KILLED_CIVILIANS, KILLED_ENEMIES, KILLED_TEAM, rank_t::killedEnemies, rank_t::killedOthers, chrScoreGlobal_t::kills, rank_t::mind, character_t::score, chrScoreGlobal_t::skills, and rank_t::type.

Referenced by CHAR_UpdateStats().

◆ CHAR_Shutdown()

void CHAR_Shutdown ( void )

Campaign closing actions for the character module.

Definition at line 298 of file cp_character.cpp.

References cgi.

Referenced by CP_Shutdown().

◆ CHAR_UpdateData()

◆ CHAR_UpdateSkills()

void CHAR_UpdateSkills ( character_t * chr)

Updates the character skills after a mission.

Parameters
[in,out]chrPointer to the character that should get the skills updated.

Definition at line 92 of file cp_character.cpp.

References chrScoreGlobal_t::experience, i, chrScoreGlobal_t::initialSkills, MAX_MAXHP, MAX_SKILL, character_t::maxHP, character_t::score, SKILL_NUM_TYPES, and chrScoreGlobal_t::skills.

Referenced by AM_UpdateSurivorsAfterBattle(), and CHAR_UpdateData().

◆ CHAR_UpdateStats()

void CHAR_UpdateStats ( const base_t * base,
const aircraft_t * aircraft )

Update employees stats after mission.

Parameters
[in]baseThe base where the team lives.
[in]aircraftThe aircraft used for the mission.
Note
Soldier promotion is being done here.
Todo
use chrScore_t to determine negative influence on soldier here, like killing too many civilians and teammates can lead to unhire and disband such soldier, or maybe rank degradation.

Definition at line 212 of file cp_character.cpp.

References _, AIR_IsEmployeeInAircraft(), chrScoreGlobal_t::assignedMissions, ccs, cgi, CHAR_ShouldUpdateSoldierRank(), CL_GetRankByIdx(), Com_sprintf(), cp_messageBuffer, DEBUG_CLIENT, E_Foreach, EMPL_SOLDIER, aircraft_t::homebase, character_t::HP, MS_AddNewMessage(), MSG_PROMOTION, character_t::name, rank_t::name, chrScoreGlobal_t::rank, and character_t::score.

Referenced by CP_MissionEnd().