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

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

#include "g_local.h"

Go to the source code of this file.

Data Structures

struct  shot_mock_s
 used in shot probability calculations (pseudo shots) More...
 

Typedefs

typedef struct shot_mock_s shot_mock_t
 used in shot probability calculations (pseudo shots) More...
 

Functions

int G_ApplyProtection (const Edict *target, const byte dmgWeight, int damage)
 Reduces damage by armour and natural protection. More...
 
void G_CheckDeathOrKnockout (Actor *target, Actor *attacker, const fireDef_t *fd, int damage)
 
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...
 
void G_CalcEffectiveSpread (const Actor *ent, const fireDef_t *fd, vec2_t effSpread)
 Calculate the effective spread for the given actor and firemode. More...
 

Detailed Description

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

Definition in file g_combat.h.

Typedef Documentation

typedef struct shot_mock_s shot_mock_t

used in shot probability calculations (pseudo shots)

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().