From cc8ac69feb4c188de3612e654d7b562c0c376507 Mon Sep 17 00:00:00 2001 From: VKing Date: Tue, 5 Jan 2016 23:40:27 +0100 Subject: [PATCH 01/30] Add function and action to detonate all explosives on a detonator --- addons/explosives/XEH_preInit.sqf | 1 + .../functions/fnc_addDetonateActions.sqf | 22 ++++++++++++++- .../functions/fnc_detonateExplosiveAll.sqf | 27 +++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 addons/explosives/functions/fnc_detonateExplosiveAll.sqf diff --git a/addons/explosives/XEH_preInit.sqf b/addons/explosives/XEH_preInit.sqf index 470cae661d..fec63776ff 100644 --- a/addons/explosives/XEH_preInit.sqf +++ b/addons/explosives/XEH_preInit.sqf @@ -28,6 +28,7 @@ PREP(canDefuse); PREP(canDetonate); PREP(defuseExplosive); PREP(detonateExplosive); +PREP(detonateExplosiveAll); PREP(dialPhone); PREP(dialingPhone); diff --git a/addons/explosives/functions/fnc_addDetonateActions.sqf b/addons/explosives/functions/fnc_addDetonateActions.sqf index 04e78f0f82..e306b2fe30 100644 --- a/addons/explosives/functions/fnc_addDetonateActions.sqf +++ b/addons/explosives/functions/fnc_addDetonateActions.sqf @@ -19,18 +19,21 @@ params ["_unit", "_detonator"]; TRACE_2("params",_unit,_detonator); -private ["_result", "_item", "_children", "_range", "_required"]; +private ["_result", "_item", "_children", "_range", "_required","_explosivesList"]; _range = getNumber (ConfigFile >> "CfgWeapons" >> _detonator >> "ACE_Range"); _result = [_unit] call FUNC(getPlacedExplosives); _children = []; +_explosivesList = []; { if (!isNull(_x select 0)) then { _required = getArray (ConfigFile >> "ACE_Triggers" >> (_x select 4) >> "requires"); if (_detonator in _required) then { _item = ConfigFile >> "CfgMagazines" >> (_x select 3); + _explosivesList pushBack _x; + _children pushBack [ [ @@ -49,4 +52,21 @@ _children = []; }; } forEach _result; +// Add action to detonate all explosives tied to the detonator +if (count _explosivesList > 0) then { + _children pushBack [ + [ + "Explosive_All", + "Detonate All", + getText(ConfigFile >> "CfgWeapons" >> _detonator >> "picture"), + {(_this select 2) call FUNC(detonateExplosiveAll);}, + {true}, + {}, + [ACE_player,_range,_explosivesList] + ] call EFUNC(interact_menu,createAction), + [], + ACE_Player + ]; +}; + _children diff --git a/addons/explosives/functions/fnc_detonateExplosiveAll.sqf b/addons/explosives/functions/fnc_detonateExplosiveAll.sqf new file mode 100644 index 0000000000..e1bc39cfd3 --- /dev/null +++ b/addons/explosives/functions/fnc_detonateExplosiveAll.sqf @@ -0,0 +1,27 @@ +/* + * Author: VKing + * Causes the unit to detonate all passed explosives. + * + * Arguments: + * 0: Unit + * 1: Range (-1 to ignore) + * 2: Explosives to detonate + * 0: Explosive + * 1: Fuse time + * + * Return Value: + * None + * + * Example: + * [player, -1, "Command"] call ACE_Explosives_fnc_detonateExplosive; + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit", "_range", "_explosivesList"]; +TRACE_3("Params",_unit,_range,_explosivesList); + +{ + [_unit,_range,_x] call FUNC(detonateExplosive); +} forEach _explosivesList; From 1706ca0adc9ae5c10840c26f6abd74aed224a56a Mon Sep 17 00:00:00 2001 From: VKing Date: Wed, 6 Jan 2016 00:06:06 +0100 Subject: [PATCH 02/30] Move detonate actions from "Detonate" layer to "Explosives" layer. Remove inconsistent ">>" from explosive actions. --- addons/explosives/CfgVehicles.hpp | 11 +-------- addons/explosives/stringtable.xml | 40 +++++++++++++++---------------- 2 files changed, 21 insertions(+), 30 deletions(-) diff --git a/addons/explosives/CfgVehicles.hpp b/addons/explosives/CfgVehicles.hpp index 24de2f5a44..38e44ee4cb 100644 --- a/addons/explosives/CfgVehicles.hpp +++ b/addons/explosives/CfgVehicles.hpp @@ -10,17 +10,8 @@ class CfgVehicles { showDisabled = 1; priority = 4; icon = PATHTOF(UI\Explosives_Menu_ca.paa); + insertChildren = QUOTE([_player] call FUNC(addTransmitterActions);); //Sub-menu items - class ACE_Detonate { - displayName = CSTRING(Detonate); - condition = QUOTE([_player] call FUNC(canDetonate)); - statement = ""; - insertChildren = QUOTE([_player] call FUNC(addTransmitterActions);); - exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting"}; - showDisabled = 1; - icon = PATHTOF(UI\Explosives_Menu_ca.paa); - priority = 2; - }; class ACE_Place { displayName = CSTRING(Place); condition = QUOTE((vehicle _player == _player) and {[_player] call FUNC(hasExplosives)}); diff --git a/addons/explosives/stringtable.xml b/addons/explosives/stringtable.xml index 6cf03d7be2..af5485fd0b 100644 --- a/addons/explosives/stringtable.xml +++ b/addons/explosives/stringtable.xml @@ -14,28 +14,28 @@ Взрывчатка - Place >> - Platzieren >> - Colocar >> - Umieść >> - Placer >> - Položit >> - Piazza >> - Elhelyezés >> - Colocar >> - Установить >> + Place + Platzieren + Colocar + Umieść + Placer + Položit + Piazza + Elhelyezés + Colocar + Установить - Detonate >> - Zünden >> - Detonar >> - Detonuj >> - Mise à feu >> - Odpálit >> - Detona >> - Robbantás >> - Detonar >> - Подрыв >> + Detonate + Zünden + Detonar + Detonuj + Mise à feu + Odpálit + Detona + Robbantás + Detonar + Подрыв Explosive code: %1 From b6dce03c905ad305a582028f4b61f284a8e74c43 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 5 Jan 2016 17:16:47 -0600 Subject: [PATCH 03/30] Fix Header --- addons/explosives/functions/fnc_detonateExplosiveAll.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/explosives/functions/fnc_detonateExplosiveAll.sqf b/addons/explosives/functions/fnc_detonateExplosiveAll.sqf index e1bc39cfd3..377dc0b93a 100644 --- a/addons/explosives/functions/fnc_detonateExplosiveAll.sqf +++ b/addons/explosives/functions/fnc_detonateExplosiveAll.sqf @@ -13,7 +13,7 @@ * None * * Example: - * [player, -1, "Command"] call ACE_Explosives_fnc_detonateExplosive; + * [player, -1, [[c4,0.5]]] call ACE_Explosives_fnc_detonateExplosiveAll; * * Public: No */ From 4c229c92f54e67108a74064fd4ea4499378166ee Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 5 Jan 2016 17:29:01 -0600 Subject: [PATCH 04/30] Add Stringtable Entry --- addons/explosives/functions/fnc_addDetonateActions.sqf | 2 +- addons/explosives/stringtable.xml | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/explosives/functions/fnc_addDetonateActions.sqf b/addons/explosives/functions/fnc_addDetonateActions.sqf index e306b2fe30..5529b2ebcd 100644 --- a/addons/explosives/functions/fnc_addDetonateActions.sqf +++ b/addons/explosives/functions/fnc_addDetonateActions.sqf @@ -57,7 +57,7 @@ if (count _explosivesList > 0) then { _children pushBack [ [ "Explosive_All", - "Detonate All", + localize LSTRING(DetonateAll), getText(ConfigFile >> "CfgWeapons" >> _detonator >> "picture"), {(_this select 2) call FUNC(detonateExplosiveAll);}, {true}, diff --git a/addons/explosives/stringtable.xml b/addons/explosives/stringtable.xml index 6cf03d7be2..728eeb30c1 100644 --- a/addons/explosives/stringtable.xml +++ b/addons/explosives/stringtable.xml @@ -37,6 +37,12 @@ Detonar >> Подрыв >> + + Detonate All + Zünden Alles + Detonar Todo + Подрыв Все + Explosive code: %1 Sprengstoffcode: %1 From 9985988987c83e279b7fd001c01cd2a1036552ea Mon Sep 17 00:00:00 2001 From: VKing Date: Wed, 6 Jan 2016 18:05:06 +0100 Subject: [PATCH 05/30] Change ACE_Player to _unit --- addons/explosives/functions/fnc_addDetonateActions.sqf | 8 ++++---- addons/explosives/functions/fnc_addTransmitterActions.sqf | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/explosives/functions/fnc_addDetonateActions.sqf b/addons/explosives/functions/fnc_addDetonateActions.sqf index 5529b2ebcd..2af4d6e772 100644 --- a/addons/explosives/functions/fnc_addDetonateActions.sqf +++ b/addons/explosives/functions/fnc_addDetonateActions.sqf @@ -43,10 +43,10 @@ _explosivesList = []; {(_this select 2) call FUNC(detonateExplosive);}, {true}, {}, - [ACE_player,_range,_x] + [_unit,_range,_x] ] call EFUNC(interact_menu,createAction), [], - ACE_Player + _unit ]; }; }; @@ -62,10 +62,10 @@ if (count _explosivesList > 0) then { {(_this select 2) call FUNC(detonateExplosiveAll);}, {true}, {}, - [ACE_player,_range,_explosivesList] + [_unit,_range,_explosivesList] ] call EFUNC(interact_menu,createAction), [], - ACE_Player + _unit ]; }; diff --git a/addons/explosives/functions/fnc_addTransmitterActions.sqf b/addons/explosives/functions/fnc_addTransmitterActions.sqf index 40ec8581d4..4397e743a0 100644 --- a/addons/explosives/functions/fnc_addTransmitterActions.sqf +++ b/addons/explosives/functions/fnc_addTransmitterActions.sqf @@ -33,10 +33,10 @@ _children = []; {}, {true}, {(_this select 2) call FUNC(addDetonateActions);}, - [ACE_player,_x] + [_unit,_x] ] call EFUNC(interact_menu,createAction), [], - ACE_Player + _unit ]; } forEach _detonators; From 63a79b99202b72c3957aa86ef3fe3caee08e40db Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sat, 9 Jan 2016 01:36:19 -0600 Subject: [PATCH 06/30] Use Function Caching in CBA --- addons/main/script_macros.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/main/script_macros.hpp b/addons/main/script_macros.hpp index fdb020c114..3d4bc31c99 100644 --- a/addons/main/script_macros.hpp +++ b/addons/main/script_macros.hpp @@ -84,7 +84,7 @@ #ifdef DISABLE_COMPILE_CACHE #define PREP(fncName) DFUNC(fncName) = compile preprocessFileLineNumbers QUOTE(PATHTOF(functions\DOUBLES(fnc,fncName).sqf)) #else - #define PREP(fncName) DFUNC(fncName) = QUOTE(PATHTOF(functions\DOUBLES(fnc,fncName).sqf)) call SLX_XEH_COMPILE + #define PREP(fncName) [QUOTE(PATHTOF(functions\DOUBLES(fnc,fncName).sqf)), QFUNC(fncName)] call SLX_XEH_COMPILE_NEW #endif #define PREP_MODULE(folder) [] call compile preprocessFileLineNumbers QUOTE(PATHTOF(folder\__PREP__.sqf)) From c2f780e95f9eea3ed7d643d4d760166203891967 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sat, 9 Jan 2016 23:54:48 -0600 Subject: [PATCH 07/30] #1259 - Medical Locations Boost Training --- addons/medical/ACE_Settings.hpp | 7 ++++++ addons/medical/CfgVehicles.hpp | 6 +++++ .../functions/fnc_isInMedicalFacility.sqf | 23 +++++++++++++------ .../functions/fnc_isInMedicalVehicle.sqf | 7 +++--- addons/medical/functions/fnc_isMedic.sqf | 14 ++++++++--- .../functions/fnc_moduleMedicalSettings.sqf | 1 + addons/medical/stringtable.xml | 6 +++++ 7 files changed, 51 insertions(+), 13 deletions(-) diff --git a/addons/medical/ACE_Settings.hpp b/addons/medical/ACE_Settings.hpp index 02b5375e96..5c3ba86b12 100644 --- a/addons/medical/ACE_Settings.hpp +++ b/addons/medical/ACE_Settings.hpp @@ -11,6 +11,13 @@ class ACE_Settings { typeName = "SCALAR"; values[] = {"Disabled", "Normal", "Advanced"}; }; + class GVAR(increaseTrainingInLocations) { + category = CSTRING(Category_Medical); + displayName = CSTRING(MedicalSettings_increaseTrainingInLocations_DisplayName); + description = CSTRING(MedicalSettings_increaseTrainingInLocations_Description); + value = 0; + typeName = "BOOL"; + }; class GVAR(enableFor) { category = CSTRING(Category_Medical); value = 0; diff --git a/addons/medical/CfgVehicles.hpp b/addons/medical/CfgVehicles.hpp index e673b27908..bb98c7f1fa 100644 --- a/addons/medical/CfgVehicles.hpp +++ b/addons/medical/CfgVehicles.hpp @@ -58,6 +58,12 @@ class CfgVehicles { }; }; }; + class increaseTrainingInLocations { + displayName = CSTRING(MedicalSettings_increaseTrainingInLocations_DisplayName); + description = CSTRING(MedicalSettings_increaseTrainingInLocations_Description); + typeName = "BOOL"; + defaultValue = 0; + }; class allowLitterCreation { displayName = CSTRING(MedicalSettings_allowLitterCreation_DisplayName); description = CSTRING(MedicalSettings_allowLitterCreation_Description); diff --git a/addons/medical/functions/fnc_isInMedicalFacility.sqf b/addons/medical/functions/fnc_isInMedicalFacility.sqf index 330a1e5ea3..f934978d2b 100644 --- a/addons/medical/functions/fnc_isInMedicalFacility.sqf +++ b/addons/medical/functions/fnc_isInMedicalFacility.sqf @@ -8,18 +8,23 @@ * ReturnValue: * Is in medical facility * + * Example: + * [player] call ace_medical_fnc_isInMedicalFacility + * * Public: Yes */ - #include "script_component.hpp" -private ["_eyePos", "_objects", "_isInBuilding", "_medicalFacility"]; params ["_unit"]; -_eyePos = eyePos _unit; -_isInBuilding = false; +//Cache the results as this function could be called rapidly +(_unit getVariable [QGVAR(cacheInFacility), [-9, false]]) params ["_expireTime", "_lastResult"]; +if (ACE_time < _expireTime) exitWith {_lastResult}; -_medicalFacility = +private _eyePos = eyePos _unit; +private _isInBuilding = false; + +private _medicalFacility = [ "TK_GUE_WarfareBFieldhHospital_Base_EP1", "TK_GUE_WarfareBFieldhHospital_EP1", @@ -37,18 +42,22 @@ _medicalFacility = "USMC_WarfareBFieldhHospital" ]; -_objects = (lineIntersectsWith [_unit modelToWorldVisual [0, 0, (_eyePos select 2)], _unit modelToWorldVisual [0, 0, (_eyePos select 2) +10], _unit]); +private _objects = (lineIntersectsWith [_unit modelToWorldVisual [0, 0, (_eyePos select 2)], _unit modelToWorldVisual [0, 0, (_eyePos select 2) +10], _unit]); { if (((typeOf _x) in _medicalFacility) || (_x getVariable [QGVAR(isMedicalFacility),false])) exitWith { _isInBuilding = true; }; } forEach _objects; if (!_isInBuilding) then { - _objects = position _unit nearObjects 7.5; + _objects = _unit nearObjects 7.5; { if (((typeOf _x) in _medicalFacility) || (_x getVariable [QGVAR(isMedicalFacility),false])) exitWith { _isInBuilding = true; }; } forEach _objects; }; + +//Save the results (with a 1 second expiry) +_unit setVariable [QGVAR(cacheInFacility), [ACE_time + 1, _isInBuilding]]; + _isInBuilding; diff --git a/addons/medical/functions/fnc_isInMedicalVehicle.sqf b/addons/medical/functions/fnc_isInMedicalVehicle.sqf index 1f1ff193fd..4182003bad 100644 --- a/addons/medical/functions/fnc_isInMedicalVehicle.sqf +++ b/addons/medical/functions/fnc_isInMedicalVehicle.sqf @@ -8,14 +8,15 @@ * Return Value: * Is unit in medical vehicle? * + * Example: + * [player] call ace_medical_fnc_isInMedicalVehicle + * * Public: Yes */ - #include "script_component.hpp" -private ["_vehicle"]; params ["_unit"]; -_vehicle = vehicle _unit; +private _vehicle = vehicle _unit; if (_unit == _vehicle) exitWith {false}; if (_unit in [driver _vehicle, gunner _vehicle, commander _vehicle]) exitWith {false}; diff --git a/addons/medical/functions/fnc_isMedic.sqf b/addons/medical/functions/fnc_isMedic.sqf index ca974fb751..ff5a1b24a9 100644 --- a/addons/medical/functions/fnc_isMedic.sqf +++ b/addons/medical/functions/fnc_isMedic.sqf @@ -9,15 +9,23 @@ * ReturnValue: * Is in of medic class * + * Example: + * [player] call ace_medical_fnc_isMedic + * * Public: Yes */ #include "script_component.hpp" -private ["_unit", "_class", "_medicN"]; params ["_unit", ["_medicN", 1]]; -_class = _unit getVariable [QGVAR(medicClass), - getNumber (configFile >> "CfgVehicles" >> typeOf _unit >> "attendant")]; +private _class = _unit getVariable [QGVAR(medicClass), getNumber (configFile >> "CfgVehicles" >> typeOf _unit >> "attendant")]; + +if (_class >= _medicN min GVAR(medicSetting)) exitWith {true}; +if (!GVAR(increaseTrainingInLocations)) exitWith {false}; + +if (([_unit] call FUNC(isInMedicalVehicle)) || {[_unit] call FUNC(isInMedicalFacility)}) then { + _class = _class + 1; //boost by one: untrained becomes medic, medic becomes doctor +}; _class >= _medicN min GVAR(medicSetting) diff --git a/addons/medical/functions/fnc_moduleMedicalSettings.sqf b/addons/medical/functions/fnc_moduleMedicalSettings.sqf index 4e1af0e86c..ab235858d2 100644 --- a/addons/medical/functions/fnc_moduleMedicalSettings.sqf +++ b/addons/medical/functions/fnc_moduleMedicalSettings.sqf @@ -21,6 +21,7 @@ if !(_activated) exitWith {}; [_logic, QGVAR(level), "level"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(medicSetting), "medicSetting"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(increaseTrainingInLocations), "increaseTrainingInLocations"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(allowLitterCreation), "allowLitterCreation"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(litterCleanUpDelay), "litterCleanUpDelay"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(enableScreams), "enableScreams"] call EFUNC(common,readSettingFromModule); diff --git a/addons/medical/stringtable.xml b/addons/medical/stringtable.xml index a3ae483065..bc460741e6 100644 --- a/addons/medical/stringtable.xml +++ b/addons/medical/stringtable.xml @@ -2835,6 +2835,12 @@ Quel niveau de détail voullez vous pour les infirmier? Mi a javasolt részletesség orvosok számára? + + Locations boost training + + + Boost medic rating in medical vehicles or near medical facilities [untrained becomes medic, medic becomes doctor] + Disable medics Отключить медиков From 09e4a6a76e888959cad53fa133c490b7e5eac34d Mon Sep 17 00:00:00 2001 From: bux Date: Sun, 10 Jan 2016 19:08:28 +0100 Subject: [PATCH 08/30] cleanup SwitchUnits --- addons/switchunits/CfgVehicles.hpp | 100 +++++++++--------- addons/switchunits/config.cpp | 18 ++-- .../functions/fnc_handleMapClick.sqf | 4 +- .../switchunits/functions/fnc_markAiOnMap.sqf | 9 +- addons/switchunits/functions/fnc_module.sqf | 2 +- .../functions/fnc_nearestPlayers.sqf | 4 +- .../functions/fnc_startSwitchUnits.sqf | 3 +- .../switchunits/functions/fnc_switchBack.sqf | 3 +- .../switchunits/functions/fnc_switchUnit.sqf | 13 +-- .../functions/script_component.hpp | 2 +- 10 files changed, 74 insertions(+), 84 deletions(-) diff --git a/addons/switchunits/CfgVehicles.hpp b/addons/switchunits/CfgVehicles.hpp index 7951a6cd59..f0549cb00e 100644 --- a/addons/switchunits/CfgVehicles.hpp +++ b/addons/switchunits/CfgVehicles.hpp @@ -1,53 +1,53 @@ class CfgVehicles { - class ACE_Module; - class ACE_ModuleSwitchUnits: ACE_Module { - author = ECSTRING(common,ACETeam); - category = "ACE"; - displayName = CSTRING(Module_DisplayName); - function = FUNC(module); - scope = 2; - isGlobal = 1; - icon = QUOTE(PATHTOF(UI\Icon_Module_SwitchUnits_ca.paa)); - class Arguments { - class SwitchToWest { - displayName = CSTRING(SwitchToWest_DisplayName); - description = CSTRING(SwitchToWest_Description); - typeName = "BOOL"; - defaultValue = 0; - }; - class SwitchToEast { - displayName = CSTRING(SwitchToEast_DisplayName); - description = CSTRING(SwitchToEast_Description); - typeName = "BOOL"; - defaultValue = 0; - }; - class SwitchToIndependent { - displayName = CSTRING(SwitchToIndependent_DisplayName); - description = CSTRING(SwitchToIndependent_Description); - typeName = "BOOL"; - defaultValue = 0; - }; - class SwitchToCivilian { - displayName = CSTRING(SwitchToCivilian_DisplayName); - description = CSTRING(SwitchToCivilian_Description); - typeName = "BOOL"; - defaultValue = 0; - }; - class EnableSafeZone { - displayName = CSTRING(EnableSafeZone_DisplayName); - description = CSTRING(EnableSafeZone_Description); - typeName = "BOOL"; - defaultValue = 1; - }; - class SafeZoneRadius { - displayName = CSTRING(SafeZoneRadius_DisplayName); - description = CSTRING(SafeZoneRadius_Description); - typeName = "NUMBER"; - defaultValue = 100; - }; + class ACE_Module; + class ACE_ModuleSwitchUnits: ACE_Module { + author = ECSTRING(common,ACETeam); + category = "ACE"; + displayName = CSTRING(Module_DisplayName); + function = FUNC(module); + scope = 2; + isGlobal = 1; + icon = QUOTE(PATHTOF(UI\Icon_Module_SwitchUnits_ca.paa)); + class Arguments { + class SwitchToWest { + displayName = CSTRING(SwitchToWest_DisplayName); + description = CSTRING(SwitchToWest_Description); + typeName = "BOOL"; + defaultValue = 0; + }; + class SwitchToEast { + displayName = CSTRING(SwitchToEast_DisplayName); + description = CSTRING(SwitchToEast_Description); + typeName = "BOOL"; + defaultValue = 0; + }; + class SwitchToIndependent { + displayName = CSTRING(SwitchToIndependent_DisplayName); + description = CSTRING(SwitchToIndependent_Description); + typeName = "BOOL"; + defaultValue = 0; + }; + class SwitchToCivilian { + displayName = CSTRING(SwitchToCivilian_DisplayName); + description = CSTRING(SwitchToCivilian_Description); + typeName = "BOOL"; + defaultValue = 0; + }; + class EnableSafeZone { + displayName = CSTRING(EnableSafeZone_DisplayName); + description = CSTRING(EnableSafeZone_Description); + typeName = "BOOL"; + defaultValue = 1; + }; + class SafeZoneRadius { + displayName = CSTRING(SafeZoneRadius_DisplayName); + description = CSTRING(SafeZoneRadius_Description); + typeName = "NUMBER"; + defaultValue = 100; + }; + }; + class ModuleDescription { + description = CSTRING(Module_Description); + }; }; - class ModuleDescription { - description = CSTRING(Module_Description); - }; - }; }; diff --git a/addons/switchunits/config.cpp b/addons/switchunits/config.cpp index 3b1d11f460..22a4924709 100644 --- a/addons/switchunits/config.cpp +++ b/addons/switchunits/config.cpp @@ -1,15 +1,15 @@ #include "script_component.hpp" class CfgPatches { - class ADDON { - units[] = {}; - weapons[] = {}; - requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ace_common"}; - author[] = {"bux578"}; - authorUrl = "https://github.com/bux578/"; - VERSION_CONFIG; - }; + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common"}; + author[] = {"bux578"}; + authorUrl = "https://github.com/bux578/"; + VERSION_CONFIG; + }; }; #include "CfgEventHandlers.hpp" diff --git a/addons/switchunits/functions/fnc_handleMapClick.sqf b/addons/switchunits/functions/fnc_handleMapClick.sqf index 03a94f81af..b0984631d7 100644 --- a/addons/switchunits/functions/fnc_handleMapClick.sqf +++ b/addons/switchunits/functions/fnc_handleMapClick.sqf @@ -18,12 +18,10 @@ */ #include "script_component.hpp" -private ["_sideNearest"]; - params ["_faction", "_pos"]; _faction params ["", "_sides"]; -_sideNearest = []; +private _sideNearest = []; { if ([_x] call FUNC(isValidAi) && (side group _x in _sides)) then { diff --git a/addons/switchunits/functions/fnc_markAiOnMap.sqf b/addons/switchunits/functions/fnc_markAiOnMap.sqf index db43c58f43..d29e75b6a4 100644 --- a/addons/switchunits/functions/fnc_markAiOnMap.sqf +++ b/addons/switchunits/functions/fnc_markAiOnMap.sqf @@ -37,18 +37,17 @@ GVAR(AllMarkerNames) = []; // create markers { if (([_x] call FUNC(isValidAi) && (side group _x in _sides)) || (_x getVariable [QGVAR(IsPlayerControlled), false])) then { - private ["_markerName", "_marker", "_markerColor"]; + + private _markerName = str _x; - _markerName = str _x; - - _marker = createMarkerLocal [_markerName, position _x]; + private _marker = createMarkerLocal [_markerName, position _x]; _markerName setMarkerTypeLocal "mil_triangle"; _markerName setMarkerShapeLocal "ICON"; _markerName setMarkerSizeLocal [0.5, 0.7]; _markerName setMarkerDirLocal getDir _x; // commy's one liner magic - _markerColor = format ["Color%1", side group _x]; + private _markerColor = format ["Color%1", side group _x]; if ((_x getVariable [QGVAR(IsPlayerControlled), false])) then { _markerName setMarkerColorLocal "ColorOrange"; diff --git a/addons/switchunits/functions/fnc_module.sqf b/addons/switchunits/functions/fnc_module.sqf index 3b8cea4037..9da63a9510 100644 --- a/addons/switchunits/functions/fnc_module.sqf +++ b/addons/switchunits/functions/fnc_module.sqf @@ -35,4 +35,4 @@ GVAR(Module) = true; [QGVAR(EnableSwitchUnits), true, false, true] call EFUNC(common,setSetting); -ACE_LOGINFO("Switch Unit Module Initialized."); +ACE_LOGINFO("SwitchUnits Module Initialized."); diff --git a/addons/switchunits/functions/fnc_nearestPlayers.sqf b/addons/switchunits/functions/fnc_nearestPlayers.sqf index 64e347d7da..f20d5fcf02 100644 --- a/addons/switchunits/functions/fnc_nearestPlayers.sqf +++ b/addons/switchunits/functions/fnc_nearestPlayers.sqf @@ -16,11 +16,9 @@ */ #include "script_component.hpp" -private ["_nearestPlayers"]; - params ["_position", "_radius"]; -_nearestPlayers = []; +private _nearestPlayers = []; { if ([_x] call EFUNC(common,isPlayer) && {alive _x}) then { diff --git a/addons/switchunits/functions/fnc_startSwitchUnits.sqf b/addons/switchunits/functions/fnc_startSwitchUnits.sqf index 481b04d2cd..8d4707f040 100644 --- a/addons/switchunits/functions/fnc_startSwitchUnits.sqf +++ b/addons/switchunits/functions/fnc_startSwitchUnits.sqf @@ -19,8 +19,7 @@ params ["_player"]; if (GVAR(EnableSwitchUnits)) then { - private "_sides"; - _sides = []; + private _sides = []; if(GVAR(SwitchToWest)) then {_sides pushBack west;}; if(GVAR(SwitchToEast)) then {_sides pushBack east;}; diff --git a/addons/switchunits/functions/fnc_switchBack.sqf b/addons/switchunits/functions/fnc_switchBack.sqf index 5aab2c9aee..b48414061c 100644 --- a/addons/switchunits/functions/fnc_switchBack.sqf +++ b/addons/switchunits/functions/fnc_switchBack.sqf @@ -28,8 +28,7 @@ params ["_originalPlayerUnit"]; selectPlayer _originalPlayerUnit; deleteVehicle _currentUnit; - private "_layer"; - _layer = "BIS_fnc_respawnCounter" call bis_fnc_rscLayer; + private _layer = "BIS_fnc_respawnCounter" call bis_fnc_rscLayer; _layer cuttext ["","plain"]; [_pfhId] call CBA_fnc_removePerFrameHandler; diff --git a/addons/switchunits/functions/fnc_switchUnit.sqf b/addons/switchunits/functions/fnc_switchUnit.sqf index 49c3e97e42..cc95d478d7 100644 --- a/addons/switchunits/functions/fnc_switchUnit.sqf +++ b/addons/switchunits/functions/fnc_switchUnit.sqf @@ -15,19 +15,17 @@ */ #include "script_component.hpp" -private ["_nearestEnemyPlayers", "_allNearestPlayers", "_oldUnit", "_leave"]; - params ["_unit"]; // don't switch to original player units if (!([_unit] call FUNC(isValidAi))) exitWith {}; // exit var -_leave = false; +private _leave = false; if (GVAR(EnableSafeZone)) then { - _allNearestPlayers = [position _unit, GVAR(SafeZoneRadius)] call FUNC(nearestPlayers); - _nearestEnemyPlayers = [_allNearestPlayers, {((side GVAR(OriginalGroup)) getFriend (side _this) < 0.6) && !(_this getVariable [QGVAR(IsPlayerControlled), false])}] call EFUNC(common,filter); + private _allNearestPlayers = [position _unit, GVAR(SafeZoneRadius)] call FUNC(nearestPlayers); + private _nearestEnemyPlayers = [_allNearestPlayers, {((side GVAR(OriginalGroup)) getFriend (side _this) < 0.6) && !(_this getVariable [QGVAR(IsPlayerControlled), false])}] call EFUNC(common,filter); if (count _nearestEnemyPlayers > 0) exitWith { _leave = true; @@ -45,7 +43,6 @@ if (_leave) exitWith { [[_unit, player], QUOTE({(_this select 0) setVariable [ARR_3(QUOTE(QGVAR(OriginalOwner)), owner (_this select 0), true)]; (_this select 0) setOwner owner (_this select 1)}), 1] call EFUNC(common,execRemoteFnc); [{ - private ["_respawnEhId", "_oldOwner"]; params ["_args", "_pfhId"]; _args params ["_unit", "_oldUnit"]; @@ -53,7 +50,7 @@ if (_leave) exitWith { _oldUnit setVariable [QGVAR(IsPlayerControlled), false, true]; _oldUnit setVariable [QGVAR(PlayerControlledName), "", true]; - _respawnEhId = _unit getVariable [QGVAR(RespawnEhId), -1]; + private _respawnEhId = _unit getVariable [QGVAR(RespawnEhId), -1]; if (_respawnEhId != -1) then { _oldUnit removeEventHandler ["Respawn", _respawnEhId]; }; @@ -69,7 +66,7 @@ if (_leave) exitWith { _unit setVariable [QGVAR(RespawnEhId), _respawnEhId, true]; // set owner back to original owner - _oldOwner = _oldUnit getVariable[QGVAR(OriginalOwner), -1]; + private _oldOwner = _oldUnit getVariable[QGVAR(OriginalOwner), -1]; if (_oldOwner > -1) then { [[_oldUnit, _oldOwner], QUOTE({(_this select 0) setOwner (_this select 1)}), 1] call EFUNC(common,execRemoteFnc); }; diff --git a/addons/switchunits/functions/script_component.hpp b/addons/switchunits/functions/script_component.hpp index df5c7a0d96..d03116f2f8 100644 --- a/addons/switchunits/functions/script_component.hpp +++ b/addons/switchunits/functions/script_component.hpp @@ -1 +1 @@ -#include "\z\ace\addons\switchunits\script_component.hpp" \ No newline at end of file +#include "\z\ace\addons\switchunits\script_component.hpp" From ec0ece059f69819dfcf6793c5e89332ecf057448 Mon Sep 17 00:00:00 2001 From: bux Date: Sun, 10 Jan 2016 20:58:54 +0100 Subject: [PATCH 09/30] use Killed event, fix missing public setVar add more text, don't delete dead unit --- .../switchunits/functions/fnc_initPlayer.sqf | 2 +- .../switchunits/functions/fnc_switchBack.sqf | 7 +++-- .../switchunits/functions/fnc_switchUnit.sqf | 30 ++++++++++++++----- addons/switchunits/stringtable.xml | 4 +++ 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/addons/switchunits/functions/fnc_initPlayer.sqf b/addons/switchunits/functions/fnc_initPlayer.sqf index 80388a9d2b..87873c349f 100644 --- a/addons/switchunits/functions/fnc_initPlayer.sqf +++ b/addons/switchunits/functions/fnc_initPlayer.sqf @@ -21,7 +21,7 @@ params ["_playerUnit", "_sides"]; if (vehicle _playerUnit == _playerUnit) then { [_sides] call FUNC(markAiOnMap); - _playerUnit setVariable [QGVAR(IsPlayerUnit), true]; + _playerUnit setVariable [QGVAR(IsPlayerUnit), true, true]; _playerUnit allowDamage false; GVAR(OriginalUnit) = _playerUnit; diff --git a/addons/switchunits/functions/fnc_switchBack.sqf b/addons/switchunits/functions/fnc_switchBack.sqf index b48414061c..4c3d05ae54 100644 --- a/addons/switchunits/functions/fnc_switchBack.sqf +++ b/addons/switchunits/functions/fnc_switchBack.sqf @@ -26,10 +26,11 @@ params ["_originalPlayerUnit"]; if (local _originalPlayerUnit) exitWith { selectPlayer _originalPlayerUnit; - deleteVehicle _currentUnit; - private _layer = "BIS_fnc_respawnCounter" call bis_fnc_rscLayer; - _layer cuttext ["","plain"]; + // deleteVehicle _currentUnit; + + // private _layer = "BIS_fnc_respawnCounter" call bis_fnc_rscLayer; + // _layer cuttext ["","plain"]; [_pfhId] call CBA_fnc_removePerFrameHandler; }; diff --git a/addons/switchunits/functions/fnc_switchUnit.sqf b/addons/switchunits/functions/fnc_switchUnit.sqf index cc95d478d7..903207652c 100644 --- a/addons/switchunits/functions/fnc_switchUnit.sqf +++ b/addons/switchunits/functions/fnc_switchUnit.sqf @@ -40,19 +40,28 @@ if (_leave) exitWith { // should switch locality // This doesn't work anymore, because one's now able to switch to units from a different side //[_unit] joinSilent group player; -[[_unit, player], QUOTE({(_this select 0) setVariable [ARR_3(QUOTE(QGVAR(OriginalOwner)), owner (_this select 0), true)]; (_this select 0) setOwner owner (_this select 1)}), 1] call EFUNC(common,execRemoteFnc); +[ + [_unit, player], + QUOTE({ + (_this select 0) setVariable [ARR_3(QUOTE(QGVAR(OriginalOwner)), owner (_this select 0), true)]; + (_this select 0) setOwner owner (_this select 1) + }), + 1 +] call EFUNC(common,execRemoteFnc); [{ params ["_args", "_pfhId"]; _args params ["_unit", "_oldUnit"]; + [localize LSTRING(TryingToSwitch)] call EFUNC(common,displayTextStructured); + if (local _unit) exitWith { _oldUnit setVariable [QGVAR(IsPlayerControlled), false, true]; _oldUnit setVariable [QGVAR(PlayerControlledName), "", true]; - private _respawnEhId = _unit getVariable [QGVAR(RespawnEhId), -1]; - if (_respawnEhId != -1) then { - _oldUnit removeEventHandler ["Respawn", _respawnEhId]; + private _killedEhId = _unit getVariable [QGVAR(KilledEhId), -1]; + if (_killedEhId != -1) then { + _oldUnit removeEventHandler ["Killed", _killedEhId]; }; selectPlayer _unit; @@ -60,15 +69,22 @@ if (_leave) exitWith { _unit setVariable [QGVAR(IsPlayerControlled), true, true]; _unit setVariable [QGVAR(PlayerControlledName), GVAR(OriginalName), true]; - _respawnEhId = _unit addEventHandler ["Respawn", { + + _killedEhId = _unit addEventHandler ["Killed", { [GVAR(OriginalUnit), _this select 0] call FUNC(switchBack); }]; - _unit setVariable [QGVAR(RespawnEhId), _respawnEhId, true]; + _unit setVariable [QGVAR(KilledEhId), _killedEhId, true]; + // set owner back to original owner private _oldOwner = _oldUnit getVariable[QGVAR(OriginalOwner), -1]; if (_oldOwner > -1) then { - [[_oldUnit, _oldOwner], QUOTE({(_this select 0) setOwner (_this select 1)}), 1] call EFUNC(common,execRemoteFnc); + [ + [_oldUnit, _oldOwner], + QUOTE({ + (_this select 0) setOwner (_this select 1) + }), 1 + ] call EFUNC(common,execRemoteFnc); }; [localize LSTRING(SwitchedUnit)] call EFUNC(common,displayTextStructured); diff --git a/addons/switchunits/stringtable.xml b/addons/switchunits/stringtable.xml index d38175b1da..9170bd63a2 100644 --- a/addons/switchunits/stringtable.xml +++ b/addons/switchunits/stringtable.xml @@ -13,6 +13,10 @@ Cambia unità Trocado de unidade + + Trying to switch + Versuche zu Wechseln + This unit is too close to the enemy. Diese Einheit ist zu nah am Feind. From abe936065e4c0094b49e6229d1ae75b73eb5f92e Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sun, 10 Jan 2016 14:46:45 -0600 Subject: [PATCH 10/30] Python tool to validate configs (using MakePbo) --- tools/config_validator.py | 118 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 tools/config_validator.py diff --git a/tools/config_validator.py b/tools/config_validator.py new file mode 100644 index 0000000000..c61d2d7a2b --- /dev/null +++ b/tools/config_validator.py @@ -0,0 +1,118 @@ +#!/usr/bin/env python3 + +#by PabstMirror - python script to verify all addons using MakePbo's lint checking and extFile Checking +#Arguments (eg: `config_validator.py full`): +#full dump full deRaped config of problem +#skipExt skips checking external file references + +import os +import sys +import subprocess +import timeit +import threading +import time + +######## GLOBALS ######### +MAINPREFIX = "z" +PREFIX = "ace_" +########################## + +def Fract_Sec(s): + temp = float() + temp = float(s) / (60*60*24) + d = int(temp) + temp = (temp - d) * 24 + h = int(temp) + temp = (temp - h) * 60 + m = int(temp) + temp = (temp - m) * 60 + sec = temp + return d,h,m,sec + +def CheckPBO(p,makePboArgs,errors): + try: + subprocess.run([ + "makepbo", + makePboArgs, + "-@={}\\{}\\addons\\{}".format(MAINPREFIX,PREFIX.rstrip("_"),p), + p, + "{}{}.pbo".format(PREFIX,p) + ], stdin=None, input=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True) + except subprocess.CalledProcessError as e: + print("!! Problem With {} ret {} !!".format(p, e.returncode)) + print(" stderr: {}".format(e.stderr)) + errors.append(p) + else: + print(" Checked ok {}".format(p)) + return + +def fullDump(p): + try: + subprocess.run([ + "makepbo", + "-PQGs", #Q Lint only - Gs Check external references and show deRap - P dont pause + "-@={}\\{}\\addons\\{}".format(MAINPREFIX,PREFIX.rstrip("_"),p), + p, + "{}{}.pbo".format(PREFIX,p) + ], stdin=None, input=None, check=True) + except subprocess.CalledProcessError as e: + input("Press Enter to continue...") + return + +def main(argv): + print(""" + #################### + # ACE3 Config Check # + #################### +""") + + start_time = timeit.default_timer() + + scriptpath = os.path.realpath(__file__) + projectpath = os.path.dirname(os.path.dirname(scriptpath)) + addonspath = os.path.join(projectpath, "addons") + + os.chdir(addonspath) + + #Q Lint only - G Check external references - P dont pause (Gs) does full derap + makePboArgs = "-PQG" + if "skipExt" in argv: + print("Skipping External Files Check"); + makePboArgs = "-PQ" + + errors = [] + + for p in os.listdir(addonspath): + path = os.path.join(addonspath, p) + if not os.path.isdir(path): + continue + if p[0] == ".": + continue + + # t = threading.Thread(target=CheckPBO, args=(p,makePboArgs,errors)) + # t.start() + CheckPBO(p,makePboArgs,errors) + + + # for t in threading.enumerate(): + # if t is threading.currentThread(): + # continue + # t.join() + + d,h,m,s = Fract_Sec(timeit.default_timer() - start_time) + print("\n# Done with {0} errrors [took: {1:2}h {2:2}m {3:4.5f}s]".format(len(errors),h,m,s)) + + if (len(errors) > 0): + if "full" in argv: + input("Dumping Full DeRap: Press Enter to continue...") + for p in errors: + fullDump(p) + else: + print("use 'full' arg to show derap") + + ret = len(errors) + print("return {}".format(ret)) + return ret + +if __name__ == "__main__": + main(sys.argv) From 01dd663337467a7ead806128fb8e01bf316d94d2 Mon Sep 17 00:00:00 2001 From: VKing Date: Mon, 11 Jan 2016 23:36:34 +0100 Subject: [PATCH 11/30] Add fnc_detonateExplosiveTrigger --- addons/explosives/XEH_preInit.sqf | 1 + .../fnc_detonateExplosiveTrigger.sqf | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 addons/explosives/functions/fnc_detonateExplosiveTrigger.sqf diff --git a/addons/explosives/XEH_preInit.sqf b/addons/explosives/XEH_preInit.sqf index 470cae661d..6f63588491 100644 --- a/addons/explosives/XEH_preInit.sqf +++ b/addons/explosives/XEH_preInit.sqf @@ -28,6 +28,7 @@ PREP(canDefuse); PREP(canDetonate); PREP(defuseExplosive); PREP(detonateExplosive); +PREP(detonateExplosiveTrigger); PREP(dialPhone); PREP(dialingPhone); diff --git a/addons/explosives/functions/fnc_detonateExplosiveTrigger.sqf b/addons/explosives/functions/fnc_detonateExplosiveTrigger.sqf new file mode 100644 index 0000000000..e8c34e1350 --- /dev/null +++ b/addons/explosives/functions/fnc_detonateExplosiveTrigger.sqf @@ -0,0 +1,27 @@ +/* + * Author: VKing + * Detonate explosives via script, for use in triggers or mission scripts to + * detonate editor-placed explosives. + * + * Arguments: + * 0: Explosives objects to detonate + * 1: Fuze delay (for each explosive; use negative number for random time up to value) + * + * Return Value: + * None + * + * Example: + * [[charge1, charge2, charge3], -1] call ACE_Explosives_fnc_detonateExplosiveTrigger; + * [[claymore1, claymore2]] call ACE_Explosives_fnc_detonateExplosiveTrigger; + * + * Public: Yes + */ +#include "script_component.hpp" + +params ["_explosiveArr",["_fuzeTime",0]]; + +private _detTime; +{ + _detTime = if (_fuzeTime < 0) then {random abs _fuzeTime} else {_fuzeTime}; + [objNull, -1, [_x, _detTime]] call FUNC(detonateExplosive); +} forEach _explosiveArr; From 4fc7c3065edc152dbef72e19b8c190431d0b233e Mon Sep 17 00:00:00 2001 From: VKing Date: Mon, 11 Jan 2016 23:41:33 +0100 Subject: [PATCH 12/30] Rename to fnc_scriptedExplosive --- addons/explosives/XEH_preInit.sqf | 2 +- ...detonateExplosiveTrigger.sqf => fnc_scriptedExplosive.sqf} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename addons/explosives/functions/{fnc_detonateExplosiveTrigger.sqf => fnc_scriptedExplosive.sqf} (79%) diff --git a/addons/explosives/XEH_preInit.sqf b/addons/explosives/XEH_preInit.sqf index 6f63588491..1281759aad 100644 --- a/addons/explosives/XEH_preInit.sqf +++ b/addons/explosives/XEH_preInit.sqf @@ -28,7 +28,6 @@ PREP(canDefuse); PREP(canDetonate); PREP(defuseExplosive); PREP(detonateExplosive); -PREP(detonateExplosiveTrigger); PREP(dialPhone); PREP(dialingPhone); @@ -53,6 +52,7 @@ PREP(openTimerSetUI); PREP(placeExplosive); PREP(removeFromSpeedDial); +PREP(scriptedExplosive); PREP(selectTrigger); PREP(setupExplosive); PREP(setPosition); diff --git a/addons/explosives/functions/fnc_detonateExplosiveTrigger.sqf b/addons/explosives/functions/fnc_scriptedExplosive.sqf similarity index 79% rename from addons/explosives/functions/fnc_detonateExplosiveTrigger.sqf rename to addons/explosives/functions/fnc_scriptedExplosive.sqf index e8c34e1350..b4abb204b3 100644 --- a/addons/explosives/functions/fnc_detonateExplosiveTrigger.sqf +++ b/addons/explosives/functions/fnc_scriptedExplosive.sqf @@ -11,8 +11,8 @@ * None * * Example: - * [[charge1, charge2, charge3], -1] call ACE_Explosives_fnc_detonateExplosiveTrigger; - * [[claymore1, claymore2]] call ACE_Explosives_fnc_detonateExplosiveTrigger; + * [[charge1, charge2, charge3], -1] call ACE_Explosives_fnc_scriptedExplosive; + * [[claymore1, claymore2]] call ACE_Explosives_fnc_scriptedExplosive; * * Public: Yes */ From 091c807708e621b88029341cf131f73a6dadda55 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 12 Jan 2016 00:30:03 -0600 Subject: [PATCH 13/30] Restart specatator display if player in unitList Possible fix for #2677 --- addons/spectator/functions/fnc_stageSpectator.sqf | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/addons/spectator/functions/fnc_stageSpectator.sqf b/addons/spectator/functions/fnc_stageSpectator.sqf index 87b2faffa8..926ac008dc 100644 --- a/addons/spectator/functions/fnc_stageSpectator.sqf +++ b/addons/spectator/functions/fnc_stageSpectator.sqf @@ -66,3 +66,13 @@ if !(_set isEqualTo (GETVAR(_unit,GVAR(isStaged),false))) then { ["spectatorStaged",[_set]] call EFUNC(common,localEvent); }; + +//BandAid for #2677 - if player in unitList weird before being staged, weird things can happen +if ((player in GVAR(unitList)) || {ACE_player in GVAR(unitList)}) then { + [] call FUNC(updateUnits); //update list now + if (!(isNull (findDisplay 12249))) then {//If display is open now, close it and restart + ACE_LOGWARNING("Player in unitList, call ace_spectator_fnc_stageSpectator before ace_spectator_fnc_setSpectator"); + ["fixWeirdList", true] call FUNC(interrupt); + [{["fixWeirdList", false] call FUNC(interrupt);}, []] call EFUNC(common,execNextFrame); + }; +}; From 65e981373b4e2029320a6c68b92b1682fb01f1f4 Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Wed, 13 Jan 2016 18:28:36 +0000 Subject: [PATCH 14/30] Store spectator display in a uiNamespace variable This allows me to explicitly close the right display and hopefully fix the interface staying open upon mission end. @Commy2's theory is that perhaps the main display `46` is killed upon mission end, meaning that `findDisplay` can't find the spectator display to close it because the game thinks it doesn't exist. --- addons/spectator/XEH_postInit.sqf | 2 +- addons/spectator/XEH_preInit.sqf | 3 +++ addons/spectator/functions/fnc_handleInterface.sqf | 5 +++-- addons/spectator/functions/fnc_interrupt.sqf | 8 ++++---- addons/spectator/functions/fnc_setSpectator.sqf | 11 ++++++----- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/addons/spectator/XEH_postInit.sqf b/addons/spectator/XEH_postInit.sqf index a9737868a0..79e62966a7 100644 --- a/addons/spectator/XEH_postInit.sqf +++ b/addons/spectator/XEH_postInit.sqf @@ -10,4 +10,4 @@ }] call EFUNC(common,addEventHandler); // Should prevent unending spectator on mission end -addMissionEventHandler ["Ended",{ [false] call FUNC(setSpectator) }]; +addMissionEventHandler ["Ended",{ [QGVAR(EndMission)] call FUNC(interrupt) }]; diff --git a/addons/spectator/XEH_preInit.sqf b/addons/spectator/XEH_preInit.sqf index 13f2ba1708..4b30edbadf 100644 --- a/addons/spectator/XEH_preInit.sqf +++ b/addons/spectator/XEH_preInit.sqf @@ -25,6 +25,9 @@ PREP(updateSpectatableSides); PREP(updateUnits); PREP(updateVisionModes); +// Reset the stored display +SETUVAR(GVAR(interface),displayNull); + // Permanent variables GVAR(availableModes) = [0,1,2]; GVAR(availableSides) = [west,east,resistance,civilian]; diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index ee71685fa2..fcc142a094 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -22,6 +22,7 @@ params ["_mode",["_args",[]]]; switch (toLower _mode) do { case "onload": { _args params ["_display"]; + SETUVAR(GVAR(interface),_display); // Always show interface and hide map upon opening [_display,nil,nil,!GVAR(showInterface),GVAR(showMap)] call FUNC(toggleInterface); @@ -451,13 +452,13 @@ switch (toLower _mode) do { // PFH to re-open display when menu closes [{ - if !(isNull (findDisplay 49)) exitWith {}; + if !(isNull (_this select 0)) exitWith {}; // If still a spectator then re-enter the interface [QGVAR(escape),false] call FUNC(interrupt); [_this select 1] call CBA_fnc_removePerFrameHandler; - },0] call CBA_fnc_addPerFrameHandler; + },0,_dlg] call CBA_fnc_addPerFrameHandler; }; case "zeus": { openCuratorInterface; diff --git a/addons/spectator/functions/fnc_interrupt.sqf b/addons/spectator/functions/fnc_interrupt.sqf index 72bb3eaa32..0826949b30 100644 --- a/addons/spectator/functions/fnc_interrupt.sqf +++ b/addons/spectator/functions/fnc_interrupt.sqf @@ -29,16 +29,16 @@ if (_interrupt) then { }; if (GVAR(interrupts) isEqualTo []) then { - if (isNull (findDisplay 12249)) then { - createDialog QGVAR(interface); + if (isNull (GETUVAR(GVAR(interface),displayNull))) then { + (findDisplay 46) createDisplay QGVAR(interface); [] call FUNC(transitionCamera); }; } else { - if !(isNull (findDisplay 12249)) then { + if !(isNull (GETUVAR(GVAR(interface),displayNull))) then { while {dialog} do { closeDialog 0; }; - (findDisplay 12249) closeDisplay 0; + (GETUVAR(GVAR(interface),displayNull)) closeDisplay 0; }; }; diff --git a/addons/spectator/functions/fnc_setSpectator.sqf b/addons/spectator/functions/fnc_setSpectator.sqf index d8a0219110..0f71cc7343 100644 --- a/addons/spectator/functions/fnc_setSpectator.sqf +++ b/addons/spectator/functions/fnc_setSpectator.sqf @@ -24,7 +24,7 @@ params [["_set",true,[true]], ["_force",true,[true]]]; // Only clients can be spectators -if (!hasInterface) exitWith {}; +if !(hasInterface) exitWith {}; // Exit if no change if (_set isEqualTo GVAR(isSet)) exitWith {}; @@ -76,12 +76,13 @@ if (_set) then { }; [{ + disableSerialization; // Create the display - (findDisplay 46) createDisplay QGVAR(interface); + _display = (findDisplay 46) createDisplay QGVAR(interface); // If not forced, make esc end spectator if (_this) then { - (findDisplay 12249) displayAddEventHandler ["KeyDown", { + _display displayAddEventHandler ["KeyDown", { if (_this select 1 == 1) then { [false] call ace_spectator_fnc_setSpectator; true @@ -101,9 +102,9 @@ if (_set) then { while {dialog} do { closeDialog 0; }; - + // Kill the display - (findDisplay 12249) closeDisplay 0; + (GETUVAR(GVAR(interface),displayNull)) closeDisplay 0; // Terminate camera GVAR(freeCamera) cameraEffect ["terminate", "back"]; From d870a1f448178651a2e839d49ec283a639f67de9 Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Wed, 13 Jan 2016 19:03:01 +0000 Subject: [PATCH 15/30] Fix nil spectator Draw3D event handler index Minor oversight introduced in pabst's fix for #2989, the icon handler is a mission event handler that isn't self terminating so the index needs to be preserved until after it is removed via `removeMissionEventHandler`. It is safe to let the `onUnload` event take care of that (and preferable so that icons disappear while temporarily closed). --- addons/spectator/functions/fnc_setSpectator.sqf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/spectator/functions/fnc_setSpectator.sqf b/addons/spectator/functions/fnc_setSpectator.sqf index 0f71cc7343..9804bab4c4 100644 --- a/addons/spectator/functions/fnc_setSpectator.sqf +++ b/addons/spectator/functions/fnc_setSpectator.sqf @@ -102,7 +102,7 @@ if (_set) then { while {dialog} do { closeDialog 0; }; - + // Kill the display (GETUVAR(GVAR(interface),displayNull)) closeDisplay 0; @@ -131,7 +131,6 @@ if (_set) then { //Kill these PFEH handlers now because the PFEH can run before the `onunload` event is handled GVAR(camHandler) = nil; GVAR(compHandler) = nil; - GVAR(iconHandler) = nil; GVAR(toolHandler) = nil; // Cleanup display variables From 099648b6b6183cccb0f87581d0fbf406cc5a0c62 Mon Sep 17 00:00:00 2001 From: VKing Date: Thu, 14 Jan 2016 18:51:14 +0100 Subject: [PATCH 16/30] Russian translation as suggested --- addons/explosives/stringtable.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/explosives/stringtable.xml b/addons/explosives/stringtable.xml index 728eeb30c1..166428f3d4 100644 --- a/addons/explosives/stringtable.xml +++ b/addons/explosives/stringtable.xml @@ -41,7 +41,7 @@ Detonate All Zünden Alles Detonar Todo - Подрыв Все + Подрыв всех Explosive code: %1 From 1affbd7d2f9e217652a027a7eaa1edab9ffd54f5 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Thu, 14 Jan 2016 17:06:46 -0600 Subject: [PATCH 17/30] Move littler syncedEH install to after settingInit --- addons/medical/XEH_postInit.sqf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/medical/XEH_postInit.sqf b/addons/medical/XEH_postInit.sqf index d833e44740..ce44540b20 100644 --- a/addons/medical/XEH_postInit.sqf +++ b/addons/medical/XEH_postInit.sqf @@ -246,6 +246,9 @@ GVAR(lastHeartBeatSound) = ACE_time; }; ["SettingsInitialized", { + // Networked litter (need to wait for GVAR(litterCleanUpDelay) to be set) + [QGVAR(createLitter), FUNC(handleCreateLitter), GVAR(litterCleanUpDelay)] call EFUNC(common,addSyncedEventHandler); + if (GVAR(level) == 2) exitWith { [ {(((_this select 0) getVariable [QGVAR(bloodVolume), 100]) < 65)}, @@ -276,9 +279,6 @@ GVAR(lastHeartBeatSound) = ACE_time; [ACE_player] call FUNC(itemCheck); }] call EFUNC(common,addEventHandler); -// Networked litter -[QGVAR(createLitter), FUNC(handleCreateLitter), GVAR(litterCleanUpDelay)] call EFUNC(common,addSyncedEventHandler); - if (hasInterface) then { ["PlayerJip", { ACE_LOGINFO("JIP Medical init for player."); From 1affa0dd18b2f704d3985392a418d06da9f0a426 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Thu, 14 Jan 2016 17:42:35 -0600 Subject: [PATCH 18/30] Cleanup multithreading, allow running from any dir --- tools/config_validator.py | 43 ++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/tools/config_validator.py b/tools/config_validator.py index c61d2d7a2b..790734101f 100644 --- a/tools/config_validator.py +++ b/tools/config_validator.py @@ -9,12 +9,11 @@ import os import sys import subprocess import timeit -import threading import time ######## GLOBALS ######### -MAINPREFIX = "z" -PREFIX = "ace_" +MAINPREFIX = "Z" +PREFIX = "ACE" ########################## def Fract_Sec(s): @@ -36,7 +35,7 @@ def CheckPBO(p,makePboArgs,errors): makePboArgs, "-@={}\\{}\\addons\\{}".format(MAINPREFIX,PREFIX.rstrip("_"),p), p, - "{}{}.pbo".format(PREFIX,p) + "{}_{}.pbo".format(PREFIX,p) ], stdin=None, input=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True) except subprocess.CalledProcessError as e: print("!! Problem With {} ret {} !!".format(p, e.returncode)) @@ -44,21 +43,21 @@ def CheckPBO(p,makePboArgs,errors): errors.append(p) else: print(" Checked ok {}".format(p)) - return + return -def fullDump(p): +def fullDump(p): try: subprocess.run([ "makepbo", "-PQGs", #Q Lint only - Gs Check external references and show deRap - P dont pause "-@={}\\{}\\addons\\{}".format(MAINPREFIX,PREFIX.rstrip("_"),p), p, - "{}{}.pbo".format(PREFIX,p) + "{}_{}.pbo".format(PREFIX,p) ], stdin=None, input=None, check=True) - except subprocess.CalledProcessError as e: + except subprocess.CalledProcessError as e: input("Press Enter to continue...") - return - + return + def main(argv): print(""" #################### @@ -68,11 +67,13 @@ def main(argv): start_time = timeit.default_timer() - scriptpath = os.path.realpath(__file__) - projectpath = os.path.dirname(os.path.dirname(scriptpath)) - addonspath = os.path.join(projectpath, "addons") + addonspath = os.path.join("P:\\",MAINPREFIX,PREFIX,"addons") - os.chdir(addonspath) + print("Switching to dir: {}".format(addonspath)) + try: + os.chdir(addonspath) + except: + raise Exception("Failed to switch to addon dir on P:") #Q Lint only - G Check external references - P dont pause (Gs) does full derap makePboArgs = "-PQG" @@ -81,27 +82,19 @@ def main(argv): makePboArgs = "-PQ" errors = [] - + for p in os.listdir(addonspath): path = os.path.join(addonspath, p) if not os.path.isdir(path): continue if p[0] == ".": continue - - # t = threading.Thread(target=CheckPBO, args=(p,makePboArgs,errors)) - # t.start() CheckPBO(p,makePboArgs,errors) - # for t in threading.enumerate(): - # if t is threading.currentThread(): - # continue - # t.join() - d,h,m,s = Fract_Sec(timeit.default_timer() - start_time) print("\n# Done with {0} errrors [took: {1:2}h {2:2}m {3:4.5f}s]".format(len(errors),h,m,s)) - + if (len(errors) > 0): if "full" in argv: input("Dumping Full DeRap: Press Enter to continue...") @@ -109,7 +102,7 @@ def main(argv): fullDump(p) else: print("use 'full' arg to show derap") - + ret = len(errors) print("return {}".format(ret)) return ret From a875d6a87058e52229856b497d895ec050b86dc1 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sat, 16 Jan 2016 08:04:22 -0600 Subject: [PATCH 19/30] Overpressure cleanup and fix distance check --- addons/overpressure/CfgEventHandlers.hpp | 2 +- addons/overpressure/CfgWeapons.hpp | 14 +++++ .../functions/fnc_cacheOverPressureValues.sqf | 53 ++++++------------- .../functions/fnc_fireLauncherBackblast.sqf | 44 +++++++-------- .../functions/fnc_fireOverpressureZone.sqf | 35 ++++++------ .../overpressure/functions/fnc_firedEHBB.sqf | 17 ++++-- .../overpressure/functions/fnc_firedEHOP.sqf | 16 +++--- .../functions/fnc_getDistance.sqf | 11 ++-- .../functions/fnc_overpressureDamage.sqf | 48 ++++++++++------- addons/overpressure/script_component.hpp | 2 + 10 files changed, 127 insertions(+), 115 deletions(-) diff --git a/addons/overpressure/CfgEventHandlers.hpp b/addons/overpressure/CfgEventHandlers.hpp index 6f8dba89bd..c2fdf64560 100644 --- a/addons/overpressure/CfgEventHandlers.hpp +++ b/addons/overpressure/CfgEventHandlers.hpp @@ -14,7 +14,7 @@ class Extended_PostInit_EventHandlers { class Extended_FiredBIS_EventHandlers { class CAManBase { class ADDON { - firedBIS = QUOTE(if (local (_this select 0)) then {_this call FUNC(firedEHBB);};); + clientFiredBIS = QUOTE(_this call FUNC(firedEHBB);); }; }; diff --git a/addons/overpressure/CfgWeapons.hpp b/addons/overpressure/CfgWeapons.hpp index a88fa90894..1f0814a487 100644 --- a/addons/overpressure/CfgWeapons.hpp +++ b/addons/overpressure/CfgWeapons.hpp @@ -49,6 +49,20 @@ class CfgWeapons { GVAR(damage) = 0.85; }; + class cannon_125mm: CannonCore { + GVAR(priority) = 1; + GVAR(angle) = 90; + GVAR(range) = 50; + GVAR(damage) = 0.85; + }; + + class cannon_105mm: CannonCore { + GVAR(priority) = 1; + GVAR(angle) = 90; + GVAR(range) = 50; + GVAR(damage) = 0.85; + }; + class mortar_155mm_AMOS: CannonCore { GVAR(priority) = 1; GVAR(angle) = 90; diff --git a/addons/overpressure/functions/fnc_cacheOverPressureValues.sqf b/addons/overpressure/functions/fnc_cacheOverPressureValues.sqf index 8de8af6375..3f18cb788a 100644 --- a/addons/overpressure/functions/fnc_cacheOverPressureValues.sqf +++ b/addons/overpressure/functions/fnc_cacheOverPressureValues.sqf @@ -1,7 +1,7 @@ /* * Author: joko // Jonas - * - * Handle fire of local launchers + * Cache the shot data for a given weapon/mag/ammo combination. + * Will use the config that has the highest priority. * * Argument: * 0: Weapon @@ -9,68 +9,49 @@ * 2: Ammo * * Return value: - * Array: + * Shot Config : * 0: Angle * 1: Range * 2: Damage * + * Example: + * ["cannon_125mm","Sh_125mm_APFSDS_T_Green","24Rnd_125mm_APFSDS_T_Green"] call ace_overpressure_fnc_cacheOverPressureValues + * + * Public: No */ - #include "script_component.hpp" +#include "script_component.hpp" params ["_weapon", "_ammo", "_magazine"]; TRACE_3("Parameter",_weapon,_magazine,_ammo); -private ["_array", "_type", "_return", "_config" /*, "_priority"*/]; - // get Priority Array from Config -_array = [ +private _array = [ getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(priority)), getNumber (configFile >> "CfgMagazines" >> _magazine >> QGVAR(priority)), getNumber (configFile >> "CfgAmmo" >> _ammo >> QGVAR(priority)) ]; -TRACE_1("Proiroity Array",_array); +(_array call CBA_fnc_findMax) params ["", ["_indexOfMaxPriority", 0, [0]]]; -/* for CBA Upadte 2.1 -_priority = _array call CBA_fnc_findMax; -_type = if (isNil "_priority") then { - 0 -} else { - _priority select 1 -}; -*/ +TRACE_2("Priority Array",_array,_indexOfMaxPriority); -// obsolete as CBA Update 2.1 start -_array params ["_max"]; - -// set Default type -_type = 0; -// get Highest Entry out the the Priority Array -{ - if (_max < _x) then { - _max = _x; - _type = _forEachIndex; - }; -} forEach _array; -// obsolete end - -TRACE_2("Highest Value",_max,_type); // create the Config entry Point -_config = [ +private _config = [ (configFile >> "CfgWeapons" >> _weapon), (configFile >> "CfgMagazines" >> _magazine), (configFile >> "CfgAmmo" >> _ammo) -] select _type; +] select _indexOfMaxPriority; TRACE_1("ConfigPath",_config); // get the Variables out of the Configes and create a array with then -_return = [ +private _return = [ (getNumber (_config >> QGVAR(angle))), (getNumber (_config >> QGVAR(range))), (getNumber (_config >> QGVAR(damage))) ]; -TRACE_1("Return",_return); -_varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine]; +TRACE_2("Return",_varName,_return); + +private _varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine]; missionNameSpace setVariable [format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine], _return]; _return diff --git a/addons/overpressure/functions/fnc_fireLauncherBackblast.sqf b/addons/overpressure/functions/fnc_fireLauncherBackblast.sqf index 4641e36eb8..3b6691fb81 100644 --- a/addons/overpressure/functions/fnc_fireLauncherBackblast.sqf +++ b/addons/overpressure/functions/fnc_fireLauncherBackblast.sqf @@ -1,7 +1,7 @@ /* * Author: commy2 and esteldunedain - * * Handle fire of local launchers + * Called from firedEHBB, only for ace_player with shot that will cause damage * * Arguments: * 0: Unit that fired @@ -14,51 +14,46 @@ * * Return value: * None + * + * Example: + * [player, "launch_RPG32_F", "launch_RPG32_F", "Single", "R_PG32V_F", "RPG32_F", projectile] call ace_overpressure_fnc_fireLauncherBackblast; + * + * Public: No */ - #include "script_component.hpp" -params ["_firer", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile"]; +params ["_firer", "_weapon", "_muzzle", "", "_ammo", "_magazine", "_projectile"]; +TRACE_6("params",_firer,_weapon,_muzzle,_ammo,_magazine,_projectile); -// Prevent AI from causing backblast damage -if !([_firer] call EFUNC(common,isPlayer)) exitWith {}; +private _position = getPosASL _projectile; +private _direction = [0, 0, 0] vectorDiff (vectorDir _projectile); -private ["_position", "_direction"]; - -_position = getPosASL _projectile; -_direction = [0, 0, 0] vectorDiff (vectorDir _projectile); - -private ["_var","_varName","_backblastAngle", "_backblastRange", "_backblastDamage"]; // Bake variable name and check if the variable exists, call the caching function otherwise -_varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine]; -_var = if (isNil _varName) then { +private _varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine]; +private _var = if (isNil _varName) then { [_weapon, _ammo, _magazine] call FUNC(cacheOverPressureValues); } else { missionNameSpace getVariable _varName; }; _var params["_backblastAngle","_backblastRange","_backblastDamage"]; - +TRACE_3("cache",_backblastAngle,_backblastRange,_backblastDamage); // Damage to others -private "_affected"; -_affected = (ASLtoAGL _position) nearEntities ["CAManBase", _backblastRange]; +private _affected = (ASLtoAGL _position) nearEntities ["CAManBase", _backblastRange]; // Let each client handle their own affected units ["overpressure", _affected, [_firer, _position, _direction, _weapon, _magazine, _ammo]] call EFUNC(common,targetEvent); // Damage to the firer -private "_distance"; -_distance = 2 * ([_position, _direction, _backblastRange, _firer] call FUNC(getDistance)); +private _distance = 2 * ([_position, _direction, _backblastRange, _firer] call FUNC(getDistance)); TRACE_1("Distance",_distance); if (_distance < _backblastRange) then { - private ["_alpha", "_beta", "_damage"]; + private _alpha = sqrt (1 - _distance / _backblastRange); + private _beta = sqrt 0.5; - _alpha = sqrt (1 - _distance / _backblastRange); - _beta = sqrt 0.5; - - _damage = _alpha * _beta * _backblastDamage; + private _damage = _alpha * _beta * _backblastDamage; [_damage * 100] call BIS_fnc_bloodEffect; if (isClass (configFile >> "CfgPatches" >> "ACE_Medical") && {([_firer] call EFUNC(medical,hasMedicalEnabled))}) then { @@ -75,8 +70,7 @@ if (_distance < _backblastRange) then { [1,1,0,1] ] call EFUNC(common,addLineToDebugDraw); - private "_ref"; - _ref = _direction call EFUNC(common,createOrthonormalReference); + private _ref = _direction call EFUNC(common,createOrthonormalReference); [ _position, _position vectorAdd (_direction vectorMultiply _backblastRange) vectorAdd ((_ref select 1) vectorMultiply _backblastRange * tan _backblastAngle), [1,1,0,1] diff --git a/addons/overpressure/functions/fnc_fireOverpressureZone.sqf b/addons/overpressure/functions/fnc_fireOverpressureZone.sqf index 02de0eb311..f254151307 100644 --- a/addons/overpressure/functions/fnc_fireOverpressureZone.sqf +++ b/addons/overpressure/functions/fnc_fireOverpressureZone.sqf @@ -1,10 +1,10 @@ /* * Author: commy2 and esteldunedain - * * Handle fire of local vehicle weapons creating overpressure zones + * Called from firedEHOP, only for local vehicles * * Arguments: - * 0: Unit that fired + * 0: Vehicle that fired * 1: Weapon fired * 2: Muzzle * 3: Mode @@ -14,33 +14,35 @@ * * Return value: * None + * + * Example: + * [tank, "cannon_125mm", "cannon_125mm", "player", "Sh_125mm_APFSDS_T_Green", "24Rnd_125mm_APFSDS_T_Green", projectile] call ace_overpressure_fnc_fireOverpressureZone + * + * Public: No */ -//#define DEBUG_MODE_FULL #include "script_component.hpp" -params ["_firer", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile"]; -// Prevent AI from causing overpressure damage -if !([gunner _firer] call EFUNC(common,isPlayer)) exitWith {}; //@todo non-maingun turrets? +params ["_firer", "_weapon", "_muzzle", "", "_ammo", "_magazine", "_projectile"]; +TRACE_6("params",_firer,_weapon,_muzzle,_ammo,_magazine,_projectile); -private ["_position", "_direction"]; +// Prevent AI from causing overpressure damage (NOTE: Vehicle is local, but turret gunner may not be) +if !([gunner _firer] call EFUNC(common,isPlayer)) exitWith {}; -_position = getPosASL _projectile; -_direction = vectorDir _projectile; - -private ["_var", "_varName", "_dangerZoneAngle", "_dangerZoneRange", "_dangerZoneDamage"]; +private _position = getPosASL _projectile; +private _direction = vectorDir _projectile; // Bake variable name and check if the variable exists, call the caching function otherwise -_varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine]; -_var = if (isNil _varName) then { +private _varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine]; +private _var = if (isNil _varName) then { [_weapon, _ammo, _magazine] call FUNC(cacheOverPressureValues); } else { missionNameSpace getVariable _varName; }; _var params["_dangerZoneAngle","_dangerZoneRange","_dangerZoneDamage"]; +TRACE_3("cache",_dangerZoneAngle,_dangerZoneRange,_dangerZoneDamage); // Damage to others -private "_affected"; -_affected = (ASLtoAGL _position) nearEntities ["CAManBase", _dangerZoneRange]; +private _affected = (ASLtoAGL _position) nearEntities ["CAManBase", _dangerZoneRange]; // Let each client handle their own affected units ["overpressure", _affected, [_firer, _position, _direction, _weapon, _magazine, _ammo]] call EFUNC(common,targetEvent); @@ -52,8 +54,7 @@ _affected = (ASLtoAGL _position) nearEntities ["CAManBase", _dangerZoneRange]; [1,0,0,1] ] call EFUNC(common,addLineToDebugDraw); - private "_ref"; - _ref = _direction call EFUNC(common,createOrthonormalReference); + private _ref = _direction call EFUNC(common,createOrthonormalReference); [ _position, _position vectorAdd (_direction vectorMultiply _dangerZoneRange) vectorAdd ((_ref select 1) vectorMultiply _dangerZoneRange * tan _dangerZoneAngle), [1,1,0,1] diff --git a/addons/overpressure/functions/fnc_firedEHBB.sqf b/addons/overpressure/functions/fnc_firedEHBB.sqf index cf2ac31561..6327cc67c9 100644 --- a/addons/overpressure/functions/fnc_firedEHBB.sqf +++ b/addons/overpressure/functions/fnc_firedEHBB.sqf @@ -1,6 +1,5 @@ /* * Author: joko // Jonas - * * Handle fire of local launchers * * Arguments: @@ -14,14 +13,22 @@ * * Return value: * None + * + * Example: + * [player, "launch_RPG32_F", "launch_RPG32_F", "Single", "R_PG32V_F", "RPG32_F", projectile] call ace_overpressure_fnc_firedEHBB; + * + * Public: No */ #include "script_component.hpp" -private ["_damage","_varName"]; -params ["", "_weapon", "", "", "_ammo", "_magazine", ""]; + +params ["_firer", "_weapon", "", "", "_ammo", "_magazine", ""]; + +// Prevent AI from causing backblast damage (fast exit to only run for local players) +if (_firer != ACE_player) exitWith {}; // Bake variable name and check if the variable exists, call the caching function otherwise -_varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine]; -_damage = if (isNil _varName) then { +private _varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine]; +private _damage = if (isNil _varName) then { ([_weapon, _ammo, _magazine] call FUNC(cacheOverPressureValues)) select 2; } else { (missionNameSpace getVariable _varName) select 2; diff --git a/addons/overpressure/functions/fnc_firedEHOP.sqf b/addons/overpressure/functions/fnc_firedEHOP.sqf index 6cec770deb..fbcb034279 100644 --- a/addons/overpressure/functions/fnc_firedEHOP.sqf +++ b/addons/overpressure/functions/fnc_firedEHOP.sqf @@ -1,10 +1,9 @@ /* * Author: joko // Jonas - * - * Handle fire of Other Weapons + * Handle fire of Vehicle Weapons * * Arguments: - * 0: Unit that fired + * 0: Vehicle that fired (XEH will filter only local) * 1: Weapon fired * 2: Muzzle * 3: Mode @@ -14,14 +13,19 @@ * * Return value: * None + * + * Example: + * [tank, "cannon_125mm", "cannon_125mm", "player", "Sh_125mm_APFSDS_T_Green", "24Rnd_125mm_APFSDS_T_Green", projectile] call ace_overpressure_fnc_firedEHOP + * + * Public: No */ #include "script_component.hpp" -private ["_damage","_varName"]; + params ["", "_weapon", "", "", "_ammo", "_magazine", ""]; // Bake variable name and check if the variable exists, call the caching function otherwise -_varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine]; -_damage = if (isNil _varName) then { +private _varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine]; +private _damage = if (isNil _varName) then { ([_weapon, _ammo, _magazine] call FUNC(cacheOverPressureValues)) select 2; } else { (missionNameSpace getVariable _varName) select 2; diff --git a/addons/overpressure/functions/fnc_getDistance.sqf b/addons/overpressure/functions/fnc_getDistance.sqf index cabdd267fa..341da388ca 100644 --- a/addons/overpressure/functions/fnc_getDistance.sqf +++ b/addons/overpressure/functions/fnc_getDistance.sqf @@ -1,6 +1,5 @@ /* * Author: commy2 and esteldunedain - * * Calculate the distance to the first intersection of a line * * Arguments: @@ -15,11 +14,12 @@ * Example: * [[1823.41,5729.05,6.66627], [-0.953255,0.109689,-0.281554], 15, ace_player] call ace_overpressure_fnc_getDistance * + * Public: No */ #include "script_component.hpp" params ["_posASL", "_direction", "_maxDistance", "_shooter"]; -TRACE_3("params",_posASL,_direction,_maxDistance); +TRACE_4("params",_posASL,_direction,_maxDistance, _shooter); private _intersections = lineIntersectsSurfaces [_posASL, _posASL vectorAdd (_direction vectorMultiply _maxDistance), _shooter, objNull, true, 99]; @@ -29,9 +29,10 @@ private _distance = 999; { _x params ["_intersectPosASL", "_surfaceNormal", "_intersectObject"]; - - //Hit something solid that can reflect - (Static covers Building) - if ((isNull _intersectObject) || {(_intersectObject isKindOf "Static") || {_intersectObject isKindOf "AllVehicles"}}) exitWith { + TRACE_3("Intersect",_intersectPosASL,_surfaceNormal,_intersectObject); + + //Hit something solid that can reflect - (Static covers Building) [Need to manually filter out _shoot for FFV shots] + if ((isNull _intersectObject) || {(_intersectObject != _shooter) && {(_intersectObject isKindOf "Static") || {_intersectObject isKindOf "AllVehicles"}}}) exitWith { _distance = _posASL vectorDistance _intersectPosASL; TRACE_3("hit solid object",_distance,_intersectObject,typeOf _intersectObject); diff --git a/addons/overpressure/functions/fnc_overpressureDamage.sqf b/addons/overpressure/functions/fnc_overpressureDamage.sqf index b1c8a5c574..3b8d4ea6f2 100644 --- a/addons/overpressure/functions/fnc_overpressureDamage.sqf +++ b/addons/overpressure/functions/fnc_overpressureDamage.sqf @@ -1,56 +1,56 @@ /* * Author: commy2 and esteldunedain - * * Calculate and apply backblast damage to potentially affected local units + * Handles the "overpressure" event. * * Argument: * 0: Unit that fired * 1: Pos ASL of the projectile - * 2: Direction of the projectile + * 2: Direction of the projectile (reversed for launcher backblast) * 3: Weapon fired * 4: Magazine * 5: Ammo * * Return value: * None + * + * Example: + * [tank, [1727.57,5786.15,7.24899], [-0.982474,-0.185998,-0.0122501], "cannon_125mm", "24Rnd_125mm_APFSDS_T_Green", "Sh_125mm_APFSDS_T_Green"] call ace_overpressure_fnc_overpressureDamage + * + * Public: No */ #include "script_component.hpp" -private ["_var","_overpressureAngle", "_overpressureRange", "_overpressureDamage"]; params ["_firer", "_posASL", "_direction", "_weapon", "_magazine", "_ammo"]; // Bake variable name and check if the variable exists, call the caching function otherwise -_varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine]; -_var = if (isNil _varName) then { +private _varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine]; +private _var = if (isNil _varName) then { [_weapon, _ammo, _magazine] call FUNC(cacheOverPressureValues); } else { missionNameSpace getVariable _varName; }; _var params["_overpressureAngle","_overpressureRange","_overpressureDamage"]; - -TRACE_4("Parameters:",_overpressureAngle,_overpressureRange,_overpressureDamage,_weapon); +TRACE_3("cache",_overpressureAngle,_overpressureRange,_overpressureDamage); { if (local _x && {_x != _firer} && {vehicle _x == _x}) then { - private ["_targetPositionASL", "_relativePosition", "_axisDistance", "_distance", "_angle", "_line", "_line2"]; + private _targetPositionASL = eyePos _x; + private _relativePosition = _targetPositionASL vectorDiff _posASL; + private _axisDistance = _relativePosition vectorDotProduct _direction; + private _distance = vectorMagnitude _relativePosition; + private _angle = acos (_axisDistance / _distance); - _targetPositionASL = eyePos _x; - _relativePosition = _targetPositionASL vectorDiff _posASL; - _axisDistance = _relativePosition vectorDotProduct _direction; - _distance = vectorMagnitude _relativePosition; - _angle = acos (_axisDistance / _distance); - - _line = [_posASL, _targetPositionASL, _firer, _x]; - _line2 = [_posASL, _targetPositionASL]; + private _line = [_posASL, _targetPositionASL, _firer, _x]; + private _line2 = [_posASL, _targetPositionASL]; TRACE_4("Affected:",_x,_axisDistance,_distance,_angle); if (_angle < _overpressureAngle && {_distance < _overpressureRange} && {!lineIntersects _line} && {!terrainIntersectASL _line2}) then { - private ["_alpha", "_beta", "_damage"]; - _alpha = sqrt (1 - _distance / _overpressureRange); - _beta = sqrt (1 - _angle / _overpressureAngle); + private _alpha = sqrt (1 - _distance / _overpressureRange); + private _beta = sqrt (1 - _angle / _overpressureAngle); - _damage = _alpha * _beta * _overpressureDamage; + private _damage = _alpha * _beta * _overpressureDamage; // If the target is the ACE_player if (_x == ACE_player) then {[_damage * 100] call BIS_fnc_bloodEffect}; @@ -60,6 +60,14 @@ TRACE_4("Parameters:",_overpressureAngle,_overpressureRange,_overpressureDamage, } else { _x setDamage (damage _x + _damage); }; + + #ifdef DEBUG_MODE_FULL + //Shows damage lines in green + [ _posASL, + _targetPositionASL, + [0,1,0,1] + ] call EFUNC(common,addLineToDebugDraw); + #endif }; }; } forEach ((ASLtoAGL _posASL) nearEntities ["CAManBase", _overpressureRange]); diff --git a/addons/overpressure/script_component.hpp b/addons/overpressure/script_component.hpp index fbe7cd1238..2ede0c3ec3 100644 --- a/addons/overpressure/script_component.hpp +++ b/addons/overpressure/script_component.hpp @@ -1,6 +1,8 @@ #define COMPONENT overpressure #include "\z\ace\addons\main\script_mod.hpp" +// #define DEBUG_MODE_FULL + #ifdef DEBUG_ENABLED_OVERPRESSURE #define DEBUG_MODE_FULL #endif From 893c6658a52610b7d7da41cb5c0f6bf32caa55b0 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sat, 16 Jan 2016 17:29:57 -0600 Subject: [PATCH 20/30] Fix debug msg order, re-add local check on eh --- addons/overpressure/CfgEventHandlers.hpp | 2 +- addons/overpressure/functions/fnc_cacheOverPressureValues.sqf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/overpressure/CfgEventHandlers.hpp b/addons/overpressure/CfgEventHandlers.hpp index c2fdf64560..472c253f7d 100644 --- a/addons/overpressure/CfgEventHandlers.hpp +++ b/addons/overpressure/CfgEventHandlers.hpp @@ -14,7 +14,7 @@ class Extended_PostInit_EventHandlers { class Extended_FiredBIS_EventHandlers { class CAManBase { class ADDON { - clientFiredBIS = QUOTE(_this call FUNC(firedEHBB);); + clientFiredBIS = QUOTE(if (local (_this select 0)) then {_this call FUNC(firedEHBB);};); }; }; diff --git a/addons/overpressure/functions/fnc_cacheOverPressureValues.sqf b/addons/overpressure/functions/fnc_cacheOverPressureValues.sqf index 3f18cb788a..f2687aec26 100644 --- a/addons/overpressure/functions/fnc_cacheOverPressureValues.sqf +++ b/addons/overpressure/functions/fnc_cacheOverPressureValues.sqf @@ -49,9 +49,9 @@ private _return = [ (getNumber (_config >> QGVAR(range))), (getNumber (_config >> QGVAR(damage))) ]; -TRACE_2("Return",_varName,_return); private _varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine]; missionNameSpace setVariable [format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine], _return]; +TRACE_2("Return",_varName,_return); _return From 35e6a181b52b04c60e2173d0a0ecdf63b0a87561 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sat, 16 Jan 2016 17:48:58 -0600 Subject: [PATCH 21/30] opps --- addons/overpressure/functions/fnc_cacheOverPressureValues.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/overpressure/functions/fnc_cacheOverPressureValues.sqf b/addons/overpressure/functions/fnc_cacheOverPressureValues.sqf index f2687aec26..273843ce8f 100644 --- a/addons/overpressure/functions/fnc_cacheOverPressureValues.sqf +++ b/addons/overpressure/functions/fnc_cacheOverPressureValues.sqf @@ -51,7 +51,7 @@ private _return = [ ]; private _varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine]; -missionNameSpace setVariable [format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine], _return]; +missionNameSpace setVariable [_varName, _return]; TRACE_2("Return",_varName,_return); _return From 48a1ddd401ab5c5973aba9611291f83fe04184bf Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sat, 16 Jan 2016 21:58:59 -0600 Subject: [PATCH 22/30] #3166 - Fix Vehicle inventory is not locked --- addons/vehiclelock/functions/fnc_onOpenInventory.sqf | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/vehiclelock/functions/fnc_onOpenInventory.sqf b/addons/vehiclelock/functions/fnc_onOpenInventory.sqf index 5db2cbebe0..62be76e0fb 100644 --- a/addons/vehiclelock/functions/fnc_onOpenInventory.sqf +++ b/addons/vehiclelock/functions/fnc_onOpenInventory.sqf @@ -37,6 +37,12 @@ if (GVAR(LockVehicleInventory) && //if setting not enabled _handeled = true; //Just opens a dummy groundContainer (so the player can still see their own inventory) ACE_player action ["Gear", objNull]; + + //As of right now arma doesn't seem to be respecting this anymore, delaying a frame seems to work. + [{ + TRACE_1("delaying a frame", ace_player); + ACE_player action ["Gear", objNull]; + }, []] call EFUNC(common,execNextFrame); }; _handeled From a5c6c5579f2789789144408f6a0733513f3b6a9d Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sun, 17 Jan 2016 12:12:05 -0600 Subject: [PATCH 23/30] #3175 - Javelin - Fix zeus RC after switchCamera --- addons/javelin/functions/fnc_onOpticDraw.sqf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/javelin/functions/fnc_onOpticDraw.sqf b/addons/javelin/functions/fnc_onOpticDraw.sqf index 8be68be5b5..473e0603ec 100644 --- a/addons/javelin/functions/fnc_onOpticDraw.sqf +++ b/addons/javelin/functions/fnc_onOpticDraw.sqf @@ -65,6 +65,10 @@ _newTarget = objNull; // Bail on fast movement if ((velocity ACE_player) distance [0,0,0] > 0.5 && {cameraView == "GUNNER"} && {cameraOn == ACE_player}) exitWith { // keep it steady. ACE_player switchCamera "INTERNAL"; + if (player != ACE_player) then { + TRACE_2("Zeus, manually reseting RC after switchCamera",player,ACE_player); + player remotecontrol ACE_player; + }; }; // Refresh the firemode From 67087d7c88b0c1b5b659f6c4fcb7b2b9523fb1da Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Mon, 18 Jan 2016 00:27:19 -0600 Subject: [PATCH 24/30] Capitalization --- addons/javelin/functions/fnc_onOpticDraw.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/javelin/functions/fnc_onOpticDraw.sqf b/addons/javelin/functions/fnc_onOpticDraw.sqf index 473e0603ec..f561806eaa 100644 --- a/addons/javelin/functions/fnc_onOpticDraw.sqf +++ b/addons/javelin/functions/fnc_onOpticDraw.sqf @@ -67,7 +67,7 @@ if ((velocity ACE_player) distance [0,0,0] > 0.5 && {cameraView == "GUNNER"} && ACE_player switchCamera "INTERNAL"; if (player != ACE_player) then { TRACE_2("Zeus, manually reseting RC after switchCamera",player,ACE_player); - player remotecontrol ACE_player; + player remoteControl ACE_player; }; }; From 569179e0bf7057c8c739f07ae8505a98387d0e3f Mon Sep 17 00:00:00 2001 From: VKing Date: Mon, 18 Jan 2016 14:59:38 +0100 Subject: [PATCH 25/30] Add the PSO-1M2-1 windage adjust --- optionals/compat_rhs_afrf3/CfgWeapons.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/optionals/compat_rhs_afrf3/CfgWeapons.hpp b/optionals/compat_rhs_afrf3/CfgWeapons.hpp index 32c1f590c5..bbd0ce6d6c 100644 --- a/optionals/compat_rhs_afrf3/CfgWeapons.hpp +++ b/optionals/compat_rhs_afrf3/CfgWeapons.hpp @@ -54,6 +54,12 @@ class CfgWeapons { ACE_ScopeAdjust_VerticalIncrement = 0.0; ACE_ScopeAdjust_HorizontalIncrement = 0.5; }; + class rhs_acc_pso1m21: rhs_acc_sniper_base { + ACE_ScopeAdjust_Vertical[] = { 0, 0 }; + ACE_ScopeAdjust_Horizontal[] = { -10, 10 }; + ACE_ScopeAdjust_VerticalIncrement = 0.0; + ACE_ScopeAdjust_HorizontalIncrement = 0.5; + }; class Launcher_Base_F; class rhs_weap_rpg7: Launcher_Base_F { @@ -79,4 +85,4 @@ class CfgWeapons { ace_hearing_protection = 0.5; ace_hearing_lowerVolume = 0.60; }; -}; \ No newline at end of file +}; From 2af3d9e7699804af2207ddf26fd9f628655c308c Mon Sep 17 00:00:00 2001 From: VKing Date: Mon, 18 Jan 2016 16:16:53 +0100 Subject: [PATCH 26/30] Don't show adjustment or click sound if the adjustment doesn't happen --- addons/scopes/functions/fnc_applyScopeAdjustment.sqf | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/scopes/functions/fnc_applyScopeAdjustment.sqf b/addons/scopes/functions/fnc_applyScopeAdjustment.sqf index fbd3e1b636..7fdb671859 100644 --- a/addons/scopes/functions/fnc_applyScopeAdjustment.sqf +++ b/addons/scopes/functions/fnc_applyScopeAdjustment.sqf @@ -32,6 +32,7 @@ if (isNil "_adjustment") then { }; _adjustmentDifference = (_adjustment select _weaponIndex) vectorDiff [_elevation, _windage, _zero]; +if (_adjustmentDifference isEqualTo [0,0,0]) exitWith {false}; // Don't coninue if no adjustment is made _adjustment set [_weaponIndex, [_elevation, _windage, _zero]]; [_unit, QGVAR(Adjustment), _adjustment, 0.5] call EFUNC(common,setVariablePublic); From 0a91dfa7b25d7f75825f1e86eb06143ab61269e2 Mon Sep 17 00:00:00 2001 From: esteldunedain Date: Mon, 18 Jan 2016 13:23:55 -0300 Subject: [PATCH 27/30] Do not add or remove earplugs if gear should be preserved. Fix #3180. --- addons/hearing/functions/fnc_handleRespawn.sqf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/hearing/functions/fnc_handleRespawn.sqf b/addons/hearing/functions/fnc_handleRespawn.sqf index 527d5d6b16..5bad68761c 100644 --- a/addons/hearing/functions/fnc_handleRespawn.sqf +++ b/addons/hearing/functions/fnc_handleRespawn.sqf @@ -20,6 +20,9 @@ TRACE_2("params",_unit,typeOf _unit); if (!local _unit) exitWith {}; //XEH should only be called on local units +//Do not add or remove earplugs if gear should be preserved +if (missionNamespace getVariable [QEGVAR(respawn,SavePreDeathGear), false]) exitWith {}; + private _respawn = [0] call BIS_fnc_missionRespawnType; //if respawn is not Group or side: From f599542b8ee705c0c9e0a2c48f466c73668e5623 Mon Sep 17 00:00:00 2001 From: esteldunedain Date: Tue, 19 Jan 2016 00:18:01 -0300 Subject: [PATCH 28/30] gforces cleanup. Close #2130 --- addons/gforces/XEH_postInit.sqf | 2 +- .../functions/fnc_pfhUpdateGForces.sqf | 66 +++++++------------ 2 files changed, 25 insertions(+), 43 deletions(-) diff --git a/addons/gforces/XEH_postInit.sqf b/addons/gforces/XEH_postInit.sqf index a97822be8c..23abe8e826 100644 --- a/addons/gforces/XEH_postInit.sqf +++ b/addons/gforces/XEH_postInit.sqf @@ -12,4 +12,4 @@ GVAR(GForces_CC) ppEffectCommit 0.4; GVAR(lastUpdateTime) = 0; GVAR(oldVel) = [0,0,0]; -[FUNC(pfhUpdateGForces), 0, []] call CBA_fnc_addPerFrameHandler; +[DFUNC(pfhUpdateGForces), 0, []] call CBA_fnc_addPerFrameHandler; diff --git a/addons/gforces/functions/fnc_pfhUpdateGForces.sqf b/addons/gforces/functions/fnc_pfhUpdateGForces.sqf index ee1bc8ca4a..dd569781e7 100644 --- a/addons/gforces/functions/fnc_pfhUpdateGForces.sqf +++ b/addons/gforces/functions/fnc_pfhUpdateGForces.sqf @@ -13,34 +13,18 @@ */ #include "script_component.hpp" -private ["_interval", "_player", "_newVel", "_accel", "_currentGForce", "_average", "_sum", "_classCoef", "_suitCoef", "_gBlackOut", "_gRedOut", "_g", "_gBO", "_coef", "_strength"]; - EXPLODE_2_PVT(_this,_params,_pfhId); -_interval = ACE_time - GVAR(lastUpdateTime); - -// Update the g-forces at constant game time intervals -if (_interval < INTERVAL) exitWith {}; - -if (isNull ACE_player) exitWith {}; - -if !(alive ACE_player) exitWith {}; - +// Update the g-forces at constant mission time intervals (taking accTime into account) +if ((ACE_time - GVAR(lastUpdateTime)) < INTERVAL) exitWith {}; GVAR(lastUpdateTime) = ACE_time; -/*if !(vehicle ACE_player isKindOf "Air") exitWith { - GVAR(GForces) = []; - GVAR(GForces_Index) = 0; - waitUntil {sleep 5; (vehicle _player isKindOf "Air") or ((getPos _player select 2) > 5)}; -};*/ - -_newVel = velocity (vehicle ACE_player); - -_accel = ((_newVel vectorDiff GVAR(oldVel)) vectorMultiply (1 / INTERVAL)) vectorAdd [0, 0, 9.8]; -_currentGForce = (_accel vectorDotProduct vectorUp (vehicle ACE_player)) / 9.8; +if (isNull ACE_player || !(alive ACE_player)) exitWith {}; +private _newVel = velocity (vehicle ACE_player); +private _accel = ((_newVel vectorDiff GVAR(oldVel)) vectorMultiply (1 / INTERVAL)) vectorAdd [0, 0, 9.8]; // Cap maximum G's to +- 10 to avoid g-effects when the update is low fps. -_currentGForce = (_currentGForce max -10) min 10; +private _currentGForce = (((_accel vectorDotProduct vectorUp (vehicle ACE_player)) / 9.8) max -10) min 10; GVAR(GForces) set [GVAR(GForces_Index), _currentGForce]; GVAR(GForces_Index) = (GVAR(GForces_Index) + 1) % round (AVERAGEDURATION / INTERVAL); @@ -63,31 +47,27 @@ GVAR(oldVel) = _newVel; * Effects and camera shake start 30% the limit value, and build gradually */ -_average = 0; -if (count GVAR(GForces) > 0) then { - _sum = 0; - { - _sum = _sum + _x; - } forEach GVAR(GForces); - _average = _sum / (count GVAR(GForces)); +private _average = 0; +private _count = { + _average = _average + _x; + true +} count GVAR(GForces); + +if (_count > 0) then { + _average = _average / _count; }; -_classCoef = ACE_player getVariable ["ACE_GForceCoef", - getNumber (configFile >> "CfgVehicles" >> (typeOf ACE_player) >> "ACE_GForceCoef")]; -_suitCoef = if ((uniform ACE_player) != "") then { - getNumber (configFile >> "CfgWeapons" >> (uniform ACE_player) >> "ACE_GForceCoef") +private _classCoef = (ACE_player getVariable ["ACE_GForceCoef", + getNumber (configFile >> "CfgVehicles" >> (typeOf ACE_player) >> "ACE_GForceCoef")]) max 0.001; +private _suitCoef = if ((uniform ACE_player) != "") then { + (getNumber (configFile >> "CfgWeapons" >> (uniform ACE_player) >> "ACE_GForceCoef")) max 0.001 } else { 1 }; -//Fix "Error Zero divisor" -if (_classCoef == 0) then {_classCoef = 0.001}; -if (_suitCoef == 0) then {_suitCoef = 0.001}; +private _gBlackOut = MAXVIRTUALG / _classCoef + MAXVIRTUALG / _suitCoef - MAXVIRTUALG; -_gBlackOut = MAXVIRTUALG / _classCoef + MAXVIRTUALG / _suitCoef - MAXVIRTUALG; -_gRedOut = MINVIRTUALG / _classCoef; - -// @todo: Sort the interaction with medical +// Unconsciousness if ((_average > _gBlackOut) and {isClass (configFile >> "CfgPatches" >> "ACE_Medical") and {!(ACE_player getVariable ["ACE_isUnconscious", false])}}) then { [ACE_player, true, (10 + floor(random 5))] call EFUNC(medical,setUnconscious); }; @@ -96,12 +76,14 @@ GVAR(GForces_CC) ppEffectAdjust [1,1,0,[0,0,0,1],[0,0,0,0],[1,1,1,1],[10,10,0,0, if !(ACE_player getVariable ["ACE_isUnconscious", false]) then { if (_average > 0.30 * _gBlackOut) then { - _strength = ((_average - 0.30 * _gBlackOut) / (0.70 * _gBlackOut)) max 0; + private _strength = ((_average - 0.30 * _gBlackOut) / (0.70 * _gBlackOut)) max 0; GVAR(GForces_CC) ppEffectAdjust [1,1,0,[0,0,0,1],[0,0,0,0],[1,1,1,1],[2*(1-_strength),2*(1-_strength),0,0,0,0.1,0.5]]; addCamShake [_strength, 1, 15]; } else { + private _gRedOut = MINVIRTUALG / _classCoef; + if (_average < -0.30 * _gRedOut) then { - _strength = ((abs _average - 0.30 * _gRedOut) / (0.70 * _gRedOut)) max 0; + private _strength = ((abs _average - 0.30 * _gRedOut) / (0.70 * _gRedOut)) max 0; GVAR(GForces_CC) ppEffectAdjust [1,1,0,[1,0.2,0.2,1],[0,0,0,0],[1,1,1,1],[2*(1-_strength),2*(1-_strength),0,0,0,0.1,0.5]]; addCamShake [_strength / 1.5, 1, 15]; }; From 0ea1c0c03ff60656971bde286a1d48dd51c3cada Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 19 Jan 2016 08:31:52 -0600 Subject: [PATCH 29/30] Cleanup non-working code, and documentation --- addons/vehiclelock/functions/fnc_onOpenInventory.sqf | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/vehiclelock/functions/fnc_onOpenInventory.sqf b/addons/vehiclelock/functions/fnc_onOpenInventory.sqf index 62be76e0fb..17682c72de 100644 --- a/addons/vehiclelock/functions/fnc_onOpenInventory.sqf +++ b/addons/vehiclelock/functions/fnc_onOpenInventory.sqf @@ -35,12 +35,11 @@ if (GVAR(LockVehicleInventory) && //if setting not enabled playSound "ACE_Sound_Click"; //don't open the vehicles inventory _handeled = true; - //Just opens a dummy groundContainer (so the player can still see their own inventory) - ACE_player action ["Gear", objNull]; - //As of right now arma doesn't seem to be respecting this anymore, delaying a frame seems to work. + // As of 1.54 the action needs to be delayed a frame to work, which used not to be the case [{ TRACE_1("delaying a frame", ace_player); + //Just opens a dummy groundContainer (so the player can still see their own inventory) ACE_player action ["Gear", objNull]; }, []] call EFUNC(common,execNextFrame); }; From 6d6cbec5ef2970c5f5740ce08a23b83cd19be3b5 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 19 Jan 2016 09:02:51 -0600 Subject: [PATCH 30/30] Add missing FUNC to FCS key (Rangefinders) #3160 --- addons/fcs/functions/fnc_keyDown.sqf | 2 +- addons/fcs/functions/fnc_keyUp.sqf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/fcs/functions/fnc_keyDown.sqf b/addons/fcs/functions/fnc_keyDown.sqf index a34233bc91..488611fde1 100644 --- a/addons/fcs/functions/fnc_keyDown.sqf +++ b/addons/fcs/functions/fnc_keyDown.sqf @@ -16,7 +16,7 @@ params ["_vehicle", "_turret"]; private _distance = call FUNC(getRange); -call (updateRangeHUD); +call FUNC(updateRangeHUD); if !(!GVAR(enabled) && FUNC(canUseFCS)) exitWith {}; diff --git a/addons/fcs/functions/fnc_keyUp.sqf b/addons/fcs/functions/fnc_keyUp.sqf index ebbd6e3a06..e729a48b86 100644 --- a/addons/fcs/functions/fnc_keyUp.sqf +++ b/addons/fcs/functions/fnc_keyUp.sqf @@ -17,7 +17,7 @@ params ["_vehicle", "_turret", "_distance", ["_showHint", false], ["_playSound", private _turretConfig = [configFile >> "CfgVehicles" >> typeOf _vehicle, _turret] call EFUNC(common,getTurretConfigPath); -call (updateRangeHUD); +call FUNC(updateRangeHUD); if (isNil "_distance") then { _distance = call FUNC(getRange);