Skip to content

Commit

Permalink
Improve arty and statics (#376)
Browse files Browse the repository at this point in the history
* Improve arty and statics

- Disembark only the crew

- Remove distanceSqr optimization for readability

- Remove useless _static variable

- Apply suppression to all crew of the vehicle when disembarking

- Don't call doVehicleSuppress after disembark

* Remove unnecessary brackets

Co-authored-by: Jouni Järvinen <[email protected]>

---------

Co-authored-by: Jouni Järvinen <[email protected]>
  • Loading branch information
rekterakathom and rautamiekka authored May 5, 2024
1 parent 571d80a commit adfe03d
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions addons/danger/functions/fnc_brainVehicle.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@ if (_artillery) exitWith {
_vehicle setVariable [QEGVAR(main,isArtillery), true];

// enemies within 12-30m may cause crew to disembark!
if (_attack && {_dangerCausedBy distanceSqr _vehicle < (144 + random 324)} && {currentCommand _unit isEqualTo ""}) then {
(units _unit) orderGetIn false;
_unit setSuppression 0.94; // to prevent instant laser aim on exiting vehicle
if (_attack && {_dangerCausedBy distance _vehicle < (12 + random 18)} && {currentCommand _unit isEqualTo ""}) then {
private _vehicleCrew = crew _vehicle;
_vehicleCrew orderGetIn false;
{
_x setSuppression 0.94; // to prevent instant laser aim on exiting vehicle
} forEach _vehicleCrew; // There may be more than one unit in vehicle
};
[_timeout] + _causeArray
};
Expand All @@ -83,19 +86,21 @@ if (_vehicle isKindOf "Air") exitWith {
};

// vehicle type ~ Static weapon
private _static = _vehicle isKindOf "StaticWeapon";
if (_static) exitWith {
if (_vehicle isKindOf "StaticWeapon") exitWith {

// get out if enemy near OR out of ammunition
if ((count (magazines _vehicle)) isEqualTo 0 || {(_vehicle findNearestEnemy _vehicle) distance _vehicle < (6 + random 15)}) then {
(units _unit) orderGetIn false;
_unit setSuppression 0.94; // to prevent instant laser aim on exiting vehicle
};

// suppression
if (_attack) then {
[_unit, _dangerPos] call EFUNC(main,doVehicleSuppress);
[{_this call EFUNC(main,doVehicleSuppress)}, [_unit, _dangerPos], 3] call CBA_fnc_waitAndExecute;
if ((count (magazines _vehicle)) isEqualTo 0 || {(_unit findNearestEnemy _dangerPos) distance _vehicle < (6 + random 15)}) then {
private _vehicleCrew = (crew _vehicle);
_vehicleCrew orderGetIn false;
{
_x setSuppression 0.94; // to prevent instant laser aim on exiting vehicle
} forEach _vehicleCrew; // There may be more than one unit in vehicle
} else {
// suppression
if (_attack) then {
[_unit, _dangerPos] call EFUNC(main,doVehicleSuppress);
[{_this call EFUNC(main,doVehicleSuppress)}, [_unit, _dangerPos], 3] call CBA_fnc_waitAndExecute;
};
};

// end
Expand Down

0 comments on commit adfe03d

Please sign in to comment.