Skip to content

Commit

Permalink
Merge pull request #2779 from acemod/fixFCSLead
Browse files Browse the repository at this point in the history
Fix lead calculation for vehicle FCS
  • Loading branch information
KoffeinFlummi committed Oct 21, 2015
2 parents 57abe3b + a899c74 commit 5d7a8af
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion addons/fcs/XEH_clientInit.sqf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "script_component.hpp"

GVAR(enabled) = false;
GVAR(ACE_time) = 0;
GVAR(time) = 0;
GVAR(position) = [0,0,0];

if (!hasInterface) exitWith {};
Expand Down
2 changes: 1 addition & 1 deletion addons/fcs/functions/fnc_keyDown.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ _distance = call FUNC(getRange);
if !(!GVAR(enabled) && FUNC(canUseFCS)) exitWith {};

GVAR(Enabled) = true;
GVAR(Time) = ACE_time;
GVAR(time) = ACE_time;

if (_distance == 0) then {
_distance = [5, 5000, 0] call EFUNC(common,getTargetDistance); // maximum distance: 5000m, 5m precision
Expand Down
18 changes: 9 additions & 9 deletions addons/fcs/functions/fnc_keyUp.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,17 @@ private ["_movingAzimuth", "_posTarget", "_velocityTarget"];

// MOVING TARGETS
_movingAzimuth = 0;
if (ACE_time - GVAR(ACE_time) > 1 and GVAR(ACE_time) != -1 and count _this < 3) then {
if (ACE_time - GVAR(time) > 1 and GVAR(time) != -1 and count _this < 3) then {
// calculate speed of target
_posTarget = [
(getPos _vehicle select 0) + _distance * (_weaponDirection select 0),
(getPos _vehicle select 1) + _distance * (_weaponDirection select 1),
(getPos _vehicle select 2) + _distance * (_weaponDirection select 2)
];
_velocityTarget = [
((_posTarget select 0) - (GVAR(position) select 0)) / (ACE_time - GVAR(ACE_time)),
((_posTarget select 1) - (GVAR(position) select 1)) / (ACE_time - GVAR(ACE_time)),
((_posTarget select 2) - (GVAR(position) select 2)) / (ACE_time - GVAR(ACE_time))
((_posTarget select 0) - (GVAR(position) select 0)) / (ACE_time - GVAR(time)),
((_posTarget select 1) - (GVAR(position) select 1)) / (ACE_time - GVAR(time)),
((_posTarget select 2) - (GVAR(position) select 2)) / (ACE_time - GVAR(time))
];

private ["_magazineType", "_ammoType", "_initSpeed", "_airFriction", "_timeToLive", "_simulationStep", "_initSpeedCoef", "_velocityMagnitude"];
Expand All @@ -90,7 +90,7 @@ if (ACE_time - GVAR(ACE_time) > 1 and GVAR(ACE_time) != -1 and count _this < 3)
if (_initSpeedCoef > 0) then {
_initSpeed = _initSpeedCoef;
};

if (_simulationStep != 0) then {
private ["_posX", "_velocityX", "_velocityY", "_timeToTarget"];

Expand Down Expand Up @@ -130,7 +130,7 @@ if (ACE_time - GVAR(ACE_time) > 1 and GVAR(ACE_time) != -1 and count _this < 3)
};
};
GVAR(enabled) = false;
GVAR(ACE_time) = -1;
GVAR(time) = -1;

private ["_viewDiff", "_FCSAzimuth", "_FCSMagazines", "_FCSElevation"];

Expand All @@ -157,7 +157,7 @@ _FCSElevation = [];
_maxElev = getNumber (_turretConfig >> "maxElev");
_initSpeed = getNumber (configFile >> "CfgMagazines" >> _magazine >> "initSpeed");
_airFriction = getNumber (configFile >> "CfgAmmo" >> _ammoType >> "airFriction");

{
private ["_weapon", "_muzzles", "_weaponMagazines", "_muzzleMagazines"];
_weapon = _x;
Expand All @@ -179,7 +179,7 @@ _FCSElevation = [];
};
};
} forEach _weapons;

_offset = "ace_fcs" callExtension format ["%1,%2,%3,%4", _initSpeed, _airFriction, _angleTarget, _distance];
_offset = parseNumber _offset;

Expand Down Expand Up @@ -209,4 +209,4 @@ if(_playSound) then {

if(_showHint) then {
[format ["%1: %2", localize LSTRING(ZeroedTo), _distance]] call EFUNC(common,displayTextStructured);
};
};

0 comments on commit 5d7a8af

Please sign in to comment.