diff --git a/.gitignore b/.gitignore index bcae9b6..a9216a1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ releases/* keys/* *.biprivatekey +.hemttprivatekey .hemttout diff --git a/CHANGELOG.md b/CHANGELOG.md index de97d04..0f3cb55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# Changelog for AIMEE 7.2.2026 + +1.3.10.0 +- Added search light interactions to ground vehicles. +- Added 4 copilot-related controls: 'Take Controls', 'Release Controls', 'Lock Controls' and 'Unlock Controls'. + # Changelog for AIMEE 27.9.2025 1.3.9.0 diff --git a/addons/change_ammo/addon.toml b/addons/change_ammo/addon.toml index 3a886f6..8bb019b 100644 --- a/addons/change_ammo/addon.toml +++ b/addons/change_ammo/addon.toml @@ -3,6 +3,3 @@ enabled = true [binarize] enabled = true - -[asc] -enabled = true diff --git a/addons/change_ammo/functions/fnc_loadMagazine.sqf b/addons/change_ammo/functions/fnc_loadMagazine.sqf index ff6b092..9d1d862 100644 --- a/addons/change_ammo/functions/fnc_loadMagazine.sqf +++ b/addons/change_ammo/functions/fnc_loadMagazine.sqf @@ -16,7 +16,7 @@ * None * * Example: - * [vehicle player, vehicle player, [_weapon, _muzzle, _magazine, _turret]] call AIMEE_change_ammo_fnc_loadMagazine + * [vehicle player, vehicle player, [currentWeapon vehicle player, currentMuzzle vehicle player, currentMagazine vehicle player, vehicle player unitTurret player]] call AIMEE_change_ammo_fnc_loadMagazine * * Public: No */ @@ -27,16 +27,8 @@ _args params ["_weapon", "_muzzle", "_magazine", "_turret"]; // Don't change mags for currently unselected weapons if (((weaponState [_target, _turret]) select 1) != _muzzle) exitWith {}; -private _magazinesAllTurrets = []; - // Get magazines that are of the correct type; Exclude empty mags -{ - _x params ["_xMag", "_xTurret", "_xAmmo"]; - - if ((_xMag == _magazine) && {_xTurret isEqualTo _turret} && {_xAmmo > 0}) then { - _magazinesAllTurrets pushBack _x; - }; -} forEach (magazinesAllTurrets _target); +private _magazinesAllTurrets = (magazinesAllTurrets _target) select {_x params ["_xMag", "_xTurret", "_xAmmo"]; (_xMag == _magazine) && {_xTurret isEqualTo _turret} && {_xAmmo > 0}}; // Get count of rounds in magazines, then select maximum private _magazinesCount = _magazinesAllTurrets apply {_x select 2}; diff --git a/addons/change_ammo/functions/fnc_magazinesUnitMenus.sqf b/addons/change_ammo/functions/fnc_magazinesUnitMenus.sqf index 83cbc6a..07e348b 100644 --- a/addons/change_ammo/functions/fnc_magazinesUnitMenus.sqf +++ b/addons/change_ammo/functions/fnc_magazinesUnitMenus.sqf @@ -7,7 +7,7 @@ * 0: Unit * * Return Value: - * Modified interaction menu + * Interaction menu * * Example: * player call AIMEE_change_ammo_fnc_magazinesUnitMenus @@ -15,14 +15,18 @@ * Public: No */ -(weaponState _this) params ["_weapon", "_muzzle", "", "_magazine"]; +params ["_unit"]; + +(weaponState _unit) params ["_weapon", "_muzzle", "", "_magazine"]; // Returns case correct magazines -private _magazines = (magazines [_this, false]) call CBA_fnc_getArrayElements; +private _magazines = (magazines [_unit, false]) call CBA_fnc_getArrayElements; -if (_magazines isEqualTo []) exitWith {[]}; +if (_magazines isEqualTo []) exitWith { + [] // return +}; -private _compatibleMagazines = compatibleMagazines [_weapon, _muzzle] - [_magazine]; +private _compatibleMagazines = (compatibleMagazines [_weapon, _muzzle]) - [_magazine]; private _class = ""; private _config = configNull; private _cfgMagazines = configFile >> "CfgMagazines"; @@ -32,23 +36,25 @@ for "_i" from 0 to (count _magazines) - 2 step 2 do { _class = _magazines select _i; // Find compatible magazines - if (_class in _compatibleMagazines) then { - _config = _cfgMagazines >> _class; - - _menus pushBack [ - [ - format [QGVAR(magazine_%1), _class], // Action name - format [GVAR(numMagazines), getText (_config >> "displayName"), _magazines select (_i + 1)], // Name of action shown in menu - getText (_config >> "picture"), // Icon - {_player reload (_this select 2)}, // Statement - {true}, // Condition - nil, - [_muzzle, _class] // Action parameters - ] call ace_interact_menu_fnc_createAction, - [], - _this - ]; + if !(_class in _compatibleMagazines) then { + continue; }; + + _config = _cfgMagazines >> _class; + + _menus pushBack [ + [ + format [QGVAR(magazine_%1), _class], // Action name + format [GVAR(numMagazines), getText (_config >> "displayName"), _magazines select (_i + 1)], // Name of action shown in menu + getText (_config >> "picture"), // Icon + {_player reload (_this select 2)}, // Statement + {true}, // Condition + nil, + [_muzzle, _class] // Action parameters + ] call ace_interact_menu_fnc_createAction, + [], + _unit + ]; }; -_menus +_menus // return diff --git a/addons/change_ammo/functions/fnc_magazinesVehicleMenus.sqf b/addons/change_ammo/functions/fnc_magazinesVehicleMenus.sqf index 722933f..bf7c2e4 100644 --- a/addons/change_ammo/functions/fnc_magazinesVehicleMenus.sqf +++ b/addons/change_ammo/functions/fnc_magazinesVehicleMenus.sqf @@ -8,7 +8,7 @@ * 1: Vehicle * * Return Value: - * Modified interaction menu + * Interaction menu * * Example: * [player, vehicle player] call AIMEE_change_ammo_fnc_magazinesVehicleMenus @@ -19,40 +19,49 @@ params ["_unit", "_target"]; private _turret = _target unitTurret _unit; -(weaponState [_target, _turret]) params ["_weapon", "_muzzle", "", "_magazine"]; -// Do not allow menu creation for vanilla autocannons that use different firemodes to switch ammunition types instead of magazines -if (_weapon in ["autocannon_40mm_CTWS", "autocannon_30mm_CTWS", "autocannon_30mm", "ACE_cannon_20mm_Rh202"]) exitWith {[]}; +if (_turret isEqualTo []) exitWith { + [] // return +}; + +(weaponState [_target, _turret]) params ["_weapon", "_muzzle", "", "_magazine"]; // Returns case correct magazines -private _allAvailableMags = (_target magazinesTurret [_turret, false]) call CBA_fnc_getArrayElements; -private _compatibleMags = compatibleMagazines [_weapon, _muzzle] - [_magazine]; +private _magazines = (_target magazinesTurret [_turret, false]) call CBA_fnc_getArrayElements; + +if (_magazines isEqualTo []) exitWith { + [] // return +}; + +private _compatibleMags = (compatibleMagazines [_weapon, _muzzle]) - [_magazine]; private _menus = []; private _class = ""; private _config = ""; private _cfgMagazines = configFile >> "CfgMagazines"; -for "_i" from 0 to (count _allAvailableMags) - 2 step 2 do { - _class = _allAvailableMags select _i; +for "_i" from 0 to (count _magazines) - 2 step 2 do { + _class = _magazines select _i; // Find compatible magazines - if (_class in _compatibleMags) then { - _config = _cfgMagazines >> _class; - - _menus pushBack [ - [ - format [QGVAR(magazineVehicle_%1), _class], // Action name - getText (_config >> "displayName"), // Name of action shown in menu - getText (_config >> "picture"), // Icon - {[_player, _target, _this select 2] call FUNC(loadMagazine)}, // Statement - {true}, // Condition - nil, - [_weapon, _muzzle, _class, _turret] // Action parameters - ] call ace_interact_menu_fnc_createAction, - [], - _target - ]; + if !(_class in _compatibleMags) then { + continue; }; + + _config = _cfgMagazines >> _class; + + _menus pushBack [ + [ + format [QGVAR(magazineVehicle_%1), _class], // Action name + getText (_config >> "displayName"), // Name of action shown in menu + getText (_config >> "picture"), // Icon + {[_player, _target, _this select 2] call FUNC(loadMagazine)}, // Statement + {true}, // Condition + nil, + [_weapon, _muzzle, _class, _turret] // Action parameters + ] call ace_interact_menu_fnc_createAction, + [], + _target + ]; }; -_menus +_menus // return diff --git a/addons/change_ammo/script_component.hpp b/addons/change_ammo/script_component.hpp index e6ac21c..b3e571c 100644 --- a/addons/change_ammo/script_component.hpp +++ b/addons/change_ammo/script_component.hpp @@ -4,7 +4,7 @@ // #define DEBUG_MODE_FULL // #define DISABLE_COMPILE_CACHE -// #define DEBUG_SYNCHRONOUS +#define DEBUG_SYNCHRONOUS // #define ENABLE_PERFORMANCE_COUNTERS #ifdef DEBUG_ENABLED_AIMEE_CHANGE_AMMO diff --git a/addons/group/addon.toml b/addons/group/addon.toml index 3a886f6..8bb019b 100644 --- a/addons/group/addon.toml +++ b/addons/group/addon.toml @@ -3,6 +3,3 @@ enabled = true [binarize] enabled = true - -[asc] -enabled = true diff --git a/addons/group/script_component.hpp b/addons/group/script_component.hpp index 0bb921d..18eb89e 100644 --- a/addons/group/script_component.hpp +++ b/addons/group/script_component.hpp @@ -4,7 +4,7 @@ // #define DEBUG_MODE_FULL // #define DISABLE_COMPILE_CACHE -// #define DEBUG_SYNCHRONOUS +#define DEBUG_SYNCHRONOUS // #define ENABLE_PERFORMANCE_COUNTERS #ifdef DEBUG_ENABLED_AIMEE_GROUP diff --git a/addons/inventory/XEH_PREP.hpp b/addons/inventory/XEH_PREP.hpp index f87bbf5..645f987 100644 --- a/addons/inventory/XEH_PREP.hpp +++ b/addons/inventory/XEH_PREP.hpp @@ -1,7 +1,6 @@ PREP(assemble); PREP(assembleModify); PREP(backpackPos); -PREP(backpackType); PREP(backpackUAVModify); PREP(canAssemble); PREP(canDisassemble); diff --git a/addons/inventory/addon.toml b/addons/inventory/addon.toml index 3a886f6..8bb019b 100644 --- a/addons/inventory/addon.toml +++ b/addons/inventory/addon.toml @@ -3,6 +3,3 @@ enabled = true [binarize] enabled = true - -[asc] -enabled = true diff --git a/addons/inventory/functions/fnc_UAVAssemble.sqf b/addons/inventory/functions/fnc_UAVAssemble.sqf index e943dc1..5dbdf3e 100644 --- a/addons/inventory/functions/fnc_UAVAssemble.sqf +++ b/addons/inventory/functions/fnc_UAVAssemble.sqf @@ -10,7 +10,7 @@ * None * * Example: - * player call AIMEE_uav_terminal_fnc_UAVAssemble + * player call AIMEE_inventory_fnc_UAVAssemble * * Public: No */ @@ -26,6 +26,8 @@ _unit playAction "PutDown"; [{ params ["_unit"]; + if (!alive _unit) exitWith {}; + // Check if backpack hasn't changed private _UAVType = _unit call FUNC(UAVType); @@ -38,7 +40,7 @@ _unit playAction "PutDown"; // Find position to place UAV private _direction = getDir _unit; - private _position = (getPosASL _unit) vectorAdd [0.8 * sin(_direction), 0.8 * cos(_direction), 0]; + private _position = (getPosASL _unit) vectorAdd [sin _direction, cos _direction, 0] vectorMultiply 0.8; private _intersection = (lineIntersectsSurfaces [_position vectorAdd [0, 0, 1.5], _position vectorDiff [0, 0, 1.5], _unit, objNull, true, 1, "GEOM", "FIRE"]) param [0, []]; private _vectorUp = if (_intersection isNotEqualTo []) then { diff --git a/addons/inventory/functions/fnc_UAVType.sqf b/addons/inventory/functions/fnc_UAVType.sqf index 2309768..d6c82bc 100644 --- a/addons/inventory/functions/fnc_UAVType.sqf +++ b/addons/inventory/functions/fnc_UAVType.sqf @@ -10,18 +10,24 @@ * Returns what type of UAV can be assembled from backpack * * Example: - * player call AIMEE_uav_terminal_fnc_UAVType + * player call AIMEE_inventory_fnc_UAVType * * Public: No */ -private _backpack = backpackContainer _this; +params ["_unit"]; -if (isNull _backpack) exitWith {""}; +private _backpack = backpackContainer _unit; + +if (isNull _backpack) exitWith { + "" // return +}; private _config = configOf _backpack >> "assembleInfo"; // Ignore static weapons -if (isNull _config || {isArray (_config >> "base")}) exitWith {""}; +if (isNull _config || {isArray (_config >> "base")}) exitWith { + "" // return +}; -getText (_config >> "assembleTo") +getText (_config >> "assembleTo") // return diff --git a/addons/inventory/functions/fnc_assemble.sqf b/addons/inventory/functions/fnc_assemble.sqf index e295295..7da05fe 100644 --- a/addons/inventory/functions/fnc_assemble.sqf +++ b/addons/inventory/functions/fnc_assemble.sqf @@ -15,14 +15,16 @@ * Public: No */ -(call FUNC(locateBackpack)) params ["_base", "_weapon", "_weaponHolder", "_baseOnGround"]; +params ["_unit"]; + +(_unit call FUNC(locateBackpack)) params ["_base", "_weapon", "_weaponHolder", "_baseOnGround"]; // If the base is on the ground, switch it with the weapon on the player's back if (_baseOnGround) then { - _weapon = backpackContainer _this; + _weapon = backpackContainer _unit; // Add base to player, which will automatically drop bag - _this addBackpack (typeOf _base); + _unit addBackpack (typeOf _base); // Delete weapon in weaponholder deleteVehicle _weaponHolder; @@ -30,8 +32,8 @@ if (_baseOnGround) then { // Look for switched backpacks in next frame and assemble then [{ (_this select 0) action ["Assemble", _this select 1]; - }, [_this, _weapon]] call CBA_fnc_execNextFrame; + }, [_unit, _weapon]] call CBA_fnc_execNextFrame; } else { // If tripod on back (weapon on ground) - _this action ["Assemble", _weapon]; + _unit action ["Assemble", _weapon]; }; diff --git a/addons/inventory/functions/fnc_assembleModify.sqf b/addons/inventory/functions/fnc_assembleModify.sqf index d9cc8e7..3db407b 100644 --- a/addons/inventory/functions/fnc_assembleModify.sqf +++ b/addons/inventory/functions/fnc_assembleModify.sqf @@ -4,13 +4,13 @@ * Sets the name of the interaction. * * Arguments: - * 0: Object + * 0: Object (not used) * 1: Unit - * 2: Params + * 2: Params (not used) * 3: Interaction menu * * Return Value: - * Modified interaction menu + * None * * Public: No */ diff --git a/addons/inventory/functions/fnc_backpackPos.sqf b/addons/inventory/functions/fnc_backpackPos.sqf index c1a55dd..caf92a8 100644 --- a/addons/inventory/functions/fnc_backpackPos.sqf +++ b/addons/inventory/functions/fnc_backpackPos.sqf @@ -15,5 +15,7 @@ * Public: No */ -private _spine = _this selectionPosition "spine3"; -(((_this selectionPosition "rightshoulder" vectorDiff _spine) vectorCrossProduct (_this selectionPosition "leftshoulder" vectorDiff _spine)) vectorMultiply 4) vectorAdd _spine; +params ["_unit"]; + +private _spine = _unit selectionPosition "spine3"; +(((_unit selectionPosition "rightshoulder" vectorDiff _spine) vectorCrossProduct (_unit selectionPosition "leftshoulder" vectorDiff _spine)) vectorMultiply 4) vectorAdd _spine // return diff --git a/addons/inventory/functions/fnc_backpackType.sqf b/addons/inventory/functions/fnc_backpackType.sqf deleted file mode 100644 index b76980c..0000000 --- a/addons/inventory/functions/fnc_backpackType.sqf +++ /dev/null @@ -1,24 +0,0 @@ -#include "..\script_component.hpp" -/* - * Author: johnb43 - * Returns the types of backpack that a UAV can be disassembled into. - * - * Arguments: - * 0: Unit - * - * Return Value: - * Returns what type of UAV can be disassembled into backpack - * - * Example: - * player call AIMEE_uav_terminal_fnc_backpackType - * - * Public: No - */ - -if (isNull _this) exitWith {[]}; - -private _config = configOf _backpack >> "assembleInfo"; - -if (isNull _config) exitWith {[]}; - -getArray (_config >> "dissasembleTo") diff --git a/addons/inventory/functions/fnc_backpackUAVModify.sqf b/addons/inventory/functions/fnc_backpackUAVModify.sqf index 16be393..195d233 100644 --- a/addons/inventory/functions/fnc_backpackUAVModify.sqf +++ b/addons/inventory/functions/fnc_backpackUAVModify.sqf @@ -4,13 +4,13 @@ * Sets the icon and name of the interaction. * * Arguments: - * 0: Object + * 0: Object (not used) * 1: Unit - * 2: Params + * 2: Params (not used) * 3: Interaction menu * * Return Value: - * Modified interaction menu + * None * * Public: No */ diff --git a/addons/inventory/functions/fnc_canAssemble.sqf b/addons/inventory/functions/fnc_canAssemble.sqf index b71c247..d67801c 100644 --- a/addons/inventory/functions/fnc_canAssemble.sqf +++ b/addons/inventory/functions/fnc_canAssemble.sqf @@ -15,8 +15,12 @@ * Public: No */ -if (isNull (configOf backpackContainer _this >> "assembleInfo")) exitWith {false}; +params ["_unit"]; -(call FUNC(locateBackpack)) params ["_base", "_weapon"]; +if (isNull (configOf backpackContainer _unit >> "assembleInfo")) exitWith { + false // return +}; -!isNull _base && {!isNull _weapon} +(_unit call FUNC(locateBackpack)) params ["_base", "_weapon"]; + +!isNull _base && {!isNull _weapon} // return diff --git a/addons/inventory/functions/fnc_canDisassemble.sqf b/addons/inventory/functions/fnc_canDisassemble.sqf index de740ac..fb2bd01 100644 --- a/addons/inventory/functions/fnc_canDisassemble.sqf +++ b/addons/inventory/functions/fnc_canDisassemble.sqf @@ -19,21 +19,27 @@ params ["_unit", "_vehicle"]; // Check if disabled via commands -if !(weaponDisassemblyEnabled _unit && weaponDisassemblyEnabled _vehicle) exitWith {false}; +if !(weaponDisassemblyEnabled _unit && weaponDisassemblyEnabled _vehicle) exitWith { + false // return +}; private _config = configOf _vehicle >> "assembleInfo"; // Check if not possible -if (isNull _config || {getArray (_config >> "dissasembleTo") isEqualTo []}) exitWith {false}; +if (isNull _config || {getArray (_config >> "dissasembleTo") isEqualTo []}) exitWith { + false // return +}; private _crew = crew _vehicle; // If vehicle is empty, quit -if (_crew isEqualTo []) exitWith {true}; +if (_crew isEqualTo []) exitWith { + true // return +}; private _sideUnit = side group _unit; (_crew select {!unitIsUAV _x}) findIf { // ignore UAV units // Units must all be unconscious, captive or friendly (side group is used in case unit is captive/unconscious) for actions to show up !captive _x && {lifeState _x in ["HEALTHY", "INJURED"]} && {[_sideUnit, side group _x] call BIS_fnc_sideIsEnemy} -} == -1 +} == -1 // return diff --git a/addons/inventory/functions/fnc_canPickup.sqf b/addons/inventory/functions/fnc_canPickup.sqf index 9fee4da..eac8eef 100644 --- a/addons/inventory/functions/fnc_canPickup.sqf +++ b/addons/inventory/functions/fnc_canPickup.sqf @@ -22,4 +22,4 @@ private _content = itemCargo _target; _content append (magazineCargo _target); _content append (backpackCargo _target); -count _content == 1 && {[_unit, _target, []] call ace_common_fnc_canInteractWith} +count _content == 1 && {[_unit, _target, []] call ace_common_fnc_canInteractWith} // return diff --git a/addons/inventory/functions/fnc_explosiveMenus.sqf b/addons/inventory/functions/fnc_explosiveMenus.sqf index 735634d..2234bbe 100644 --- a/addons/inventory/functions/fnc_explosiveMenus.sqf +++ b/addons/inventory/functions/fnc_explosiveMenus.sqf @@ -7,7 +7,7 @@ * 0: Unit * * Return Value: - * Modified interaction menu + * Interaction menu * * Example: * player call AIMEE_inventory_fnc_explosiveMenus @@ -15,10 +15,14 @@ * Public: No */ +params ["_unit"]; + // Returns case correct magazines -private _magazines = (magazines [_this, false]) call CBA_fnc_getArrayElements; +private _magazines = (magazines [_unit, false]) call CBA_fnc_getArrayElements; -if (_magazines isEqualTo []) exitWith {[]}; +if (_magazines isEqualTo []) exitWith { + [] // return +}; private _explosives = uiNamespace getVariable ["ace_arsenal_putCache", createHashMap]; private _class = ""; @@ -30,39 +34,43 @@ for "_i" from 0 to (count _magazines) - 2 step 2 do { _class = _magazines select _i; // Find compatible magazines - if (_class in _explosives) then { - _config = _cfgMagazines >> _class; + if !(_class in _explosives) then { + continue; + }; - _menus pushBack [ - [ - format [QGVAR(explosive_%1), _class], // Action name - format [LQSTRING(str_action_putbomb), getText (_config >> "displayName"), _magazines select (_i + 1)], // Name of action shown in menu - getText (_config >> "picture"), // Icon - { - _player playAction "PutDown"; + _config = _cfgMagazines >> _class; - [{ - params ["_unit", "_mineData"]; + _menus pushBack [ + [ + format [QGVAR(explosive_%1), _class], // Action name + format [LQSTRING(str_action_putbomb), getText (_config >> "displayName"), _magazines select (_i + 1)], // Name of action shown in menu + getText (_config >> "picture"), // Icon + { + _player playAction "PutDown"; - // If magazine couldn't be removed, it means it was deleted before; Don't continue - if !([_unit, _mineData select 0] call CBA_fnc_removeMagazine) exitWith {}; + [{ + params ["_unit", "_mineData"]; - private _mine = createVehicle [_mineData select 1, _unit, [], 0]; - _mine setDir (getDir _unit); - _mine setPosWorld getPosWorld _mine; // mine direction needs to be synchronised + if (!alive _unit) exitWith {}; - _unit addOwnedMine _mine; - (side group _unit) revealMine _mine; - }, [_player, _this select 2], 1] call CBA_fnc_waitAndExecute; - }, // Statement - {true}, // Condition - nil, - [_class, getText (_config >> "ammo")] // Action parameters - ] call ace_interact_menu_fnc_createAction, - [], - _this - ]; - }; + // If magazine couldn't be removed, it means it was deleted before; Don't continue + if !([_unit, _mineData select 0] call CBA_fnc_removeMagazine) exitWith {}; + + private _mine = createVehicle [_mineData select 1, _unit, [], 0]; + _mine setDir (getDir _unit); + _mine setPosWorld getPosWorld _mine; // Mine direction needs to be synchronised + + _unit addOwnedMine _mine; + (side group _unit) revealMine _mine; + }, [_player, _this select 2], 1] call CBA_fnc_waitAndExecute; + }, // Statement + {true}, // Condition + nil, + [_class, getText (_config >> "ammo")] // Action parameters + ] call ace_interact_menu_fnc_createAction, + [], + _unit + ]; }; -_menus +_menus // return diff --git a/addons/inventory/functions/fnc_hasInventory.sqf b/addons/inventory/functions/fnc_hasInventory.sqf index 9839441..35daea3 100644 --- a/addons/inventory/functions/fnc_hasInventory.sqf +++ b/addons/inventory/functions/fnc_hasInventory.sqf @@ -15,4 +15,6 @@ * Public: No */ -!lockedInventory _this && {maxLoad _this > 0} && {getNumber (configOf _this >> "disableInventory") != 1} +params ["_object"]; + +!lockedInventory _object && {maxLoad _object > 0} && {getNumber (configOf _object >> "disableInventory") != 1} // return diff --git a/addons/inventory/functions/fnc_holderModify.sqf b/addons/inventory/functions/fnc_holderModify.sqf index 47ccd7f..6356bbd 100644 --- a/addons/inventory/functions/fnc_holderModify.sqf +++ b/addons/inventory/functions/fnc_holderModify.sqf @@ -5,12 +5,12 @@ * * Arguments: * 0: Object - * 1: Unit - * 2: Params + * 1: Unit (not used) + * 2: Params (not used) * 3: Interaction menu * * Return Value: - * Modified interaction menu + * None * * Public: No */ diff --git a/addons/inventory/functions/fnc_locateBackpack.sqf b/addons/inventory/functions/fnc_locateBackpack.sqf index cf76860..b5da3b5 100644 --- a/addons/inventory/functions/fnc_locateBackpack.sqf +++ b/addons/inventory/functions/fnc_locateBackpack.sqf @@ -19,13 +19,19 @@ * Public: No */ -private _backpack = backpackContainer _this; +params ["_unit"]; -if (isNull _backpack) exitWith {[objNull, objNull, objNull, false]}; +private _backpack = backpackContainer _unit; + +if (isNull _backpack) exitWith { + [objNull, objNull, objNull, false] // return +}; private _config = configOf _backpack >> "assembleInfo"; -if (isNull _config) exitWith {[objNull, objNull, objNull, false]}; +if (isNull _config) exitWith { + [objNull, objNull, objNull, false] // return +}; // If tripod on back if (getNumber (_config >> "primary") == 0) then { @@ -44,14 +50,16 @@ if (getNumber (_config >> "primary") == 0) then { if (!isNull _weapon) exitWith { _weaponHolder = _x; }; - } forEach (nearestObjects [_this, ["GroundWeaponHolder"], 3]); + } forEach (nearestObjects [_unit, ["GroundWeaponHolder"], 3]); - [_backpack, _weapon, _weaponHolder, false] + [_backpack, _weapon, _weaponHolder, false] // return } else { // If weapon on back: Returns classnames of tripod backpacks that are compatible with a given weapon backpack private _bases = getArray (_config >> "base"); - if ((_bases param [0, ""]) == "") exitWith {[objNull, objNull, objNull, false]}; + if ((_bases param [0, ""]) == "") exitWith { + [objNull, objNull, objNull, false] // return + }; private _type = ""; private _weaponHolder = objNull; @@ -69,7 +77,7 @@ if (getNumber (_config >> "primary") == 0) then { if (!isNull _base) exitWith { _weaponHolder = _x; }; - } forEach (nearestObjects [_this, ["GroundWeaponHolder"], 3]); + } forEach (nearestObjects [_unit, ["GroundWeaponHolder"], 3]); - [_base, _backpack, _weaponHolder, true] + [_base, _backpack, _weaponHolder, true] // return }; diff --git a/addons/inventory/functions/fnc_playerPickUpItem.sqf b/addons/inventory/functions/fnc_playerPickUpItem.sqf index 0c3939a..400d02e 100644 --- a/addons/inventory/functions/fnc_playerPickUpItem.sqf +++ b/addons/inventory/functions/fnc_playerPickUpItem.sqf @@ -11,7 +11,7 @@ * 4: Container * * Return Value: - * Returns if the item was picked up or not + * Returns if the item was picked up or not * * Example: * [player, cursorObject, "FirstAidKit"] call AIMEE_inventory_fnc_playerPickupItem @@ -33,6 +33,11 @@ if (headgear _unit == "" && {_description == "headgear"}) exitWith { [{ params ["_unit", "_item", "_container"]; + if (!alive _unit) exitWith {}; + + // Check if unit's gear hasn't updated; Don't continue + if (headgear _unit != "") exitWith {}; + // If item couldn't be removed, it means it was deleted before; Don't continue if !([_container, _item] call CBA_fnc_removeItemCargo) exitWith {}; @@ -40,7 +45,7 @@ if (headgear _unit == "" && {_description == "headgear"}) exitWith { _unit addHeadgear _item; }, [_unit, _item, _container], 1] call CBA_fnc_waitAndExecute; - true + true // return }; // Face wear if (goggles _unit == "" && {_description == "goggles"}) exitWith { @@ -49,6 +54,11 @@ if (goggles _unit == "" && {_description == "goggles"}) exitWith { [{ params ["_unit", "_item", "_container"]; + if (!alive _unit) exitWith {}; + + // Check if unit's gear hasn't updated; Don't continue + if (goggles _unit != "") exitWith {}; + // If item couldn't be removed, it means it was deleted before; Don't continue if !([_container, _item] call CBA_fnc_removeItemCargo) exitWith {}; @@ -56,7 +66,7 @@ if (goggles _unit == "" && {_description == "goggles"}) exitWith { _unit addGoggles _item; }, [_unit, _item, _container], 1] call CBA_fnc_waitAndExecute; - true + true // return }; private _containerIndex = ["uniform", "vest"] findIf {_description == _x}; @@ -70,6 +80,11 @@ if (_containerIndex != -1) exitWith { params ["_unit", "_firstContainerClassname", "_container", "_containerIndex", "_weaponItemsCargo", "_magazinesAmmoCargo", "_itemCargo"]; _itemCargo params ["_items", "_itemsCount"]; + if (!alive _unit) exitWith {}; + + // Check if unit's gear hasn't updated; Don't continue + if (([uniform _unit, vest _unit] select _containerIndex) != "") exitWith {}; + // If item couldn't be removed, it means it was deleted before; Don't continue if !([_container, _firstContainerClassname] call CBA_fnc_removeItemCargo) exitWith {}; @@ -107,7 +122,7 @@ if (_containerIndex != -1) exitWith { } forEach _items; }, [_unit, _firstContainerClassname, _container, _containerIndex, weaponsItemsCargo _firstContainer, magazinesAmmoCargo _firstContainer, getItemCargo _firstContainer], 1] call CBA_fnc_waitAndExecute; - true + true // return } else { // Add to inventory if possible if (_unit canAdd _firstContainerClassname && {load _firstContainer == 0}) exitWith { @@ -116,16 +131,21 @@ if (_containerIndex != -1) exitWith { [{ params ["_unit", "_firstContainerClassname", "_container"]; + if (!alive _unit) exitWith {}; + + // Check if unit's gear hasn't updated; Don't continue + if !(_unit canAdd _firstContainerClassname) exitWith {}; + // If item couldn't be removed, it means it was deleted before; Don't continue if !([_container, _firstContainerClassname] call CBA_fnc_removeItemCargo) exitWith {}; _unit addItem _firstContainerClassname; }, [_unit, _firstContainerClassname, _container], 1] call CBA_fnc_waitAndExecute; - true + true // return }; - false + false // return }; }; @@ -143,50 +163,68 @@ if (load _firstContainer == 0) exitWith { // Check if the assignedItems slot for item is empty { - if (_x == _description) exitWith { - // If the item can't be added to the assignedItems, check if it fits in the inventory further below - if (((_loadout select 9) select _forEachIndex) != "") exitWith {}; + if (_x != _description) then { + continue; + }; - _unit playAction "PutDown"; + // If the item can't be added to the assignedItems, check if it fits in the inventory further below + if (((_loadout select 9) select _forEachIndex) != "") exitWith {}; - [{ - params ["_unit", "_item", "_container"]; + _unit playAction "PutDown"; - // If item couldn't be removed, it means it was deleted before; Don't continue - if !([_container, _item] call CBA_fnc_removeItemCargo) exitWith {}; + [{ + params ["_unit", "_item", "_container", "_slotNumber"]; - _unit linkItem _item; - }, [_unit, _item, _container], 1] call CBA_fnc_waitAndExecute; + if (!alive _unit) exitWith {}; - true breakOut "main" - }; + // Check if unit's gear hasn't updated; Don't continue + if ((_unit getSlotItemName _slotNumber) != "") exitWith {}; + + // If item couldn't be removed, it means it was deleted before; Don't continue + if !([_container, _item] call CBA_fnc_removeItemCargo) exitWith {}; + + _unit linkItem _item; + }, [_unit, _item, _container, [608, 612, 611, 609, 610, 616] select _forEachIndex], 1] call CBA_fnc_waitAndExecute; + + true breakOut "main" // return } forEach ["map", "uav_terminal", "radio", "compass", "watch", "nvgoggles"]; // Check if weapons have space for item { - if (_x == _description) exitWith { - private _attachmentIndex = _forEachIndex; + if (_x != _description) then { + continue; + }; - { - _x params [["_weapon", ""], ["_muzzle", ""], ["_flashlight", ""], ["_optics", ""], "", "", ["_bipod", ""]]; + private _attachmentIndex = _forEachIndex; - // Check if item is compatible and if slot is empty - if (_weapon canAdd _item && {([_optics, _flashlight, _muzzle, _bipod] select _attachmentIndex) == ""}) exitWith { - _unit playAction "PutDown"; + { + _x params [["_weapon", ""], ["_muzzle", ""], ["_flashlight", ""], ["_optics", ""], "", "", ["_bipod", ""]]; - [{ - params ["_unit", "_item", "_container", "_weapon"]; + // Check if item is compatible and if slot is empty + if !(_weapon canAdd _item && {([_optics, _flashlight, _muzzle, _bipod] select _attachmentIndex) == ""}) then { + continue; + }; - // If item couldn't be removed, it means it was deleted before; Don't continue - if !([_container, _item] call CBA_fnc_removeItemCargo) exitWith {}; + _unit playAction "PutDown"; - _unit addWeaponItem [_weapon, _item]; - }, [_unit, _item, _container, _weapon], 1] call CBA_fnc_waitAndExecute; + [{ + params ["_unit", "_item", "_container", "_weapon", "_attachmentIndex", "_weaponIndex"]; - true breakOut "main" - }; - } forEach [_loadout select 0, _loadout select 1, _loadout select 2, _loadout select 8]; // Primary, secondary, handgun weapons, binoculars - }; + if (!alive _unit) exitWith {}; + + ((getUnitLoadout _unit) select ([_weaponIndex, 8] select (_weaponIndex == 3))) params [["_newWeapon", ""], ["_muzzle", ""], ["_flashlight", ""], ["_optics", ""], "", "", ["_bipod", ""]]; + + // Check if unit's gear hasn't updated; Don't continue + if (_newWeapon != _weapon || {([_optics, _flashlight, _muzzle, _bipod] select _attachmentIndex) != ""}) exitWith {}; + + // If item couldn't be removed, it means it was deleted before; Don't continue + if !([_container, _item] call CBA_fnc_removeItemCargo) exitWith {}; + + _unit addWeaponItem [_weapon, _item]; + }, [_unit, _item, _container, _weapon, _attachmentIndex, _forEachIndex], 1] call CBA_fnc_waitAndExecute; + + true breakOut "main" // return + } forEach [_loadout select 0, _loadout select 1, _loadout select 2, _loadout select 8]; // Primary, secondary, handgun weapons, binoculars } forEach ["optics", "flashlight", "muzzle", "under"]; // Add to inventory if possible @@ -196,17 +234,22 @@ if (load _firstContainer == 0) exitWith { [{ params ["_unit", "_item", "_container"]; + if (!alive _unit) exitWith {}; + + // Check if unit's gear hasn't updated; Don't continue + if !(_unit canAdd _item) exitWith {}; + // If item couldn't be removed, it means it was deleted before; Don't continue if !([_container, _item] call CBA_fnc_removeItemCargo) exitWith {}; _unit addItem _item; }, [_unit, _item, _container], 1] call CBA_fnc_waitAndExecute; - true + true // return }; - false + false // return }; // If not possible, open container -false +false // return diff --git a/addons/inventory/functions/fnc_playerPickUpMagazine.sqf b/addons/inventory/functions/fnc_playerPickUpMagazine.sqf index 0eafb6e..3e0f768 100644 --- a/addons/inventory/functions/fnc_playerPickUpMagazine.sqf +++ b/addons/inventory/functions/fnc_playerPickUpMagazine.sqf @@ -12,7 +12,7 @@ * Returns if the magazine was picked up or not * * Example: - * [player, cursorObject, "30Rnd_762x39_AK12_Mag_F"] call AIMEE_inventory_fnc_playerPickupMagazine + * [player, cursorObject, ["30Rnd_762x39_AK12_Mag_F", 30]] call AIMEE_inventory_fnc_playerPickupMagazine * * Public: No */ @@ -24,74 +24,115 @@ _magazine params ["_magazine", "_ammo"]; private _loadout = getUnitLoadout _unit; private _muzzles = []; -private _index = -1; +private _magazineMuzzles = []; { _x params [["_weapon", ""], "", "", "", ["_primaryMagazine", []], ["_secondaryMagazine", []]]; + // Find in which muzzle the magazine fits + if !(_weapon canAdd _magazine) then { + continue; + }; + _muzzles = _weapon call CBA_fnc_getMuzzles; - _index = (_muzzles apply {compatibleMagazines [_weapon, _x]}) findIf {_magazine in _x}; + _magazineMuzzles = (_muzzles apply {_magazine in compatibleMagazines [_weapon, _x]}); - // Find in which muzzle the magazine fits - if (_weapon canAdd _magazine && {([_primaryMagazine, _secondaryMagazine] select _index) param [0, ""] == ""}) exitWith { - _unit playAction "PutDown"; + // Check all muzzles, in case primary muzzle is full, but secondary muzzle can take magazine + if !(true in _magazineMuzzles) then { + continue; + }; - [{ - params ["_unit", "_magazine", "_ammo", "_container", "_weapon", "_muzzles", "_isSecondaryMagazine"]; + private _muzzleIndex = -1; + + { + if (([_primaryMagazine, _secondaryMagazine] select _forEachIndex) param [0, ""] == "") exitWith { + _muzzleIndex = _forEachIndex; + }; + } forEach _magazineMuzzles; + + _unit playAction "PutDown"; + + [{ + params ["_unit", "_magazine", "_ammo", "_container", "_weapon", "_muzzles", "_muzzleIndex", "_weaponIndex"]; + + if (!alive _unit) exitWith {}; + + ((getUnitLoadout _unit) select ([_weaponIndex, 8] select (_weaponIndex == 3))) params [["_newWeapon", ""], "", "", "", ["_primaryMagazine", []], ["_secondaryMagazine", []]]; + + // Check if unit's gear hasn't updated; Don't continue + if (_newWeapon != _weapon || {([_primaryMagazine, _secondaryMagazine] select _muzzleIndex) param [0, ""] != ""}) exitWith {}; + + // If magazine couldn't be removed, it means it was deleted before; Don't continue + if !([_container, _magazine, 1, _ammo] call CBA_fnc_removeMagazineCargo) exitWith {}; - // If magazine couldn't be removed, it means it was deleted before; Don't continue - if !([_container, _magazine, 1, _ammo] call CBA_fnc_removeMagazineCargo) exitWith {}; + private _weaponConfig = configFile >> "CfgWeapons" >> _weapon; - private _weaponConfig = configFile >> "CfgWeapons" >> _weapon; + // If secondary magazine was chosen, get secondary muzzle + if (_muzzleIndex != 0) then { + _weaponConfig = _weaponConfig >> _muzzles select _muzzleIndex; + }; - // If secondary magazine was chosen, get secondary muzzle - if (_isSecondaryMagazine) then { - _weaponConfig = _weaponConfig >> _muzzles select 1; + // From ACE + private _gesture = getText (_weaponConfig >> "reloadAction"); + private _duration = 0; + + // If an item doesn't have a reload animation, add it instantly + if (_gesture != "") then { + if (_weapon isKindOf ["Launcher", configFile >> "CfgWeapons"]) then { + _duration = getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> _gesture >> "speed"); + }; + + if (_duration == 0) then { + _duration = getNumber (configFile >> "CfgGesturesMale" >> "States" >> _gesture >> "speed"); }; - // From ACE - private _gesture = getText (_weaponConfig >> "reloadAction"); - private _duration = 0; - - // If an item doesn't have a reload animation, add it instantly - if (_gesture != "") then { - if (_weapon isKindOf ["Launcher", configFile >> "CfgWeapons"]) then { - _duration = getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> _gesture >> "speed"); - }; - - if (_duration == 0) then { - _duration = getNumber (configFile >> "CfgGesturesMale" >> "States" >> _gesture >> "speed"); - }; - - _duration = if (_duration != 0) then { - if (_duration < 0) then { - abs _duration - } else { - 1 / _duration - } + _duration = if (_duration != 0) then { + if (_duration < 0) then { + abs _duration } else { - 6 - }; + 1 / _duration + } + } else { + 6 + }; + + _unit playActionNow _gesture; + + // Play sound + private _sound = getArray (configFile >> "CfgWeapons" >> _weapon >> "reloadMagazineSound"); + + if (_sound isEqualTo []) exitWith {}; - _unit playActionNow _gesture; + // Get position where to play the sound (position of the weapon) + private _position = _unit modelToWorldVisualWorld (_unit selectionPosition "RightHand"); + + _sound params ["_filename", ["_volume", 1], ["_soundPitch", 1], ["_distance", 0]]; + + if (_filename == "") exitWith {}; + + // Add file extension .wss as default + if !(toLowerANSI (_filename select [count _filename - 4]) in [".wav", ".ogg", ".wss"]) then { + _filename = format ["%1.wss", _filename]; }; - [{ - params ["_unit", "_magazine", "_ammo", "_weapon"]; + playSound3D [_filename, objNull, insideBuilding _unit >= 0.5, _position, _volume, _soundPitch, _distance]; + }; - _unit addWeaponItem [_weapon, [_magazine, _ammo]]; - }, [_unit, _magazine, _ammo, _weapon], _duration] call CBA_fnc_waitAndExecute; - }, [_unit, _magazine, _ammo, _container, _weapon, _muzzles, _index == 1], 1] call CBA_fnc_waitAndExecute; + [{ + params ["_unit", "_magazine", "_ammo", "_weapon"]; - true breakOut "main" - }; + _unit addWeaponItem [_weapon, [_magazine, _ammo]]; + }, [_unit, _magazine, _ammo, _weapon], _duration] call CBA_fnc_waitAndExecute; + }, [_unit, _magazine, _ammo, _container, _weapon, _muzzles, _muzzleIndex, _forEachIndex], 1] call CBA_fnc_waitAndExecute; + + true breakOut "main" // return } forEach [_loadout select 0, _loadout select 1, _loadout select 2, _loadout select 8]; // Primary, secondary, handgun weapons, binoculars // Add to inventory if possible if (_unit canAdd _magazine) exitWith { _unit action ["TakeMagazine", _container, _magazine]; - true + true // return }; -false +false // return diff --git a/addons/inventory/functions/fnc_playerPickup.sqf b/addons/inventory/functions/fnc_playerPickup.sqf index b7bdbe7..6c9f3d0 100644 --- a/addons/inventory/functions/fnc_playerPickup.sqf +++ b/addons/inventory/functions/fnc_playerPickup.sqf @@ -27,19 +27,21 @@ private _backpacks = backpackCargo _container; switch (true) do { // Item case (count _items == 1): { - [_unit, _container, _items select 0, _firstContainerClassname, _firstContainer] call FUNC(playerPickupItem) + [_unit, _container, _items select 0, _firstContainerClassname, _firstContainer] call FUNC(playerPickupItem) // return }; // Magazine case (count _magazines == 1): { - [_unit, _container, _magazines select 0] call FUNC(playerPickupMagazine) + [_unit, _container, _magazines select 0] call FUNC(playerPickupMagazine) // return }; // Backpack case (count _backpacks == 1): { _unit action ["PutBag"]; _unit action ["AddBag", _container, _backpacks select 0]; - true + true // return }; // If not one item - default {false}; + default { + false // return + }; }; diff --git a/addons/inventory/script_component.hpp b/addons/inventory/script_component.hpp index 6d08228..528564c 100644 --- a/addons/inventory/script_component.hpp +++ b/addons/inventory/script_component.hpp @@ -4,7 +4,7 @@ // #define DEBUG_MODE_FULL // #define DISABLE_COMPILE_CACHE -// #define DEBUG_SYNCHRONOUS +#define DEBUG_SYNCHRONOUS // #define ENABLE_PERFORMANCE_COUNTERS #ifdef DEBUG_ENABLED_AIMEE_INVENTORY diff --git a/addons/main/addon.toml b/addons/main/addon.toml index 3a886f6..8bb019b 100644 --- a/addons/main/addon.toml +++ b/addons/main/addon.toml @@ -3,6 +3,3 @@ enabled = true [binarize] enabled = true - -[asc] -enabled = true diff --git a/addons/main/functions/fnc_ignoreKeybind.sqf b/addons/main/functions/fnc_ignoreKeybind.sqf index 1ef980e..000862c 100644 --- a/addons/main/functions/fnc_ignoreKeybind.sqf +++ b/addons/main/functions/fnc_ignoreKeybind.sqf @@ -15,24 +15,26 @@ * Public: No */ +params ["_type"]; + !GVAR(settingHide) || { // Show Engine off/on interaction if ACE Keybinds for turning engine off and on are unbound - if (_this == "engineControlACE") then { + if (_type == "engineControlACE") then { private _engineOff = ["ACE3 Vehicles", "ace_weaponselect_EngineOff"] call CBA_fnc_getKeybind; private _engineOn = ["ACE3 Vehicles", "ace_weaponselect_EngineOn"] call CBA_fnc_getKeybind; // If both keybinds don't exist, show if (isNil "_engineOff" && isNil "_engineOn") exitWith { - true + true // return }; if (!isNil "_engineOff") then { - (_engineOff select 8) isEqualTo [] + (_engineOff select 8) isEqualTo [] // return } else { - (_engineOn select 8) isEqualTo [] - } + (_engineOn select 8) isEqualTo [] // return + }; } else { // Vanilla keybinds - (actionKeysNamesArray [_this, 1]) isEqualTo [] + (actionKeysNamesArray [_type, 1]) isEqualTo [] // return }; } diff --git a/addons/main/functions/fnc_operatingUAV.sqf b/addons/main/functions/fnc_operatingUAV.sqf index 14ee615..880766b 100644 --- a/addons/main/functions/fnc_operatingUAV.sqf +++ b/addons/main/functions/fnc_operatingUAV.sqf @@ -15,4 +15,6 @@ * Public: No */ -((UAVControl getConnectedUAV _this) select 1) != "" +params ["_unit"]; + +((UAVControl getConnectedUAV _unit) select 1) != "" // return diff --git a/addons/main/script_component.hpp b/addons/main/script_component.hpp index 41d66db..e08f73d 100644 --- a/addons/main/script_component.hpp +++ b/addons/main/script_component.hpp @@ -4,7 +4,7 @@ // #define DEBUG_MODE_FULL // #define DISABLE_COMPILE_CACHE -// #define DEBUG_SYNCHRONOUS +#define DEBUG_SYNCHRONOUS // #define ENABLE_PERFORMANCE_COUNTERS #ifdef DEBUG_ENABLED_AIMEE_MAIN diff --git a/addons/main/script_macros.hpp b/addons/main/script_macros.hpp index 1b5490a..41e25d9 100644 --- a/addons/main/script_macros.hpp +++ b/addons/main/script_macros.hpp @@ -34,19 +34,6 @@ #define DEFAULT_TEXT "Standby..." #define DISTANCE_INTERACTION_WEAPONHOLDER 4 -#define GEAR_ERROR 0 -#define GEAR_DOWN 1 -#define GEAR_EXTENDING 2 -#define GEAR_UP 3 -#define GEAR_RETRACTING 4 -#define GEAR_UNKNOWN 5 -#define FLAPS_MAX 2 - -#define EJECT_TYPE_CAR 0 -#define EJECT_TYPE_FORCE 1 -#define EJECT_TYPE_NONE -1 -#define EJECT_TYPE_JET -2 - #define TEXT_LEFT LQSTRING(STR_ACTION_CUSTOMINFO_LEFT_MODE) #define TEXT_CLOSE_LEFT LQSTRING(STR_ACTION_CUSTOMINFO_LEFT_CLOSE) #define TEXT_RIGHT LQSTRING(STR_ACTION_CUSTOMINFO_RIGHT_MODE) diff --git a/addons/main/script_version.hpp b/addons/main/script_version.hpp index cf37d81..cdd008a 100644 --- a/addons/main/script_version.hpp +++ b/addons/main/script_version.hpp @@ -1,4 +1,4 @@ #define MAJOR 1 #define MINOR 3 -#define PATCHLVL 9 +#define PATCHLVL 10 #define BUILD 0 diff --git a/addons/uav_terminal/addon.toml b/addons/uav_terminal/addon.toml index 3a886f6..8bb019b 100644 --- a/addons/uav_terminal/addon.toml +++ b/addons/uav_terminal/addon.toml @@ -3,6 +3,3 @@ enabled = true [binarize] enabled = true - -[asc] -enabled = true diff --git a/addons/uav_terminal/functions/fnc_UAVMenus.sqf b/addons/uav_terminal/functions/fnc_UAVMenus.sqf index 7af105a..945c2ac 100644 --- a/addons/uav_terminal/functions/fnc_UAVMenus.sqf +++ b/addons/uav_terminal/functions/fnc_UAVMenus.sqf @@ -7,7 +7,7 @@ * 0: Unit * * Return Value: - * Returns menus + * Interaction menu * * Example: * player call AIMEE_uav_terminal_fnc_UAVMenus @@ -15,10 +15,14 @@ * Public: No */ -private _uav = getConnectedUAV _this; +params ["_unit"]; + +private _uav = getConnectedUAV _unit; (UAVControl _uav) params ["_controller", "_role"]; -if (_controller != _this) exitWith {[]}; +if (_controller != _unit) exitWith { + [] // return +}; private _config = configOf _uav; private _menus = []; @@ -67,7 +71,7 @@ if (_role != "") then { } ] call ace_interact_menu_fnc_createAction, [], - _this + _unit ]; }; @@ -105,4 +109,4 @@ if (getText (_config >> "uavCameraDriverPos") != "" && {_role != "DRIVER"}) then ]; }; -_menus +_menus // return diff --git a/addons/uav_terminal/functions/fnc_UAVModify.sqf b/addons/uav_terminal/functions/fnc_UAVModify.sqf index 141670d..85c7b79 100644 --- a/addons/uav_terminal/functions/fnc_UAVModify.sqf +++ b/addons/uav_terminal/functions/fnc_UAVModify.sqf @@ -4,13 +4,13 @@ * Sets the icon and name of the interaction. * * Arguments: - * 0: Object + * 0: Object (not used) * 1: Unit - * 2: Params + * 2: Params (not used) * 3: Interaction menu * * Return Value: - * Modified interaction menu + * None * * Public: No */ diff --git a/addons/uav_terminal/functions/fnc_assignedTerminal.sqf b/addons/uav_terminal/functions/fnc_assignedTerminal.sqf index 88e592a..ba0bd1b 100644 --- a/addons/uav_terminal/functions/fnc_assignedTerminal.sqf +++ b/addons/uav_terminal/functions/fnc_assignedTerminal.sqf @@ -15,7 +15,9 @@ * Public: No */ +params ["_unit"]; + private _cfgWeapons = configFile >> "CfgWeapons"; -private _terminal = _this getSlotItemName 612; +private _terminal = _unit getSlotItemName 612; -_terminal isKindOf ["UavTerminal_base", _cfgWeapons] && {[_cfgWeapons >> _terminal >> "ItemInfo" >> "side", "NUMBER", -1] call CBA_fnc_getConfigEntry == (side _this) call BIS_fnc_sideID} +_terminal isKindOf ["UavTerminal_base", _cfgWeapons] && {[_cfgWeapons >> _terminal >> "ItemInfo" >> "side", "NUMBER", -1] call CBA_fnc_getConfigEntry == (side _unit) call BIS_fnc_sideID} // return diff --git a/addons/uav_terminal/functions/fnc_infoPanelMenus.sqf b/addons/uav_terminal/functions/fnc_infoPanelMenus.sqf index b13ebbc..58ac447 100644 --- a/addons/uav_terminal/functions/fnc_infoPanelMenus.sqf +++ b/addons/uav_terminal/functions/fnc_infoPanelMenus.sqf @@ -7,7 +7,7 @@ * 0: Unit * * Return Value: - * Returns menus + * Interaction menu * * Example: * player call AIMEE_uav_terminal_fnc_infoPanelMenus @@ -15,6 +15,8 @@ * Public: No */ +params ["_unit"]; + ["left", "right"] apply { [ [ @@ -50,6 +52,6 @@ } ] call ace_interact_menu_fnc_createAction, [], - _this + _unit ]; -}; +} // return diff --git a/addons/uav_terminal/functions/fnc_terminalModify.sqf b/addons/uav_terminal/functions/fnc_terminalModify.sqf index a9d0e89..69e1c5b 100644 --- a/addons/uav_terminal/functions/fnc_terminalModify.sqf +++ b/addons/uav_terminal/functions/fnc_terminalModify.sqf @@ -4,13 +4,13 @@ * Sets the icon and name of the interaction. * * Arguments: - * 0: Object + * 0: Object (not used) * 1: Unit - * 2: Params + * 2: Params (not used) * 3: Interaction menu * * Return Value: - * Modified interaction menu + * None * * Public: No */ diff --git a/addons/uav_terminal/script_component.hpp b/addons/uav_terminal/script_component.hpp index d257a41..af386e1 100644 --- a/addons/uav_terminal/script_component.hpp +++ b/addons/uav_terminal/script_component.hpp @@ -4,7 +4,7 @@ // #define DEBUG_MODE_FULL // #define DISABLE_COMPILE_CACHE -// #define DEBUG_SYNCHRONOUS +#define DEBUG_SYNCHRONOUS // #define ENABLE_PERFORMANCE_COUNTERS #ifdef DEBUG_ENABLED_AIMEE_TERMINALS diff --git a/addons/vehicle_controls/CfgVehicles.hpp b/addons/vehicle_controls/CfgVehicles.hpp index 096e278..6e20f72 100644 --- a/addons/vehicle_controls/CfgVehicles.hpp +++ b/addons/vehicle_controls/CfgVehicles.hpp @@ -11,13 +11,13 @@ condition = QUOTE(GVAR(settingLightsAction) && {'headlights' call EFUNC(main,ignoreKeybind)} && {!isLightOn _target} && {[ARR_2(_player,_target)] call FUNC(isDriver)});\ displayName = CQSTRING(STR_ACTION_LIGHTS_ON);\ icon = ICON_LIGHTS_ON;\ - statement = QUOTE(_target setPilotLight true);\ + statement = QPACTION('LightOn',_target);\ };\ class GVAR(lightsOffAction) {\ condition = QUOTE(GVAR(settingLightsAction) && {'headlights' call EFUNC(main,ignoreKeybind)} && {isLightOn _target} && {[ARR_2(_player,_target)] call FUNC(isDriver)});\ displayName = CQSTRING(STR_ACTION_LIGHTS_OFF);\ icon = ICON_LIGHTS_OFF;\ - statement = QUOTE(_target setPilotLight false);\ + statement = QPACTION('LightOff',_target);\ } #define MANUAL_FIRE_ACTION \ @@ -39,13 +39,13 @@ condition = QUOTE(GVAR(settingEngineAction) && {'engineToggle' call EFUNC(main,ignoreKeybind) && {'engineControlACE' call EFUNC(main,ignoreKeybind)}} && {!isEngineOn _target} && {[ARR_2(_player,_target)] call FUNC(isDriver)});\ displayName = CQSTRING(STR_action_engineon);\ icon = ICON_ENGINE_ON;\ - statement = QUOTE(_target engineOn true);\ + statement = QPACTION('EngineOn',_target);\ };\ class GVAR(engineOffAction) {\ condition = QUOTE(GVAR(settingEngineAction) && {'engineToggle' call EFUNC(main,ignoreKeybind) && {'engineControlACE' call EFUNC(main,ignoreKeybind)}} && {isEngineOn _target} && {[ARR_2(_player,_target)] call FUNC(isDriver)});\ displayName = CQSTRING(STR_action_engineoff);\ icon = ICON_ENGINE_OFF;\ - statement = QUOTE(_target engineOn false);\ + statement = QPACTION('EngineOff',_target);\ } #define GEAR_ACTION \ @@ -62,24 +62,27 @@ condition = QUOTE(GVAR(settingCollisionAction) && {!isCollisionLightOn _target} && {[ARR_2(_player,_target)] call FUNC(isDriver)});\ displayName = CQSTRING(STR_ACTION_COLLISIONLIGHTS_ON);\ icon = ICON_COLLISION_LIGHTS_ON;\ - statement = QUOTE(_target setCollisionLight true);\ + statement = QPACTION('CollisionLightOn',_target);\ };\ class GVAR(collisionLightsOffAction) {\ condition = QUOTE(GVAR(settingCollisionAction) && {isCollisionLightOn _target} && {[ARR_2(_player,_target)] call FUNC(isDriver)});\ displayName = CQSTRING(STR_ACTION_COLLISIONLIGHTS_OFF);\ icon = ICON_COLLISION_LIGHTS_OFF;\ - statement = QUOTE(_target setCollisionLight false);\ + statement = QPACTION('CollisionLightOff',_target);\ } +// From Apollo in the Arma discord: +// class Reflectors {} do not have animationSources to switch them on and off. +// If they're in the root of the vehicle the game puts a userAction "lights on", or if they're in a turret it gives a "searchlight on" option. There are no "hide" animations in model.cfg for them. #define SEARCH_LIGHT_ACTION \ class GVAR(searchLightOnAction) {\ - condition = QUOTE(GVAR(settingSearchAction) && {(_target unitTurret _player) isEqualTo [0]} && {!isLightOn [ARR_2(_target,[0])]});\ + condition = QUOTE(GVAR(settingSearchAction) && {private _turret = _target unitTurret _player; !(_turret in [ARR_2([],[-1])]) && {!isLightOn [ARR_2(_target,_turret)]} && {count ([ARR_2(_target,_turret)] call CBA_fnc_getTurret >> 'Reflectors') != 0}});\ displayName = CQSTRING(STR_action_searchlights_on);\ icon = ICON_LIGHTS_ON;\ statement = QPACTION('SearchLightOn',_target);\ };\ class GVAR(searchLightOffAction) {\ - condition = QUOTE(GVAR(settingSearchAction) && {(_target unitTurret _player) isEqualTo [0]} && {isLightOn [ARR_2(_target,[0])]});\ + condition = QUOTE(GVAR(settingSearchAction) && {isLightOn [ARR_2(_target,_target unitTurret _player)]});\ displayName = CQSTRING(STR_action_searchlights_off);\ icon = ICON_LIGHTS_OFF;\ statement = QPACTION('SearchLightOff',_target);\ @@ -99,6 +102,30 @@ statement = QPACTION('AutoHoverCancel',_target);\ } +#define LOCK_CONTROL_ACTION \ + class GVAR(lockControlAction) {\ + condition = QUOTE(GVAR(settingTakeControlsAction) && {isCopilotEnabled _target} && {driver _target == _player} && {_target getVariable [ARR_2(QQGVAR(copilotControlsUnlocked),false)]});\ + displayName = CQSTRING(STR_action_lock_control);\ + statement = QPACTION('LockVehicleControl',_target);\ + };\ + class GVAR(unlockControlAction) {\ + condition = QUOTE(GVAR(settingTakeControlsAction) && {isCopilotEnabled _target} && {driver _target == _player} && {!(_target getVariable [ARR_2(QQGVAR(copilotControlsUnlocked),false)])});\ + displayName = CQSTRING(STR_action_unlock_control);\ + statement = QPACTION('UnlockVehicleControl',_target);\ + } + +#define TAKE_CONTROL_ACTION \ + class GVAR(takeControlAction) {\ + condition = QUOTE(GVAR(settingTakeControlsAction) && {isCopilotEnabled _target} && {!isPlayer driver _target || {_target getVariable [ARR_2(QQGVAR(copilotControlsUnlocked),false)]}} && {!([ARR_2(_player,_target)] call FUNC(isDriver))} && {getNumber ([ARR_2(_target,_target unitTurret _player)] call CBA_fnc_getTurret >> 'isCopilot') == 1});\ + displayName = CQSTRING(STR_action_take_control);\ + statement = QPACTION('TakeVehicleControl',_target);\ + };\ + class GVAR(releaseControlAction) {\ + condition = QUOTE(GVAR(settingTakeControlsAction) && {isCopilotEnabled _target} && {!isPlayer driver _target || {_target getVariable [ARR_2(QQGVAR(copilotControlsUnlocked),false)]}} && {[ARR_2(_player,_target)] call FUNC(isDriver)} && {getNumber ([ARR_2(_target,_target unitTurret _player)] call CBA_fnc_getTurret >> 'isCopilot') == 1});\ + displayName = CQSTRING(STR_action_suspend_control);\ + statement = QPACTION('SuspendVehicleControl',_target);\ + } + #define FLAPS_ACTION \ class GVAR(flapsAction) {\ condition = QUOTE(GVAR(settingFlapsAction) && {'FlapsDown' call EFUNC(main,ignoreKeybind)} && {getNumber (configOf _target >> 'flaps') != 0} && {[ARR_2(_player,_target)] call FUNC(isDriver)});\ @@ -112,9 +139,10 @@ class CfgVehicles { class Car: LandVehicle { class ACE_SelfActions { ENGINE_ACITON; - MANUAL_FIRE_ACTION; LIGHTS_ACTION; + SEARCH_LIGHT_ACTION; ARTY_COMP_ACTION; + MANUAL_FIRE_ACTION; }; }; @@ -134,36 +162,37 @@ class CfgVehicles { class Tank: LandVehicle { class ACE_SelfActions { ENGINE_ACITON; - MANUAL_FIRE_ACTION; LIGHTS_ACTION; + SEARCH_LIGHT_ACTION; ARTY_COMP_ACTION; + MANUAL_FIRE_ACTION; }; }; class Air; class Helicopter: Air { class ACE_SelfActions { + TAKE_CONTROL_ACTION; + LOCK_CONTROL_ACTION; ENGINE_ACITON; - MANUAL_FIRE_ACTION; - COLLISION_LIGHTS_ACTION; - GEAR_ACTION; HOVER_ACTION; - }; - }; - class Helicopter_Base_F: Helicopter {}; - class Heli_light_03_base_F: Helicopter_Base_F { - class ACE_SelfActions: ACE_SelfActions { + GEAR_ACTION; + LIGHTS_ACTION; + COLLISION_LIGHTS_ACTION; SEARCH_LIGHT_ACTION; + MANUAL_FIRE_ACTION; }; }; class Plane: Air { class ACE_SelfActions { ENGINE_ACITON; - MANUAL_FIRE_ACTION; - COLLISION_LIGHTS_ACTION; GEAR_ACTION; FLAPS_ACTION; + LIGHTS_ACTION; + COLLISION_LIGHTS_ACTION; + SEARCH_LIGHT_ACTION; + MANUAL_FIRE_ACTION; }; }; @@ -171,10 +200,11 @@ class CfgVehicles { class Ship_F: Ship { class ACE_SelfActions { ENGINE_ACITON; - MANUAL_FIRE_ACTION; LIGHTS_ACTION; COLLISION_LIGHTS_ACTION; + SEARCH_LIGHT_ACTION; ARTY_COMP_ACTION; + MANUAL_FIRE_ACTION; }; }; }; diff --git a/addons/vehicle_controls/XEH_PREP.hpp b/addons/vehicle_controls/XEH_PREP.hpp index ebe958d..860de09 100644 --- a/addons/vehicle_controls/XEH_PREP.hpp +++ b/addons/vehicle_controls/XEH_PREP.hpp @@ -4,7 +4,6 @@ PREP(flapsDown); PREP(flapsMenus); PREP(gearHandler); PREP(gearStatus); -PREP(initUserActions); PREP(isDriver); PREP(toggleGear); PREP(userActionMenus); diff --git a/addons/vehicle_controls/XEH_postInit.sqf b/addons/vehicle_controls/XEH_postInit.sqf index a3da639..e9edbf3 100644 --- a/addons/vehicle_controls/XEH_postInit.sqf +++ b/addons/vehicle_controls/XEH_postInit.sqf @@ -2,4 +2,49 @@ if (!hasInterface) exitWith {}; -call FUNC(initUserActions); +GVAR(commandingTurrets) = createHashMap; + +// User actions +[ + "AllVehicles", + 1, + ["ACE_SelfActions"], + [ + QGVAR(userActions), + format [LQSTRING(str_disp_xbox_hint_igui_more_actions), ""], + ICON_MORE, + {}, + { + GVAR(settingUserActions) && {!isNull (configOf (_this select 0) >> "UserActions")}; + }, + FUNC(userActionMenus) + ] call ace_interact_menu_fnc_createAction, + true +] call ace_interact_menu_fnc_addActionToClass; + +// Detect when a controls are shifted in the player's vehicle +["turret", { + params ["_unit", "_newTurret", "_oldTurret"]; + + private _vehicle = objectParent _unit; + + if (isNull _vehicle) then { + if (isNil QGVAR(controlsShiftedEH)) exitWith {}; + + removeMissionEventHandler ["ControlsShifted", GVAR(controlsShiftedEH)]; + + GVAR(controlsShiftedEH) = nil; + } else { + if !(_vehicle isKindOf "Helicopter") exitWith {}; + + _vehicle setVariable [QGVAR(copilotControlsUnlocked), !isPlayer driver _vehicle]; + + if (!isNil QGVAR(controlsShiftedEH)) exitWith {}; + + GVAR(controlsShiftedEH) = addMissionEventHandler ["ControlsShifted", { + params ["", "", "_vehicle", "", "_controlsUnlocked"]; + + _vehicle setVariable [QGVAR(copilotControlsUnlocked), _controlsUnlocked]; + }]; + }; +}, true] call CBA_fnc_addPlayerEventHandler; diff --git a/addons/vehicle_controls/addon.toml b/addons/vehicle_controls/addon.toml index 3a886f6..8bb019b 100644 --- a/addons/vehicle_controls/addon.toml +++ b/addons/vehicle_controls/addon.toml @@ -3,6 +3,3 @@ enabled = true [binarize] enabled = true - -[asc] -enabled = true diff --git a/addons/vehicle_controls/functions/fnc_canManual.sqf b/addons/vehicle_controls/functions/fnc_canManual.sqf index 272231e..ded7a8b 100644 --- a/addons/vehicle_controls/functions/fnc_canManual.sqf +++ b/addons/vehicle_controls/functions/fnc_canManual.sqf @@ -1,7 +1,7 @@ #include "..\script_component.hpp" /* * Author: upsilon, johnb43 - * Returns whether a gun can be manually fired by commander. + * Returns whether a gun can be manually fired by a unit. * * Arguments: * 0: Unit @@ -21,11 +21,42 @@ params ["_unit", "_vehicle"]; private _config = configOf _vehicle; if (getNumber (_config >> "enableManualFire") == 0 || {isPlayer gunner _vehicle}) exitWith { - false + false // return }; if (_vehicle isKindOf "Air" || {unitIsUAV _vehicle}) then { - call FUNC(isDriver) && {"true" configClasses (_config >> "Turrets") isNotEqualTo []} + call FUNC(isDriver) && {"true" configClasses (_config >> "Turrets") isNotEqualTo []} // return } else { - _unit == commander _vehicle + // primaryObserver in config is what the command "commander" returns, which isn't always the actual commander slot + // Only the "effectiveCommander" can use manual fire + _unit == effectiveCommander _vehicle && { + (GVAR(commandingTurrets) getOrDefaultCall [typeOf _vehicle, { + private _turretConfig = configNull; + private _commanding = 0; + private _maxCommanding = -1e10; + private _maxTurret = []; + + { + _turretConfig = _config; + + { + if (_x < 0) exitWith { + _turretConfig = configNull; + }; + + // config classes ignores inherited classes, just like the engine does with turrets + _turretConfig = ("true" configClasses (_turretConfig >> "turrets")) param [_x, configNull]; + } forEach _x; + + _commanding = getNumber (_turretConfig >> "commanding"); + + if (_commanding > _maxCommanding) then { + _maxCommanding = _commanding; + _maxTurret = _x; + }; + } forEach (allTurrets _vehicle); + + _maxTurret + }, true]) isEqualTo (_vehicle unitTurret _unit) // return + } }; diff --git a/addons/vehicle_controls/functions/fnc_flapsMenus.sqf b/addons/vehicle_controls/functions/fnc_flapsMenus.sqf index 038aa6e..c59dd7c 100644 --- a/addons/vehicle_controls/functions/fnc_flapsMenus.sqf +++ b/addons/vehicle_controls/functions/fnc_flapsMenus.sqf @@ -15,6 +15,8 @@ * Public: No */ +params ["_vehicle"]; + private _menus = []; private _icons = [ICON_FLAPS_0, ICON_FLAPS_1, ICON_FLAPS_2]; private _texts = ["Retracted", "Extended 1", "Extended 2"]; @@ -34,8 +36,8 @@ for "_i" from 0 to FLAPS_MAX do { _i ] call ace_interact_menu_fnc_createAction, [], - _this + _vehicle ]; }; -_menus +_menus // return diff --git a/addons/vehicle_controls/functions/fnc_gearHandler.sqf b/addons/vehicle_controls/functions/fnc_gearHandler.sqf index 71e87e2..e0f16fe 100644 --- a/addons/vehicle_controls/functions/fnc_gearHandler.sqf +++ b/addons/vehicle_controls/functions/fnc_gearHandler.sqf @@ -16,4 +16,6 @@ * Public: No */ -[_this select 0, [GEAR_UP, GEAR_DOWN] select (_this select 1)] call FUNC(gearStatus); +params ["_vehicle", "_gearDown"]; + +[_vehicle, [GEAR_UP, GEAR_DOWN] select _gearDown] call FUNC(gearStatus); diff --git a/addons/vehicle_controls/functions/fnc_gearModify.sqf b/addons/vehicle_controls/functions/fnc_gearModify.sqf index 9bb6276..1e5716c 100644 --- a/addons/vehicle_controls/functions/fnc_gearModify.sqf +++ b/addons/vehicle_controls/functions/fnc_gearModify.sqf @@ -5,18 +5,20 @@ * * Arguments: * 0: Vehicle - * 1: Player - * 2: Params + * 1: Player (not used) + * 2: Params (not used) * 3: Interaction menu * * Return Value: - * Modified interaction menu + * None * * Public: No */ -(_this select 3) set [1, - switch ((_this select 0) call FUNC(gearStatus)) do { +params ["_target", "", "", "_menu"]; + +_menu set [1, + switch (_target call FUNC(gearStatus)) do { case GEAR_ERROR: { LQSTRING(str_lib_info_retract_gear) + " " + toUpper LQSTRING(str_mis_state_error) }; diff --git a/addons/vehicle_controls/functions/fnc_gearStatus.sqf b/addons/vehicle_controls/functions/fnc_gearStatus.sqf index 6346d99..761736e 100644 --- a/addons/vehicle_controls/functions/fnc_gearStatus.sqf +++ b/addons/vehicle_controls/functions/fnc_gearStatus.sqf @@ -9,7 +9,7 @@ * 1: Set new value * * Return Value: - * None + * Gear status * * Public: No */ @@ -33,7 +33,7 @@ if (_old == GEAR_UNKNOWN) then { }; } forEach (animationNames _vehicle); - if (_phases isEqualTo []) exitWith {-1}; + if (_phases isEqualTo []) exitWith {}; _phases sort true; @@ -67,4 +67,4 @@ if (!isNil "_set") then { _vehicle setVariable [QGVAR(gearStatus), _set]; }; -_old; +_old // return diff --git a/addons/vehicle_controls/functions/fnc_initUserActions.sqf b/addons/vehicle_controls/functions/fnc_initUserActions.sqf deleted file mode 100644 index 339a89f..0000000 --- a/addons/vehicle_controls/functions/fnc_initUserActions.sqf +++ /dev/null @@ -1,30 +0,0 @@ -#include "..\script_component.hpp" -/* - * Author: upsilon, johnb43 - * Gets scroll wheel actions from vehicle configs and makes them into ACE interactions. - * - * Arguments: - * None - * - * Return Value: - * None - * - * Public: No - */ - -[ - "AllVehicles", - 1, - ["ACE_SelfActions"], - [ - QGVAR(userActions), - format [LQSTRING(str_disp_xbox_hint_igui_more_actions), ""], - ICON_MORE, - {}, - { - GVAR(settingUserActions) && {!isNull (configOf (_this select 0) >> "UserActions")}; - }, - FUNC(userActionMenus) - ] call ace_interact_menu_fnc_createAction, - true -] call ace_interact_menu_fnc_addActionToClass; diff --git a/addons/vehicle_controls/functions/fnc_isDriver.sqf b/addons/vehicle_controls/functions/fnc_isDriver.sqf index bc4975c..7e79bd7 100644 --- a/addons/vehicle_controls/functions/fnc_isDriver.sqf +++ b/addons/vehicle_controls/functions/fnc_isDriver.sqf @@ -8,10 +8,10 @@ * 1: Vehicle * * Return Value: - * is driver + * Is driver * * Example: - * [player, vehicle player] call AIMEE_vehicle_controls_fnc_isDriver; + * [player, vehicle player] call AIMEE_vehicle_controls_fnc_isDriver * * Public: No */ @@ -19,11 +19,11 @@ params ["_unit", "_vehicle"]; if (_unit == (currentPilot _vehicle)) exitWith { - true + true // return }; if (_vehicle == (getConnectedUAV _unit)) exitWith { - ((UAVControl _vehicle) select 1) == "DRIVER" + ((UAVControl _vehicle) select 1) == "DRIVER" // return }; -false +false // return diff --git a/addons/vehicle_controls/functions/fnc_toggleGear.sqf b/addons/vehicle_controls/functions/fnc_toggleGear.sqf index c946e86..655cfb8 100644 --- a/addons/vehicle_controls/functions/fnc_toggleGear.sqf +++ b/addons/vehicle_controls/functions/fnc_toggleGear.sqf @@ -11,7 +11,7 @@ * None * * Example: - * [player, vehicle player] call AIMEE_vehicle_controls_fnc_toggleGear; + * [player, vehicle player] call AIMEE_vehicle_controls_fnc_toggleGear * * Public: No */ diff --git a/addons/vehicle_controls/functions/fnc_userActionMenus.sqf b/addons/vehicle_controls/functions/fnc_userActionMenus.sqf index 64171d8..6d22e09 100644 --- a/addons/vehicle_controls/functions/fnc_userActionMenus.sqf +++ b/addons/vehicle_controls/functions/fnc_userActionMenus.sqf @@ -7,10 +7,10 @@ * 0: Vehicle * * Return Value: - * None + * Interaction menu * * Example: - * vehicle player call AIMEE_vehicle_controls_fnc_userActionMenus; + * vehicle player call AIMEE_vehicle_controls_fnc_userActionMenus * * Public: No */ @@ -19,9 +19,11 @@ params ["_target"]; private _actions = "true" configClasses (configOf _target >> "UserActions"); -if (_actions isEqualTo []) exitWith {[]}; +if (_actions isEqualTo []) exitWith { + [] // return +}; -// this is used instead of target in vanilla user actions +// This is used instead of target in vanilla user actions private _run = { params ["_target", "", "_args"]; @@ -46,12 +48,13 @@ private _condition = { private _menus = []; private _displayName = ""; +private _isFIR = (typeOf _target) select [0, 4] == "FIR_"; { _displayName = getText (_x >> "displayName"); // Eject for Firewill plane ejection - if (_displayName != "" && {getText (_x >> "shortcut") != "Eject" || {(typeOf _target) select [0, 4] == "FIR_"}}) then { + if (_displayName != "" && {_isFIR || {getText (_x >> "shortcut") != "Eject"}}) then { _menus pushBack [ [ format [QGVAR(userAction_%1_%2), configName _x, getNumber (_x >> "userActionID")], @@ -68,4 +71,4 @@ private _displayName = ""; }; } forEach _actions; -_menus +_menus // return diff --git a/addons/vehicle_controls/script_component.hpp b/addons/vehicle_controls/script_component.hpp index 7a8f101..c104ba1 100644 --- a/addons/vehicle_controls/script_component.hpp +++ b/addons/vehicle_controls/script_component.hpp @@ -4,7 +4,7 @@ // #define DEBUG_MODE_FULL // #define DISABLE_COMPILE_CACHE -// #define CBA_DEBUG_SYNCHRONOUS +#define DEBUG_SYNCHRONOUS // #define ENABLE_PERFORMANCE_COUNTERS #ifdef DEBUG_ENABLED_AIMEE_VEHICLE_CTRL @@ -15,4 +15,13 @@ #define DEBUG_SETTINGS DEBUG_ENABLED_AIMEE_VEHICLE_CTRL #endif +#define GEAR_ERROR 0 +#define GEAR_DOWN 1 +#define GEAR_EXTENDING 2 +#define GEAR_UP 3 +#define GEAR_RETRACTING 4 +#define GEAR_UNKNOWN 5 + +#define FLAPS_MAX 2 + #include "..\main\script_macros.hpp" diff --git a/addons/vehicle_seats/CfgVehicles.hpp b/addons/vehicle_seats/CfgVehicles.hpp index e832364..7c97698 100644 --- a/addons/vehicle_seats/CfgVehicles.hpp +++ b/addons/vehicle_seats/CfgVehicles.hpp @@ -1,6 +1,6 @@ #define GETIN_ACTION \ class GVAR(getInAction) {\ - condition = QUOTE(GVAR(settingGetInAction) && {alive _target} && {!(_player call EFUNC(main,operatingUAV))} && {locked _target < 2} && {!([ARR_2(side _player,side _target)] call BIS_fnc_sideIsEnemy)} && {((fullCrew [ARR_3(_target,'',true)]) findIf {[ARR_3(_player,_target,_x)] call FUNC(canSwitch)}) != -1});\ + condition = QUOTE(GVAR(settingGetInAction) && {alive _target} && {locked _target < 2} && {!(_player call EFUNC(main,operatingUAV))} && {!([ARR_2(side _player,side _target)] call BIS_fnc_sideIsEnemy)} && {((fullCrew [ARR_3(_target,'',true)]) findIf {[ARR_3(_player,_target,_x)] call FUNC(canSwitch)}) != -1});\ displayName = CQSTRING(STR_rscMenu.hppRscGroupRootMenu_Items_GetIn1);\ exceptions[] = {"isNotInside", "isNotSwimming"};\ icon = ICON_GET_IN;\ @@ -72,7 +72,7 @@ class CfgVehicles { class CAManBase: Man { class ACE_SelfActions { class GVAR(changeAction) { - condition = QUOTE(private _vehicle = objectParent _player; GVAR(settingChangeAction) && {!isNull _vehicle} && {!(_player call EFUNC(main,operatingUAV))} && {locked _vehicle < 2} && {isMultiplayer || {(effectiveCommander _vehicle) == _player}} && {!([ARR_3(_player,_vehicle,'turnIn')] call FUNC(canTurnInOrOut))}); + condition = QUOTE(private _vehicle = objectParent _player; GVAR(settingChangeAction) && {alive _vehicle} && {!(_player call EFUNC(main,operatingUAV))} && {locked _vehicle < 2} && {isMultiplayer || {(effectiveCommander _vehicle) == _player}} && {!([ARR_3(_player,_vehicle,TURN_IN)] call FUNC(canTurnInOrOut))}); displayName = CQSTRING(STR_3den_display3den_entitymenu_changeseat_text); exceptions[] = {"isNotInside"}; icon = ICON_CHANGE_SEAT; @@ -80,7 +80,7 @@ class CfgVehicles { }; class GVAR(turnOutAction) { - condition = QUOTE(private _vehicle = objectParent _player; GVAR(settingTurnOutAction) && {!isNull _vehicle} && {!(_player call EFUNC(main,operatingUAV))} && {'TurnOut' call EFUNC(main,ignoreKeybind)} && {[ARR_3(_player,_vehicle,'turnOut')] call FUNC(canTurnInOrOut)}); + condition = QUOTE(private _vehicle = objectParent _player; GVAR(settingTurnOutAction) && {alive _vehicle} && {!(_player call EFUNC(main,operatingUAV))} && {'TurnOut' call EFUNC(main,ignoreKeybind)} && {[ARR_3(_player,_vehicle,TURN_OUT)] call FUNC(canTurnInOrOut)}); displayName = CQSTRING(STR_action_turnout); exceptions[] = {"isNotInside"}; icon = ICON_ARROW_UP; @@ -88,7 +88,7 @@ class CfgVehicles { }; class GVAR(turnInAction) { - condition = QUOTE(private _vehicle = objectParent _player; GVAR(settingTurnOutAction) && {!isNull _vehicle} && {!(_player call EFUNC(main,operatingUAV))} && {'TurnIn' call EFUNC(main,ignoreKeybind)} && {[ARR_3(_player,_vehicle,'turnIn')] call FUNC(canTurnInOrOut)}); + condition = QUOTE(private _vehicle = objectParent _player; GVAR(settingTurnOutAction) && {alive _vehicle} && {!(_player call EFUNC(main,operatingUAV))} && {'TurnIn' call EFUNC(main,ignoreKeybind)} && {[ARR_3(_player,_vehicle,TURN_IN)] call FUNC(canTurnInOrOut)}); displayName = CQSTRING(STR_action_turnin); exceptions[] = {"isNotInside"}; icon = ICON_ARROW_DOWN; diff --git a/addons/vehicle_seats/addon.toml b/addons/vehicle_seats/addon.toml index 3a886f6..8bb019b 100644 --- a/addons/vehicle_seats/addon.toml +++ b/addons/vehicle_seats/addon.toml @@ -3,6 +3,3 @@ enabled = true [binarize] enabled = true - -[asc] -enabled = true diff --git a/addons/vehicle_seats/functions/fnc_canEject.sqf b/addons/vehicle_seats/functions/fnc_canEject.sqf index 2a6f66a..c208ac5 100644 --- a/addons/vehicle_seats/functions/fnc_canEject.sqf +++ b/addons/vehicle_seats/functions/fnc_canEject.sqf @@ -20,7 +20,9 @@ params ["_unit", "_vehicle"]; private _config = configOf _vehicle; -if (isClass (_config >> "EjectionSystem")) exitWith {EJECT_TYPE_JET}; +if (isClass (_config >> "EjectionSystem")) exitWith { + EJECT_TYPE_JET // return +}; private _type = [EJECT_TYPE_NONE, EJECT_TYPE_CAR] select ( switch (_unit call CBA_fnc_vehicleRole) do { @@ -44,4 +46,4 @@ if (GVAR(settingForceEject) && {_type == EJECT_TYPE_NONE} && {_vehicle isKindOf _type = EJECT_TYPE_FORCE; }; -_type +_type // return diff --git a/addons/vehicle_seats/functions/fnc_canSwitch.sqf b/addons/vehicle_seats/functions/fnc_canSwitch.sqf index 6f12e08..f433f8c 100644 --- a/addons/vehicle_seats/functions/fnc_canSwitch.sqf +++ b/addons/vehicle_seats/functions/fnc_canSwitch.sqf @@ -26,28 +26,24 @@ params ["_unit", "_vehicle", "_seat"]; _seat params ["_occupant", "_role", "_cargoIndex", "_turretPath"]; // Fails if current occupant can't be booted -if (alive _occupant && { - if (isPlayer _occupant || {isNull objectParent _unit}) then { - true - } else { - getText (configOf _occupant >> "simulation") == "UAVPilot" - }; -}) exitWith {false}; +if (alive _occupant && {isPlayer _occupant || {unitIsUAV _occupant} || {isNull objectParent _unit}}) exitWith { + false // return +}; // Various other restrictions switch (_role) do { case "driver": { - !(lockedDriver _vehicle) && {getNumber (configOf _vehicle >> "hasDriver") == 1} + !(lockedDriver _vehicle) && {getNumber (configOf _vehicle >> "hasDriver") == 1} // return }; case "gunner"; case "commander"; case "turret": { - !(_vehicle lockedTurret _turretPath) && {getNumber ([_vehicle, _turretPath] call CBA_fnc_getTurret >> "hasGunner") == 1} + !(_vehicle lockedTurret _turretPath) && {getNumber ([_vehicle, _turretPath] call CBA_fnc_getTurret >> "hasGunner") == 1} // return }; case "cargo": { - !(_vehicle lockedCargo _cargoIndex) + !(_vehicle lockedCargo _cargoIndex) // return }; default { - false + false // return }; }; diff --git a/addons/vehicle_seats/functions/fnc_canTurnInOrOut.sqf b/addons/vehicle_seats/functions/fnc_canTurnInOrOut.sqf index 5f45414..53bad55 100644 --- a/addons/vehicle_seats/functions/fnc_canTurnInOrOut.sqf +++ b/addons/vehicle_seats/functions/fnc_canTurnInOrOut.sqf @@ -6,31 +6,27 @@ * Arguments: * 0: Unit * 1: Vehicle - * 2: Type + * 2: Type * * Return Value: * Can turn in or out * * Example: - * [player, vehicle player, "turnIn"] call AIMEE_vehicle_seats_fnc_canTurnInOrOut + * [player, vehicle player, TURN_IN] call AIMEE_vehicle_seats_fnc_canTurnInOrOut * * Public: No */ params ["_unit", "_vehicle", "_type"]; -if (_type != "turnOut" && {_type != "turnIn"}) exitWith { - false -}; - private _condition = isTurnedOut _unit; -if (_type == "turnOut") then { +if (_type == TURN_OUT) then { _condition = !_condition; }; if (!_condition) exitWith { - false + false // return }; private _fullCrew = fullCrew _vehicle; @@ -41,4 +37,4 @@ if (_index != -1 && {(_fullCrew select _index) select 4}) then { _condition = getText ([_vehicle, _vehicle unitTurret _unit] call CBA_fnc_getTurret >> "personTurretAction") != ""; }; -_condition && {_unit call ace_common_fnc_hasHatch} +_condition && {_unit call ace_common_fnc_hasHatch} // return diff --git a/addons/vehicle_seats/functions/fnc_changeMenus.sqf b/addons/vehicle_seats/functions/fnc_changeMenus.sqf index 9b2ba8b..9b53b27 100644 --- a/addons/vehicle_seats/functions/fnc_changeMenus.sqf +++ b/addons/vehicle_seats/functions/fnc_changeMenus.sqf @@ -8,7 +8,7 @@ * 1: Unit * * Return Value: - * All interaction submenus for all seat changing for a given class of vehicle + * Interaction menu * * Example: * [vehicle player, player] call AIMEE_vehicle_seats_fnc_changeMenus @@ -29,11 +29,13 @@ private _menus = []; }) params ["_drivers", "_commanders", "_gunners", "_turrets", "_cargos"]; if (_drivers isNotEqualTo [] && {[_unit, _vehicle, _drivers select 0] call FUNC(canSwitch)}) then { + private _isAir = _vehicle isKindOf "Air"; + _menus pushBack [ [ QGVAR(driverAction), - [TEXT_DRIVER, TEXT_PILOT] select (_vehicle isKindOf "Air"), - [ICON_DRIVER, ICON_PILOT] select (_vehicle isKindOf "Air"), + [TEXT_DRIVER, TEXT_PILOT] select _isAir, + [ICON_DRIVER, ICON_PILOT] select _isAir, {_player action (_this select 2)}, {true}, nil, @@ -76,4 +78,4 @@ if (_gunners isNotEqualTo [] && {[_unit, _vehicle, _gunners select 0] call FUNC( }; } forEach _cargos; -_menus +_menus // return diff --git a/addons/vehicle_seats/functions/fnc_turretMenus.sqf b/addons/vehicle_seats/functions/fnc_turretMenus.sqf index 2e5b1df..946aa1d 100644 --- a/addons/vehicle_seats/functions/fnc_turretMenus.sqf +++ b/addons/vehicle_seats/functions/fnc_turretMenus.sqf @@ -7,10 +7,14 @@ * 0: Vehicle * 1: Prefix * 2: Seat + * 2.0: Occupant + * 2.1: Role + * 2.2: Cargo Index + * 2.3: Turret * 3: Icon * * Return Value: - * All interaction submenus for all seat changing for a given class of vehicle + * Interaction menu * * Example: * [vehicle player, "GetIn", [player, "driver", nil, [-1]], "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_commander_ca.paa"] call AIMEE_vehicle_seats_fnc_turretMenus @@ -43,4 +47,4 @@ if (_turretPath in (_vehicle call ace_common_fnc_getTurretsFFV)) then { ] call ace_interact_menu_fnc_createAction, [], _vehicle -] +] // return diff --git a/addons/vehicle_seats/script_component.hpp b/addons/vehicle_seats/script_component.hpp index 49fffed..71aa070 100644 --- a/addons/vehicle_seats/script_component.hpp +++ b/addons/vehicle_seats/script_component.hpp @@ -4,7 +4,7 @@ // #define DEBUG_MODE_FULL // #define DISABLE_COMPILE_CACHE -// #define CBA_DEBUG_SYNCHRONOUS +#define DEBUG_SYNCHRONOUS // #define ENABLE_PERFORMANCE_COUNTERS #ifdef DEBUG_ENABLED_AIMEE_VEHICLE_SEATS @@ -15,4 +15,12 @@ #define DEBUG_SETTINGS DEBUG_ENABLED_AIMEE_VEHICLE_SEATS #endif +#define EJECT_TYPE_CAR 0 +#define EJECT_TYPE_FORCE 1 +#define EJECT_TYPE_NONE -1 +#define EJECT_TYPE_JET -2 + +#define TURN_IN 0 +#define TURN_OUT 1 + #include "..\main\script_macros.hpp"