From c1b9ec80ed323a25c2aca254d15e41e9b35864b8 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Mon, 6 Nov 2017 03:03:43 +0300 Subject: [PATCH 01/31] Add quickmount GetIn menu --- addons/quickmount/CfgVehicles.hpp | 47 +++++++++ addons/quickmount/XEH_PREP.hpp | 2 + .../functions/fnc_addGetInActions.sqf | 97 +++++++++++++++++++ .../quickmount/functions/fnc_canShowGetIn.sqf | 22 +++++ addons/quickmount/script_component.hpp | 2 +- 5 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 addons/quickmount/functions/fnc_addGetInActions.sqf create mode 100644 addons/quickmount/functions/fnc_canShowGetIn.sqf diff --git a/addons/quickmount/CfgVehicles.hpp b/addons/quickmount/CfgVehicles.hpp index 0d141d7bc38..ef829078ba9 100644 --- a/addons/quickmount/CfgVehicles.hpp +++ b/addons/quickmount/CfgVehicles.hpp @@ -34,4 +34,51 @@ class CfgVehicles { description = CSTRING(KeybindDescription); }; }; + +#define GETIN_ACTIONS \ + class ACE_Actions { \ + class ACE_MainActions { \ + class GVAR(GetIn) { \ + displayName = "$STR_rscMenu.hppRscGroupRootMenu_Items_GetIn1"; \ + condition = QUOTE(call DFUNC(canShowGetIn)); \ + statement = ""; \ + exceptions[] = {"isNotSwimming"}; \ + insertChildren = QUOTE(call DFUNC(addGetInActions)); \ + }; \ + }; \ + }; \ + class ACE_SelfActions { \ + class GVAR(GetIn) { \ + displayName = "Change seat";/*---------------------------------------------------------------*/ \ + condition = QUOTE(call DFUNC(canShowGetIn)); \ + statement = ""; \ + insertChildren = QUOTE(call DFUNC(addGetInActions)); \ + }; \ + }; + + class LandVehicle; + class Car: LandVehicle { + GETIN_ACTIONS + }; + class Motorcycle: LandVehicle { + GETIN_ACTIONS + }; + class StaticWeapon: LandVehicle { + GETIN_ACTIONS + }; + class Tank: LandVehicle { + GETIN_ACTIONS + }; + class Air; + class Helicopter: Air { + GETIN_ACTIONS + }; + class Plane: Air { + GETIN_ACTIONS + }; + class Ship; + class Ship_F: Ship { + GETIN_ACTIONS + }; + }; diff --git a/addons/quickmount/XEH_PREP.hpp b/addons/quickmount/XEH_PREP.hpp index eba2f68296d..cc9464b8273 100644 --- a/addons/quickmount/XEH_PREP.hpp +++ b/addons/quickmount/XEH_PREP.hpp @@ -1,2 +1,4 @@ +PREP(addGetInActions); +PREP(canShowGetIn); PREP(getInNearest); PREP(moduleInit); diff --git a/addons/quickmount/functions/fnc_addGetInActions.sqf b/addons/quickmount/functions/fnc_addGetInActions.sqf new file mode 100644 index 00000000000..ef6d66ac5d9 --- /dev/null +++ b/addons/quickmount/functions/fnc_addGetInActions.sqf @@ -0,0 +1,97 @@ +/* + * Author: Dystopian + * Create actions for nearest vehicles with cargo. + * + * Arguments: + * 0: Target + * + * Return Value: + * Child actions + * + * Example: + * [cursorObject] call ace_quickmount_fnc_addGetInActions + * + * Public: No + */ +//#define DEBUG_MODE_FULL +#include "script_component.hpp" + +params ["_vehicle", "_player"]; +TRACE_2("params",_vehicle,_player); + +private _vehicleConfig = configFile >> "CfgVehicles" >> typeOf _vehicle; +private _isInVehicle = _player != vehicle _player; +private _statement = {if (_player != vehicle _player) then {moveOut (_this select 1)}; (_this select 1) action (_this select 2)}; + +private _actions = []; +{ + scopeName "crewLoop"; + _x params ["_unit", "_role", "_cargoIndex", "_turretPath", "_isPersonTurret"]; + if (isNull _unit || {!alive _unit}) then { + private ["_name", "_icon", "_statement", "_params"]; + if (!(_turretPath isEqualTo [])) then { // all turrets including FFV + if (_vehicle lockedTurret _turretPath) exitWith {}; + switch (_role) do { + case "gunner": { + if ("UAVPilot" == getText (configFile >> "CfgVehicles" >> (getText (_vehicleConfig >> "crew")) >> "simulation")) then {breakTo "crewLoop"}; + _icon = "A3\ui_f\data\IGUI\Cfg\Actions\getingunner_ca.paa"; + }; + case "commander": { + _icon = "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_commander_ca.paa"; + }; + default { + if (_isPersonTurret) then { + _icon = "A3\ui_f\data\IGUI\Cfg\CrewAimIndicator\gunnerAuto_ca.paa"; + } else { + _icon = "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_gunner_ca.paa"; + }; + }; + }; + _name = getText ([_vehicleConfig, _turretPath] call CBA_fnc_getTurret >> "gunnerName"); + if (_isInVehicle) then { + _params = [_vehicle, _turretPath]; + _statement = {moveOut _player; _player moveInTurret (_this select 2)}; + } else { + _params = ["GetInTurret", _vehicle, _turretPath]; + _statement = {_player action (_this select 2)}; + }; + } else { // cargo, no FFV + if (_cargoIndex > -1) then { + if (_vehicle lockedCargo _cargoIndex) exitWith {}; + _name = format ["%1 %2", localize "str_getin_pos_passenger", _cargoIndex]; + _icon = "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_cargo_ca.paa"; + if (_isInVehicle) then { + _params = [_vehicle, _cargoIndex]; + _statement = {moveOut _player; _player moveInCargo (_this select 2)}; + } else { + _params = ["GetInCargo", _vehicle, _cargoIndex]; + _statement = {_player action (_this select 2)}; + }; + } else { // driver + if (lockedDriver _vehicle) exitWith {}; + if ("UAVPilot" == getText (configFile >> "CfgVehicles" >> (getText (_vehicleConfig >> "crew")) >> "simulation")) then {breakTo "crewLoop"}; + if (_vehicle isKindOf "Air") then { + _name = localize "str_getin_pos_pilot"; + _icon = "A3\ui_f\data\IGUI\Cfg\Actions\getinpilot_ca.paa"; + } else { + _name = localize "str_driver"; + _icon = "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_driver_ca.paa"; + }; + if (_isInVehicle) then { + _params = _vehicle; + _statement = {moveOut _player; _player moveInDriver (_this select 2)}; + } else { + _params = ["GetInDriver", _vehicle]; + _statement = {_player action (_this select 2)}; + }; + }; + }; + private _action = [ + format ["%1%2%3", _role, _cargoIndex, _turretPath], + _name, _icon, _statement, {true}, {}, _params + ] call EFUNC(interact_menu,createAction); + _actions pushBack [_action, [], _vehicle]; + }; +} forEach fullCrew [_vehicle, "", true]; + +_actions diff --git a/addons/quickmount/functions/fnc_canShowGetIn.sqf b/addons/quickmount/functions/fnc_canShowGetIn.sqf new file mode 100644 index 00000000000..149125487ca --- /dev/null +++ b/addons/quickmount/functions/fnc_canShowGetIn.sqf @@ -0,0 +1,22 @@ +/* + * Author: Dystopian + * Create actions for nearest vehicles with cargo. + * + * Arguments: + * 0: Target + * + * Return Value: + * Child actions + * + * Example: + * [cursorObject] call ace_quickmount_fnc_canShowGetIn + * + * Public: No + */ +//#define DEBUG_MODE_FULL +#include "script_component.hpp" + +params ["_target", "_player"]; +TRACE_2("can",_target,_player); + +true diff --git a/addons/quickmount/script_component.hpp b/addons/quickmount/script_component.hpp index a0ec1debd0e..b372d5adb70 100644 --- a/addons/quickmount/script_component.hpp +++ b/addons/quickmount/script_component.hpp @@ -3,7 +3,7 @@ #include "\z\ace\addons\main\script_mod.hpp" // #define DEBUG_MODE_FULL -// #define DISABLE_COMPILE_CACHE +#define DISABLE_COMPILE_CACHE // #define ENABLE_PERFORMANCE_COUNTERS #ifdef DEBUG_ENABLED_QUICKMOUNT From 39c9c8b748772ec0d95f7b52a33cbf54ec166ba7 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Tue, 7 Nov 2017 01:53:14 +0300 Subject: [PATCH 02/31] Add compartment support --- .../functions/fnc_addGetInActions.sqf | 102 +++++++++++++----- 1 file changed, 74 insertions(+), 28 deletions(-) diff --git a/addons/quickmount/functions/fnc_addGetInActions.sqf b/addons/quickmount/functions/fnc_addGetInActions.sqf index ef6d66ac5d9..72d796af0d3 100644 --- a/addons/quickmount/functions/fnc_addGetInActions.sqf +++ b/addons/quickmount/functions/fnc_addGetInActions.sqf @@ -13,27 +13,78 @@ * * Public: No */ -//#define DEBUG_MODE_FULL +#define DEBUG_MODE_FULL #include "script_component.hpp" +// this will check UAV vehicle like Stomper (with cargo seat) +#define IS_CREW_UAV(vehicleConfig) ("UAVPilot" == getText (configFile >> "CfgVehicles" >> (getText (vehicleConfig >> "crew")) >> "simulation")) + params ["_vehicle", "_player"]; -TRACE_2("params",_vehicle,_player); private _vehicleConfig = configFile >> "CfgVehicles" >> typeOf _vehicle; -private _isInVehicle = _player != vehicle _player; -private _statement = {if (_player != vehicle _player) then {moveOut (_this select 1)}; (_this select 1) action (_this select 2)}; +private _isInVehicle = _player in _vehicle; + +private _driverCompartments = (_vehicleConfig >> "driverCompartments") call BIS_fnc_getCfgData; +private _cargoCompartments = getArray (_vehicleConfig >> "cargoCompartments"); +private _cargoCompartmentsLast = count _cargoCompartments - 1; + +// first find current compartment +private _compartment = ""; +if (_isInVehicle) then { + private ["_role", "_turretPath"]; + private _cargoNumber = 0; + { + _role = _x select 1; + if (_player == _x select 0) exitWith { + _turretPath = _x select 3; + }; + if (_role == "cargo") then { + INC(_cargoNumber); + }; + } forEach fullCrew [_vehicle, "", true]; + switch (_role) do { + case "driver": { + _compartment = _driverCompartments; + }; + case "cargo": { + _compartment = _cargoCompartments select (_cargoNumber min _cargoCompartmentsLast); + }; + default { + private _turretConfig = [_vehicleConfig, _turretPath] call CBA_fnc_getTurret; + _compartment = (_turretConfig >> "gunnerCompartments") call BIS_fnc_getCfgData; + }; + }; + TRACE_4("",_role,_turretPath,_cargoNumber,_compartment); +}; + +// second find seats with the same compartment private _actions = []; +private _cargoNumber = -1; { scopeName "crewLoop"; _x params ["_unit", "_role", "_cargoIndex", "_turretPath", "_isPersonTurret"]; - if (isNull _unit || {!alive _unit}) then { + if (!isNull _unit && {alive _unit}) then { + if (_role == "cargo") then { + INC(_cargoNumber); + }; + } else { private ["_name", "_icon", "_statement", "_params"]; if (!(_turretPath isEqualTo [])) then { // all turrets including FFV - if (_vehicle lockedTurret _turretPath) exitWith {}; + if (_vehicle lockedTurret _turretPath) then {breakTo "crewLoop"}; + private _turretConfig = [_vehicleConfig, _turretPath] call CBA_fnc_getTurret; + if (_isInVehicle) then { + if !(_compartment isEqualTo ((_turretConfig >> "gunnerCompartments") call BIS_fnc_getCfgData)) then {breakTo "crewLoop"}; + _params = [_vehicle, _turretPath]; + _statement = {moveOut _player; _player moveInTurret (_this select 2)}; + } else { + _params = ["GetInTurret", _vehicle, _turretPath]; + _statement = {_player action (_this select 2)}; + }; + _name = getText (_turretConfig >> "gunnerName"); switch (_role) do { case "gunner": { - if ("UAVPilot" == getText (configFile >> "CfgVehicles" >> (getText (_vehicleConfig >> "crew")) >> "simulation")) then {breakTo "crewLoop"}; + if (IS_CREW_UAV(_vehicleConfig)) then {breakTo "crewLoop"}; _icon = "A3\ui_f\data\IGUI\Cfg\Actions\getingunner_ca.paa"; }; case "commander": { @@ -47,43 +98,38 @@ private _actions = []; }; }; }; - _name = getText ([_vehicleConfig, _turretPath] call CBA_fnc_getTurret >> "gunnerName"); - if (_isInVehicle) then { - _params = [_vehicle, _turretPath]; - _statement = {moveOut _player; _player moveInTurret (_this select 2)}; - } else { - _params = ["GetInTurret", _vehicle, _turretPath]; - _statement = {_player action (_this select 2)}; - }; } else { // cargo, no FFV if (_cargoIndex > -1) then { - if (_vehicle lockedCargo _cargoIndex) exitWith {}; - _name = format ["%1 %2", localize "str_getin_pos_passenger", _cargoIndex]; - _icon = "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_cargo_ca.paa"; + INC(_cargoNumber); + if (_vehicle lockedCargo _cargoIndex) then {breakTo "crewLoop"}; if (_isInVehicle) then { + if !(_compartment isEqualTo (_cargoCompartments select (_cargoNumber min _cargoCompartmentsLast))) then {breakTo "crewLoop"}; _params = [_vehicle, _cargoIndex]; _statement = {moveOut _player; _player moveInCargo (_this select 2)}; } else { - _params = ["GetInCargo", _vehicle, _cargoIndex]; + _params = ["GetInCargo", _vehicle, _cargoNumber]; _statement = {_player action (_this select 2)}; }; + _name = format ["%1 %2", localize "str_getin_pos_passenger", _cargoNumber + 1]; + _icon = "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_cargo_ca.paa"; } else { // driver - if (lockedDriver _vehicle) exitWith {}; - if ("UAVPilot" == getText (configFile >> "CfgVehicles" >> (getText (_vehicleConfig >> "crew")) >> "simulation")) then {breakTo "crewLoop"}; - if (_vehicle isKindOf "Air") then { - _name = localize "str_getin_pos_pilot"; - _icon = "A3\ui_f\data\IGUI\Cfg\Actions\getinpilot_ca.paa"; - } else { - _name = localize "str_driver"; - _icon = "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_driver_ca.paa"; - }; + if (lockedDriver _vehicle) then {breakTo "crewLoop"}; + if (IS_CREW_UAV(_vehicleConfig)) then {breakTo "crewLoop"}; if (_isInVehicle) then { + if !(_compartment isEqualTo _driverCompartments) then {breakTo "crewLoop"}; _params = _vehicle; _statement = {moveOut _player; _player moveInDriver (_this select 2)}; } else { _params = ["GetInDriver", _vehicle]; _statement = {_player action (_this select 2)}; }; + if (_vehicle isKindOf "Air") then { + _name = localize "str_getin_pos_pilot"; + _icon = "A3\ui_f\data\IGUI\Cfg\Actions\getinpilot_ca.paa"; + } else { + _name = localize "str_driver"; + _icon = "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_driver_ca.paa"; + }; }; }; private _action = [ From 9e73ca877d72837d7ee48807f19346a45faa24cb Mon Sep 17 00:00:00 2001 From: Dystopian Date: Wed, 8 Nov 2017 01:44:39 +0300 Subject: [PATCH 03/31] Check engine, check pilot, check static turret driver --- .../functions/fnc_addGetInActions.sqf | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/addons/quickmount/functions/fnc_addGetInActions.sqf b/addons/quickmount/functions/fnc_addGetInActions.sqf index 72d796af0d3..d4b61bfbcc8 100644 --- a/addons/quickmount/functions/fnc_addGetInActions.sqf +++ b/addons/quickmount/functions/fnc_addGetInActions.sqf @@ -16,15 +16,23 @@ #define DEBUG_MODE_FULL #include "script_component.hpp" +scopeName "main"; + // this will check UAV vehicle like Stomper (with cargo seat) #define IS_CREW_UAV(vehicleConfig) ("UAVPilot" == getText (configFile >> "CfgVehicles" >> (getText (vehicleConfig >> "crew")) >> "simulation")) +// this is used in statements when move from driver +#define MOVEOUT_AND_CHECK_ENGINE_ON private _preserveEngineOn = _player == driver _target && {isEngineOn _target}; moveOut _player; if (_preserveEngineOn) then {_target engineOn true} + params ["_vehicle", "_player"]; private _vehicleConfig = configFile >> "CfgVehicles" >> typeOf _vehicle; private _isInVehicle = _player in _vehicle; private _driverCompartments = (_vehicleConfig >> "driverCompartments") call BIS_fnc_getCfgData; +// Air class by default has driverCompartments=0 and cargoCompartments[]={0}, so we have to disable them +private _isPilotAndIsolated = _driverCompartments isEqualTo 0 && {_vehicle isKindOf "Air"}; + private _cargoCompartments = getArray (_vehicleConfig >> "cargoCompartments"); private _cargoCompartmentsLast = count _cargoCompartments - 1; @@ -45,6 +53,9 @@ if (_isInVehicle) then { switch (_role) do { case "driver": { + if (_isPilotAndIsolated) then { + [] breakOut "main"; + }; _compartment = _driverCompartments; }; case "cargo": { @@ -76,7 +87,7 @@ private _cargoNumber = -1; if (_isInVehicle) then { if !(_compartment isEqualTo ((_turretConfig >> "gunnerCompartments") call BIS_fnc_getCfgData)) then {breakTo "crewLoop"}; _params = [_vehicle, _turretPath]; - _statement = {moveOut _player; _player moveInTurret (_this select 2)}; + _statement = {MOVEOUT_AND_CHECK_ENGINE_ON; _player moveInTurret (_this select 2)}; } else { _params = ["GetInTurret", _vehicle, _turretPath]; _statement = {_player action (_this select 2)}; @@ -105,7 +116,7 @@ private _cargoNumber = -1; if (_isInVehicle) then { if !(_compartment isEqualTo (_cargoCompartments select (_cargoNumber min _cargoCompartmentsLast))) then {breakTo "crewLoop"}; _params = [_vehicle, _cargoIndex]; - _statement = {moveOut _player; _player moveInCargo (_this select 2)}; + _statement = {MOVEOUT_AND_CHECK_ENGINE_ON; _player moveInCargo (_this select 2)}; } else { _params = ["GetInCargo", _vehicle, _cargoNumber]; _statement = {_player action (_this select 2)}; @@ -113,10 +124,20 @@ private _cargoNumber = -1; _name = format ["%1 %2", localize "str_getin_pos_passenger", _cargoNumber + 1]; _icon = "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_cargo_ca.paa"; } else { // driver - if (lockedDriver _vehicle) then {breakTo "crewLoop"}; - if (IS_CREW_UAV(_vehicleConfig)) then {breakTo "crewLoop"}; + if ( + lockedDriver _vehicle + || {IS_CREW_UAV(_vehicleConfig)} + || {0 == getNumber (_vehicleConfig >> "hasDriver")} + ) then { + breakTo "crewLoop"; + }; if (_isInVehicle) then { - if !(_compartment isEqualTo _driverCompartments) then {breakTo "crewLoop"}; + if ( + !(_compartment isEqualTo _driverCompartments) + || {_isPilotAndIsolated} + ) then { + breakTo "crewLoop"; + }; _params = _vehicle; _statement = {moveOut _player; _player moveInDriver (_this select 2)}; } else { From 0222463de99aad3b0ccc7fa99d6af14dbfa10fc1 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Wed, 8 Nov 2017 13:33:28 +0300 Subject: [PATCH 04/31] Add doc, condition, translation --- addons/quickmount/CfgVehicles.hpp | 12 ++++----- ...ctions.sqf => fnc_addFreeSeatsActions.sqf} | 8 +++--- .../functions/fnc_canShowFreeSeats.sqf | 27 +++++++++++++++++++ .../quickmount/functions/fnc_canShowGetIn.sqf | 22 --------------- addons/quickmount/stringtable.xml | 4 +++ 5 files changed, 41 insertions(+), 32 deletions(-) rename addons/quickmount/functions/{fnc_addGetInActions.sqf => fnc_addFreeSeatsActions.sqf} (97%) create mode 100644 addons/quickmount/functions/fnc_canShowFreeSeats.sqf delete mode 100644 addons/quickmount/functions/fnc_canShowGetIn.sqf diff --git a/addons/quickmount/CfgVehicles.hpp b/addons/quickmount/CfgVehicles.hpp index ef829078ba9..ae86725d66b 100644 --- a/addons/quickmount/CfgVehicles.hpp +++ b/addons/quickmount/CfgVehicles.hpp @@ -40,19 +40,19 @@ class CfgVehicles { class ACE_MainActions { \ class GVAR(GetIn) { \ displayName = "$STR_rscMenu.hppRscGroupRootMenu_Items_GetIn1"; \ - condition = QUOTE(call DFUNC(canShowGetIn)); \ + condition = QUOTE(call DFUNC(canShowFreeSeats)); \ statement = ""; \ exceptions[] = {"isNotSwimming"}; \ - insertChildren = QUOTE(call DFUNC(addGetInActions)); \ + insertChildren = QUOTE(call DFUNC(addFreeSeatsActions)); \ }; \ }; \ }; \ class ACE_SelfActions { \ - class GVAR(GetIn) { \ - displayName = "Change seat";/*---------------------------------------------------------------*/ \ - condition = QUOTE(call DFUNC(canShowGetIn)); \ + class GVAR(ChangeSeat) { \ + displayName = CSTRING(ChangeSeat); \ + condition = QUOTE(call DFUNC(canShowFreeSeats)); \ statement = ""; \ - insertChildren = QUOTE(call DFUNC(addGetInActions)); \ + insertChildren = QUOTE(call DFUNC(addFreeSeatsActions)); \ }; \ }; diff --git a/addons/quickmount/functions/fnc_addGetInActions.sqf b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf similarity index 97% rename from addons/quickmount/functions/fnc_addGetInActions.sqf rename to addons/quickmount/functions/fnc_addFreeSeatsActions.sqf index d4b61bfbcc8..45a89477934 100644 --- a/addons/quickmount/functions/fnc_addGetInActions.sqf +++ b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf @@ -1,19 +1,19 @@ /* * Author: Dystopian - * Create actions for nearest vehicles with cargo. + * Creates actions for vehicle free seats. * * Arguments: - * 0: Target + * 0: Vehicle + * 1: Unit * * Return Value: * Child actions * * Example: - * [cursorObject] call ace_quickmount_fnc_addGetInActions + * [cursorObject, player] call ace_quickmount_fnc_addFreeSeatsActions * * Public: No */ -#define DEBUG_MODE_FULL #include "script_component.hpp" scopeName "main"; diff --git a/addons/quickmount/functions/fnc_canShowFreeSeats.sqf b/addons/quickmount/functions/fnc_canShowFreeSeats.sqf new file mode 100644 index 00000000000..b9e182b9561 --- /dev/null +++ b/addons/quickmount/functions/fnc_canShowFreeSeats.sqf @@ -0,0 +1,27 @@ +/* + * Author: Dystopian + * Checks if Free Seats menu can be shown. + * + * Arguments: + * 0: Vehicle + * 1: Unit + * + * Return Value: + * Able to show menu + * + * Example: + * [cursorObject, player] call ace_quickmount_fnc_canShowFreeSeats + * + * Public: No + */ +#include "script_component.hpp" + +params ["_vehicle", "_unit"]; + +GVAR(enabled) +&& {alive _vehicle} +&& {2 > locked _vehicle} +&& { + 0 == {alive _x} count crew _vehicle + || {0.6 <= side group _unit getFriend side group _vehicle} +} diff --git a/addons/quickmount/functions/fnc_canShowGetIn.sqf b/addons/quickmount/functions/fnc_canShowGetIn.sqf deleted file mode 100644 index 149125487ca..00000000000 --- a/addons/quickmount/functions/fnc_canShowGetIn.sqf +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Author: Dystopian - * Create actions for nearest vehicles with cargo. - * - * Arguments: - * 0: Target - * - * Return Value: - * Child actions - * - * Example: - * [cursorObject] call ace_quickmount_fnc_canShowGetIn - * - * Public: No - */ -//#define DEBUG_MODE_FULL -#include "script_component.hpp" - -params ["_target", "_player"]; -TRACE_2("can",_target,_player); - -true diff --git a/addons/quickmount/stringtable.xml b/addons/quickmount/stringtable.xml index ce9bb9465fa..1489a29099b 100644 --- a/addons/quickmount/stringtable.xml +++ b/addons/quickmount/stringtable.xml @@ -100,5 +100,9 @@ 優先想進入哪個座位。 Priorytet pozycji w pojeździe + + Change seat + Пересесть + From 9e17c18ac404f18f61bd36a94bcc06c5113c3604 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Sat, 11 Nov 2017 17:33:30 +0300 Subject: [PATCH 05/31] Add hybrid config entries, fix MP issue --- addons/quickmount/XEH_PREP.hpp | 4 +- .../functions/fnc_addFreeSeatsActions.sqf | 66 ++++++++++++------- addons/quickmount/script_component.hpp | 2 +- 3 files changed, 47 insertions(+), 25 deletions(-) diff --git a/addons/quickmount/XEH_PREP.hpp b/addons/quickmount/XEH_PREP.hpp index cc9464b8273..5b0ec5a0425 100644 --- a/addons/quickmount/XEH_PREP.hpp +++ b/addons/quickmount/XEH_PREP.hpp @@ -1,4 +1,4 @@ -PREP(addGetInActions); -PREP(canShowGetIn); +PREP(addFreeSeatsActions); +PREP(canShowFreeSeats); PREP(getInNearest); PREP(moduleInit); diff --git a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf index 45a89477934..9d5b1f11af7 100644 --- a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf +++ b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf @@ -16,29 +16,54 @@ */ #include "script_component.hpp" -scopeName "main"; +#define TO_STRING(arg) if !(arg isEqualType "") then {arg = "Compartment" + str arg} // this will check UAV vehicle like Stomper (with cargo seat) #define IS_CREW_UAV(vehicleConfig) ("UAVPilot" == getText (configFile >> "CfgVehicles" >> (getText (vehicleConfig >> "crew")) >> "simulation")) // this is used in statements when move from driver -#define MOVEOUT_AND_CHECK_ENGINE_ON private _preserveEngineOn = _player == driver _target && {isEngineOn _target}; moveOut _player; if (_preserveEngineOn) then {_target engineOn true} +#define MOVEOUT_AND_CHECK_ENGINE_ON \ + private _preserveEngineOn = _player == driver _target && {isEngineOn _target}; \ + moveOut _player; \ + if (_preserveEngineOn) then {_target engineOn true}; + +// moveIn right after moveOut doesn't work in MP for non-local vehicles, player just stays out +// we have to wait some time (e.g. until player is out) +// usually it takes 1 frame in SP and 3 frames in MP, so in MP looks a little lagging +#define MOVE_IN(command) [ARR_3( \ + {isNull objectParent (_this select 0)}, \ + {(_this select 0) command (_this select 1)}, \ + [ARR_2(_player,_this select 2)] \ +)] call CBA_fnc_waitUntilAndExecute; + +scopeName "main"; params ["_vehicle", "_player"]; private _vehicleConfig = configFile >> "CfgVehicles" >> typeOf _vehicle; private _isInVehicle = _player in _vehicle; -private _driverCompartments = (_vehicleConfig >> "driverCompartments") call BIS_fnc_getCfgData; -// Air class by default has driverCompartments=0 and cargoCompartments[]={0}, so we have to disable them -private _isPilotAndIsolated = _driverCompartments isEqualTo 0 && {_vehicle isKindOf "Air"}; - -private _cargoCompartments = getArray (_vehicleConfig >> "cargoCompartments"); -private _cargoCompartmentsLast = count _cargoCompartments - 1; +private ["_driverCompartments", "_isPilotAndIsolated", "_cargoCompartments", "_cargoCompartmentsLast", "_compartment"]; -// first find current compartment -private _compartment = ""; if (_isInVehicle) then { + _driverCompartments = (_vehicleConfig >> "driverCompartments") call BIS_fnc_getCfgData; + // Air class by default has driverCompartments=0 and cargoCompartments[]={0}, so we have to disable them + _isPilotAndIsolated = _driverCompartments isEqualTo 0 && {_vehicle isKindOf "Air"}; + TO_STRING(_driverCompartments); + + _cargoCompartments = getArray (_vehicleConfig >> "cargoCompartments"); + _cargoCompartments = _cargoCompartments apply { + if (_x isEqualType "") then { + _x + } else { + "Compartment" + str _x + }; + }; + _cargoCompartmentsLast = count _cargoCompartments - 1; + + TRACE_2("",_driverCompartments,_cargoCompartments); + + // find current compartment private ["_role", "_turretPath"]; private _cargoNumber = 0; { @@ -64,12 +89,12 @@ if (_isInVehicle) then { default { private _turretConfig = [_vehicleConfig, _turretPath] call CBA_fnc_getTurret; _compartment = (_turretConfig >> "gunnerCompartments") call BIS_fnc_getCfgData; + TO_STRING(_compartment); }; }; TRACE_4("",_role,_turretPath,_cargoNumber,_compartment); }; -// second find seats with the same compartment private _actions = []; private _cargoNumber = -1; { @@ -85,9 +110,11 @@ private _cargoNumber = -1; if (_vehicle lockedTurret _turretPath) then {breakTo "crewLoop"}; private _turretConfig = [_vehicleConfig, _turretPath] call CBA_fnc_getTurret; if (_isInVehicle) then { - if !(_compartment isEqualTo ((_turretConfig >> "gunnerCompartments") call BIS_fnc_getCfgData)) then {breakTo "crewLoop"}; + private _gunnerCompartments = (_turretConfig >> "gunnerCompartments") call BIS_fnc_getCfgData; + TO_STRING(_gunnerCompartments); + if (_compartment != _gunnerCompartments) then {breakTo "crewLoop"}; _params = [_vehicle, _turretPath]; - _statement = {MOVEOUT_AND_CHECK_ENGINE_ON; _player moveInTurret (_this select 2)}; + _statement = {MOVEOUT_AND_CHECK_ENGINE_ON; MOVE_IN(moveInTurret)}; } else { _params = ["GetInTurret", _vehicle, _turretPath]; _statement = {_player action (_this select 2)}; @@ -114,9 +141,9 @@ private _cargoNumber = -1; INC(_cargoNumber); if (_vehicle lockedCargo _cargoIndex) then {breakTo "crewLoop"}; if (_isInVehicle) then { - if !(_compartment isEqualTo (_cargoCompartments select (_cargoNumber min _cargoCompartmentsLast))) then {breakTo "crewLoop"}; + if (_compartment != (_cargoCompartments select (_cargoNumber min _cargoCompartmentsLast))) then {breakTo "crewLoop"}; _params = [_vehicle, _cargoIndex]; - _statement = {MOVEOUT_AND_CHECK_ENGINE_ON; _player moveInCargo (_this select 2)}; + _statement = {MOVEOUT_AND_CHECK_ENGINE_ON; MOVE_IN(moveInCargo)}; } else { _params = ["GetInCargo", _vehicle, _cargoNumber]; _statement = {_player action (_this select 2)}; @@ -132,14 +159,9 @@ private _cargoNumber = -1; breakTo "crewLoop"; }; if (_isInVehicle) then { - if ( - !(_compartment isEqualTo _driverCompartments) - || {_isPilotAndIsolated} - ) then { - breakTo "crewLoop"; - }; + if (_compartment != _driverCompartments || {_isPilotAndIsolated}) then {breakTo "crewLoop"}; _params = _vehicle; - _statement = {moveOut _player; _player moveInDriver (_this select 2)}; + _statement = {moveOut _player; MOVE_IN(moveInDriver)}; } else { _params = ["GetInDriver", _vehicle]; _statement = {_player action (_this select 2)}; diff --git a/addons/quickmount/script_component.hpp b/addons/quickmount/script_component.hpp index b372d5adb70..a0ec1debd0e 100644 --- a/addons/quickmount/script_component.hpp +++ b/addons/quickmount/script_component.hpp @@ -3,7 +3,7 @@ #include "\z\ace\addons\main\script_mod.hpp" // #define DEBUG_MODE_FULL -#define DISABLE_COMPILE_CACHE +// #define DISABLE_COMPILE_CACHE // #define ENABLE_PERFORMANCE_COUNTERS #ifdef DEBUG_ENABLED_QUICKMOUNT From 414d00e70c7d52262387e27dde99f3100241e203 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Sat, 11 Nov 2017 17:59:18 +0300 Subject: [PATCH 06/31] Optimize condition --- addons/quickmount/functions/fnc_addFreeSeatsActions.sqf | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf index 9d5b1f11af7..1d8150e5cff 100644 --- a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf +++ b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf @@ -129,11 +129,10 @@ private _cargoNumber = -1; _icon = "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_commander_ca.paa"; }; default { - if (_isPersonTurret) then { - _icon = "A3\ui_f\data\IGUI\Cfg\CrewAimIndicator\gunnerAuto_ca.paa"; - } else { - _icon = "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_gunner_ca.paa"; - }; + _icon = [ + "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_gunner_ca.paa", + "A3\ui_f\data\IGUI\Cfg\CrewAimIndicator\gunnerAuto_ca.paa" + ] select _isPersonTurret; }; }; } else { // cargo, no FFV From 5316536d85122593e9ef1b6fe39222bc0a54822d Mon Sep 17 00:00:00 2001 From: Dystopian Date: Sun, 12 Nov 2017 05:36:30 +0300 Subject: [PATCH 07/31] Ignore Enabled setting in vehicle --- addons/quickmount/functions/fnc_canShowFreeSeats.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/quickmount/functions/fnc_canShowFreeSeats.sqf b/addons/quickmount/functions/fnc_canShowFreeSeats.sqf index b9e182b9561..5311e937a1f 100644 --- a/addons/quickmount/functions/fnc_canShowFreeSeats.sqf +++ b/addons/quickmount/functions/fnc_canShowFreeSeats.sqf @@ -18,7 +18,7 @@ params ["_vehicle", "_unit"]; -GVAR(enabled) +(GVAR(enabled) || {!isNull objectParent _unit}) && {alive _vehicle} && {2 > locked _vehicle} && { From 8af32963ea9b65f5d873578f74d28f42bf6ef468 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Sun, 12 Nov 2017 14:34:27 +0300 Subject: [PATCH 08/31] Work around SQF validator macro issue --- .../quickmount/functions/fnc_addFreeSeatsActions.sqf | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf index 1d8150e5cff..97d1a26e4d2 100644 --- a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf +++ b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf @@ -30,11 +30,12 @@ // moveIn right after moveOut doesn't work in MP for non-local vehicles, player just stays out // we have to wait some time (e.g. until player is out) // usually it takes 1 frame in SP and 3 frames in MP, so in MP looks a little lagging -#define MOVE_IN(command) [ARR_3( \ - {isNull objectParent (_this select 0)}, \ - {(_this select 0) command (_this select 1)}, \ - [ARR_2(_player,_this select 2)] \ -)] call CBA_fnc_waitUntilAndExecute; +#define MOVE_IN(command) \ + [ARR_3( \ + {isNull objectParent (_this select 0)}, \ + {(_this select 0) command (_this select 1)}, \ + [ARR_2(_player,_this select 2)] \ + )] call CBA_fnc_waitUntilAndExecute; scopeName "main"; From 3e3993ac14db431c0d1d9ddd89eb2c41fb8c6fdb Mon Sep 17 00:00:00 2001 From: Dystopian Date: Sun, 12 Nov 2017 16:33:19 +0300 Subject: [PATCH 09/31] Fix config macro entries --- addons/quickmount/CfgVehicles.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/addons/quickmount/CfgVehicles.hpp b/addons/quickmount/CfgVehicles.hpp index ae86725d66b..7c887be2682 100644 --- a/addons/quickmount/CfgVehicles.hpp +++ b/addons/quickmount/CfgVehicles.hpp @@ -54,31 +54,31 @@ class CfgVehicles { statement = ""; \ insertChildren = QUOTE(call DFUNC(addFreeSeatsActions)); \ }; \ - }; + } class LandVehicle; class Car: LandVehicle { - GETIN_ACTIONS + GETIN_ACTIONS; }; class Motorcycle: LandVehicle { - GETIN_ACTIONS + GETIN_ACTIONS; }; class StaticWeapon: LandVehicle { - GETIN_ACTIONS + GETIN_ACTIONS; }; class Tank: LandVehicle { - GETIN_ACTIONS + GETIN_ACTIONS; }; class Air; class Helicopter: Air { - GETIN_ACTIONS + GETIN_ACTIONS; }; class Plane: Air { - GETIN_ACTIONS + GETIN_ACTIONS; }; class Ship; class Ship_F: Ship { - GETIN_ACTIONS + GETIN_ACTIONS; }; }; From 02d5a69910ea875511b3541510bfee47970da493 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Sun, 26 Nov 2017 23:27:18 +0300 Subject: [PATCH 10/31] Add workaround for getting damage when seat changing while moving --- .../functions/fnc_addFreeSeatsActions.sqf | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf index 97d1a26e4d2..8bd49528936 100644 --- a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf +++ b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf @@ -21,10 +21,18 @@ // this will check UAV vehicle like Stomper (with cargo seat) #define IS_CREW_UAV(vehicleConfig) ("UAVPilot" == getText (configFile >> "CfgVehicles" >> (getText (vehicleConfig >> "crew")) >> "simulation")) +// workaround getting damage when moveout while vehicle is moving +#define MOVEOUT_AND_BLOCK_DAMAGE \ + if (isDamageAllowed _player) then { \ + _player allowDamage false; \ + SETVAR(_player,GVAR(damageBlocked),true); \ + }; \ + moveOut _player; + // this is used in statements when move from driver -#define MOVEOUT_AND_CHECK_ENGINE_ON \ +#define MOVEOUT_AND_BLOCK_DAMAGE_AND_CHECK_ENGINE_ON \ private _preserveEngineOn = _player == driver _target && {isEngineOn _target}; \ - moveOut _player; \ + MOVEOUT_AND_BLOCK_DAMAGE; \ if (_preserveEngineOn) then {_target engineOn true}; // moveIn right after moveOut doesn't work in MP for non-local vehicles, player just stays out @@ -33,7 +41,14 @@ #define MOVE_IN(command) \ [ARR_3( \ {isNull objectParent (_this select 0)}, \ - {(_this select 0) command (_this select 1)}, \ + { \ + params [ARR_2("_player","_moveInParams")]; \ + _player command _moveInParams; \ + if (GETVAR(_player,GVAR(damageBlocked),false)) then { \ + _player allowDamage true; \ + SETVAR(_player,GVAR(damageBlocked),nil); \ + }; \ + }, \ [ARR_2(_player,_this select 2)] \ )] call CBA_fnc_waitUntilAndExecute; @@ -115,7 +130,7 @@ private _cargoNumber = -1; TO_STRING(_gunnerCompartments); if (_compartment != _gunnerCompartments) then {breakTo "crewLoop"}; _params = [_vehicle, _turretPath]; - _statement = {MOVEOUT_AND_CHECK_ENGINE_ON; MOVE_IN(moveInTurret)}; + _statement = {MOVEOUT_AND_BLOCK_DAMAGE_AND_CHECK_ENGINE_ON; MOVE_IN(moveInTurret)}; } else { _params = ["GetInTurret", _vehicle, _turretPath]; _statement = {_player action (_this select 2)}; @@ -143,7 +158,7 @@ private _cargoNumber = -1; if (_isInVehicle) then { if (_compartment != (_cargoCompartments select (_cargoNumber min _cargoCompartmentsLast))) then {breakTo "crewLoop"}; _params = [_vehicle, _cargoIndex]; - _statement = {MOVEOUT_AND_CHECK_ENGINE_ON; MOVE_IN(moveInCargo)}; + _statement = {MOVEOUT_AND_BLOCK_DAMAGE_AND_CHECK_ENGINE_ON; MOVE_IN(moveInCargo)}; } else { _params = ["GetInCargo", _vehicle, _cargoNumber]; _statement = {_player action (_this select 2)}; @@ -161,7 +176,7 @@ private _cargoNumber = -1; if (_isInVehicle) then { if (_compartment != _driverCompartments || {_isPilotAndIsolated}) then {breakTo "crewLoop"}; _params = _vehicle; - _statement = {moveOut _player; MOVE_IN(moveInDriver)}; + _statement = {MOVEOUT_AND_BLOCK_DAMAGE; MOVE_IN(moveInDriver)}; } else { _params = ["GetInDriver", _vehicle]; _statement = {_player action (_this select 2)}; From 17ca955298b11189c62f8e49b092642840eea382 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Mon, 27 Nov 2017 00:56:52 +0300 Subject: [PATCH 11/31] Add setting for Get In menu disabling --- addons/quickmount/XEH_preInit.sqf | 8 ++++++++ addons/quickmount/functions/fnc_canShowFreeSeats.sqf | 2 +- addons/quickmount/stringtable.xml | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/addons/quickmount/XEH_preInit.sqf b/addons/quickmount/XEH_preInit.sqf index b47cf6628db..638df36861c 100644 --- a/addons/quickmount/XEH_preInit.sqf +++ b/addons/quickmount/XEH_preInit.sqf @@ -6,4 +6,12 @@ PREP_RECOMPILE_START; #include "XEH_PREP.hpp" PREP_RECOMPILE_END; +[ + QGVAR(enableGetInMenu), + "CHECKBOX", + localize LSTRING(SettingEnableGetInMenuName), + format ["ACE %1", localize LSTRING(Category)], + true +] call CBA_settings_fnc_init; + ADDON = true; diff --git a/addons/quickmount/functions/fnc_canShowFreeSeats.sqf b/addons/quickmount/functions/fnc_canShowFreeSeats.sqf index 5311e937a1f..51de01b110d 100644 --- a/addons/quickmount/functions/fnc_canShowFreeSeats.sqf +++ b/addons/quickmount/functions/fnc_canShowFreeSeats.sqf @@ -18,7 +18,7 @@ params ["_vehicle", "_unit"]; -(GVAR(enabled) || {!isNull objectParent _unit}) +(GVAR(enabled) && {GVAR(enableGetInMenu)} || {!isNull objectParent _unit}) && {alive _vehicle} && {2 > locked _vehicle} && { diff --git a/addons/quickmount/stringtable.xml b/addons/quickmount/stringtable.xml index f1ae152a822..23dcf7ca2ba 100644 --- a/addons/quickmount/stringtable.xml +++ b/addons/quickmount/stringtable.xml @@ -115,5 +115,9 @@ Change seat Пересесть + + "Get In" interaction + Меню "Сесть" + From a66d97e8e866fa2459565e12ab39d3beb01c2bc8 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Sat, 23 Dec 2017 13:22:04 +0300 Subject: [PATCH 12/31] Fix race when 2 players try to get the same seat --- .../functions/fnc_addFreeSeatsActions.sqf | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf index 8bd49528936..d2392921cec 100644 --- a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf +++ b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf @@ -16,7 +16,7 @@ */ #include "script_component.hpp" -#define TO_STRING(arg) if !(arg isEqualType "") then {arg = "Compartment" + str arg} +#define TO_STRING(var) if !(var isEqualType "") then {var = "Compartment" + str var} // this will check UAV vehicle like Stomper (with cargo seat) #define IS_CREW_UAV(vehicleConfig) ("UAVPilot" == getText (configFile >> "CfgVehicles" >> (getText (vehicleConfig >> "crew")) >> "simulation")) @@ -38,16 +38,31 @@ // moveIn right after moveOut doesn't work in MP for non-local vehicles, player just stays out // we have to wait some time (e.g. until player is out) // usually it takes 1 frame in SP and 3 frames in MP, so in MP looks a little lagging +// also if unit isn't moved to new seat in 1 second, we move him back to his seat #define MOVE_IN(command) \ [ARR_3( \ {isNull objectParent (_this select 0)}, \ { \ params [ARR_2("_player","_moveInParams")]; \ _player command _moveInParams; \ - if (GETVAR(_player,GVAR(damageBlocked),false)) then { \ - _player allowDamage true; \ - SETVAR(_player,GVAR(damageBlocked),nil); \ - }; \ + [ARR_5( \ + {!isNull objectParent _this}, \ + { \ + if (GETVAR(_this,GVAR(damageBlocked),false)) then { \ + _this allowDamage true; \ + SETVAR(_this,GVAR(damageBlocked),nil); \ + }; \ + }, \ + _player, \ + 1, \ + { \ + (_this getVariable QGVAR(moveBackParams)) call (_this getVariable QGVAR(moveBackCode)); \ + if (GETVAR(_this,GVAR(damageBlocked),false)) then { \ + _this allowDamage true; \ + SETVAR(_this,GVAR(damageBlocked),nil); \ + }; \ + } \ + )] call CBA_fnc_waitUntilAndExecute; \ }, \ [ARR_2(_player,_this select 2)] \ )] call CBA_fnc_waitUntilAndExecute; @@ -80,11 +95,12 @@ if (_isInVehicle) then { TRACE_2("",_driverCompartments,_cargoCompartments); // find current compartment - private ["_role", "_turretPath"]; + private ["_role", "_cargoIndex", "_turretPath"]; private _cargoNumber = 0; { _role = _x select 1; if (_player == _x select 0) exitWith { + _cargoIndex = _x select 2; _turretPath = _x select 3; }; if (_role == "cargo") then { @@ -98,17 +114,23 @@ if (_isInVehicle) then { [] breakOut "main"; }; _compartment = _driverCompartments; + _player setVariable [QGVAR(moveBackCode), {(_this select 0) moveInDriver (_this select 1)}]; + _player setVariable [QGVAR(moveBackParams), [_player, _vehicle]]; }; case "cargo": { _compartment = _cargoCompartments select (_cargoNumber min _cargoCompartmentsLast); + _player setVariable [QGVAR(moveBackCode), {(_this select 0) moveInCargo [_this select 1, _this select 2]}]; + _player setVariable [QGVAR(moveBackParams), [_player, _vehicle, _cargoIndex]]; }; default { private _turretConfig = [_vehicleConfig, _turretPath] call CBA_fnc_getTurret; _compartment = (_turretConfig >> "gunnerCompartments") call BIS_fnc_getCfgData; TO_STRING(_compartment); + _player setVariable [QGVAR(moveBackCode), {(_this select 0) moveInTurret [_this select 1, _this select 2]}]; + _player setVariable [QGVAR(moveBackParams), [_player, _vehicle, _turretPath]]; }; }; - TRACE_4("",_role,_turretPath,_cargoNumber,_compartment); + TRACE_5("",_role,_cargoIndex,_turretPath,_cargoNumber,_compartment); }; private _actions = []; @@ -122,7 +144,7 @@ private _cargoNumber = -1; }; } else { private ["_name", "_icon", "_statement", "_params"]; - if (!(_turretPath isEqualTo [])) then { // all turrets including FFV + if !(_turretPath isEqualTo []) then { // all turrets including FFV if (_vehicle lockedTurret _turretPath) then {breakTo "crewLoop"}; private _turretConfig = [_vehicleConfig, _turretPath] call CBA_fnc_getTurret; if (_isInVehicle) then { From 81f711d6a8283e703d570e6ed6a28aded6e0297d Mon Sep 17 00:00:00 2001 From: Dystopian Date: Sun, 24 Dec 2017 03:16:15 +0300 Subject: [PATCH 13/31] Convert if-else to switch --- .../functions/fnc_addFreeSeatsActions.sqf | 90 ++++++++++--------- 1 file changed, 46 insertions(+), 44 deletions(-) diff --git a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf index d2392921cec..288761f3104 100644 --- a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf +++ b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf @@ -144,50 +144,8 @@ private _cargoNumber = -1; }; } else { private ["_name", "_icon", "_statement", "_params"]; - if !(_turretPath isEqualTo []) then { // all turrets including FFV - if (_vehicle lockedTurret _turretPath) then {breakTo "crewLoop"}; - private _turretConfig = [_vehicleConfig, _turretPath] call CBA_fnc_getTurret; - if (_isInVehicle) then { - private _gunnerCompartments = (_turretConfig >> "gunnerCompartments") call BIS_fnc_getCfgData; - TO_STRING(_gunnerCompartments); - if (_compartment != _gunnerCompartments) then {breakTo "crewLoop"}; - _params = [_vehicle, _turretPath]; - _statement = {MOVEOUT_AND_BLOCK_DAMAGE_AND_CHECK_ENGINE_ON; MOVE_IN(moveInTurret)}; - } else { - _params = ["GetInTurret", _vehicle, _turretPath]; - _statement = {_player action (_this select 2)}; - }; - _name = getText (_turretConfig >> "gunnerName"); - switch (_role) do { - case "gunner": { - if (IS_CREW_UAV(_vehicleConfig)) then {breakTo "crewLoop"}; - _icon = "A3\ui_f\data\IGUI\Cfg\Actions\getingunner_ca.paa"; - }; - case "commander": { - _icon = "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_commander_ca.paa"; - }; - default { - _icon = [ - "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_gunner_ca.paa", - "A3\ui_f\data\IGUI\Cfg\CrewAimIndicator\gunnerAuto_ca.paa" - ] select _isPersonTurret; - }; - }; - } else { // cargo, no FFV - if (_cargoIndex > -1) then { - INC(_cargoNumber); - if (_vehicle lockedCargo _cargoIndex) then {breakTo "crewLoop"}; - if (_isInVehicle) then { - if (_compartment != (_cargoCompartments select (_cargoNumber min _cargoCompartmentsLast))) then {breakTo "crewLoop"}; - _params = [_vehicle, _cargoIndex]; - _statement = {MOVEOUT_AND_BLOCK_DAMAGE_AND_CHECK_ENGINE_ON; MOVE_IN(moveInCargo)}; - } else { - _params = ["GetInCargo", _vehicle, _cargoNumber]; - _statement = {_player action (_this select 2)}; - }; - _name = format ["%1 %2", localize "str_getin_pos_passenger", _cargoNumber + 1]; - _icon = "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_cargo_ca.paa"; - } else { // driver + switch (toLower _role) do { + case "driver": { if ( lockedDriver _vehicle || {IS_CREW_UAV(_vehicleConfig)} @@ -211,6 +169,50 @@ private _cargoNumber = -1; _icon = "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_driver_ca.paa"; }; }; + case "cargo": { + INC(_cargoNumber); + if (_vehicle lockedCargo _cargoIndex) then {breakTo "crewLoop"}; + if (_isInVehicle) then { + if (_compartment != (_cargoCompartments select (_cargoNumber min _cargoCompartmentsLast))) then {breakTo "crewLoop"}; + _params = [_vehicle, _cargoIndex]; + _statement = {MOVEOUT_AND_BLOCK_DAMAGE_AND_CHECK_ENGINE_ON; MOVE_IN(moveInCargo)}; + } else { + _params = ["GetInCargo", _vehicle, _cargoNumber]; + _statement = {_player action (_this select 2)}; + }; + _name = format ["%1 %2", localize "str_getin_pos_passenger", _cargoNumber + 1]; + _icon = "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_cargo_ca.paa"; + }; + default { // all turrets including FFV + if (_vehicle lockedTurret _turretPath) then {breakTo "crewLoop"}; + private _turretConfig = [_vehicleConfig, _turretPath] call CBA_fnc_getTurret; + if (_isInVehicle) then { + private _gunnerCompartments = (_turretConfig >> "gunnerCompartments") call BIS_fnc_getCfgData; + TO_STRING(_gunnerCompartments); + if (_compartment != _gunnerCompartments) then {breakTo "crewLoop"}; + _params = [_vehicle, _turretPath]; + _statement = {MOVEOUT_AND_BLOCK_DAMAGE_AND_CHECK_ENGINE_ON; MOVE_IN(moveInTurret)}; + } else { + _params = ["GetInTurret", _vehicle, _turretPath]; + _statement = {_player action (_this select 2)}; + }; + _name = getText (_turretConfig >> "gunnerName"); + switch (toLower _role) do { + case "gunner": { + if (IS_CREW_UAV(_vehicleConfig)) then {breakTo "crewLoop"}; + _icon = "A3\ui_f\data\IGUI\Cfg\Actions\getingunner_ca.paa"; + }; + case "commander": { + _icon = "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_commander_ca.paa"; + }; + default { + _icon = [ + "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_gunner_ca.paa", + "A3\ui_f\data\IGUI\Cfg\CrewAimIndicator\gunnerAuto_ca.paa" + ] select _isPersonTurret; + }; + }; + }; }; private _action = [ format ["%1%2%3", _role, _cargoIndex, _turretPath], From 6cc77b84515286644d24ca6e18442d4071814c1a Mon Sep 17 00:00:00 2001 From: Dystopian Date: Wed, 27 Dec 2017 00:25:32 +0300 Subject: [PATCH 14/31] Decrease move-back timeout to 0.5s --- addons/quickmount/functions/fnc_addFreeSeatsActions.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf index 288761f3104..573c481dc08 100644 --- a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf +++ b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf @@ -38,7 +38,7 @@ // moveIn right after moveOut doesn't work in MP for non-local vehicles, player just stays out // we have to wait some time (e.g. until player is out) // usually it takes 1 frame in SP and 3 frames in MP, so in MP looks a little lagging -// also if unit isn't moved to new seat in 1 second, we move him back to his seat +// also if unit isn't moved to new seat in 0.5 seconds, we move him back to his seat #define MOVE_IN(command) \ [ARR_3( \ {isNull objectParent (_this select 0)}, \ @@ -54,7 +54,7 @@ }; \ }, \ _player, \ - 1, \ + 0.5, \ { \ (_this getVariable QGVAR(moveBackParams)) call (_this getVariable QGVAR(moveBackCode)); \ if (GETVAR(_this,GVAR(damageBlocked),false)) then { \ From 5dedfd41d26a98f85d4a362b4a2448cd0903fade Mon Sep 17 00:00:00 2001 From: Dystopian Date: Wed, 3 Jan 2018 07:36:09 +0300 Subject: [PATCH 15/31] Check if vehicle is flipped --- addons/quickmount/functions/fnc_canShowFreeSeats.sqf | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/quickmount/functions/fnc_canShowFreeSeats.sqf b/addons/quickmount/functions/fnc_canShowFreeSeats.sqf index 51de01b110d..e31051d8b91 100644 --- a/addons/quickmount/functions/fnc_canShowFreeSeats.sqf +++ b/addons/quickmount/functions/fnc_canShowFreeSeats.sqf @@ -25,3 +25,4 @@ params ["_vehicle", "_unit"]; 0 == {alive _x} count crew _vehicle || {0.6 <= side group _unit getFriend side group _vehicle} } +&& {0.3 < vectorUp _vehicle select 2 || {_vehicle isKindOf "Air"}} // moveIn* and GetIn* don't work for flipped vehicles except Air From 6a204d4ef8205db5e11c3e33de791de51fa002e6 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Fri, 27 Apr 2018 20:15:37 +0300 Subject: [PATCH 16/31] Add getin statement for parent menu --- addons/quickmount/CfgVehicles.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/quickmount/CfgVehicles.hpp b/addons/quickmount/CfgVehicles.hpp index 728490b7426..d24a207d4ba 100644 --- a/addons/quickmount/CfgVehicles.hpp +++ b/addons/quickmount/CfgVehicles.hpp @@ -41,7 +41,7 @@ class CfgVehicles { class GVAR(GetIn) { \ displayName = "$STR_rscMenu.hppRscGroupRootMenu_Items_GetIn1"; \ condition = QUOTE(call DFUNC(canShowFreeSeats)); \ - statement = ""; \ + statement = QUOTE(call DFUNC(getInNearest)); \ exceptions[] = {"isNotSwimming"}; \ insertChildren = QUOTE(call DFUNC(addFreeSeatsActions)); \ }; \ From fdc67c72c24a7501fbd37cf976081ae0934b3286 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Fri, 27 Apr 2018 22:33:13 +0300 Subject: [PATCH 17/31] Improve canShowFreeSeats --- addons/quickmount/functions/fnc_canShowFreeSeats.sqf | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/addons/quickmount/functions/fnc_canShowFreeSeats.sqf b/addons/quickmount/functions/fnc_canShowFreeSeats.sqf index e31051d8b91..19f5a3d32d9 100644 --- a/addons/quickmount/functions/fnc_canShowFreeSeats.sqf +++ b/addons/quickmount/functions/fnc_canShowFreeSeats.sqf @@ -18,11 +18,17 @@ params ["_vehicle", "_unit"]; -(GVAR(enabled) && {GVAR(enableGetInMenu)} || {!isNull objectParent _unit}) +( + GVAR(enabled) && {GVAR(enableGetInMenu)} + || {!isNull objectParent _unit} +) && {alive _vehicle} && {2 > locked _vehicle} && { - 0 == {alive _x} count crew _vehicle + -1 == crew _vehicle findIf {alive _x} || {0.6 <= side group _unit getFriend side group _vehicle} } -&& {0.3 < vectorUp _vehicle select 2 || {_vehicle isKindOf "Air"}} // moveIn* and GetIn* don't work for flipped vehicles except Air +&& { + 0.3 < vectorUp _vehicle select 2 // moveIn* and GetIn* don't work for flipped vehicles + || {_vehicle isKindOf "Air"} // except Air +} From b70c904c73a210f2544b8af456eed4edeecae3d3 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Fri, 12 Oct 2018 20:49:19 +0300 Subject: [PATCH 18/31] Apply latest trends --- addons/quickmount/XEH_preInit.sqf | 8 +------- addons/quickmount/functions/fnc_addFreeSeatsActions.sqf | 2 +- addons/quickmount/functions/fnc_canShowFreeSeats.sqf | 4 ++-- addons/quickmount/initSettings.sqf | 7 +++++++ 4 files changed, 11 insertions(+), 10 deletions(-) create mode 100644 addons/quickmount/initSettings.sqf diff --git a/addons/quickmount/XEH_preInit.sqf b/addons/quickmount/XEH_preInit.sqf index 638df36861c..9361d05015e 100644 --- a/addons/quickmount/XEH_preInit.sqf +++ b/addons/quickmount/XEH_preInit.sqf @@ -6,12 +6,6 @@ PREP_RECOMPILE_START; #include "XEH_PREP.hpp" PREP_RECOMPILE_END; -[ - QGVAR(enableGetInMenu), - "CHECKBOX", - localize LSTRING(SettingEnableGetInMenuName), - format ["ACE %1", localize LSTRING(Category)], - true -] call CBA_settings_fnc_init; +#include "initSettings.sqf" ADDON = true; diff --git a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf index 573c481dc08..3cdad3bab5a 100644 --- a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf +++ b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf @@ -1,3 +1,4 @@ +#include "script_component.hpp" /* * Author: Dystopian * Creates actions for vehicle free seats. @@ -14,7 +15,6 @@ * * Public: No */ -#include "script_component.hpp" #define TO_STRING(var) if !(var isEqualType "") then {var = "Compartment" + str var} diff --git a/addons/quickmount/functions/fnc_canShowFreeSeats.sqf b/addons/quickmount/functions/fnc_canShowFreeSeats.sqf index 19f5a3d32d9..9f14d8097bb 100644 --- a/addons/quickmount/functions/fnc_canShowFreeSeats.sqf +++ b/addons/quickmount/functions/fnc_canShowFreeSeats.sqf @@ -1,3 +1,4 @@ +#include "script_component.hpp" /* * Author: Dystopian * Checks if Free Seats menu can be shown. @@ -7,14 +8,13 @@ * 1: Unit * * Return Value: - * Able to show menu + * Can show menu * * Example: * [cursorObject, player] call ace_quickmount_fnc_canShowFreeSeats * * Public: No */ -#include "script_component.hpp" params ["_vehicle", "_unit"]; diff --git a/addons/quickmount/initSettings.sqf b/addons/quickmount/initSettings.sqf new file mode 100644 index 00000000000..4c36365e4d3 --- /dev/null +++ b/addons/quickmount/initSettings.sqf @@ -0,0 +1,7 @@ +[ + QGVAR(enableGetInMenu), + "CHECKBOX", + LSTRING(SettingEnableGetInMenuName), + format ["ACE %1", LLSTRING(Category)], + true +] call CBA_settings_fnc_init; From e472b025e6238208f05df86dbade2e5e218356ca Mon Sep 17 00:00:00 2001 From: Dystopian Date: Sat, 13 Oct 2018 12:43:28 +0300 Subject: [PATCH 19/31] Improve fnc_addFreeSeatsActions --- .../functions/fnc_addFreeSeatsActions.sqf | 51 ++++++++----------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf index 3cdad3bab5a..2a8a1639e49 100644 --- a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf +++ b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf @@ -16,10 +16,10 @@ * Public: No */ -#define TO_STRING(var) if !(var isEqualType "") then {var = "Compartment" + str var} +#define TO_STRING(var) if !(var isEqualType "") then {var = format [ARR_2("Compartment%1",var)]} // this will check UAV vehicle like Stomper (with cargo seat) -#define IS_CREW_UAV(vehicleConfig) ("UAVPilot" == getText (configFile >> "CfgVehicles" >> (getText (vehicleConfig >> "crew")) >> "simulation")) +#define IS_CREW_UAV(vehicleConfig) ("UAVPilot" == getText (configFile >> "CfgVehicles" >> getText (vehicleConfig >> "crew") >> "simulation")) // workaround getting damage when moveout while vehicle is moving #define MOVEOUT_AND_BLOCK_DAMAGE \ @@ -73,44 +73,34 @@ params ["_vehicle", "_player"]; private _vehicleConfig = configFile >> "CfgVehicles" >> typeOf _vehicle; private _isInVehicle = _player in _vehicle; +private _fullCrew = fullCrew [_vehicle, "", true]; -private ["_driverCompartments", "_isPilotAndIsolated", "_cargoCompartments", "_cargoCompartmentsLast", "_compartment"]; +private ["_driverCompartments", "_isDriverIsolated", "_cargoCompartments", "_cargoCompartmentsLast", "_compartment"]; if (_isInVehicle) then { _driverCompartments = (_vehicleConfig >> "driverCompartments") call BIS_fnc_getCfgData; // Air class by default has driverCompartments=0 and cargoCompartments[]={0}, so we have to disable them - _isPilotAndIsolated = _driverCompartments isEqualTo 0 && {_vehicle isKindOf "Air"}; + _isDriverIsolated = _driverCompartments isEqualTo 0 && {_vehicle isKindOf "Air"}; TO_STRING(_driverCompartments); _cargoCompartments = getArray (_vehicleConfig >> "cargoCompartments"); - _cargoCompartments = _cargoCompartments apply { - if (_x isEqualType "") then { - _x - } else { - "Compartment" + str _x + { + if !(_x isEqualType "") then { + _cargoCompartments set [_forEachIndex, format ["Compartment%1", _x]]; }; - }; + } forEach _cargoCompartments; _cargoCompartmentsLast = count _cargoCompartments - 1; TRACE_2("",_driverCompartments,_cargoCompartments); // find current compartment - private ["_role", "_cargoIndex", "_turretPath"]; - private _cargoNumber = 0; - { - _role = _x select 1; - if (_player == _x select 0) exitWith { - _cargoIndex = _x select 2; - _turretPath = _x select 3; - }; - if (_role == "cargo") then { - INC(_cargoNumber); - }; - } forEach fullCrew [_vehicle, "", true]; + ( + _fullCrew select (_fullCrew findIf {_player == _x select 0}) + ) params ["", "_role", "_cargoIndex", "_turretPath"]; switch (_role) do { case "driver": { - if (_isPilotAndIsolated) then { + if (_isDriverIsolated) then { [] breakOut "main"; }; _compartment = _driverCompartments; @@ -118,19 +108,20 @@ if (_isInVehicle) then { _player setVariable [QGVAR(moveBackParams), [_player, _vehicle]]; }; case "cargo": { + private _cargoNumber = fullCrew [_vehicle, "cargo", true] findIf {_player == _x select 0}; _compartment = _cargoCompartments select (_cargoNumber min _cargoCompartmentsLast); - _player setVariable [QGVAR(moveBackCode), {(_this select 0) moveInCargo [_this select 1, _this select 2]}]; - _player setVariable [QGVAR(moveBackParams), [_player, _vehicle, _cargoIndex]]; + _player setVariable [QGVAR(moveBackCode), {(_this select 0) moveInCargo (_this select 1)}]; + _player setVariable [QGVAR(moveBackParams), [_player, [_vehicle, _cargoIndex]]]; }; default { private _turretConfig = [_vehicleConfig, _turretPath] call CBA_fnc_getTurret; _compartment = (_turretConfig >> "gunnerCompartments") call BIS_fnc_getCfgData; TO_STRING(_compartment); - _player setVariable [QGVAR(moveBackCode), {(_this select 0) moveInTurret [_this select 1, _this select 2]}]; - _player setVariable [QGVAR(moveBackParams), [_player, _vehicle, _turretPath]]; + _player setVariable [QGVAR(moveBackCode), {(_this select 0) moveInTurret (_this select 1)}]; + _player setVariable [QGVAR(moveBackParams), [_player, [_vehicle, _turretPath]]]; }; }; - TRACE_5("",_role,_cargoIndex,_turretPath,_cargoNumber,_compartment); + TRACE_4("",_role,_cargoIndex,_turretPath,_compartment); }; private _actions = []; @@ -154,7 +145,7 @@ private _cargoNumber = -1; breakTo "crewLoop"; }; if (_isInVehicle) then { - if (_compartment != _driverCompartments || {_isPilotAndIsolated}) then {breakTo "crewLoop"}; + if (_compartment != _driverCompartments || {_isDriverIsolated}) then {breakTo "crewLoop"}; _params = _vehicle; _statement = {MOVEOUT_AND_BLOCK_DAMAGE; MOVE_IN(moveInDriver)}; } else { @@ -220,6 +211,6 @@ private _cargoNumber = -1; ] call EFUNC(interact_menu,createAction); _actions pushBack [_action, [], _vehicle]; }; -} forEach fullCrew [_vehicle, "", true]; +} forEach _fullCrew; _actions From 0e439afe8e65246d25a67a36496c9525ab7ab7e5 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Sat, 13 Oct 2018 14:02:38 +0300 Subject: [PATCH 20/31] Change copilot and gunless turret icons --- .../functions/fnc_addFreeSeatsActions.sqf | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf index 2a8a1639e49..284f578b84c 100644 --- a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf +++ b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf @@ -67,6 +67,14 @@ [ARR_2(_player,_this select 2)] \ )] call CBA_fnc_waitUntilAndExecute; +#define ICON_DRIVER "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_driver_ca.paa" +#define ICON_PILOT "A3\ui_f\data\IGUI\Cfg\Actions\getinpilot_ca.paa" +#define ICON_CARGO "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_cargo_ca.paa" +#define ICON_GUNNER "A3\ui_f\data\IGUI\Cfg\Actions\getingunner_ca.paa" +#define ICON_COMMANDER "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_commander_ca.paa" +#define ICON_TURRET "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_gunner_ca.paa" +#define ICON_FFV "A3\ui_f\data\IGUI\Cfg\CrewAimIndicator\gunnerAuto_ca.paa" + scopeName "main"; params ["_vehicle", "_player"]; @@ -154,10 +162,10 @@ private _cargoNumber = -1; }; if (_vehicle isKindOf "Air") then { _name = localize "str_getin_pos_pilot"; - _icon = "A3\ui_f\data\IGUI\Cfg\Actions\getinpilot_ca.paa"; + _icon = ICON_PILOT; } else { _name = localize "str_driver"; - _icon = "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_driver_ca.paa"; + _icon = ICON_DRIVER; }; }; case "cargo": { @@ -172,7 +180,7 @@ private _cargoNumber = -1; _statement = {_player action (_this select 2)}; }; _name = format ["%1 %2", localize "str_getin_pos_passenger", _cargoNumber + 1]; - _icon = "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_cargo_ca.paa"; + _icon = ICON_CARGO; }; default { // all turrets including FFV if (_vehicle lockedTurret _turretPath) then {breakTo "crewLoop"}; @@ -191,18 +199,21 @@ private _cargoNumber = -1; switch (toLower _role) do { case "gunner": { if (IS_CREW_UAV(_vehicleConfig)) then {breakTo "crewLoop"}; - _icon = "A3\ui_f\data\IGUI\Cfg\Actions\getingunner_ca.paa"; + _icon = ICON_GUNNER; }; case "commander": { - _icon = "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_commander_ca.paa"; + _icon = ICON_COMMANDER; }; default { - _icon = [ - "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_gunner_ca.paa", - "A3\ui_f\data\IGUI\Cfg\CrewAimIndicator\gunnerAuto_ca.paa" - ] select _isPersonTurret; + if ("" isEqualTo getText (_turretConfig >> "gun")) exitWith { + _icon = ICON_CARGO; + }; + _icon = [ICON_TURRET,ICON_FFV] select _isPersonTurret; }; }; + if (0 < getNumber (_turretConfig >> "isCopilot")) then { + _icon = ICON_PILOT; + }; }; }; private _action = [ From 8d59c9e99f2f42a6e5db5ba2187ea68185af93a5 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Sun, 14 Oct 2018 16:53:57 +0300 Subject: [PATCH 21/31] Fix macro name --- addons/quickmount/functions/fnc_addFreeSeatsActions.sqf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf index 284f578b84c..ebac3d22ed5 100644 --- a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf +++ b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf @@ -16,7 +16,7 @@ * Public: No */ -#define TO_STRING(var) if !(var isEqualType "") then {var = format [ARR_2("Compartment%1",var)]} +#define TO_COMPARTMENT_STRING(var) if !(var isEqualType "") then {var = format [ARR_2("Compartment%1",var)]} // this will check UAV vehicle like Stomper (with cargo seat) #define IS_CREW_UAV(vehicleConfig) ("UAVPilot" == getText (configFile >> "CfgVehicles" >> getText (vehicleConfig >> "crew") >> "simulation")) @@ -89,7 +89,7 @@ if (_isInVehicle) then { _driverCompartments = (_vehicleConfig >> "driverCompartments") call BIS_fnc_getCfgData; // Air class by default has driverCompartments=0 and cargoCompartments[]={0}, so we have to disable them _isDriverIsolated = _driverCompartments isEqualTo 0 && {_vehicle isKindOf "Air"}; - TO_STRING(_driverCompartments); + TO_COMPARTMENT_STRING(_driverCompartments); _cargoCompartments = getArray (_vehicleConfig >> "cargoCompartments"); { @@ -124,7 +124,7 @@ if (_isInVehicle) then { default { private _turretConfig = [_vehicleConfig, _turretPath] call CBA_fnc_getTurret; _compartment = (_turretConfig >> "gunnerCompartments") call BIS_fnc_getCfgData; - TO_STRING(_compartment); + TO_COMPARTMENT_STRING(_compartment); _player setVariable [QGVAR(moveBackCode), {(_this select 0) moveInTurret (_this select 1)}]; _player setVariable [QGVAR(moveBackParams), [_player, [_vehicle, _turretPath]]]; }; @@ -187,7 +187,7 @@ private _cargoNumber = -1; private _turretConfig = [_vehicleConfig, _turretPath] call CBA_fnc_getTurret; if (_isInVehicle) then { private _gunnerCompartments = (_turretConfig >> "gunnerCompartments") call BIS_fnc_getCfgData; - TO_STRING(_gunnerCompartments); + TO_COMPARTMENT_STRING(_gunnerCompartments); if (_compartment != _gunnerCompartments) then {breakTo "crewLoop"}; _params = [_vehicle, _turretPath]; _statement = {MOVEOUT_AND_BLOCK_DAMAGE_AND_CHECK_ENGINE_ON; MOVE_IN(moveInTurret)}; From 5a023819162f07c013708b2e662dee829571a1ad Mon Sep 17 00:00:00 2001 From: Dystopian Date: Wed, 24 Oct 2018 00:24:30 +0300 Subject: [PATCH 22/31] Fix FFV icon --- addons/quickmount/functions/fnc_addFreeSeatsActions.sqf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf index ebac3d22ed5..2a7d4221640 100644 --- a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf +++ b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf @@ -205,10 +205,13 @@ private _cargoNumber = -1; _icon = ICON_COMMANDER; }; default { + if (_isPersonTurret) exitWith { + _icon = ICON_FFV; + }; if ("" isEqualTo getText (_turretConfig >> "gun")) exitWith { _icon = ICON_CARGO; }; - _icon = [ICON_TURRET,ICON_FFV] select _isPersonTurret; + _icon = ICON_TURRET; }; }; if (0 < getNumber (_turretConfig >> "isCopilot")) then { From 283fae0ef2d68cff3f4a53e4e9f6893eeacbd872 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Wed, 24 Oct 2018 01:02:40 +0300 Subject: [PATCH 23/31] Optimize turret icon code --- .../functions/fnc_addFreeSeatsActions.sqf | 28 ++++++------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf index 2a7d4221640..f4106321d15 100644 --- a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf +++ b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf @@ -184,6 +184,7 @@ private _cargoNumber = -1; }; default { // all turrets including FFV if (_vehicle lockedTurret _turretPath) then {breakTo "crewLoop"}; + if (_role == "gunner" && {IS_CREW_UAV(_vehicleConfig)}) then {breakTo "crewLoop"}; private _turretConfig = [_vehicleConfig, _turretPath] call CBA_fnc_getTurret; if (_isInVehicle) then { private _gunnerCompartments = (_turretConfig >> "gunnerCompartments") call BIS_fnc_getCfgData; @@ -196,26 +197,13 @@ private _cargoNumber = -1; _statement = {_player action (_this select 2)}; }; _name = getText (_turretConfig >> "gunnerName"); - switch (toLower _role) do { - case "gunner": { - if (IS_CREW_UAV(_vehicleConfig)) then {breakTo "crewLoop"}; - _icon = ICON_GUNNER; - }; - case "commander": { - _icon = ICON_COMMANDER; - }; - default { - if (_isPersonTurret) exitWith { - _icon = ICON_FFV; - }; - if ("" isEqualTo getText (_turretConfig >> "gun")) exitWith { - _icon = ICON_CARGO; - }; - _icon = ICON_TURRET; - }; - }; - if (0 < getNumber (_turretConfig >> "isCopilot")) then { - _icon = ICON_PILOT; + _icon = switch true do { + case (0 < getNumber (_turretConfig >> "isCopilot")): {ICON_PILOT}; + case (_role == "gunner"): {ICON_GUNNER}; + case (_role == "commander"): {ICON_COMMANDER}; + case (_isPersonTurret): {ICON_FFV}; + case ("" isEqualTo getText (_turretConfig >> "gun")): {ICON_CARGO}; + default {ICON_TURRET}; }; }; }; From fb010184a2e1448ade6d60688ad6769f125da5c5 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Wed, 31 Oct 2018 01:19:14 +0400 Subject: [PATCH 24/31] Extend setting to 4 values --- .../functions/fnc_canShowFreeSeats.sqf | 12 ++++++++---- addons/quickmount/initSettings.sqf | 17 +++++++++++++---- addons/quickmount/stringtable.xml | 4 ---- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/addons/quickmount/functions/fnc_canShowFreeSeats.sqf b/addons/quickmount/functions/fnc_canShowFreeSeats.sqf index 9f14d8097bb..539239a7927 100644 --- a/addons/quickmount/functions/fnc_canShowFreeSeats.sqf +++ b/addons/quickmount/functions/fnc_canShowFreeSeats.sqf @@ -18,10 +18,14 @@ params ["_vehicle", "_unit"]; -( - GVAR(enabled) && {GVAR(enableGetInMenu)} - || {!isNull objectParent _unit} -) +private _isInVehicle = _unit in _vehicle; + +GVAR(enabled) +&& { + GVAR(enableMenu) == 3 + || {_isInVehicle && {GVAR(enableMenu) == 2}} + || {!_isInVehicle && {GVAR(enableMenu) == 1}} +} && {alive _vehicle} && {2 > locked _vehicle} && { diff --git a/addons/quickmount/initSettings.sqf b/addons/quickmount/initSettings.sqf index 47d93eadd20..f2133571670 100644 --- a/addons/quickmount/initSettings.sqf +++ b/addons/quickmount/initSettings.sqf @@ -35,9 +35,18 @@ ] call CBA_settings_fnc_init; [ - QGVAR(enableGetInMenu), - "CHECKBOX", - LSTRING(SettingEnableGetInMenuName), + QGVAR(enableMenu), + "LIST", + ELSTRING(interact_menu,Category_InteractionMenu), format ["ACE %1", LLSTRING(Category)], - true + [ + [0,1,2,3], + [ + "STR_A3_None", + "STR_rscMenu.hppRscGroupRootMenu_Items_GetIn1", + LSTRING(ChangeSeat), + "str_word_all" + ], + 3 + ] ] call CBA_settings_fnc_init; diff --git a/addons/quickmount/stringtable.xml b/addons/quickmount/stringtable.xml index 1a0dd921862..941aad3f602 100644 --- a/addons/quickmount/stringtable.xml +++ b/addons/quickmount/stringtable.xml @@ -115,9 +115,5 @@ Change seat Пересесть - - "Get In" interaction - Меню "Сесть" - From 5856d7b1b4aa07a28ee8411d389e15c968a80be9 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Thu, 1 Nov 2018 00:58:15 +0400 Subject: [PATCH 25/31] Fix menu is shown when vehicle is full --- addons/quickmount/functions/fnc_canShowFreeSeats.sqf | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/quickmount/functions/fnc_canShowFreeSeats.sqf b/addons/quickmount/functions/fnc_canShowFreeSeats.sqf index 539239a7927..560a036a50f 100644 --- a/addons/quickmount/functions/fnc_canShowFreeSeats.sqf +++ b/addons/quickmount/functions/fnc_canShowFreeSeats.sqf @@ -36,3 +36,4 @@ GVAR(enabled) 0.3 < vectorUp _vehicle select 2 // moveIn* and GetIn* don't work for flipped vehicles || {_vehicle isKindOf "Air"} // except Air } +&& {!([] isEqualTo (_this call FUNC(addFreeSeatsActions)))} // this should be replaced with faster function From 09356d63bcd59ee93e3bdf9dc724544062a20930 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Thu, 1 Nov 2018 01:09:39 +0400 Subject: [PATCH 26/31] Optimize UAV checking code --- addons/quickmount/functions/fnc_addFreeSeatsActions.sqf | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf index f4106321d15..64c19a7b1c2 100644 --- a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf +++ b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf @@ -18,9 +18,6 @@ #define TO_COMPARTMENT_STRING(var) if !(var isEqualType "") then {var = format [ARR_2("Compartment%1",var)]} -// this will check UAV vehicle like Stomper (with cargo seat) -#define IS_CREW_UAV(vehicleConfig) ("UAVPilot" == getText (configFile >> "CfgVehicles" >> getText (vehicleConfig >> "crew") >> "simulation")) - // workaround getting damage when moveout while vehicle is moving #define MOVEOUT_AND_BLOCK_DAMAGE \ if (isDamageAllowed _player) then { \ @@ -147,7 +144,7 @@ private _cargoNumber = -1; case "driver": { if ( lockedDriver _vehicle - || {IS_CREW_UAV(_vehicleConfig)} + || {unitIsUAV _vehicle} || {0 == getNumber (_vehicleConfig >> "hasDriver")} ) then { breakTo "crewLoop"; @@ -184,7 +181,7 @@ private _cargoNumber = -1; }; default { // all turrets including FFV if (_vehicle lockedTurret _turretPath) then {breakTo "crewLoop"}; - if (_role == "gunner" && {IS_CREW_UAV(_vehicleConfig)}) then {breakTo "crewLoop"}; + if (_role == "gunner" && {unitIsUAV _vehicle}) then {breakTo "crewLoop"}; private _turretConfig = [_vehicleConfig, _turretPath] call CBA_fnc_getTurret; if (_isInVehicle) then { private _gunnerCompartments = (_turretConfig >> "gunnerCompartments") call BIS_fnc_getCfgData; From 493e5b3db73566ac17ace53aa89563e93fc00b4f Mon Sep 17 00:00:00 2001 From: Dystopian Date: Tue, 6 Nov 2018 02:08:19 +0400 Subject: [PATCH 27/31] Fix bug with disabled FFV turrets --- .../functions/fnc_addFreeSeatsActions.sqf | 87 +++++++++++-------- 1 file changed, 53 insertions(+), 34 deletions(-) diff --git a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf index 64c19a7b1c2..91516b72f45 100644 --- a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf +++ b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf @@ -16,50 +16,54 @@ * Public: No */ +#define DISABLED_FFV_TIMEOUT 0.3 +#define TAKEN_SEAT_TIMEOUT 0.5 + #define TO_COMPARTMENT_STRING(var) if !(var isEqualType "") then {var = format [ARR_2("Compartment%1",var)]} // workaround getting damage when moveout while vehicle is moving -#define MOVEOUT_AND_BLOCK_DAMAGE \ +#define MOVE_OUT \ if (isDamageAllowed _player) then { \ _player allowDamage false; \ SETVAR(_player,GVAR(damageBlocked),true); \ }; \ - moveOut _player; - -// this is used in statements when move from driver -#define MOVEOUT_AND_BLOCK_DAMAGE_AND_CHECK_ENGINE_ON \ private _preserveEngineOn = _player == driver _target && {isEngineOn _target}; \ - MOVEOUT_AND_BLOCK_DAMAGE; \ + moveOut _player; \ if (_preserveEngineOn) then {_target engineOn true}; +#define UNBLOCK_DAMAGE \ + if (GETVAR(_this,GVAR(damageBlocked),false)) then { \ + _this allowDamage true; \ + SETVAR(_this,GVAR(damageBlocked),nil); \ + }; + +// if unit isn't moved to new seat in TAKEN_SEAT_TIMEOUT, we move him back to his seat +#define WAIT_IN_OR_MOVE_BACK \ + [ARR_5( \ + {!isNull objectParent _this}, \ + {UNBLOCK_DAMAGE}, \ + _player, \ + TAKEN_SEAT_TIMEOUT, \ + { \ + (_this getVariable QGVAR(moveBackParams)) call (_this getVariable QGVAR(moveBackCode)); \ + UNBLOCK_DAMAGE; \ + } \ + )] call CBA_fnc_waitUntilAndExecute; + // moveIn right after moveOut doesn't work in MP for non-local vehicles, player just stays out -// we have to wait some time (e.g. until player is out) -// usually it takes 1 frame in SP and 3 frames in MP, so in MP looks a little lagging -// also if unit isn't moved to new seat in 0.5 seconds, we move him back to his seat +// so we have to wait some time (e.g. until player is out) +// usually it's done in the same frame in SP and takes 3 frames in MP, so in MP looks a little lagging #define MOVE_IN(command) \ + if (isNull objectParent _player) exitWith {\ + _player command (_this select 2); \ + WAIT_IN_OR_MOVE_BACK; \ + }; \ [ARR_3( \ {isNull objectParent (_this select 0)}, \ { \ params [ARR_2("_player","_moveInParams")]; \ _player command _moveInParams; \ - [ARR_5( \ - {!isNull objectParent _this}, \ - { \ - if (GETVAR(_this,GVAR(damageBlocked),false)) then { \ - _this allowDamage true; \ - SETVAR(_this,GVAR(damageBlocked),nil); \ - }; \ - }, \ - _player, \ - 0.5, \ - { \ - (_this getVariable QGVAR(moveBackParams)) call (_this getVariable QGVAR(moveBackCode)); \ - if (GETVAR(_this,GVAR(damageBlocked),false)) then { \ - _this allowDamage true; \ - SETVAR(_this,GVAR(damageBlocked),nil); \ - }; \ - } \ - )] call CBA_fnc_waitUntilAndExecute; \ + WAIT_IN_OR_MOVE_BACK; \ }, \ [ARR_2(_player,_this select 2)] \ )] call CBA_fnc_waitUntilAndExecute; @@ -152,7 +156,7 @@ private _cargoNumber = -1; if (_isInVehicle) then { if (_compartment != _driverCompartments || {_isDriverIsolated}) then {breakTo "crewLoop"}; _params = _vehicle; - _statement = {MOVEOUT_AND_BLOCK_DAMAGE; MOVE_IN(moveInDriver)}; + _statement = {MOVE_OUT; MOVE_IN(moveInDriver)}; } else { _params = ["GetInDriver", _vehicle]; _statement = {_player action (_this select 2)}; @@ -171,7 +175,7 @@ private _cargoNumber = -1; if (_isInVehicle) then { if (_compartment != (_cargoCompartments select (_cargoNumber min _cargoCompartmentsLast))) then {breakTo "crewLoop"}; _params = [_vehicle, _cargoIndex]; - _statement = {MOVEOUT_AND_BLOCK_DAMAGE_AND_CHECK_ENGINE_ON; MOVE_IN(moveInCargo)}; + _statement = {MOVE_OUT; MOVE_IN(moveInCargo)}; } else { _params = ["GetInCargo", _vehicle, _cargoNumber]; _statement = {_player action (_this select 2)}; @@ -183,15 +187,30 @@ private _cargoNumber = -1; if (_vehicle lockedTurret _turretPath) then {breakTo "crewLoop"}; if (_role == "gunner" && {unitIsUAV _vehicle}) then {breakTo "crewLoop"}; private _turretConfig = [_vehicleConfig, _turretPath] call CBA_fnc_getTurret; - if (_isInVehicle) then { + if (!_isInVehicle) then { + _params = ["GetInTurret", _vehicle, _turretPath]; + _statement = {_player action (_this select 2)}; + } else { private _gunnerCompartments = (_turretConfig >> "gunnerCompartments") call BIS_fnc_getCfgData; TO_COMPARTMENT_STRING(_gunnerCompartments); if (_compartment != _gunnerCompartments) then {breakTo "crewLoop"}; _params = [_vehicle, _turretPath]; - _statement = {MOVEOUT_AND_BLOCK_DAMAGE_AND_CHECK_ENGINE_ON; MOVE_IN(moveInTurret)}; - } else { - _params = ["GetInTurret", _vehicle, _turretPath]; - _statement = {_player action (_this select 2)}; + _statement = { + MOVE_OUT; + // due to arma bug the unit is stuck in wrong anim when move too fast in turret with configured enabledByAnimationSource + // we check if enabledByAnimationSource is closed and wait DISABLED_FFV_TIMEOUT before move in + private _turretPath = _this select 2 select 1; + private _turretConfig = [configFile >> "CfgVehicles" >> typeOf _target, _turretPath] call CBA_fnc_getTurret; + private _enabledByAnimationSource = getText (_turretConfig >> "enabledByAnimationSource"); + if ( + "" isEqualTo _enabledByAnimationSource + || {1 == _target doorPhase _enabledByAnimationSource} + ) exitWith {MOVE_IN(moveInTurret)}; + [{ + params ["_target", "_player"]; + MOVE_IN(moveInTurret); + }, _this, DISABLED_FFV_TIMEOUT] call CBA_fnc_waitAndExecute; + }; }; _name = getText (_turretConfig >> "gunnerName"); _icon = switch true do { From 32e8e5d509708d2f953bbdeece5161187ee30dd9 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Thu, 15 Nov 2018 23:01:49 +0400 Subject: [PATCH 28/31] Remove bugged FFV, Add turret locality check, Add Failed message --- .../functions/fnc_addFreeSeatsActions.sqf | 84 +++++++++++-------- 1 file changed, 49 insertions(+), 35 deletions(-) diff --git a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf index 91516b72f45..c0ce444dc5f 100644 --- a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf +++ b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf @@ -16,7 +16,6 @@ * Public: No */ -#define DISABLED_FFV_TIMEOUT 0.3 #define TAKEN_SEAT_TIMEOUT 0.5 #define TO_COMPARTMENT_STRING(var) if !(var isEqualType "") then {var = format [ARR_2("Compartment%1",var)]} @@ -45,28 +44,42 @@ _player, \ TAKEN_SEAT_TIMEOUT, \ { \ - (_this getVariable QGVAR(moveBackParams)) call (_this getVariable QGVAR(moveBackCode)); \ + [ARR_2(_this,_this getVariable QGVAR(moveBackParams))] call (_this getVariable QGVAR(moveBackCode)); \ UNBLOCK_DAMAGE; \ + localize "str_mis_state_failed" call EFUNC(common,displayTextStructured); \ } \ )] call CBA_fnc_waitUntilAndExecute; +#define IS_MOVED_OUT (\ + isNull objectParent _player \ + && { \ + [] isEqualTo _turretPath \ + || {local _target isEqualTo (_target turretLocal _turretPath)} \ + } \ +) + // moveIn right after moveOut doesn't work in MP for non-local vehicles, player just stays out -// so we have to wait some time (e.g. until player is out) +// so we have to wait some time (e.g. until player is out and turret locality become vehicle locality) // usually it's done in the same frame in SP and takes 3 frames in MP, so in MP looks a little lagging #define MOVE_IN(command) \ - if (isNull objectParent _player) exitWith {\ - _player command (_this select 2); \ + (_this select 2) params [ARR_2("_moveInParams","_turretPath")]; \ + if (IS_MOVED_OUT) then { \ + _player command _moveInParams; \ WAIT_IN_OR_MOVE_BACK; \ - }; \ - [ARR_3( \ - {isNull objectParent (_this select 0)}, \ - { \ - params [ARR_2("_player","_moveInParams")]; \ - _player command _moveInParams; \ - WAIT_IN_OR_MOVE_BACK; \ - }, \ - [ARR_2(_player,_this select 2)] \ - )] call CBA_fnc_waitUntilAndExecute; + } else { \ + [ARR_3( \ + { \ + params [ARR_4("_target","_player","","_turretPath")]; \ + IS_MOVED_OUT \ + }, \ + { \ + params [ARR_4("_target","_player","_moveInParams","_turretPath")]; \ + _player command _moveInParams; \ + WAIT_IN_OR_MOVE_BACK; \ + }, \ + [ARR_4(_target,_player,_moveInParams,_turretPath)] \ + )] call CBA_fnc_waitUntilAndExecute; \ + }; #define ICON_DRIVER "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_driver_ca.paa" #define ICON_PILOT "A3\ui_f\data\IGUI\Cfg\Actions\getinpilot_ca.paa" @@ -84,7 +97,7 @@ private _vehicleConfig = configFile >> "CfgVehicles" >> typeOf _vehicle; private _isInVehicle = _player in _vehicle; private _fullCrew = fullCrew [_vehicle, "", true]; -private ["_driverCompartments", "_isDriverIsolated", "_cargoCompartments", "_cargoCompartmentsLast", "_compartment"]; +private ["_driverCompartments", "_isDriverIsolated", "_cargoCompartments", "_cargoCompartmentsLast", "_compartment", "_playerTurretPath"]; if (_isInVehicle) then { _driverCompartments = (_vehicleConfig >> "driverCompartments") call BIS_fnc_getCfgData; @@ -107,6 +120,8 @@ if (_isInVehicle) then { _fullCrew select (_fullCrew findIf {_player == _x select 0}) ) params ["", "_role", "_cargoIndex", "_turretPath"]; + _playerTurretPath = _turretPath; + switch (_role) do { case "driver": { if (_isDriverIsolated) then { @@ -114,20 +129,20 @@ if (_isInVehicle) then { }; _compartment = _driverCompartments; _player setVariable [QGVAR(moveBackCode), {(_this select 0) moveInDriver (_this select 1)}]; - _player setVariable [QGVAR(moveBackParams), [_player, _vehicle]]; + _player setVariable [QGVAR(moveBackParams), _vehicle]; }; case "cargo": { private _cargoNumber = fullCrew [_vehicle, "cargo", true] findIf {_player == _x select 0}; _compartment = _cargoCompartments select (_cargoNumber min _cargoCompartmentsLast); _player setVariable [QGVAR(moveBackCode), {(_this select 0) moveInCargo (_this select 1)}]; - _player setVariable [QGVAR(moveBackParams), [_player, [_vehicle, _cargoIndex]]]; + _player setVariable [QGVAR(moveBackParams), [_vehicle, _cargoIndex]]; }; default { private _turretConfig = [_vehicleConfig, _turretPath] call CBA_fnc_getTurret; _compartment = (_turretConfig >> "gunnerCompartments") call BIS_fnc_getCfgData; TO_COMPARTMENT_STRING(_compartment); _player setVariable [QGVAR(moveBackCode), {(_this select 0) moveInTurret (_this select 1)}]; - _player setVariable [QGVAR(moveBackParams), [_player, [_vehicle, _turretPath]]]; + _player setVariable [QGVAR(moveBackParams), [_vehicle, _turretPath]]; }; }; TRACE_4("",_role,_cargoIndex,_turretPath,_compartment); @@ -155,7 +170,7 @@ private _cargoNumber = -1; }; if (_isInVehicle) then { if (_compartment != _driverCompartments || {_isDriverIsolated}) then {breakTo "crewLoop"}; - _params = _vehicle; + _params = [_vehicle, _playerTurretPath]; _statement = {MOVE_OUT; MOVE_IN(moveInDriver)}; } else { _params = ["GetInDriver", _vehicle]; @@ -174,7 +189,7 @@ private _cargoNumber = -1; if (_vehicle lockedCargo _cargoIndex) then {breakTo "crewLoop"}; if (_isInVehicle) then { if (_compartment != (_cargoCompartments select (_cargoNumber min _cargoCompartmentsLast))) then {breakTo "crewLoop"}; - _params = [_vehicle, _cargoIndex]; + _params = [[_vehicle, _cargoIndex], _playerTurretPath]; _statement = {MOVE_OUT; MOVE_IN(moveInCargo)}; } else { _params = ["GetInCargo", _vehicle, _cargoNumber]; @@ -194,22 +209,21 @@ private _cargoNumber = -1; private _gunnerCompartments = (_turretConfig >> "gunnerCompartments") call BIS_fnc_getCfgData; TO_COMPARTMENT_STRING(_gunnerCompartments); if (_compartment != _gunnerCompartments) then {breakTo "crewLoop"}; - _params = [_vehicle, _turretPath]; + // due to arma bug the unit is stuck in wrong anim when move in turret with configured enabledByAnimationSource + private _enabledByAnimationSource = getText (_turretConfig >> "enabledByAnimationSource"); + if ( + !("" isEqualTo _enabledByAnimationSource) + && {1 > _vehicle doorPhase _enabledByAnimationSource} + ) then {breakTo "crewLoop"}; + _params = [[_vehicle, _turretPath], _playerTurretPath, _enabledByAnimationSource]; _statement = { - MOVE_OUT; - // due to arma bug the unit is stuck in wrong anim when move too fast in turret with configured enabledByAnimationSource - // we check if enabledByAnimationSource is closed and wait DISABLED_FFV_TIMEOUT before move in - private _turretPath = _this select 2 select 1; - private _turretConfig = [configFile >> "CfgVehicles" >> typeOf _target, _turretPath] call CBA_fnc_getTurret; - private _enabledByAnimationSource = getText (_turretConfig >> "enabledByAnimationSource"); + private _enabledByAnimationSource = _this select 2 select 2; if ( - "" isEqualTo _enabledByAnimationSource - || {1 == _target doorPhase _enabledByAnimationSource} - ) exitWith {MOVE_IN(moveInTurret)}; - [{ - params ["_target", "_player"]; - MOVE_IN(moveInTurret); - }, _this, DISABLED_FFV_TIMEOUT] call CBA_fnc_waitAndExecute; + !("" isEqualTo _enabledByAnimationSource) + && {1 > _target doorPhase _enabledByAnimationSource} + ) exitWith {}; + MOVE_OUT; + MOVE_IN(moveInTurret); }; }; _name = getText (_turretConfig >> "gunnerName"); From 274ef001eab240f58da09c9fb5ddf43815dbffcf Mon Sep 17 00:00:00 2001 From: Dystopian Date: Fri, 16 Nov 2018 01:10:39 +0400 Subject: [PATCH 29/31] Replace some macros with function --- .../functions/fnc_addFreeSeatsActions.sqf | 93 +++++++++---------- 1 file changed, 44 insertions(+), 49 deletions(-) diff --git a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf index c0ce444dc5f..13388c60d84 100644 --- a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf +++ b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf @@ -20,16 +20,6 @@ #define TO_COMPARTMENT_STRING(var) if !(var isEqualType "") then {var = format [ARR_2("Compartment%1",var)]} -// workaround getting damage when moveout while vehicle is moving -#define MOVE_OUT \ - if (isDamageAllowed _player) then { \ - _player allowDamage false; \ - SETVAR(_player,GVAR(damageBlocked),true); \ - }; \ - private _preserveEngineOn = _player == driver _target && {isEngineOn _target}; \ - moveOut _player; \ - if (_preserveEngineOn) then {_target engineOn true}; - #define UNBLOCK_DAMAGE \ if (GETVAR(_this,GVAR(damageBlocked),false)) then { \ _this allowDamage true; \ @@ -53,33 +43,46 @@ #define IS_MOVED_OUT (\ isNull objectParent _player \ && { \ - [] isEqualTo _turretPath \ - || {local _target isEqualTo (_target turretLocal _turretPath)} \ + [] isEqualTo _currentTurret \ + || {local _target isEqualTo (_target turretLocal _currentTurret)} \ } \ ) -// moveIn right after moveOut doesn't work in MP for non-local vehicles, player just stays out -// so we have to wait some time (e.g. until player is out and turret locality become vehicle locality) -// usually it's done in the same frame in SP and takes 3 frames in MP, so in MP looks a little lagging -#define MOVE_IN(command) \ - (_this select 2) params [ARR_2("_moveInParams","_turretPath")]; \ - if (IS_MOVED_OUT) then { \ - _player command _moveInParams; \ - WAIT_IN_OR_MOVE_BACK; \ - } else { \ - [ARR_3( \ - { \ - params [ARR_4("_target","_player","","_turretPath")]; \ - IS_MOVED_OUT \ - }, \ - { \ - params [ARR_4("_target","_player","_moveInParams","_turretPath")]; \ - _player command _moveInParams; \ - WAIT_IN_OR_MOVE_BACK; \ - }, \ - [ARR_4(_target,_player,_moveInParams,_turretPath)] \ - )] call CBA_fnc_waitUntilAndExecute; \ +private _fnc_move = { + (_this select 2) params ["_moveInCode", "_moveInParams", "_currentTurret", ["_enabledByAnimationSource", ""]]; + + // check bugged FFV + if ( + !("" isEqualTo _enabledByAnimationSource) + && {1 > _target doorPhase _enabledByAnimationSource} + ) exitWith {}; + + // workaround getting damage when moveOut while vehicle is moving + if (isDamageAllowed _player) then { + _player allowDamage false; + SETVAR(_player,GVAR(damageBlocked),true); }; + private _preserveEngineOn = _player == driver _target && {isEngineOn _target}; + moveOut _player; + if (_preserveEngineOn) then {_target engineOn true}; + + // moveIn right after moveOut doesn't work in MP for non-local vehicles, player just stays out + // so we have to wait some time (e.g. until player is out and turret locality become vehicle locality) + // usually it's done in the same frame for local vehicles/turrets and takes 3-7 frames for non-local, so in MP can look a little lagging + if (IS_MOVED_OUT) exitWith { + [_player, _moveInParams] call _moveInCode; + WAIT_IN_OR_MOVE_BACK; + }; + [ + {params ["", "_target", "_player", "", "_currentTurret"]; IS_MOVED_OUT}, + { + params ["_moveInCode", "", "_player", "_moveInParams"]; + [_player, _moveInParams] call _moveInCode; + WAIT_IN_OR_MOVE_BACK; + }, + [_moveInCode, _target, _player, _moveInParams, _currentTurret] + ] call CBA_fnc_waitUntilAndExecute; +}; #define ICON_DRIVER "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_driver_ca.paa" #define ICON_PILOT "A3\ui_f\data\IGUI\Cfg\Actions\getinpilot_ca.paa" @@ -97,7 +100,7 @@ private _vehicleConfig = configFile >> "CfgVehicles" >> typeOf _vehicle; private _isInVehicle = _player in _vehicle; private _fullCrew = fullCrew [_vehicle, "", true]; -private ["_driverCompartments", "_isDriverIsolated", "_cargoCompartments", "_cargoCompartmentsLast", "_compartment", "_playerTurretPath"]; +private ["_driverCompartments", "_isDriverIsolated", "_cargoCompartments", "_cargoCompartmentsLast", "_compartment", "_currentTurret"]; if (_isInVehicle) then { _driverCompartments = (_vehicleConfig >> "driverCompartments") call BIS_fnc_getCfgData; @@ -120,7 +123,7 @@ if (_isInVehicle) then { _fullCrew select (_fullCrew findIf {_player == _x select 0}) ) params ["", "_role", "_cargoIndex", "_turretPath"]; - _playerTurretPath = _turretPath; + _currentTurret = _turretPath; switch (_role) do { case "driver": { @@ -170,8 +173,8 @@ private _cargoNumber = -1; }; if (_isInVehicle) then { if (_compartment != _driverCompartments || {_isDriverIsolated}) then {breakTo "crewLoop"}; - _params = [_vehicle, _playerTurretPath]; - _statement = {MOVE_OUT; MOVE_IN(moveInDriver)}; + _params = [{(_this select 0) moveInDriver (_this select 1)}, _vehicle, _currentTurret]; + _statement = _fnc_move; } else { _params = ["GetInDriver", _vehicle]; _statement = {_player action (_this select 2)}; @@ -189,8 +192,8 @@ private _cargoNumber = -1; if (_vehicle lockedCargo _cargoIndex) then {breakTo "crewLoop"}; if (_isInVehicle) then { if (_compartment != (_cargoCompartments select (_cargoNumber min _cargoCompartmentsLast))) then {breakTo "crewLoop"}; - _params = [[_vehicle, _cargoIndex], _playerTurretPath]; - _statement = {MOVE_OUT; MOVE_IN(moveInCargo)}; + _params = [{(_this select 0) moveInCargo (_this select 1)}, [_vehicle, _cargoIndex], _currentTurret]; + _statement = _fnc_move; } else { _params = ["GetInCargo", _vehicle, _cargoNumber]; _statement = {_player action (_this select 2)}; @@ -215,16 +218,8 @@ private _cargoNumber = -1; !("" isEqualTo _enabledByAnimationSource) && {1 > _vehicle doorPhase _enabledByAnimationSource} ) then {breakTo "crewLoop"}; - _params = [[_vehicle, _turretPath], _playerTurretPath, _enabledByAnimationSource]; - _statement = { - private _enabledByAnimationSource = _this select 2 select 2; - if ( - !("" isEqualTo _enabledByAnimationSource) - && {1 > _target doorPhase _enabledByAnimationSource} - ) exitWith {}; - MOVE_OUT; - MOVE_IN(moveInTurret); - }; + _params = [{(_this select 0) moveInTurret (_this select 1)}, [_vehicle, _turretPath], _currentTurret, _enabledByAnimationSource]; + _statement = _fnc_move; }; _name = getText (_turretConfig >> "gunnerName"); _icon = switch true do { From 66b661d6717b3a8131e882f480a1f12e8f6da6e1 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Fri, 16 Nov 2018 01:20:01 +0400 Subject: [PATCH 30/31] Fix validator --- addons/quickmount/functions/fnc_addFreeSeatsActions.sqf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf index 13388c60d84..59267b35b42 100644 --- a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf +++ b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf @@ -40,7 +40,8 @@ } \ )] call CBA_fnc_waitUntilAndExecute; -#define IS_MOVED_OUT (\ +#define IS_MOVED_OUT \ +( \ isNull objectParent _player \ && { \ [] isEqualTo _currentTurret \ From ef3cc84aa48483fa3ae037ac0ebb2e46530025b8 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Mon, 19 Nov 2018 00:10:21 +0400 Subject: [PATCH 31/31] Remove global variables, Add debug --- .../functions/fnc_addFreeSeatsActions.sqf | 77 ++++++++++--------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf index 59267b35b42..b49525d406e 100644 --- a/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf +++ b/addons/quickmount/functions/fnc_addFreeSeatsActions.sqf @@ -18,24 +18,31 @@ #define TAKEN_SEAT_TIMEOUT 0.5 -#define TO_COMPARTMENT_STRING(var) if !(var isEqualType "") then {var = format [ARR_2("Compartment%1",var)]} +#define ICON_DRIVER "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_driver_ca.paa" +#define ICON_PILOT "A3\ui_f\data\IGUI\Cfg\Actions\getinpilot_ca.paa" +#define ICON_CARGO "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_cargo_ca.paa" +#define ICON_GUNNER "A3\ui_f\data\IGUI\Cfg\Actions\getingunner_ca.paa" +#define ICON_COMMANDER "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_commander_ca.paa" +#define ICON_TURRET "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_gunner_ca.paa" +#define ICON_FFV "A3\ui_f\data\IGUI\Cfg\CrewAimIndicator\gunnerAuto_ca.paa" -#define UNBLOCK_DAMAGE \ - if (GETVAR(_this,GVAR(damageBlocked),false)) then { \ - _this allowDamage true; \ - SETVAR(_this,GVAR(damageBlocked),nil); \ - }; +#define TO_COMPARTMENT_STRING(var) if !(var isEqualType "") then {var = format [ARR_2("Compartment%1",var)]} // if unit isn't moved to new seat in TAKEN_SEAT_TIMEOUT, we move him back to his seat #define WAIT_IN_OR_MOVE_BACK \ [ARR_5( \ - {!isNull objectParent _this}, \ - {UNBLOCK_DAMAGE}, \ - _player, \ + {!isNull objectParent (_this select 0)}, \ + { \ + params [ARR_2("_player","_damageBlocked")]; \ + if (_damageBlocked) then {_player allowDamage true}; \ + LOG_1("moved in in %1 frames",diag_frameno-GVAR(frame)); \ + }, \ + [ARR_4(_player,_damageBlocked,_moveBackCode,_moveBackParams)], \ TAKEN_SEAT_TIMEOUT, \ { \ - [ARR_2(_this,_this getVariable QGVAR(moveBackParams))] call (_this getVariable QGVAR(moveBackCode)); \ - UNBLOCK_DAMAGE; \ + params [ARR_4("_player","_damageBlocked","_moveBackCode","_moveBackParams")]; \ + [ARR_2(_player,_moveBackParams)] call _moveBackCode; \ + if (_damageBlocked) then {_player allowDamage true}; \ localize "str_mis_state_failed" call EFUNC(common,displayTextStructured); \ } \ )] call CBA_fnc_waitUntilAndExecute; @@ -49,8 +56,11 @@ } \ ) +#define MOVE_IN_CODE(command) (_this select 0) command (_this select 1) + private _fnc_move = { - (_this select 2) params ["_moveInCode", "_moveInParams", "_currentTurret", ["_enabledByAnimationSource", ""]]; + (_this select 2) params ["_moveInCode", "_moveInParams", "_currentTurret", "_moveBackCode", "_moveBackParams", ["_enabledByAnimationSource", ""]]; + TRACE_7("fnc_move params",_moveInCode,_moveInParams,_currentTurret,_moveBackCode,_moveBackParams,_enabledByAnimationSource,call {GVAR(frame)=diag_frameno}); // check bugged FFV if ( @@ -59,9 +69,10 @@ private _fnc_move = { ) exitWith {}; // workaround getting damage when moveOut while vehicle is moving + private _damageBlocked = false; if (isDamageAllowed _player) then { _player allowDamage false; - SETVAR(_player,GVAR(damageBlocked),true); + _damageBlocked = true; }; private _preserveEngineOn = _player == driver _target && {isEngineOn _target}; moveOut _player; @@ -71,28 +82,22 @@ private _fnc_move = { // so we have to wait some time (e.g. until player is out and turret locality become vehicle locality) // usually it's done in the same frame for local vehicles/turrets and takes 3-7 frames for non-local, so in MP can look a little lagging if (IS_MOVED_OUT) exitWith { + LOG("moved out in current frame"); [_player, _moveInParams] call _moveInCode; WAIT_IN_OR_MOVE_BACK; }; [ - {params ["", "_target", "_player", "", "_currentTurret"]; IS_MOVED_OUT}, + {params ["_target", "_player", "_currentTurret"]; IS_MOVED_OUT}, { - params ["_moveInCode", "", "_player", "_moveInParams"]; + params ["", "_player", "", "_moveInCode", "_moveInParams", "_moveBackCode", "_moveBackParams", "_damageBlocked"]; + LOG_2("moved out in %1 frames",diag_frameno-GVAR(frame),call {GVAR(frame)=diag_frameno; 0}); [_player, _moveInParams] call _moveInCode; WAIT_IN_OR_MOVE_BACK; }, - [_moveInCode, _target, _player, _moveInParams, _currentTurret] + [_target, _player, _currentTurret, _moveInCode, _moveInParams, _moveBackCode, _moveBackParams, _damageBlocked] ] call CBA_fnc_waitUntilAndExecute; }; -#define ICON_DRIVER "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_driver_ca.paa" -#define ICON_PILOT "A3\ui_f\data\IGUI\Cfg\Actions\getinpilot_ca.paa" -#define ICON_CARGO "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_cargo_ca.paa" -#define ICON_GUNNER "A3\ui_f\data\IGUI\Cfg\Actions\getingunner_ca.paa" -#define ICON_COMMANDER "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_commander_ca.paa" -#define ICON_TURRET "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_gunner_ca.paa" -#define ICON_FFV "A3\ui_f\data\IGUI\Cfg\CrewAimIndicator\gunnerAuto_ca.paa" - scopeName "main"; params ["_vehicle", "_player"]; @@ -101,7 +106,7 @@ private _vehicleConfig = configFile >> "CfgVehicles" >> typeOf _vehicle; private _isInVehicle = _player in _vehicle; private _fullCrew = fullCrew [_vehicle, "", true]; -private ["_driverCompartments", "_isDriverIsolated", "_cargoCompartments", "_cargoCompartmentsLast", "_compartment", "_currentTurret"]; +private ["_driverCompartments", "_isDriverIsolated", "_cargoCompartments", "_cargoCompartmentsLast", "_compartment", "_currentTurret", "_moveBackCode", "_moveBackParams"]; if (_isInVehicle) then { _driverCompartments = (_vehicleConfig >> "driverCompartments") call BIS_fnc_getCfgData; @@ -117,8 +122,6 @@ if (_isInVehicle) then { } forEach _cargoCompartments; _cargoCompartmentsLast = count _cargoCompartments - 1; - TRACE_2("",_driverCompartments,_cargoCompartments); - // find current compartment ( _fullCrew select (_fullCrew findIf {_player == _x select 0}) @@ -132,24 +135,24 @@ if (_isInVehicle) then { [] breakOut "main"; }; _compartment = _driverCompartments; - _player setVariable [QGVAR(moveBackCode), {(_this select 0) moveInDriver (_this select 1)}]; - _player setVariable [QGVAR(moveBackParams), _vehicle]; + _moveBackCode = {MOVE_IN_CODE(moveInDriver)}; + _moveBackParams = _vehicle; }; case "cargo": { private _cargoNumber = fullCrew [_vehicle, "cargo", true] findIf {_player == _x select 0}; _compartment = _cargoCompartments select (_cargoNumber min _cargoCompartmentsLast); - _player setVariable [QGVAR(moveBackCode), {(_this select 0) moveInCargo (_this select 1)}]; - _player setVariable [QGVAR(moveBackParams), [_vehicle, _cargoIndex]]; + _moveBackCode = {MOVE_IN_CODE(moveInCargo)}; + _moveBackParams = [_vehicle, _cargoIndex]; }; default { private _turretConfig = [_vehicleConfig, _turretPath] call CBA_fnc_getTurret; _compartment = (_turretConfig >> "gunnerCompartments") call BIS_fnc_getCfgData; TO_COMPARTMENT_STRING(_compartment); - _player setVariable [QGVAR(moveBackCode), {(_this select 0) moveInTurret (_this select 1)}]; - _player setVariable [QGVAR(moveBackParams), [_vehicle, _turretPath]]; + _moveBackCode = {MOVE_IN_CODE(moveInTurret)}; + _moveBackParams = [_vehicle, _turretPath]; }; }; - TRACE_4("",_role,_cargoIndex,_turretPath,_compartment); + TRACE_6("current",_role,_cargoIndex,_turretPath,_compartment,_driverCompartments,_cargoCompartments); }; private _actions = []; @@ -174,7 +177,7 @@ private _cargoNumber = -1; }; if (_isInVehicle) then { if (_compartment != _driverCompartments || {_isDriverIsolated}) then {breakTo "crewLoop"}; - _params = [{(_this select 0) moveInDriver (_this select 1)}, _vehicle, _currentTurret]; + _params = [{MOVE_IN_CODE(moveInDriver)}, _vehicle, _currentTurret, _moveBackCode, _moveBackParams]; _statement = _fnc_move; } else { _params = ["GetInDriver", _vehicle]; @@ -193,7 +196,7 @@ private _cargoNumber = -1; if (_vehicle lockedCargo _cargoIndex) then {breakTo "crewLoop"}; if (_isInVehicle) then { if (_compartment != (_cargoCompartments select (_cargoNumber min _cargoCompartmentsLast))) then {breakTo "crewLoop"}; - _params = [{(_this select 0) moveInCargo (_this select 1)}, [_vehicle, _cargoIndex], _currentTurret]; + _params = [{MOVE_IN_CODE(moveInCargo)}, [_vehicle, _cargoIndex], _currentTurret, _moveBackCode, _moveBackParams]; _statement = _fnc_move; } else { _params = ["GetInCargo", _vehicle, _cargoNumber]; @@ -219,7 +222,7 @@ private _cargoNumber = -1; !("" isEqualTo _enabledByAnimationSource) && {1 > _vehicle doorPhase _enabledByAnimationSource} ) then {breakTo "crewLoop"}; - _params = [{(_this select 0) moveInTurret (_this select 1)}, [_vehicle, _turretPath], _currentTurret, _enabledByAnimationSource]; + _params = [{MOVE_IN_CODE(moveInTurret)}, [_vehicle, _turretPath], _currentTurret, _moveBackCode, _moveBackParams, _enabledByAnimationSource]; _statement = _fnc_move; }; _name = getText (_turretConfig >> "gunnerName");