UFO: Alien Invasion
Loading...
Searching...
No Matches
g_combat.h File Reference

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

#include "g_local.h"
Include dependency graph for g_combat.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  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.
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.
void G_CalcEffectiveSpread (const Actor *ent, const fireDef_t *fd, vec2_t effSpread)
 Calculate the effective spread for the given actor and firemode.

Detailed Description

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

Definition in file g_combat.h.

Function Documentation

◆ G_ApplyProtection()

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_t::protection, teamDef_t::resistance, and character_t::teamDef.

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

◆ G_CalcEffectiveSpread()

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_t::crouch, G_ActorGetInjuryPenalty(), GET_ACC, Actor::isCrouched(), MODIFIER_ACCURACY, PITCH, character_t::score, SKILL_BALANCE, chrScoreGlobal_t::skills, fireDef_t::spread, WEAPON_BALANCE, fireDef_t::weaponSkill, and YAW.

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

◆ G_CheckDeathOrKnockout()

◆ G_ClientShoot()

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_t::ammo, Item::ammoDef(), AngleToDir(), Edict::chr, CORE_DIRECTIONS, crand(), fireDef_t::damage, Item::def(), objDef_t::deplete, Edict::dir, fireDef_t::dmgweight, ET_ACTOR, ET_FIRE, ET_SMOKE, ET_SMOKESTUN, Edict::fieldSize, chrScoreMission_t::fired, chrScoreMission_t::firedHit, chrScoreMission_t::firedSplash, chrScoreMission_t::firedSplashHit, chrScoreMission_t::firedSplashTUs, chrScoreMission_t::firedTUs, FIRESH_IsMedikit, objDef_t::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_t::getShotOrigin(), Edict::getTeam(), Edict::getTus(), FiremodeSettings::getWeapon(), gi, fireDef_t::gravity, i, invDef_t::id, objDef_t::id, Edict::inuse, character_t::inv, INVDEF, fireDef_t::irgoggles, Actor::isCrouched(), Actor::isDead(), Edict::isSamePosAs(), Actor::isStunned(), KILLED_NUM_TYPES, MAX_TEAMS, mor_panic, fireDef_t::obj, objDef_t::oneshot, Edict::origin, Edict::pos, PRINT_HUD, fireDef_t::range, character_t::RFmode, fireDef_t::rounds, character_t::scoreMission, Item::setAmmoLeft(), fireDef_t::shots, invDef_t::single, fireDef_t::splrad, objDef_t::thrown, todeg, type, VectorDist, VectorMA(), VectorSubtract, Edict::visflags, and fireDef_t::weaponSkill.

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