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

Match related functions. More...

#include "g_match.h"
#include "g_local.h"
#include "g_actor.h"
#include "g_ai.h"
#include "g_edicts.h"
#include "g_trigger.h"
#include "g_utils.h"
#include "g_vis.h"
Include dependency graph for g_match.cpp:

Go to the source code of this file.

Functions

static int G_GetEarnedExperience (abilityskills_t skill, Edict *ent)
 Determines the amount of XP earned by a given soldier for a given skill, based on the soldier's performance in the last mission.
static void G_UpdateCharacterExperience (Edict *ent)
 Updates character experience after a mission.
void G_MatchEndTrigger (int team, int timeGap)
 Triggers the end of the game. Will be executed in the next server (or game) frame.
static void G_SendCharacterData (const Actor *actor)
 Sends character stats like assigned missions and kills back to client.
static void G_MatchSendResults (int team, bool nextmap)
 Handles the end of a match.
bool G_MatchDoEnd (void)
 Checks whether a match is over.
void G_MatchEndCheck (void)
 Checks whether there are still actors to fight with left. If none are the match end will be triggered.
bool G_MatchIsRunning (void)
 Checks whether the game is running (active team and no intermission time).

Detailed Description

Match related functions.

Definition in file g_match.cpp.

Function Documentation

◆ G_GetEarnedExperience()

int G_GetEarnedExperience ( abilityskills_t skill,
Edict * ent )
static

Determines the amount of XP earned by a given soldier for a given skill, based on the soldier's performance in the last mission.

Parameters
[in]skillThe skill for which to fetch the maximum amount of XP.
[in]entPointer to the character you want to get the earned experience for
See also
G_UpdateCharacterExperience
G_GetMaxExperiencePerMission

Definition at line 42 of file g_match.cpp.

References ABILITY_ACCURACY, ABILITY_MIND, ABILITY_NUM_TYPES, ABILITY_POWER, chrScoreMission_t::carriedWeight, Edict::chr, GET_ENCUMBRANCE_PENALTY, chrScoreMission_t::hits, chrScoreMission_t::hitsSplash, i, KILLED_ENEMIES, chrScoreMission_t::kills, level, character_t::score, character_t::scoreMission, SKILL_ASSAULT, SKILL_CLOSE, SKILL_EXPLOSIVE, SKILL_HEAVY, SKILL_NUM_TYPES, SKILL_SNIPER, chrScoreGlobal_t::skills, and WEIGHT_FACTOR.

Referenced by G_UpdateCharacterExperience().

◆ G_MatchDoEnd()

bool G_MatchDoEnd ( void )

Checks whether a match is over.

Returns
true if this match is over, false otherwise

Definition at line 253 of file g_match.cpp.

References AIL_Cleanup(), G_MatchSendResults(), G_PrintStats(), gi, and level.

Referenced by G_RunFrame().

◆ G_MatchEndCheck()

void G_MatchEndCheck ( void )

Checks whether there are still actors to fight with left. If none are the match end will be triggered.

See also
G_MatchEndTrigger
Todo
count from 0 to get the civilians for objectives
Todo
< 2 does not work when we count civilians

Definition at line 280 of file g_match.cpp.

References G_EdictsGetNextLivingActorOfTeam(), G_MatchEndTrigger(), i, Actor::isStunned(), level, MAX_TEAMS, and TEAM_ALIEN.

Referenced by G_BleedWounds(), G_ClientDisconnect(), G_ClientMove(), and G_ClientShoot().

◆ G_MatchEndTrigger()

void G_MatchEndTrigger ( int team,
int timeGap )

Triggers the end of the game. Will be executed in the next server (or game) frame.

Parameters
[in]teamThe winning team
[in]timeGapSecond to wait before really ending the game. Useful if you want to allow a last view on the scene

Definition at line 125 of file g_match.cpp.

References G_EdictsGetTriggerNextMaps(), Edict::getTeam(), level, Edict::nextthink, Edict::think, and Think_NextMapTrigger().

Referenced by G_ClientEndRound(), G_MatchEndCheck(), G_MissionThink(), SVCmd_Win_f(), and Touch_NextMapTrigger().

◆ G_MatchIsRunning()

bool G_MatchIsRunning ( void )

Checks whether the game is running (active team and no intermission time).

Returns
true if there is an active team for the current turn and the end of the game was not yet triggered
See also
G_MatchEndTrigger

Definition at line 320 of file g_match.cpp.

References level, and TEAM_NO_ACTIVE.

Referenced by Door_Use(), G_CheckForceEndRound(), G_ClientEndRound(), G_ClientUserinfoChanged(), G_GetStartingTeam(), G_MissionThink(), G_ReactionFireCanBeEnabled(), and G_RunFrame().

◆ G_MatchSendResults()

void G_MatchSendResults ( int team,
bool nextmap )
static

Handles the end of a match.

Parameters
[in]teamThe winning team number
[in]nextmapIs there a follow-up map within the same match ?
See also
G_RunFrame
CL_ParseResults

Definition at line 184 of file g_match.cpp.

References EV_RESULTS, G_ActorDieOrStun(), G_EdictsGetNextActor(), G_EdictsGetNextLivingActor(), G_EventAdd(), G_EventEnd(), G_IsAI, G_SendCharacterData(), G_UpdateCharacterExperience(), G_VisMakeEverythingVisible(), Edict::getTeam(), gi, Edict::HP, i, Actor::isInRescueZone(), level, MAX_TEAMS, PM_ALL, and TEAM_ALIEN.

Referenced by G_MatchDoEnd().

◆ G_SendCharacterData()

void G_SendCharacterData ( const Actor * actor)
static

Sends character stats like assigned missions and kills back to client.

Parameters
[in]actorThe edict to send the data for
Note
first short is the ucn to allow the client to identify the character
parsed in GAME_CP_Results
See also
GAME_SendCurrentTeamSpawningInfo
Note
you also have to update the pascal string size in G_MatchSendResults if you change the buffer here

Scores

See also
inv_shared.h:chrScoreGlobal_t

Definition at line 153 of file g_match.cpp.

References chrScoreGlobal_t::assignedMissions, BODYPART_MAXTYPE, Edict::chr, chrScoreGlobal_t::experience, Edict::getStun(), gi, Edict::HP, KILLED_NUM_TYPES, chrScoreGlobal_t::kills, Edict::morale, character_t::score, SKILL_NUM_TYPES, chrScoreGlobal_t::stuns, woundInfo_t::treatmentLevel, character_t::ucn, woundInfo_t::woundLevel, and character_t::wounds.

Referenced by G_MatchSendResults().

◆ G_UpdateCharacterExperience()

void G_UpdateCharacterExperience ( Edict * ent)
static

Updates character experience after a mission.

Parameters
[in,out]entPointer to the character that should get the experience updated
See also
CHAR_UpdateStats
G_UpdateCharacterScore
G_UpdateHitScore

Definition at line 97 of file g_match.cpp.

References ABILITY_SPEED, Edict::chr, chrScoreGlobal_t::experience, G_GetEarnedExperience(), i, teamDef_t::robot, character_t::score, SKILL_NUM_TYPES, and character_t::teamDef.

Referenced by G_MatchSendResults().