UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
g_combat.cpp File Reference

All parts of the main game logic that are combat related. More...

#include "g_combat.h"
#include "g_actor.h"
#include "g_client.h"
#include "g_edicts.h"
#include "g_health.h"
#include "g_inventory.h"
#include "g_match.h"
#include "g_reaction.h"
#include "g_spawn.h"
#include "g_utils.h"
#include "g_vis.h"

Go to the source code of this file.

Macros

#define MAX_WALL_THICKNESS_FOR_SHOOTING_THROUGH   8
 
#define GRENADE_DT   0.1f
 
#define GRENADE_STOPSPEED   60.0f
 

Enumerations

enum  morale_modifiers { ML_SHOOT, ML_WOUND, ML_DEATH }
 

Functions

static bool G_TeamPointVis (int team, const vec3_t point)
 Test if point is "visible" from team. More...
 
static void G_Morale (morale_modifiers type, const Edict *victim, const Edict *attacker, int param)
 Applies morale changes to actors around a wounded or killed actor. More...
 
static void G_ShotMorale (const Actor *shooter, const fireDef_t *fd, const vec3_t from, const Item *weapon, const vec3_t impact)
 Applies morale changes to actors who find themselves in the general direction of a shot. More...
 
static void G_UpdateShotMock (shot_mock_t *mock, const Edict *shooter, const Edict *struck, int damage)
 Function to calculate possible damages for mock pseudoaction. More...
 
static void G_UpdateCharacterBodycount (Edict *attacker, const fireDef_t *fd, const Actor *target)
 Update character stats for this mission after successful shoot. More...
 
static void G_UpdateHitScore (Edict *attacker, const Edict *target, const fireDef_t *fd, const int splashDamage)
 Increases the 'hit' score by one for all affected teams/skills by one (except splash damage, read below). More...
 
int G_ApplyProtection (const Edict *target, const byte dmgWeight, int damage)
 Reduces damage by armour and natural protection. More...
 
static bool G_Damage (Edict *target, const fireDef_t *fd, int damage, Actor *attacker, shot_mock_t *mock, const vec3_t impact)
 Deals damage of a give type and amount to a target. More...
 
void G_CheckDeathOrKnockout (Actor *target, Actor *attacker, const fireDef_t *fd, int damage)
 
static bool G_FireAffectedSurface (const cBspSurface_t *surface, const fireDef_t *fd)
 Checks surface vulnerability for firedefinition damagetype. More...
 
static void G_SplashDamage (Actor *ent, const fireDef_t *fd, vec3_t impact, shot_mock_t *mock, const trace_t *tr)
 Deals splash damage to a target and its surroundings. More...
 
static void G_SpawnItemOnFloor (const pos3_t pos, const Item *item)
 Spawn an item on the floor. A new ET_ITEM edict is created if needed. More...
 
void G_CalcEffectiveSpread (const Actor *shooter, const fireDef_t *fd, vec2_t effSpread)
 Calculate the effective spread for the given actor and firemode. More...
 
static void G_ShootGrenade (const Player &player, Actor *shooter, const fireDef_t *fd, const vec3_t from, const pos3_t at, int mask, const Item *weapon, shot_mock_t *mock, int z_align, vec3_t impact)
 A parabola-type shoot (grenade, throw). More...
 
static void G_ShootSingle (Actor *ent, const fireDef_t *fd, const vec3_t from, const pos3_t at, int mask, const Item *weapon, shot_mock_t *mock, int z_align, int i, shoot_types_t shootType, vec3_t impact)
 Fires straight shots. More...
 
static bool G_PrepareShot (Edict *ent, shoot_types_t shootType, fireDefIndex_t firemode, Item **weapon, containerIndex_t *container, const fireDef_t **fd)
 Prepares weapon, firemode and container used for shoot. More...
 
bool G_ClientShoot (const Player &player, Actor *actor, const pos3_t at, shoot_types_t shootType, fireDefIndex_t firemode, shot_mock_t *mock, bool allowReaction, int z_align)
 Setup for shooting, either real or mock. More...
 

Detailed Description

All parts of the main game logic that are combat related.

Definition in file g_combat.cpp.

Macro Definition Documentation

#define GRENADE_DT   0.1f

Definition at line 690 of file g_combat.cpp.

Referenced by G_ShootGrenade().

#define GRENADE_STOPSPEED   60.0f

Definition at line 691 of file g_combat.cpp.

Referenced by G_ShootGrenade().

#define MAX_WALL_THICKNESS_FOR_SHOOTING_THROUGH   8

Definition at line 38 of file g_combat.cpp.

Referenced by G_ShootSingle().

Enumeration Type Documentation

Enumerator
ML_SHOOT 
ML_WOUND 
ML_DEATH 

Definition at line 40 of file g_combat.cpp.

Function Documentation

int G_ApplyProtection ( const Edict target,
const byte  dmgWeight,
int  damage 
)

Reduces damage by armour and natural protection.

Parameters
[in]targetWhat we want to damage.
[in]dmgWeightThe type of damage is dealt.
[in]damageThe value of the damage.
Returns
The new amount of damage after applying armour and resistance.

Definition at line 362 of file g_combat.cpp.

References Edict::chr, Item::def(), Edict::getArmour(), objDef_s::protection, teamDef_s::resistance, and character_s::teamDef.

Referenced by AI_CheckPosition(), G_Damage(), G_SplashDamage(), and Touch_HurtTrigger().

void G_CalcEffectiveSpread ( const Actor shooter,
const fireDef_t fd,
vec2_t  effSpread 
)

Calculate the effective spread for the given actor and firemode.

Parameters
[in]shooterThe shooting actor
[in]fdThe firedefinition the actor is shooting with
[out]effSpreadThe adjusted spread

Definition at line 671 of file g_combat.cpp.

References ABILITY_ACCURACY, Edict::chr, fireDef_s::crouch, f, G_ActorGetInjuryPenalty(), GET_ACC, Actor::isCrouched(), MODIFIER_ACCURACY, PITCH, character_s::score, SKILL_BALANCE, chrScoreGlobal_s::skills, fireDef_s::spread, WEAPON_BALANCE, fireDef_s::weaponSkill, and YAW.

Referenced by AI_FighterCheckShoot(), G_ShootGrenade(), and G_ShootSingle().

bool G_ClientShoot ( const Player &  player,
Actor actor,
const pos3_t  at,
shoot_types_t  shootType,
fireDefIndex_t  firemode,
shot_mock_t mock,
bool  allowReaction,
int  z_align 
)

Setup for shooting, either real or mock.

Parameters
[in]playerThe player this action belongs to (i.e. either the ai or the player)
[in]actorthe edict that is doing the shot
[in]atPosition to fire on.
[in]shootTypeWhat type of shot this is (left, right reaction-left etc...).
[in]firemodeThe firemode index of the ammo for the used weapon.
[in]mockpseudo shooting - only for calculating mock values - nullptr for real shots
[in]allowReactionSet to true to check whether this has forced any reaction fire, otherwise false.
Returns
true if everything went ok (i.e. the shot(s) where fired ok), otherwise false.
Parameters
[in]z_alignThis value may change the target z height - often GROUND_DELTA is used to calculate the alignment. This can be used for splash damage weapons. It's often useful to target the ground close to the victim. That way you don't need a 100 percent chance to hit your target. Even if you don't hit it, the splash damage might reduce the health of your target.
Todo:
check for direct shot / splash damage shot?

Reset status.

See also
G_UpdateHitScore for the check.

Reset status.

See also
G_UpdateHitScore for the check.

If loaded ammo is less than needed ammo from firedef then reduce shot-number relative to the difference.

Todo:
This really needs an overhaul.And it might get dumped completely when Feature Request "[1814158] Extended shot-definitions in firedef" https://sourceforge.net/tracker/?func=detail&atid=805245&aid=1814158&group_id=157793 gets implemented.

Definition at line 1183 of file g_combat.cpp.

References _, fireDef_s::ammo, Item::ammoDef(), AngleToDir(), Edict::chr, CORE_DIRECTIONS, crand(), game_import_s::csi, fireDef_s::damage, csi_s::damIncendiary, csi_s::damNormal, csi_s::damSmoke, csi_s::damStunGas, Item::def(), objDef_s::deplete, Edict::dir, objDef_s::dmgtype, fireDef_s::dmgweight, InventoryInterface::emptyContainer(), ET_ACTOR, ET_FIRE, ET_SMOKE, ET_SMOKESTUN, f, Edict::fieldSize, chrScoreMission_s::fired, chrScoreMission_s::firedHit, chrScoreMission_s::firedSplash, chrScoreMission_s::firedSplashHit, chrScoreMission_s::firedSplashTUs, chrScoreMission_s::firedTUs, FIRESH_IsMedikit, objDef_s::fireTwoHanded, G_ActionCheckForCurrentTeam(), G_ActionCheckForReaction(), G_ActorGetModifiedTimeForFiredef(), G_ActorSetTU(), G_CheckVisTeamAll(), G_ClientPrintf(), G_EdictsGetLivingActorFromPos(), G_EventActorTurn(), G_EventEnd(), G_EventEndShoot(), G_EventInventoryAmmo(), G_EventInventoryDelete(), G_EventShootHidden(), G_EventStartShoot(), G_FindRadius(), G_IsActorWounded(), G_IsAIPlayer, G_IsVisibleForTeam, G_MatchEndCheck(), G_PrepareShot(), G_ReactionFirePostShot(), G_ReactionFirePreShot(), G_ReactionFireSettingsUpdate(), G_SendStats(), G_ShootGrenade(), G_ShootSingle(), G_ShotMorale(), G_SpawnFireField(), G_SpawnSmokeField(), G_SpawnStunSmokeField(), G_TeamPointVis(), G_TeamToVisMask, G_TouchTriggers(), G_VisToPM(), game, Item::getAmmoLeft(), FiremodeSettings::getFmIdx(), FiremodeSettings::getHand(), Edict::getLeftHandItem(), fireDef_s::getShotOrigin(), Edict::getTeam(), Edict::getTus(), FiremodeSettings::getWeapon(), gi, fireDef_s::gravity, i, objDef_s::id, invDef_s::id, cvar_s::integer, Edict::inuse, character_s::inv, INVDEF, game_locals_s::invi, fireDef_s::irgoggles, Actor::isCrouched(), Actor::isDead(), Edict::isSamePosAs(), Actor::isStunned(), KILLED_NUM_TYPES, MAX_TEAMS, mor_panic, fireDef_s::obj, objDef_s::oneshot, Edict::origin, Edict::pos, PRINT_HUD, fireDef_s::range, character_s::RFmode, fireDef_s::rounds, character_s::scoreMission, Item::setAmmoLeft(), fireDef_s::shots, invDef_s::single, fireDef_s::splrad, objDef_s::thrown, todeg, type, VectorDist, VectorMA(), VectorSubtract, Edict::visflags, and fireDef_s::weaponSkill.

Referenced by actorL_shoot(), actorL_throwgrenade(), AI_ActorThink(), AI_CalcShotDamage(), G_ClientAction(), and ReactionFire::shoot().

static bool G_Damage ( Edict target,
const fireDef_t fd,
int  damage,
Actor attacker,
shot_mock_t mock,
const vec3_t  impact 
)
static

Deals damage of a give type and amount to a target.

Parameters
[in,out]targetWhat we want to damage.
[in]fdThe fire definition that defines what type of damage is dealt.
[in]damageThe value of the damage.
[in]attackerThe attacker.
[in]mockpseudo shooting - only for calculating mock values - nullptr for real shots
[in]impactimpact location - nullptr for splash damage
Returns
true if damage could be dealt (even if it was 0) false otherwise
See also
G_SplashDamage
G_TakeDamage
G_PrintActorStats
Todo:
there should be a possible protection, too

< Check for >0 and splrad to not count this as direct hit.

Definition at line 389 of file g_combat.cpp.

References Edict::addStun(), Edict::chr, CHRSH_IsTeamDefRobot(), Com_DPrintf(), chrReservations_s::crouch, game_import_s::csi, csi_s::damShock, csi_s::damSmoke, csi_s::damStunElectro, csi_s::damStunGas, DEBUG_GAME, Edict::destroy, objDef_s::dmgtype, fireDef_s::dmgweight, f, G_ActorReserveTUs(), G_ActorSetTU(), G_ApplyProtection(), G_CheckDeathOrKnockout(), G_CheckVis(), G_CheckVisTeamAll(), G_DamageActor(), g_difficulty, G_EventSendState(), G_IsAlien, G_IsBreakable, G_IsBrushModel, G_IsLivingActor(), G_IsSinglePlayer, g_nodamage, G_SendStats(), G_TakeDamage(), G_TreatActor(), G_UpdateHitScore(), G_UpdateShotMock(), G_VisToPM(), Edict::getTeam(), gi, Edict::HP, cvar_s::integer, Edict::isSameTeamAs(), makeActor(), MAX_TEAMS, fireDef_s::obj, Actor::removeReaction(), character_s::reservedTus, Actor::setDazed(), chrReservations_s::shot, fireDef_s::splrad, character_s::teamDef, cvar_s::value, and Edict::visflags.

Referenced by G_ShootSingle(), and G_SplashDamage().

static bool G_FireAffectedSurface ( const cBspSurface_t surface,
const fireDef_t fd 
)
inlinestatic

Checks surface vulnerability for firedefinition damagetype.

Returns
True if the surface has the fireaffected flag set and the firedef might produce fire (e.g. flamer)
Parameters
[in]surfaceThe collision surface to check the surface flag for
[in]fdThe firedef to check the dmgtype for
Todo:
Such function should check notonly fire - it should be generic function to check surface vulnerability for given damagetype.

Definition at line 536 of file g_combat.cpp.

References game_import_s::csi, csi_s::damBlast, csi_s::damFire, csi_s::damIncendiary, objDef_s::dmgtype, gi, fireDef_s::obj, SURF_BURN, and cBspSurface_s::surfaceFlags.

Referenced by G_ShootSingle(), and G_SplashDamage().

static void G_Morale ( morale_modifiers  type,
const Edict victim,
const Edict attacker,
int  param 
)
static

Applies morale changes to actors around a wounded or killed actor.

Note
only called when mor_panic is not zero
Parameters
[in]typeType of morale modifier (
See also
morale_modifiers)
Parameters
[in]victimAn actor being a victim of the attack.
[in]attackerAn actor being attacker in this attack.
[in]paramUsed to modify morale changes, for G_Damage() it is value of damage.
See also
G_Damage

Definition at line 98 of file g_combat.cpp.

References ABILITY_MIND, Edict::chr, ET_ACTOR, f, G_ActorVis(), G_EdictsGetNextLivingActor(), G_FrustumVis(), G_IsAlien, G_IsCivilian, G_IsSinglePlayer, G_SendStats(), GET_MORALE, Edict::getTeam(), int(), Edict::isSameTeamAs(), level, ML_DEATH, ML_SHOOT, mob_death, mob_shoot, mob_wound, mof_civilian, mof_enemy, mof_teamkill, mof_watching, mon_teamfactor, mor_attacker, mor_default, mor_distance, mor_pain, mor_victim, Edict::morale, MORALE_RANDOM, level_locals_s::num_alive, level_locals_s::num_spawned, Edict::origin, character_s::score, Edict::setMorale(), chrScoreGlobal_s::skills, Edict::type, cvar_s::value, and VectorDist.

Referenced by G_CheckDeathOrKnockout(), and G_ShotMorale().

static bool G_PrepareShot ( Edict ent,
shoot_types_t  shootType,
fireDefIndex_t  firemode,
Item **  weapon,
containerIndex_t container,
const fireDef_t **  fd 
)
static

Prepares weapon, firemode and container used for shoot.

Parameters
[in]entPointer to attacker.
[in]shootTypeType of shot.
[in]firemodeAn index of used firemode.
[in,out]weaponWeapon being used. It is nullptr when calling this function.
[in,out]containerContainer with weapon being used. It is 0 when calling this function.
[in,out]fdFiremode being used. It is nullptr when calling this function.
Returns
true if function is able to check and set everything correctly.
See also
G_ClientShoot

Definition at line 1132 of file g_combat.cpp.

References Edict::chr, CID_HEADGEAR, CID_LEFT, CID_RIGHT, Item::getFiredefs(), Inventory::getHeadgear(), Edict::getLeftHandItem(), Edict::getRightHandItem(), gi, character_s::inv, IS_SHOT_HEADGEAR, IS_SHOT_RIGHT, and ST_NUM_SHOOT_TYPES.

Referenced by G_ClientShoot().

static void G_ShootGrenade ( const Player &  player,
Actor shooter,
const fireDef_t fd,
const vec3_t  from,
const pos3_t  at,
int  mask,
const Item weapon,
shot_mock_t mock,
int  z_align,
vec3_t  impact 
)
static

A parabola-type shoot (grenade, throw).

See also
G_ShootSingle
Com_GrenadeTarget
Parameters
[in]playerThe shooting player
[in]shooterThe shooting actor
[in]fdThe firedefinition the actor is shooting with
[in]fromThe position the actor is shooting from
[in]atThe grid position the actor is shooting to (or trying to shoot to)
[in]maskThe team visibility mask (who's seeing the event)
[in]weaponThe weapon to shoot with
[in]mockpseudo shooting - only for calculating mock values - nullptr for real shots
[in]z_alignThis value may change the target z height
[out]impactThe location of the target (-center?)

Definition at line 707 of file g_combat.cpp.

References _, level_locals_s::activeTeam, fireDef_s::ammo, AngleVectors(), fireDef_s::bounce, fireDef_s::bounceFac, Item::def(), fireDef_s::delay, DotProduct, trace_s::endpos, trace_s::entNum, Edict::fieldSize, trace_s::fraction, G_CalcEffectiveSpread(), G_ClientPrintf(), G_EdictsGetByNum(), G_EventShootHidden(), G_EventThrow(), G_IsActor, G_IsCivilian, G_IsCrouched, G_SpawnItemOnFloor(), G_SplashDamage(), G_TeamPointVis(), G_Trace(), gaussrand(), gi, GRAVITY, GRENADE_DT, GRENADE_STOPSPEED, GROUND_DELTA, i, Actor::isDead(), Edict::isSameTeamAs(), fireDef_s::launched, level, MASK_SHOT, MAX_TEAMS, cBspSurface_s::name, oldPos, PITCH, trace_s::plane, PRINT_HUD, fireDef_s::range, fireDef_s::rolled, SF_BODY, SF_BOUNCED, SF_BOUNCING, SF_IMPACT, fireDef_s::splrad, trace_s::surface, objDef_s::thrown, tr, VecToAngles(), VecToPos, VectorAdd, VectorCopy, VectorLength(), VectorMA(), VectorScale, and YAW.

Referenced by G_ClientShoot().

static void G_ShootSingle ( Actor ent,
const fireDef_t fd,
const vec3_t  from,
const pos3_t  at,
int  mask,
const Item weapon,
shot_mock_t mock,
int  z_align,
int  i,
shoot_types_t  shootType,
vec3_t  impact 
)
static

Fires straight shots.

Parameters
[in]entThe attacker.
[in]fdThe fire definition that is used for the shot.
[in]fromLocation of the gun muzzle.
[in]atGrid coordinate of the target.
[in]maskVisibility bit-mask (who's seeing the event)
[in]weaponThe weapon the actor is shooting with
[in]mockpseudo shooting - only for calculating mock values - nullptr for real shots
[in]z_alignThis value may change the target z height
[in]iThe ith shot
[in]shootTypeThe firemode (ST_NUM_SHOOT_TYPES)
[out]impactThe location of the target (-center?)
See also
CL_TargetingStraight
Todo:
reduce even more if the wall was hit far away and not close by the shooting actor

Definition at line 930 of file g_combat.cpp.

References fireDef_s::ammo, AngleVectors(), fireDef_s::bounce, Com_DPrintf(), trace_s::contentFlags, CONTENTS_SOLID, crand(), fireDef_s::damage, DEBUG_GAME, Item::def(), fireDef_s::delay, objDef_s::deplete, DotProduct, trace_s::endpos, trace_s::entNum, f, Edict::fieldSize, FIRESH_IsMedikit, trace_s::fraction, G_CalcEffectiveSpread(), G_Damage(), G_EdictsGetByNum(), G_EventShoot(), G_EventShootHidden(), G_FireAffectedSurface(), G_IsActor, G_IsBreakable, G_IsCivilian, G_IsCrouched, G_SpawnItemOnFloor(), G_SpawnParticle(), G_SplashDamage(), G_TeamToVisMask, G_Trace(), G_UpdateHitScore(), gaussrand(), Edict::getTeam(), gi, Actor::isDead(), Edict::isSamePosAs(), Edict::isSameTeamAs(), MASK_SHOT, MAX_WALL_THICKNESS_FOR_SHOOTING_THROUGH, PITCH, trace_s::plane, fireDef_s::range, SF_BODY, SF_BOUNCED, SF_BOUNCING, SF_IMPACT, fireDef_s::splrad, trace_s::startsolid, trace_s::surface, sv_shot_origin, fireDef_s::throughWall, objDef_s::thrown, UNIT_SIZE, cvar_s::value, VecToAngles(), VecToPos, VectorAdd, VectorCompare, VectorCopy, VectorMA(), VectorNormalizeFast(), VectorScale, VectorSubtract, and YAW.

Referenced by G_ClientShoot().

static void G_ShotMorale ( const Actor shooter,
const fireDef_t fd,
const vec3_t  from,
const Item weapon,
const vec3_t  impact 
)
static

Applies morale changes to actors who find themselves in the general direction of a shot.

Parameters
shooterThe shooting actor.
fdThe firedef used to shoot.
fromThe weapon's muzzle location.
weaponThe weapon used to shoot.
impactThe shoot's impact location.

Definition at line 171 of file g_combat.cpp.

References game_import_s::csi, fireDef_s::damage, csi_s::damLaser, Item::def(), objDef_s::dmgtype, DotProduct, f, G_EdictsGetNextLivingActor(), G_Morale(), gi, fireDef_s::irgoggles, Edict::isSamePosAs(), Edict::isSameTeamAs(), ML_SHOOT, Edict::origin, UNIT_SIZE, VecToPos, VectorDistSqr, VectorLength(), VectorLengthSqr, VectorScale, and VectorSubtract.

Referenced by G_ClientShoot().

static void G_SpawnItemOnFloor ( const pos3_t  pos,
const Item item 
)
static

Spawn an item on the floor. A new ET_ITEM edict is created if needed.

Parameters
[in]posThe grid position to spawn the item at
[in]itemThe item to spawn

Definition at line 638 of file g_combat.cpp.

References Edict::chr, CID_FLOOR, G_CheckVis(), G_EdictsGetLivingActorFromPos(), G_EventPerish(), G_FreeEdict(), G_GetFloorItemFromPos(), G_GetFloorItems(), G_SpawnFloor(), G_VisFlagsReset(), game, character_s::inv, INVDEF, game_locals_s::invi, and InventoryInterface::tryAddToInventory().

Referenced by G_ShootGrenade(), and G_ShootSingle().

static void G_SplashDamage ( Actor ent,
const fireDef_t fd,
vec3_t  impact,
shot_mock_t mock,
const trace_t tr 
)
static

Deals splash damage to a target and its surroundings.

Parameters
[in]entThe shooting actor
[in]fdThe fire definition that defines what type of damage is dealt and how big the splash radius is.
[in]impactThe impact vector where the grenade is exploding
[in,out]mockpseudo shooting - only for calculating mock values - nullptr for real shots
[in]trThe trace where the grenade hits something (or not)
Todo:
splash might also hit other surfaces and the trace doesn't handle that

Definition at line 558 of file g_combat.cpp.

References Edict::absBox, shot_mock_s::allow_self, Edict::chr, trace_s::contentFlags, game_import_s::csi, csi_s::damShock, objDef_s::dmgtype, fireDef_s::dmgweight, G_ActorGetEyeVector(), G_AppearPerishEvent(), G_ApplyProtection(), G_Damage(), G_EdictsGetNextInUse(), G_EventSpawnSound(), G_FireAffectedSurface(), G_FrustumVis(), G_IsBreakable, G_IsBrushModel, G_IsLivingActor(), G_PMToVis(), G_SmokeVis(), G_SpawnParticle(), G_TeamToPM(), G_TestLine(), G_VisFlagsAdd(), G_VisToPM(), character_s::gender, teamDef_s::getActorSound(), AABB::getCenter(), Edict::getTeam(), gi, fireDef_s::irgoggles, fireDef_s::obj, Edict::origin, trace_s::plane, SND_HURT, fireDef_s::spldmg, fireDef_s::splrad, trace_s::surface, character_s::teamDef, UNIT_SIZE, VectorCopy, VectorDist, VectorMA(), and Edict::visflags.

Referenced by G_ShootGrenade(), and G_ShootSingle().

static bool G_TeamPointVis ( int  team,
const vec3_t  point 
)
static

Test if point is "visible" from team.

Parameters
[in]teamA team to test.
[in]pointA point to check.
Returns
true if point is "visible"

Definition at line 52 of file g_combat.cpp.

References Edict::absBox, G_ActorGetEyeVector(), G_EdictsGetNextInUse(), G_EdictsGetNextLivingActorOfTeam(), G_FrustumVis(), G_IsSmoke, G_TestLine(), Edict::origin, RayIntersectAABB(), UNIT_SIZE, and VectorDist.

Referenced by G_ClientShoot(), and G_ShootGrenade().

static void G_UpdateCharacterBodycount ( Edict attacker,
const fireDef_t fd,
const Actor target 
)
static

Update character stats for this mission after successful shoot.

Note
Mind you that this code is always from the view of PHALANX soldiers right now, not anybody else!
Parameters
[in,out]attackerPointer to attacker.
[in]fdPointer to fireDef_t used in shoot.
[in]targetPointer to target.
See also
G_UpdateCharacterSkills

Definition at line 257 of file g_combat.cpp.

References Edict::chr, Edict::getTeam(), Actor::isDead(), Actor::isStunned(), KILLED_CIVILIANS, KILLED_ENEMIES, KILLED_TEAM, chrScoreMission_s::kills, chrScoreGlobal_s::kills, lengthof, character_s::score, scoreMission, character_s::scoreMission, chrScoreMission_s::skillKills, chrScoreMission_s::stuns, chrScoreGlobal_s::stuns, TEAM_ALIEN, TEAM_CIVILIAN, TEAM_PHALANX, type, and fireDef_s::weaponSkill.

Referenced by G_CheckDeathOrKnockout().

static void G_UpdateHitScore ( Edict attacker,
const Edict target,
const fireDef_t fd,
const int  splashDamage 
)
static

Increases the 'hit' score by one for all affected teams/skills by one (except splash damage, read below).

Parameters
[in,out]attackerThe soldier to update (he/she dealt the damage)
[in]targetThe hit target.
[in]fdthe used fire definition.
[in]splashDamageDo we count it as splashdamage? If this value is not zero the stats well be counted as splashdamage and the value will be added to the overall splash-damage count.

Definition at line 304 of file g_combat.cpp.

References Edict::chr, chrScoreMission_s::firedHit, chrScoreMission_s::firedSplashHit, Edict::getTeam(), chrScoreMission_s::hits, chrScoreMission_s::hitsSplash, chrScoreMission_s::hitsSplashDamage, Edict::isSameTeamAs(), KILLED_CIVILIANS, KILLED_ENEMIES, KILLED_TEAM, character_s::scoreMission, TEAM_ALIEN, TEAM_CIVILIAN, type, and fireDef_s::weaponSkill.

Referenced by G_Damage(), and G_ShootSingle().

static void G_UpdateShotMock ( shot_mock_t mock,
const Edict shooter,
const Edict struck,
int  damage 
)
static

Function to calculate possible damages for mock pseudoaction.

Parameters
[in,out]mockPseudo action - only for calculating mock values - nullptr for real action.
[in]shooterPointer to attacker for this mock pseudoaction.
[in]struckPointer to victim of this mock pseudoaction.
[in]damageUpdates mock value of damage.
Note
Called only from G_Damage().
See also
G_Damage

Definition at line 224 of file g_combat.cpp.

References shot_mock_s::allow_self, shot_mock_s::civilian, shot_mock_s::damage, shot_mock_s::enemyCount, shot_mock_s::friendCount, G_IsActor, G_IsAI, G_IsCivilian, G_IsDead, G_IsVisibleForTeam, Edict::getTeam(), Edict::inuse, Edict::isSameAs(), and Edict::isSameTeamAs().

Referenced by G_Damage().