From e4c86a8af5738035d0985e6a8df08ea33cf93e07 Mon Sep 17 00:00:00 2001 From: commy2 Date: Sat, 14 May 2016 19:50:08 +0200 Subject: [PATCH 01/12] don't do 'playerInventoryChanged' just because ammo decreased after firing --- addons/common/XEH_postInit.sqf | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 2b5637a78f..0eac9a3e63 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -334,6 +334,7 @@ GVAR(OldPlayerVehicle) = vehicle objNull; GVAR(OldPlayerTurret) = [objNull] call FUNC(getTurretIndex); GVAR(OldPlayerWeapon) = currentWeapon objNull; GVAR(OldPlayerInventory) = []; +GVAR(OldPlayerInventoryNoAmmo) = []; GVAR(OldPlayerVisionMode) = currentVisionMode objNull; GVAR(OldCameraView) = ""; GVAR(OldVisibleMap) = false; @@ -385,7 +386,19 @@ GVAR(OldIsCamera) = false; if !(_data isEqualTo GVAR(OldPlayerInventory)) then { // Raise ACE event locally GVAR(OldPlayerInventory) = _data; - ["playerInventoryChanged", [ACE_player, _data]] call FUNC(localEvent); + + // we don't want to trigger this just because your ammo counter decreased. + _data = + GVAR(OldPlayerInventory); + (_data param [0, []]) set [4, primaryWeaponMagazine ACE_player]; + (_data param [0, []]) set [5, nil]; + (_data param [1, []]) set [4, secondaryWeaponMagazine ACE_player]; + (_data param [1, []]) set [5, nil]; + (_data param [2, []]) set [4, handgunMagazine ACE_player]; + (_data param [2, []]) set [5, nil]; + if !(_data isEqualTo GVAR(OldPlayerInventoryNoAmmo)) then { + GVAR(OldPlayerInventoryNoAmmo) = _data; + ["playerInventoryChanged", [ACE_player, GVAR(OldPlayerInventory)]] call FUNC(localEvent); + }; }; // "playerVisionModeChanged" event From 7628f9a4ab879a8f7e9b89fb6f585cd39417245f Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sat, 14 May 2016 13:08:58 -0500 Subject: [PATCH 02/12] Fix nils in array --- addons/common/XEH_postInit.sqf | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 0eac9a3e63..14e09e2c5b 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -389,12 +389,18 @@ GVAR(OldIsCamera) = false; // we don't want to trigger this just because your ammo counter decreased. _data = + GVAR(OldPlayerInventory); - (_data param [0, []]) set [4, primaryWeaponMagazine ACE_player]; - (_data param [0, []]) set [5, nil]; - (_data param [1, []]) set [4, secondaryWeaponMagazine ACE_player]; - (_data param [1, []]) set [5, nil]; - (_data param [2, []]) set [4, handgunMagazine ACE_player]; - (_data param [2, []]) set [5, nil]; + if (!((_data select 0) isEqualTo [])) then { + (_data param [0, []]) set [4, primaryWeaponMagazine ACE_player]; + (_data param [0, []]) set [5, []]; + }; + if (!((_data select 1) isEqualTo [])) then { + (_data param [1, []]) set [4, secondaryWeaponMagazine ACE_player]; + (_data param [1, []]) set [5, []]; + }; + if (!((_data select 2) isEqualTo [])) then { + (_data param [2, []]) set [4, handgunMagazine ACE_player]; + (_data param [2, []]) set [5, []]; + }; if !(_data isEqualTo GVAR(OldPlayerInventoryNoAmmo)) then { GVAR(OldPlayerInventoryNoAmmo) = _data; ["playerInventoryChanged", [ACE_player, GVAR(OldPlayerInventory)]] call FUNC(localEvent); From 07caf1b0bdf56aeebb5940b887ef2c91789d881e Mon Sep 17 00:00:00 2001 From: commy2 Date: Sat, 14 May 2016 20:33:33 +0200 Subject: [PATCH 03/12] fix for null player --- addons/common/XEH_postInit.sqf | 25 ++++++++++++------- .../medical/functions/fnc_reviveStateLoop.sqf | 2 +- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 14e09e2c5b..e75841cb8e 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -389,18 +389,25 @@ GVAR(OldIsCamera) = false; // we don't want to trigger this just because your ammo counter decreased. _data = + GVAR(OldPlayerInventory); - if (!((_data select 0) isEqualTo [])) then { - (_data param [0, []]) set [4, primaryWeaponMagazine ACE_player]; - (_data param [0, []]) set [5, []]; + + private _weaponInfo = _data param [0, []]; + if !(_weaponInfo isEqualTo []) then { + _weaponInfo set [4, primaryWeaponMagazine ACE_player]; + _weaponInfo deleteAt 5; }; - if (!((_data select 1) isEqualTo [])) then { - (_data param [1, []]) set [4, secondaryWeaponMagazine ACE_player]; - (_data param [1, []]) set [5, []]; + + _weaponInfo = _data param [1, []]; + if !(_weaponInfo isEqualTo []) then { + _weaponInfo set [4, secondaryWeaponMagazine ACE_player]; + _weaponInfo deleteAt 5; }; - if (!((_data select 2) isEqualTo [])) then { - (_data param [2, []]) set [4, handgunMagazine ACE_player]; - (_data param [2, []]) set [5, []]; + + _weaponInfo = _data param [2, []]; + if !(_weaponInfo isEqualTo []) then { + _weaponInfo set [4, handgunMagazine ACE_player]; + _weaponInfo deleteAt 5; }; + if !(_data isEqualTo GVAR(OldPlayerInventoryNoAmmo)) then { GVAR(OldPlayerInventoryNoAmmo) = _data; ["playerInventoryChanged", [ACE_player, GVAR(OldPlayerInventory)]] call FUNC(localEvent); diff --git a/addons/medical/functions/fnc_reviveStateLoop.sqf b/addons/medical/functions/fnc_reviveStateLoop.sqf index 3e55f7b7ce..77a48c9340 100644 --- a/addons/medical/functions/fnc_reviveStateLoop.sqf +++ b/addons/medical/functions/fnc_reviveStateLoop.sqf @@ -13,7 +13,7 @@ #include "script_component.hpp" -params ["_unit"] +params ["_unit"]; // If locality changed finish the local loop // @todo: reinitiate the loop elsewhere From 32055401d3be3b0d38bb173d58d773559c5b437a Mon Sep 17 00:00:00 2001 From: Glowbal Date: Mon, 16 May 2016 00:09:53 +0200 Subject: [PATCH 04/12] Add backwards compatability for InventoryChanged The output of `getUnitLoadout` is different as `getAllGear`. Using a different format in the event would mean that any eventhandler depending on the inventory output would now be broken. --- addons/common/XEH_postInit.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 2b5637a78f..82cf0da2ea 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -385,7 +385,7 @@ GVAR(OldIsCamera) = false; if !(_data isEqualTo GVAR(OldPlayerInventory)) then { // Raise ACE event locally GVAR(OldPlayerInventory) = _data; - ["playerInventoryChanged", [ACE_player, _data]] call FUNC(localEvent); + ["playerInventoryChanged", [ACE_player, [ACE_player, false] call FUNC(getAllGear) ]] call FUNC(localEvent); }; // "playerVisionModeChanged" event From cac7b9c0c36e7ad18c2a8e52e5e93f4a6d92dd19 Mon Sep 17 00:00:00 2001 From: commy2 Date: Mon, 16 May 2016 15:15:51 +0200 Subject: [PATCH 05/12] optional param to skip deprecated warning --- addons/common/functions/fnc_getAllGear.sqf | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/common/functions/fnc_getAllGear.sqf b/addons/common/functions/fnc_getAllGear.sqf index 716793f7bd..cebcc489f1 100644 --- a/addons/common/functions/fnc_getAllGear.sqf +++ b/addons/common/functions/fnc_getAllGear.sqf @@ -33,9 +33,11 @@ */ #include "script_component.hpp" -ACE_DEPRECATED("ace_common_fnc_getAllGear","3.7.0","getUnitLoadout"); +params ["_unit", ["_showDeprecated", true]]; -params ["_unit"]; +if (_showDeprecated) then { + ACE_DEPRECATED("ace_common_fnc_getAllGear","3.7.0","getUnitLoadout"); +}; if (isNull _unit) exitWith {[ "", From 473149b8ca2da3a7cea3029316b44f413a04bf04 Mon Sep 17 00:00:00 2001 From: commy2 Date: Mon, 16 May 2016 15:22:37 +0200 Subject: [PATCH 06/12] revert changes from other PR to make it compatible --- addons/common/functions/fnc_assignedItemFix.sqf | 4 ++-- addons/goggles/XEH_postInit.sqf | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/common/functions/fnc_assignedItemFix.sqf b/addons/common/functions/fnc_assignedItemFix.sqf index 3f454f83ff..18dd6b4e0c 100644 --- a/addons/common/functions/fnc_assignedItemFix.sqf +++ b/addons/common/functions/fnc_assignedItemFix.sqf @@ -29,9 +29,9 @@ GVAR(AssignedItemsShownItems) = [ ]; ["playerInventoryChanged", { - params ["_unit", "_assignedItems"]; + params ["_unit"]; - _assignedItems = _assignedItems param [9, ["","","","","",""]]; // ["ItemMap","ItemGPS","ItemRadio","ItemCompass","ItemWatch","NVGoggles"] + private _assignedItems = getUnitLoadout _unit param [9, ["","","","","",""]]; // ["ItemMap","ItemGPS","ItemRadio","ItemCompass","ItemWatch","NVGoggles"] GVAR(AssignedItemsShownItems) = [ !((_assignedItems select 0) isEqualTo "") && {getText (configFile >> "CfgWeapons" >> _assignedItems select 0 >> "ACE_hideItemType") != "map"}, diff --git a/addons/goggles/XEH_postInit.sqf b/addons/goggles/XEH_postInit.sqf index 3a038ed923..37edd7184b 100644 --- a/addons/goggles/XEH_postInit.sqf +++ b/addons/goggles/XEH_postInit.sqf @@ -45,10 +45,12 @@ GVAR(surfaceCacheIsDust) = false; GVAR(OldGlasses) = ""; ["playerInventoryChanged", { - private _currentGlasses = (_this select 1) param [7, ""]; + params ["_unit"]; + + private _currentGlasses = goggles _unit; if (GVAR(OldGlasses) != _currentGlasses) then { - ["GlassesChanged", [ACE_player, _currentGlasses]] call EFUNC(common,localEvent); + ["GlassesChanged", [_unit, _currentGlasses]] call EFUNC(common,localEvent); GVAR(OldGlasses) = _currentGlasses; }; }] call EFUNC(common,addEventHandler); From 25876d82caeef935058b0335e4fc701ef989ad58 Mon Sep 17 00:00:00 2001 From: commy2 Date: Wed, 18 May 2016 12:21:53 +0200 Subject: [PATCH 07/12] manual merge --- addons/common/XEH_postInit.sqf | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 8922da7c6f..88012a7884 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -386,7 +386,6 @@ GVAR(OldIsCamera) = false; if !(_data isEqualTo GVAR(OldPlayerInventory)) then { // Raise ACE event locally GVAR(OldPlayerInventory) = _data; -<<<<<<< HEAD // we don't want to trigger this just because your ammo counter decreased. _data = + GVAR(OldPlayerInventory); From 709916c0f3dfec70c6b4131b2f01972be612b1f0 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Thu, 19 May 2016 19:53:23 -0500 Subject: [PATCH 08/12] Fix UBC errors for RHS 4.1 (#3800) --- optionals/compat_rhs_afrf3/CfgAmmo.hpp | 2 +- optionals/compat_rhs_afrf3/CfgVehicles.hpp | 4 ++-- optionals/compat_rhs_usf3/CfgAmmo.hpp | 3 ++- optionals/compat_rhs_usf3/CfgWeapons.hpp | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/optionals/compat_rhs_afrf3/CfgAmmo.hpp b/optionals/compat_rhs_afrf3/CfgAmmo.hpp index 3a00fdea68..0ab559f96c 100644 --- a/optionals/compat_rhs_afrf3/CfgAmmo.hpp +++ b/optionals/compat_rhs_afrf3/CfgAmmo.hpp @@ -39,7 +39,7 @@ class CfgAmmo { ACE_muzzleVelocities[]={700, 800, 820, 833}; ACE_barrelLengths[]={406.4, 508.0, 609.6, 660.4}; }; - class rhs_B_762x54_Ball_Tracer_Green: B_762x51_Ball { + class rhs_B_762x54_Ball_Tracer_Green: rhs_B_762x54_Ball { ACE_caliber=7.925; ACE_bulletLength=28.956; ACE_bulletMass=9.6552; diff --git a/optionals/compat_rhs_afrf3/CfgVehicles.hpp b/optionals/compat_rhs_afrf3/CfgVehicles.hpp index 87d8673cd8..34effc0a58 100644 --- a/optionals/compat_rhs_afrf3/CfgVehicles.hpp +++ b/optionals/compat_rhs_afrf3/CfgVehicles.hpp @@ -243,8 +243,8 @@ class CfgVehicles { EGVAR(fastroping,onPrepare) = QFUNC(onPrepare); class UserActions { - class openDoor; - class closeDoor_L: openDoor { + class openDoor_L; + class closeDoor_L: openDoor_L { condition = QUOTE((this doorPhase 'LeftDoor' > 0.5) && {alive this} && {!(this getVariable [ARR_2(QUOTE(QEGVAR(fastroping,doorsLocked)),false)])}); }; }; diff --git a/optionals/compat_rhs_usf3/CfgAmmo.hpp b/optionals/compat_rhs_usf3/CfgAmmo.hpp index b830d5e564..930976bf33 100644 --- a/optionals/compat_rhs_usf3/CfgAmmo.hpp +++ b/optionals/compat_rhs_usf3/CfgAmmo.hpp @@ -2,7 +2,8 @@ class CfgAmmo { class BulletBase; - class rhsusf_B_300winmag: BulletBase { + class B_762x54_Ball; + class rhsusf_B_300winmag: B_762x54_Ball { ACE_caliber=7.823; ACE_bulletLength=37.821; ACE_bulletMass=14.256; diff --git a/optionals/compat_rhs_usf3/CfgWeapons.hpp b/optionals/compat_rhs_usf3/CfgWeapons.hpp index c49b9bc5e4..8ef39bd666 100644 --- a/optionals/compat_rhs_usf3/CfgWeapons.hpp +++ b/optionals/compat_rhs_usf3/CfgWeapons.hpp @@ -111,8 +111,8 @@ class CfgWeapons }; }; }; - class rhs_weap_m4a1; - class rhs_weap_mk18: rhs_weap_m4a1 { + class rhs_weap_m4a1_blockII; + class rhs_weap_mk18: rhs_weap_m4a1_blockII { ACE_barrelTwist = 177.8; ACE_barrelLength = 261.62; ACE_Overheating_dispersion = 1; From 508b71e7bab96342ba2d1f2be7484959450cdc49 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Thu, 19 May 2016 21:39:15 -0500 Subject: [PATCH 09/12] Scopes - Allow Scope Adjust from FFV --- addons/fcs/functions/fnc_adjustRange.sqf | 1 + .../fcs/functions/fnc_calculateSolution.sqf | 1 + addons/fcs/functions/fnc_canUseFCS.sqf | 11 ++++++- addons/fcs/functions/fnc_keyUp.sqf | 1 + addons/scopes/XEH_PREP.hpp | 1 + addons/scopes/XEH_postInit.sqf | 32 ++++++++++++++----- addons/scopes/XEH_preInit.sqf | 2 -- .../scopes/functions/fnc_canAdjustScope.sqf | 26 +++++++++++++++ addons/scopes/functions/fnc_firedEH.sqf | 1 + 9 files changed, 65 insertions(+), 11 deletions(-) create mode 100644 addons/scopes/functions/fnc_canAdjustScope.sqf diff --git a/addons/fcs/functions/fnc_adjustRange.sqf b/addons/fcs/functions/fnc_adjustRange.sqf index f6f543d35a..bed9389716 100644 --- a/addons/fcs/functions/fnc_adjustRange.sqf +++ b/addons/fcs/functions/fnc_adjustRange.sqf @@ -22,6 +22,7 @@ private _min = getNumber (_turretConfig >> QGVAR(MinDistance)); private _max = getNumber (_turretConfig >> QGVAR(MaxDistance)); private _distance = _vehicle getVariable [format ["%1_%2", QGVAR(Distance), _turret], _min]; +TRACE_4("",_distance,_delta,_min,_max); _distance = _distance + _delta; _distance = _distance min _max; diff --git a/addons/fcs/functions/fnc_calculateSolution.sqf b/addons/fcs/functions/fnc_calculateSolution.sqf index 9908832824..6d489de006 100644 --- a/addons/fcs/functions/fnc_calculateSolution.sqf +++ b/addons/fcs/functions/fnc_calculateSolution.sqf @@ -15,6 +15,7 @@ */ #include "script_component.hpp" params ["_vehicle","_turret","_distance","_angleTarget"]; +TRACE_4("params",_vehicle,_turret,_distance,_angleTarget); private _FCSMagazines = []; private _FCSElevation = []; diff --git a/addons/fcs/functions/fnc_canUseFCS.sqf b/addons/fcs/functions/fnc_canUseFCS.sqf index 91b49554c2..1dcd1ca49e 100644 --- a/addons/fcs/functions/fnc_canUseFCS.sqf +++ b/addons/fcs/functions/fnc_canUseFCS.sqf @@ -8,9 +8,18 @@ * Return Value: * Boolean * + * Example: + * [] call ace_fcs_fnc_canUseFCS + * * Public: No */ #include "script_component.hpp" getNumber ([configFile >> "CfgVehicles" >> typeOf vehicle ACE_player, [ACE_player] call EFUNC(common,getTurretIndex)] call EFUNC(common,getTurretConfigPath) >> QGVAR(Enabled)) == 1 -&& {cameraView == "GUNNER"} // return +&& {cameraView == "GUNNER"} +&& { + private _animationState = animationState ACE_player; + private _moves = configFile >> getText (configFile >> "CfgVehicles" >> (typeof ACE_player) >> "moves"); + + (getNumber (_moves >> "States" >> _animationState >> "canPullTrigger") == 0) +} diff --git a/addons/fcs/functions/fnc_keyUp.sqf b/addons/fcs/functions/fnc_keyUp.sqf index 919ac3a58e..4fbd247d16 100644 --- a/addons/fcs/functions/fnc_keyUp.sqf +++ b/addons/fcs/functions/fnc_keyUp.sqf @@ -14,6 +14,7 @@ #include "script_component.hpp" params ["_vehicle", "_turret", "_distance", ["_showHint", false], ["_playSound", true]]; +TRACE_5("params",_vehicle,_turret,_distance,_showHint,_playSound); private _turretConfig = [configFile >> "CfgVehicles" >> typeOf _vehicle, _turret] call EFUNC(common,getTurretConfigPath); diff --git a/addons/scopes/XEH_PREP.hpp b/addons/scopes/XEH_PREP.hpp index 908d8064f0..05f58a5922 100644 --- a/addons/scopes/XEH_PREP.hpp +++ b/addons/scopes/XEH_PREP.hpp @@ -2,6 +2,7 @@ PREP(adjustScope); PREP(adjustZero); PREP(applyScopeAdjustment); +PREP(canAdjustScope); PREP(canAdjustZero); PREP(firedEH); PREP(getOptics); diff --git a/addons/scopes/XEH_postInit.sqf b/addons/scopes/XEH_postInit.sqf index 625f963f33..cc1d9e9c5c 100644 --- a/addons/scopes/XEH_postInit.sqf +++ b/addons/scopes/XEH_postInit.sqf @@ -33,8 +33,10 @@ if (!hasInterface) exitWith {}; ["ACE3 Scope Adjustment", QGVAR(AdjustUpMinor), localize LSTRING(AdjustUpMinor), { // Conditions: canInteract - if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; + if !([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific + if (!([ACE_player] call FUNC(canAdjustScope))) exitWith {false}; + [ACE_player] call FUNC(inventoryCheck); // Statement @@ -46,8 +48,10 @@ if (!hasInterface) exitWith {}; ["ACE3 Scope Adjustment", QGVAR(AdjustDownMinor), localize LSTRING(AdjustDownMinor), { // Conditions: canInteract - if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; + if !([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific + if (!([ACE_player] call FUNC(canAdjustScope))) exitWith {false}; + [ACE_player] call FUNC(inventoryCheck); // Statement @@ -59,8 +63,10 @@ if (!hasInterface) exitWith {}; ["ACE3 Scope Adjustment", QGVAR(AdjustLeftMinor), localize LSTRING(AdjustLeftMinor), { // Conditions: canInteract - if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; + if !([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific + if (!([ACE_player] call FUNC(canAdjustScope))) exitWith {false}; + [ACE_player] call FUNC(inventoryCheck); // Statement @@ -72,8 +78,10 @@ if (!hasInterface) exitWith {}; ["ACE3 Scope Adjustment", QGVAR(AdjustRightMinor), localize LSTRING(AdjustRightMinor), { // Conditions: canInteract - if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; + if !([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific + if (!([ACE_player] call FUNC(canAdjustScope))) exitWith {false}; + [ACE_player] call FUNC(inventoryCheck); // Statement @@ -85,8 +93,10 @@ if (!hasInterface) exitWith {}; ["ACE3 Scope Adjustment", QGVAR(AdjustUpMajor), localize LSTRING(AdjustUpMajor), { // Conditions: canInteract - if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; + if !([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific + if (!([ACE_player] call FUNC(canAdjustScope))) exitWith {false}; + [ACE_player] call FUNC(inventoryCheck); // Statement @@ -98,8 +108,10 @@ if (!hasInterface) exitWith {}; ["ACE3 Scope Adjustment", QGVAR(AdjustDownMajor), localize LSTRING(AdjustDownMajor), { // Conditions: canInteract - if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; + if !([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific + if (!([ACE_player] call FUNC(canAdjustScope))) exitWith {false}; + [ACE_player] call FUNC(inventoryCheck); // Statement @@ -111,8 +123,10 @@ if (!hasInterface) exitWith {}; ["ACE3 Scope Adjustment", QGVAR(AdjustLeftMajor), localize LSTRING(AdjustLeftMajor), { // Conditions: canInteract - if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; + if !([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific + if (!([ACE_player] call FUNC(canAdjustScope))) exitWith {false}; + [ACE_player] call FUNC(inventoryCheck); // Statement @@ -124,8 +138,10 @@ if (!hasInterface) exitWith {}; ["ACE3 Scope Adjustment", QGVAR(AdjustRightMajor), localize LSTRING(AdjustRightMajor), { // Conditions: canInteract - if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; + if !([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific + if (!([ACE_player] call FUNC(canAdjustScope))) exitWith {false}; + [ACE_player] call FUNC(inventoryCheck); // Statement diff --git a/addons/scopes/XEH_preInit.sqf b/addons/scopes/XEH_preInit.sqf index e33c54337d..a7feade1c3 100644 --- a/addons/scopes/XEH_preInit.sqf +++ b/addons/scopes/XEH_preInit.sqf @@ -4,6 +4,4 @@ ADDON = false; #include "XEH_PREP.hpp" -GVAR(fadeScript) = scriptNull; - ADDON = true; diff --git a/addons/scopes/functions/fnc_canAdjustScope.sqf b/addons/scopes/functions/fnc_canAdjustScope.sqf new file mode 100644 index 0000000000..b5cc729cbb --- /dev/null +++ b/addons/scopes/functions/fnc_canAdjustScope.sqf @@ -0,0 +1,26 @@ +/* + * Author: PabstMirror + * Tests if player would be in a position to adjust scope + * Mainly for determining edge cases with turned-out / FFV. + * + * Argument: + * 0: Unit + * + * Return value: + * + * + * Example: + * [player] call ace_scopes_fnc_canAdjustScope + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit"]; + +if ((vehicle _unit) == _unit) exitWith {true}; + +private _animationState = animationState _unit; +private _moves = configFile >> getText (configFile >> "CfgVehicles" >> (typeof _unit) >> "moves"); + +(getNumber (_moves >> "States" >> _animationState >> "canPullTrigger") == 1) diff --git a/addons/scopes/functions/fnc_firedEH.sqf b/addons/scopes/functions/fnc_firedEH.sqf index d28c0dee7e..07eadb5620 100644 --- a/addons/scopes/functions/fnc_firedEH.sqf +++ b/addons/scopes/functions/fnc_firedEH.sqf @@ -24,6 +24,7 @@ _weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex); if (_weaponIndex < 0) exitWith {}; _zeroing = _adjustment select _weaponIndex; +TRACE_1("Adjusting With",_zeroing); if (_zeroing isEqualTo [0, 0, 0]) exitWith {}; From 0d5385ffaf99e05e1f8b1a973174b39541648fe2 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Thu, 19 May 2016 21:50:51 -0500 Subject: [PATCH 10/12] Update FCS hud when manually setting range. --- addons/fcs/functions/fnc_keyUp.sqf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/fcs/functions/fnc_keyUp.sqf b/addons/fcs/functions/fnc_keyUp.sqf index 4fbd247d16..113d369a3c 100644 --- a/addons/fcs/functions/fnc_keyUp.sqf +++ b/addons/fcs/functions/fnc_keyUp.sqf @@ -24,6 +24,8 @@ if (isNil "_distance") then { getNumber (_turretConfig >> QGVAR(MaxDistance)), getNumber (_turretConfig >> QGVAR(MinDistance)) ] call FUNC(getRange); +} else { + ((uiNamespace getVariable ["ACE_dlgRangefinder", displayNull]) displayCtrl 1713151) ctrlSetText ([_distance, 4, 0] call CBA_fnc_formatNumber); }; // MOVING TARGETS From d464a23d21ae7d45834fc3aa5f06b1e2828eb1a9 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Fri, 20 May 2016 01:10:12 -0500 Subject: [PATCH 11/12] Use the lovely CBA_fnc_canUseWeapon function --- addons/fcs/functions/fnc_canUseFCS.sqf | 7 +---- addons/scopes/XEH_PREP.hpp | 1 - addons/scopes/XEH_postInit.sqf | 16 ++++++------ .../scopes/functions/fnc_canAdjustScope.sqf | 26 ------------------- 4 files changed, 9 insertions(+), 41 deletions(-) delete mode 100644 addons/scopes/functions/fnc_canAdjustScope.sqf diff --git a/addons/fcs/functions/fnc_canUseFCS.sqf b/addons/fcs/functions/fnc_canUseFCS.sqf index 1dcd1ca49e..3899584788 100644 --- a/addons/fcs/functions/fnc_canUseFCS.sqf +++ b/addons/fcs/functions/fnc_canUseFCS.sqf @@ -17,9 +17,4 @@ getNumber ([configFile >> "CfgVehicles" >> typeOf vehicle ACE_player, [ACE_player] call EFUNC(common,getTurretIndex)] call EFUNC(common,getTurretConfigPath) >> QGVAR(Enabled)) == 1 && {cameraView == "GUNNER"} -&& { - private _animationState = animationState ACE_player; - private _moves = configFile >> getText (configFile >> "CfgVehicles" >> (typeof ACE_player) >> "moves"); - - (getNumber (_moves >> "States" >> _animationState >> "canPullTrigger") == 0) -} +&& {!([ACE_player] call CBA_fnc_canUseWeapon)} //Not Turned Out diff --git a/addons/scopes/XEH_PREP.hpp b/addons/scopes/XEH_PREP.hpp index 05f58a5922..908d8064f0 100644 --- a/addons/scopes/XEH_PREP.hpp +++ b/addons/scopes/XEH_PREP.hpp @@ -2,7 +2,6 @@ PREP(adjustScope); PREP(adjustZero); PREP(applyScopeAdjustment); -PREP(canAdjustScope); PREP(canAdjustZero); PREP(firedEH); PREP(getOptics); diff --git a/addons/scopes/XEH_postInit.sqf b/addons/scopes/XEH_postInit.sqf index cc1d9e9c5c..1763bb7a32 100644 --- a/addons/scopes/XEH_postInit.sqf +++ b/addons/scopes/XEH_postInit.sqf @@ -35,7 +35,7 @@ if (!hasInterface) exitWith {}; // Conditions: canInteract if !([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific - if (!([ACE_player] call FUNC(canAdjustScope))) exitWith {false}; + if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false}; [ACE_player] call FUNC(inventoryCheck); @@ -50,7 +50,7 @@ if (!hasInterface) exitWith {}; // Conditions: canInteract if !([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific - if (!([ACE_player] call FUNC(canAdjustScope))) exitWith {false}; + if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false}; [ACE_player] call FUNC(inventoryCheck); @@ -65,7 +65,7 @@ if (!hasInterface) exitWith {}; // Conditions: canInteract if !([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific - if (!([ACE_player] call FUNC(canAdjustScope))) exitWith {false}; + if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false}; [ACE_player] call FUNC(inventoryCheck); @@ -80,7 +80,7 @@ if (!hasInterface) exitWith {}; // Conditions: canInteract if !([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific - if (!([ACE_player] call FUNC(canAdjustScope))) exitWith {false}; + if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false}; [ACE_player] call FUNC(inventoryCheck); @@ -95,7 +95,7 @@ if (!hasInterface) exitWith {}; // Conditions: canInteract if !([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific - if (!([ACE_player] call FUNC(canAdjustScope))) exitWith {false}; + if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false}; [ACE_player] call FUNC(inventoryCheck); @@ -110,7 +110,7 @@ if (!hasInterface) exitWith {}; // Conditions: canInteract if !([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific - if (!([ACE_player] call FUNC(canAdjustScope))) exitWith {false}; + if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false}; [ACE_player] call FUNC(inventoryCheck); @@ -125,7 +125,7 @@ if (!hasInterface) exitWith {}; // Conditions: canInteract if !([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific - if (!([ACE_player] call FUNC(canAdjustScope))) exitWith {false}; + if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false}; [ACE_player] call FUNC(inventoryCheck); @@ -140,7 +140,7 @@ if (!hasInterface) exitWith {}; // Conditions: canInteract if !([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific - if (!([ACE_player] call FUNC(canAdjustScope))) exitWith {false}; + if (!([ACE_player] call CBA_fnc_canUseWeapon)) exitWith {false}; [ACE_player] call FUNC(inventoryCheck); diff --git a/addons/scopes/functions/fnc_canAdjustScope.sqf b/addons/scopes/functions/fnc_canAdjustScope.sqf deleted file mode 100644 index b5cc729cbb..0000000000 --- a/addons/scopes/functions/fnc_canAdjustScope.sqf +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Author: PabstMirror - * Tests if player would be in a position to adjust scope - * Mainly for determining edge cases with turned-out / FFV. - * - * Argument: - * 0: Unit - * - * Return value: - * - * - * Example: - * [player] call ace_scopes_fnc_canAdjustScope - * - * Public: No - */ -#include "script_component.hpp" - -params ["_unit"]; - -if ((vehicle _unit) == _unit) exitWith {true}; - -private _animationState = animationState _unit; -private _moves = configFile >> getText (configFile >> "CfgVehicles" >> (typeof _unit) >> "moves"); - -(getNumber (_moves >> "States" >> _animationState >> "canPullTrigger") == 1) From f69142dd45a9aaa8a318237a5b78185caa9c8c0b Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Fri, 20 May 2016 11:23:14 -0500 Subject: [PATCH 12/12] Hearing - New XEH, Fix dead effects, Medical var (#3802) * Hearing - New XEH, Fix dead effects, Medical var * Use setHearingCapability * Cleanup dead player vol update * Don't change global hearing in medical * Fix exitWith --- addons/common/XEH_preInit.sqf | 2 + .../functions/fnc_setHearingCapability.sqf | 56 +++++++++---------- addons/hearing/CfgEventHandlers.hpp | 16 ------ addons/hearing/XEH_postInit.sqf | 4 ++ .../hearing/functions/fnc_explosionNear.sqf | 3 - addons/hearing/functions/fnc_firedNear.sqf | 3 - addons/hearing/functions/fnc_updateVolume.sqf | 13 +++-- addons/medical/XEH_postInit.sqf | 4 -- 8 files changed, 39 insertions(+), 62 deletions(-) diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 16e0a65159..dea4e64538 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -46,6 +46,8 @@ if (isServer) then { GVAR(statusEffect_Names) = []; GVAR(statusEffect_isGlobal) = []; +GVAR(setHearingCapabilityMap) = []; + ////////////////////////////////////////////////// // Set up PlayerChanged eventhandler for pre init (EH is installed in postInit) ////////////////////////////////////////////////// diff --git a/addons/common/functions/fnc_setHearingCapability.sqf b/addons/common/functions/fnc_setHearingCapability.sqf index 2366081ec1..5b1e7a5a3a 100644 --- a/addons/common/functions/fnc_setHearingCapability.sqf +++ b/addons/common/functions/fnc_setHearingCapability.sqf @@ -5,48 +5,44 @@ * Arguments: * 0: id * 1: settings - * 2: add (default: true) + * 2: add [true] OR remove [false] (default: true) * * Return Value: * None * - * Public: Yes + * Example: + * ["earwax", 0.5, true] call ace_common_fnc_setHearingCapability * - * Note: uses player + * Public: Yes */ #include "script_component.hpp" -params ["_id", "_settings", ["_add", true]]; - -private _map = missionNamespace getVariable [QGVAR(setHearingCapabilityMap),[]]; +params ["_id", "_setting", ["_add", true]]; private _exists = false; - -{ - if (_id == _x select 0) exitWith { - _exists = true; - if (_add) then { - _x set [1, _settings]; - } else { - _map set [_forEachIndex, 0]; - _map = _map - [0]; - }; - }; -} forEach _map; - -if (!_exists && _add) then { - _map pushBack [_id, _settings]; -}; - -missionNamespace setVariable [QGVAR(setHearingCapabilityMap), _map]; - -// find lowest volume private _lowestVolume = 1; -{ - _lowestVolume = (_x select 1) min _lowestVolume; - false -} count _map; +GVAR(setHearingCapabilityMap) = GVAR(setHearingCapabilityMap) select { + _x params ["_xID", "_xSetting"]; + if (_id == _xID) then { + _exists = true; + if (_add) then { + _x set [1, _setting]; + _lowestVolume = _lowestVolume min _setting; + true + } else { + false + }; + } else { + _lowestVolume = _lowestVolume min _xSetting; + true + }; +}; + +if (!_exists && _add) then { + _lowestVolume = _lowestVolume min _setting; + GVAR(setHearingCapabilityMap) pushBack [_id, _setting]; +}; // in game sounds 0 fadeSound _lowestVolume; diff --git a/addons/hearing/CfgEventHandlers.hpp b/addons/hearing/CfgEventHandlers.hpp index 352f802435..aa8dbf5134 100644 --- a/addons/hearing/CfgEventHandlers.hpp +++ b/addons/hearing/CfgEventHandlers.hpp @@ -25,22 +25,6 @@ class Extended_Init_EventHandlers { }; }; -class Extended_FiredNear_EventHandlers { - class AllVehicles { - class GVAR(FiredNear) { - clientFiredNear = QUOTE(_this call FUNC(firedNear);); - }; - }; -}; - -class Extended_Explosion_EventHandlers { - class CAManBase { - class GVAR(ExplosionNear) { - clientExplosion = QUOTE(_this call FUNC(explosionNear);); - }; - }; -}; - class Extended_Respawn_EventHandlers { class CAManBase { class ADDON { diff --git a/addons/hearing/XEH_postInit.sqf b/addons/hearing/XEH_postInit.sqf index cbae40dee0..fdd61ccfde 100644 --- a/addons/hearing/XEH_postInit.sqf +++ b/addons/hearing/XEH_postInit.sqf @@ -17,6 +17,10 @@ GVAR(volumeAttenuation) = 1; // Only run PFEH and install event handlers if combat deafness is enabled if (!GVAR(EnableCombatDeafness)) exitWith {}; + //Add XEH: + ["CAManBase", "FiredNear", FUNC(firedNear)] call CBA_fnc_addClassEventHandler; + ["CAManBase", "Explosion", FUNC(explosionNear)] call CBA_fnc_addClassEventHandler; + // Update hearing protection now: [] call FUNC(updateHearingProtection); diff --git a/addons/hearing/functions/fnc_explosionNear.sqf b/addons/hearing/functions/fnc_explosionNear.sqf index 799de52320..76c6707de5 100644 --- a/addons/hearing/functions/fnc_explosionNear.sqf +++ b/addons/hearing/functions/fnc_explosionNear.sqf @@ -16,9 +16,6 @@ */ #include "script_component.hpp" -// Only run if combat deafness is enabled -if (!GVAR(EnableCombatDeafness)) exitWith {}; - params ["_unit", "_damage"]; if (_unit != ACE_player) exitWith {}; diff --git a/addons/hearing/functions/fnc_firedNear.sqf b/addons/hearing/functions/fnc_firedNear.sqf index f583ab0050..46bbee4fae 100644 --- a/addons/hearing/functions/fnc_firedNear.sqf +++ b/addons/hearing/functions/fnc_firedNear.sqf @@ -22,9 +22,6 @@ */ #include "script_component.hpp" -// Only run if combat deafness is enabled -if (!GVAR(EnableCombatDeafness)) exitWith {}; - params ["_object", "_firer", "_distance", "_weapon", "", "", "_ammo"]; //Only run if firedNear object is player or player's vehicle: diff --git a/addons/hearing/functions/fnc_updateVolume.sqf b/addons/hearing/functions/fnc_updateVolume.sqf index 58eedc7b39..2212bd6222 100644 --- a/addons/hearing/functions/fnc_updateVolume.sqf +++ b/addons/hearing/functions/fnc_updateVolume.sqf @@ -16,6 +16,12 @@ */ #include "script_component.hpp" +if (!alive ACE_player) exitWith { + if (missionNameSpace getVariable [QGVAR(disableVolumeUpdate), false]) exitWith {}; + TRACE_1("dead - removing hearing effects",ACE_player); + [QUOTE(ADDON), 1, true] call EFUNC(common,setHearingCapability); +}; + (_this select 0) params ["_justUpdateVolume"]; GVAR(deafnessDV) = (GVAR(deafnessDV) min 20) max 0; @@ -54,9 +60,4 @@ if (ACE_player getVariable ["ACE_isUnconscious", false]) then { _volume = _volume min GVAR(UnconsciousnessVolume); }; -private _soundTransitionTime = if (_justUpdateVolume) then {0.1} else {1}; - -_soundTransitionTime fadeSound _volume; -_soundTransitionTime fadeSpeech _volume; -ACE_player setVariable ["tf_globalVolume", _volume]; -if (!isNil "acre_api_fnc_setGlobalVolume") then {[_volume^(0.33)] call acre_api_fnc_setGlobalVolume;}; +[QUOTE(ADDON), _volume, true] call EFUNC(common,setHearingCapability); diff --git a/addons/medical/XEH_postInit.sqf b/addons/medical/XEH_postInit.sqf index 8d8911a6bf..f0d3b907f6 100644 --- a/addons/medical/XEH_postInit.sqf +++ b/addons/medical/XEH_postInit.sqf @@ -37,19 +37,15 @@ if (isServer) then {["placedInBodyBag", FUNC(serverRemoveBody)] call EFUNC(commo params ["_unit", "_status"]; if (local _unit) then { if (_status) then { - _unit setVariable ["tf_globalVolume", 0.4]; _unit setVariable ["tf_voiceVolume", 0, true]; _unit setVariable ["tf_unable_to_use_radio", true, true]; _unit setVariable ["acre_sys_core_isDisabled", true, true]; - if (!isNil "acre_api_fnc_setGlobalVolume") then { [0.4^0.33] call acre_api_fnc_setGlobalVolume; }; } else { - _unit setVariable ["tf_globalVolume", 1]; _unit setVariable ["tf_voiceVolume", 1, true]; _unit setVariable ["tf_unable_to_use_radio", false, true]; _unit setVariable ["acre_sys_core_isDisabled", false, true]; - if (!isNil "acre_api_fnc_setGlobalVolume") then { [1] call acre_api_fnc_setGlobalVolume; }; }; }; }] call EFUNC(common,addEventHandler);