diff --git a/addons/cargo/XEH_postInit.sqf b/addons/cargo/XEH_postInit.sqf index 6146f2c862c..7245b45e2f7 100644 --- a/addons/cargo/XEH_postInit.sqf +++ b/addons/cargo/XEH_postInit.sqf @@ -81,7 +81,8 @@ GVAR(vehicleAction) = [ {locked _target < 2} && {([_player, _target] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE} && {alive _target} && - {[_player, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)} + {[_player, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)} && + {[_player, _target] call EFUNC(interaction,canInteractWithVehicleCrew)} } ] call EFUNC(interact_menu,createAction); @@ -99,6 +100,7 @@ GVAR(objectActions) = [ {(_target getVariable [QGVAR(canLoad), getNumber (configOf _target >> QGVAR(canLoad))]) in [true, 1]} && {alive _target} && {[_player, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)} && + {[_player, _target] call EFUNC(interaction,canInteractWithVehicleCrew)} && {(_target getVariable [QGVAR(noRename), getNumber (configOf _target >> QGVAR(noRename))]) in [false, 0]} } ] call EFUNC(interact_menu,createAction), @@ -114,6 +116,7 @@ GVAR(objectActions) = [ {locked _target < 2} && {alive _target} && {[_player, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)} && + {[_player, _target] call EFUNC(interaction,canInteractWithVehicleCrew)} && {((nearestObjects [_target, GVAR(cargoHolderTypes), (MAX_LOAD_DISTANCE + 10)]) findIf { private _hasCargoConfig = 1 == getNumber (configOf _x >> QGVAR(hasCargo)); private _hasCargoPublic = _x getVariable [QGVAR(hasCargo), false]; diff --git a/addons/interaction/XEH_PREP.hpp b/addons/interaction/XEH_PREP.hpp index 8f68aa79cf8..554f9037047 100644 --- a/addons/interaction/XEH_PREP.hpp +++ b/addons/interaction/XEH_PREP.hpp @@ -14,6 +14,7 @@ PREP(hideMouseHint); // interaction with units PREP(canInteractWithCivilian); +PREP(canInteractWithVehicleCrew); PREP(getDown); PREP(sendAway); PREP(canJoinGroup); diff --git a/addons/interaction/functions/fnc_addPassengersActions.sqf b/addons/interaction/functions/fnc_addPassengersActions.sqf index 27698eb697d..40ba9672ef4 100644 --- a/addons/interaction/functions/fnc_addPassengersActions.sqf +++ b/addons/interaction/functions/fnc_addPassengersActions.sqf @@ -6,65 +6,68 @@ * Arguments: * 0: Vehicle * 1: Player - * 3: Parameters + * 2: Parameters * * Return Value: * Children actions * * Example: - * [target, player, [params]] call ace_interaction_fnc_addPassengersActions + * [cursorObject, player, [params]] call ace_interaction_fnc_addPassengersActions * * Public: No */ params ["_vehicle", "_player"]; +// If player is not in vehicle and the crew is hostile, do not show any actions +if !(_player in _vehicle || {[_player, _vehicle] call FUNC(canInteractWithVehicleCrew)}) exitWith { + [] // return +}; + private _actions = []; +private _icon = ""; { - private _unit = _x; - - if (_unit != _player && {getText (configOf _unit >> "simulation") != "UAVPilot"}) then { - private _icon = [ - "", - "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_driver_ca.paa", - "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_gunner_ca.paa", - "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_commander_ca.paa" - ] select (([driver _vehicle, gunner _vehicle, commander _vehicle] find _unit) + 1); + _x params ["_unit", "_role"]; - if (_unit getVariable [QEGVAR(captives,isHandcuffed), false]) then { - _icon = QPATHTOEF(captives,UI\handcuff_ca.paa); - }; + _icon = [ + "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_driver_ca.paa", + "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_gunner_ca.paa", + "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_commander_ca.paa", + "" + ] select (["driver", "gunner", "commander"] find _role); - _actions pushBack [ - [ - format ["%1", _unit], - [_unit, true] call EFUNC(common,getName), - [_icon, "#FFFFFF"], - { - //statement (Run on hover) - reset the cache so we will insert actions immedietly when hovering over new unit - TRACE_2("Cleaning Cache",_target,vehicle _target); - [vehicle _target, QEGVAR(interact_menu,ATCache_ACE_SelfActions)] call EFUNC(common,eraseCache); - }, - {true}, - { - if (EGVAR(interact_menu,selectedTarget) isEqualTo _target) then { - _this call FUNC(addPassengerActions) - } else { - [] //not selected, don't waste time on actions - }; - }, - [_unit], - {[0, 0, 0]}, - 2, - [false,false,false,true,false], //add run on hover (4th bit true) - {if (["ace_medical_gui"] call EFUNC(common,isModLoaded)) then {call EFUNC(medical_gui,modifyActionTriageLevel)}} - ] call EFUNC(interact_menu,createAction), - [], - _unit - ]; + if (_unit getVariable [QEGVAR(captives,isHandcuffed), false]) then { + _icon = QPATHTOEF(captives,UI\handcuff_ca.paa); }; - false -} count crew _vehicle; + + _actions pushBack [ + [ + format ["%1", _unit], + [_unit, true] call EFUNC(common,getName), + [_icon, "#FFFFFF"], + { + // statement (Run on hover) - reset the cache so we will insert actions immediately when hovering over new unit + TRACE_2("Cleaning Cache",_target,objectParent _target); + [objectParent _target, QEGVAR(interact_menu,ATCache_ACE_SelfActions)] call EFUNC(common,eraseCache); + }, + {true}, + { + if (EGVAR(interact_menu,selectedTarget) isEqualTo _target) then { + _this call FUNC(addPassengerActions) + } else { + [] // not selected, don't waste time on actions + }; + }, + [_unit], + {[0, 0, 0]}, + 2, + [false, false, false, true, false], // add run on hover (4th bit true) + {if (["ace_medical_gui"] call EFUNC(common,isModLoaded)) then {call EFUNC(medical_gui,modifyActionTriageLevel)}} + ] call EFUNC(interact_menu,createAction), + [], + _unit + ]; +} forEach ((fullCrew _vehicle) select {_x select 0 != _player && {!unitIsUAV (_x select 0)}}); _actions diff --git a/addons/interaction/functions/fnc_canInteractWithVehicleCrew.sqf b/addons/interaction/functions/fnc_canInteractWithVehicleCrew.sqf new file mode 100644 index 00000000000..a314a8b601a --- /dev/null +++ b/addons/interaction/functions/fnc_canInteractWithVehicleCrew.sqf @@ -0,0 +1,31 @@ +#include "..\script_component.hpp" +/* + * Author: johnb43 + * Checks if a unit can interact with the vehicle crew inside. + * + * Arguments: + * 0: Player + * 1: Vehicle + * + * Return Value: + * Unit can interact with vehicle crew + * + * Example: + * [cursorObject, player] call ace_interaction_fnc_canInteractWithVehicleCrew + * + * Public: No + */ + +params ["_player", "_vehicle"]; + +private _crew = crew _vehicle; + +// If vehicle is empty, quit +if (_crew isEqualTo []) exitWith {true}; + +private _sidePlayer = side group _player; + +(_crew select {_x != _player && {!unitIsUAV _x}}) findIf { // ignore player and UAV units + // Units must all be unconscious, captive or friendly (side group is used in case unit is captive/unconscious) for actions to show up + !captive _x && {lifeState _x in ["HEALTHY", "INJURED"]} && {[_sidePlayer, side group _x] call BIS_fnc_sideIsEnemy} +} == -1 diff --git a/addons/quickmount/config.cpp b/addons/quickmount/config.cpp index 063897aebca..d74d99c0503 100644 --- a/addons/quickmount/config.cpp +++ b/addons/quickmount/config.cpp @@ -5,7 +5,7 @@ class CfgPatches { units[] = {}; weapons[] = {}; requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ace_common"}; + requiredAddons[] = {"ace_interaction"}; author = ECSTRING(common,ACETeam); authors[] = {"Kingsley"}; url = ECSTRING(main,URL); diff --git a/addons/quickmount/functions/fnc_canShowFreeSeats.sqf b/addons/quickmount/functions/fnc_canShowFreeSeats.sqf index 865bab4d517..6812d9bf832 100644 --- a/addons/quickmount/functions/fnc_canShowFreeSeats.sqf +++ b/addons/quickmount/functions/fnc_canShowFreeSeats.sqf @@ -32,8 +32,7 @@ GVAR(enabled) && {isNull getConnectedUAVUnit _unit} && {simulationEnabled _vehicle} && { - -1 == crew _vehicle findIf {alive _x} - || {0.6 <= side group _unit getFriend side group _vehicle} + [_unit, _vehicle] call EFUNC(interaction,canInteractWithVehicleCrew) } && { 0.3 < vectorUp _vehicle select 2 // moveIn* and GetIn* don't work for flipped vehicles