Skip to content

Commit

Permalink
Revised CAS modules (#319)
Browse files Browse the repository at this point in the history
* Fix targeting and fire flares

* Address review comments + additional launch CM params

* Fix launch CM

* extraordinary important optimization
  • Loading branch information
Kexanone authored Jun 11, 2018
1 parent a95542b commit 7e61f3a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//
// ARGUMENTS:
// _this select 0: - ARRAY of OBJECTs - Vehicles that launches the CM.
// _this select 1: - BOOL - Has curator selected more than one unit.
// _this select 1: - ARRAY of SCALARs - [number of deployments, delay]; for flares only; default [6, 0.1].
//
// RETURNS:
// nothing (procedure)
Expand All @@ -19,7 +19,7 @@
#define ALL_SL_WEAP_CLASSES ["SmokeLauncher","rhs_weap_smokegen","rhs_weap_902a","rhs_weap_902b","rhsusf_weap_M259"]
#define ALL_CM_WEAP_CLASSES ["CMFlareLauncher", "CMFlareLauncher_Singles", "CMFlareLauncher_Triples", "rhs_weap_CMFlareLauncher","rhsusf_weap_CMFlareLauncher"]

params[["_vehicle", objNull, [objNull]], ["_multipleSelection", false, [false]]];
params[["_vehicle", objNull, [objNull]], ["_flareParams", [6, 0.1], [[]], 2]];

private _isVehicleAir = _vehicle isKindOf "Air";
private _smokeType = ["smokeshell", "magazine"] select _isVehicleAir;
Expand All @@ -41,8 +41,7 @@ if (_vehicle isKindOf "Man") then
] call BIS_fnc_sortBy;

// Display different messages if the unit doesn't have any smokes
if (_allSmokeMagazines isEqualTo [] && !_multipleSelection) exitWith {["Smoke grenades unavailable!"] call Achilles_fnc_showZeusErrorMessage};
if (_allSmokeMagazines isEqualTo [] && _multipleSelection) exitWith {[format ["Smoke grenades unavailable for %1!", name _vehicle]] call Achilles_fnc_showZeusErrorMessage};
if (_allSmokeMagazines isEqualTo []) exitWith {[format ["Smoke grenades unavailable for %1!", name _vehicle]] call Achilles_fnc_showZeusErrorMessage};

// Make the unit throw the smoke grenade
private _smokeMuzzle = (_allSmokeMagazines select 0) select 4;
Expand All @@ -60,11 +59,8 @@ else
{((getText (configfile >> "CfgMagazines" >> (_x select 0) >> "nameSound")) == _smokeType) && ((_x select 2) > 0)}
] call BIS_fnc_sortBy;

if (_allSmokeMagazines isEqualTo [] && !_multipleSelection && !_isVehicleAir) exitWith {["Smoke dispensers unavailable!"] call Achilles_fnc_showZeusErrorMessage};
if (_allSmokeMagazines isEqualTo [] && _multipleSelection && !_isVehicleAir) exitWith {[format ["Smoke dispensers unavailable for %1!", name _vehicle]] call Achilles_fnc_showZeusErrorMessage};

if (_allSmokeMagazines isEqualTo [] && !_multipleSelection && _isVehicleAir) exitWith {["Countermeasures unavailable!"] call Achilles_fnc_showZeusErrorMessage};
if (_allSmokeMagazines isEqualTo [] && _multipleSelection && _isVehicleAir) exitWith {[format ["Countermeasures unavailable for %1!", name _vehicle]] call Achilles_fnc_showZeusErrorMessage};
if (_allSmokeMagazines isEqualTo [] && !_isVehicleAir) exitWith {[format ["Smoke dispensers unavailable for %1!", name _vehicle]] call Achilles_fnc_showZeusErrorMessage};
if (_allSmokeMagazines isEqualTo [] && _isVehicleAir) exitWith {[format ["Countermeasures unavailable for %1!", name _vehicle]] call Achilles_fnc_showZeusErrorMessage};

private _turretPath = (_allSmokeMagazines select 0) select 1;
private _weapons = _vehicle weaponsTurret _turretPath;
Expand All @@ -80,14 +76,14 @@ else
// If the vehicle is an aircraft
if (_isVehicleAir) then
{
[_vehicle,_CMWeapon] spawn
[_vehicle,_CMWeapon, _flareParams] spawn
{
params["_vehicle", "_CMWeapon"];

for "_i" from 0 to 5 do
params["_vehicle", "_CMWeapon", "_flareParams"];
_flareParams params ["_flareCounts", "_delay"];
for "_i" from 0 to _flareCounts do
{
[_vehicle, _CMWeapon] call BIS_fnc_fire;
sleep 0.1;
sleep _delay;
};
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,13 @@ waituntil {

//--- Fire!
if ((getposasl _plane) distance _pos < 1000 && _fireNull) then {
//--- Fire CM
[_plane, [5, 1.1]] call Achilles_fnc_LaunchCM;
//--- Create laser target
private _target = ((position _logic nearEntities ["LaserTarget",250])) param [0,objnull];
private _targetType = if (_planeSide getfriend west > 0.6) then {"LaserTargetW"} else {"LaserTargetE"};
_target = ((position _logic nearEntities [_targetType,250])) param [0,objnull];
if (isnull _target) then {
_target = createvehicle ["LaserTargetC",position _logic,[],0,"none"];
_target = createvehicle [_targetType,position _logic,[],0,"none"];
};
_plane reveal lasertarget _target;
_plane dowatch lasertarget _target;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,8 @@
{
private _vehicles = curatorSelected select 0;
if (isNil "_vehicles") exitWith {};
private _mutlipleUnits = count _vehicles > 1;
{
[vehicle _x, _mutlipleUnits] call Achilles_fnc_LaunchCM;
[vehicle _x] call Achilles_fnc_LaunchCM;
} forEach _vehicles;
true;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ switch _mode do {
// search for suitable CAS planes on first use
if (isNil "Achilles_var_CASPlaneInfoCache") then
{
publicVariableServer "Achilles_fnc_LaunchCM";
publicVariableServer "Achilles_fnc_moduleCAS_server";
Achilles_var_CASPlaneInfoCache = [[],[],[],[]];

Expand Down

0 comments on commit 7e61f3a

Please sign in to comment.