2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2017-06-02 21:51:38 +00:00
|
|
|
/*
|
|
|
|
* Author: PabstMirror
|
|
|
|
* Adds interaction menu actions to switch the firemode to a vehicle.
|
|
|
|
* Also adds a Laser Designator if vehicle is configured for one.
|
|
|
|
*
|
|
|
|
* Arguments:
|
2017-09-16 19:24:43 +00:00
|
|
|
* 0: Player <OBJECT>
|
2017-06-02 21:51:38 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Nothing
|
|
|
|
*
|
|
|
|
* Example:
|
2017-09-16 19:24:43 +00:00
|
|
|
* [player] call ace_hellfire_fnc_setupVehicle
|
2017-06-02 21:51:38 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2017-09-16 19:24:43 +00:00
|
|
|
|
|
|
|
params ["_player"];
|
|
|
|
// Note: player may be the currently controlled UAV's AI unit (so may be different from ace_player)
|
|
|
|
TRACE_1("showHud",_player);
|
|
|
|
|
|
|
|
private _enabled = false;
|
|
|
|
private _vehicle = vehicle _player;
|
|
|
|
private _turretPath = [-1];
|
|
|
|
|
|
|
|
if ((alive _player) && {_player != _vehicle}) then {
|
|
|
|
if (_player != (driver _vehicle)) then {
|
|
|
|
_turretPath = _player call CBA_fnc_turretPath
|
|
|
|
};
|
|
|
|
{
|
|
|
|
if ((getNumber (configFile >> "CfgWeapons" >> _x >> QGVAR(enabled))) == 1) then {
|
|
|
|
TRACE_1("enabled",_x);
|
|
|
|
_enabled = true;
|
|
|
|
};
|
|
|
|
} forEach (_vehicle weaponsTurret _turretPath);
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!_enabled) exitWith {TRACE_3("Not enabled",_enabled,_vehicle,_turretPath);};
|
|
|
|
|
2017-06-02 21:51:38 +00:00
|
|
|
|
|
|
|
// Add laser if vehicle is configured for one:
|
2021-10-30 21:42:03 +00:00
|
|
|
if ((getNumber (configOf _vehicle >> QGVAR(addLaserDesignator))) == 1) then {
|
2017-06-02 21:51:38 +00:00
|
|
|
[{
|
|
|
|
params ["_vehicle", "_turretPath"];
|
|
|
|
TRACE_3("checking for laser",_vehicle,_turretPath,_vehicle turretLocal _turretPath);
|
|
|
|
if (!alive _vehicle) exitWith {};
|
|
|
|
if (!(_vehicle turretLocal _turretPath)) then {WARNING("Turret not local");};
|
|
|
|
private _hasLaser = false;
|
|
|
|
{
|
|
|
|
// Most addons just use "Laserdesignator_mounted", but this should cover custom ones
|
|
|
|
if ((getNumber (configFile >> "CfgWeapons" >> _x >> "Laser")) == 1) exitWith {
|
|
|
|
_hasLaser = true;
|
|
|
|
};
|
|
|
|
} forEach (_vehicle weaponsTurret _turretPath);
|
|
|
|
if (!_hasLaser) then {
|
|
|
|
TRACE_1("Adding Laser Designator",typeOf _vehicle);
|
|
|
|
_vehicle addWeaponTurret ["Laserdesignator_mounted", _turretPath];
|
|
|
|
_vehicle addMagazineTurret ["Laserbatteries", _turretPath];
|
|
|
|
};
|
2017-09-16 19:24:43 +00:00
|
|
|
}, [_vehicle, _turretPath], 1] call CBA_fnc_waitAndExecute; // Need to delay slightly for turret to become local (probably only needs a single frame)
|
2017-06-02 21:51:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Add interaction menu actions:
|
|
|
|
if (_vehicle getVariable [QGVAR(actionsAdded), false]) exitWith {};
|
|
|
|
_vehicle setVariable [QGVAR(actionsAdded), true];
|
|
|
|
|
|
|
|
private _action = [QUOTE(ADDON), localize LSTRING(hellfireModeAction), "", {}, {true}] call EFUNC(interact_menu,createAction);
|
|
|
|
private _basePath = [_vehicle, 1, ["ACE_SelfActions"], _action] call EFUNC(interact_menu,addActionToObject);
|
|
|
|
|
|
|
|
private _fnc_statement = {
|
|
|
|
params ["_target", "", "_attackProfile"];
|
|
|
|
TRACE_2("statement",_target,_attackProfile);
|
|
|
|
|
|
|
|
_target setVariable [QEGVAR(missileguidance,attackProfile), _attackProfile];
|
|
|
|
};
|
|
|
|
private _fnc_condition = {
|
|
|
|
params ["_target", "_player", "_attackProfile"];
|
2021-10-30 21:42:03 +00:00
|
|
|
|
2017-06-02 21:51:38 +00:00
|
|
|
private _turretPath = if (ACE_player == (driver _target)) then {[-1]} else {ACE_player call CBA_fnc_turretPath};
|
2017-06-23 16:32:48 +00:00
|
|
|
private _hasWeapon = ({(isNumber (configFile >> "CfgWeapons" >> _x >> QGVAR(enabled))) && {getNumber (configFile >> "CfgWeapons" >> _x >> QGVAR(enabled)) > 0}} count (_target weaponsTurret _turretPath)) > 0;
|
2017-06-02 21:51:38 +00:00
|
|
|
|
|
|
|
(_hasWeapon) &&
|
|
|
|
{(_target getVariable [QEGVAR(missileguidance,attackProfile), "hellfire"]) != _attackProfile};
|
|
|
|
};
|
|
|
|
|
|
|
|
{
|
|
|
|
private _displayName = getText (configFile >> QEGVAR(missileguidance,AttackProfiles) >> _x >> "name");
|
|
|
|
private _action = [format [QGVAR(%1),_x], _displayName, "", _fnc_statement, _fnc_condition, {}, _x] call EFUNC(interact_menu,createAction);
|
|
|
|
[_vehicle, 1, _basePath, _action] call EFUNC(interact_menu,addActionToObject);
|
|
|
|
} forEach ["hellfire", "hellfire_hi", "hellfire_lo"];
|
|
|
|
|
|
|
|
TRACE_2("interactions added",_vehicle,typeOf _vehicle);
|