Skip to content

Commit

Permalink
store nextMoveTime in PFH args
Browse files Browse the repository at this point in the history
  • Loading branch information
ampersand38 committed Aug 5, 2020
1 parent 66c66af commit e26a4d8
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "script_component.hpp"
#define DISTANCE_CLOSE 3
#define MOVE_DELAY 0.1
#define MOVE_DELAY 5
#define MOVE_TIMEOUT 60
/*
* Author: Ampersand
Expand Down Expand Up @@ -37,10 +37,9 @@ _assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5];

[{
params ["_args", "_pfhID"];
_args params ["_gunner", "_assistant", "_targetPos", "_startTime"];
_args params ["_gunner", "_assistant", "_targetPos", "_nextMoveTime", "_endTime"];

private _closeEnough = _gunner distance _assistant <= DISTANCE_CLOSE;
private _endTime = _startTime + MOVE_TIMEOUT;

if (_closeEnough || {CBA_MissionTime > _endTime || {!alive _gunner || {!alive _assistant}}}) exitWith {
[_pfhID] call CBA_fnc_removePerFrameHandler;
Expand All @@ -64,9 +63,8 @@ _assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5];
};
};

private _nextMoveTime = _assistant getVariable [QGVAR(nextMoveTime), CBA_MissionTime];
if (unitReady _assistant || {CBA_MissionTime >= _nextMoveTime}) then {
_assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5];
_assistant doMove ASLtoAGL getPosASL _gunner;
_args set [3, CBA_missionTime + MOVE_DELAY];
};
}, MOVE_DELAY, [_gunner, _assistant, _targetPos, CBA_MissionTime]] call CBA_fnc_addPerFrameHandler;
}, 0.1, [_gunner, _assistant, _targetPos, CBA_MissionTime + MOVE_DELAY, CBA_missionTime + MOVE_TIMEOUT]] call CBA_fnc_addPerFrameHandler;

0 comments on commit e26a4d8

Please sign in to comment.