Skip to content

Commit

Permalink
Update fnc_moduleUnpackStaticWeapon.sqf
Browse files Browse the repository at this point in the history
Changed `remoteExec` to `CBA_fnc_targetEvent`.
Added text elements to stringtable.
Converted to script macros.
Changed `getCompatibleBases` to private and simplified.
  • Loading branch information
ampersand38 committed Jun 8, 2020
1 parent 44f65bd commit 2aeb1af
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -36,36 +36,35 @@ if (isPlayer _gunner) exitWith {
["str_a3_cfgvehicles_moduleremotecontrol_f_errorPlayer"] call EFUNC(common,showMessage);
};

getCompatibleBases = {
private _fnc_getCompatibleBases = {
params ["_backpack"];
private _cfgBase = configFile >> "CfgVehicles" >> _backpack >> "assembleInfo" >> "base";
private _compatibleBases = if (isText _cfgBase) then {[getText _cfgBase]} else {getArray _cfgBase};
_compatibleBases
[getArray _cfgBase, [getText _cfgBase]] select (isText _cfgBase)
};

private _backpack = backpack _gunner;

if (_backpack isEqualTo "") exitWith {
["Unit must carry a weapon bag"] call EFUNC(common,showMessage);
[LSTRING(ModuleUnpackStaticWeapon_Unit)] call EFUNC(common,showMessage);
};

private _compatibleBases = [_backpack] call getCompatibleBases;
private _compatibleBases = [_backpack] call _fnc_getCompatibleBases;
if (_compatibleBases isEqualType "") then {_compatibleBases = [_compatibleBases];};

private _backpackers = units _gunner select {!(backpack _x isEqualTo "")};
private _assistant = {
if (backpack _x in _compatibleBases) exitWith {_x};
if (_backpack in ([backpack _x] call getCompatibleBases)) exitWith {_x};
if (_backpack in ([backpack _x] call _fnc_getCompatibleBases)) exitWith {_x};

objNull
} forEach _backpackers;

if (_assistant isEqualTo objNull) exitWith {
["Unit group must contain two compatible weapon bags"] call EFUNC(common,showMessage);
[LSTRING(ModuleUnpackStaticWeapon_Group)] call EFUNC(common,showMessage);
};

// Get target position
[_gunner, {
params ["_successful", "_gunner", "_mousePosASL", "_assistant"];
[_gunner, _assistant, ASLToAGL _mousePosASL] remoteExecCall ["zen_modules_fnc_unpackStaticWeapon", _gunner];
[QEGVAR(ai,unpackStaticWeapon), [_gunner, _assistant, ASLToAGL _mousePosASL], _gunner] call CBA_fnc_targetEvent;
}, _assistant, "Static Weapon Facing"] call EFUNC(common,selectPosition);

0 comments on commit 2aeb1af

Please sign in to comment.