mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
e2ac18a05d
* advanced_ballistics * advanced_fatigue * advanced_throwing * ai * aircraft * arsenal * atragmx * attach * backpacks * ballistics * captives * cargo * chemlights * common * concertina_wire * cookoff * dagr * disarming * disposable * dogtags * dragging * explosives * fastroping * fcs * finger * frag * gestures * gforces * goggles * grenades * gunbag * hearing * hitreactions * huntir * interact_menu * interaction * inventory * kestrel4500 * laser * laserpointer * logistics_uavbattery * logistics_wirecutter * magazinerepack * map * map_gestures * maptools * markers * medical * medical_ai * medical_blood * medical_menu * microdagr * minedetector * missileguidance * missionmodules * mk6mortar * modules * movement * nametags * nightvision * nlaw * optics * optionsmenu * overheating * overpressure * parachute * pylons * quickmount * rangecard * rearm * recoil * refuel * reload * reloadlaunchers * repair * respawn * safemode * sandbag * scopes * slideshow * spectator * spottingscope * switchunits * tacticalladder * tagging * trenches * tripod * ui * vector * vehiclelock * vehicles * viewdistance * weaponselect * weather * winddeflection * yardage450 * zeus * arsenal defines.hpp * optionals * DEBUG_MODE_FULL 1 * DEBUG_MODE_FULL 2 * Manual fixes * Add SQF Validator check for #include after block comment * explosives fnc_openTimerUI * fix uniqueItems
96 lines
3.7 KiB
Plaintext
96 lines
3.7 KiB
Plaintext
#include "script_component.hpp"
|
|
/*
|
|
* 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:
|
|
* 0: Player <OBJECT>
|
|
*
|
|
* Return Value:
|
|
* Nothing
|
|
*
|
|
* Example:
|
|
* [player] call ace_hellfire_fnc_setupVehicle
|
|
*
|
|
* Public: No
|
|
*/
|
|
|
|
|
|
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);};
|
|
|
|
|
|
// Add laser if vehicle is configured for one:
|
|
if ((getNumber (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> QGVAR(addLaserDesignator))) == 1) then {
|
|
[{
|
|
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];
|
|
};
|
|
}, [_vehicle, _turretPath], 1] call CBA_fnc_waitAndExecute; // Need to delay slightly for turret to become local (probably only needs a single frame)
|
|
};
|
|
|
|
|
|
// 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"];
|
|
|
|
private _turretPath = if (ACE_player == (driver _target)) then {[-1]} else {ACE_player call CBA_fnc_turretPath};
|
|
private _hasWeapon = ({(isNumber (configFile >> "CfgWeapons" >> _x >> QGVAR(enabled))) && {getNumber (configFile >> "CfgWeapons" >> _x >> QGVAR(enabled)) > 0}} count (_target weaponsTurret _turretPath)) > 0;
|
|
|
|
(_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);
|