Skip to content

Commit 0bde05c

Browse files
committed
Airburst
1 parent 7844e1d commit 0bde05c

File tree

4 files changed

+37
-4
lines changed

4 files changed

+37
-4
lines changed

addons/xm157/XEH_PREP.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
LOG("prep");
22

3+
PREP(airburst_ammoFired);
34
PREP(ballistics_calculator);
45
PREP(ballistics_getData);
56
PREP(keyPress);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include "..\script_component.hpp"
2+
/*
3+
* Author: PabstMirror
4+
* Handles ammo fired event for airburst ammo. Called from the ammo's fired EH.
5+
*
6+
* Arguments:
7+
* FiredEH
8+
*
9+
* Return Value:
10+
* Nothing
11+
*
12+
* Example:
13+
* [] call ace_xm157_fnc_airburst_ammoFired
14+
*
15+
* Public: No
16+
*/
17+
18+
params ["", "", "", "", "_ammo", "", "_projectile", "_gunner"];
19+
if (!local _gunner) exitWith {};
20+
if (isNull _projectile) exitWith {};
21+
TRACE_3("ammoFired local",_ammo,_projectile,_gunner);
22+
23+
private _tof = missionNamespace getVariable [QGVAR(timeOfFlight), -1];
24+
if (_tof < 0.1) exitWith {}; // ~20m safety check
25+
26+
[{
27+
TRACE_1("triggerAmmo",_this);
28+
triggerAmmo _this;
29+
}, _projectile, _tof] call CBA_fnc_waitAndExecute;

addons/xm157/functions/fnc_ballistics_calculator.sqf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* 3: Bank (deg) - Roll <NUMBER>
1111
*
1212
* Return Value:
13-
* Elevation and Windage in MRAD <ARRAY>
13+
* Elevation and Windage in MRAD, Time Of Flight <ARRAY>
1414
*
1515
* Example:
1616
* [500, 90, 0, 0] call ace_xm157_fnc_ballistics_calculator
@@ -21,7 +21,7 @@
2121
params ["_targetRange", "_directionOfFire", "_inclinationAngle", "_bank"];
2222

2323
private _weaponInfo = [] call FUNC(ballistics_getData);
24-
if (_weaponInfo isEqualTo []) exitWith { [0,0] };
24+
if (_weaponInfo isEqualTo []) exitWith { [0,0,0] };
2525
_weaponInfo params ["_scopeBaseAngle","_boreHeight","_airFriction","_muzzleVelocity","_bc",
2626
"_dragModel","_atmosphereModel","_barrelTwist","_twistDirection","_caliber","_bulletLength","_bulletMass"];
2727

@@ -98,4 +98,4 @@ if (_useAB && {(_bulletPos select 1) > 0}) then {
9898
_windage = _windage + _spinDrift;
9999
};
100100

101-
[17.453*_elevation, 17.453*_windage] // Convert to MRAD and return
101+
[17.453*_elevation, 17.453*_windage, _TOF] // Convert to MRAD and return

addons/xm157/functions/fnc_weaponInfo_draw.sqf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ _thisArgs params ["_display"];
2020
if (isNull _display) exitWith {
2121
TRACE_1("cleaning up display",_thisEventHandler);
2222
GVAR(shown) = false;
23+
GVAR(timeOfFlight) = nil;
2324
removeMissionEventHandler ["Draw3D", _thisEventHandler];
2425
};
2526
private _ctrlScopeObject = _display displayCtrl IDC_SCOPE_OBJECT;
@@ -131,13 +132,15 @@ if (_needsUpdate || {_nonMagnified isNotEqualTo _lastMagnified}) then {
131132
// Screen - update reticle position based on ballistics computer
132133
if (_range > 0 && {_size > 0}) then {
133134
BEGIN_COUNTER(ballistics_calculator);
134-
([_range, _weaponDir, _weaponPitch, _weaponBank] call FUNC(ballistics_calculator)) params ["_elevMRAD", "_windMRAD"];
135+
([_range, _weaponDir, _weaponPitch, _weaponBank] call FUNC(ballistics_calculator)) params ["_elevMRAD", "_windMRAD", "_TOF"];
135136
END_COUNTER(ballistics_calculator);
136137
_ctrl ctrlSetPosition [-_windMRAD / _fovMRAD + 0.5 - _size / 2, + 4/3 * (_elevMRAD / _fovMRAD + 0.5 - _size/2), _size, _size*4/3];
137138
_ctrl ctrlCommit 0;
139+
GVAR(timeOfFlight) = _TOF;
138140
} else {
139141
_ctrl ctrlSetPosition [0.5 - _size / 2, + 4/3 * (0.5 - _size/2), _size, _size*4/3];
140142
_ctrl ctrlCommit 0;
143+
GVAR(timeOfFlight) = nil;
141144
};
142145

143146

0 commit comments

Comments
 (0)