forked from cataclysmbnteam/Cataclysm-BN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ballistics.h
53 lines (45 loc) · 1.76 KB
/
ballistics.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#pragma once
#ifndef CATA_SRC_BALLISTICS_H
#define CATA_SRC_BALLISTICS_H
class Creature;
class dispersion_sources;
class vehicle;
struct dealt_projectile_attack;
struct projectile;
struct tripoint;
/** Aim result for a single projectile attack */
struct projectile_attack_aim {
///< Hit quality, where 0.0 is a perfect hit and 1.0 is a miss
double missed_by;
///< Number of tiles the attack missed by
double missed_by_tiles;
///< Dispersion of this particular shot in arcminutes
double dispersion;
};
/**
* Evaluates dispersion sources, range, and target to determine attack trajectory.
**/
projectile_attack_aim projectile_attack_roll( const dispersion_sources &dispersion, double range,
double target_size );
/**
* Fires a projectile at the target point from the source point with total_dispersion
* dispersion.
* Returns the rolled dispersion of the shot and the actually hit point.
*/
dealt_projectile_attack projectile_attack( const projectile &proj_arg, const tripoint &source,
const tripoint &target_arg, const dispersion_sources &dispersion,
Creature *origin = nullptr, const vehicle *in_veh = nullptr );
namespace ranged
{
/**
* The chance that a fired shot reaches required accuracy - by default grazing shot.
*
* @param dispersion accuracy of the shot. Must be a purely normal distribution.
* @param range distance between the shooter and the target.
* @param target_size size of the target, in the range (0, 1].
* @param missed_by maximum degree of miss, in the range (0, 1]. Effectively a multiplier on @param target_size.
*/
double hit_chance( const dispersion_sources &dispersion, double range, double target_size,
double missed_by = 1.0 );
} // namespace ranged
#endif // CATA_SRC_BALLISTICS_H