diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..f6f23b8d1b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + diff --git a/TO_MERGE/agm/Captives/agm_cabletie.p3d b/TO_MERGE/agm/Captives/agm_cabletie.p3d deleted file mode 100644 index e0804b8c5f..0000000000 Binary files a/TO_MERGE/agm/Captives/agm_cabletie.p3d and /dev/null differ diff --git a/TO_MERGE/agm/Captives/clientInit.sqf b/TO_MERGE/agm/Captives/clientInit.sqf deleted file mode 100644 index bb7c5ebbb0..0000000000 --- a/TO_MERGE/agm/Captives/clientInit.sqf +++ /dev/null @@ -1,3 +0,0 @@ -// by commy2 - -[missionNamespace, "playerChanged", {_this call AGM_Captives_fnc_handlePlayerChanged}] call AGM_Core_fnc_addCustomEventhandler; diff --git a/TO_MERGE/agm/Captives/config.cpp b/TO_MERGE/agm/Captives/config.cpp deleted file mode 100644 index 56b3f8bc32..0000000000 --- a/TO_MERGE/agm/Captives/config.cpp +++ /dev/null @@ -1,363 +0,0 @@ -class CfgPatches { - class AGM_Captives { - units[] = {}; - weapons[] = {"AGM_CableTie"}; - requiredVersion = 0.60; - requiredAddons[] = {AGM_Core, AGM_Interaction}; - version = "0.95"; - versionStr = "0.95"; - versionAr[] = {0,95,0}; - author[] = {"commy2", "KoffeinFlummi"}; - authorUrl = "https://github.com/commy2/"; - }; -}; - -class CfgFunctions { - class AGM_Captives { - class AGM_Captives { - file = "\AGM_Captives\functions"; - class canFriskPerson; - class canLoadCaptive; - class canUnloadCaptive; - class escortCaptive; - class handleGetOut; - class handleKnockedOut; - class handlePlayerChanged; - class handleWokeUp; - class initPost; - class initUnit; - class loadCaptive; - class openFriskMenu; - class setCaptive; - class surrender; - class unloadCaptive; - }; - }; -}; - -//release escorted captive when entering a vehicle -class Extended_GetIn_EventHandlers { - class All { - class AGM_Captives_AutoDetachCaptive { - getIn = "if (local (_this select 2) && {(_this select 2) getVariable ['AGM_isEscorting', false]}) then {(_this select 2) setVariable ['AGM_isEscorting', false, true]}"; - }; - }; -}; - -//reset captive animation after leaving vehicle -class Extended_GetOut_EventHandlers { - class All { - class AGM_Captives_LeaveVehicle { - getOut = "if (local (_this select 2) && {(_this select 2) getVariable ['AGM_isCaptive', false]}) then {_this call AGM_Captives_fnc_handleGetOut}"; - }; - }; -}; - -//reset captivity and escorting status when getting killed -class Extended_Killed_EventHandlers { - class CAManBase { - class AGM_Captives_AutoDetachCaptive { - killed = "if ((_this select 0) getVariable ['AGM_isCaptive', false]) then {(_this select 0) setVariable ['AGM_isCaptive', false, true]}; if ((_this select 0) getVariable ['AGM_isEscorting', false]) then {(_this select 0) setVariable ['AGM_isEscorting', false, true]};"; - }; - }; -}; - -//handle captive and unconsciousness state -class Extended_Init_EventHandlers { - class CAManBase { - class AGM_Captives_AutoDetachCaptive { - init = "_this call AGM_Captives_fnc_initUnit"; - }; - }; -}; - -//mission start -class Extended_InitPost_EventHandlers { - class CAManBase { - class AGM_Captives_InitPost { - init = "if (local (_this select 0)) then {_this call AGM_Captives_fnc_initPost};"; - }; - }; -}; - -class Extended_PostInit_EventHandlers { - class AGM_Captives { - clientInit = "call compile preprocessFileLineNumbers '\AGM_Captives\clientInit.sqf'"; - }; -}; - -class AGM_Core_canInteractConditions { - class AGM_Interaction_isNotEscorting { - condition = "!(_player getVariable ['AGM_isEscorting', false])"; - }; - class AGM_Interaction_isNotCaptive { - condition = "!(_player getVariable ['AGM_isCaptive', false])"; - }; - class AGM_Interaction_isNotSurrendering { - condition = "!(_player getVariable ['AGM_isSurrender', false])"; - }; -}; - -class CfgVehicles { - class Man; - class CAManBase: Man { - class AGM_Actions { - class AGM_SetCaptive { - displayName = "$STR_AGM_Captives_SetCaptive"; - distance = 4; - condition = "'AGM_CableTie' in items _player && {alive _target} && {!(_target getVariable ['AGM_isCaptive', false])}"; - statement = "player removeItem 'AGM_CableTie'; [_target, true] call AGM_Captives_fnc_setCaptive"; - showDisabled = 0; - priority = 2.4; - icon = "\AGM_Captives\UI\handcuff_ca.paa"; - hotkey = "C"; - }; - class AGM_ReleaseCaptive { - displayName = "$STR_AGM_Captives_ReleaseCaptive"; - distance = 4; - condition = "_target getVariable ['AGM_isCaptive', false] && {isNull (attachedTo _target)}"; - statement = "[_target, false] call AGM_Captives_fnc_setCaptive"; - exceptions[] = {"AGM_Interaction_isNotEscorting"}; - showDisabled = 0; - priority = 2.4; - icon = "\AGM_Captives\UI\handcuff_ca.paa"; - hotkey = "R"; - }; - class AGM_EscortCaptive { - displayName = "$STR_AGM_Captives_EscortCaptive"; - distance = 4; - condition = "_target getVariable ['AGM_isCaptive', false] && {isNull (attachedTo _target)} && {alive _target} && {!(_target getVariable ['AGM_isUnconscious', false])}"; - statement = "[_target, true] call AGM_Captives_fnc_escortCaptive"; - exceptions[] = {"AGM_Interaction_isNotEscorting"}; - showDisabled = 0; - icon = "\AGM_Captives\UI\captive_ca.paa"; - priority = 2.3; - hotkey = "E"; - }; - class AGM_StopEscorting { - displayName = "$STR_AGM_Captives_StopEscorting"; - distance = 4; - condition = "_target getVariable ['AGM_isCaptive', false] && {_target in attachedObjects _player}"; - statement = "[_target, false] call AGM_Captives_fnc_escortCaptive"; - exceptions[] = {"AGM_Interaction_isNotEscorting"}; - showDisabled = 0; - icon = "\AGM_Captives\UI\captive_ca.paa"; - priority = 2.3; - hotkey = "E"; - }; - class AGM_LoadCaptive { - displayName = "$STR_AGM_Captives_LoadCaptive"; - distance = 4; - condition = "[_player, _target, objNull] call AGM_Captives_fnc_canLoadCaptive"; - statement = "[_player, _target, objNull] call AGM_Captives_fnc_loadCaptive"; - exceptions[] = {"AGM_Interaction_isNotEscorting"}; - showDisabled = 0; - icon = "\AGM_Captives\UI\captive_ca.paa"; - priority = 2.2; - hotkey = "L"; - }; - class AGM_FriskPerson { - displayName = "$STR_AGM_Captives_FriskPerson"; - distance = 2; - condition = "[_player, _target] call AGM_Captives_fnc_canFriskPerson"; - statement = "[_player, _target] call AGM_Captives_fnc_openFriskMenu"; - showDisabled = 0; - //icon = ""; //@todo - priority = 3; - hotkey = "F"; - }; - }; - - class AGM_SelfActions { - class AGM_StopEscortingSelf { - displayName = "$STR_AGM_Captives_StopEscorting"; - condition = "(_player getVariable ['AGM_escortedUnit', objNull]) getVariable ['AGM_isCaptive', false] && {(_player getVariable ['AGM_escortedUnit', objNull]) in attachedObjects _player}"; - statement = "[_player getVariable ['AGM_escortedUnit', objNull], false] call AGM_Captives_fnc_escortCaptive;"; - exceptions[] = {"AGM_Interaction_isNotEscorting"}; - showDisabled = 0; - priority = 2.3; - hotkey = "C"; - }; - /*class AGM_LoadCaptiveSelf { - displayName = "$STR_AGM_Captives_LoadCaptive"; - condition = "[_player, objNull, objNull] call AGM_Captives_fnc_canLoadCaptiveIntoVehicle"; - statement = "[_player, objNull, objNull] call AGM_Captives_fnc_loadCaptiveIntoVehicle"; - exceptions[] = {"AGM_Interaction_isNotEscorting"}; - showDisabled = 0; - priority = 2.2; - hotkey = "K"; - };*/ - }; - }; - - #define MACRO_LOADUNLOADCAPTIVE \ - class AGM_Actions { \ - class AGM_LoadCaptive { \ - displayName = "$STR_AGM_Captives_LoadCaptive"; \ - distance = 4; \ - condition = "[_player, objNull, _target] call AGM_Captives_fnc_canLoadCaptive"; \ - statement = "[_player, objNull, _target] call AGM_Captives_fnc_loadCaptive"; \ - exceptions[] = {"AGM_Interaction_isNotEscorting"}; \ - showDisabled = 0; \ - priority = 1.2; \ - hotkey = "L"; \ - }; \ - class AGM_UnloadCaptive { \ - displayName = "$STR_AGM_Captives_UnloadCaptive"; \ - distance = 4; \ - condition = "[_player, _target] call AGM_Captives_fnc_canUnloadCaptive"; \ - statement = "[_player, _target] call AGM_Captives_fnc_unloadCaptive"; \ - showDisabled = 0; \ - priority = 1.2; \ - hotkey = "C"; \ - }; \ - }; - - class LandVehicle; - class Car: LandVehicle { - MACRO_LOADUNLOADCAPTIVE - }; - class Tank: LandVehicle { - MACRO_LOADUNLOADCAPTIVE - }; - - class Air; - class Helicopter: Air { - MACRO_LOADUNLOADCAPTIVE - }; - class Plane: Air { - MACRO_LOADUNLOADCAPTIVE - }; - - class Ship; - class Ship_F: Ship { - MACRO_LOADUNLOADCAPTIVE - }; - - class StaticWeapon: LandVehicle { - MACRO_LOADUNLOADCAPTIVE - }; - - class StaticMortar; - class Mortar_01_base_F: StaticMortar { - MACRO_LOADUNLOADCAPTIVE - }; - - #define MACRO_ADDITEM(ITEM,COUNT) class _xx_##ITEM { \ - name = #ITEM; \ - count = COUNT; \ - }; - - class Box_NATO_Support_F; - class AGM_Box_Misc: Box_NATO_Support_F { - class TransportItems { - MACRO_ADDITEM(AGM_CableTie,12) - }; - }; -}; - -class CfgWeapons { - class AGM_ItemCore; - class InventoryItem_Base_F; - - class AGM_CableTie: AGM_ItemCore { - displayName = "$STR_AGM_Captives_CableTie"; - descriptionShort = "$STR_AGM_Captives_CableTieDescription"; - model = "\AGM_Captives\agm_cabletie.p3d"; - picture = "\AGM_Captives\UI\agm_cabletie_x_ca.paa"; - scope = 2; - class ItemInfo: InventoryItem_Base_F { - mass = 1; - }; - }; -}; - -/*class CfgMovesBasic; -class CfgMovesMaleSdr: CfgMovesBasic { - class States { - class CutSceneAnimationBase; - class AmovPercMstpSnonWnonDnon_EaseIn: CutSceneAnimationBase { - head = "headDefault"; - static = 1; - disableWeapons = 0; - forceAim = 0; - InterpolateTo[] = {"AmovPercMstpSnonWnonDnon_EaseOut",0.02,"Unconscious",0.1}; - }; - class AmovPercMstpSnonWnonDnon_Ease: AmovPercMstpSnonWnonDnon_EaseIn { - looped = 1; - InterpolateTo[] = {"Unconscious",0.1}; - }; - class AmovPercMstpSnonWnonDnon_EaseOut: AmovPercMstpSnonWnonDnon_EaseIn { - InterpolateTo[] = {"AmovPercMstpSnonWnonDnon_EaseIn",0.02,"Unconscious",0.1}; - }; - - class AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon: CutSceneAnimationBase { - InterpolateTo[] = {"Unconscious",0.01,"AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon",0.1}; - }; - - class AmovPercMstpSsurWnonDnon: AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon { - looped = 1; - InterpolateTo[] = {"Unconscious",0.01}; - }; - - class AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon: AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon { - InterpolateTo[] = {"Unconscious",0.01,"AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon",0.1}; - }; - }; -};*/ - -class CfgMovesBasic { - class Actions { - class CivilStandActions; - class AGM_CivilStandCaptiveActions: CivilStandActions { - turnL = ""; - turnR = ""; - stop = "AGM_AmovPercMstpScapWnonDnon"; - StopRelaxed = "AGM_AmovPercMstpScapWnonDnon"; - default = "AGM_AmovPercMstpScapWnonDnon"; - getOver = ""; - throwPrepare = ""; - throwGrenade[] = {"","Gesture"}; - }; - }; -}; - -class CfgMovesMaleSdr: CfgMovesBasic { - class StandBase; - class States { - class AmovPercMstpSnonWnonDnon: StandBase { - ConnectTo[] += {"AGM_AmovPercMstpSnonWnonDnon_AmovPercMstpScapWnonDnon",0.1}; - }; - - class CutSceneAnimationBase; - class AGM_AmovPercMstpSnonWnonDnon_AmovPercMstpScapWnonDnon: CutSceneAnimationBase { - actions = "AGM_CivilStandCaptiveActions"; - file = "\A3\anims_f\Data\Anim\Sdr\mov\erc\stp\non\non\AmovPercMstpSnonWnonDnon_EaseIn"; - speed = 1; - looped = 0; - interpolationRestart = 2; - ConnectTo[] = {"AGM_AmovPercMstpScapWnonDnon",0.1}; - InterpolateTo[] = {"Unconscious",0.01,"AGM_AmovPercMstpScapWnonDnon_AmovPercMstpSnonWnonDnon",0.1}; - }; - - class AGM_AmovPercMstpScapWnonDnon: AGM_AmovPercMstpSnonWnonDnon_AmovPercMstpScapWnonDnon { - file = "\A3\anims_f\Data\Anim\Sdr\mov\erc\stp\non\non\AmovPercMstpSnonWnonDnon_Ease"; - speed = 0; - ConnectTo[] = {"AGM_AmovPercMstpScapWnonDnon_AmovPercMstpSnonWnonDnon",0.1}; - InterpolateTo[] = {"Unconscious",0.01}; - looped = 1; - }; - - class AGM_AmovPercMstpScapWnonDnon_AmovPercMstpSnonWnonDnon: AGM_AmovPercMstpSnonWnonDnon_AmovPercMstpScapWnonDnon { - actions = "CivilStandActions"; - file = "\A3\anims_f\Data\Anim\Sdr\mov\erc\stp\non\non\amovpercmstpsnonwnondnon_easeout"; - ConnectTo[] = {"AmovPercMstpSnonWnonDnon",0.1}; - InterpolateTo[] = {"Unconscious",0.01,"AGM_AmovPercMstpSnonWnonDnon_AmovPercMstpScapWnonDnon",0.1}; - }; - }; -}; - -/* -player playMove "AGM_AmovPercMstpScapWnonDnon"; -player switchMove "AGM_AmovPercMstpScapWnonDnon_AmovPercMstpSnonWnonDnon"; -*/ diff --git a/TO_MERGE/agm/Captives/functions/fn_canFriskPerson.sqf b/TO_MERGE/agm/Captives/functions/fn_canFriskPerson.sqf deleted file mode 100644 index 77ad6f6446..0000000000 --- a/TO_MERGE/agm/Captives/functions/fn_canFriskPerson.sqf +++ /dev/null @@ -1,21 +0,0 @@ -/* - * By: bux578 - * - * Checks the conditions for being able to frisk a unit - * - * Arguments: - * 0: caller (player) (Object) - * 1: target (Object) - * - * Return Value: - * Boolean - */ - -private ["_unit", "_target"]; - -_unit = _this select 0; -_target = _this select 1; - - _target getVariable ["AGM_isCaptive", false] -|| {_target getVariable ["AGM_isSearchable", false]} -|| {_target getVariable ["AGM_isUnconscious", false]} diff --git a/TO_MERGE/agm/Captives/functions/fn_canLoadCaptive.sqf b/TO_MERGE/agm/Captives/functions/fn_canLoadCaptive.sqf deleted file mode 100644 index 637a4889af..0000000000 --- a/TO_MERGE/agm/Captives/functions/fn_canLoadCaptive.sqf +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Author: commy2 - * - * Check if the unit can load the target object into a vehicle. - * - * Argument: - * 0: Unit that wants to load a captive (Object) - * 1: A captive. ObjNull for the first escorted captive (Object) - * 2: Vehicle to load the captive into. ObjNull for the nearest vehicle (Object) - * - * Return value: - * Boolean (Bool) - */ - -private ["_unit", "_target", "_vehicle", "_objects"]; - -_unit = _this select 0; -_target = _this select 1; -_vehicle = _this select 2; - -if (isNull _target) then { - _objects = attachedObjects _unit; - _objects = [_objects, {_this getVariable ["AGM_isCaptive", false]}] call AGM_Core_fnc_filter; - _target = _objects select 0; -}; - -if (isNull _vehicle) then { - _objects = nearestObjects [_unit, ["Car", "Tank", "Helicopter", "Plane", "Ship_F"], 10]; - _vehicle = _objects select 0; -}; - -_unit getVariable ["AGM_isEscorting", false] -&& {!isNil "_target"} -&& {!isNil "_vehicle"} -&& {_vehicle emptyPositions "cargo" > 0} diff --git a/TO_MERGE/agm/Captives/functions/fn_canUnloadCaptive.sqf b/TO_MERGE/agm/Captives/functions/fn_canUnloadCaptive.sqf deleted file mode 100644 index 8c52bac0b0..0000000000 --- a/TO_MERGE/agm/Captives/functions/fn_canUnloadCaptive.sqf +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Author: commy2 - * - * Check if the unit can unload a captive from the vehicle. - * - * Argument: - * 0: Unit that wants to unload a captive (Object) - * 1: Vehicle to unload a captive from. (Object) - * - * Return value: - * Boolean (Bool) - */ - -private ["_unit", "_vehicle", "_cargo"]; - -_unit = _this select 0; -_vehicle = _this select 1; - -_cargo = crew _vehicle; // Can also unload from driver, gunner, commander, turret positions. They shouldn't be there anyway. - -_cargo = [_cargo, {_this getVariable ["AGM_isCaptive", false]}] call AGM_Core_fnc_filter; - -count _cargo > 0 diff --git a/TO_MERGE/agm/Captives/functions/fn_escortCaptive.sqf b/TO_MERGE/agm/Captives/functions/fn_escortCaptive.sqf deleted file mode 100644 index 55244cf2f8..0000000000 --- a/TO_MERGE/agm/Captives/functions/fn_escortCaptive.sqf +++ /dev/null @@ -1,43 +0,0 @@ -//author : Nic547 -//Attaches a Captive to the player - -private ["_unit", "_state"]; - -_unit = _this select 0; -_state = _this select 1; - -if !("AGM_Handcuffed" in ([_unit] call AGM_Core_fnc_getCaptivityStatus)) exitWith { - [localize "STR_AGM_Captives_NoCaptive"] call AGM_Core_fnc_displayTextStructured; -}; - -if (_state) then { - if (player getVariable ["AGM_isEscorting", false]) exitWith {}; - - [player, _unit] call AGM_Core_fnc_claim; - player setVariable ["AGM_isEscorting", true, true]; - - _unit attachTo [player, [0, 1, 0]]; - - player setVariable ["AGM_escortedUnit", _unit, true]; - _actionID = player addAction [format ["%1", localize "STR_AGM_Captives_StopEscorting"], "[player getVariable ['AGM_escortedUnit', objNull], false] call AGM_Captives_fnc_escortCaptive;", nil, 20, false, true, "", "!isNull (player getVariable ['AGM_escortedUnit', objNull])"]; - - [_unit, _actionID] spawn { - _unit = _this select 0; - _actionID = _this select 1; - - while {player getVariable ["AGM_isEscorting", false]} do { - sleep 0.2; - - if (!alive _unit || {!alive player} || {!canStand _unit} || {!canStand player} || {_unit getVariable ["AGM_isUnconscious", false]} || {player getVariable ["AGM_isUnconscious", false]} || {!isNull (attachedTo player)}) then { - player setVariable ["AGM_isEscorting", false, true]; - }; - }; - [objNull, _unit] call AGM_Core_fnc_claim; - - detach _unit; - player removeAction _actionID; - }; -} else { - player setVariable ["AGM_isEscorting", false, true]; - player setVariable ["AGM_escortedUnit", objNull, true]; -}; diff --git a/TO_MERGE/agm/Captives/functions/fn_handleGetOut.sqf b/TO_MERGE/agm/Captives/functions/fn_handleGetOut.sqf deleted file mode 100644 index 0cb88b0a8e..0000000000 --- a/TO_MERGE/agm/Captives/functions/fn_handleGetOut.sqf +++ /dev/null @@ -1,14 +0,0 @@ -// by commy2 - -private ["_vehicle", "_unit", "_cargoIndex"]; - -_vehicle = _this select 0; -_unit = _this select 2; - -_cargoIndex = _unit getVariable ["AGM_Captives_CargoIndex", -1]; - -if (_cargoIndex != -1) exitWith { - _unit moveInCargo [_vehicle, _cargoIndex]; -}; - -[_unit, 'AGM_AmovPercMstpScapWnonDnon', 2] call AGM_Core_fnc_doAnimation; diff --git a/TO_MERGE/agm/Captives/functions/fn_handlePlayerChanged.sqf b/TO_MERGE/agm/Captives/functions/fn_handlePlayerChanged.sqf deleted file mode 100644 index 5bece824f9..0000000000 --- a/TO_MERGE/agm/Captives/functions/fn_handlePlayerChanged.sqf +++ /dev/null @@ -1,12 +0,0 @@ -// by commy2 - -private ["_unit", "_oldUnit"]; - -_unit = _this select 0; -_oldUnit = _this select 1; - -if (_unit getVariable ["AGM_isCaptive", false]) then { - showHUD false; -} else { - showHUD true; -}; diff --git a/TO_MERGE/agm/Captives/functions/fn_handleWokeUp.sqf b/TO_MERGE/agm/Captives/functions/fn_handleWokeUp.sqf deleted file mode 100644 index facbf9b31f..0000000000 --- a/TO_MERGE/agm/Captives/functions/fn_handleWokeUp.sqf +++ /dev/null @@ -1,10 +0,0 @@ -// by commy2 - -private "_unit"; - -_unit = _this select 0; - -if (_unit getVariable ["AGM_isCaptive", false] && {vehicle _unit == _unit}) then { - [_unit] call AGM_Core_fnc_fixLoweredRifleAnimation; - [_unit, "AGM_AmovPercMstpScapWnonDnon", 0] call AGM_Core_fnc_doAnimation; -}; diff --git a/TO_MERGE/agm/Captives/functions/fn_initPost.sqf b/TO_MERGE/agm/Captives/functions/fn_initPost.sqf deleted file mode 100644 index 73c9674f7a..0000000000 --- a/TO_MERGE/agm/Captives/functions/fn_initPost.sqf +++ /dev/null @@ -1,11 +0,0 @@ -// by commy2 - -private "_unit"; - -_unit = _this select 0; - -// reset status on mission start -if (_unit getVariable ["AGM_isCaptive", false]) then { - _unit setVariable ["AGM_isCaptive", false]; - [_unit, true] call AGM_Captives_fnc_setCaptive; -}; diff --git a/TO_MERGE/agm/Captives/functions/fn_initUnit.sqf b/TO_MERGE/agm/Captives/functions/fn_initUnit.sqf deleted file mode 100644 index 76d4671b7f..0000000000 --- a/TO_MERGE/agm/Captives/functions/fn_initUnit.sqf +++ /dev/null @@ -1,12 +0,0 @@ -// by commy2 - -[_this select 0, "knockedOut", { - if (local (_this select 0)) then {_this call AGM_Captives_fnc_handleKnockedOut}; -}] call AGM_Core_fnc_addCustomEventhandler; - -[_this select 0, "wokeUp", { - if (local (_this select 0)) then {_this call AGM_Captives_fnc_handleWokeUp}; -}] call AGM_Core_fnc_addCustomEventhandler; - -// prevent players from throwing grenades -[_this select 0, "Throw", {(_this select 1) getVariable ["AGM_isCaptive", false]}, {}] call AGM_Core_fnc_addActionEventhandler; diff --git a/TO_MERGE/agm/Captives/functions/fn_loadCaptive.sqf b/TO_MERGE/agm/Captives/functions/fn_loadCaptive.sqf deleted file mode 100644 index 12bcb35f9b..0000000000 --- a/TO_MERGE/agm/Captives/functions/fn_loadCaptive.sqf +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Author: commy2 - * - * Unit loads the target object into a vehicle. - * - * Argument: - * 0: Unit that wants to load a captive (Object) - * 1: A captive. ObjNull for the first escorted captive (Object) - * 2: Vehicle to load the captive into. ObjNull for the nearest vehicle (Object) - * - * Return value: - * Nothing - */ - -private ["_unit", "_target", "_vehicle", "_objects"]; - -_unit = _this select 0; -_target = _this select 1; -_vehicle = _this select 2; - -if (isNull _target) then { - _objects = attachedObjects _unit; - _objects = [_objects, {_this getVariable ["AGM_isCaptive", false]}] call AGM_Core_fnc_filter; - _target = _objects select 0; -}; - -if (isNull _vehicle) then { - _objects = nearestObjects [_unit, ["Car_F", "Tank_F", "Helicopter_F", "Boat_F", "Plane_F"], 10]; - _vehicle = _objects select 0; -}; - -if (!isNil "_target" && {!isNil "_vehicle"}) then { - _unit setVariable ["AGM_isEscorting", false]; - [[_target, _vehicle], "{(_this select 0) moveInCargo (_this select 1); (_this select 0) assignAsCargo (_this select 1); (_this select 0) setVariable ['AGM_Captives_CargoIndex', (_this select 1) getCargoIndex (_this select 0), true];}", _target] call AGM_Core_fnc_execRemoteFnc; -}; diff --git a/TO_MERGE/agm/Captives/functions/fn_openFriskMenu.sqf b/TO_MERGE/agm/Captives/functions/fn_openFriskMenu.sqf deleted file mode 100644 index c7f60ba2e6..0000000000 --- a/TO_MERGE/agm/Captives/functions/fn_openFriskMenu.sqf +++ /dev/null @@ -1,70 +0,0 @@ -/* - Name: AGM_Captives_fnc_openFriskMenu - - Author: bux578 - - Description: - Open the select menu with the "personal" items of a frisked unit - It only shows "handgunWeapon", "uniformItems", "vestItems", "backpackItems" and "assignedItems" because every other item is visible on the character - - Parameters: - 0: Object - player unit - 1: Object - unit - - Returns: - Nothing -*/ - -private ["_player", "_unit", "_weapon", "_listedItemClasses", "_actions", "_allGear"]; - -_player = _this select 0; -_unit = _this select 1; - -_weapon = currentWeapon _player; -if (_weapon == primaryWeapon _player && {_weapon != ""}) then { - [_player, "AmovPercMstpSlowWrflDnon", 0] call AGM_Core_fnc_doAnimation; -}; - -_listedItemClasses = []; - -_actions = [localize "STR_AGM_Captives_FriskMenuHeader", localize "STR_AGM_Captives_CancelSelection"] call AGM_Interaction_fnc_prepareSelectMenu; - -_allGear = []; - -if ((handgunWeapon _unit) != "") then { - _allGear pushBack (handgunWeapon _unit); -}; -if (count (uniformItems _unit) > 0) then { - _allGear = _allGear + (uniformItems _unit); -}; -if (count (vestItems _unit) > 0) then { - _allGear = _allGear + (vestItems _unit); -}; -if (count (backpackItems _unit) > 0) then { - _allGear = _allGear + (backpackItems _unit); -}; -if (count (assignedItems _unit) > 0) then { - _allGear = _allGear + (assignedItems _unit); -}; - -// Handgun -// Uniform Items -// Vest Items -// Backpack Items -// Assigned Items -{ - if (!(_x in _listedItemClasses)) then { - private "_item"; - _item = configFile >> "CfgMagazines" >> _x; - if (isNil "_item" || str _item == "") then { //str _item ? - _item = configFile >> "CfgWeapons" >> _x; - }; - _actions = [_actions, getText(_item >> "displayName"), getText(_item >> "picture"), _x] call AGM_Interaction_fnc_addSelectableItem; - _listedItemClasses pushBack _x; - }; -} forEach (_allGear); - -[_actions, {call AGM_Interaction_fnc_hideMenu;}, {call AGM_Interaction_fnc_hideMenu;}] call AGM_Interaction_fnc_openSelectMenu; - -// don't need an "Ok" Button -ctrlShow [8860, false]; diff --git a/TO_MERGE/agm/Captives/functions/fn_setCaptive.sqf b/TO_MERGE/agm/Captives/functions/fn_setCaptive.sqf deleted file mode 100644 index a2e4ed7e3e..0000000000 --- a/TO_MERGE/agm/Captives/functions/fn_setCaptive.sqf +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Author: Nic547, commy2 - * - * Makes a civilian unable to move. - * - * Argument: - * 0: Unit (Object) - * 1: True to take captive, false to release captive (Object) - * - * Return value: - * Nothing - */ - -private ["_unit", "_state"]; - -_unit = _this select 0; -_state = _this select 1; - -if (!local _unit) exitWith {[[_unit, _state, true], _fnc_scriptName, _unit] call AGM_Core_fnc_execRemoteFnc}; - -if (_state) then { - if (_unit getVariable ["AGM_isCaptive", false]) exitWith {}; - - _unit setVariable ["AGM_isCaptive", true, true]; - - // fix anim on mission start (should work on dedicated servers) - _unit spawn { - [_this, "AGM_Handcuffed", true] call AGM_Core_fnc_setCaptivityStatus; - - if (_this getVariable ["AGM_isCaptive", false] && {vehicle _this == _this}) then { - [_this] call AGM_Core_fnc_fixLoweredRifleAnimation; - [_this, "AGM_AmovPercMstpScapWnonDnon", 0] spawn AGM_Core_fnc_doAnimation; - }; - }; - - _unit setVariable ["AGM_Captives_CargoIndex", vehicle _unit getCargoIndex _unit, true]; - - if (_unit == AGM_player) then { - showHUD false; - }; -} else { - if !(_unit getVariable ["AGM_isCaptive", false]) exitWith {}; - - _unit setVariable ["AGM_isCaptive", false, true]; - [_unit, "AGM_Handcuffed", false] call AGM_Core_fnc_setCaptivityStatus; - if (vehicle _unit == _unit) then { - [_unit, "AGM_AmovPercMstpScapWnonDnon_AmovPercMstpSnonWnonDnon", 2] call AGM_Core_fnc_doAnimation; - }; - - if (_unit getVariable ["AGM_Captives_CargoIndex", -1] != -1) then { - _unit setVariable ["AGM_Captives_CargoIndex", -1, true]; - }; - - if (_unit == AGM_player) then { - showHUD true; - }; -}; diff --git a/TO_MERGE/agm/Captives/functions/fn_surrender.sqf b/TO_MERGE/agm/Captives/functions/fn_surrender.sqf deleted file mode 100644 index 9ba1dbcfc2..0000000000 --- a/TO_MERGE/agm/Captives/functions/fn_surrender.sqf +++ /dev/null @@ -1,50 +0,0 @@ -// by commy2 - -private ["_unit", "_state"]; - -_unit = _this select 0; -_state = _this select 1; - -if (!local _unit) exitWith {[_this, _fnc_scriptName, _unit] call AGM_Core_fnc_execRemoteFnc}; - -if (_state) then { - if (_unit getVariable ["AGM_isSurrender", false]) exitWith {}; - - _unit setVariable ["AGM_isSurrender", true, true]; - [_unit, "AGM_Surrendered", true] call AGM_Core_fnc_setCaptivityStatus; - - _unit spawn { - // fix for lowered rifle animation glitch - if (currentWeapon _this != "" && {currentWeapon _this == primaryWeapon _this} && {weaponLowered _this} && {stance _this == "STAND"}) then { - _this playMove "amovpercmstpsraswrfldnon"; - }; - - while {_this getVariable ["AGM_isSurrender", false]} do { - sleep 0.001; //sleep in UI - - if (isPlayer _this) then {showHUD false}; - - if (!alive _this || {_this getVariable ["AGM_isUnconscious", false]}) then { - _this setVariable ["AGM_isSurrender", false, true]; - } else { - _this playMove "amovpercmstpsnonwnondnon_amovpercmstpssurwnondnon"; - }; - }; - if !(_this getVariable ["AGM_isUnconscious", false]) then { - _this playMoveNow "AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon"; - } else { - _this playMoveNow "unconscious"; - }; - - [_this, "AGM_Surrendered", false] call AGM_Core_fnc_setCaptivityStatus; - - if (isPlayer _this) then {showHUD true}; - }; -} else { - _unit setVariable ["AGM_isSurrender", false, true]; -}; - -/* -player playMove "AmovPercMstpSsurWnonDnon" -player switchMove "AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon" -*/ diff --git a/TO_MERGE/agm/Captives/functions/fn_unloadCaptive.sqf b/TO_MERGE/agm/Captives/functions/fn_unloadCaptive.sqf deleted file mode 100644 index e7849f1c0e..0000000000 --- a/TO_MERGE/agm/Captives/functions/fn_unloadCaptive.sqf +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Author: commy2 - * - * Unit unloads a captive from a vehicle. - * - * Argument: - * 0: Unit that wants to unload a captive (Object) - * 1: Vehicle to unload a captive from. (Object) - * - * Return value: - * Nothing - */ - -private ["_unit", "_vehicle", "_cargo", "_target"]; - -_unit = _this select 0; -_vehicle = _this select 1; - -_cargo = crew _vehicle; // Can also unload from driver, gunner, commander, turret positions. They shouldn't be there anyway. - -_cargo = [_cargo, {_this getVariable ["AGM_isCaptive", false]}] call AGM_Core_fnc_filter; - -if (count _cargo > 0) then { - _target = _cargo select 0; - - _target setVariable ["AGM_Captives_CargoIndex", -1, true]; - - moveOut _target; - [_target, "AGM_AmovPercMstpScapWnonDnon", 2] call AGM_Core_fnc_doAnimation; - [_target, "{unassignVehicle _this}", _target] call AGM_Core_fnc_execRemoteFnc; -}; diff --git a/addons/aircraft/CfgAmmo.hpp b/addons/aircraft/CfgAmmo.hpp index 2c9d6a91e6..177753223f 100644 --- a/addons/aircraft/CfgAmmo.hpp +++ b/addons/aircraft/CfgAmmo.hpp @@ -1,302 +1,43 @@ class CfgAmmo { - class BulletBase; - class B_20mm: BulletBase { - deflecting = 3; - hit = 100; - indirectHit = 10; - indirectHitRange = 2; - model = "\A3\Weapons_f\Data\bullettracer\tracer_red"; - }; - + // adjust minigun caliber and deflection to other ammo class SubmunitionBullet; class B_65x39_Minigun_Caseless: SubmunitionBullet { - hit = 10; - indirectHit = 0; - indirectHitRange = 0; caliber = 1; - deflecting = 5; - typicalSpeed = 850; + deflecting = 15; }; class B_762x51_Minigun_Tracer_Red: SubmunitionBullet { - hit = 12; - indirectHit = 0; - indirectHitRange = 0; - model = "\A3\Weapons_f\Data\bullettracer\tracer_red"; caliber = 1.6; - deflecting = 5; - typicalSpeed = 850; - }; - - class M_Titan_AA; - class M_Zephyr: M_Titan_AA { - proxyShape = "\A3\Weapons_F\Ammo\Missile_AA_02_F.p3d"; - model = "\A3\Weapons_F\Ammo\Missile_AA_02_fly_F.p3d"; - airFriction = 0.078; - sideAirFriction = 0.18; - maneuvrability = 24; - class CamShakeFire {}; - class CamShakePlayerFire {}; - }; - - class M_Zephyr_Mi06: M_Zephyr { - maverickWeaponIndexOffset = 6; - }; - - class MissileBase; - class M_Air_AA: MissileBase { - model = "\A3\Weapons_F\Ammo\Missile_AT_02_fly_F"; - proxyShape = "\A3\Weapons_F\Ammo\Missile_AT_02_F"; - hit = 280; - indirectHit = 85; - indirectHitRange = 10; - maneuvrability = 27; - simulationStep = 0.002; - airLock = 1; - irLock = 1; - cost = 1500; - //maxSpeed = 2400; - timeToLive = 40; - airFriction = 0.05; - sideAirFriction = 0.1; - trackOversteer = 1; - trackLead = 1; - initTime = 0; - thrustTime = 12; - thrust = 340; - fuseDistance = 500; - weaponLockSystem = "2 + 16"; - maxControlRange = 8000; - class CamShakeExplode {}; - class CamShakeHit {}; - class CamShakeFire {}; - class CamShakePlayerFire {}; - }; - - class Missile_AA_04_F: MissileBase { - hit = 800; - indirectHit = 60; - indirectHitRange = 12; - airLock = 2; - irLock = 1; - laserLock = 0; - nvLock = 0; - weaponLockSystem = "2 + 16"; - cmimmunity = 0.8; - initTime = 0; - thrust = 380; - thrustTime = 9.5; - airFriction = 0.04; - sideAirFriction = 0.08; - //maxSpeed = 2600; - maneuvrability = 14; - simulationStep = 0.002; - fuseDistance = 500; - timeToLive = 19; - trackLead = 1; - trackOversteer = 1; + deflecting = 15; }; + // also adjust tracer, "muh lightshow"; also adjust splash damage radius + class BulletBase; class Gatling_30mm_HE_Plane_CAS_01_F: BulletBase { - model = "\A3\Weapons_f\Data\bullettracer\tracer_red.p3d"; - cost = 20; hit = 80; indirectHit = 12; - indirectHitRange = 3; + indirectHitRange = 3; //2; caliber = 1.4; - explosive = 0.6; - airlock = 1; deflecting = 3; - airFriction = -0.00042; - typicalSpeed = 960; - visibleFire = 32; - audibleFire = 32; - visibleFireTime = 3; fuseDistance = 3; - tracerScale = 2.5; tracerStartTime = 0.02; - tracerEndTime = 4.7; - multiSoundHit[] = {"soundHit1",0.2,"soundHit2",0.2,"soundHit3",0.2,"soundHit4",0.1,"soundHit5",0.15,"soundHit6",0.15}; - soundFly[] = {"A3\Sounds_F\weapons\Explosion\cannon_fly",1,1,50}; - explosionSoundEffect = "DefaultExplosion"; - explosionEffects = "ExploAmmoExplosion"; - craterEffects = "ExploAmmoCrater"; - soundHit1[] = {"A3\Sounds_F\weapons\Explosion\gr_explosion_1",3.16228,1,1600}; - soundHit2[] = {"A3\Sounds_F\weapons\Explosion\gr_explosion_2",3.16228,1,1600}; - soundHit3[] = {"A3\Sounds_F\weapons\Explosion\gr_explosion_3",3.16228,1,1600}; - soundHit4[] = {"A3\Sounds_F\weapons\Explosion\gr_explosion_4",3.16228,1,1600}; - soundHit5[] = {"A3\Sounds_F\weapons\Explosion\gr_explosion_5",3.16228,1,1600}; - soundHit6[] = {"A3\Sounds_F\weapons\Explosion\gr_explosion_6",3.16228,1,1600}; - class CamShakeExplode {}; - class CamShakeHit {}; - class CamShakeFire {}; - class CamShakePlayerFire {}; }; + + // helper projectiles to simulate a rof > fps class ACE_Gatling_30mm_HE_Plane_CAS_01_Deploy: Gatling_30mm_HE_Plane_CAS_01_F { simulation = "shotSubmunitions"; triggerTime = 0; submunitionAmmo = "ACE_Gatling_30mm_HE_Plane_CAS_01_Sub"; submunitionConeType[] = {"custom", {{0,0}, {0,0}, {0,0}} }; }; - class ACE_Gatling_30mm_HE_Plane_CAS_01_Sub: Gatling_30mm_HE_Plane_CAS_01_F { - }; + class ACE_Gatling_30mm_HE_Plane_CAS_01_Sub: Gatling_30mm_HE_Plane_CAS_01_F {}; + + // adjust damage and splash damage, closer to bluefor gatling with same caliber class Cannon_30mm_HE_Plane_CAS_02_F: Gatling_30mm_HE_Plane_CAS_01_F { - model = "\A3\Weapons_f\Data\bullettracer\tracer_green.p3d"; - hit = 70; - indirectHit = 11; + hit = 70; //40; + indirectHit = 11; //14; indirectHitRange = 3; - caliber = 2; - explosive = 0.6; }; - - class Missile_AGM_02_F: MissileBase { - model = "\A3\Weapons_F_EPC\Ammo\Missile_AGM_02_fly_F.p3d"; - proxyShape = "\A3\Weapons_F_EPC\Ammo\Missile_AGM_02_F.p3d"; - maverickWeaponIndexOffset = 2; - cost = 1500; - hit = 2100; - indirectHit = 85; - indirectHitRange = 8; - manualControl = 0; - maxControlRange = 8000; - airLock = 0; - irLock = 1; - laserLock = 0; - nvLock = 0; - weaponLockSystem = "2 + 16"; - cmimmunity = 0.8; - initTime = 0; - thrust = 240; - thrustTime = 5; - airFriction = 0.05; - sideAirFriction = 0.1; - maxSpeed = 828; - maneuvrability = 27; - simulationStep = 0.002; - fuseDistance = 500; - timeToLive = 40; - trackLead = 1; - trackOversteer = 1; - craterEffects = "AAMissileCrater"; - effectsMissile = "missile3"; - explosionEffects = "AAMissileExplosion"; - muzzleEffect = "BIS_fnc_effectFiredHeliRocket"; - whistleDist = 20; - class CamShakeExplode {}; - class CamShakeHit {}; - class CamShakeFire {}; - class CamShakePlayerFire {}; - }; - - class LaserBombCore; - class Bomb_04_F: LaserBombCore { - model = "\A3\Weapons_F_EPC\Ammo\Bomb_04_fly_F.p3d"; - proxyShape = "\A3\Weapons_F_EPC\Ammo\Bomb_04_F.p3d"; - maverickWeaponIndexOffset = 8; - hit = 6000; - indirectHit = 1400; - indirectHitRange = 15; - nvLock = 1; - weaponLockSystem = "2 + 16 + 4"; - maneuvrability = 20; - fuseDistance = 35; - trackLead = 0.95; - trackOversteer = 1; - craterEffects = "BombCrater"; - explosionEffects = "BombExplosion"; - explosionSoundEffect = "DefaultExplosion"; - explosionTime = 2; - multiSoundHit[] = {"soundHit1",0.2,"soundHit2",0.2,"soundHit3",0.2,"soundHit4",0.2,"soundHit5",0.2}; - soundHit1[] = {"\A3\Sounds_F\weapons\Explosion\expl_big_1",2.51189,1,2400}; - soundHit2[] = {"\A3\Sounds_F\weapons\Explosion\expl_big_2",2.51189,1,2400}; - soundHit3[] = {"\A3\Sounds_F\weapons\Explosion\expl_big_3",2.51189,1,2400}; - soundHit4[] = {"\A3\Sounds_F\weapons\Explosion\expl_shell_1",2.51189,1,2400}; - soundHit5[] = {"\A3\Sounds_F\weapons\Explosion\expl_shell_2",2.51189,1,2400}; - whistleDist = 24; - }; - - class Rocket_04_HE_F: MissileBase { - model = "\A3\Weapons_F_EPC\Ammo\Rocket_04_HE_fly_F.p3d"; - proxyShape = "\A3\Weapons_F_EPC\Ammo\Rocket_04_HE_F.p3d"; - maverickWeaponIndexOffset = 12; - cost = 500; - hit = 210; - indirectHit = 55; - indirectHitRange = 15; - manualControl = 0; - maxControlRange = 8000; - airLock = 0; - irLock = 1; - laserLock = 0; - nvLock = 0; - weaponLockSystem = 0; - cmimmunity = 1; - initTime = 0.002; - thrust = 1600; - thrustTime = 0.7; - airFriction = 0.0046; - sideAirFriction = 0.005; - maxSpeed = 610; - maneuvrability = 0; - fuseDistance = 50; - timeToLive = 60; - effectsMissileInit = "MissileDAR1"; - whistleDist = 30; - class CamShakeExplode {}; - class CamShakeHit {}; - class CamShakeFire {}; - class CamShakePlayerFire {}; - }; - - class Rocket_04_AP_F: Rocket_04_HE_F { - model = "\A3\Weapons_F_EPC\Ammo\Rocket_04_AP_fly_F.p3d"; - proxyShape = "\A3\Weapons_F_EPC\Ammo\Rocket_04_AP_F.p3d"; - maverickWeaponIndexOffset = 19; - hit = 400; - indirectHit = 20; - indirectHitRange = 10; - }; - - class Missile_AA_03_F: Missile_AA_04_F { - model = "\A3\Weapons_F_EPC\Ammo\Missile_AA_03_fly_F.p3d"; - proxyShape = "\A3\Weapons_F_EPC\Ammo\Missile_AA_03_F.p3d"; - maverickWeaponIndexOffset = 0; - hit = 900; - indirectHit = 50; - indirectHitRange = 15; - }; - - class Missile_AGM_01_F: Missile_AGM_02_F { - model = "\A3\Weapons_F_EPC\Ammo\Missile_AGM_01_fly_F.p3d"; - proxyShape = "\A3\Weapons_F_EPC\Ammo\Missile_AGM_01_F.p3d"; - maverickWeaponIndexOffset = 2; - hit = 2200; - indirectHit = 90; - indirectHitRange = 10; - }; - - class Bomb_03_F: Bomb_04_F { - model = "\A3\Weapons_F_EPC\Ammo\Bomb_03_F.p3d"; - proxyShape = "\A3\Weapons_F_EPC\Ammo\Bomb_03_F.p3d"; - maverickWeaponIndexOffset = 6; - hit = 6400; - indirectHit = 1400; - indirectHitRange = 16; - }; - - class Rocket_03_HE_F: Rocket_04_HE_F { - model = "\A3\Weapons_F_EPC\Ammo\Rocket_03_HE_fly_F.p3d"; - proxyShape = "\A3\Weapons_F_EPC\Ammo\Rocket_03_HE_F.p3d"; - maverickWeaponIndexOffset = 8; - }; - - class Rocket_03_AP_F: Rocket_04_AP_F { - model = "\A3\Weapons_F_EPC\Ammo\Rocket_03_AP_fly_F.p3d"; - proxyShape = "\A3\Weapons_F_EPC\Ammo\Rocket_03_AP_F.p3d"; - maverickWeaponIndexOffset = 28; - }; - - class RocketBase; }; diff --git a/addons/aircraft/CfgMagazines.hpp b/addons/aircraft/CfgMagazines.hpp index 7328eda091..0c306f8f04 100644 --- a/addons/aircraft/CfgMagazines.hpp +++ b/addons/aircraft/CfgMagazines.hpp @@ -1,202 +1,15 @@ class CfgMagazines { + // shoot helper object to tripple rof class VehicleMagazine; - class 24Rnd_PG_missiles; - - class 12Rnd_PG_missiles: 24Rnd_PG_missiles { - count = 12; - displayName = "$STR_A3_CfgMagazines_12Rnd_PG_missiles0"; - displayNameShort = "$STR_A3_CfgMagazines_12Rnd_PG_missiles_dns"; - descriptionShort = "$STR_A3_CfgMagazines_12Rnd_PG_missiles1"; - }; - class 12Rnd_missiles: VehicleMagazine { - scope = 2; - count = 12; - ammo = "M_AT"; - displayName = "$STR_A3_CfgMagazines_24Rnd_PuG_missiles0"; - displayNameShort = "$STR_A3_CfgMagazines_24Rnd_PuG_missiles_dns"; - descriptionShort = "$STR_A3_CfgMagazines_24Rnd_PuG_missiles0"; - initSpeed = 44; - maxLeadSpeed = 800; - nameSound = "rockets"; - sound[] = {"A3\sounds_f\weapons\rockets\explosion_missile_01",1,1,1200}; - reloadSound[] = {"",0.000316228,1}; - }; - - //minigun magazines, muzzle velocities and tracercounts - class 200Rnd_65x39_Belt: VehicleMagazine {}; - class 2000Rnd_65x39_Belt: 200Rnd_65x39_Belt {}; - class 2000Rnd_65x39_Belt_Tracer_Red: 2000Rnd_65x39_Belt { - }; - class 2000Rnd_65x39_Belt_Green: 2000Rnd_65x39_Belt {}; - class 2000Rnd_65x39_Belt_Tracer_Green: 2000Rnd_65x39_Belt_Green { - tracersEvery = 1; - }; - class 2000Rnd_65x39_Belt_Yellow: 2000Rnd_65x39_Belt { - tracersEvery = 1; - }; - class 2000Rnd_65x39_Belt_Tracer_Yellow: 2000Rnd_65x39_Belt_Yellow { - tracersEvery = 1; - }; - - class 5000Rnd_762x51_Belt: 2000Rnd_65x39_Belt { - tracersEvery = 1; - count = 5000; - }; - class 5000Rnd_762x51_Yellow_Belt: 5000Rnd_762x51_Belt {}; - class 4000Rnd_762x51_M134 : 5000Rnd_762x51_Belt { - count = 4000; - tracersEvery = 1; - }; - class 2000Rnd_762x51_M134 : 4000Rnd_762x51_M134 { - count = 2000; - tracersEvery = 1; - }; - - class 2Rnd_AAA_missiles: VehicleMagazine { - scope = 2; - displayName = "$STR_A3_CfgMagazines_2Rnd_AAA_missiles0"; - displayNameShort = "$STR_A3_CfgMagazines_2Rnd_AAA_missiles_dns"; - ammo = "M_Air_AA"; - count = 2; - maxLeadSpeed = 950; - nameSound = "missiles"; - }; - class 2Rnd_AAA_missiles_MI02: 2Rnd_AAA_missiles { - ammo = "M_Air_AA_MI02"; - }; - class 4Rnd_AAA_missiles: 2Rnd_AAA_missiles { - displayName = "$STR_A3_CfgMagazines_4Rnd_AAA_missiles0"; - displayNameShort = "$STR_A3_CfgMagazines_4Rnd_AAA_missiles_dns"; - count = 4; - }; - class 4Rnd_AAA_missiles_MI02: 4Rnd_AAA_missiles { - ammo = "M_Air_AA_MI02"; - }; - - class 4Rnd_GAA_missiles: VehicleMagazine { - scope = 2; - displayName = "$STR_A3_CfgMagazines_4Rnd_GAA_missiles0"; - displayNameShort = "$STR_A3_CfgMagazines_4Rnd_GAA_missiles_dns"; - count = 4; - ammo = "M_Zephyr"; - maxLeadSpeed = 950; - nameSound = "missiles"; - }; - - class 300Rnd_20mm_shells: VehicleMagazine { - scope = 2; - displayName = "$STR_A3_CfgMagazines_300Rnd_20mm_shells0"; - displayNameShort = "$STR_A3_CfgMagazines_300Rnd_20mm_shells_dns"; - ammo = "B_20mm"; - count = 300; - deflecting = 3; - maxLeadSpeed = 300; - tracersEvery = 5; - nameSound = "cannon"; - }; - class 1000Rnd_Gatling_30mm_Plane_CAS_01_F: VehicleMagazine { - scope = 2; - displayNameShort = ""; ammo = "ACE_Gatling_30mm_HE_Plane_CAS_01_Deploy"; count = 1170; - //count = 390; - //initSpeed = 3852; - maxLeadSpeed = 300; - nameSound = "cannon"; - tracersEvery = 1; - }; - - class 2Rnd_Missile_AA_04_F: VehicleMagazine { - scope = 2; - displayNameShort = "$STR_A3_CFGMAGAZINES_4RND_AAA_MISSILES_DNS"; - ammo = "Missile_AA_04_F"; - count = 2; - maxLeadSpeed = 220; - nameSound = "missiles"; - }; - class 6Rnd_Missile_AGM_02_F: VehicleMagazine { - scope = 2; - displayNameShort = "$STR_A3_CFGMAGAZINES_38RND_80MM_ROCKETS_DNS"; - ammo = "Missile_AGM_02_F"; - count = 6; - maxLeadSpeed = 450; - nameSound = "missiles"; - }; - class 2Rnd_Missile_AGM_02_F: VehicleMagazine { - scope = 2; - displayNameShort = "$STR_A3_CFGMAGAZINES_38RND_80MM_ROCKETS_DNS"; - ammo = "Missile_AGM_02_F"; - count = 2; - maxLeadSpeed = 450; - nameSound = "missiles"; - }; - - class 7Rnd_Rocket_04_HE_F: VehicleMagazine { - scope = 2; - displayNameShort = "$STR_A3_CFGMAGAZINES_40RND_20MM_G_BELT_DNS"; - ammo = "Rocket_04_HE_F"; - count = 7; - maxLeadSpeed = 200; - nameSound = "rockets"; - }; - class 7Rnd_Rocket_04_AP_F: 7Rnd_Rocket_04_HE_F { - displayNameShort = "$STR_A3_CFGMAGAZINES_TITAN_AP_DNS"; - ammo = "Rocket_04_AP_F"; - }; - - class 4Rnd_Bomb_04_F: VehicleMagazine { - scope = 2; - displayNameShort = "$STR_A3_CFGVEHICLES_BOMB0"; - ammo = "Bomb_04_F"; - count = 4; - maxLeadSpeed = 1000; - nameSound = "cannon"; - }; - - class 500Rnd_Cannon_30mm_Plane_CAS_02_F: 1000Rnd_Gatling_30mm_Plane_CAS_01_F { - displayNameShort = ""; - ammo = "Cannon_30mm_HE_Plane_CAS_02_F"; - count = 500; - }; - - class 2Rnd_Missile_AA_03_F: 2Rnd_Missile_AA_04_F { - displayNameShort = "$STR_A3_CFGMAGAZINES_4RND_AAA_MISSILES_DNS"; - ammo = "Missile_AA_03_F"; - count = 2; - }; - class 4Rnd_Missile_AGM_01_F: 6Rnd_Missile_AGM_02_F { - displayNameShort = "$STR_A3_CFGMAGAZINES_38RND_80MM_ROCKETS_DNS"; - ammo = "Missile_AGM_01_F"; - count = 4; - }; - - class 20Rnd_Rocket_03_HE_F: 7Rnd_Rocket_04_HE_F { - displayNameShort = "$STR_A3_CFGMAGAZINES_40RND_20MM_G_BELT_DNS"; - ammo = "Rocket_03_HE_F"; - count = 20; - }; - class 20Rnd_Rocket_03_AP_F: 7Rnd_Rocket_04_AP_F { - displayNameShort = "$STR_A3_CFGMAGAZINES_TITAN_AP_DNS"; - ammo = "Rocket_03_AP_F"; - count = 20; - }; - - class 2Rnd_Bomb_03_F: 4Rnd_Bomb_04_F { - displayNameShort = "$STR_A3_CFGVEHICLES_BOMB0"; - ammo = "Bomb_03_F"; - count = 2; }; + // an extended magazine for the comanche + class 300Rnd_20mm_shells; class ACE_500Rnd_20mm_shells_Comanche: 300Rnd_20mm_shells { - displayName = "20mm"; - displayNameShort = "20mm"; - ammo = "B_20mm"; count = 500; - deflecting = 3; - initSpeed = 1030; - maxLeadSpeed = 300; - tracersEvery = 5; }; }; diff --git a/addons/aircraft/CfgVehicles.hpp b/addons/aircraft/CfgVehicles.hpp index 18be36b9e8..5f419506c0 100644 --- a/addons/aircraft/CfgVehicles.hpp +++ b/addons/aircraft/CfgVehicles.hpp @@ -8,12 +8,9 @@ class CfgVehicles { class NewTurret { class Turrets; }; - class CargoTurret; }; - class Air: AllVehicles { - class AnimationSources; - }; + class Air: AllVehicles {}; class Helicopter: Air { class Turrets { @@ -33,6 +30,7 @@ class CfgVehicles { class Turrets: Turrets { class CopilotTurret; }; + class AnimationSources; }; class Helicopter_Base_H: Helicopter_Base_F { @@ -46,7 +44,7 @@ class CfgVehicles { lockDetectionSystem = 0; incomingMissileDetectionSystem = 16; driverCanEject = 1; - //class MFD {}; + class Turrets: Turrets { class CopilotTurret: CopilotTurret { canEject = 1; @@ -55,14 +53,11 @@ class CfgVehicles { }; }; - class B_Heli_Light_01_F: Heli_Light_01_base_F { + class Heli_Light_01_unarmed_base_F: Heli_Light_01_base_F {}; + + class B_Heli_Light_01_F: Heli_Light_01_unarmed_base_F { /*class Turrets: Turrets { class CopilotTurret: CopilotTurret {}; - - class CargoTurret_01: CargoTurret {}; - class CargoTurret_02: CargoTurret_01 {}; - class CargoTurret_03: CargoTurret_02 {}; - class CargoTurret_04: CargoTurret_01 {}; };*/ }; @@ -70,7 +65,7 @@ class CfgVehicles { lockDetectionSystem = 0; incomingMissileDetectionSystem = 16; driverCanEject = 1; - //class MFD {}; + class Turrets: Turrets { class CopilotTurret: CopilotTurret { canEject = 1; @@ -84,7 +79,8 @@ class CfgVehicles { driverCanEject = 1; lockDetectionSystem = 12; incomingMissileDetectionSystem = 16; - magazines[] = {"2000Rnd_762x51_Belt_T_Green", "12Rnd_PG_missiles", "168Rnd_CMFlare_Chaff_Magazine"}; + magazines[] = {"2000Rnd_762x51_Belt_T_Green","12Rnd_PG_missiles","168Rnd_CMFlare_Chaff_Magazine"}; + class Turrets: Turrets { class CopilotTurret: CopilotTurret { canEject = 1; @@ -103,36 +99,7 @@ class CfgVehicles { lockDetectionSystem = 12; incomingMissileDetectionSystem = 16; driverCanEject = 1; - //class MFD {}; - class AnimationSources: AnimationSources { - class HitGlass1 { - source = "Hit"; - hitpoint = "HitGlass1"; - raw = 1; - }; - class HitGlass2: HitGlass1 { - hitpoint = "HitGlass2"; - }; - class HitGlass3: HitGlass1 { - hitpoint = "HitGlass3"; - }; - class HitGlass4: HitGlass1 { - hitpoint = "HitGlass4"; - }; - class Gatling { - source = "revolving"; - weapon = "ACE_gatling_20mm_Comanche"; - }; - class Hide { - source = "user"; - animPeriod = 0; - initPhase = 0; - }; - class Muzzle_flash { - source = "ammorandom"; - weapon = "ACE_gatling_20mm_Comanche"; - }; - }; + class Turrets: Turrets { class MainTurret: MainTurret { canEject = 1; @@ -141,6 +108,15 @@ class CfgVehicles { magazines[] = {"ACE_500Rnd_20mm_shells_Comanche","4Rnd_AAA_missiles","24Rnd_PG_missiles"}; }; }; + + class AnimationSources: AnimationSources { + class Gatling { + weapon = "ACE_gatling_20mm_Comanche"; + }; + class Muzzle_flash { + weapon = "ACE_gatling_20mm_Comanche"; + }; + }; }; class B_Heli_Attack_01_F: Heli_Attack_01_base_F {}; @@ -149,6 +125,7 @@ class CfgVehicles { lockDetectionSystem = 12; incomingMissileDetectionSystem = 16; driverCanEject = 1; + class Turrets: Turrets { class MainTurret: MainTurret { canEject = 1; @@ -160,6 +137,7 @@ class CfgVehicles { lockDetectionSystem = 12; incomingMissileDetectionSystem = 16; driverCanEject = 1; + class Turrets: Turrets { class CopilotTurret: CopilotTurret { canEject = 1; @@ -174,6 +152,7 @@ class CfgVehicles { canEject = 1; }; }; + /*class UserActions { class DoorL1_Open { available = 1; @@ -195,16 +174,14 @@ class CfgVehicles { lockDetectionSystem = 12; incomingMissileDetectionSystem = 16; driverCanEject = 1; - //class MFD {}; + class Turrets: Turrets { class CopilotTurret: CopilotTurret { canEject = 1; showHMD = 1; }; - - class CargoTurret_01: CargoTurret {}; - class CargoTurret_02: CargoTurret_01 {}; }; + /*class UserActions: UserActions { class DoorL1_Open { available = 1; @@ -246,9 +223,9 @@ class CfgVehicles { lockDetectionSystem = 0; incomingMissileDetectionSystem = 16; driverCanEject = 1; - //class MFD {}; weapons[] = {"M134_minigun","missiles_DAR","CMFlareLauncher"}; magazines[] = {"5000Rnd_762x51_Yellow_Belt","24Rnd_missiles","168Rnd_CMFlare_Chaff_Magazine"}; + class Turrets: Turrets { class MainTurret: MainTurret { canEject = 1; @@ -268,36 +245,37 @@ class CfgVehicles { class I_Heli_light_03_F: I_Heli_light_03_base_F { class Turrets: Turrets { class MainTurret: MainTurret {}; - - class CargoTurret_01: CargoTurret {}; - class CargoTurret_02: CargoTurret_01 {}; }; }; - class I_Heli_light_03_unarmed_base_F: I_Heli_light_03_base_F { - //class MFD {}; - }; + class I_Heli_light_03_unarmed_base_F: I_Heli_light_03_base_F {}; + class I_Heli_light_03_unarmed_F: I_Heli_light_03_unarmed_base_F {}; class Plane_CAS_01_base_F: Plane_Base_F { lockDetectionSystem = 12; incomingMissileDetectionSystem = 16; - //class MFD {}; + class Turrets; + #include }; class Plane_CAS_02_base_F: Plane_Base_F { lockDetectionSystem = 12; incomingMissileDetectionSystem = 16; + class Turrets; + #include }; class Plane_Fighter_03_base_F: Plane_Base_F { lockDetectionSystem = 12; incomingMissileDetectionSystem = 16; + class Turrets; + #include }; @@ -308,34 +286,34 @@ class CfgVehicles { }; class UAV_02_base_F: UAV { + weapons[] = {}; + magazines[] = {}; + class Turrets { class MainTurret; }; - weapons[] = {}; - magazines[] = {}; }; class UAV_02_CAS_base_F: UAV_02_base_F { + weapons[] = {}; + magazines[] = {}; + /*class Turrets: Turrets { class MainTurret: MainTurret {}; };*/ - weapons[] = {}; - magazines[] = {}; }; class B_Heli_Transport_03_base_F: Helicopter_Base_H { lockDetectionSystem = 12; incomingMissileDetectionSystem = 16; driverCanEject = 1; + class Turrets: Turrets { class CopilotTurret: CopilotTurret { canEject = 1; }; //class MainTurret: MainTurret {}; class RightDoorGun: MainTurret {}; - - class CargoTurret_01: CargoTurret {}; - class CargoTurret_02: CargoTurret_01 {}; }; }; @@ -346,9 +324,6 @@ class CfgVehicles { }; //class MainTurret: MainTurret {}; //class RightDoorGun: MainTurret {}; - - //class CargoTurret_01: CargoTurret {}; - //class CargoTurret_02: CargoTurret_01 {}; }; }; @@ -356,6 +331,7 @@ class CfgVehicles { lockDetectionSystem = 12; incomingMissileDetectionSystem = 16; driverCanEject = 1; + class Turrets: Turrets { class CopilotTurret: CopilotTurret { canEject = 1; @@ -374,15 +350,6 @@ class CfgVehicles { class LoadmasterTurret: LoadmasterTurret { canEject = 1; }; - - class CargoTurret_01: CargoTurret {}; - class CargoTurret_02: CargoTurret_01 {}; - class CargoTurret_03: CargoTurret_01 {}; - class CargoTurret_04: CargoTurret_01 {}; - class CargoTurret_05: CargoTurret_01 {}; - class CargoTurret_06: CargoTurret_05 {}; - class CargoTurret_07: CargoTurret_05 {}; - class CargoTurret_08: CargoTurret_05 {}; }; }; @@ -394,9 +361,6 @@ class CfgVehicles { class LoadmasterTurret: LoadmasterTurret { canEject = 1; }; - - class CargoTurret_01: CargoTurret {}; - class CargoTurret_02: CargoTurret_01 {}; }; }; }; diff --git a/addons/aircraft/CfgWeapons.hpp b/addons/aircraft/CfgWeapons.hpp index 321df4a3af..c5f22fc3a2 100644 --- a/addons/aircraft/CfgWeapons.hpp +++ b/addons/aircraft/CfgWeapons.hpp @@ -4,15 +4,10 @@ class Mode_Burst; class Mode_FullAuto; class CfgWeapons { - class MGunCore; - class MGun: MGunCore {}; - - class LMG_RCWS: MGun {}; - // Manual Switching Of Flare Mode class SmokeLauncher; class CMFlareLauncher: SmokeLauncher { - modes[] = {"Single", "Burst", "AIBurst"}; + modes[] = {"Single","Burst","AIBurst"}; class Single: Mode_SemiAuto { reloadTime = 0.1; }; @@ -21,13 +16,15 @@ class CfgWeapons { }; }; + // bigger mag for comanche class CannonCore; class gatling_20mm: CannonCore { - magazines[] = {"2000Rnd_20mm_shells","1000Rnd_20mm_shells","300Rnd_20mm_shells","ACE_500Rnd_20mm_shells_Comanche"}; + magazines[] += {"ACE_500Rnd_20mm_shells_Comanche"}; + // buff gatling rof class manual: CannonCore { - reloadTime = 0.023; - dispersion = 0.006; + reloadTime = 0.023; //0.04; + dispersion = 0.006; //0.0022; }; class close: manual {}; class short: close {}; @@ -36,21 +33,14 @@ class CfgWeapons { }; class ACE_gatling_20mm_Comanche: gatling_20mm { - displayName = "XM301"; - class close: close { - reloadTime = 0.04; - dispersion = 0.0022; - }; - class far: far { - reloadTime = 0.04; - dispersion = 0.0022; - }; + displayName = "$STR_ACE_Aircraft_gatling_20mm_Name"; + class manual: manual { reloadTime = 0.04; dispersion = 0.0022; - displayName = "XM301"; + displayName = "$STR_ACE_Aircraft_gatling_20mm_Name"; }; - class medium: medium { + class close: close { reloadTime = 0.04; dispersion = 0.0022; }; @@ -58,38 +48,53 @@ class CfgWeapons { reloadTime = 0.04; dispersion = 0.0022; }; + class medium: medium { + reloadTime = 0.04; + dispersion = 0.0022; + }; + class far: far { + reloadTime = 0.04; + dispersion = 0.0022; + }; }; + // buff gatling rof + class MGunCore; + class MGun: MGunCore {}; + + class LMG_RCWS: MGun {}; + class LMG_Minigun: LMG_RCWS { - magazines[] = {"1000Rnd_65x39_Belt","1000Rnd_65x39_Belt_Green","1000Rnd_65x39_Belt_Tracer_Green","1000Rnd_65x39_Belt_Tracer_Red","1000Rnd_65x39_Belt_Tracer_Yellow","1000Rnd_65x39_Belt_Yellow","2000Rnd_65x39_Belt","2000Rnd_65x39_Belt_Green","2000Rnd_65x39_Belt_Tracer_Green","2000Rnd_65x39_Belt_Tracer_Green_Splash","2000Rnd_65x39_Belt_Tracer_Red","2000Rnd_65x39_Belt_Tracer_Yellow","2000Rnd_65x39_Belt_Tracer_Yellow_Splash","2000Rnd_65x39_Belt_Yellow","2000Rnd_762x51_Belt_T_Green","2000Rnd_762x51_Belt_T_Red","2000Rnd_762x51_Belt_T_Yellow","200Rnd_65x39_Belt","200Rnd_65x39_Belt_Tracer_Green","200Rnd_65x39_Belt_Tracer_Red","200Rnd_65x39_Belt_Tracer_Yellow","5000Rnd_762x51_Belt","5000Rnd_762x51_Yellow_Belt"}; class manual: MGun { - reloadTime = 0.015; - dispersion = 0.006; + reloadTime = 0.075; //0.015; + dispersion = 0.00093; //0.006; }; class close: manual {}; class short: close {}; class medium: close {}; class far: close {}; }; + class LMG_Minigun_heli: LMG_Minigun { showAimCursorInternal = 0; class manual: manual { - reloadTime = 0.015; - dispersion = 0.006; + reloadTime = 0.015; //0.033; Note: This is a way to fast ROF (requires over 60 FPS) @todo + dispersion = 0.006; //0.0087; }; class close: manual {}; class short: close {}; class medium: close {}; class far: close {}; }; + class M134_minigun: MGunCore { class LowROF: Mode_FullAuto { - reloadTime = 0.015; - dispersion = 0.006; + reloadTime = 0.015; //0.03; same as above @todo + dispersion = 0.006; //0.0023; }; class HighROF: LowROF { - reloadTime = 0.015; - dispersion = 0.006; + reloadTime = 0.015; //0.03; + dispersion = 0.006; //0.0023; }; class close: HighROF {}; class short: close {}; @@ -100,19 +105,10 @@ class CfgWeapons { class Gatling_30mm_Plane_CAS_01_F: CannonCore { autoFire = 1; burst = 1; - reloadTime = 0.0154; class LowROF: Mode_FullAuto { autoFire = 0; - //burst = 65; - burst = 22; - //reloadTime = 0.0154; - reloadTime = 0.0462; - //sound[] = {"A3\Sounds_F_epc\weapons\cas_02_cannon",1.77828,1,3800}; - sound[] = {"A3\Sounds_F_EPC\Weapons\gau_03_burst",2.51189,1,4500,{25704,32159}}; - weaponSoundEffect = "DefaultRifle"; - dispersion = 0.005; - soundContinuous = 1; - textureType = "burst"; + burst = 22; //65; + reloadTime = 0.0462; //0.0154; //0.034; multiplier = 3; }; class close: LowROF {}; @@ -121,120 +117,4 @@ class CfgWeapons { class medium: close {}; class far: close {}; }; - - class RocketPods; - class Missile_AA_04_Plane_CAS_01_F: RocketPods { - holdsterAnimValue = 2; - aiRateOfFire = 5; - aiRateOfFireDistance = 500; - autoFire = 0; - cursor = "EmptyCursor"; - cursorAim = "missile"; - nameSound = "MissileLauncher"; - textureType = "fullAuto"; - weaponLockDelay = 3; - minRange = 300; - minRangeProbab = 0.25; - midRange = 2500; - midRangeProbab = 0.9; - maxRange = 9000; - maxRangeProbab = 0.01; - }; - - class MissileLauncher; - class Missile_AGM_02_Plane_CAS_01_F: MissileLauncher { - holdsterAnimValue = 3; - magazineReloadTime = 30; - reloadTime = 0.001; - textureType = "semi"; - weaponLockDelay = 3; - weaponSoundEffect = "DefaultRifle"; - }; - - class Rocket_04_HE_Plane_CAS_01_F: RocketPods { - holdsterAnimValue = 4; - canLock = 1; - modes[] = {"Far_AI","Medium_AI","Close_AI","Burst"}; - weaponLockDelay = 0; - class Far_AI: RocketPods { - canLock = 1; - weaponLockDelay = 0; - showToPlayer = 0; - minRange = 800; - minRangeProbab = 0.31; - midRange = 2500; - midRangeProbab = 0.71; - maxRange = 3200; - maxRangeProbab = 0.1; - burst = 1; - reloadTime = 0.001; - autoFire = 0; - aiRateOfFire = 5; - aiRateOfFireDistance = 500; - }; - class Medium_AI: Far_AI {}; - class Close_AI: Far_AI {}; - class Burst: RocketPods { - burst = 1; - reloadTime = 0.002; - minRange = 300; - minRangeProbab = 0.25; - midRange = 400; - midRangeProbab = 0.7; - maxRange = 1300; - maxRangeProbab = 0.1; - aiRateOfFire = 5; - aiRateOfFireDistance = 500; - autoFire = 0; - soundContinuous = 0; - textureType = "fullAuto"; - weaponSoundEffect = "DefaultRifle"; - }; - }; - - class Rocket_04_AP_Plane_CAS_01_F: Rocket_04_HE_Plane_CAS_01_F { - holdsterAnimValue = 5; - }; - - class Bomb_04_Plane_CAS_01_F: RocketPods { - holdsterAnimValue = 6; - aiRateOfFire = 5; - aiRateOfFireDistance = 500; - missileLockCone = 180; - nameSound = ""; - textureType = "fullAuto"; - weaponLockDelay = 1; - }; - - class Cannon_30mm_Plane_CAS_02_F: CannonCore { - scope = 1; - holdsterAnimValue = 1; - ballisticsComputer = 2; - canLock = 1; - modes[] = {"LowROF","close","near","short","medium","far"}; - nameSound = "cannon"; - shotFromTurret = 0; - muzzlePos = "Cannon_muzzleflash"; - muzzleEnd = "Cannon_barrel_end"; - selectionFireAnim = "Cannon_muzzleflash"; - autoFire = 1; - burst = 5; - reloadTime = 0.04; - class GunParticles { - class Effect { - effectName = "MachineGun2"; - positionName = "Cannon_barrel_start"; - directionName = "Cannon_barrel_end"; - }; - }; - class LowROF: Mode_FullAuto { - dispersion = 0.0055; - reloadTime = 0.04; - }; - class close: LowROF {}; - class near: close {}; - class short: close {}; - class medium: close {}; - class far: close {}; - }; }; diff --git a/addons/aircraft/config.cpp b/addons/aircraft/config.cpp index 93e4eb8efe..86135c4bc9 100644 --- a/addons/aircraft/config.cpp +++ b/addons/aircraft/config.cpp @@ -6,7 +6,7 @@ class CfgPatches { weapons[] = {}; requiredVersion = REQUIRED_VERSION; requiredAddons[] = {"ace_common"}; - author[] = {"KoffeinFlummi","Crusty"}; + author[] = {"KoffeinFlummi","Crusty","commy2"}; authorUrl = "https://github.com/KoffeinFlummi/"; VERSION_CONFIG; }; diff --git a/addons/aircraft/stringtable.xml b/addons/aircraft/stringtable.xml index da013cac5e..4d1c49fff6 100644 --- a/addons/aircraft/stringtable.xml +++ b/addons/aircraft/stringtable.xml @@ -14,6 +14,18 @@ Rajada Raffica + + XM301 + XM301 + XM301 + XM301 + XM301 + XM301 + XM301 + XM301 + XM301 + XM301 + Open Cargo Door Laderampe öffnen @@ -35,4 +47,4 @@ Закрыть грузовой отсек - \ No newline at end of file + diff --git a/addons/attach/$PBOPREFIX$ b/addons/attach/$PBOPREFIX$ index 1e4e48a4ca..71a2f40af8 100644 --- a/addons/attach/$PBOPREFIX$ +++ b/addons/attach/$PBOPREFIX$ @@ -1 +1 @@ -z\ace\Addons\laser \ No newline at end of file +z\ace\Addons\attach \ No newline at end of file diff --git a/addons/attach/CfgEventHandlers.hpp b/addons/attach/CfgEventHandlers.hpp index 5eca7fa129..f0a9f14d91 100644 --- a/addons/attach/CfgEventHandlers.hpp +++ b/addons/attach/CfgEventHandlers.hpp @@ -1,5 +1,6 @@ + class Extended_PreInit_EventHandlers { - class ADDON { - init = QUOTE( call COMPILE_FILE(XEH_preInit) ); - }; -}; \ No newline at end of file + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; diff --git a/addons/attach/CfgMagazines.hpp b/addons/attach/CfgMagazines.hpp index 293a075d70..d63b8db36b 100644 --- a/addons/attach/CfgMagazines.hpp +++ b/addons/attach/CfgMagazines.hpp @@ -1,10 +1,12 @@ + class CfgMagazines { - class CA_Magazine; - class B_IR_Grenade: CA_Magazine { - ACE_Attachable = 1; - }; - class SmokeShell; - class Chemlight_green: SmokeShell { - ACE_Attachable = 1; - }; -}; \ No newline at end of file + class CA_Magazine; + class B_IR_Grenade: CA_Magazine { + ACE_Attachable = 1; + }; + + class SmokeShell; + class Chemlight_green: SmokeShell { + ACE_Attachable = 1; + }; +}; diff --git a/addons/attach/CfgVehicles.hpp b/addons/attach/CfgVehicles.hpp index a8653b9e06..1cd65127a6 100644 --- a/addons/attach/CfgVehicles.hpp +++ b/addons/attach/CfgVehicles.hpp @@ -1,104 +1,149 @@ -#define MACRO_ADDITEM(ITEM,COUNT) class _xx_##ITEM { \ - name = #ITEM; \ - count = COUNT; \ -}; + +#define MACRO_ATTACHTOVEHICLE \ + class ACE_Actions { \ + class GVAR(AttachVehicle) { \ + displayName = "$STR_ACE_Attach_AttachDetach"; \ + condition = QUOTE(([ARR_3(_player, _target, '')] call FUNC(canAttach))); \ + statement = QUOTE( [ARR_2(_player, _target)] call FUNC(openAttachUI);); \ + exceptions[] = {"ACE_Drag_isNotDragging"}; \ + showDisabled = 0; \ + priority = 0; \ + icon = PATHTOF(UI\attach_ca.paa); \ + distance = 4; \ + }; \ + class GVAR(DetachVehicle) { \ + displayName = "$STR_ACE_Attach_Detach"; \ + condition = QUOTE(([ARR_2(_player, _target)] call FUNC(canDetach))); \ + statement = QUOTE( [ARR_2(_player, _target)] call FUNC(detach) ); \ + exceptions[] = {"ACE_Drag_isNotDragging"}; \ + showDisabled = 0; \ + priority = 0; \ + icon = PATHTOF(UI\detach_ca.paa); \ + distance = 4; \ + }; \ + }; class CfgVehicles { - class Man; - class CAManBase: Man { - class ACE_SelfActions { - class ACE_Equipment { - class GVAR(Attach) { - displayName = "$STR_ACE_Attach_AttachDetach"; - condition = QUOTE( [_player, ''] call FUNC(canAttach) ); - statement = QUOTE( [_player] call FUNC(openAttachUI); ); - exceptions[] = {"ACE_Drag_isNotDragging"}; - showDisabled = 0; - priority = 5; - icon = PATHTOF(UI\attach_ca.paa); - hotkey = "T"; + class LandVehicle; + class Car: LandVehicle { + MACRO_ATTACHTOVEHICLE + }; + + class Tank: LandVehicle { + MACRO_ATTACHTOVEHICLE + }; + + class Air; + class Helicopter: Air { + MACRO_ATTACHTOVEHICLE + }; + + class Plane: Air { + MACRO_ATTACHTOVEHICLE + }; + + class Ship; + class Ship_F: Ship { + MACRO_ATTACHTOVEHICLE + }; + + class Man; + class CAManBase: Man { + class ACE_SelfActions { + class ACE_Equipment { + class GVAR(Attach) { + displayName = "$STR_ACE_Attach_AttachDetach"; + condition = QUOTE(([ARR_3(_player, _player, '')] call FUNC(canAttach))); + statement = QUOTE( [ARR_2(_player, _player)] call FUNC(openAttachUI); ); + exceptions[] = {"ACE_Drag_isNotDragging"}; + showDisabled = 0; + priority = 5; + icon = PATHTOF(UI\attach_ca.paa); + hotkey = "T"; + }; + class GVAR(Detach) { + displayName = "$STR_ACE_Attach_Detach"; + condition = QUOTE(([ARR_2(_player, _player)] call FUNC(canDetach))); + statement = QUOTE( [ARR_2(_player, _player)] call FUNC(detach) ); + exceptions[] = {"ACE_Drag_isNotDragging"}; + showDisabled = 0; + priority = 5; + icon = PATHTOF(UI\detach_ca.paa); + hotkey = "T"; + }; + }; }; - class GVAR(Detach) { - displayName = "$STR_ACE_Attach_Detach"; - condition = QUOTE( [_player] call FUNC(canDetach) ); - statement = QUOTE( [_player] call FUNC(detach) ); - exceptions[] = {"ACE_Drag_isNotDragging"}; - showDisabled = 0; - priority = 5; - icon = PATHTOF(UI\detach_ca.paa); - hotkey = "T"; + }; + + class All; + class ACE_IR_Strobe_Effect: All { + scope = 1; + displayName = "IR Strobe"; + model = "\A3\Weapons_F\empty.p3d"; + simulation = "nvmarker"; + + class NVGMarker { + diffuse[] = {0.006, 0.006, 0.006, 1}; + ambient[] = {0.005, 0.005, 0.005, 1}; + brightness = 0.2; + name = "pozicni blik"; + drawLightSize = 0.2; + drawLightCenterSize = 0.003; + activeLight = 0; + blinking=1; + blinkingStartsOn=1; + blinkingPattern[] = {2,2}; + blinkingPatternGuarantee = false; + dayLight = 0; + onlyInNvg = 1; + useFlare = 0; }; - }; + + side = 7;//-1=NO_SIDE yellow box,3=CIV grey box,4=NEUTRAL yellow box,6=FRIENDLY green box,7=LOGIC no radar signature + accuracy = 1000; + cost = 0; + armor = 500; + threat[] = {0,0,0}; + nameSound = ""; + type = 0; + weapons[] = {}; + magazines[] = {}; + nvTarget = 1; + destrType = "DestructNo"; + brightness = 20; }; - }; - class All; - class ACE_IR_Strobe_Effect: All { - scope = 1; - displayName = "IR Strobe"; - model = "\A3\Weapons_F\empty.p3d"; - simulation = "nvmarker"; - - class NVGMarker { - diffuse[] = {0,0,0}; - ambient[] = {0,0,0}; - brightness = 0.004; - name = "pozicni blik"; - drawLight = 1; - drawLightSize = 0.005; - drawLightCenterSize = 0.003; - activeLight = 0; - blinking=1; - dayLight = 0; - onlyInNvg = 1; - useFlare = 0; + class NATO_Box_Base; + class Box_NATO_Support_F: NATO_Box_Base { + class TransportItems { + MACRO_ADDITEM(ACE_IR_Strobe_Item,12); + }; }; - side = 7;//-1=NO_SIDE yellow box,3=CIV grey box,4=NEUTRAL yellow box,6=FRIENDLY green box,7=LOGIC no radar signature - accuracy = 1000; - cost = 0; - armor = 500; - threat[] = {0,0,0}; - nameSound = ""; - type = 0; - weapons[] = {}; - magazines[] = {}; - nvTarget = 1; - destrType = "DestructNo"; - brightness = 20; - }; - class NATO_Box_Base; - class EAST_Box_Base; - class IND_Box_Base; - class FIA_Box_Base_F; - - class Box_NATO_Support_F: NATO_Box_Base { - class TransportItems { - MACRO_ADDITEM(ACE_IR_Strobe_Item,12) + class EAST_Box_Base; + class Box_East_Support_F: EAST_Box_Base { + class TransportItems { + MACRO_ADDITEM(ACE_IR_Strobe_Item,12); + }; }; - }; - class Box_East_Support_F: EAST_Box_Base { - class TransportItems { - MACRO_ADDITEM(ACE_IR_Strobe_Item,12) + class IND_Box_Base; + class Box_IND_Support_F: IND_Box_Base { + class TransportItems { + MACRO_ADDITEM(ACE_IR_Strobe_Item,12); + }; }; - }; - class Box_IND_Support_F: IND_Box_Base { - class TransportItems { - MACRO_ADDITEM(ACE_IR_Strobe_Item,12) + class FIA_Box_Base_F; + class Box_FIA_Support_F: FIA_Box_Base_F { + class TransportItems { + MACRO_ADDITEM(ACE_IR_Strobe_Item,12); + }; }; - }; - class Box_FIA_Support_F: FIA_Box_Base_F { - class TransportItems { - MACRO_ADDITEM(ACE_IR_Strobe_Item,12) + class ACE_Box_Misc: Box_NATO_Support_F { + class TransportItems { + MACRO_ADDITEM(ACE_IR_Strobe_Item,12); + }; }; - }; - - class ACE_Box_Misc: Box_NATO_Support_F { - class TransportItems { - MACRO_ADDITEM(ACE_IR_Strobe_Item,12) - }; - }; -}; \ No newline at end of file +}; diff --git a/addons/attach/CfgWeapons.hpp b/addons/attach/CfgWeapons.hpp index 65ca397ec9..4ad34832c5 100644 --- a/addons/attach/CfgWeapons.hpp +++ b/addons/attach/CfgWeapons.hpp @@ -1,16 +1,19 @@ -class CfgWeapons { - class ACE_ItemCore; - class InventoryItem_Base_F; - class ACE_IR_Strobe_Item: ACE_ItemCore { - displayName = "$STR_ACE_IrStrobe_Name"; - descriptionShort = "$STR_ACE_IrStrobe_Description"; - model = "\A3\weapons_F\ammo\mag_univ.p3d"; - picture = PATHTOF(UI\irstrobe_item.paa); - scope = 2; - ACE_attachable = 1; - class ItemInfo: InventoryItem_Base_F { - mass = 1; +class CfgWeapons { + class ACE_ItemCore; + class InventoryItem_Base_F; + + class ACE_IR_Strobe_Item: ACE_ItemCore { + ACE_attachable = 1; + author = "$STR_ACE_Common_ACETeam"; + scope = 2; + displayName = "$STR_ACE_IrStrobe_Name"; + descriptionShort = "$STR_ACE_IrStrobe_Description"; + model = "\A3\weapons_F\ammo\mag_univ.p3d"; + picture = PATHTOF(UI\irstrobe_item.paa); + + class ItemInfo: InventoryItem_Base_F { + mass = 1; + }; }; - }; -}; \ No newline at end of file +}; diff --git a/addons/attach/README.md b/addons/attach/README.md index 7ac36f109d..5fb73d0645 100644 --- a/addons/attach/README.md +++ b/addons/attach/README.md @@ -1,7 +1,8 @@ ace_attach ========== -Introducing the ability to attach various throwables to yourself to mark your position and assist in IFF. +Introducing the ability to attach various throwables to yourself or vehicles, to mark your position and assist in IFF. +Adds item `ACE_IR_Strobe_Item`. ## Maintainers @@ -11,3 +12,4 @@ The people responsible for merging changes to this component or answering potent - [esteldunedain](https://github.com/esteldunedain) - [bux578](https://github.com/bux578) - [KoffeinFlummi](https://github.com/KoffeinFlummi) +- [PabstMirror](https://github.com/PabstMirror) diff --git a/addons/attach/XEH_preInit.sqf b/addons/attach/XEH_preInit.sqf index 279ea4d4c7..63eb2e8438 100644 --- a/addons/attach/XEH_preInit.sqf +++ b/addons/attach/XEH_preInit.sqf @@ -7,5 +7,7 @@ PREP(canAttach); PREP(canDetach); PREP(detach); PREP(openAttachUI); +PREP(placeApprove); +PREP(placeCancel); ADDON = true; diff --git a/addons/attach/config.cpp b/addons/attach/config.cpp index 4143f6eb44..dd7e1add3b 100644 --- a/addons/attach/config.cpp +++ b/addons/attach/config.cpp @@ -1,21 +1,18 @@ #include "script_component.hpp" class CfgPatches { - class ADDON { - units[] = {}; - weapons[] = {"ACE_IR_Strobe_Item"}; - requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ace_common", "ace_interaction"}; - author[] = {"KoffeinFlummi", "eRazeri", "CAA-Picard"}; - authorUrl = "https://github.com/KoffeinFlummi/"; - VERSION_CONFIG; - }; + class ADDON { + units[] = {}; + weapons[] = {"ACE_IR_Strobe_Item"}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_interaction"}; + author[] = {"KoffeinFlummi","eRazeri","CAA-Picard"}; + authorUrl = "https://github.com/KoffeinFlummi/"; + VERSION_CONFIG; + }; }; #include "CfgEventHandlers.hpp" - -#include "CfgVehicles.hpp" - -#include "CfgWeapons.hpp" - #include "CfgMagazines.hpp" +#include "CfgVehicles.hpp" +#include "CfgWeapons.hpp" diff --git a/addons/attach/functions/fnc_attach.sqf b/addons/attach/functions/fnc_attach.sqf index ab920c6428..3aa06bacc2 100644 --- a/addons/attach/functions/fnc_attach.sqf +++ b/addons/attach/functions/fnc_attach.sqf @@ -1,62 +1,90 @@ +/* + * Author: eRazeri and CAA-Picard + * Attach an item to the unit + * + * Arguments: + * 0: unit doing the attach (player) + * 1: vehicle that it will be attached to (player or vehicle) + * 2: Name of the attachable item + * + * Return Value: + * Nothing + * + * Example: + * Nothing + * + * Public: No + */ #include "script_component.hpp" -/* -Author: eRazeri and CAA-Picard +PARAMS_3(_unit,_attachToVehicle,_itemName); -Attach an item to the unit +//Sanity Check (_unit has item in inventory, not over attach limit) +if !([_unit, _attachToVehicle, _itemName] call FUNC(canAttach)) exitWith {ERROR("Tried to attach, but check failed");}; -Arguments: -0: unit -1: Item name +private ["_itemVehClass", "_onAtachText", "_selfAttachPosition"]; -Return Value: -none -*/ +_itemVehClass = ""; +_onAtachText = ""; +_selfAttachPosition = [_unit, [-0.05, 0, 0.12], "rightshoulder"]; -private ["_unit", "_itemName", "_attachedItem"]; - -_unit = _this select 0; -_itemName = _this select 1; - -// Check if unit has an attached item -if (_unit getVariable [QGVAR(ItemName), ""] != "") exitWith {}; - -// Check if the unit still has the item -if !((_itemName in items _unit) or (_itemName in magazines _unit)) exitWith {}; - -// Attach item -switch true do { - case (_itemName == "ACE_IR_Strobe_Item") : { - _attachedItem = "ACE_IR_Strobe_Effect" createVehicle [0,0,0]; - _attachedItem attachTo [_unit,[0,-0.11,0.16],"pilot"];//makes it attach to the head a bit better, shoulder is not good for visibility - eRazeri - [localize "STR_ACE_Attach_IrStrobe_Attached"] call EFUNC(common,displayTextStructured); - }; - case (_itemName == "B_IR_Grenade") : { - _attachedItem = "B_IRStrobe" createVehicle [0,0,0]; - _attachedItem attachTo [_unit,[-0.05,0,0.12],"rightshoulder"]; - [localize "STR_ACE_Attach_IrGrenade_Attached"] call EFUNC(common,displayTextStructured); - }; - case (_itemName == "O_IR_Grenade") : { - _attachedItem = "O_IRStrobe" createVehicle [0,0,0]; - _attachedItem attachTo [_unit,[-0.05,0,0.12],"rightshoulder"]; - [localize "STR_ACE_Attach_IrGrenade_Attached"] call EFUNC(common,displayTextStructured); - }; - case (_itemName == "I_IR_Grenade") : { - _attachedItem = "I_IRStrobe" createVehicle [0,0,0]; - _attachedItem attachTo [_unit,[-0.05,0,0.12],"rightshoulder"]; - [localize "STR_ACE_Attach_IrGrenade_Attached"] call EFUNC(common,displayTextStructured); - }; - case (_itemName == "Chemlight_blue" or {_itemName == "Chemlight_green"} or {_itemName == "Chemlight_red"} or {_itemName == "Chemlight_yellow"}) : { - _attachedItem = _itemName createVehicle [0,0,0]; - _attachedItem attachTo [_unit,[-0.05,0,0.12],"rightshoulder"]; - [localize "STR_ACE_Attach_Chemlight_Attached"] call EFUNC(common,displayTextStructured);; - }; - default { - if (true) exitWith {}; - }; +switch (true) do { + case (_itemName == "ACE_IR_Strobe_Item"): { + _itemVehClass = "ACE_IR_Strobe_Effect"; + _onAtachText = localize "STR_ACE_Attach_IrStrobe_Attached"; + //_selfAttachPosition = [_unit, [0, -0.11, 0.16], "pilot"]; //makes it attach to the head a bit better, shoulder is not good for visibility - eRazeri + }; + case (_itemName == "B_IR_Grenade"): { + _itemVehClass = "B_IRStrobe"; + _onAtachText = localize "STR_ACE_Attach_IrGrenade_Attached"; + }; + case (_itemName == "O_IR_Grenade"): { + _itemVehClass = "O_IRStrobe"; + _onAtachText = localize "STR_ACE_Attach_IrGrenade_Attached"; + }; + case (_itemName == "I_IR_Grenade"): { + _itemVehClass = "I_IRStrobe"; + _onAtachText = localize "STR_ACE_Attach_IrGrenade_Attached"; + }; + case (toLower _itemName in ["chemlight_blue", "chemlight_green", "chemlight_red", "chemlight_yellow"]): { + _itemVehClass = _itemName; + _onAtachText = localize "STR_ACE_Attach_Chemlight_Attached"; + }; }; -// Remove item -_unit removeItem _itemName; -_unit setVariable [QGVAR(ItemName), _itemName, true]; -_unit setVariable [QGVAR(Item), _attachedItem, true]; +if (_itemVehClass == "") exitWith {ERROR("no _itemVehClass for Item");}; + +if (_unit == _attachToVehicle) then { //Self Attachment + _unit removeItem _itemName; // Remove item + _attachedItem = _itemVehClass createVehicle [0,0,0]; + _attachedItem attachTo _selfAttachPosition; + [_onAtachText] call EFUNC(common,displayTextStructured); + _attachToVehicle setVariable [QGVAR(Objects), [_attachedItem], true]; + _attachToVehicle setVariable [QGVAR(ItemNames), [_itemName], true]; +} else { + GVAR(setupObject) = _itemVehClass createVehicleLocal [0,0,-10000]; + GVAR(setupObject) enableSimulationGlobal false; + GVAR(SetupPlacmentText) = _onAtachText; + GVAR(SetupPlacmentItem) = _itemName; + GVAR(SetupAttachVehicle) = _attachToVehicle; + GVAR(placer) = _unit; + [_unit, QGVAR(vehAttach), true] call EFUNC(common,setForceWalkStatus); + + [QGVAR(PlacementEachFrame),"OnEachFrame", { + private "_player"; + _player = ACE_player; + //Stop if player switch or player gets to far from vehicle + if (GVAR(placer) != _player || {_player distance GVAR(SetupAttachVehicle) > 7}) exitWith { + call FUNC(placeCancel); + }; + GVAR(pfeh_running) = true; + _pos = (ASLtoATL eyePos _player) vectorAdd (positionCameraToWorld [0,0,1] vectorDiff positionCameraToWorld [0,0,0]); + GVAR(setupObject) setPosATL _pos; + }] call BIS_fnc_addStackedEventHandler; // @todo replace with CBA PFH + + //had to delay the mouseHint, not sure why + [{[localize "STR_ACE_Attach_PlaceAction", localize "STR_ACE_Attach_CancelAction"] call EFUNC(interaction,showMouseHint)}, [], 0, 0] call EFUNC(common,waitAndExecute); + + _unit setVariable [QGVAR(placeActionEH), [_unit, "DefaultAction", {GVAR(pfeh_running) && {!isNull (GVAR(setupObject))}}, {call FUNC(placeApprove);}] call EFUNC(common,AddActionEventHandler)]; + _unit setVariable [QGVAR(cancelActionEH), [_unit, "MenuBack", {GVAR(pfeh_running) && {!isNull (GVAR(setupObject))}}, {call FUNC(placeCancel);}] call EFUNC(common,AddActionEventHandler)]; +}; diff --git a/addons/attach/functions/fnc_canAttach.sqf b/addons/attach/functions/fnc_canAttach.sqf index fe5191d7e2..1c33f7b112 100644 --- a/addons/attach/functions/fnc_canAttach.sqf +++ b/addons/attach/functions/fnc_canAttach.sqf @@ -1,21 +1,27 @@ -#include "script_component.hpp" - /* * Author: commy2 - * * Check if a unit can attach a specific item. - * - * Argument: - * 0: Unit that wants to attach the object (Object) - * 1: Name of the attachable item (String) - * - * Return value: - * Boolean (Bool) + * + * Arguments: + * 0: unit doing the attach (player) + * 1: vehicle that it will be attached to (player or vehicle) + * 2: Name of the attachable item + * + * Return Value: + * Boolean + * + * Example: + * Nothing + * + * Public: No */ +#include "script_component.hpp" -private ["_unit", "_item"]; +PARAMS_3(_unit,_attachToVehicle,_item); -_unit = _this select 0; -_item = _this select 1; +private ["_attachLimit", "_attachedObjects"]; -canStand _unit && {_unit getVariable [QGVAR(ItemName), ""] == ""} && {_item in (magazines _unit + items _unit + [""])} +_attachLimit = [10, 1] select (_unit == _attachToVehicle); +_attachedObjects = _attachToVehicle getVariable [QGVAR(Objects), []]; + +canStand _unit && {alive _attachToVehicle} && {count _attachedObjects < _attachLimit} && {_item in (itemsWithMagazines _unit + [""])} diff --git a/addons/attach/functions/fnc_canDetach.sqf b/addons/attach/functions/fnc_canDetach.sqf index 3ddfc6c11e..ad2f68776c 100644 --- a/addons/attach/functions/fnc_canDetach.sqf +++ b/addons/attach/functions/fnc_canDetach.sqf @@ -1,19 +1,40 @@ -#include "script_component.hpp" - /* * Author: commy2 - * * Check if a unit has an item attached and if it can remove that item. - * - * Argument: - * 0: Unit that wants to detach something (Object) - * - * Return value: - * Boolean (Bool) + * + * Arguments: + * 0: unit doing the detaching (player) + * 1: vehicle that it will be detached from (player or vehicle) + * + * Return Value: + * Boolean + * + * Example: + * Nothing + * + * Public: No */ +#include "script_component.hpp" -private "_unit"; +PARAMS_2(_unit,_attachToVehicle); -_unit = _this select 0; +private ["_attachedObjects", "_inRange"]; -canStand _unit && {_unit getVariable [QGVAR(ItemName), ""] != ""} +_attachedObjects = _attachToVehicle getVariable [QGVAR(Objects), []]; + +_inRange = false; +if (_unit == _attachToVehicle) then { + _inRange = count _attachedObjects > 0; +} else { + //Scan if unit is within range (using 2d distance) + private ["_unitPos", "_objectPos"]; + _unitPos = getPos _unit; + _unitPos set [2,0]; + { + _objectPos = getPos _x; + _objectPos set [2, 0]; + if (_objectPos distance _unitPos < 4) exitWith {_inRange = true}; + } forEach _attachedObjects; +}; + +canStand _unit && {_inRange} && {alive _attachToVehicle} diff --git a/addons/attach/functions/fnc_detach.sqf b/addons/attach/functions/fnc_detach.sqf index 3ecac44d62..8fb9e3cc9c 100644 --- a/addons/attach/functions/fnc_detach.sqf +++ b/addons/attach/functions/fnc_detach.sqf @@ -1,63 +1,86 @@ +/* + * Author: eRazeri and CAA-Picard + * Detach an item from a unit + * + * Arguments: + * 0: unit doing the attaching (player) + * 1: vehicle that it will be detached from (player or vehicle) + * + * Return Value: + * Nothing + * + * Example: + * Nothing + * + * Public: No + */ #include "script_component.hpp" -/* -Author: eRazeri and CAA-Picard +PARAMS_2(_unit,_attachToVehicle); -Detach an item from a unit +private ["_attachedObjects", "_attachedItems"]; -Arguments: -unit +_attachedObjects = _attachToVehicle getVariable [QGVAR(Objects), []]; +_attachedItems = _attachToVehicle getVariable [QGVAR(ItemNames), []]; -Return Value: -none -*/ +private ["_attachedObject", "_attachedIndex", "_itemName", "_minDistance", "_unitPos", "_objectPos"]; -private ["_unit", "_itemName", "_count", "_attachedItem", "_fnc_detachDelay"]; +_attachedObject = objNull; +_attachedIndex = -1; +_itemName = ""; -_unit = _this select 0; -_itemName = _unit getVariable [QGVAR(ItemName), ""]; -_attachedItem = _unit getVariable [QGVAR(Item), objNull]; +//Find closest attached object +_minDistance = 1000; +_unitPos = getPos _unit; +_unitPos set [2,0]; +{ + _objectPos = getPos _x; + _objectPos set [2, 0]; + if (_objectPos distance _unitPos < _minDistance) then { + _minDistance = _objectPos distance _unitPos; + _attachedObject = _x; + _itemName = _attachedItems select _forEachIndex; + _attachedIndex = _forEachIndex; + }; +} forEach _attachedObjects; // Check if unit has an attached item -if (_itemName == "") exitWith {}; +if (isNull _attachedObject || {_itemName == ""}) exitWith {ERROR("Could not find attached object")}; -// Add item to inventory -_count = (count items _unit) + (count magazines _unit); -_unit addItem _itemName; -if ((count items _unit) + (count magazines _unit) <= _count) exitWith { - [localize "STR_ACE_Attach_Inventory_Full"] call EFUNC(common,displayTextStructured); +// Exit if can't add the item +if !(_unit canAdd _itemName) exitWith { + [localize "STR_ACE_Attach_Inventory_Full"] call EFUNC(common,displayTextStructured); }; -if (_itemName == "B_IR_Grenade" or _itemName == "O_IR_Grenade" or _itemName == "I_IR_Grenade") then { - // Hack for dealing with X_IR_Grenade effect not dissapearing on deleteVehicle - detach _attachedItem; - _attachedItem setPos [getPos _unit select 0, getPos _unit select 1, ((getPos _unit select 2) - 1000)]; - // Delete attached item after 0.5 seconds - _fnc_detachDelay = { - deleteVehicle (_this select 0); - }; - [_fnc_detachDelay, [_attachedItem], 0.5, 0] call EFUNC(common,waitAndExecute); +// Add item to inventory +_unit addItem _itemName; + +if (toLower _itemName in ["b_ir_grenade", "o_ir_grenade", "i_ir_grenade"]) then { + // Hack for dealing with X_IR_Grenade effect not dissapearing on deleteVehicle + detach _attachedObject; + _attachedObject setPos ((getPos _unit) vectorAdd [0, 0, -1000]); + // Delete attached item after 0.5 seconds + [{deleteVehicle (_this select 0)}, [_attachedObject], 0.5, 0] call EFUNC(common,waitAndExecute); } else { - // Delete attached item - deleteVehicle _attachedItem; + // Delete attached item + deleteVehicle _attachedObject; }; // Reset unit variables -_unit setVariable [QGVAR(ItemName),"", true]; -_unit setVariable [QGVAR(Item),nil, true]; +_attachedObjects deleteAt _attachedIndex; +_attachedItems deleteAt _attachedIndex; +_attachToVehicle setVariable [QGVAR(Objects), _attachedObjects, true]; +_attachToVehicle setVariable [QGVAR(ItemNames), _attachedItems, true]; // Display message -switch true do { - case (_itemName == "ACE_IR_Strobe_Item") : { - [localize "STR_ACE_Attach_IrStrobe_Detached"] call EFUNC(common,displayTextStructured); - }; - case (_itemName == "B_IR_Grenade" or _itemName == "O_IR_Grenade" or _itemName == "I_IR_Grenade") : { - [localize "STR_ACE_Attach_IrGrenade_Detached"] call EFUNC(common,displayTextStructured); - }; - case (_itemName == "Chemlight_blue" or {_itemName == "Chemlight_green"} or {_itemName == "Chemlight_red"} or {_itemName == "Chemlight_yellow"}) : { - [localize "STR_ACE_Attach_Chemlight_Detached"] call EFUNC(common,displayTextStructured); - }; - default { - if (true) exitWith {}; - }; +switch (true) do { + case (_itemName == "ACE_IR_Strobe_Item") : { + [localize "STR_ACE_Attach_IrStrobe_Detached"] call EFUNC(common,displayTextStructured); + }; + case (toLower _itemName in ["b_ir_grenade", "o_ir_grenade", "i_ir_grenade"]) : { + [localize "STR_ACE_Attach_IrGrenade_Detached"] call EFUNC(common,displayTextStructured); + }; + case (toLower _itemName in ["chemlight_blue", "chemlight_green", "chemlight_red", "chemlight_yellow"]) : { + [localize "STR_ACE_Attach_Chemlight_Detached"] call EFUNC(common,displayTextStructured); + }; }; diff --git a/addons/attach/functions/fnc_openAttachUI.sqf b/addons/attach/functions/fnc_openAttachUI.sqf index 97046fa80b..5533956bb6 100644 --- a/addons/attach/functions/fnc_openAttachUI.sqf +++ b/addons/attach/functions/fnc_openAttachUI.sqf @@ -1,63 +1,67 @@ +/* + * Author: Garth de Wet (LH) + * Opens the UI for attaching objects. + * + * Arguments: + * 0: unit + * 1: target + * + * Return Value: + * Nothing + * + * Example: + * Nothing + * + * Public: No + */ #include "script_component.hpp" -/* - Author: Garth de Wet (LH) +private ["_actions", "_attachables", "_item"]; - Description: - Opens the UI for attaching objects. +PARAMS_2(_unit,_target); - Parameters: - 0: OBJECT - unit - - Returns: - Nothing - - Example: - [player] call ACE_Attach_fnc_openAttachUI; -*/ -private ["_unit", "_actions", "_attachables", "_item"]; -_unit = _this select 0; +GVAR(attachTarget) = _target; _listed = []; _attachables = magazines _unit; _actions = [localize "STR_ACE_Attach_AttachDetach", localize "STR_ACE_Attach_Attach"] call EFUNC(interaction,prepareSelectMenu); { - if !(_x in _listed) then { - _item = ConfigFile >> "CfgMagazines" >> _x; - if (getNumber (_item >> "ACE_Attachable") == 1) then { - _actions = [ - _actions, - getText(_item >> "displayName"), - getText(_item >> "picture"), - _x - ] call EFUNC(interaction,addSelectableItem); + if !(_x in _listed) then { + _item = ConfigFile >> "CfgMagazines" >> _x; + if (getNumber (_item >> "ACE_Attachable") == 1) then { + _actions = [ + _actions, + getText(_item >> "displayName"), + getText(_item >> "picture"), + _x + ] call EFUNC(interaction,addSelectableItem); + }; + _listed pushBack _x; }; - _listed pushBack _x; - }; } forEach _attachables; _attachables = items _unit; { - if !(_x in _listed) then { - _item = ConfigFile >> "CfgWeapons" >> _x; - if (getNumber (_item >> "ACE_Attachable") == 1) then { - _actions = [ - _actions, - getText(_item >> "displayName"), - getText(_item >> "picture"), - _x - ] call EFUNC(interaction,addSelectableItem); + if !(_x in _listed) then { + _item = ConfigFile >> "CfgWeapons" >> _x; + if (getNumber (_item >> "ACE_Attachable") == 1) then { + _actions = [ + _actions, + getText(_item >> "displayName"), + getText(_item >> "picture"), + _x + ] call EFUNC(interaction,addSelectableItem); + }; + _listed pushBack _x; }; - _listed pushBack _x; - }; } forEach _attachables; [ - _actions, - { - [ACE_player, _this] call FUNC(attach); - call EFUNC(interaction,hideMenu); - }, - { - call EFUNC(interaction,hideMenu); - if !(profileNamespace getVariable [QEGVAR(interaction,AutoCloseMenu), false]) then {"Default" call EFUNC(interaction,openMenuSelf)}; - } + _actions, + { + [ACE_player, GVAR(attachTarget), _this] call FUNC(attach); + call EFUNC(interaction,hideMenu); + }, + { + call EFUNC(interaction,hideMenu); + if !(profileNamespace getVariable [QEGVAR(interaction,AutoCloseMenu), false]) then {"Default" call EFUNC(interaction,openMenuSelf)}; + } ] call EFUNC(interaction,openSelectMenu); diff --git a/addons/attach/functions/fnc_placeApprove.sqf b/addons/attach/functions/fnc_placeApprove.sqf new file mode 100644 index 0000000000..c6277e2961 --- /dev/null +++ b/addons/attach/functions/fnc_placeApprove.sqf @@ -0,0 +1,110 @@ +/* + * Author: Pabst Mirror (based on Explosive attach by Garth de Wet (LH)) + * Approves placement of the lightObject, scans for an appropriate location and attaches + * + * Arguments: + * Nothing + * + * Return Value: + * Nothing + * + * Example: + * Nothing + * + * Public: No + */ +#include "script_component.hpp" + +private ["_setupObject", "_setupClassname", "_itemClassname", "_placementText", "_attachToVehicle", "_placer", "_startingPosition", "_startingOffset", "_distanceFromCenter", "_closeInUnitVector", "_keepGoingCloser", "_closeInDistance", "_endPosTestOffset", "_endPosTest", "_startingPosShifted", "_startASL", "_endPosShifted", "_endASL", "_attachedObject", "_currentObjects", "_currentItemNames"]; + + +if (GVAR(pfeh_running)) then { + [QGVAR(PlacementEachFrame),"OnEachFrame"] call BIS_fnc_removeStackedEventHandler; + GVAR(pfeh_running) = false; +}; + +_setupObject = GVAR(setupObject); +_setupClassname = typeOf _setupObject; +_itemClassname = GVAR(SetupPlacmentItem); +_placementText = GVAR(SetupPlacmentText); +_attachToVehicle = GVAR(SetupAttachVehicle); +_placer = GVAR(placer); + +GVAR(SetupPlacmentItem) = ""; +GVAR(SetupPlacmentText) = ""; +GVAR(setupObject) = objNull; +GVAR(SetupAttachVehicle) = objNull; +GVAR(placer) = objNull; + +[_placer, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); +[_placer, "DefaultAction", _placer getVariable [QGVAR(placeActionEH), -1]] call EFUNC(common,removeActionEventHandler); +[_placer, "MenuBack", _placer getVariable [QGVAR(cancelActionEH), -1]] call EFUNC(common,removeActionEventHandler); +call EFUNC(interaction,hideMouseHint); + +//A player can release the attachObject with it floating in mid-air. +//This will use lineIntersectsWith to scan towards the center of the vehicle to find a collision +//ArmA's collision detection is of couse terrible and often misses collisions (difference between what we see and collision LOD) +//So it does multiple scans at slighly different angles +//This is VERY computationaly intensive, but doesn't happen that often. + +_startingPosition = _setupObject modelToWorld [0,0,0]; +_startingOffset = _attachToVehicle worldToModel _startingPosition; + +_distanceFromCenter = vectorMagnitude _startingOffset; +_closeInUnitVector = vectorNormalized (_startingOffset vectorFromTo [0,0,0]); +_keepGoingCloser = true; +_closeInDistance = 0; + +while {_keepGoingCloser} do { + if (_closeInDistance >= _distanceFromCenter) exitWith {}; + + _closeInDistance = _closeInDistance + 0.01; //10mm each step + _endPosTestOffset = _startingOffset vectorAdd (_closeInUnitVector vectorMultiply _closeInDistance); + _endPosTestOffset set [2, (_startingOffset select 2)]; + _endPosTest = _attachToVehicle modelToWorld _endPosTestOffset; + + { + _startingPosShifted = _startingPosition vectorAdd _x; + _startASL = if (surfaceIsWater _startingPosShifted) then {_startingPosShifted} else {ATLtoASL _startingPosShifted}; + { + _endPosShifted = _endPosTest vectorAdd _x; + _endASL = if (surfaceIsWater _startingPosShifted) then {_endPosShifted} else {ATLtoASL _endPosShifted}; + + //Uncomment to see the lazor show, and see how the scanning works: + drawLine3D [_startingPosShifted, _endPosShifted, [1,0,0,1]]; + + if (_attachToVehicle in lineIntersectsWith [_startASL, _endASL, _placer, _setupObject]) exitWith {_keepGoingCloser = false}; + } forEach [[0,0,0.045], [0,0,-0.045], [0,0.045,0], [0,-0.045,0], [0.045,0,0], [-0.045,0,0]]; + } forEach [[0,0,0], [0,0,0.05], [0,0,-0.05]]; +}; + +//Delete Local Placement Object +deleteVehicle _setupObject; + +//Checks +if ((_closeInDistance >= _distanceFromCenter) || (!([_placer,_attachToVehicle,_itemClassname] call FUNC(canAttach)))) exitWith { + TRACE_2("no valid spot found",_closeInDistance,_distanceFromCenter); + [localize "STR_ACE_Attach_Failed"] call EFUNC(common,displayTextStructured); +}; + +//Move it out slightly, for visability sake (better to look a little funny than be embedded//sunk in the hull) +_closeInDistance = (_closeInDistance - 0.0085); + +//Create New 'real' Object +_endPosTestOffset = _startingOffset vectorAdd (_closeInUnitVector vectorMultiply _closeInDistance); +_endPosTestOffset set [2, (_startingOffset select 2)]; +_attachedObject = _setupClassname createVehicle (getPos _placer); +_attachedObject attachTo [_attachToVehicle, _endPosTestOffset]; + +//Remove Item from inventory +_placer removeItem _itemClassname; + +//Add Object to ACE_AttachedObjects and ACE_AttachedItemNames +_currentObjects = _attachToVehicle getVariable [QGVAR(Objects), []]; +_currentObjects pushBack _attachedObject; +_attachToVehicle setVariable [QGVAR(Objects), _currentObjects, true]; +_currentItemNames = _attachToVehicle getVariable [QGVAR(ItemNames), []]; +_currentItemNames pushBack _itemClassname; +_attachToVehicle setVariable [QGVAR(ItemNames), _currentItemNames, true]; + +[_placementText] call EFUNC(common,displayTextStructured); diff --git a/addons/attach/functions/fnc_placeCancel.sqf b/addons/attach/functions/fnc_placeCancel.sqf new file mode 100644 index 0000000000..3abdf848ba --- /dev/null +++ b/addons/attach/functions/fnc_placeCancel.sqf @@ -0,0 +1,35 @@ +/* + * Author: Pabst Mirror (based on Explosive attach by Garth de Wet (LH)) + * Cancels placement of the lightObject + * + * Arguments: + * Nothing + * + * Return Value: + * Nothing + * + * Example: + * Nothing + * + * Public: No + */ +#include "script_component.hpp" + +if (GVAR(pfeh_running)) then { + [QGVAR(PlacementEachFrame),"OnEachFrame"] call BIS_fnc_removeStackedEventHandler; + GVAR(pfeh_running) = false; +}; +if (!isNull (GVAR(setupObject))) then { + deleteVehicle GVAR(setupObject); +}; + +[GVAR(placer), QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); +call EFUNC(interaction,hideMouseHint); +[GVAR(placer), "DefaultAction", GVAR(placer) getVariable [QGVAR(placeActionEH), -1]] call EFUNC(common,removeActionEventHandler); +[GVAR(placer), "MenuBack", GVAR(placer) getVariable [QGVAR(cancelActionEH), -1]] call EFUNC(common,removeActionEventHandler); + +GVAR(placer) = objNull; +GVAR(SetupPlacmentItem) = ""; +GVAR(SetupPlacmentText) = ""; +GVAR(setupObject) = objNull; +GVAR(SetupAttachVehicle) = objNull; diff --git a/addons/attach/stringtable.xml b/addons/attach/stringtable.xml index 877f26e623..13c468184b 100644 --- a/addons/attach/stringtable.xml +++ b/addons/attach/stringtable.xml @@ -1,5 +1,5 @@  - + @@ -146,5 +146,34 @@ Az infravörös jeladóval megjelölheted a helyzetedet úgy, hogy annak pulzáló fénye csak éjjellátó készülékkel látható. ИК строб позволяет сигнализировать свое местоположение через пульсирующий маяк, видимый только через ПНВ. + + Place + Platzieren + Colocar + Umieść + Placer + Položit + Colocar + Posiziona + Elhelyez + + + Cancel + Abbrechen + Cancelar + Anuluj + Annuler + Zrušit + Cancelar + Annulla + Mégse + + + Attach Failed + Échec du Attacher + Befestigen Fehlgeschlagen + Присоединить Ошибка + Error en Acoplar + - \ No newline at end of file + diff --git a/addons/backblast/$PBOPREFIX$ b/addons/backblast/$PBOPREFIX$ deleted file mode 100644 index c5ed230994..0000000000 --- a/addons/backblast/$PBOPREFIX$ +++ /dev/null @@ -1 +0,0 @@ -z\ace\addons\backblast \ No newline at end of file diff --git a/addons/backblast/CfgEventHandlers.hpp b/addons/backblast/CfgEventHandlers.hpp deleted file mode 100644 index a336a5dd41..0000000000 --- a/addons/backblast/CfgEventHandlers.hpp +++ /dev/null @@ -1,17 +0,0 @@ - -class Extended_PreInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_preInit) ); - }; -}; - -class Extended_FiredNear_EventHandlers { - class CAManBase { - class GVAR(LauncherBackblast) { - FiredNear = QUOTE( if (local (_this select 0) && {getNumber (configfile >> 'CfgWeapons' >> _this select 3 >> 'ACE_Backblast_Damage') > 0}) then {_this call FUNC(launcherBackblast)} ); - }; - class GVAR(TankDangerZone) { - FiredNear = QUOTE( if (local (_this select 0) && {getNumber (configfile >> 'CfgWeapons' >> _this select 3 >> 'ACE_DangerZone_Damage') > 0}) then {_this call FUNC(tankDangerZone)} ); - }; - }; -}; diff --git a/addons/backblast/CfgWeapons.hpp b/addons/backblast/CfgWeapons.hpp deleted file mode 100644 index fcb4bde0c5..0000000000 --- a/addons/backblast/CfgWeapons.hpp +++ /dev/null @@ -1,44 +0,0 @@ -class CfgWeapons { - - class LauncherCore; - class Launcher: LauncherCore { - ACE_Backblast_Angle = 60; - ACE_Backblast_Range = 10; - ACE_Backblast_Damage = 0.7; - }; - class Launcher_Base_F: Launcher {}; - - class launch_Titan_base: Launcher_Base_F { - ACE_Backblast_Angle = 40; - ACE_Backblast_Range = 8; - ACE_Backblast_Damage = 0.5; - }; - class launch_Titan_short_base: launch_Titan_base { - ACE_Backblast_Angle = 40; - ACE_Backblast_Range = 8; - ACE_Backblast_Damage = 0.5; - }; - - class launch_NLAW_F: Launcher_Base_F { - ACE_Backblast_Angle = 40; - ACE_Backblast_Range = 5; - ACE_Backblast_Damage = 0.6; - }; - class launch_RPG32_F: Launcher_Base_F { - ACE_Backblast_Angle = 60; - ACE_Backblast_Range = 15; - ACE_Backblast_Damage = 0.7; - }; - - class CannonCore; - class cannon_120mm: CannonCore { - ACE_DangerZone_Angle = 90; - ACE_DangerZone_Range = 50; - ACE_DangerZone_Damage = 0.85; - }; - class mortar_155mm_AMOS: CannonCore { - ACE_DangerZone_Angle = 90; - ACE_DangerZone_Range = 60; - ACE_DangerZone_Damage = 1; - }; -}; diff --git a/addons/backblast/functions/fnc_getDistance.sqf b/addons/backblast/functions/fnc_getDistance.sqf deleted file mode 100644 index 83b290e2b0..0000000000 --- a/addons/backblast/functions/fnc_getDistance.sqf +++ /dev/null @@ -1,31 +0,0 @@ -// by commy2 -#include "script_component.hpp" - -private ["_position", "_direction", "_maxDistance", "_distance", "_iteration", "_laser", "_line"]; - -_position = + _this select 0; -_direction = + _this select 1; -_maxDistance = _this select 2; - -_distance = _maxDistance; -_iteration = _distance; -_laser = []; -_line = [_position, _laser]; - -while { - _iteration > 0.1 -} do { - _iteration = _iteration / 2; - - _laser set [0, (_position select 0) - _distance * (_direction select 0)]; - _laser set [1, (_position select 1) - _distance * (_direction select 1)]; - _laser set [2, (_position select 2) - _distance * (_direction select 2)]; - - _intersections = { - _x isKindOf "Static" || {_x isKindOf "AllVehicles"} - } count (lineIntersectsWith _line); - - _distance = _distance + ([1, -1] select (_intersections > 0)) * _iteration; -}; - -if (_distance > _maxDistance) then {999} else {_distance} diff --git a/addons/backblast/functions/fnc_launcherBackblast.sqf b/addons/backblast/functions/fnc_launcherBackblast.sqf deleted file mode 100644 index b2cde50c5d..0000000000 --- a/addons/backblast/functions/fnc_launcherBackblast.sqf +++ /dev/null @@ -1,72 +0,0 @@ -// by commy2 -#include "script_component.hpp" - -_unit = _this select 0; -_firer = _this select 1; -_distance = _this select 2; -_weapon = _this select 3; - -if (vehicle _unit != _unit || {!([_firer] call EFUNC(common,isPlayer))}) exitWith {}; - -_backblastAngle = getNumber (configFile >> "CfgWeapons" >> _weapon >> "ACE_Backblast_Angle") / 2; -_backblastRange = getNumber (configFile >> "CfgWeapons" >> _weapon >> "ACE_Backblast_Range"); -_backblastDamage = getNumber (configFile >> "CfgWeapons" >> _weapon >> "ACE_Backblast_Damage"); - -_position = eyePos _firer; -_direction = _firer weaponDirection currentWeapon _firer; - -if (_unit == _firer) then { - _distance = [_position, _direction, _backblastRange] call FUNC(getDistance); - hint format ["%1", _distance]; - if (_distance < _backblastRange) then { - _alpha = sqrt (1 - _distance / _backblastRange); - _beta = sqrt 0.5; - - _damage = 2 * _alpha * _beta * _backblastDamage; - [_damage * 100] call BIS_fnc_bloodEffect; - - // TODO: Sort this interaction with medical - if (isClass (configFile >> "CfgPatches" >> "ACE_Medical")) then { - [_unit, "HitBody", ([_unit, "", ((_unit getHitPointDamage "HitBody") + _damage), objNull, objNull] call EFUNC(medical,handleDamage))] call EFUNC(medical,setHitPointDamage); - } else { - _unit setDamage (damage _unit + _damage); - }; - - }; -} else { - _direction = [0, 0, 0] vectorDiff _direction; - - _azimuth = (_direction select 0) atan2 (_direction select 1); - _inclination = asin (_direction select 2); - - _relativePosition = eyePos _unit; - _relativeDirection = _relativePosition vectorDiff _position; - - _relativeAzimuth = (_relativeDirection select 0) atan2 (_relativeDirection select 1); - _relativeInclination = asin (_relativeDirection select 2); - - _angle = sqrt ((_relativeAzimuth - _azimuth) ^ 2 + (_relativeInclination - _inclination) ^ 2); - _distance = vectorMagnitude _relativeDirection; - - _line = [_position, _relativePosition]; - - if (_angle < _backblastAngle && {_distance < _backblastRange} && {!lineIntersects _line} && {!terrainIntersectASL _line}) then { - _alpha = sqrt (1 - _distance / _backblastRange); - _beta = sqrt (1 - _angle / _backblastAngle); - - _damage = 2 * _alpha * _beta * _backblastDamage; - if (_unit == ACE_player) then {[_damage * 100] call BIS_fnc_bloodEffect}; - - // TODO: Sort this interaction with medical - if (isClass (configFile >> "CfgPatches" >> "ACE_Medical")) then { - [_unit, "HitBody", ([_unit, "", ((_unit getHitPointDamage "HitBody") + _damage), objNull, objNull] call EFUNC(medical,handleDamage))] call EFUNC(medical,setHitPointDamage); - _unit spawn { - sleep 0.5; - [_this, "", 0, objNull, objNull] call EFUNC(medical,handleDamage); - }; - } else { - _unit setDamage (damage _unit + _damage); - }; - - }; -}; diff --git a/addons/backblast/functions/fnc_tankDangerZone.sqf b/addons/backblast/functions/fnc_tankDangerZone.sqf deleted file mode 100644 index 0371ec9620..0000000000 --- a/addons/backblast/functions/fnc_tankDangerZone.sqf +++ /dev/null @@ -1,54 +0,0 @@ -// by commy2 -#include "script_component.hpp" - -#define BARREL_MUZZLE "usti hlavne" - -_unit = _this select 0; -_vehicle = vehicle (_this select 1); -_distance = _this select 2; -_weapon = _this select 3; - -if (vehicle _unit != _unit || {!([gunner _firer] call EFUNC(common,isPlayer))}) exitWith {}; - -_dangerZoneAngle = getNumber (configFile >> "CfgWeapons" >> _weapon >> "ACE_DangerZone_Angle") / 2; -_dangerZoneRange = getNumber (configFile >> "CfgWeapons" >> _weapon >> "ACE_DangerZone_Range"); -_dangerZoneDamage = getNumber (configFile >> "CfgWeapons" >> _weapon >> "ACE_DangerZone_Damage"); - -_position = ATLToASL (_vehicle modelToWorld (_vehicle selectionPosition BARREL_MUZZLE)); -_direction = _vehicle weaponDirection _weapon; - -if (_unit != _vehicle) then { - _azimuth = (_direction select 0) atan2 (_direction select 1); - _inclination = asin (_direction select 2); - - _relativePosition = eyePos _unit; - _relativeDirection = _relativePosition vectorDiff _position; - - _relativeAzimuth = (_relativeDirection select 0) atan2 (_relativeDirection select 1); - _relativeInclination = asin (_relativeDirection select 2); - - _angle = sqrt ((_relativeAzimuth - _azimuth) ^ 2 + (_relativeInclination - _inclination) ^ 2); - _distance = vectorMagnitude _relativeDirection; - - _line = [_position, _relativePosition]; - - if (_angle < _dangerZoneAngle && {_distance < _dangerZoneRange} && {!lineIntersects (_line + [_vehicle])} && {!terrainIntersectASL _line}) then { - _alpha = sqrt (1 - _distance / _dangerZoneRange); - _beta = sqrt (1 - _angle / _dangerZoneAngle); - - _damage = 2 * _alpha * _beta * _dangerZoneDamage; - if (_unit == ACE_player) then {[_damage * 100] call BIS_fnc_bloodEffect}; - - // TODO: Sort this interaction with medical - if (isClass (configFile >> "CfgPatches" >> "ACE_Medical")) then { - [_unit, "HitBody", ([_unit, "", ((_unit getHitPointDamage "HitBody") + _damage), objNull, objNull] call EFUNC(medical,handleDamage))] call EFUNC(medical,setHitPointDamage); - _unit spawn { - sleep 0.5; - [_this, "", 0, objNull, objNull] call EFUNC(medical,handleDamage); - }; - } else { - _unit setDamage (damage _unit + _damage); - }; - - }; -}; diff --git a/addons/backblast/functions/script_component.hpp b/addons/backblast/functions/script_component.hpp deleted file mode 100644 index 817131570f..0000000000 --- a/addons/backblast/functions/script_component.hpp +++ /dev/null @@ -1 +0,0 @@ -#include "\z\ace\addons\backblast\script_component.hpp" \ No newline at end of file diff --git a/addons/backblast/script_component.hpp b/addons/backblast/script_component.hpp deleted file mode 100644 index 9f2a71f2d5..0000000000 --- a/addons/backblast/script_component.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#define COMPONENT backblast -#include "\z\ace\Addons\main\script_mod.hpp" - -#ifdef DEBUG_ENABLED_BACKBLAST - #define DEBUG_MODE_FULL -#endif - -#ifdef DEBUG_SETTINGS_BACKBLAST - #define DEBUG_SETTINGS DEBUG_SETTINGS_BACKBLAST -#endif - -#include "\z\ace\Addons\main\script_macros.hpp" \ No newline at end of file diff --git a/addons/captives/$PBOPREFIX$ b/addons/captives/$PBOPREFIX$ new file mode 100644 index 0000000000..aac16576c4 --- /dev/null +++ b/addons/captives/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\captives \ No newline at end of file diff --git a/addons/captives/CfgEventHandlers.hpp b/addons/captives/CfgEventHandlers.hpp new file mode 100644 index 0000000000..722750f915 --- /dev/null +++ b/addons/captives/CfgEventHandlers.hpp @@ -0,0 +1,48 @@ +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; + +class Extended_PostInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; + +//release escorted captive when entering a vehicle +class Extended_GetIn_EventHandlers { + class All { + class GVAR(AutoDetachCaptive) { + getIn = QUOTE(_this call FUNC(handleGetIn)); + }; + }; +}; + +//reset captive animation after leaving vehicle +class Extended_GetOut_EventHandlers { + class All { + class GVAR(AutoDetachCaptive) { + getOut = QUOTE(_this call FUNC(handleGetOut)); + }; + }; +}; + +//reset captivity and escorting status when getting killed +class Extended_Killed_EventHandlers { + class CAManBase { + class GVAR(AutoDetachCaptive) { + killed = QUOTE(_this call FUNC(handleKilled)); + }; + }; +}; + +//mission start +class Extended_InitPost_EventHandlers { + class CAManBase { + class GVAR(InitPost) { + init = QUOTE(_this call FUNC(handleUnitInitPost)); + }; + }; +}; + diff --git a/addons/captives/CfgMoves.hpp b/addons/captives/CfgMoves.hpp new file mode 100644 index 0000000000..6e67f3615b --- /dev/null +++ b/addons/captives/CfgMoves.hpp @@ -0,0 +1,83 @@ +class CfgMovesBasic { + class Actions { + class CivilStandActions; + class ACE_CivilStandHandcuffedActions: CivilStandActions { + turnL = ""; + turnR = ""; + stop = "ACE_AmovPercMstpScapWnonDnon"; + StopRelaxed = "ACE_AmovPercMstpScapWnonDnon"; + default = "ACE_AmovPercMstpScapWnonDnon"; + PutDown = ""; + getOver = ""; + throwPrepare = ""; + throwGrenade[] = {"","Gesture"}; + }; + class ACE_CivilStandSurrenderActions: ACE_CivilStandHandcuffedActions { + stop = "ACE_AmovPercMstpSsurWnonDnon"; + StopRelaxed = "ACE_AmovPercMstpSsurWnonDnon"; + default = "ACE_AmovPercMstpSsurWnonDnon"; + PutDown = ""; + }; + }; +}; + +class CfgMovesMaleSdr: CfgMovesBasic { + class StandBase; + class States { + class AmovPercMstpSnonWnonDnon: StandBase { + ConnectTo[] += {"ACE_AmovPercMstpSnonWnonDnon_AmovPercMstpScapWnonDnon",0.1,"ACE_AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon",0.1}; + }; + + class CutSceneAnimationBase; + + //Handcuffed Anims: + class ACE_AmovPercMstpSnonWnonDnon_AmovPercMstpScapWnonDnon: CutSceneAnimationBase { + actions = "ACE_CivilStandHandcuffedActions"; + file = "\A3\anims_f\Data\Anim\Sdr\mov\erc\stp\non\non\AmovPercMstpSnonWnonDnon_EaseIn"; + speed = 1; + looped = 0; + interpolationRestart = 2; + ConnectTo[] = {"ACE_AmovPercMstpScapWnonDnon",0.1}; + InterpolateTo[] = {"Unconscious",0.01,"ACE_AmovPercMstpScapWnonDnon_AmovPercMstpSnonWnonDnon",0.1}; + }; + class ACE_AmovPercMstpScapWnonDnon: ACE_AmovPercMstpSnonWnonDnon_AmovPercMstpScapWnonDnon { + file = "\A3\anims_f\Data\Anim\Sdr\mov\erc\stp\non\non\AmovPercMstpSnonWnonDnon_Ease"; + speed = 0; + ConnectTo[] = {"ACE_AmovPercMstpScapWnonDnon_AmovPercMstpSnonWnonDnon",0.1}; + InterpolateTo[] = {"Unconscious",0.01}; + looped = 1; + }; + class ACE_AmovPercMstpScapWnonDnon_AmovPercMstpSnonWnonDnon: ACE_AmovPercMstpSnonWnonDnon_AmovPercMstpScapWnonDnon { + actions = "CivilStandActions"; + file = "\A3\anims_f\Data\Anim\Sdr\mov\erc\stp\non\non\amovpercmstpsnonwnondnon_easeout"; + ConnectTo[] = {"AmovPercMstpSnonWnonDnon",0.1}; + InterpolateTo[] = {"Unconscious",0.01,"ACE_AmovPercMstpSnonWnonDnon_AmovPercMstpScapWnonDnon",0.1}; + }; + + //Surrender Anims: + class ACE_AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon: CutSceneAnimationBase { + actions = "ACE_CivilStandSurrenderActions"; + file = "\A3\anims_f\Data\Anim\Sdr\mov\erc\stp\non\non\AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon"; + speed = 1; + looped = 0; + interpolationRestart = 2; + ConnectTo[] = {"ACE_AmovPercMstpSsurWnonDnon",0.1}; + InterpolateTo[] = {"Unconscious",0.01,"ACE_AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon",0.1}; + }; + class ACE_AmovPercMstpSsurWnonDnon: ACE_AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon { + file = "\A3\anims_f\Data\Anim\Sdr\mov\erc\stp\sur\non\AmovPercMstpSsurWnonDnon"; + speed = 0; + looped = 1; + ConnectTo[] = {"ACE_AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon",0.1}; + InterpolateTo[] = {"Unconscious",0.01}; + }; + class ACE_AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon: ACE_AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon { + speed = 0.333; //for gameplay reasons, slow this down + actions = "CivilStandActions"; + file = "\A3\anims_f\Data\Anim\Sdr\mov\erc\stp\sur\non\AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon"; + ConnectTo[] = {"AmovPercMstpSnonWnonDnon",0.1}; + InterpolateTo[] = {"Unconscious",0.01,"ACE_AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon",0.1}; + }; + }; +}; + diff --git a/addons/captives/CfgVehicles.hpp b/addons/captives/CfgVehicles.hpp new file mode 100644 index 0000000000..d292402bcf --- /dev/null +++ b/addons/captives/CfgVehicles.hpp @@ -0,0 +1,191 @@ +class CfgVehicles { + class Man; + class CAManBase: Man { + class ACE_Actions { + class ACE_ApplyHandcuffs { + displayName = "$STR_ACE_Captives_SetCaptive"; + distance = 4; + condition = QUOTE([ARR_2(_player, _target)] call FUNC(canApplyHandcuffs)); + statement = QUOTE([ARR_2(_player, _target)] call FUNC(doApplyHandcuffs)); + exceptions[] = {}; + showDisabled = 0; + priority = 2.4; + icon = QUOTE(PATHTOF(UI\handcuff_ca.paa)); + hotkey = "C"; + }; + class ACE_RemoveHandcuffs { + displayName = "$STR_ACE_Captives_ReleaseCaptive"; + distance = 4; + condition = QUOTE([ARR_2(_player, _target)] call FUNC(canRemoveHandcuffs)); + statement = QUOTE([ARR_2(_player, _target)] call FUNC(doRemoveHandcuffs)); + exceptions[] = {}; + showDisabled = 0; + priority = 2.4; + icon = QUOTE(PATHTOF(UI\handcuff_ca.paa)); + hotkey = "R"; + }; + class ACE_EscortCaptive { + displayName = "$STR_ACE_Captives_EscortCaptive"; + distance = 4; + condition = QUOTE([ARR_2(_player, _target)] call FUNC(canEscortCaptive)); + statement = QUOTE([ARR_3(_player, _target, true)] call FUNC(doEscortCaptive)); + exceptions[] = {}; + showDisabled = 0; + icon = QUOTE(PATHTOF(UI\captive_ca.paa)); + priority = 2.3; + hotkey = "E"; + }; + class ACE_StopEscorting { + displayName = "$STR_ACE_Captives_StopEscorting"; + distance = 4; + condition = QUOTE([ARR_2(_player, _target)] call FUNC(canStopEscorting)); + statement = QUOTE([ARR_3(_player,_target, false)] call FUNC(doEscortCaptive)); + exceptions[] = {QGVAR(isNotEscorting)}; + showDisabled = 0; + icon = QUOTE(PATHTOF(UI\captive_ca.paa)); + priority = 2.3; + hotkey = "E"; + }; + class ACE_LoadCaptive { + displayName = "$STR_ACE_Captives_LoadCaptive"; + distance = 4; + condition = QUOTE([ARR_3(_player, _target, objNull)] call FUNC(canLoadCaptive)); + statement = QUOTE([ARR_3(_player, _target, objNull)] call FUNC(doLoadCaptive)); + exceptions[] = {QGVAR(isNotEscorting)}; + showDisabled = 0; + icon = QUOTE(PATHTOF(UI\captive_ca.paa)); + priority = 2.2; + hotkey = "L"; + }; + class ACE_FriskPerson { + displayName = "$STR_ACE_Captives_FriskPerson"; + distance = 2; + condition = QUOTE([ARR_2(_player, _target)] call FUNC(canFriskPerson)); + statement = QUOTE([ARR_2(_player, _target)] call FUNC(doFriskPerson)); + showDisabled = 0; + //icon = ""; //@todo + priority = 3; + hotkey = "F"; + }; + }; + + class ACE_SelfActions { + class ACE_StopEscortingSelf { + displayName = "$STR_ACE_Captives_StopEscorting"; + condition = QUOTE([ARR_2(_player, objNull)] call FUNC(canStopEscorting)); + statement = QUOTE([ARR_3(_player,objNull, false)] call FUNC(doEscortCaptive)); + exceptions[] = {QGVAR(isNotEscorting)}; + showDisabled = 0; + priority = 2.3; + hotkey = "C"; + }; + class ACE_StartSurrenderingSelf { + displayName = "$STR_ACE_Captives_StartSurrendering"; + condition = QUOTE([ARR_2(_player, true)] call FUNC(canSurrender)); + statement = QUOTE([ARR_2(_player, true)] call FUNC(surrender)); + exceptions[] = {}; + showDisabled = 0; + priority = 0; + }; + class ACE_StopSurrenderingSelf { + displayName = "$STR_ACE_Captives_StopSurrendering"; + condition = QUOTE([ARR_2(_player, false)] call FUNC(canSurrender)); + statement = QUOTE([ARR_2(_player, false)] call FUNC(surrender)); + exceptions[] = {QGVAR(isNotSurrendering)}; + showDisabled = 0; + priority = 0; + }; + }; + }; + +#define MACRO_LOADUNLOADCAPTIVE \ + class ACE_Actions { \ + class ACE_LoadCaptive { \ + displayName = "$STR_ACE_Captives_LoadCaptive"; \ + distance = 4; \ + condition = QUOTE([ARR_3(_player, objNull, _target)] call FUNC(canLoadCaptive)); \ + statement = QUOTE([ARR_3(_player, objNull, _target)] call FUNC(doLoadCaptive)); \ + exceptions[] = {QGVAR(isNotEscorting)}; \ + showDisabled = 0; \ + priority = 1.2; \ + hotkey = "L"; \ + }; \ + class ACE_UnloadCaptive { \ + displayName = "$STR_ACE_Captives_UnloadCaptive"; \ + distance = 4; \ + condition = QUOTE([ARR_2(_player, _target)] call FUNC(canUnloadCaptive)); \ + statement = QUOTE([ARR_2(_player, _target)] call FUNC(doUnloadCaptive)); \ + showDisabled = 0; \ + priority = 1.2; \ + hotkey = "C"; \ + }; \ + }; + + class LandVehicle; + class Car: LandVehicle { + MACRO_LOADUNLOADCAPTIVE + }; + class Tank: LandVehicle { + MACRO_LOADUNLOADCAPTIVE + }; + + class Air; + class Helicopter: Air { + MACRO_LOADUNLOADCAPTIVE + }; + class Plane: Air { + MACRO_LOADUNLOADCAPTIVE + }; + + class Ship; + class Ship_F: Ship { + MACRO_LOADUNLOADCAPTIVE + }; + + class StaticWeapon: LandVehicle { + MACRO_LOADUNLOADCAPTIVE + }; + + class StaticMortar; + class Mortar_01_base_F: StaticMortar { + MACRO_LOADUNLOADCAPTIVE + }; + +#define MACRO_ADDITEM(ITEM,COUNT) class _xx_##ITEM { \ + name = #ITEM; \ + count = COUNT; \ + }; + + class Box_NATO_Support_F; + class ACE_Box_Misc: Box_NATO_Support_F { + class TransportItems { + MACRO_ADDITEM(ACE_CableTie,12) + }; + }; + + + class Logic; + class Module_F: Logic { + class ArgumentsBaseUnits {}; + class ModuleDescription {}; + }; + + class GVAR(ModuleSurrender): Module_F { + author = "$STR_ACE_Common_ACETeam"; + category = "ACE"; + displayName = "Make Unit Surrender"; + function = QUOTE(DFUNC(moduleSurrender)); + scope = 2; //show in editor + scopeCurator = 2; //show in zeus + curatorCost = 0; //??? + isGlobal = 1; //run global + isTriggerActivated = 1; //Wait for triggers + // icon = QUOTE(PATHTOF(ui\todo.paa)); + functionPriority = 0; + class Arguments {}; + class ModuleDescription: ModuleDescription { + description = "Sync a unit to make them surrender.
Source: ace_captives"; + sync[] = {"AnyAI"}; + }; + }; +}; diff --git a/addons/captives/CfgWeapons.hpp b/addons/captives/CfgWeapons.hpp new file mode 100644 index 0000000000..be2149ca88 --- /dev/null +++ b/addons/captives/CfgWeapons.hpp @@ -0,0 +1,15 @@ +class CfgWeapons { + class ACE_ItemCore; + class InventoryItem_Base_F; + + class ACE_CableTie: ACE_ItemCore { + displayName = "$STR_ACE_Captives_CableTie"; + descriptionShort = "$STR_ACE_Captives_CableTieDescription"; + model = QUOTE(PATHTOF(models\ace_cabletie.p3d)); + picture = QUOTE(PATHTOF(UI\ace_cabletie_ca.paa)); + scope = 2; + class ItemInfo: InventoryItem_Base_F { + mass = 1; + }; + }; +}; diff --git a/addons/captives/README.md b/addons/captives/README.md new file mode 100644 index 0000000000..3938720f08 --- /dev/null +++ b/addons/captives/README.md @@ -0,0 +1,14 @@ +ace_captives +============ + +Allows taking people captive/handcuffed + +####Items: +`ACE_CableTie` - adds ability to take someone captive + + +## Maintainers + +The people responsible for merging changes to this component or answering potential questions. + +- [PabstMirror](https://github.com/PabstMirror) diff --git a/TO_MERGE/agm/Captives/UI/agm_cabletie_x_ca.paa b/addons/captives/UI/ace_cabletie_ca.paa similarity index 100% rename from TO_MERGE/agm/Captives/UI/agm_cabletie_x_ca.paa rename to addons/captives/UI/ace_cabletie_ca.paa diff --git a/TO_MERGE/agm/Captives/UI/captive_ca.paa b/addons/captives/UI/captive_ca.paa similarity index 100% rename from TO_MERGE/agm/Captives/UI/captive_ca.paa rename to addons/captives/UI/captive_ca.paa diff --git a/TO_MERGE/agm/Captives/UI/handcuff_ca.paa b/addons/captives/UI/handcuff_ca.paa similarity index 100% rename from TO_MERGE/agm/Captives/UI/handcuff_ca.paa rename to addons/captives/UI/handcuff_ca.paa diff --git a/addons/captives/XEH_postInit.sqf b/addons/captives/XEH_postInit.sqf new file mode 100644 index 0000000000..9d1a242d4d --- /dev/null +++ b/addons/captives/XEH_postInit.sqf @@ -0,0 +1,32 @@ +#include "script_component.hpp" + +["playerChanged", {_this call FUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler); +["MoveInCaptive", {_this call FUNC(vehicleCaptiveMoveIn)}] call EFUNC(common,addEventHandler); +["MoveOutCaptive", {_this call FUNC(vehicleCaptiveMoveOut)}] call EFUNC(common,addEventHandler); +["SetHandcuffed", {_this call FUNC(setHandcuffed)}] call EFUNC(common,addEventHandler); + +//Handles when someone starts escorting and then disconnects, leaving the captive attached +//This is normaly handled by the PFEH in doEscortCaptive, but that won't be running if they DC +if (isServer) then { + addMissionEventHandler ["HandleDisconnect", { + PARAMS_1(_disconnectedPlayer); + _escortedUnit = _disconnectedPlayer getVariable [QGVAR(escortedUnit), objNull]; + if ((!isNull _escortedUnit) && {(attachedTo _escortedUnit) == _disconnectedPlayer}) then { + detach _escortedUnit; + systemChat "debug: DC detach"; + }; + if (_disconnectedPlayer getVariable [QGVAR(isEscorting), false]) then { + _disconnectedPlayer setVariable [QGVAR(isEscorting), false, true]; + }; + }]; +}; + +//TODO: Medical Integration Events??? + +// [_unit, "knockedOut", { +// if (local (_this select 0)) then {_this call ACE_Captives_fnc_handleKnockedOut}; +// }] call ACE_Core_fnc_addCustomEventhandler; + +// [_unit, "wokeUp", { +// if (local (_this select 0)) then {_this call ACE_Captives_fnc_handleWokeUp}; +// }] call ACE_Core_fnc_addCustomEventhandler; diff --git a/addons/captives/XEH_preInit.sqf b/addons/captives/XEH_preInit.sqf new file mode 100644 index 0000000000..75ee77e9bc --- /dev/null +++ b/addons/captives/XEH_preInit.sqf @@ -0,0 +1,32 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP(canApplyHandcuffs); +PREP(canEscortCaptive); +PREP(canFriskPerson); +PREP(canLoadCaptive); +PREP(canRemoveHandcuffs); +PREP(canStopEscorting); +PREP(canSurrender); +PREP(canUnloadCaptive); +PREP(doApplyHandcuffs); +PREP(doEscortCaptive); +PREP(doFriskPerson); +PREP(doLoadCaptive); +PREP(doRemoveHandcuffs); +PREP(doUnloadCaptive); +PREP(handleGetIn); +PREP(handleGetOut); +PREP(handleKilled); +PREP(handleKnockedOut); +PREP(handlePlayerChanged); +PREP(handleUnitInitPost); +PREP(handleWokeUp); +PREP(moduleSurrender); +PREP(setHandcuffed); +PREP(surrender); +PREP(vehicleCaptiveMoveIn); +PREP(vehicleCaptiveMoveOut); + +ADDON = true; diff --git a/addons/captives/config.cpp b/addons/captives/config.cpp new file mode 100644 index 0000000000..27b7c4ec60 --- /dev/null +++ b/addons/captives/config.cpp @@ -0,0 +1,31 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {QGVAR(ModuleSurrender)}; + weapons[] = {"ACE_CableTie"}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ACE_Interaction"}; + author[] = {"commy2", "KoffeinFlummi"}; + authorUrl = "https://github.com/commy2/"; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" +#include "CfgMoves.hpp" +#include "CfgVehicles.hpp" +#include "CfgWeapons.hpp" + + +class ACE_canInteractConditions { + class GVAR(isNotEscorting) { + condition = QUOTE(!(GETVAR(player,QGVAR(isEscorting),false))); + }; + class GVAR(isNotHandcuffed) { + condition = QUOTE(!(GETVAR(player,QGVAR(isHandcuffed),false))); + }; + class GVAR(isNotSurrendering) { + condition = QUOTE(!(GETVAR(player,QGVAR(isSurrendering),false))); + }; +}; diff --git a/addons/captives/functions/fnc_canApplyHandcuffs.sqf b/addons/captives/functions/fnc_canApplyHandcuffs.sqf new file mode 100644 index 0000000000..f69bb2544d --- /dev/null +++ b/addons/captives/functions/fnc_canApplyHandcuffs.sqf @@ -0,0 +1,25 @@ +/* + * Author: PabstMirror + * Checks the conditions for being able to apply handcuffs + * + * Arguments: + * 0: caller (player) + * 1: target + * + * Return Value: + * The return value + * + * Example: + * [player, bob] call ACE_captives_fnc_canApplyHandcuffs + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_2(_unit,_target); + +//Player has cableTie, target is alive and not already handcuffed + +("ACE_CableTie" in (items _unit)) && +{alive _target} && +{!(_target getVariable [QGVAR(isHandcuffed), false])} diff --git a/addons/captives/functions/fnc_canEscortCaptive.sqf b/addons/captives/functions/fnc_canEscortCaptive.sqf new file mode 100644 index 0000000000..85bd8bbd3e --- /dev/null +++ b/addons/captives/functions/fnc_canEscortCaptive.sqf @@ -0,0 +1,26 @@ +/* + * Author: PabstMirror + * Tests if can escort target (attach) + * + * Arguments: + * 0: caller (player) + * 1: target + * + * Return Value: + * The return value + * + * Example: + * [player, bob] call ACE_captives_fnc_canEscortCaptive + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_2(_unit,_target); + +//Alive, handcuffed, not being escored, and not unconscious + +(_target getVariable [QGVAR(isHandcuffed), false]) && +{isNull (attachedTo _target)} && +{alive _target} && +{!(_target getVariable ["ACE_isUnconscious", false])} diff --git a/addons/captives/functions/fnc_canFriskPerson.sqf b/addons/captives/functions/fnc_canFriskPerson.sqf new file mode 100644 index 0000000000..5eecc453d4 --- /dev/null +++ b/addons/captives/functions/fnc_canFriskPerson.sqf @@ -0,0 +1,24 @@ +/* + * Author: bux578 + * Checks the conditions for being able to frisk a unit + * + * Arguments: + * 0: caller (player) + * 1: target + * + * Return Value: + * The return value + * + * Example: + * [player, bob] call ACE_captives_fnc_canFriskPerson + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_2(_unit,_target); + +_target getVariable [QGVAR(isHandcuffed), false] +|| {_target getVariable [QGVAR(isSurrendering), false]} +|| {_target getVariable ["ACE_isSearchable", false]} +|| {_target getVariable ["ACE_isUnconscious", false]} diff --git a/addons/captives/functions/fnc_canLoadCaptive.sqf b/addons/captives/functions/fnc_canLoadCaptive.sqf new file mode 100644 index 0000000000..04b33ad42d --- /dev/null +++ b/addons/captives/functions/fnc_canLoadCaptive.sqf @@ -0,0 +1,39 @@ +/* + * Author: commy2 + * Check if the unit can load the target object into a vehicle. + * + * Arguments: + * 0: Unit that wants to load a captive + * 1: A captive. ObjNull for the first escorted captive (may be null) + * 2: Vehicle to load the captive into. ObjNull for the nearest vehicle (may be null) + * + * Return Value: + * The return value + * + * Example: + * [player, bob] call ACE_captives_fnc_canLoadCaptive + * + * Public: No + */ +#include "script_component.hpp" + +private ["_objects"]; + +PARAMS_3(_unit,_target,_vehicle); + +if (isNull _target) then { + _objects = attachedObjects _unit; + _objects = [_objects, {_this getVariable [QGVAR(isHandcuffed), false]}] call EFUNC(common,filter); + if ((count _objects) > 0) then {_target = _objects select 0;}; +}; + +if (isNull _vehicle) then { + _objects = nearestObjects [_unit, ["Car", "Tank", "Helicopter", "Plane", "Ship_F"], 10]; + if ((count _objects) > 0) then {_vehicle = _objects select 0;}; +}; + +(!isNull _target) +&& {!isNull _vehicle} +&& {_unit getVariable [QGVAR(isEscorting), false]} +&& {_target getVariable [QGVAR(isHandcuffed), false]} +&& {_vehicle emptyPositions "cargo" > 0} diff --git a/addons/captives/functions/fnc_canRemoveHandcuffs.sqf b/addons/captives/functions/fnc_canRemoveHandcuffs.sqf new file mode 100644 index 0000000000..4642cd90fd --- /dev/null +++ b/addons/captives/functions/fnc_canRemoveHandcuffs.sqf @@ -0,0 +1,23 @@ +/* + * Author: PabstMirror + * Checks the conditions for being able to remove handcuffs + * + * Arguments: + * 0: caller (player) + * 1: target + * + * Return Value: + * The return value + * + * Example: + * [player, bob] call ACE_captives_fnc_canRemoveHandcuffs + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_2(_unit,_target); + +//Unit is handcuffed and not currently being escorted +_target getVariable [QGVAR(isHandcuffed), false] && +{isNull (attachedTo _target)} diff --git a/addons/captives/functions/fnc_canStopEscorting.sqf b/addons/captives/functions/fnc_canStopEscorting.sqf new file mode 100644 index 0000000000..e6a5a0e568 --- /dev/null +++ b/addons/captives/functions/fnc_canStopEscorting.sqf @@ -0,0 +1,40 @@ +/* + * Author: PabstMirror + * Tests if player can stop escorting + * + * Arguments: + * 0: caller (player) + * 1: target + * + * Return Value: + * The return value + * + * Example: + * [player, bob] call ACE_captives_fnc_canStopEscorting + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_1(_unit); +DEFAULT_PARAM(1,_target,objNull); + +private ["_isAttached"]; + +if (isNull _target) then { + _target = _unit getVariable [QGVAR(escortedUnit), objNull]; +}; + +if (isNull _target) exitWith { + ERROR("Null Target (no ACE_escortedUnit)"); + false +}; + +_isAttached = _target in (attachedObjects _unit); + +if (_isAttached && (!(_target getVariable [QGVAR(isHandcuffed), false]))) exitWith { + ERROR("Attached But Not Captive"); + false +}; + +_isAttached diff --git a/addons/captives/functions/fnc_canSurrender.sqf b/addons/captives/functions/fnc_canSurrender.sqf new file mode 100644 index 0000000000..238087c62b --- /dev/null +++ b/addons/captives/functions/fnc_canSurrender.sqf @@ -0,0 +1,22 @@ +/* + * Author: PabstMirror + * Checks the conditions for being able to surrender + * + * Arguments: + * 0: caller (player) + * 1: New Surrender State to test + * + * Return Value: + * The return value + * + * Example: + * [Jean, true] call ACE_captives_fnc_canSurrender; + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_2(_unit,_newSurrenderState); + +//TODO: any other conditions?? +(!((_unit getVariable [QGVAR(isSurrendering), false]) isEqualTo _newSurrenderState)) diff --git a/addons/captives/functions/fnc_canUnloadCaptive.sqf b/addons/captives/functions/fnc_canUnloadCaptive.sqf new file mode 100644 index 0000000000..a86bdae588 --- /dev/null +++ b/addons/captives/functions/fnc_canUnloadCaptive.sqf @@ -0,0 +1,28 @@ +/* + * Author: commy2 + * Check if the unit can unload a captive from the vehicle. + * + * Arguments: + * 0: Unit that wants to unload a captive + * 1: A captive. ObjNull for the first escorted captive + * 2: Vehicle to unload a captive from + * + * Return Value: + * The return value + * + * Example: + * [player, bob, car1] call ACE_captives_fnc_canUnloadCaptive; + * + * Public: No + */ +#include "script_component.hpp" + +private ["_cargo"]; + +PARAMS_2(_unit,_vehicle); + +_cargo = crew _vehicle; // Can also unload from driver, gunner, commander, turret positions. They shouldn't be there anyway. + +_cargo = [_cargo, {_this getVariable [QGVAR(isHandcuffed), false]}] call EFUNC(common,filter); + +count _cargo > 0 diff --git a/addons/captives/functions/fnc_doApplyHandcuffs.sqf b/addons/captives/functions/fnc_doApplyHandcuffs.sqf new file mode 100644 index 0000000000..0d15f503e8 --- /dev/null +++ b/addons/captives/functions/fnc_doApplyHandcuffs.sqf @@ -0,0 +1,25 @@ +/* + * Author: PabstMirror + * Checks the conditions for being able to apply handcuffs + * + * Arguments: + * 0: caller (player) + * 1: target + * + * Return Value: + * The return value + * + * Example: + * [player, bob] call ACE_captives_fnc_doApplyHandcuffs; + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_2(_unit,_target); + +_unit removeItem "ACE_CableTie"; + +playSound3D [QUOTE(PATHTO_R(sounds\cable_tie_zipping.ogg)), objNull, false, (getPosASL _target), 1, 1, 10]; + +["SetHandcuffed", [_target], [_target, true]] call EFUNC(common,targetEvent); diff --git a/addons/captives/functions/fnc_doEscortCaptive.sqf b/addons/captives/functions/fnc_doEscortCaptive.sqf new file mode 100644 index 0000000000..299aa81631 --- /dev/null +++ b/addons/captives/functions/fnc_doEscortCaptive.sqf @@ -0,0 +1,59 @@ +/* + * Author: Nic547 + * Attaches a Captive to the _unit + * + * Arguments: + * 0: _unit-Player + * 1: target + * 2: _state + * + * Return Value: + * The return value + * + * Example: + * [player, bob, true] call ACE_captives_fnc_doEscorteCaptive; + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_3(_unit,_target,_state); + +if (_state) then { + if (_unit getVariable [QGVAR(isEscorting), false]) exitWith {}; + + [_unit, _target] call EFUNC(common,claim); + _unit setVariable [QGVAR(isEscorting), true, true]; + + _target attachTo [_unit, [0, 1, 0]]; + + _unit setVariable [QGVAR(escortedUnit), _target, true]; + + //Add Actionmenu to release captive + _actionID = _unit addAction [format ["%1", localize "STR_ACE_Captives_StopEscorting"], + {[(_this select 0), ((_this select 0) getVariable [QGVAR(escortedUnit), objNull]), false] call FUNC(doEscortCaptive);}, + nil, 20, false, true, "", QUOTE(!isNull (GETVAR(_target,QGVAR(escortedUnit),objNull)))]; + + private "_escortFnc"; + _escortFnc = { + EXPLODE_3_PVT((_this select 0),_unit,_target,_actionID); + if (_unit getVariable [QGVAR(isEscorting), false]) then { + if (!alive _target || {!alive _unit} || {!canStand _target} || {!canStand _unit} || {_target getVariable ["ACE_isUnconscious", false]} || {_unit getVariable ["ACE_isUnconscious", false]} || {!isNull (attachedTo _unit)}) then { + _unit setVariable [QGVAR(isEscorting), false, true]; + }; + }; + + if (!(_unit getVariable [QGVAR(isEscorting), false])) then { + [(_this select 1)] call cba_fnc_removePerFrameHandler; + [objNull, _target] call EFUNC(common,claim); + detach _target; + _unit removeAction _actionID; + _unit setVariable [QGVAR(escortedUnit), objNull, true]; + }; + }; + [_escortFnc, 0.2, [_unit, _target, _actionID]] call CBA_fnc_addPerFrameHandler; + +} else { + _unit setVariable [QGVAR(isEscorting), false, true]; + _unit setVariable [QGVAR(escortedUnit), objNull, true]; +}; diff --git a/addons/captives/functions/fnc_doFriskPerson.sqf b/addons/captives/functions/fnc_doFriskPerson.sqf new file mode 100644 index 0000000000..14b18ffd0e --- /dev/null +++ b/addons/captives/functions/fnc_doFriskPerson.sqf @@ -0,0 +1,70 @@ +/* + * Author: bux578 + * Open the select menu with the "personal" items of a frisked unit. It only shows "handgunWeapon", "uniformItems", "vestItems", "backpackItems" and "assignedItems" because every other item is visible on the character + * + * Arguments: + * 0: player unit + * 1: unit + * + * Return Value: + * Nothing + * + * Example: + * [player, bob] call ACE_captives_fnc_doFristPerson; + * + * Public: No + */ +#include "script_component.hpp" + +private ["_weapon", "_listedItemClasses", "_actions", "_allGear"]; + +PARAMS_2(_player,_unit); + +_weapon = currentWeapon _player; +if (_weapon == primaryWeapon _player && {_weapon != ""}) then { + [_player, "AmovPercMstpSlowWrflDnon", 0] call EFUNC(common,doAnimation); +}; + +_listedItemClasses = []; + +_actions = [localize "STR_ACE_Captives_FriskMenuHeader", localize "STR_ACE_Captives_CancelSelection"] call ACE_Interaction_fnc_prepareSelectMenu; + +_allGear = []; + +if ((handgunWeapon _unit) != "") then { + _allGear pushBack (handgunWeapon _unit); +}; +if (count (uniformItems _unit) > 0) then { + _allGear = _allGear + (uniformItems _unit); +}; +if (count (vestItems _unit) > 0) then { + _allGear = _allGear + (vestItems _unit); +}; +if (count (backpackItems _unit) > 0) then { + _allGear = _allGear + (backpackItems _unit); +}; +if (count (assignedItems _unit) > 0) then { + _allGear = _allGear + (assignedItems _unit); +}; + +// Handgun +// Uniform Items +// Vest Items +// Backpack Items +// Assigned Items +{ + if (!(_x in _listedItemClasses)) then { + private "_item"; + _item = configFile >> "CfgMagazines" >> _x; + if (isNil "_item" || str _item == "") then { //str _item ? + _item = configFile >> "CfgWeapons" >> _x; + }; + _actions = [_actions, getText(_item >> "displayName"), getText(_item >> "picture"), _x] call ACE_Interaction_fnc_addSelectableItem; + _listedItemClasses pushBack _x; + }; +} forEach (_allGear); + +[_actions, {call ACE_Interaction_fnc_hideMenu;}, {call ACE_Interaction_fnc_hideMenu;}] call ACE_Interaction_fnc_openSelectMenu; + +// don't need an "Ok" Button +ctrlShow [8860, false]; diff --git a/addons/captives/functions/fnc_doLoadCaptive.sqf b/addons/captives/functions/fnc_doLoadCaptive.sqf new file mode 100644 index 0000000000..9fd65a130d --- /dev/null +++ b/addons/captives/functions/fnc_doLoadCaptive.sqf @@ -0,0 +1,38 @@ +/* + * Author: commy2 + * Unit loads the target object into a vehicle. + * + * Arguments: + * 0: Unit that wants to load a captive + * 1: A captive. ObjNull for the first escorted captive + * 2: Vehicle to load the captive into. ObjNull for the nearest vehicle + * + * Return Value: + * Nothing + * + * Example: + * [bob, tom, car] call ACE_captives_fnc_doLoadCaptive + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_3(_unit,_target,_vehicle); + +if (isNull _target) then { + _objects = attachedObjects _unit; + _objects = [_objects, {_this getVariable [QGVAR(isHandcuffed), false]}] call EFUNC(common,filter); + if ((count _objects) > 0) then {_target = _objects select 0;}; +}; +if (isNull _target) exitWith {}; + +if (isNull _vehicle) then { + _objects = nearestObjects [_unit, ["Car_F", "Tank_F", "Helicopter_F", "Boat_F", "Plane_F"], 10]; + if ((count _objects) > 0) then {_vehicle = _objects select 0;}; +}; +if (isNull _vehicle) exitWith {}; + +if ((!isNil "_target") && {!isNil "_vehicle"}) then { + _unit setVariable [QGVAR(isEscorting), false, true]; + ["MoveInCaptive", [_target], [_target, _vehicle]] call EFUNC(common,targetEvent); +}; diff --git a/addons/captives/functions/fnc_doRemoveHandcuffs.sqf b/addons/captives/functions/fnc_doRemoveHandcuffs.sqf new file mode 100644 index 0000000000..a69decf620 --- /dev/null +++ b/addons/captives/functions/fnc_doRemoveHandcuffs.sqf @@ -0,0 +1,20 @@ +/* + * Author: PabstMirror + * Remove handcuffs from a target + * + * Arguments: + * 0: target + * + * Return Value: + * The return value + * + * Example: + * [bob, false] call ACE_captives_fnc_doRemoveHandcuffs + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_2(_unit,_target); + +["SetHandcuffed", [_target], [_target, false]] call EFUNC(common,targetEvent); diff --git a/addons/captives/functions/fnc_doUnloadCaptive.sqf b/addons/captives/functions/fnc_doUnloadCaptive.sqf new file mode 100644 index 0000000000..b7fa57a7bb --- /dev/null +++ b/addons/captives/functions/fnc_doUnloadCaptive.sqf @@ -0,0 +1,32 @@ +/* + * Author: commy2 + * Unit unloads a captive from a vehicle. + * + * Arguments: + * 0: Unit that wants to unload a captive + * 1: Vehicle to unload a captive from. + * + * Return Value: + * Nothing + * + * Example: + * [bob, car] call ACE_captives_fnc_doUnloadCaptive + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_2(_unit,_vehicle); + +private ["_cargo", "_target"]; + +_cargo = crew _vehicle; // Can also unload from driver, gunner, commander, turret positions. They shouldn't be there anyway. + +_cargo = [_cargo, {_this getVariable [QGVAR(isHandcuffed), false]}] call EFUNC(common,filter); + +if ((count _cargo) > 0) then { + _target = _cargo select 0; + ["MoveOutCaptive", [_target], [_target]] call EFUNC(common,targetEvent); +} else { + ERROR("No captive to unload"); +}; diff --git a/addons/captives/functions/fnc_handleGetIn.sqf b/addons/captives/functions/fnc_handleGetIn.sqf new file mode 100644 index 0000000000..54133e2362 --- /dev/null +++ b/addons/captives/functions/fnc_handleGetIn.sqf @@ -0,0 +1,24 @@ +/* + * Author: commy2 + * Handles when a unit gets in to a vehicle. Release escorted captive when entering a vehicle + * + * Arguments: + * 0: _vehicle + * 2: dunno + * 1: _unit + * + * Return Value: + * The return value + * + * Example: + * [car2, x, player] call ACE_captives_fnc_handleGetIn + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_3(_vehicle,_dontcare,_unit); + +if ((local _unit) && (_unit getVariable [QGVAR(isEscorting), false])) then { + _unit setVariable [QGVAR(isEscorting), false, true]; +}; diff --git a/addons/captives/functions/fnc_handleGetOut.sqf b/addons/captives/functions/fnc_handleGetOut.sqf new file mode 100644 index 0000000000..4bf9a1fa19 --- /dev/null +++ b/addons/captives/functions/fnc_handleGetOut.sqf @@ -0,0 +1,33 @@ +/* + * Author: commy2 + * Handles when a captive unit gets out of a vehicle. + * + * Arguments: + * 0: _vehicle + * 2: dunno + * 1: _unit + * + * Return Value: + * The return value + * + * Example: + * [car2, x, player] call ACE_captives_fnc_handleGetOut + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_3(_vehicle,_dontcare,_unit); + +if ((local _unit) && {_unit getVariable [QGVAR(isHandcuffed), false]}) then { + private ["_cargoIndex"]; + + _cargoIndex = _unit getVariable [QGVAR(CargoIndex), -1]; + + //If captive was not "unloaded", then move them back into the vehicle. + if (_cargoIndex != -1) exitWith { + _unit moveInCargo [_vehicle, _cargoIndex]; + }; + + [_unit, "ACE_AmovPercMstpScapWnonDnon", 2] call EFUNC(common,doAnimation); +}; diff --git a/addons/captives/functions/fnc_handleKilled.sqf b/addons/captives/functions/fnc_handleKilled.sqf new file mode 100644 index 0000000000..9e9c5e1ac8 --- /dev/null +++ b/addons/captives/functions/fnc_handleKilled.sqf @@ -0,0 +1,30 @@ +/* + * Author: PabstMirror + * Handles when a unit is kill. Reset captivity and escorting status + * + * Arguments: + * 0: _oldUnit + * + * Return Value: + * None + * + * Example: + * [bob1] call ACE_captives_fnc_handleKilled + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_1(_oldUnit); + +if (_oldUnit getVariable [QGVAR(isHandcuffed), false]) then { + _oldUnit setVariable [QGVAR(isHandcuffed), false, true]; +}; + +if (_oldUnit getVariable [QGVAR(isEscorting), false]) then { + _oldUnit setVariable [QGVAR(isEscorting), false, true]; +}; + +if (_oldUnit getVariable [QGVAR(isSurrendering), false]) then { + _oldUnit setVariable [QGVAR(isSurrendering), false, true]; +}; diff --git a/TO_MERGE/agm/Captives/functions/fn_handleKnockedOut.sqf b/addons/captives/functions/fnc_handleKnockedOut.sqf similarity index 100% rename from TO_MERGE/agm/Captives/functions/fn_handleKnockedOut.sqf rename to addons/captives/functions/fnc_handleKnockedOut.sqf diff --git a/addons/captives/functions/fnc_handlePlayerChanged.sqf b/addons/captives/functions/fnc_handlePlayerChanged.sqf new file mode 100644 index 0000000000..13e284ef80 --- /dev/null +++ b/addons/captives/functions/fnc_handlePlayerChanged.sqf @@ -0,0 +1,27 @@ +/* + * Author: commy2 + * Handles playerChanged. Resets "showHUD" based on handcuff status + * + * Arguments: + * 0: _newUnit + * 1: _oldUnit + * + * Return Value: + * The return value + * + * Example: + * [bob1, bob2] call ACE_captives_fnc_handlePlayerChange + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_2(_newUnit,_oldUnit); + +if ((_newUnit getVariable [QGVAR(isHandcuffed), false]) || {_newUnit getVariable [QGVAR(isSurrendering), false]}) then { + TRACE_1("Player Change (showHUD false)",_newUnit); + showHUD false; +} else { + TRACE_1("Player Change (showHUD true)",_newUnit); + showHUD true; +}; diff --git a/addons/captives/functions/fnc_handleUnitInitPost.sqf b/addons/captives/functions/fnc_handleUnitInitPost.sqf new file mode 100644 index 0000000000..1a5a8f2ecd --- /dev/null +++ b/addons/captives/functions/fnc_handleUnitInitPost.sqf @@ -0,0 +1,34 @@ +/* + * Author: commy2 + * handle captive and unconsciousness state and prevent grenades + * + * Arguments: + * 0: _unit + * + * Return Value: + * The return value + * + * Example: + * [bob] call ACE_captives_fnc_handleUnitInitPost + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_1(_unit); + +// prevent players from throwing grenades (added to all units) +[_unit, "Throw", {((_this select 1) getVariable [QGVAR(isHandcuffed), false]) || {(_this select 1) getVariable [QGVAR(isSurrendering), false]}}, {}] call EFUNC(common,addActionEventhandler); + +if (local _unit) then { + // reset status on mission start + if (_unit getVariable [QGVAR(isHandcuffed), false]) then { + _unit setVariable [QGVAR(isHandcuffed), false]; + [_unit, true] call FUNC(setHandcuffed); + }; + + if (_unit getVariable [QGVAR(isSurrendering), false]) then { + _unit setVariable [QGVAR(isSurrendering), false]; + [_unit, true] call FUNC(surrender); + }; +}; diff --git a/addons/captives/functions/fnc_handleWokeUp.sqf b/addons/captives/functions/fnc_handleWokeUp.sqf new file mode 100644 index 0000000000..9bf2e1a2bc --- /dev/null +++ b/addons/captives/functions/fnc_handleWokeUp.sqf @@ -0,0 +1,23 @@ +/* + * Author: commy2 + * TODO + * + * Arguments: + * 0: _unit + * + * Return Value: + * The return value + * + * Example: + * [bob] call ACE_captives_fnc_handleWokeUp + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_1(_unit); + +if (_unit getVariable [QGVAR(isHandcuffed), false] && {vehicle _unit == _unit}) then { + [_unit] call EFUNC(common,fixLoweredRifleAnimation); + [_unit, "ACE_AmovPercMstpScapWnonDnon", 0] call EFUNC(common,doAnimation); +}; diff --git a/addons/captives/functions/fnc_moduleSurrender.sqf b/addons/captives/functions/fnc_moduleSurrender.sqf new file mode 100644 index 0000000000..5cbf43aacc --- /dev/null +++ b/addons/captives/functions/fnc_moduleSurrender.sqf @@ -0,0 +1,46 @@ +/* + * Author: PabstMirror + * Module Function to make a unit surrender (can be called from editor, or placed with zeus) + * + * Arguments: + * 0: The Module Logic Object + * 1: synced objects + * 2: Activated + * + * Return Value: + * Nothing + * + * Example: + * Called from module + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_3(_logic,_units,_activated); + +if (!_activated) exitWith {}; + +if (local _logic) then { + if ((!isnull curatorcamera) && {((count curatorMouseOver) == 2) && {(curatorMouseOver select 1) == _logic}}) then {//in zeus interface and we placed the module + _bisMouseOver = missionNamespace getVariable ["bis_fnc_curatorObjectPlaced_mouseOver", []];//bis caches the previous curatorMouseOver + if ((count _bisMouseOver) == 2) then {//check what mouse was over before the module was placed + _mouseOverObject = _bisMouseOver select 1; + if ((_mouseOverObject isKindOf "CAManBase") && {(vehicle _mouseOverObject) == _mouseOverObject}) then { + systemChat format ["Debug - module surrendering %1", (name _mouseOverObject)]; + [_mouseOverObject, true] call FUNC(surrender); + } else { + systemChat format ["Only use on dismounted inf"]; + }; + } else { + systemChat format ["Nothing under mouse"]; + }; + } else {//an editor module + { + systemChat format ["Debug - module surrendering %1", (name _x)]; + [_x, true] call FUNC(surrender); + } forEach _units; + }; + + deleteVehicle _logic; +}; diff --git a/addons/captives/functions/fnc_setHandcuffed.sqf b/addons/captives/functions/fnc_setHandcuffed.sqf new file mode 100644 index 0000000000..912b00662f --- /dev/null +++ b/addons/captives/functions/fnc_setHandcuffed.sqf @@ -0,0 +1,63 @@ +/* + * Author: Nic547, commy2 + * Handcuffs a unit. + * + * Arguments: + * 0: Unit + * 1: True to take captive, false to release captive + * + * Return Value: + * Nothing + * + * Example: + * [bob, true] call ACE_captives_fnc_setHandcuffed; + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_2(_unit,_state); + +// We only want this function to work on local machines +if (!local _unit) exitwith { + [_this, QUOTE(FUNC(setHandcuffed)), _unit] call EFUNC(common,execRemoteFnc); + TRACE_2("running setHandcuffed on remote unit",_unit,_state); +}; + +if (_state isEqualTo (_unit getVariable [QGVAR(isHandcuffed), false])) then { + LOG("setHandcuffed: current state same as new"); +}; + +if (_state) then { + _unit setVariable [QGVAR(isHandcuffed), true, true]; + [_unit, QGVAR(Handcuffed), true] call EFUNC(common,setCaptivityStatus); + _unit setVariable [QGVAR(CargoIndex), ((vehicle _unit) getCargoIndex _unit), true]; + + if (_unit == ACE_player) then { + showHUD false; + }; + + // fix anim on mission start (should work on dedicated servers) + [{ + PARAMS_1(_unit); + if (_unit getVariable [QGVAR(isHandcuffed), false] && {vehicle _unit == _unit}) then { + [_unit] call EFUNC(common,fixLoweredRifleAnimation); + [_unit, "ACE_AmovPercMstpScapWnonDnon", 1] call EFUNC(common,doAnimation); + }; + }, [_unit], 0.01, 0] call EFUNC(common,waitAndExecute); +} else { + _unit setVariable [QGVAR(isHandcuffed), false, true]; + [_unit, QGVAR(Handcuffed), false] call EFUNC(common,setCaptivityStatus); + if ((vehicle _unit) == _unit) then { + //Break out of hands up animation loop (doAnimation handles Unconscious prioity) + [_unit, "ACE_AmovPercMstpScapWnonDnon_AmovPercMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation); + }; + + if (_unit getVariable [QGVAR(CargoIndex), -1] != -1) then { + _unit setVariable [QGVAR(CargoIndex), -1, true]; + }; + + if (_unit == ACE_player) then { + showHUD true; + }; +}; diff --git a/addons/captives/functions/fnc_surrender.sqf b/addons/captives/functions/fnc_surrender.sqf new file mode 100644 index 0000000000..1f0e232926 --- /dev/null +++ b/addons/captives/functions/fnc_surrender.sqf @@ -0,0 +1,76 @@ +/* + * Author: commy2 PabstMirror + * Lets a unit surrender + * + * Arguments: + * 0: Unit + * 1: State + * + * Return Value: + * Nothing + * + * Example: + * [Pierre, true] call ACE_captives_fnc_surrender; + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_2(_unit,_state); + +// We only want this function to work on local machines +if (!local _unit) exitwith { + [_this, QUOTE(FUNC(surrender)), _unit] call EFUNC(common,execRemoteFnc); + TRACE_2("running surrender on remote unit",_unit,_state); +}; + +if ((_unit getVariable [QGVAR(isSurrendering), false]) isEqualTo _state) then { + LOG("Surrender: current state same as new"); +}; + +if (_state) then { + _unit setVariable [QGVAR(isSurrendering), true, true]; + [_unit, QGVAR(Surrendered), true] call EFUNC(common,setCaptivityStatus); + + if (_unit == ACE_player) then { + showHUD false; + }; + + // fix anim on mission start (should work on dedicated servers) + [{ + PARAMS_1(_unit); + if (_unit getVariable [QGVAR(isSurrendering), false] && {vehicle _unit == _unit}) then { + [_unit] call EFUNC(common,fixLoweredRifleAnimation); + [_unit, "ACE_AmovPercMstpSsurWnonDnon", 1] call EFUNC(common,doAnimation); + }; + }, [_unit], 0.01, 0] call EFUNC(common,waitAndExecute); + + //PFEH - (TODO: move to event system?) + [{ + EXPLODE_1_PVT((_this select 0),_unit); + if (_unit getVariable [QGVAR(isSurrendering), false]) then { + //If unit dies, gets knocked out, or is handcuffed then end surrender + if ((!alive _unit) || {_unit getVariable ["ACE_isUnconscious", false]} || {_unit getVariable [QGVAR(isHandcuffed), false]}) then { + [_unit, false] call FUNC(surrender); + [(_this select 1)] call CBA_fnc_removePerFrameHandler; + }; + } else { + [(_this select 1)] call cba_fnc_removePerFrameHandler; + }; + }, 0.0, [_unit]] call CBA_fnc_addPerFrameHandler; +} else { + _unit setVariable [QGVAR(isSurrendering), false, true]; + [_unit, QGVAR(Surrendered), false] call EFUNC(common,setCaptivityStatus); + + if ((vehicle _unit) == _unit) then { + //Break out of hands up animation loop (doAnimation handles Unconscious prioity) + [_unit, "ACE_AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation); + }; + + if (_unit == ACE_player) then { + //only re-enable HUD if not handcuffed + if (!(_unit getVariable [QGVAR(isHandcuffed), false])) then { + showHUD true; + }; + }; +}; diff --git a/addons/captives/functions/fnc_vehicleCaptiveMoveIn.sqf b/addons/captives/functions/fnc_vehicleCaptiveMoveIn.sqf new file mode 100644 index 0000000000..626a0b34e4 --- /dev/null +++ b/addons/captives/functions/fnc_vehicleCaptiveMoveIn.sqf @@ -0,0 +1,26 @@ +/* + * Author: PabstMirror + * Loads a captive into a vehicle + * + * Arguments: + * 0: The Captive + * 1: The Vehicle + * + * Return Value: + * Nothing + * + * Example: + * [bob, car1] call ACE_captives_fnc_vehicleCaptiveMoveIn; + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_2(_target,_vehicle); + +private ["_cargoIndex"]; + +_target moveInCargo _vehicle; +_target assignAsCargo _vehicle; +_cargoIndex = _vehicle getCargoIndex _target; +_target setVariable [QGVAR(CargoIndex), _cargoIndex, true]; diff --git a/addons/captives/functions/fnc_vehicleCaptiveMoveOut.sqf b/addons/captives/functions/fnc_vehicleCaptiveMoveOut.sqf new file mode 100644 index 0000000000..5ef6f01406 --- /dev/null +++ b/addons/captives/functions/fnc_vehicleCaptiveMoveOut.sqf @@ -0,0 +1,24 @@ +/* + * Author: PabstMirror + * Unloads a captive from a vehicle. + * + * Arguments: + * 0: Captive Unit being unloaded + * + * Return Value: + * Nothing + * + * Example: + * [bob] call ACE_captives_fnc_vehicleCaptiveMoveOut; + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_1(_unit); + +_unit setVariable [QGVAR(CargoIndex), -1, true]; + +moveOut _unit; +[_unit, "ACE_AmovPercMstpScapWnonDnon", 2] call EFUNC(common,doAnimation); +unassignVehicle _unit; diff --git a/addons/captives/functions/script_component.hpp b/addons/captives/functions/script_component.hpp new file mode 100644 index 0000000000..e91d5c843b --- /dev/null +++ b/addons/captives/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\captives\script_component.hpp" \ No newline at end of file diff --git a/addons/captives/models/ace_cabletie.p3d b/addons/captives/models/ace_cabletie.p3d new file mode 100644 index 0000000000..72a6facd2b Binary files /dev/null and b/addons/captives/models/ace_cabletie.p3d differ diff --git a/addons/captives/models/ace_default.rvmat b/addons/captives/models/ace_default.rvmat new file mode 100644 index 0000000000..c7a241ca38 --- /dev/null +++ b/addons/captives/models/ace_default.rvmat @@ -0,0 +1,79 @@ +ambient[]={1,1,1,1}; +diffuse[]={1,1,1,1}; +forcedDiffuse[]={0,0,0,0}; +emmisive[]={0,0,0,1}; +specular[]={0.01,0.01,0.01,1}; //amount of glossiness - the higher the number, the higher the glossiness +specularPower=500; //area of glossiness - the higher the number, the smaller the area +PixelShaderID="Super"; +VertexShaderID="Super"; + +class Stage1 { + texture="#(rgb,1,1,1)color(0.5,0.5,1,1)"; + uvSource="tex"; + class uvTransform { + aside[]={1,0,0}; + up[]={0,1,0}; + dir[]={0,0,0}; + pos[]={0,0,0}; + }; +}; +class Stage2 { + texture="#(argb,8,8,3)color(0.5,0.5,0.5,1,dt)"; + uvSource="tex"; + class uvTransform { + aside[]={1,0,0}; + up[]={0,1,0}; + dir[]={0,0,0}; + pos[]={0,0,0}; + }; +}; +class Stage3 { + texture="#(argb,8,8,3)color(0,0,0,0,mc)"; + uvSource="tex"; + class uvTransform { + aside[]={1,0,0}; + up[]={0,1,0}; + dir[]={0,0,0}; + pos[]={0,0,0}; + }; +}; +class Stage4 { + texture="#(argb,8,8,3)color(1,1,1,1,as)"; + uvSource="tex"; + class uvTransform { + aside[]={1,0,0}; + up[]={0,1,0}; + dir[]={0,0,1}; + pos[]={0,0,1}; + }; +}; +class Stage5 { + texture="#(rgb,1,1,1)color(0.2,0.2,1,1)"; + uvSource="tex"; + class uvTransform { + aside[]={1,0,0}; + up[]={0,1,0}; + dir[]={0,0,0}; + pos[]={0,0,0}; + }; +}; +class Stage6 { + texture="#(ai,64,64,1)fresnel(4.7,1.2)"; + uvSource="tex"; + class uvTransform { + aside[]={1,0,0}; + up[]={0,1,0}; + dir[]={0,0,1}; + pos[]={0,0,0}; + }; +}; +class Stage7 { + texture="a3\data_f\env_land_ca.paa"; + uvSource="tex"; + class uvTransform { + aside[]={1,0,0}; + up[]={0,1,0}; + dir[]={0,0,1}; + pos[]={0,0,0}; + }; +}; diff --git a/addons/captives/script_component.hpp b/addons/captives/script_component.hpp new file mode 100644 index 0000000000..e68eb19d2f --- /dev/null +++ b/addons/captives/script_component.hpp @@ -0,0 +1,12 @@ +#define COMPONENT captives +#include "\z\ace\addons\main\script_mod.hpp" + +#ifdef DEBUG_ENABLED_CAPTIVES + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_CAPTIVES + #define DEBUG_SETTINGS DEBUG_SETTINGS_CAPTIVES +#endif + +#include "\z\ace\addons\main\script_macros.hpp" \ No newline at end of file diff --git a/addons/captives/sounds/cable_tie_zipping.ogg b/addons/captives/sounds/cable_tie_zipping.ogg new file mode 100644 index 0000000000..4f76037eb1 Binary files /dev/null and b/addons/captives/sounds/cable_tie_zipping.ogg differ diff --git a/TO_MERGE/agm/Captives/stringtable.xml b/addons/captives/stringtable.xml similarity index 84% rename from TO_MERGE/agm/Captives/stringtable.xml rename to addons/captives/stringtable.xml index 060f89d9ec..7d8096b3e6 100644 --- a/TO_MERGE/agm/Captives/stringtable.xml +++ b/addons/captives/stringtable.xml @@ -1,8 +1,8 @@  - - + + - + Take Prisoner Gefangen nehmen Tomar prisionero @@ -14,7 +14,7 @@ Foglyul ejtés Взять в плен - + Free Prisoner Gefangenen freilassen Liberar prisionero @@ -26,7 +26,7 @@ Fogoly szabadon elengedése Освободить пленника - + Escort Prisoner Gefangenen eskortieren Escoltar prisionero @@ -38,7 +38,7 @@ Fogoly kísérése Конвоировать пленника - + Release Prisoner Gefangenen loslassen Soltar prisionero @@ -50,7 +50,7 @@ Fogoly elengedése Прекратить конвоирование - + You need to take him as prisoner first! Du must ihn zuerst gefangen nehmen. Necesitas hacerle prisionero primero! @@ -62,7 +62,7 @@ Először foglyul kell ejtened! Вы должны сначала взять его в плен! - + Load Captive Gefangenen einladen Cargar prisionero @@ -71,8 +71,9 @@ Naložit zajatce Fogoly berakása Загрузить пленного + Embarcar Prisioneiro - + Unload Captive Gefangenen ausladen Descargar prisionero @@ -81,8 +82,9 @@ Vyložit zajatce Fogoly kivevése Выгрузить пленного + Desembarcar Prisioneiro - + Cable Tie Kabelbinder Opaska zaciskowa @@ -94,7 +96,7 @@ Gyorskötöző Кабельная стяжка - + Cable ties that allow you to restrain prisoners. Kabelbinder ermöglichen es, Gefangene zu fesseln. Opaska zaciskowa pozwala na skrępowanie dłoni u więźnia. @@ -106,7 +108,7 @@ Gyorskötöző emberek fogjulejtéséhez. Кабельные стяжки позволяют связывать пленников. - + Inventory of frisked person Inventar der durchsuchten Person Inventaire de la fouille @@ -115,8 +117,9 @@ Inventář prohledávané osoby Ekwipunek rewidowanej osoby Инвентарь обысканных лиц + Inventário da pessoa revistada - + Frisk person Person durchsuchen Fouiller @@ -125,6 +128,13 @@ Rewiduj osobę Motozás Обыскать человека + Revistar + + + Surrender + + + Stop Surrendering \ No newline at end of file diff --git a/addons/common/CfgEventHandlers.hpp b/addons/common/CfgEventHandlers.hpp index 7ea3b1e1f9..b9c5d7e4ce 100644 --- a/addons/common/CfgEventHandlers.hpp +++ b/addons/common/CfgEventHandlers.hpp @@ -2,7 +2,6 @@ class Extended_PreInit_EventHandlers { class ADDON { init = QUOTE(call COMPILE_FILE(XEH_preInit)); - serverInit = QUOTE(call COMPILE_FILE(scripts\readParameters)); disableModuload = true; }; }; diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index c6a0ce7b9f..dbb665d446 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -1,6 +1,25 @@ // ACE - Common #include "script_component.hpp" +// Load settings from profile +if (hasInterface) then { + call FUNC(loadSettingsFromProfile); +}; + +// Listens for global "SettingChanged" events, to update the force status locally +["SettingChanged", { + + PARAMS_2(_name,_value); + if !(count _this > 2) exitWith {}; + + _force = _this select 2; + if (_force) then { + _settingData = [_name] call FUNC(getSettingData); + if (count _settingData == 0) exitWith {}; + _settingData set [6,_force]; + }; +}] call FUNC(addEventhandler); + // hack to get PFH to work in briefing [QGVAR(onBriefingPFH), "onEachFrame", { if (time > 0) exitWith { @@ -63,7 +82,7 @@ enableCamShake true; }] call FUNC(addEventhandler); -GVAR(OldPlayerInventory) = ACE_player call FUNC(getAllGear); +GVAR(OldPlayerInventory) = [ACE_player] call FUNC(getAllGear); GVAR(OldPlayerVisionMode) = currentVisionMode ACE_player; GVAR(OldZeusDisplayIsOpen) = !(isNull findDisplay 312); GVAR(OldCameraView) = cameraView; @@ -74,7 +93,7 @@ GVAR(OldPlayerTurret) = [ACE_player] call FUNC(getTurretIndex); [{ // "playerInventoryChanged" event - _newPlayerInventory = ACE_player call FUNC(getAllGear); + _newPlayerInventory = [ACE_player] call FUNC(getAllGear); if !(_newPlayerInventory isEqualTo GVAR(OldPlayerInventory)) then { // Raise ACE event locally GVAR(OldPlayerInventory) = _newPlayerInventory; diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 1bd305fa02..64a06a0f8c 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -11,6 +11,7 @@ PREP(addCustomEventHandler); PREP(addLineToDebugDraw); PREP(addMapMarkerCreatedEventHandler); PREP(addScrollWheelEventHandler); +PREP(addSetting); PREP(adminKick); PREP(ambientBrightness); PREP(applyForceWalkStatus); @@ -48,6 +49,7 @@ PREP(getConfigGunner); PREP(getDefaultAnim); PREP(getDoorTurrets); PREP(getForceWalkStatus); +PREP(getGunner); PREP(getHitPoints); PREP(getHitPointsWithSelections); PREP(getInPosition); @@ -55,6 +57,7 @@ PREP(getMarkerType); PREP(getName); PREP(getNumberFromMissionSQM); PREP(getPitchBankYaw); +PREP(getSettingData); PREP(getStringFromMissionSQM); PREP(getTargetAzimuthAndInclination); PREP(getTargetDistance); @@ -72,6 +75,7 @@ PREP(getVehicleCargo); PREP(getVehicleCodriver); PREP(getVehicleCrew); PREP(getWeaponAzimuthAndInclination); +PREP(getWeaponIndex); PREP(getWeaponType); PREP(getWindDirection); PREP(goKneeling); @@ -85,6 +89,8 @@ PREP(isInBuilding); PREP(isPlayer); PREP(isTurnedOut); PREP(letterToCode); +PREP(loadSettingsFromProfile); +PREP(loadSettingsOnServer); PREP(map); PREP(moduleCheckPBOs); PREP(moduleLSDVehicles); @@ -97,8 +103,7 @@ PREP(player); PREP(playerSide); PREP(progressBar); PREP(queueAnimation); -PREP(readBooleanParameterFromModule); -PREP(readNumericParameterFromModule); +PREP(readSettingFromModule); PREP(removeActionEventHandler); PREP(removeActionMenuEventHandler); PREP(removeCameraEventHandler); @@ -115,12 +120,16 @@ PREP(setName); PREP(setParameter); PREP(setPitchBankYaw); PREP(setVariableJIP); +PREP(setVariablePublic); +PREP(setSetting); +PREP(setSettingFromConfig); PREP(stringToColoredText); PREP(subString); PREP(toBin); PREP(toBitmask); PREP(toHex); PREP(toNumber); +PREP(throttledPublicVariable); PREP(unmuteUnit); PREP(waitAndExecute); @@ -162,7 +171,10 @@ PREP(hashListSelect); PREP(hashListSet); PREP(hashListPush); - +// Load settings +if (isServer) then { + call FUNC(loadSettingsOnServer); +}; ACE_player = player; @@ -183,7 +195,6 @@ if (hasInterface) then { }, 0, []] call cba_fnc_addPerFrameHandler; }; - PREP(stringCompare); PREP(string_removeWhiteSpace); PREP(isHC); diff --git a/addons/common/config.cpp b/addons/common/config.cpp index 2be05e6b57..84052cbdfb 100644 --- a/addons/common/config.cpp +++ b/addons/common/config.cpp @@ -57,10 +57,42 @@ class ACE_canInteractConditions { }; }; -class ACE_Options { +class ACE_Settings { + /* + *class GVAR(sampleSetting) { + * Value + * value = 1; + * + * Type (SCALAR, BOOL, STRING, ARRAY, COLOR) + * typeName = "SCALAR"; + * + * Force the setting? + * force = 0; + * + * Does it appear on the options menu? + * isClientSetable = 1; + * + * The following settings only apply when isClientSetable == 1 + * Stringtable entry with the setting name + * displayName = "$STR_ACE_Common_SettingName"; + * + * Stringtable entry with the setting description + * description = "$STR_ACE_Common_SettingDescription"; + * + * Stringtable entries that describe the options + * Only applies if typeName == "SCALAR"; + * values[] = {"Disabled", "Enabled", "Only Cursor", "Only On Keypress", "Only Cursor and KeyPress"}; + *}; + */ + class GVAR(forceAllSettings) { + value = 0; + typeName = "BOOL"; + }; class GVAR(enableNumberHotkeys) { + value = 1; + typeName = "BOOL"; + isClientSetable = 1; displayName = "$STR_ACE_Common_EnableNumberHotkeys"; - default = 1; }; }; diff --git a/addons/common/functions/fnc_addSetting.sqf b/addons/common/functions/fnc_addSetting.sqf new file mode 100644 index 0000000000..866b7fb35b --- /dev/null +++ b/addons/common/functions/fnc_addSetting.sqf @@ -0,0 +1,40 @@ +/* + * Author: CAA-Picard + * Adds a new setting at runtime, with all it's metadata. + * If has only local effects. + * + * Arguments: + * 0: _name (String) + * 1: _typeName (String) + * 2: _isClientSetable (Bool) + * 3: _localizedName (String) + * 4: _localizedDescription (String) + * 5: _possibleValues (Array) + * 6: _isForced (Bool) + * 7: _defaultValue (Any) + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" + +EXPLODE_8_PVT(_this,_name,_typeName,_isClientSetable,_localizedName,_localizedDescription,_possibleValues,_isForced,_value); + +_settingData = [_name] call FUNC(getSettingData); + +// Exit if the setting already exists +if (count _settingData > 0) exitWith {}; + +// Update the variable +TRACE_2("Setting added",_name,_value); + +// Init the variable +missionNamespace setVariable [_name, _value]; + +// Add the setting data +GVAR(settings) pushBack _this; + +// Raise event locally +["SettingChanged", [_name, _value]] call FUNC(localEvent); diff --git a/addons/common/functions/fnc_fixLoweredRifleAnimation.sqf b/addons/common/functions/fnc_fixLoweredRifleAnimation.sqf index 55bc6865b0..411fdd2eb3 100644 --- a/addons/common/functions/fnc_fixLoweredRifleAnimation.sqf +++ b/addons/common/functions/fnc_fixLoweredRifleAnimation.sqf @@ -1,10 +1,22 @@ -// by commy2 +/* + * Author: commy2 + * Fixes the lowered rifle animation + * + * Arguments: + * 0: Unit + * + * Return Value: + * Nothing + * + * Example: + * [_player] call ace_common_fnc_fixLoweredRifleAnimation + * + * Public: No + */ #include "script_component.hpp" -private "_unit"; +PARAMS_1(_unit); -_unit = _this select 0; - -if (currentWeapon _unit != "" && {currentWeapon _unit == primaryWeapon _unit} && {weaponLowered _unit} && {stance _unit == "STAND"}) then { +if (currentWeapon _unit != "" && {currentWeapon _unit == primaryWeapon _unit} && {weaponLowered _unit} && {stance _unit == "STAND"} && {(vehicle _unit) == _unit}) then { [_unit, "amovpercmstpsraswrfldnon", 0] call FUNC(doAnimation); }; diff --git a/addons/common/functions/fnc_getGunner.sqf b/addons/common/functions/fnc_getGunner.sqf new file mode 100644 index 0000000000..0c82066e4b --- /dev/null +++ b/addons/common/functions/fnc_getGunner.sqf @@ -0,0 +1,28 @@ +/* + * Author: commy2 + * + * Get the gunner of a vehicle who uses the given weapon type. Requires every turret to have a different weapon. + * + * Argument: + * 0: The vehicle (Object) + * 1: weapon of the vehicle (String) + * + * Return value: + * The turret gunner with this weapon (Object) + */ + +private ["_vehicle", "_weapon"]; + +_vehicle = _this select 0; +_weapon = _this select 1; + +private "_gunner"; +_gunner = objNull; + +{ + if (_weapon in (_vehicle weaponsTurret _x)) exitWith { + _gunner = _vehicle turretUnit _x; + }; +} forEach allTurrets _vehicle; + +_gunner diff --git a/addons/common/functions/fnc_getSettingData.sqf b/addons/common/functions/fnc_getSettingData.sqf new file mode 100644 index 0000000000..3dd2582860 --- /dev/null +++ b/addons/common/functions/fnc_getSettingData.sqf @@ -0,0 +1,31 @@ +/* + * Author: CAA-Picard + * Returns the metadata of a setting if it exists + * + * Arguments: + * 0: Name of the setting (String) + * + * Return Value: + * Setting Data (Array) + * 0: _name + * 1: _typeName + * 2: _isClientSetable + * 3: _localizedName + * 4: _localizedDescription + * 5: _possibleValues + * 6: _isForced + * 7: _defaultValue + * + * Public: No + */ +#include "script_component.hpp" + +EXPLODE_1_PVT(_this,_name); + +private ["_value"]; +_value = []; +{ + if ((_x select 0) == _name) exitWith {_value = _x}; +} forEach GVAR(settings); + +_value diff --git a/addons/common/functions/fnc_getWeaponIndex.sqf b/addons/common/functions/fnc_getWeaponIndex.sqf new file mode 100644 index 0000000000..f2b8bce9f2 --- /dev/null +++ b/addons/common/functions/fnc_getWeaponIndex.sqf @@ -0,0 +1,25 @@ +/* + * Author: commy2 + * Get the index of the weapon. + * 0 = primary, 1 = secondary, 2 = handgun, -1 = other + * + * Argument: + * 0: Unit + * 1: Weapon + * + * Return value: + * Weapon index + * + * Public: No + */ + #include "script_component.hpp" + + EXPLODE_2_PVT(_this,_unit,_weapon); + +if (_weapon == "") exitWith {-1}; + +[ + primaryWeapon _unit, + secondaryWeapon _unit, + handgunWeapon _unit +] find _weapon diff --git a/addons/common/functions/fnc_loadSettingsFromProfile.sqf b/addons/common/functions/fnc_loadSettingsFromProfile.sqf new file mode 100644 index 0000000000..1e8e9001aa --- /dev/null +++ b/addons/common/functions/fnc_loadSettingsFromProfile.sqf @@ -0,0 +1,37 @@ +/* + * Author: CAA-Picard + * Load the user setable settings from the user profile. + * Config < Server UserConfig < Mission Config < Client settings + * + * Arguments: + * None + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" + +// Iterate through settings +{ + _name = _x select 0; + _isClientSetable = _x select 2; + _isForced = _x select 6; + + // If setting is user setable + if (_isClientSetable) then { + // If setting is not forced + if !(_isForced) then { + _profileValue = profileNamespace getvariable _name; + // If the setting is stored on the profile + if !(isNil "_profileValue") then { + // If the profile variable has the correct type + if (typeName _profileValue == typeName (missionNamespace getvariable _name)) then { + // Load the setting from the profile + missionNamespace setvariable [_name, _profileValue]; + }; + }; + }; + }; +} forEach GVAR(settings); diff --git a/addons/common/functions/fnc_loadSettingsOnServer.sqf b/addons/common/functions/fnc_loadSettingsOnServer.sqf new file mode 100644 index 0000000000..20a7e1c40f --- /dev/null +++ b/addons/common/functions/fnc_loadSettingsOnServer.sqf @@ -0,0 +1,69 @@ +/* + * Author: CAA-Picard + * Load the parameters on the server. + * Config < Server UserConfig < Mission Config + * + * Arguments: + * None + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" + +GVAR(settings) = []; + +// Load settings from main config +_countOptions = count (configFile >> "ACE_Settings"); +for "_index" from 0 to (_countOptions - 1) do { + _optionEntry = (configFile >> "ACE_Settings") select _index; + + [_optionEntry] call FUNC(setSettingFromConfig); +}; +// Check if all settings should be forced +if (GVAR(forceAllSettings)) then { + { + _x set [6, true]; + } forEach GVAR(settings); +}; + +// @todo +// Load settings from server userconfig only if the ACE_ServerSettings is loaded +/*if (isClass (configFile >> "CfgPatches" >> "ACE_ServerSettings")) then { + DFUNC(serverUserConfig) = compile preprocessFileLineNumbers "\userconfig\ACE\ACE_Settings.hpp"; + if !(isNil DFUNC(serverUserConfig)) then { + [] call FUNC(serverUserConfig); + }; + // Check if all settings should be forced + if (GVAR(forceAllSettings)) then { + { + if !(missionNamespace getVariable format ["%1_forced", _x]) then { + missionNamespace setVariable format ["%1_forced", _x, true]; + publicVariable format ["%1_forced", _name]; + }; + } forEach GVAR(settingsList); + }; +};*/ + +// Load settings from mission config +_countOptions = count (missionConfigFile >> "ACE_Settings"); +for "_index" from 0 to (_countOptions - 1) do { + _optionEntry = (missionConfigFile >> "ACE_Settings") select _index; + + [_optionEntry] call FUNC(setSettingFromConfig); +}; +// Check if all settings should be forced +if (GVAR(forceAllSettings)) then { + { + _x set [6, true]; + } forEach GVAR(settings); +}; + +// Publish all settings data +publicVariable QGVAR(settings); +// Publish all setting values +{ + publicVariable (_x select 0); +} forEach GVAR(settings); diff --git a/addons/common/functions/fnc_readBooleanParameterFromModule.sqf b/addons/common/functions/fnc_readBooleanParameterFromModule.sqf deleted file mode 100644 index 9ee2faa001..0000000000 --- a/addons/common/functions/fnc_readBooleanParameterFromModule.sqf +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Author: CAA-Picard - * - * Reads a boolean value from a module, sets de ACE_Parameter. Logs if parameters are missing in the module. - * - * Arguments: - * 0: Module (Object) - * 1: ACE_Parameter name (string) - * 2: Module parameter name (string) - * - * Return Value: - * None - */ -#include "script_component.hpp" - - private ["_logic", "_parameterName", "_moduleParameterName"]; - -_logic = _this select 0; -_parameterName = _this select 1; -_moduleParameterName = _this select 2; - -// Check if the parameter is defined in the module -if (isNil {_logic getVariable _moduleParameterName}) exitWith { - diag_log text format["[ACE]: Warning in %1 module: %2 parameter is missing. Probably an obsolete version of the module is used in the mission.", typeOf _logic, _moduleParameterName]; -}; - -// Set the parameter -[_parameterName , if (_logic getVariable _moduleParameterName) then {1} else {0}] call FUNC(setParameter); diff --git a/addons/common/functions/fnc_readNumericParameterFromModule.sqf b/addons/common/functions/fnc_readNumericParameterFromModule.sqf deleted file mode 100644 index a9c35f5b46..0000000000 --- a/addons/common/functions/fnc_readNumericParameterFromModule.sqf +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Author: CAA-Picard - * - * Reads a numeric value from a module, sets de ACE_Parameter. Logs if parameters are missing in the module. - * - * Arguments: - * 0: Module (Object) - * 1: ACE_Parameter name (string) - * 2: Module parameter name (string) - * - * Return Value: - * None - */ -#include "script_component.hpp" - - private ["_logic", "_parameterName", "_moduleParameterName", "_value"]; - -_logic = _this select 0; -_parameterName = _this select 1; -_moduleParameterName = _this select 2; - -// Check if the parameter is defined in the module -if (isNil {_logic getVariable _moduleParameterName}) exitWith { - diag_log text format["[ACE]: Warning in %1 module: %2 parameter is missing. Probably an obsolete version of the module is used in the mission.", typeOf _logic, _moduleParameterName] -}; - -// Check if the value is defined as string for backward compatibility -_value = _logic getVariable _moduleParameterName; -if (typeName _value == "STRING") then { - _value = parseNumber _value; -}; - -// Set the parameter -[_parameterName, _value] call FUNC(setParameter); diff --git a/addons/common/functions/fnc_readSettingFromModule.sqf b/addons/common/functions/fnc_readSettingFromModule.sqf new file mode 100644 index 0000000000..0f3ab447b1 --- /dev/null +++ b/addons/common/functions/fnc_readSettingFromModule.sqf @@ -0,0 +1,27 @@ +/* + * Author: CAA-Picard + * + * Reads a setting value from a module, set it and force it. Logs if the setting is missing from the module. + * Must be called on the server, effect is global. + * + * Arguments: + * 0: Module (Object) + * 1: ACE_Parameter name (string) + * 2: Module parameter name (string) + * + * Return Value: + * None + */ +#include "script_component.hpp" + +if !(isServer) exitWith {}; + +EXPLODE_3_PVT(_this,_logic,_settingName,_moduleVariable); + +// Check if the parameter is defined in the module +if (isNil {_logic getVariable _moduleVariable}) exitWith { + diag_log text format["[ACE]: Warning in %1 module: %2 setting is missing. Probably an obsolete version of the module is used in the mission.", typeOf _logic, _moduleVariable]; +}; + +// Set the setting globally and force it +[_settingName, _logic getVariable _moduleVariable, true, true] call FUNC(setSetting); diff --git a/addons/common/functions/fnc_setSetting.sqf b/addons/common/functions/fnc_setSetting.sqf new file mode 100644 index 0000000000..ae4b1d6655 --- /dev/null +++ b/addons/common/functions/fnc_setSetting.sqf @@ -0,0 +1,78 @@ +/* + * Author: CAA-Picard + * Change the value of an existing setting if it was not previously forced. Force if neccesary. + * If executed on clients it has local effect. + * If executed on server it can have global effect if the last parameter is set to true. + * + * Arguments: + * 0: Setting name (String) + * 1: Value (Any) + * 2: Force it? (Bool) (Optional) + * 3: Broadcast the change to all clients (Bool) (Optional) + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" + +private ["_name","_value"]; +_name = _this select 0; +_value = _this select 1; + +private ["_force"]; +_force = false; +if (count _this > 2) then { + _force = _this select 2; +}; + +_settingData = [_name] call FUNC(getSettingData); + +// Exit if the setting does not exist +if (count _settingData == 0) exitWith {}; + +// Exit if the setting is already forced +if (_settingData select 6) exitWith {}; + +// If the type is not equal, try to cast it +_failed = false; +if ((typeName _value) != (_settingData select 1)) then { + _failed = true; + if ((_settingData select 1) == "BOOL" and (typeName _value) == "SCALAR") then { + // If value is not 0 or 1 consider it invalid and don't set anything + if (_value == 0) then { + _value = false; + _failed = false; + }; + if (_value == 1) then { + _value = true; + _failed = false; + }; + }; + if ((_settingData select 1) == "COLOR" and (typeName _value) == "ARRAY") then { + _failed = false; + }; +}; +if (_failed) exitWith {}; + +// Force it if it was required +_settingData set [6, _force]; + +// Exit if the value didn't change +if (_value isEqualTo (missionNamespace getVariable _name)) exitWith {}; + +// Update the variable +TRACE_2("Variable Updated",_name,_value); +missionNamespace setVariable [_name, _value]; + +if (isServer && {count _this > 3} && {_this select 3}) then { + // Publicize the new value + publicVariable _name; + + // Raise event globally, this publicizes eventual changes in _force status so clients can update it locally + ["SettingChanged", [_name, _value, _force]] call FUNC(globalEvent); +} else { + // Raise event locally + ["SettingChanged", [_name, _value, _force]] call FUNC(localEvent); +}; diff --git a/addons/common/functions/fnc_setSettingFromConfig.sqf b/addons/common/functions/fnc_setSettingFromConfig.sqf new file mode 100644 index 0000000000..4151f3e0e4 --- /dev/null +++ b/addons/common/functions/fnc_setSettingFromConfig.sqf @@ -0,0 +1,102 @@ +/* + * Author: CAA-Picard + * Load a setting from config if it was not previosuly forced. Force if neccesary. + * + * Arguments: + * 0: Config entry (config entry) + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" + +EXPLODE_1_PVT(_this,_optionEntry); + +_fnc_getValueWithType = { + EXPLODE_2_PVT(_this,_optionEntry,_typeName); + + _value = getNumber (_optionEntry >> "value"); + TRACE_3("_fnc_getValueWithType:", configName _optionEntry, _typeName, _value); + if (_typeName == "BOOL") exitWith { + _value > 0 + }; + if (_typeName == "STRING") exitWith { + getText (_optionEntry >> "value") + }; + if (_typeName == "ARRAY") exitWith { + getArray (_optionEntry >> "value") + }; + if (_typeName == "COLOR") exitWith { + getArray (_optionEntry >> "value") + }; + _value +}; + +_name = configName _optionEntry; + +// Check if the variable is already defined +if (isNil _name) then { + // That setting was not loaded yet + + // Get type from config + _typeName = getText (_optionEntry >> "typeName"); + if (_typeName == "") then { + _typeName = "SCALAR"; + }; + + // Read entry and cast it to the correct type + _value = [_optionEntry, _typeName] call _fnc_getValueWithType; + + // Init the variable + missionNamespace setVariable [_name, _value]; + + // Add the setting to a list on the server + // Set the variable to not forced + /*_settingData = [ + _name, + _typeName, + _isClientSetable, + _localizedName, + _localizedDescription, + _possibleValues, + _isForced, + _defaultValue + ];*/ + _settingData = [ + _name, + _typeName, + (getNumber (_optionEntry >> "isClientSetable")) > 0, + getText (_optionEntry >> "displayName"), + getText (_optionEntry >> "description"), + getArray (_optionEntry >> "values"), + getNumber (_optionEntry >> "force") > 0, + _value + ]; + + GVAR(settings) pushBack _settingData; + +} else { + // The setting already exists. + + // Check if it's already forced and quit + _settingData = [_name] call FUNC(getSettingData); + if (_settingData select 6) exitWith {}; + + // The setting is not forced, so update the value + + // Get the type from the existing variable + _typeName = _settingData select 1; + + // Read entry and cast it to the correct type + _value = [_optionEntry, _typeName] call _fnc_getValueWithType; + + // Update the variable + missionNamespace setVariable [_name, _value]; + + // Force the setting if requested + if (getNumber (_optionEntry >> "force") > 0) then { + _settingData set [6, true]; + }; +}; diff --git a/addons/common/functions/fnc_setVariablePublic.sqf b/addons/common/functions/fnc_setVariablePublic.sqf new file mode 100644 index 0000000000..81093a2679 --- /dev/null +++ b/addons/common/functions/fnc_setVariablePublic.sqf @@ -0,0 +1,59 @@ +/* + * Author: commy2 + * + * Sets a public variable, but wait a certain amount of time to transfer the value over the network. Changing the value by calling this function again resets the windup timer. + * + * Argument: + * 0: Object the variable should be assigned to (Object) + * 1: Name of the variable (String) + * 2: Value of the variable (Any) + * 3: Windup time (Number, optional. Default: 1) + * + * Return value: + * Nothing. + */ +#include "script_component.hpp" + +private ["_object", "_varName", "_value", "_sync"]; + +_object = _this select 0; +_varName = _this select 1; +_value = _this select 2; +_sync = _this select 3; + +if (isNil "_sync") then { + _sync = 1; +}; + +// set value locally +_object setVariable [_varName, _value]; + +// "duh" +if (!isMultiplayer) exitWith {}; + +// generate stacked eventhandler id +private "_idName"; +_idName = format ["ACE_setVariablePublic_%1", _varName]; + +// exit now if an eh for that variable already exists +private "_allIdNames"; +_allIdNames = [GETMVAR(BIS_stackedEventHandlers_onEachFrame,[]), {_this select 0}] call FUNC(map); + +if (_idName in _allIdNames) exitWith {}; + +// when to push the value +private "_syncTime"; +_syncTime = diag_tickTime + _sync; + +// add eventhandler +[_idName, "onEachFrame", { + // wait to sync the variable + if (diag_tickTime > _this select 2) then { + // set value public + (_this select 0) setVariable [_this select 1, (_this select 0) getVariable (_this select 1), true]; + + // remove eventhandler + [_this select 3, "onEachFrame"] call BIS_fnc_removeStackedEventHandler + }; +}, [_object, _varName, _syncTime, _idName]] call BIS_fnc_addStackedEventHandler; +nil diff --git a/addons/common/functions/fnc_throttledPublicVariable.sqf b/addons/common/functions/fnc_throttledPublicVariable.sqf new file mode 100644 index 0000000000..6953d39fb5 --- /dev/null +++ b/addons/common/functions/fnc_throttledPublicVariable.sqf @@ -0,0 +1,49 @@ +/* + * Author: CAA-Picard + * Schedules the publishment of an object variable to reduce network overhead + * + * Arguments: + * 0: Unit . + * 1: Variable name + * 2: Maximum delay + * + * Return Value: + * None + * + * Example: + * None + * + * Public: No + */ +#include "script_component.hpp" + +EXPLODE_3_PVT(_this,_unit,_varName,_maxDelay); + +// Create the publish scheduler PFH the first time +if (isNil QGVAR(publishSchedId)) then { + + GVAR(publishVarNames) = []; + GVAR(publishNextTime) = 1e7; + + GVAR(publishSchedId) = [{ + + if (diag_tickTime > GVAR(publishNextTime)) then { + { + EXPLODE_2_PVT(_x,_unit,_varName); + _unit setVariable [_varName, (_unit getVariable _varName), true]; + } forEach GVAR(publishVarNames); + + GVAR(publishVarNames) = []; + GVAR(publishNextTime) = 1e7; + }; + }, 0, []] call cba_fnc_addPerFrameHandler; +}; + +// If the variable is not on the list +if (GVAR(publishVarNames) find [_unit,_varName] == -1) exitWith { + GVAR(publishVarNames) pushBack [_unit,_varName]; + GVAR(publishNextTime) = GVAR(publishNextTime) min (diag_tickTime + _maxDelay); +}; + +// If the variable is on the list +GVAR(publishNextTime) = GVAR(publishNextTime) min (diag_tickTime + _maxDelay); \ No newline at end of file diff --git a/addons/common/scripts/readParameters.sqf b/addons/common/scripts/readParameters.sqf deleted file mode 100644 index 3b17ea7f1f..0000000000 --- a/addons/common/scripts/readParameters.sqf +++ /dev/null @@ -1,55 +0,0 @@ -// by CAA-Picard -#include "script_component.hpp" - -// Read ACE_Parameters from config and set them on the mission namespace -_config = configFile >> "ACE_Parameters_Numeric"; -_count = count _config; -for "_index" from 0 to (_count - 1) do { - _x = _config select _index; - - _name = configName _x; - _value = _x call bis_fnc_getcfgdata; - [_name, _value] call FUNC(setParameter); -}; - -_config = configFile >> "ACE_Parameters_Boolean"; -_count = count _config; -for "_index" from 0 to (_count - 1) do { - _x = _config select _index; - - _name = configName _x; - _value = _x call bis_fnc_getcfgdata; - [_name, _value > 0] call FUNC(setParameter); -}; - - -// Read ACE_Parameters from mission and set them on the mission namespace, replacing defaults if necesary -_config = missionConfigFile >> "ACE_Parameters"; -_count = count _config; -for "_index" from 0 to (_count - 1) do { - _x = _config select _index; - - _name = configName _x; - _value = _x call bis_fnc_getcfgdata; - [_name, _value] call FUNC(setParameter); -}; - -_config = missionConfigFile >> "ACE_Parameters_Numeric"; -_count = count _config; -for "_index" from 0 to (_count - 1) do { - _x = _config select _index; - - _name = configName _x; - _value = _x call bis_fnc_getcfgdata; - [_name, _value] call FUNC(setParameter); -}; - -_config = missionConfigFile >> "ACE_Parameters_Boolean"; -_count = count _config; -for "_index" from 0 to (_count - 1) do { - _x = _config select _index; - - _name = configName _x; - _value = _x call bis_fnc_getcfgdata; - [_name, _value > 0] call FUNC(setParameter); -}; diff --git a/addons/explosives/config.cpp b/addons/explosives/config.cpp index 5f2264c620..da95d45e7e 100644 --- a/addons/explosives/config.cpp +++ b/addons/explosives/config.cpp @@ -39,7 +39,13 @@ class CfgMineTriggers { }; }; -class ACE_Parameters_Boolean { - GVAR(RequireSpecialist) = 0; - GVAR(PunishNonSpecialists) = 1; +class ACE_Settings { + class GVAR(RequireSpecialist) { + value = 0; + typeName = "BOOL"; + }; + class GVAR(PunishNonSpecialists) { + value = 1; + typeName = "BOOL"; + }; }; diff --git a/addons/explosives/functions/fnc_module.sqf b/addons/explosives/functions/fnc_module.sqf index 1e1e9d3e62..432671b551 100644 --- a/addons/explosives/functions/fnc_module.sqf +++ b/addons/explosives/functions/fnc_module.sqf @@ -20,7 +20,7 @@ _activated = _this select 2; if !(_activated) exitWith {}; -[_logic, QGVAR(RequireSpecialist), "RequireSpecialist" ] call EFUNC(Common,readBooleanParameterFromModule); -[_logic, QGVAR(PunishNonSpecialists), "PunishNonSpecialists" ] call EFUNC(Common,readBooleanParameterFromModule); +[_logic, QGVAR(RequireSpecialist), "RequireSpecialist" ] call EFUNC(Common,readSettingFromModule); +[_logic, QGVAR(PunishNonSpecialists), "PunishNonSpecialists" ] call EFUNC(Common,readSettingFromModule); diag_log text "[ACE]: Explosive Module Initialized."; diff --git a/addons/fcs/CfgAmmo.hpp b/addons/fcs/CfgAmmo.hpp new file mode 100644 index 0000000000..25d02399d5 --- /dev/null +++ b/addons/fcs/CfgAmmo.hpp @@ -0,0 +1,32 @@ + +class CfgAmmo { + class B_35mm_AA; + class ACE_B_35mm_ABM: B_35mm_AA { + GVAR(Airburst) = 1; + deflecting = 0; + }; + + class B_35mm_AA_Tracer_Red; + class ACE_B_35mm_ABM_Tracer_Red: B_35mm_AA_Tracer_Red { + GVAR(Airburst) = 1; + deflecting = 0; + }; + + class B_35mm_AA_Tracer_Green; + class ACE_B_35mm_ABM_Tracer_Green: B_35mm_AA_Tracer_Green { + GVAR(Airburst) = 1; + deflecting = 0; + }; + + class B_35mm_AA_Tracer_Yellow; + class ACE_B_35mm_ABM_Tracer_Yellow: B_35mm_AA_Tracer_Yellow { + GVAR(Airburst) = 1; + deflecting = 0; + }; + + class ACE_B_35mm_ABM_Helper: B_35mm_AA { + indirectHitRange = 6; + simulation = "shotRocket"; + timeToLive = 0; + }; +}; diff --git a/addons/fcs/CfgEventHandlers.hpp b/addons/fcs/CfgEventHandlers.hpp index 0d507b359d..961a05b27d 100644 --- a/addons/fcs/CfgEventHandlers.hpp +++ b/addons/fcs/CfgEventHandlers.hpp @@ -1,19 +1,95 @@ class Extended_PreInit_EventHandlers { class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_preInit) ); + init = QUOTE(call COMPILE_FILE(XEH_preInit)); }; }; class Extended_PostInit_EventHandlers { class ADDON { - clientInit = QUOTE(call COMPILE_FILE(XEH_clientInit) ); + clientInit = QUOTE(call COMPILE_FILE(XEH_clientInit)); }; }; class Extended_Init_EventHandlers { - class AllVehicles { + class Tank { class ADDON { - clientInit = QUOTE(_this call FUNC(vehicleInit)); + serverInit = QUOTE(_this call FUNC(vehicleInit)); + }; + }; + class Car { + class ADDON { + serverInit = QUOTE(_this call FUNC(vehicleInit)); + }; + }; + class Helicopter { + class ADDON { + serverInit = QUOTE(_this call FUNC(vehicleInit)); + }; + }; + class Plane { + class ADDON { + serverInit = QUOTE(_this call FUNC(vehicleInit)); + }; + }; + class Ship_F { + class ADDON { + serverInit = QUOTE(_this call FUNC(vehicleInit)); + }; + }; +}; + +class Extended_Respawn_EventHandlers { + class Tank { + class ADDON { + respawn = QUOTE(_this call FUNC(vehicleInit)); + }; + }; + class Car { + class ADDON { + respawn = QUOTE(_this call FUNC(vehicleInit)); + }; + }; + class Helicopter { + class ADDON { + respawn = QUOTE(_this call FUNC(vehicleInit)); + }; + }; + class Plane { + class ADDON { + respawn = QUOTE(_this call FUNC(vehicleInit)); + }; + }; + class Ship_F { + class ADDON { + respawn = QUOTE(_this call FUNC(vehicleInit)); + }; + }; +}; + +class Extended_FiredBIS_EventHandlers { + class Tank { + class ADDON { + firedBIS = QUOTE(_this call FUNC(firedEH)); + }; + }; + class Car { + class ADDON { + firedBIS = QUOTE(_this call FUNC(firedEH)); + }; + }; + class Helicopter { + class ADDON { + firedBIS = QUOTE(_this call FUNC(firedEH)); + }; + }; + class Plane { + class ADDON { + firedBIS = QUOTE(_this call FUNC(firedEH)); + }; + }; + class Ship_F { + class ADDON { + firedBIS = QUOTE(_this call FUNC(firedEH)); }; }; }; diff --git a/addons/fcs/CfgMagazines.hpp b/addons/fcs/CfgMagazines.hpp new file mode 100644 index 0000000000..dc48e21411 --- /dev/null +++ b/addons/fcs/CfgMagazines.hpp @@ -0,0 +1,34 @@ + +class CfgMagazines { + class 680Rnd_35mm_AA_shells; + class ACE_120Rnd_35mm_ABM_shells: 680Rnd_35mm_AA_shells { + ammo = "ACE_B_35mm_ABM"; + count = 120; + displayName = "35mm ABM Shells"; + displayNameShort = "35mm ABM"; + }; + + class 680Rnd_35mm_AA_shells_Tracer_Red; + class ACE_120Rnd_35mm_ABM_shells_Tracer_Red: 680Rnd_35mm_AA_shells_Tracer_Red { + ammo = "ACE_B_35mm_ABM_Tracer_Red"; + count = 120; + displayName = "35mm ABM Shells"; + displayNameShort = "35mm ABM-T"; + }; + + class 680Rnd_35mm_AA_shells_Tracer_Green; + class ACE_120Rnd_35mm_ABM_shells_Tracer_Green: 680Rnd_35mm_AA_shells_Tracer_Green { + ammo = "ACE_B_35mm_ABM_Tracer_Green"; + count = 120; + displayName = "35mm ABM Shells"; + displayNameShort = "35mm ABM-T"; + }; + + class 680Rnd_35mm_AA_shells_Tracer_Yellow; + class ACE_120Rnd_35mm_ABM_shells_Tracer_Yellow: 680Rnd_35mm_AA_shells_Tracer_Yellow { + ammo = "ACE_B_35mm_ABM_Tracer_Yellow"; + count = 120; + displayName = "35mm ABM Shells"; + displayNameShort = "35mm ABM-T"; + }; +}; diff --git a/addons/fcs/CfgOptics.hpp b/addons/fcs/CfgOptics.hpp index 01b997b0ee..3c17e760f0 100644 --- a/addons/fcs/CfgOptics.hpp +++ b/addons/fcs/CfgOptics.hpp @@ -1,3 +1,4 @@ + #define MACRO_RANGEFINDER \ class CA_Distance; \ class ACE_CA_Distance: CA_Distance { \ @@ -17,12 +18,12 @@ class RscInGameUI { class RscUnitInfo; class RscUnitInfo_AH64D_gunner { onLoad = ""; - controls[] = {"CA_Distance", "ACE_CA_Distance"}; + controls[] = {"CA_Distance","ACE_CA_Distance"}; MACRO_RANGEFINDER }; class RscWeaponRangeFinder { onLoad = "uiNamespace setVariable ['ACE_dlgRangefinder', _this select 0]; ((_this select 0) displayCtrl 151) ctrlSetTextColor [0, 0, 0, 0];"; - controls[] = {"CA_Distance", "ACE_CA_Distance"}; + controls[] = {"CA_Distance","ACE_CA_Distance"}; MACRO_RANGEFINDER }; @@ -56,17 +57,17 @@ class RscInGameUI { }; class RscWeaponRangeFinderAbramsCom { onLoad = "uiNamespace setVariable ['ACE_dlgRangefinder', _this select 0]; ((_this select 0) displayCtrl 151) ctrlSetTextColor [0, 0, 0, 0];"; - controls[] = {"CA_Distance", "ACE_CA_Distance"}; + controls[] = {"CA_Distance","ACE_CA_Distance"}; MACRO_RANGEFINDER }; class RscWeaponRangeFinderAbramsGun { onLoad = "uiNamespace setVariable ['ACE_dlgRangefinder', _this select 0]; ((_this select 0) displayCtrl 151) ctrlSetTextColor [0, 0, 0, 0];"; - controls[] = {"CA_Distance", "ACE_CA_Distance"}; + controls[] = {"CA_Distance","ACE_CA_Distance"}; MACRO_RANGEFINDER }; class RscWeaponRangeFinderStrykerMGSGun { onLoad = "uiNamespace setVariable ['ACE_dlgRangefinder', _this select 0]; ((_this select 0) displayCtrl 151) ctrlSetTextColor [0, 0, 0, 0];"; - controls[] = {"CA_Distance", "ACE_CA_Distance"}; + controls[] = {"CA_Distance","ACE_CA_Distance"}; MACRO_RANGEFINDER }; class RscOptics_crows: RscUnitInfo { @@ -88,7 +89,7 @@ class RscInGameUI { class RscWeaponRangeZeroing: RscUnitInfo { onLoad = "uiNamespace setVariable ['ACE_dlgRangefinder', _this select 0]; ((_this select 0) displayCtrl 151) ctrlSetTextColor [0, 0, 0, 0]; [""onLoad"",_this,""RscUnitInfo"",'IGUI'] call compile preprocessfilelinenumbers ""A3\ui_f\scripts\initDisplay.sqf"""; - controls[] = {"CA_Zeroing", "CA_DistanceText", "CA_Distance", "ACE_CA_Distance", "ACE_Rangehelper"}; + controls[] = {"CA_Zeroing", "CA_DistanceText", "CA_Distance","ACE_CA_Distance", "ACE_Rangehelper"}; MACRO_RANGEFINDER }; class RscOptics_sos: RscUnitInfo { diff --git a/addons/fcs/CfgVehicles.hpp b/addons/fcs/CfgVehicles.hpp new file mode 100644 index 0000000000..4cc010f917 --- /dev/null +++ b/addons/fcs/CfgVehicles.hpp @@ -0,0 +1,518 @@ + +class CfgVehicles { + class All { + class Turrets; + }; + + class AllVehicles: All { + class NewTurret { + GVAR(Enabled) = 0; + GVAR(MinDistance) = 200; + GVAR(MaxDistance) = 9990; + GVAR(DistanceInterval) = 5; + class Turrets; + }; + class CargoTurret; + }; + + // LAND VEHICLES + class Land: AllVehicles {}; + + class LandVehicle: Land { + class CommanderOptics; + }; + + class Car: LandVehicle { + class ACE_SelfActions { + class ResetFCS { + displayName = $STR_ACE_FCS_ResetFCS; + enableInside = 1; + condition = QUOTE(call FUNC(canResetFCS)); + statement = QUOTE([ARR_2(_vehicle,[_player] call DEFUNC(common,getTurretIndex))] call DFUNC(reset);); + showDisabled = 0; + priority = 1; + icon = ""; + }; + }; + }; + + class Tank: LandVehicle { + class ACE_SelfActions { + class ResetFCS { + displayName = $STR_ACE_FCS_ResetFCS; + enableInside = 1; + condition = QUOTE(call FUNC(canResetFCS)); + statement = QUOTE([ARR_2(_vehicle,[_player] call DEFUNC(common,getTurretIndex))] call DFUNC(reset);); + showDisabled = 0; + priority = 1; + icon = ""; + }; + }; + class Turrets { + class MainTurret: NewTurret { + GVAR(Enabled) = 1; // all tracked vehicles get one by default + class Turrets { + class CommanderOptics; + }; + }; + }; + }; + + class Tank_F: Tank { + class Turrets { + class MainTurret: NewTurret { + GVAR(Enabled) = 1; // all tracked vehicles get one by default + class Turrets { + class CommanderOptics;//: CommanderOptics {}; + }; + }; + }; + }; + + class Car_F: Car { + class Turrets { + class MainTurret; + }; + }; + + class Wheeled_APC_F: Car_F { + class Turrets { + class MainTurret: NewTurret { + class Turrets { + class CommanderOptics;//: CommanderOptics {}; + }; + }; + }; + }; + + class MRAP_01_base_F: Car_F {}; + + class MRAP_01_gmg_base_F: MRAP_01_base_F { + /*class Turrets: Turrets { + class MainTurret: MainTurret {}; + };*/ + }; + + class MRAP_01_hmg_base_F: MRAP_01_gmg_base_F { + /*class Turrets: Turrets { + class MainTurret: MainTurret {}; + };*/ + }; + + class B_MRAP_01_F: MRAP_01_base_F { + class Turrets; + }; + + class MRAP_02_base_F: Car_F {}; + + class MRAP_02_hmg_base_F: MRAP_02_base_F { + /*class Turrets: Turrets { + class MainTurret: MainTurret {}; + };*/ + }; + + class MRAP_02_gmg_base_F: MRAP_02_hmg_base_F { + /*class Turrets: Turrets { + class MainTurret: MainTurret {}; + };*/ + }; + + class O_MRAP_02_F: MRAP_02_base_F { + class Turrets; + }; + + class MRAP_03_base_F: Car_F { + /*class Turrets: Turrets { + class CommanderTurret: MainTurret {}; + };*/ + }; + + class MRAP_03_hmg_base_F: MRAP_03_base_F { + /*class Turrets: Turrets { + class MainTurret: MainTurret {}; + class CommanderTurret: CommanderTurret {}; + };*/ + }; + + class MRAP_03_gmg_base_F: MRAP_03_hmg_base_F { + /*class Turrets: Turrets { + class MainTurret: MainTurret {}; + class CommanderTurret: CommanderTurret {}; + };*/ + }; + + class Offroad_01_base_F: Car_F {}; + + class Offroad_01_armed_base_F: Offroad_01_base_F { + /*class Turrets: Turrets { + class M2_Turret: MainTurret {}; + };*/ + }; + + class APC_Wheeled_01_base_F: Wheeled_APC_F { + /*class Turrets: Turrets { + class MainTurret: MainTurret { + class Turrets: Turrets { + class CommanderOptics: CommanderOptics {}; + }; + }; + };*/ + }; + + class B_APC_Wheeled_01_base_F: APC_Wheeled_01_base_F {}; + + class B_APC_Wheeled_01_cannon_F: B_APC_Wheeled_01_base_F { + class Turrets: Turrets { + class MainTurret: MainTurret { + GVAR(Enabled) = 1; + discreteDistance[] = {}; + discreteDistanceInitIndex = 0; + }; + }; + }; + + class APC_Wheeled_02_base_F: Wheeled_APC_F { + /*class Turrets: Turrets { + class MainTurret: MainTurret { + class Turrets; + }; + + class CommanderOptics: CommanderOptics {}; + };*/ + }; + + class APC_Wheeled_03_base_F: Wheeled_APC_F { + class Turrets: Turrets { + class MainTurret: MainTurret { + GVAR(Enabled) = 1; + discreteDistance[] = {}; + discreteDistanceInitIndex = 0; + + /*class Turrets: Turrets { + class CommanderOptics: CommanderOptics {}; + };*/ + }; + }; + }; + + class I_APC_Wheeled_03_base_F: APC_Wheeled_03_base_F {}; + + class I_APC_Wheeled_03_cannon_F: I_APC_Wheeled_03_base_F { + /*class Turrets: Turrets { + class MainTurret: MainTurret {}; + };*/ + }; + + class APC_Tracked_01_base_F: Tank_F { + /*class Turrets: Turrets { + class MainTurret: MainTurret { + class Turrets; + }; + };*/ + }; + + class B_APC_Tracked_01_base_F: APC_Tracked_01_base_F { + /*class Turrets: Turrets { + class MainTurret: MainTurret {}; + };*/ + }; + + class B_APC_Tracked_01_rcws_F: B_APC_Tracked_01_base_F { + class Turrets: Turrets { + class MainTurret: MainTurret { + GVAR(Enabled) = 0; + }; + class CommanderOptics: CommanderOptics {}; + }; + }; + + class B_APC_Tracked_01_CRV_F: B_APC_Tracked_01_base_F { + //GVAR(Enabled) = 0; @todo + }; + + class B_APC_Tracked_01_AA_F: B_APC_Tracked_01_base_F { + class Turrets: Turrets { + class MainTurret: MainTurret { + discreteDistance[] = {}; + discreteDistanceInitIndex = 0; + magazines[] += {"ACE_120Rnd_35mm_ABM_shells_Tracer_Red"}; + + /*class Turrets: Turrets { + class CommanderOptics: CommanderOptics {}; + };*/ + }; + }; + }; + + class APC_Tracked_02_base_F: Tank_F { + /*class Turrets: Turrets { + class MainTurret: MainTurret { + class Turrets: Turrets { + class CommanderOptics: CommanderOptics {}; + }; + }; + };*/ + }; + + class O_APC_Tracked_02_base_F: APC_Tracked_02_base_F {}; + + class O_APC_Tracked_02_cannon_F: O_APC_Tracked_02_base_F { + /*class Turrets: Turrets { + class MainTurret: MainTurret {}; + };*/ + }; + + class O_APC_Tracked_02_AA_F: O_APC_Tracked_02_base_F { + class Turrets: Turrets { + class MainTurret: MainTurret { + magazines[] += {"ACE_120Rnd_35mm_ABM_shells_Tracer_Green"}; + + /*class Turrets: Turrets { + class CommanderOptics: CommanderOptics {}; + };*/ + }; + }; + }; + + class APC_Tracked_03_base_F: Tank_F { + class Turrets: Turrets { + class MainTurret: MainTurret { + discreteDistance[] = {}; + discreteDistanceInitIndex = 0; + + /*class Turrets: Turrets { + class CommanderOptics: CommanderOptics {}; + };*/ + }; + }; + }; + + class MBT_01_base_F: Tank_F { + class Turrets: Turrets { + class MainTurret: MainTurret { + discreteDistance[] = {}; + discreteDistanceInitIndex = 0; + + /*class Turrets: Turrets { + class CommanderOptics: CommanderOptics {}; + };*/ + }; + }; + }; + + class B_MBT_01_base_F: MBT_01_base_F {}; + + class B_MBT_01_cannon_F: B_MBT_01_base_F {}; + + class MBT_01_arty_base_F: MBT_01_base_F { + class Turrets: Turrets { + class MainTurret: MainTurret { + GVAR(Enabled) = 0; + + /*class Turrets: Turrets { + class CommanderOptics: CommanderOptics {}; + };*/ + }; + }; + }; + + class MBT_01_mlrs_base_F: MBT_01_base_F { + class Turrets: Turrets { + class MainTurret: MainTurret { + GVAR(Enabled) = 0; + //class Turrets; + }; + }; + }; + + class MBT_02_base_F: Tank_F { + class Turrets: Turrets { + class MainTurret: MainTurret { + discreteDistance[] = {}; + discreteDistanceInitIndex = 0; + + /*class Turrets: Turrets { + class CommanderOptics: CommanderOptics {}; + };*/ + }; + }; + }; + + class MBT_02_arty_base_F: MBT_02_base_F { + class Turrets: Turrets { + class MainTurret: MainTurret { + GVAR(Enabled) = 0; + + /*class Turrets: Turrets { + class CommanderOptics: CommanderOptics {}; + };*/ + }; + }; + }; + + class MBT_03_base_F: Tank_F { + class Turrets: Turrets { + class MainTurret: MainTurret { + discreteDistance[] = {}; + discreteDistanceInitIndex = 0; + + /*class Turrets: Turrets { + class CommanderOptics: CommanderOptics {}; + };*/ + }; + }; + }; + + class B_MBT_01_TUSK_F: B_MBT_01_cannon_F { + class Turrets: Turrets { + class MainTurret: MainTurret { + discreteDistance[] = {}; + discreteDistanceInitIndex = 0; + + class Turrets: Turrets { + class CommanderOptics: CommanderOptics { + GVAR(Enabled) = 1; + }; + }; + }; + }; + }; + + // SHIPS + /*class Ship: AllVehicles { + class Turrets { + class MainTurret; + }; + }; + + class Ship_F: Ship {}; + + class Boat_F: Ship_F {}; + + class Boat_Armed_01_base_F: Boat_F { + class Turrets: Turrets { + class FrontTurret; + class RearTurret: FrontTurret {}; + }; + };*/ + + /*class Boat_Armed_01_minigun_base_F: Boat_Armed_01_base_F { + class Turrets: Turrets { + class FrontTurret: FrontTurret {}; + class RearTurret: RearTurret {}; + }; + };*/ + + // AIR VEHICLES + class Air: AllVehicles {}; + + class Helicopter: Air { + class Turrets { + class MainTurret; + }; + }; + + class Plane: Air {}; + + class Helicopter_Base_F: Helicopter { + class Turrets: Turrets { + class CopilotTurret; + }; + }; + + class Helicopter_Base_H: Helicopter_Base_F { + class Turrets: Turrets { + class CopilotTurret; + }; + }; + + class Heli_Light_01_base_F: Helicopter_Base_H { + /*class Turrets: Turrets { + class CopilotTurret: CopilotTurret {}; + };*/ + }; + + class Heli_Light_01_unarmed_base_F: Heli_Light_01_base_F {}; + + class B_Heli_Light_01_F: Heli_Light_01_unarmed_base_F { + /*class Turrets: Turrets { + class CopilotTurret: CopilotTurret {}; + };*/ + }; + + class Heli_Light_01_armed_base_F: Heli_Light_01_base_F { + /*class Turrets: Turrets { + class CopilotTurret: CopilotTurret {}; + };*/ + }; + + class Heli_Light_02_base_F: Helicopter_Base_H { + /*class Turrets: Turrets { + class CopilotTurret: CopilotTurret {}; + };*/ + }; + + class Plane_Base_F: Plane { + class Turrets { + class CopilotTurret; + }; + }; + + class Heli_Attack_01_base_F: Helicopter_Base_F { + class Turrets: Turrets { + class MainTurret: MainTurret { + GVAR(Enabled) = 1; + discreteDistance[] = {}; + discreteDistanceInitIndex = 0; + }; + }; + }; + + class Heli_Attack_02_base_F: Helicopter_Base_F { + class Turrets: Turrets { + class MainTurret: MainTurret { + GVAR(Enabled) = 1; + discreteDistance[] = {}; + discreteDistanceInitIndex = 0; + }; + }; + }; + + class Heli_Transport_01_base_F: Helicopter_Base_H { + /*class Turrets: Turrets { + class CopilotTurret: CopilotTurret {}; + class MainTurret: MainTurret {}; + class RightDoorGun: MainTurret {}; + };*/ + }; + + class Heli_Transport_02_base_F: Helicopter_Base_H { + /*class Turrets: Turrets { + class CopilotTurret: CopilotTurret {}; + };*/ + }; + + class I_Heli_light_03_base_F: Helicopter_Base_F { + /*class Turrets: Turrets { + class MainTurret: MainTurret {}; + };*/ + }; + + class I_Heli_light_03_F: I_Heli_light_03_base_F { + /*class Turrets: Turrets { + class MainTurret: MainTurret {}; + };*/ + }; + + class Plane_CAS_01_base_F: Plane_Base_F { + class Turrets; + }; + + class Plane_CAS_02_base_F: Plane_Base_F { + class Turrets; + }; + + class Plane_Fighter_03_base_F: Plane_Base_F { + class Turrets; + }; +}; diff --git a/addons/fcs/CfgWeapons.hpp b/addons/fcs/CfgWeapons.hpp new file mode 100644 index 0000000000..ec72bc6f44 --- /dev/null +++ b/addons/fcs/CfgWeapons.hpp @@ -0,0 +1,24 @@ + +class CfgWeapons { + // disable locking, so it doesn't interfere with our system + class CannonCore; + class cannon_120mm: CannonCore { + canLock = 0; + ballisticsComputer = 0; + }; + class autocannon_Base_F: CannonCore { + canLock = 0; + ballisticsComputer = 0; + }; + class autocannon_35mm: CannonCore { + canLock = 0; + ballisticsComputer = 0; + magazines[] += {"ACE_120Rnd_35mm_ABM_shells","ACE_120Rnd_35mm_ABM_shells_Tracer_Red","ACE_120Rnd_35mm_ABM_shells_Tracer_Green","ACE_120Rnd_35mm_ABM_shells_Tracer_Yellow"}; + }; + + // fix mrco having an invisible rangefinder + class ItemCore; + class optic_MRCO: ItemCore { + weaponInfoType = "RscWeaponZeroing"; + }; +}; diff --git a/addons/fcs/XEH_clientInit.sqf b/addons/fcs/XEH_clientInit.sqf index 66720ae44a..17faa70f17 100644 --- a/addons/fcs/XEH_clientInit.sqf +++ b/addons/fcs/XEH_clientInit.sqf @@ -1,79 +1,7 @@ #include "script_component.hpp" -GVAR(enabled) = True; +GVAR(enabled) = false; GVAR(time) = 0; GVAR(position) = [0,0,0]; -// Add keybinds -["ACE3", - localize "STR_ACE_FCS_LaseTarget", - { - // Conditions: canInteract - _exceptions = []; - if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; - // Conditions: specific - if !(!GVAR(enabled) && {call FUNC(canUseRangefinder) || FUNC(canUseFCS)}) exitWith {false}; - - // Statement - [vehicle ACE_player] call FUNC(keyDown); - // Return false so it doesn't block the rest weapon action - false - }, - [15, [false, false, false]], - false, - "keydown" -] call cba_fnc_registerKeybind; - -["ACE3", - localize "STR_ACE_FCS_LaseTarget", - { - // Conditions: canInteract - _exceptions = []; - if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; - // Conditions: specific - if !(GVAR(enabled) && FUNC(canUseFCS)) exitWith {false}; - - // Statement - [vehicle ACE_player] call FUNC(keyUp); - false - }, - [15, [false, false, false]], - false, - "keyup" -] call cba_fnc_registerKeybind; - -["ACE3", - localize "STR_ACE_FCS_AdjustRangeUp", - { - // Conditions: canInteract - _exceptions = []; - if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; - // Conditions: specific - if !(call FUNC(canUseRangefinder) || FUNC(canUseFCS)) exitWith {false}; - - // Statement - [vehicle ACE_player, 50] call FUNC(adjustRange); - true - }, - [201, [false, false, false]], - false, - "keydown" -] call cba_fnc_registerKeybind; - -["ACE3", - localize "STR_ACE_FCS_AdjustRangeDown", - { - // Conditions: canInteract - _exceptions = []; - if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; - // Conditions: specific - if !(call FUNC(canUseRangefinder) || FUNC(canUseFCS)) exitWith {false}; - - // Statement - [vehicle ACE_player, -50] call FUNC(adjustRange); - true - }, - [209, [false, false, false]], - false, - "keydown" -] call cba_fnc_registerKeybind; +#include "initKeybinds.sqf" diff --git a/addons/fcs/XEH_preInit.sqf b/addons/fcs/XEH_preInit.sqf index 18729ca54f..78a2fd091c 100644 --- a/addons/fcs/XEH_preInit.sqf +++ b/addons/fcs/XEH_preInit.sqf @@ -9,6 +9,7 @@ PREP(canUseRangefinder); PREP(firedEH); PREP(getAngle); PREP(getRange); +PREP(handleAirBurstAmmunitionPFH); PREP(keyDown); PREP(keyUp); PREP(reset); diff --git a/addons/fcs/config.cpp b/addons/fcs/config.cpp index e1e8ac8901..20ae063c70 100644 --- a/addons/fcs/config.cpp +++ b/addons/fcs/config.cpp @@ -6,7 +6,7 @@ class CfgPatches { weapons[] = {}; requiredVersion = REQUIRED_VERSION; requiredAddons[] = {ace_common, ace_interaction}; - author[] = {"KoffeinFlummi","BadGuy (simon84)"}; + author[] = {"KoffeinFlummi","BadGuy (simon84)","commy2"}; authorUrl = "https://github.com/KoffeinFlummi/"; VERSION_CONFIG; }; @@ -14,329 +14,9 @@ class CfgPatches { #include "CfgEventHandlers.hpp" -class CfgVehicles { - class All { - class Turrets; - }; +#include "CfgAmmo.hpp" +#include "CfgMagazines.hpp" +#include "CfgVehicles.hpp" +#include "CfgWeapons.hpp" - class AllVehicles: All { - GVAR(Enabled) = 0; - GVAR(MinDistance) = 200; - GVAR(MaxDistance) = 9990; - GVAR(DistanceInterval) = 5; - class NewTurret { - class Turrets; - }; - class CargoTurret; - }; - - class Land: AllVehicles {}; - - class LandVehicle: Land { - class CommanderOptics; - }; - - // WHEELED - class Car: LandVehicle { - class ACE_SelfActions { - class ResetFCS { - displayName = $STR_ACE_FCS_ResetFCS; - enableInside = 1; - condition = QUOTE(call FUNC(canResetFCS)); - statement = QUOTE([vehicle _player] call FUNC(reset);); - showDisabled = 0; - priority = 1; - icon = ""; - }; - }; - }; - - class Car_F: Car { - class Turrets { - class MainTurret; - }; - }; - - class Wheeled_APC_F: Car_F { - class Turrets { - class MainTurret: NewTurret { - class Turrets { - class CommanderOptics; - }; - }; - }; - }; - - class APC_Wheeled_01_base_F: Wheeled_APC_F {}; - class B_APC_Wheeled_01_base_F: APC_Wheeled_01_base_F {}; - class B_APC_Wheeled_01_cannon_F: B_APC_Wheeled_01_base_F { - GVAR(Enabled) = 1; - class Turrets: Turrets { - class MainTurret: MainTurret { - discreteDistance[] = {}; - discreteDistanceInitIndex = 0; - }; - }; - }; - - class APC_Wheeled_03_base_F: Wheeled_APC_F { - GVAR(Enabled) = 1; - class Turrets: Turrets { - class MainTurret: MainTurret { - discreteDistance[] = {}; - discreteDistanceInitIndex = 0; - }; - }; - }; - - // TRACKED - class Tank: LandVehicle { - GVAR(Enabled) = 1; // all tracked vehicles get one by default - class ACE_SelfActions { - class ResetFCS { - displayName = $STR_ACE_FCS_ResetFCS; - enableInside = 1; - condition = QUOTE(call FUNC(canResetFCS)); - statement = QUOTE([vehicle _player] call FUNC(reset);); - showDisabled = 0; - priority = 1; - icon = ""; - }; - }; - class Turrets { - class MainTurret: NewTurret { - class Turrets { - class CommanderOptics; - }; - }; - }; - }; - - class Tank_F: Tank { - class Turrets { - class MainTurret: NewTurret { - class Turrets { - class CommanderOptics; - }; - }; - }; - }; - - class MBT_01_base_F: Tank_F { - class Turrets: Turrets { - class MainTurret: MainTurret { - discreteDistance[] = {}; - discreteDistanceInitIndex = 0; - }; - }; - }; - - class B_MBT_01_base_F: MBT_01_base_F {}; - class B_MBT_01_cannon_F: B_MBT_01_base_F {}; - class B_MBT_01_TUSK_F: B_MBT_01_cannon_F { - class Turrets: Turrets { - class MainTurret: MainTurret { - discreteDistance[] = {}; - discreteDistanceInitIndex = 0; - }; - }; - }; - class MBT_01_arty_base_F: MBT_01_base_F { - GVAR(Enabled) = 0; - }; - class MBT_01_mlrs_base_F: MBT_01_base_F { - GVAR(Enabled) = 0; - }; - - class MBT_02_base_F: Tank_F { - class Turrets: Turrets { - class MainTurret: MainTurret { - discreteDistance[] = {}; - discreteDistanceInitIndex = 0; - }; - }; - }; - class MBT_02_arty_base_F: MBT_02_base_F { - GVAR(Enabled) = 0; - }; - - class MBT_03_base_F: Tank_F { - class Turrets: Turrets { - class MainTurret: MainTurret { - discreteDistance[] = {}; - discreteDistanceInitIndex = 0; - }; - }; - }; - - class APC_Tracked_01_base_F: Tank_F {}; - class B_APC_Tracked_01_base_F: APC_Tracked_01_base_F {}; - class B_APC_Tracked_01_rcws_F: B_APC_Tracked_01_base_F { - GVAR(Enabled) = 0; - }; - class B_APC_Tracked_01_CRV_F: B_APC_Tracked_01_base_F { - GVAR(Enabled) = 0; - }; - class B_APC_Tracked_01_AA_F: B_APC_Tracked_01_base_F { - class Turrets: Turrets { - class MainTurret: MainTurret { - discreteDistance[] = {}; - discreteDistanceInitIndex = 0; - magazines[] += {"ACE_120Rnd_35mm_ABM_shells_Tracer_Red"}; - }; - }; - }; - - class APC_Tracked_02_base_F: Tank_F {}; - class O_APC_Tracked_02_base_F: APC_Tracked_02_base_F {}; - class O_APC_Tracked_02_AA_F: O_APC_Tracked_02_base_F { - class Turrets: Turrets { - class MainTurret: MainTurret { - magazines[] += {"ACE_120Rnd_35mm_ABM_shells_Tracer_Green"}; - }; - }; - }; - - class APC_Tracked_03_base_F: Tank_F { - class Turrets: Turrets { - class MainTurret: MainTurret { - discreteDistance[] = {}; - discreteDistanceInitIndex = 0; - }; - }; - }; - - // HELICOPTERS - class Air: AllVehicles {}; - - class Helicopter: Air { - class ACE_SelfActions { - class ResetFCS { - displayName = $STR_ACE_FCS_ResetFCS; - enableInside = 1; - condition = QUOTE(call FUNC(canResetFCS)); - statement = QUOTE([vehicle _player] call FUNC(reset);); - showDisabled = 0; - priority = 1; - icon = ""; - }; - }; - class Turrets { - class MainTurret; - }; - }; - - class Helicopter_Base_F: Helicopter { - class Turrets: Turrets { - class CopilotTurret; - }; - }; - - class Heli_Attack_01_base_F: Helicopter_Base_F { - GVAR(Enabled) = 1; - class Turrets: Turrets { - class MainTurret: MainTurret { - discreteDistance[] = {}; - discreteDistanceInitIndex = 0; - }; - }; - }; - - class Heli_Attack_02_base_F: Helicopter_Base_F { - GVAR(Enabled) = 1; - class Turrets: Turrets { - class MainTurret: MainTurret { - discreteDistance[] = {}; - discreteDistanceInitIndex = 0; - }; - }; - }; -}; - -class CfgWeapons { - // disable locking, so it doesn't interfere with our system - class CannonCore; - class cannon_120mm: CannonCore { - canLock = 0; - ballisticsComputer = 0; - }; - class autocannon_Base_F: CannonCore { - canLock = 0; - ballisticsComputer = 0; - }; - class autocannon_35mm: CannonCore { - canLock = 0; - ballisticsComputer = 0; - magazines[] += {"ACE_120Rnd_35mm_ABM_shells","ACE_120Rnd_35mm_ABM_shells_Tracer_Red","ACE_120Rnd_35mm_ABM_shells_Tracer_Green","ACE_120Rnd_35mm_ABM_shells_Tracer_Yellow"}; - }; - - // fix mrco having an invisible rangefinder - class ItemCore; - class optic_MRCO: ItemCore { - weaponInfoType = "RscWeaponZeroing"; - }; -}; - -class CfgMagazines { - class 680Rnd_35mm_AA_shells; - class 680Rnd_35mm_AA_shells_Tracer_Red; - class 680Rnd_35mm_AA_shells_Tracer_Green; - class 680Rnd_35mm_AA_shells_Tracer_Yellow; - - class ACE_120Rnd_35mm_ABM_shells: 680Rnd_35mm_AA_shells { - ammo = "ACE_B_35mm_ABM"; - count = 120; - displayName = "35mm ABM Shells"; - displayNameShort = "35mm ABM"; - }; - class ACE_120Rnd_35mm_ABM_shells_Tracer_Red: 680Rnd_35mm_AA_shells_Tracer_Red { - ammo = "ACE_B_35mm_ABM_Tracer_Red"; - count = 120; - displayName = "35mm ABM Shells"; - displayNameShort = "35mm ABM-T"; - }; - class ACE_120Rnd_35mm_ABM_shells_Tracer_Green: 680Rnd_35mm_AA_shells_Tracer_Green { - ammo = "ACE_B_35mm_ABM_Tracer_Green"; - count = 120; - displayName = "35mm ABM Shells"; - displayNameShort = "35mm ABM-T"; - }; - class ACE_120Rnd_35mm_ABM_shells_Tracer_Yellow: 680Rnd_35mm_AA_shells_Tracer_Yellow { - ammo = "ACE_B_35mm_ABM_Tracer_Yellow"; - count = 120; - displayName = "35mm ABM Shells"; - displayNameShort = "35mm ABM-T"; - }; -}; - -class CfgAmmo { - class B_35mm_AA; - class B_35mm_AA_Tracer_Red; - class B_35mm_AA_Tracer_Green; - class B_35mm_AA_Tracer_Yellow; - - class ACE_B_35mm_ABM: B_35mm_AA { - GVAR(Airburst) = 1; - deflecting = 0; - }; - class ACE_B_35mm_ABM_Tracer_Red: B_35mm_AA_Tracer_Red { - GVAR(Airburst) = 1; - deflecting = 0; - }; - class ACE_B_35mm_ABM_Tracer_Green: B_35mm_AA_Tracer_Green { - GVAR(Airburst) = 1; - deflecting = 0; - }; - class ACE_B_35mm_ABM_Tracer_Yellow: B_35mm_AA_Tracer_Yellow { - GVAR(Airburst) = 1; - deflecting = 0; - }; - - class ACE_B_35mm_ABM_Helper: B_35mm_AA { - indirectHitRange = 6; - simulation = "shotRocket"; - timeToLive = 0; - }; -}; - -#include +#include "CfgOptics.hpp" diff --git a/addons/fcs/functions/fnc_adjustRange.sqf b/addons/fcs/functions/fnc_adjustRange.sqf index 1620c53375..4b7f4b6b88 100644 --- a/addons/fcs/functions/fnc_adjustRange.sqf +++ b/addons/fcs/functions/fnc_adjustRange.sqf @@ -13,17 +13,20 @@ #include "script_component.hpp" -private ["_vehicle", "_delta", "_min", "_max", "_distance"]; +private ["_vehicle", "_turret", "_delta", "_turretConfig", "_min", "_max", "_distance"]; _vehicle = _this select 0; -_delta = _this select 1; +_turret = _this select 1; +_delta = _this select 2; -_min = getNumber (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> QGVAR(MinDistance)); -_max = getNumber (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> QGVAR(MaxDistance)); -_distance = _vehicle getVariable [QGVAR(Distance), _min]; +_turretConfig = [configFile >> "CfgVehicles" >> typeOf _vehicle, _turret] call EFUNC(common,getTurretConfigPath); + +_min = getNumber (_turretConfig >> QGVAR(MinDistance)); +_max = getNumber (_turretConfig >> QGVAR(MaxDistance)); +_distance = _vehicle getVariable [format ["%1_%2", QGVAR(Distance), _turret], _min]; _distance = _distance + _delta; _distance = _distance min _max; _distance = _distance max _min; -[_vehicle, 0, _distance] call FUNC(keyUp); +[_vehicle, _turret, _distance] call FUNC(keyUp); diff --git a/addons/fcs/functions/fnc_canResetFCS.sqf b/addons/fcs/functions/fnc_canResetFCS.sqf index 8760503cdb..488f1eebf4 100644 --- a/addons/fcs/functions/fnc_canResetFCS.sqf +++ b/addons/fcs/functions/fnc_canResetFCS.sqf @@ -12,5 +12,4 @@ #include "script_component.hpp" -ACE_player == gunner vehicle ACE_player -&& (count ((vehicle ACE_player) getVariable [QGVAR(Magazines), []]) > 1) +count ((vehicle ACE_player) getVariable [format ["%1_%2", QGVAR(Magazines), [ACE_player] call EFUNC(common,getTurretIndex)], []]) > 1 diff --git a/addons/fcs/functions/fnc_canUseFCS.sqf b/addons/fcs/functions/fnc_canUseFCS.sqf index ef4a3f2814..cb4a1b608d 100644 --- a/addons/fcs/functions/fnc_canUseFCS.sqf +++ b/addons/fcs/functions/fnc_canUseFCS.sqf @@ -12,6 +12,5 @@ #include "script_component.hpp" -ACE_player == gunner vehicle ACE_player -&& {getNumber (configFile >> "CfgVehicles" >> typeOf (vehicle ACE_player) >> QGVAR(Enabled)) == 1} +getNumber ([configFile >> "CfgVehicles" >> typeOf vehicle ACE_player, [ACE_player] call EFUNC(common,getTurretIndex)] call EFUNC(common,getTurretConfigPath) >> QGVAR(Enabled)) == 1 && {cameraView == "GUNNER"} diff --git a/addons/fcs/functions/fnc_firedEH.sqf b/addons/fcs/functions/fnc_firedEH.sqf index e6fff694ca..f17693d33e 100644 --- a/addons/fcs/functions/fnc_firedEH.sqf +++ b/addons/fcs/functions/fnc_firedEH.sqf @@ -12,51 +12,50 @@ #include "script_component.hpp" -private ["_unit", "_weaponType", "_ammoType", "_magazineType", "_round", "_FCSMagazines", "_FCSElevation", "_offset"]; +private ["_vehicle", "_weapon", "_ammo", "_magazine", "_projectile"]; -_unit = _this select 0; -_weaponType = _this select 1; -_ammoType = _this select 4; -_magazineType = _this select 5; -_round = _this select 6; +_vehicle = _this select 0; +_weapon = _this select 1; +_ammo = _this select 4; +_magazine = _this select 5; +_projectile = _this select 6; -_FCSMagazines = _unit getVariable QGVAR(Magazines); -_FCSElevation = _unit getVariable QGVAR(Elevation); +private ["_gunner", "_turret"]; -if (ACE_player != gunner _unit) exitWith {}; -if !(_magazineType in _FCSMagazines) exitWith {}; +_gunner = [_vehicle, _weapon] call EFUNC(common,getGunner); +_turret = [_gunner] call EFUNC(common,getTurretIndex); + +// Exit if the unit isn't a player +if !([_gunner] call EFUNC(common,isPlayer)) exitWith {}; + +private ["_FCSMagazines", "_FCSElevation", "_offset"]; + +_FCSMagazines = _vehicle getVariable format ["%1_%2", QGVAR(Magazines), _turret]; +_FCSElevation = _vehicle getVariable format ["%1_%2", QGVAR(Elevation), _turret]; + +if !(_magazine in _FCSMagazines) exitWith {}; // GET ELEVATION OFFSET OF CURRENT MAGAZINE _offset = 0; { - if (_x == _magazineType) exitWith { + if (_x == _magazine) exitWith { _offset = _FCSElevation select _forEachIndex; }; } forEach _FCSMagazines; -[_round, (_unit getVariable QGVAR(Azimuth)), _offset, 0] call EFUNC(common,changeProjectileDirection); +[_projectile, (_vehicle getVariable format ["%1_%2", QGVAR(Azimuth), _turret]), _offset, 0] call EFUNC(common,changeProjectileDirection); // Air burst missile -// may need to get rewritten -if (getNumber (configFile >> "CfgAmmo" >> _ammoType >> "ACE_Airburst") == 1) then { - _this spawn { - _vehicle = _this select 0; - _projectile = _this select 6; - _distance = _vehicle getVariable [QGVAR(Distance), currentZeroing _vehicle]; +// handle locally only +if (!local _gunner) exitWith {}; - if (_distance < 50) exitWith {}; - if (_distance > 1500) exitWith {}; +if (getNumber (configFile >> "CfgAmmo" >> _ammo >> QGVAR(Airburst)) == 1) then { + private "_zeroing"; + _zeroing = _vehicle getVariable [format ["%1_%2", QGVAR(Distance), _turret], currentZeroing _vehicle]; - waitUntil {_projectile distance _vehicle > _distance || {!alive _projectile}}; - if (!alive _projectile) exitWith {}; + if (_zeroing < 50) exitWith {}; + if (_zeroing > 1500) exitWith {}; - _position = getPosATL _projectile; - - _subMunition = createVehicle ["ACE_B_35mm_ABM_Helper", _position, [], 0, "FLY"]; - _subMunition setPosATL _position; - _subMunition setVelocity [0, 0, -10]; - - deleteVehicle _projectile; - }; + [FUNC(handleAirBurstAmmunitionPFH), 0, [_vehicle, _projectile, _zeroing]] call CBA_fnc_addPerFrameHandler; }; diff --git a/addons/fcs/functions/fnc_handleAirBurstAmmunitionPFH.sqf b/addons/fcs/functions/fnc_handleAirBurstAmmunitionPFH.sqf new file mode 100644 index 0000000000..7e8480ce18 --- /dev/null +++ b/addons/fcs/functions/fnc_handleAirBurstAmmunitionPFH.sqf @@ -0,0 +1,21 @@ +// by commy2 + +_vehicle = _this select 0 select 0; +_projectile = _this select 0 select 1; +_zeroing = _this select 0 select 2; + +if (isNull _projectile || {!alive _projectile}) exitWith { + [_this select 1] call CBA_fnc_removePerFrameHandler; +}; + +if (_projectile distance _vehicle < _zeroing) exitWith {}; + +_position = getPosATL _projectile; + +_subMunition = createVehicle ["ACE_B_35mm_ABM_Helper", _position, [], 0, "FLY"]; +_subMunition setPosATL _position; +_subMunition setVelocity [0, 0, -10]; + +deleteVehicle _projectile; + +[_this select 1] call CBA_fnc_removePerFrameHandler; diff --git a/addons/fcs/functions/fnc_keyDown.sqf b/addons/fcs/functions/fnc_keyDown.sqf index 086a11c03c..7699b82a20 100644 --- a/addons/fcs/functions/fnc_keyDown.sqf +++ b/addons/fcs/functions/fnc_keyDown.sqf @@ -12,12 +12,14 @@ #include "script_component.hpp" -private ["_vehicle", "_distance", "_weaponDirection"]; +private ["_vehicle", "_turret", "_distance", "_weaponDirection"]; _vehicle = _this select 0; +_turret = _this select 1; + _distance = call FUNC(getRange); -if !(call FUNC(canUseFCS)) exitWith {}; +if !(!GVAR(enabled) && FUNC(canUseFCS)) exitWith {}; GVAR(Enabled) = true; GVAR(Time) = time; @@ -26,7 +28,15 @@ if (_distance == 0) then { _distance = [5, 5000, 0] call EFUNC(common,getTargetDistance); // maximum distance: 5000m, 5m precision }; -_weaponDirection = _vehicle weaponDirection currentWeapon _vehicle; +_weaponDirection = _vehicle weaponDirection (_vehicle currentWeaponTurret _turret); // @todo doesn't work for sub turrets + +if (_turret isEqualTo ([typeOf _vehicle] call EFUNC(common,getTurretCommander))) then { + _weaponDirection = eyeDirection _vehicle; +}; + +if (_weaponDirection isEqualTo [0,0,0]) then { // dummy value for non main turrets + _weaponDirection = [1,0,0]; +}; GVAR(Position) = [ (getPos _vehicle select 0) + _distance * (_weaponDirection select 0), diff --git a/addons/fcs/functions/fnc_keyUp.sqf b/addons/fcs/functions/fnc_keyUp.sqf index c95460e65b..1e5878f0b5 100644 --- a/addons/fcs/functions/fnc_keyUp.sqf +++ b/addons/fcs/functions/fnc_keyUp.sqf @@ -12,22 +12,37 @@ #include "script_component.hpp" -private ["_ammoType", "_viewDiff", "_posArrival", "_airFriction", "_timeToLive", "_maxElev", "_vehicle", "_posTarget", "_distance", "_simulationStep", "_posX", "_velocityMagnitude", "_magazines", "_movingAzimuth", "_FCSElevation", "_velocityX", "_velocityY", "_weaponDirection", "_velocityTarget", "_FCSAzimuth", "_FCSMagazines", "_dirArrival", "_i", "_magazineType", "_angleTarget", "_offset", "_timeToTarget", "_initSpeed"]; +private ["_vehicle", "_turret", "_turretConfig", "_distance", "_magazines"]; _vehicle = _this select 0; +_turret = _this select 1; + +_turretConfig = [configFile >> "CfgVehicles" >> typeOf _vehicle, _turret] call EFUNC(common,getTurretConfigPath); + _distance = call FUNC(getRange); -_magazines = magazines _vehicle; +_magazines = _vehicle magazinesTurret _turret; if (_distance == 0) then { _distance = [ - getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(DistanceInterval)), - getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(MaxDistance)), - getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(MinDistance)) + getNumber (_turretConfig >> QGVAR(DistanceInterval)), + getNumber (_turretConfig >> QGVAR(MaxDistance)), + getNumber (_turretConfig >> QGVAR(MinDistance)) ] call EFUNC(common,getTargetDistance); // maximum distance: 5000m, 5m precision }; -_weaponDirection = _vehicle weaponDirection currentWeapon _vehicle; +private ["_weaponDirection", "_angleTarget"]; + +_weaponDirection = _vehicle weaponDirection (_vehicle currentWeaponTurret _turret); // @todo doesn't work for sub turrets + +if (_turret isEqualTo ([typeOf _vehicle] call EFUNC(common,getTurretCommander))) then { + _weaponDirection = eyeDirection _vehicle; +}; + +if (_weaponDirection isEqualTo [0,0,0]) then { // dummy value for non main turrets + _weaponDirection = [1,0,0]; +}; + _angleTarget = asin (_weaponDirection select 2); if (count _this > 2) then { @@ -38,6 +53,8 @@ if (!(isNil QGVAR(backgroundCalculation)) and {!(scriptDone GVAR(backgroundCalcu terminate GVAR(backgroundCalculation); }; +private "_movingAzimuth"; + // MOVING TARGETS _movingAzimuth = 0; if (time - GVAR(time) > 1 and GVAR(time) != -1 and count _this < 3) then { @@ -53,8 +70,10 @@ if (time - GVAR(time) > 1 and GVAR(time) != -1 and count _this < 3) then { ((_posTarget select 2) - (GVAR(position) select 2)) / (time - GVAR(time)) ]; + private ["_magazineType", "_ammoType", "_initSpeed", "_airFriction", "_timeToLive", "_simulationStep"]; + // estimate time to target - _magazineType = currentMagazine _vehicle; + _magazineType = _vehicle currentMagazineTurret _turret; _ammoType = getText (configFile >> "CfgMagazines" >> _magazineType >> "ammo"); _initSpeed = getNumber (configFile >> "CfgMagazines" >> _magazineType >> "initSpeed"); _airFriction = getNumber (configFile >> "CfgAmmo" >> _ammoType >> "airFriction"); @@ -62,10 +81,13 @@ if (time - GVAR(time) > 1 and GVAR(time) != -1 and count _this < 3) then { _simulationStep = getNumber (configFile >> "CfgAmmo" >> _ammoType >> "simulationStep"); if (_simulationStep != 0) then { + private ["_posX", "_velocityX", "_velocityY", "_timeToTarget"]; + _posX = 0; _velocityX = _initSpeed; _velocityY = 0; _timeToTarget = 0; + for "_i" from 1 to ((floor (_timeToLive / _simulationStep)) + 1) do { _posX = _posX + _velocityX * _simulationStep; if (_posX >= _distance) exitWith { // bullet passed the target @@ -76,12 +98,15 @@ if (time - GVAR(time) > 1 and GVAR(time) != -1 and count _this < 3) then { _velocityY = _velocityY + _velocityY * _velocityMagnitude * _airFriction * _simulationStep - 9.81 * _simulationStep; }; + private ["_posArrival", "_dirArrival"]; + // calculate offsets _posArrival = [ (_posTarget select 0) + (_velocityTarget select 0) * _timeToTarget, (_posTarget select 1) + (_velocityTarget select 1) * _timeToTarget, (_posTarget select 2) + (_velocityTarget select 2) * _timeToTarget ]; + _dirArrival = [ ((_posArrival select 0) - (getPos _vehicle select 0)) / (_posArrival distance (getPos _vehicle)), ((_posArrival select 1) - (getPos _vehicle select 1)) / (_posArrival distance (getPos _vehicle)), @@ -96,9 +121,12 @@ if (time - GVAR(time) > 1 and GVAR(time) != -1 and count _this < 3) then { GVAR(enabled) = false; GVAR(time) = -1; +private ["_viewDiff", "_FCSAzimuth", "_FCSMagazines", "_FCSElevation"]; + // CALCULATE AZIMUTH CORRECTION -_viewDiff = _vehicle getVariable QGVAR(ViewDiff); +_viewDiff = _vehicle getVariable format ["%1_%2", QGVAR(ViewDiff), _turret]; _FCSAzimuth = _movingAzimuth; + if (_viewDiff != 0) then { _FCSAzimuth = (atan (_distance / _viewDiff) - (abs _viewDiff / _viewDiff) * 90) + _movingAzimuth; }; @@ -108,11 +136,16 @@ _FCSMagazines = []; _FCSElevation = []; { - _ammoType = getText (configFile >> "CfgMagazines" >> _x >> "ammo"); + private "_ammoType"; + + _ammoType = getText (configFile >> "CfgMagazines" >> _x >> "ammo"); + if !(getText (configFile >> "CfgAmmo" >> _ammoType >> "simulation") == "shotMissile") then { - _maxElev = getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "Turrets" >> "MainTurret" >> "maxElev"); - _initSpeed = getNumber (configFile >> "CfgMagazines" >> _x >> "initSpeed"); - _airFriction = getNumber (configFile >> "CfgAmmo" >> _ammoType >> "airFriction"); + private ["_maxElev", "_initSpeed", "_airFriction", "_offset"]; + + _maxElev = getNumber (_turretConfig >> "maxElev"); + _initSpeed = getNumber (configFile >> "CfgMagazines" >> _x >> "initSpeed"); + _airFriction = getNumber (configFile >> "CfgAmmo" >> _ammoType >> "airFriction"); _offset = "ace_fcs" callExtension format ["%1,%2,%3,%4", _initSpeed, _airFriction, _angleTarget, _distance]; _offset = parseNumber _offset; @@ -122,9 +155,9 @@ _FCSElevation = []; }; } forEach _magazines; -_vehicle setVariable [QGVAR(Distance), _distance, true]; -_vehicle setVariable [QGVAR(Magazines), _FCSMagazines, true]; -_vehicle setVariable [QGVAR(Elevation), _FCSElevation, true]; -_vehicle setVariable [QGVAR(Azimuth), _FCSAzimuth, true]; +[_vehicle, format ["%1_%2", QGVAR(Distance), _turret], _distance] call EFUNC(common,setVariablePublic); +[_vehicle, format ["%1_%2", QGVAR(Magazines), _turret], _FCSMagazines] call EFUNC(common,setVariablePublic); +[_vehicle, format ["%1_%2", QGVAR(Elevation), _turret], _FCSElevation] call EFUNC(common,setVariablePublic); +[_vehicle, format ["%1_%2", QGVAR(Azimuth), _turret], _FCSAzimuth] call EFUNC(common,setVariablePublic); [format ["%1: %2", localize "STR_ACE_FCS_ZeroedTo", _distance]] call EFUNC(common,displayTextStructured); diff --git a/addons/fcs/functions/fnc_reset.sqf b/addons/fcs/functions/fnc_reset.sqf index f49c4c9589..a23a759fa3 100644 --- a/addons/fcs/functions/fnc_reset.sqf +++ b/addons/fcs/functions/fnc_reset.sqf @@ -12,13 +12,14 @@ #include "script_component.hpp" -private ["_vehicle"]; +private ["_vehicle", "_turret"]; _vehicle = _this select 0; +_turret = _this select 1; -_vehicle setVariable [QGVAR(Distance), 0, true]; -_vehicle setVariable [QGVAR(Magazines), [], true]; -_vehicle setVariable [QGVAR(Elevation), 0, true]; -_vehicle setVariable [QGVAR(Azimuth), 0, true]; +[_vehicle, format ["%1_%2", QGVAR(Distance), _turret], 0] call EFUNC(common,setVariablePublic); +[_vehicle, format ["%1_%2", QGVAR(Magazines), _turret], []] call EFUNC(common,setVariablePublic); +[_vehicle, format ["%1_%2", QGVAR(Elevation), _turret], 0] call EFUNC(common,setVariablePublic); +[_vehicle, format ["%1_%2", QGVAR(Azimuth), _turret], 0] call EFUNC(common,setVariablePublic); [localize "STR_ACE_FCS_HasBeenReset"] call EFUNC(common,displayTextStructured); diff --git a/addons/fcs/functions/fnc_vehicleInit.sqf b/addons/fcs/functions/fnc_vehicleInit.sqf index 5872b1757f..8ac23073f6 100644 --- a/addons/fcs/functions/fnc_vehicleInit.sqf +++ b/addons/fcs/functions/fnc_vehicleInit.sqf @@ -1,7 +1,7 @@ /* - * Author: KoffeinFlummi + * Author: KoffeinFlummi, commy2 * - * Checks if a vehicle is equipped with an FCS and if so, adds the fired event handler + * Checks if a vehicle is equipped with an FCS and if so, adds the fired event handler. Execute on server. * * Arguments: * 0: Vehicle @@ -12,25 +12,34 @@ #include "script_component.hpp" -private ["_gunBeg", "_gunnerView", "_gunBegPos", "_gunnerViewPos", "_viewDiff"]; +private "_vehicle"; -if (getNumber (configFile >> "CfgVehicles" >> (typeOf (_this select 0)) >> QGVAR(Enabled)) == 1) then { - (_this select 0) addEventHandler ["Fired", {_this call FUNC(firedEH)}]; +_vehicle = _this select 0; - (_this select 0) setVariable [QGVAR(Distance), 0, true]; - (_this select 0) setVariable [QGVAR(Magazines), [], true]; - (_this select 0) setVariable [QGVAR(Elevation), [], true]; - (_this select 0) setVariable [QGVAR(Azimuth), 0, true]; +{ + private "_turretConfig"; + _turretConfig = [configFile >> "CfgVehicles" >> typeOf _vehicle, _x] call EFUNC(common,getTurretConfigPath); - // calculate offset between gunner camera and muzzle position - if !((_this select 0) isKindOf "Air") then { - _gunBeg = getText (configFile >> "CfgVehicles" >> (typeOf (_this select 0)) >> "Turrets" >> "MainTurret" >> "gunBeg"); - _gunnerView = getText (configFile >> "CfgVehicles" >> (typeOf (_this select 0)) >> "Turrets" >> "MainTurret" >> "memoryPointGunnerOptics"); - _gunBegPos = ((_this select 0) selectionPosition _gunBeg) select 0; - _gunnerViewPos = ((_this select 0) selectionPosition _gunnerView) select 0; - _viewDiff = _gunBegPos - _gunnerViewPos; - (_this select 0) setVariable [QGVAR(ViewDiff), _viewDiff, true]; - } else { - (_this select 0) setVariable [QGVAR(ViewDiff), 0, true]; + if (getNumber (_turretConfig >> QGVAR(Enabled)) == 1) then { + _vehicle setVariable [format ["%1_%2", QGVAR(Distance), _x], 0, true]; + _vehicle setVariable [format ["%1_%2", QGVAR(Magazines), _x], [], true]; + _vehicle setVariable [format ["%1_%2", QGVAR(Elevation), _x], [], true]; + _vehicle setVariable [format ["%1_%2", QGVAR(Azimuth), _x], 0, true]; + + // calculate offset between gunner camera and muzzle position + if !(_vehicle isKindOf "Air") then { + private ["_gunBeg", "_gunnerView", "_gunBegPos", "_gunnerViewPos", "_viewDiff"]; + + _gunBeg = getText (_turretConfig >> "gunBeg"); + _gunnerView = getText (_turretConfig >> "memoryPointGunnerOptics"); + + _gunBegPos = (_vehicle selectionPosition _gunBeg) select 0; + _gunnerViewPos = (_vehicle selectionPosition _gunnerView) select 0; + _viewDiff = _gunBegPos - _gunnerViewPos; + + _vehicle setVariable [format ["%1_%2", QGVAR(ViewDiff), _x], _viewDiff, true]; + } else { + _vehicle setVariable [format ["%1_%2", QGVAR(ViewDiff), _x], 0, true]; + }; }; -}; +} forEach allTurrets _vehicle; diff --git a/addons/fcs/initKeybinds.sqf b/addons/fcs/initKeybinds.sqf new file mode 100644 index 0000000000..dd1a94b78e --- /dev/null +++ b/addons/fcs/initKeybinds.sqf @@ -0,0 +1,81 @@ +// by commy2 + +["ACE3", + localize "STR_ACE_FCS_LaseTarget", + { + // Conditions: canInteract + _exceptions = []; + if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; + // Conditions: specific + if !((!GVAR(enabled) && FUNC(canUseFCS)) || FUNC(canUseRangefinder)) exitWith {false}; + + // prevent holding down + if (GETGVAR(isDownStateKey1,false)) exitWith {false}; + GVAR(isDownStateKey1) = true; + + // Statement + [vehicle ACE_player, [ACE_player] call EFUNC(common,getTurretIndex)] call FUNC(keyDown); + // Return false so it doesn't block the rest weapon action + false + }, + [15, [false, false, false]], + false, + "keydown" +] call cba_fnc_registerKeybind; + +["ACE3", + localize "STR_ACE_FCS_LaseTarget", + { + // prevent holding down + GVAR(isDownStateKey1) = false; + + // Conditions: canInteract + _exceptions = []; + if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; + // Conditions: specific + if !(GVAR(enabled) && FUNC(canUseFCS)) exitWith {false}; + + // Statement + [vehicle ACE_player, [ACE_player] call EFUNC(common,getTurretIndex)] call FUNC(keyUp); + false + }, + [15, [false, false, false]], + false, + "keyup" +] call cba_fnc_registerKeybind; + +["ACE3", + localize "STR_ACE_FCS_AdjustRangeUp", + { + // Conditions: canInteract + _exceptions = []; + if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; + // Conditions: specific + if !(call FUNC(canUseRangefinder) || FUNC(canUseFCS)) exitWith {false}; + + // Statement + [vehicle ACE_player, [ACE_player] call EFUNC(common,getTurretIndex), 50] call FUNC(adjustRange); + true + }, + [201, [false, false, false]], + false, + "keydown" +] call cba_fnc_registerKeybind; + +["ACE3", + localize "STR_ACE_FCS_AdjustRangeDown", + { + // Conditions: canInteract + _exceptions = []; + if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; + // Conditions: specific + if !(call FUNC(canUseRangefinder) || FUNC(canUseFCS)) exitWith {false}; + + // Statement + [vehicle ACE_player, [ACE_player] call EFUNC(common,getTurretIndex), -50] call FUNC(adjustRange); + true + }, + [209, [false, false, false]], + false, + "keydown" +] call cba_fnc_registerKeybind; diff --git a/addons/flashsuppressors/CfgVehicles.hpp b/addons/flashsuppressors/CfgVehicles.hpp index 40dc505d64..a973518b91 100644 --- a/addons/flashsuppressors/CfgVehicles.hpp +++ b/addons/flashsuppressors/CfgVehicles.hpp @@ -1,9 +1,4 @@ -#define MACRO_ADDITEM(ITEM,COUNT) class _xx_##ITEM { \ - name = #ITEM; \ - count = COUNT; \ -} - class CfgVehicles { class NATO_Box_Base; class Box_NATO_Support_F: NATO_Box_Base { diff --git a/addons/gforces/functions/fnc_pfhUpdateGForces.sqf b/addons/gforces/functions/fnc_pfhUpdateGForces.sqf index f45d629760..839110fd2b 100644 --- a/addons/gforces/functions/fnc_pfhUpdateGForces.sqf +++ b/addons/gforces/functions/fnc_pfhUpdateGForces.sqf @@ -1,5 +1,17 @@ -// by KoffeinFlummi and CAA-Picard -#include "script_component.hpp" +/* + * Author: KoffeinFlummi and CAA-Picard + * Calculates average g-forces and triggers g-effects + * + * Argument: + * 0: Arguments + * 1: pfh_id + * + * Return value: + * None + * + * Public: No + */ + #include "script_component.hpp" EXPLODE_2_PVT(_this,_params,_pfhId); diff --git a/addons/goggles/config.cpp b/addons/goggles/config.cpp index f804be003e..dcc9c6ed0e 100644 --- a/addons/goggles/config.cpp +++ b/addons/goggles/config.cpp @@ -3,13 +3,13 @@ #define COLOUR 8.0 class CfgPatches { class ADDON { - units[] = {}; - weapons[] = {}; - requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ace_common"}; - author[] = {"Garth 'L-H' de Wet"}; - authorUrl = "http://garth.snakebiteink.co.za/"; - VERSION_CONFIG; + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common"}; + author[] = {"Garth 'L-H' de Wet"}; + authorUrl = "http://garth.snakebiteink.co.za/"; + VERSION_CONFIG; }; }; @@ -243,10 +243,12 @@ class SniperCloud { ACE_Goggles_BulletCount = 1; }; -class ACE_Options { +class ACE_Settings { class GVAR(showInThirdPerson) { - displayName = $STR_ACE_Goggles_ShowInThirdPerson; - default = 0; + value = 0; + typeName = "BOOL"; + isClientSetable = 1; + displayName = "$STR_ACE_Goggles_ShowInThirdPerson"; }; }; diff --git a/addons/goggles/functions/fnc_externalCamera.sqf b/addons/goggles/functions/fnc_externalCamera.sqf index 093e2c318e..9161804a56 100644 --- a/addons/goggles/functions/fnc_externalCamera.sqf +++ b/addons/goggles/functions/fnc_externalCamera.sqf @@ -15,5 +15,5 @@ */ #include "script_component.hpp" -if ((missionNameSpace getVariable [QGVAR(showInThirdPerson), 0]) == 1) exitWith { false }; +if (GVAR(showInThirdPerson)) exitWith { false }; (cameraView == "External") diff --git a/addons/grenades/CfgAmmo.hpp b/addons/grenades/CfgAmmo.hpp index 7b0a24740d..0f86230784 100644 --- a/addons/grenades/CfgAmmo.hpp +++ b/addons/grenades/CfgAmmo.hpp @@ -1,89 +1,89 @@ class CfgAmmo { - class FlareCore; - class FlareBase: FlareCore { - intensity = 20000; - flareSize = 12; - }; - class F_40mm_White: FlareBase { - intensity = 40000; - flareSize = 12; - }; - class F_20mm_White: FlareBase { - intensity = 20000; - flareSize = 12; - }; - class F_Signal_Green: FlareBase { - intensity = 20000; - flareSize = 12; - }; - class Flare_82mm_AMOS_White: FlareCore { - intensity = 80000; - flareSize = 12; - }; + class FlareCore; + class FlareBase: FlareCore { + intensity = 20000; + flareSize = 12; + }; + class F_40mm_White: FlareBase { + intensity = 40000; + flareSize = 12; + }; + class F_20mm_White: FlareBase { + intensity = 20000; + flareSize = 12; + }; + class F_Signal_Green: FlareBase { + intensity = 20000; + flareSize = 12; + }; + class Flare_82mm_AMOS_White: FlareCore { + intensity = 80000; + flareSize = 12; + }; - class F_20mm_Red: F_20mm_White {}; - class F_20mm_Green: F_20mm_White {}; - class F_20mm_Yellow: F_20mm_White {}; + class F_20mm_Red: F_20mm_White {}; + class F_20mm_Green: F_20mm_White {}; + class F_20mm_Yellow: F_20mm_White {}; - class ACE_F_Hand_White: F_20mm_White { - grenadeBurningSound[] = {"SmokeShellSoundLoop1",0.5,"SmokeShellSoundLoop2",0.5}; - grenadeFireSound[] = {"SmokeShellSoundHit1",0.25,"SmokeShellSoundHit2",0.25,"SmokeShellSoundHit3",0.5}; - soundTrigger[] = {"SmokeShellSoundLoop1",0.5,"SmokeShellSoundLoop2",0.5}; - SmokeShellSoundHit1[] = {"A3\Sounds_F\weapons\smokeshell\smoke_1",1.25893,1,100}; - SmokeShellSoundHit2[] = {"A3\Sounds_F\weapons\smokeshell\smoke_2",1.25893,1,100}; - SmokeShellSoundHit3[] = {"A3\Sounds_F\weapons\smokeshell\smoke_3",1.25893,1,100}; - SmokeShellSoundLoop1[] = {"A3\Sounds_F\weapons\smokeshell\smoke_loop1",0.125893,1,70}; - SmokeShellSoundLoop2[] = {"A3\Sounds_F\weapons\smokeshell\smoke_loop2",0.125893,1,70}; - timeToLive = 60; - }; - class ACE_F_Hand_Red: F_20mm_Red { - grenadeBurningSound[] = {"SmokeShellSoundLoop1",0.5,"SmokeShellSoundLoop2",0.5}; - grenadeFireSound[] = {"SmokeShellSoundHit1",0.25,"SmokeShellSoundHit2",0.25,"SmokeShellSoundHit3",0.5}; - soundTrigger[] = {"SmokeShellSoundLoop1",0.5,"SmokeShellSoundLoop2",0.5}; - SmokeShellSoundHit1[] = {"A3\Sounds_F\weapons\smokeshell\smoke_1",1.25893,1,100}; - SmokeShellSoundHit2[] = {"A3\Sounds_F\weapons\smokeshell\smoke_2",1.25893,1,100}; - SmokeShellSoundHit3[] = {"A3\Sounds_F\weapons\smokeshell\smoke_3",1.25893,1,100}; - SmokeShellSoundLoop1[] = {"A3\Sounds_F\weapons\smokeshell\smoke_loop1",0.125893,1,70}; - SmokeShellSoundLoop2[] = {"A3\Sounds_F\weapons\smokeshell\smoke_loop2",0.125893,1,70}; - timeToLive = 60; - }; - class ACE_F_Hand_Green: F_20mm_Green { - grenadeBurningSound[] = {"SmokeShellSoundLoop1",0.5,"SmokeShellSoundLoop2",0.5}; - grenadeFireSound[] = {"SmokeShellSoundHit1",0.25,"SmokeShellSoundHit2",0.25,"SmokeShellSoundHit3",0.5}; - soundTrigger[] = {"SmokeShellSoundLoop1",0.5,"SmokeShellSoundLoop2",0.5}; - SmokeShellSoundHit1[] = {"A3\Sounds_F\weapons\smokeshell\smoke_1",1.25893,1,100}; - SmokeShellSoundHit2[] = {"A3\Sounds_F\weapons\smokeshell\smoke_2",1.25893,1,100}; - SmokeShellSoundHit3[] = {"A3\Sounds_F\weapons\smokeshell\smoke_3",1.25893,1,100}; - SmokeShellSoundLoop1[] = {"A3\Sounds_F\weapons\smokeshell\smoke_loop1",0.125893,1,70}; - SmokeShellSoundLoop2[] = {"A3\Sounds_F\weapons\smokeshell\smoke_loop2",0.125893,1,70}; - timeToLive = 60; - }; - class ACE_F_Hand_Yellow: F_20mm_Yellow { - grenadeBurningSound[] = {"SmokeShellSoundLoop1",0.5,"SmokeShellSoundLoop2",0.5}; - grenadeFireSound[] = {"SmokeShellSoundHit1",0.25,"SmokeShellSoundHit2",0.25,"SmokeShellSoundHit3",0.5}; - soundTrigger[] = {"SmokeShellSoundLoop1",0.5,"SmokeShellSoundLoop2",0.5}; - SmokeShellSoundHit1[] = {"A3\Sounds_F\weapons\smokeshell\smoke_1",1.25893,1,100}; - SmokeShellSoundHit2[] = {"A3\Sounds_F\weapons\smokeshell\smoke_2",1.25893,1,100}; - SmokeShellSoundHit3[] = {"A3\Sounds_F\weapons\smokeshell\smoke_3",1.25893,1,100}; - SmokeShellSoundLoop1[] = {"A3\Sounds_F\weapons\smokeshell\smoke_loop1",0.125893,1,70}; - SmokeShellSoundLoop2[] = {"A3\Sounds_F\weapons\smokeshell\smoke_loop2",0.125893,1,70}; - timeToLive = 60; - }; + class ACE_F_Hand_White: F_20mm_White { + grenadeBurningSound[] = {"SmokeShellSoundLoop1",0.5,"SmokeShellSoundLoop2",0.5}; + grenadeFireSound[] = {"SmokeShellSoundHit1",0.25,"SmokeShellSoundHit2",0.25,"SmokeShellSoundHit3",0.5}; + soundTrigger[] = {"SmokeShellSoundLoop1",0.5,"SmokeShellSoundLoop2",0.5}; + SmokeShellSoundHit1[] = {"A3\Sounds_F\weapons\smokeshell\smoke_1",1.25893,1,100}; + SmokeShellSoundHit2[] = {"A3\Sounds_F\weapons\smokeshell\smoke_2",1.25893,1,100}; + SmokeShellSoundHit3[] = {"A3\Sounds_F\weapons\smokeshell\smoke_3",1.25893,1,100}; + SmokeShellSoundLoop1[] = {"A3\Sounds_F\weapons\smokeshell\smoke_loop1",0.125893,1,70}; + SmokeShellSoundLoop2[] = {"A3\Sounds_F\weapons\smokeshell\smoke_loop2",0.125893,1,70}; + timeToLive = 60; + }; + class ACE_F_Hand_Red: F_20mm_Red { + grenadeBurningSound[] = {"SmokeShellSoundLoop1",0.5,"SmokeShellSoundLoop2",0.5}; + grenadeFireSound[] = {"SmokeShellSoundHit1",0.25,"SmokeShellSoundHit2",0.25,"SmokeShellSoundHit3",0.5}; + soundTrigger[] = {"SmokeShellSoundLoop1",0.5,"SmokeShellSoundLoop2",0.5}; + SmokeShellSoundHit1[] = {"A3\Sounds_F\weapons\smokeshell\smoke_1",1.25893,1,100}; + SmokeShellSoundHit2[] = {"A3\Sounds_F\weapons\smokeshell\smoke_2",1.25893,1,100}; + SmokeShellSoundHit3[] = {"A3\Sounds_F\weapons\smokeshell\smoke_3",1.25893,1,100}; + SmokeShellSoundLoop1[] = {"A3\Sounds_F\weapons\smokeshell\smoke_loop1",0.125893,1,70}; + SmokeShellSoundLoop2[] = {"A3\Sounds_F\weapons\smokeshell\smoke_loop2",0.125893,1,70}; + timeToLive = 60; + }; + class ACE_F_Hand_Green: F_20mm_Green { + grenadeBurningSound[] = {"SmokeShellSoundLoop1",0.5,"SmokeShellSoundLoop2",0.5}; + grenadeFireSound[] = {"SmokeShellSoundHit1",0.25,"SmokeShellSoundHit2",0.25,"SmokeShellSoundHit3",0.5}; + soundTrigger[] = {"SmokeShellSoundLoop1",0.5,"SmokeShellSoundLoop2",0.5}; + SmokeShellSoundHit1[] = {"A3\Sounds_F\weapons\smokeshell\smoke_1",1.25893,1,100}; + SmokeShellSoundHit2[] = {"A3\Sounds_F\weapons\smokeshell\smoke_2",1.25893,1,100}; + SmokeShellSoundHit3[] = {"A3\Sounds_F\weapons\smokeshell\smoke_3",1.25893,1,100}; + SmokeShellSoundLoop1[] = {"A3\Sounds_F\weapons\smokeshell\smoke_loop1",0.125893,1,70}; + SmokeShellSoundLoop2[] = {"A3\Sounds_F\weapons\smokeshell\smoke_loop2",0.125893,1,70}; + timeToLive = 60; + }; + class ACE_F_Hand_Yellow: F_20mm_Yellow { + grenadeBurningSound[] = {"SmokeShellSoundLoop1",0.5,"SmokeShellSoundLoop2",0.5}; + grenadeFireSound[] = {"SmokeShellSoundHit1",0.25,"SmokeShellSoundHit2",0.25,"SmokeShellSoundHit3",0.5}; + soundTrigger[] = {"SmokeShellSoundLoop1",0.5,"SmokeShellSoundLoop2",0.5}; + SmokeShellSoundHit1[] = {"A3\Sounds_F\weapons\smokeshell\smoke_1",1.25893,1,100}; + SmokeShellSoundHit2[] = {"A3\Sounds_F\weapons\smokeshell\smoke_2",1.25893,1,100}; + SmokeShellSoundHit3[] = {"A3\Sounds_F\weapons\smokeshell\smoke_3",1.25893,1,100}; + SmokeShellSoundLoop1[] = {"A3\Sounds_F\weapons\smokeshell\smoke_loop1",0.125893,1,70}; + SmokeShellSoundLoop2[] = {"A3\Sounds_F\weapons\smokeshell\smoke_loop2",0.125893,1,70}; + timeToLive = 60; + }; - class ACE_G_M84: F_20mm_Yellow { - useFlare = 0; - flareSize = 0; - intensity = 0; - grenadeBurningSound[] = {"SmokeShellSoundLoop1",0.5,"SmokeShellSoundLoop2",0.5}; - grenadeFireSound[] = {"SmokeShellSoundHit1",0.25,"SmokeShellSoundHit2",0.25,"SmokeShellSoundHit3",0.5}; - soundTrigger[] = {"SmokeShellSoundLoop1",0.5,"SmokeShellSoundLoop2",0.5}; - SmokeShellSoundHit1[] = {"A3\Sounds_F\weapons\smokeshell\smoke_1",1.25893,1,100}; - SmokeShellSoundHit2[] = {"A3\Sounds_F\weapons\smokeshell\smoke_2",1.25893,1,100}; - SmokeShellSoundHit3[] = {"A3\Sounds_F\weapons\smokeshell\smoke_3",1.25893,1,100}; - SmokeShellSoundLoop1[] = {"A3\Sounds_F\weapons\smokeshell\smoke_loop1",0.125893,1,70}; - SmokeShellSoundLoop2[] = {"A3\Sounds_F\weapons\smokeshell\smoke_loop2",0.125893,1,70}; - timeToLive = 60; - fuseDistance = 2.3; - model = PATHTOF(models\ACE_m84_thrown.p3d); - }; + class ACE_G_M84: F_20mm_Yellow { + useFlare = 0; + flareSize = 0; + intensity = 0; + grenadeBurningSound[] = {"SmokeShellSoundLoop1",0.5,"SmokeShellSoundLoop2",0.5}; + grenadeFireSound[] = {"SmokeShellSoundHit1",0.25,"SmokeShellSoundHit2",0.25,"SmokeShellSoundHit3",0.5}; + soundTrigger[] = {"SmokeShellSoundLoop1",0.5,"SmokeShellSoundLoop2",0.5}; + SmokeShellSoundHit1[] = {"A3\Sounds_F\weapons\smokeshell\smoke_1",1.25893,1,100}; + SmokeShellSoundHit2[] = {"A3\Sounds_F\weapons\smokeshell\smoke_2",1.25893,1,100}; + SmokeShellSoundHit3[] = {"A3\Sounds_F\weapons\smokeshell\smoke_3",1.25893,1,100}; + SmokeShellSoundLoop1[] = {"A3\Sounds_F\weapons\smokeshell\smoke_loop1",0.125893,1,70}; + SmokeShellSoundLoop2[] = {"A3\Sounds_F\weapons\smokeshell\smoke_loop2",0.125893,1,70}; + timeToLive = 60; + fuseDistance = 2.3; + model = PATHTOF(models\ACE_m84_thrown.p3d); + }; }; diff --git a/addons/grenades/CfgEventHandlers.hpp b/addons/grenades/CfgEventHandlers.hpp index 02f1ac5553..2587bdf86f 100644 --- a/addons/grenades/CfgEventHandlers.hpp +++ b/addons/grenades/CfgEventHandlers.hpp @@ -1,19 +1,19 @@ class Extended_PreInit_EventHandlers { - class ADDON { - init = QUOTE( call COMPILE_FILE(XEH_preInit) ); - }; + class ADDON { + init = QUOTE( call COMPILE_FILE(XEH_preInit) ); + }; }; class Extended_PostInit_EventHandlers { - class ADDON { - clientInit = QUOTE( call COMPILE_FILE(XEH_postInitClient) ); - }; + class ADDON { + init = QUOTE( call COMPILE_FILE(XEH_postInit) ); + }; }; class Extended_FiredBIS_EventHandlers { - class CAManBase { - class ADDON { - clientFiredBIS = QUOTE( _this call FUNC(throwGrenade) ); + class CAManBase { + class ADDON { + clientFiredBIS = QUOTE( _this call FUNC(throwGrenade) ); + }; }; - }; }; diff --git a/addons/grenades/CfgMagazines.hpp b/addons/grenades/CfgMagazines.hpp index 5775302d2c..33392f41ee 100644 --- a/addons/grenades/CfgMagazines.hpp +++ b/addons/grenades/CfgMagazines.hpp @@ -1,60 +1,60 @@ class CfgMagazines { - class HandGrenade; - class ACE_HandFlare_Base: HandGrenade { - value = 2; - nameSoundWeapon = "smokeshell"; - nameSound = "smokeshell"; - mass = 4; - initSpeed = 22; - }; - class ACE_HandFlare_White: ACE_HandFlare_Base { - ammo = "ACE_F_Hand_White"; - displayname = "$STR_ACE_Grenades_M127A1_White_Name"; - descriptionshort = "$STR_ACE_Grenades_M127A1_White_Description"; - displayNameShort = "$STR_ACE_Grenades_M127A1_White_NameShort"; - model = "\A3\weapons_f\ammo\flare_white"; - picture = "\A3\Weapons_F\Data\UI\gear_flare_white_ca.paa"; - }; - class ACE_HandFlare_Red: ACE_HandFlare_Base { - ammo = "ACE_F_Hand_Red"; - displayname = "$STR_ACE_Grenades_M127A1_Red_Name"; - descriptionshort = "$STR_ACE_Grenades_M127A1_Red_Description"; - displayNameShort = "$STR_ACE_Grenades_M127A1_Red_NameShort"; - model = "\A3\weapons_f\ammo\flare_red"; - picture = "\A3\Weapons_F\Data\UI\gear_flare_red_ca.paa"; - }; - class ACE_HandFlare_Green: ACE_HandFlare_Base { - ammo = "ACE_F_Hand_Green"; - displayname = "$STR_ACE_Grenades_M127A1_Green_Name"; - descriptionshort = "$STR_ACE_Grenades_M127A1_Green_Description"; - displayNameShort = "$STR_ACE_Grenades_M127A1_Green_NameShort"; - model = "\A3\weapons_f\ammo\flare_green"; - picture = "\A3\Weapons_F\Data\UI\gear_flare_green_ca.paa"; - }; - class ACE_HandFlare_Yellow: ACE_HandFlare_Base { - ammo = "ACE_F_Hand_Yellow"; - displayname = "$STR_ACE_Grenades_M127A1_Yellow_Name"; - descriptionshort = "$STR_ACE_Grenades_M127A1_Yellow_Description"; - displayNameShort = "$STR_ACE_Grenades_M127A1_Yellow_NameShort"; - model = "\A3\weapons_f\ammo\flare_yellow"; - picture = "\A3\Weapons_F\Data\UI\gear_flare_yellow_ca.paa"; - }; - class ACE_M84: HandGrenade { - ammo = "ACE_G_M84"; - displayname = "$STR_ACE_Grenades_M84_Name"; - descriptionshort = "$STR_ACE_Grenades_M84_Description"; - displayNameShort = "M84"; - model = PATHTOF(models\ACE_m84.p3d); - picture = PATHTOF(UI\ACE_m84_x_ca.paa); - }; + class HandGrenade; + class ACE_HandFlare_Base: HandGrenade { + value = 2; + nameSoundWeapon = "smokeshell"; + nameSound = "smokeshell"; + mass = 4; + initSpeed = 22; + }; + class ACE_HandFlare_White: ACE_HandFlare_Base { + ammo = "ACE_F_Hand_White"; + displayname = "$STR_ACE_Grenades_M127A1_White_Name"; + descriptionshort = "$STR_ACE_Grenades_M127A1_White_Description"; + displayNameShort = "$STR_ACE_Grenades_M127A1_White_NameShort"; + model = "\A3\weapons_f\ammo\flare_white"; + picture = "\A3\Weapons_F\Data\UI\gear_flare_white_ca.paa"; + }; + class ACE_HandFlare_Red: ACE_HandFlare_Base { + ammo = "ACE_F_Hand_Red"; + displayname = "$STR_ACE_Grenades_M127A1_Red_Name"; + descriptionshort = "$STR_ACE_Grenades_M127A1_Red_Description"; + displayNameShort = "$STR_ACE_Grenades_M127A1_Red_NameShort"; + model = "\A3\weapons_f\ammo\flare_red"; + picture = "\A3\Weapons_F\Data\UI\gear_flare_red_ca.paa"; + }; + class ACE_HandFlare_Green: ACE_HandFlare_Base { + ammo = "ACE_F_Hand_Green"; + displayname = "$STR_ACE_Grenades_M127A1_Green_Name"; + descriptionshort = "$STR_ACE_Grenades_M127A1_Green_Description"; + displayNameShort = "$STR_ACE_Grenades_M127A1_Green_NameShort"; + model = "\A3\weapons_f\ammo\flare_green"; + picture = "\A3\Weapons_F\Data\UI\gear_flare_green_ca.paa"; + }; + class ACE_HandFlare_Yellow: ACE_HandFlare_Base { + ammo = "ACE_F_Hand_Yellow"; + displayname = "$STR_ACE_Grenades_M127A1_Yellow_Name"; + descriptionshort = "$STR_ACE_Grenades_M127A1_Yellow_Description"; + displayNameShort = "$STR_ACE_Grenades_M127A1_Yellow_NameShort"; + model = "\A3\weapons_f\ammo\flare_yellow"; + picture = "\A3\Weapons_F\Data\UI\gear_flare_yellow_ca.paa"; + }; + class ACE_M84: HandGrenade { + ammo = "ACE_G_M84"; + displayname = "$STR_ACE_Grenades_M84_Name"; + descriptionshort = "$STR_ACE_Grenades_M84_Description"; + displayNameShort = "M84"; + model = PATHTOF(models\ACE_m84.p3d); + picture = PATHTOF(UI\ACE_m84_x_ca.paa); + }; - class 3Rnd_UGL_FlareGreen_F; - class 6Rnd_GreenSignal_F: 3Rnd_UGL_FlareGreen_F { - ammo = "F_40mm_Green"; - initSpeed = 120; - }; - class 6Rnd_RedSignal_F: 6Rnd_GreenSignal_F { - ammo = "F_40mm_Red"; - initSpeed = 120; - }; + class 3Rnd_UGL_FlareGreen_F; + class 6Rnd_GreenSignal_F: 3Rnd_UGL_FlareGreen_F { + ammo = "F_40mm_Green"; + initSpeed = 120; + }; + class 6Rnd_RedSignal_F: 6Rnd_GreenSignal_F { + ammo = "F_40mm_Red"; + initSpeed = 120; + }; }; diff --git a/addons/grenades/CfgVehicles.hpp b/addons/grenades/CfgVehicles.hpp index 9a0164e24f..d4ff039bf7 100644 --- a/addons/grenades/CfgVehicles.hpp +++ b/addons/grenades/CfgVehicles.hpp @@ -1,45 +1,45 @@ #define MACRO_ADDITEM(ITEM,COUNT) class _xx_##ITEM { \ - name = #ITEM; \ - count = COUNT; \ - }; + name = #ITEM; \ + count = COUNT; \ + }; class CfgVehicles { - class NATO_Box_Base; - class EAST_Box_Base; - class IND_Box_Base; - class Box_NATO_Support_F; + class NATO_Box_Base; + class EAST_Box_Base; + class IND_Box_Base; + class Box_NATO_Support_F; - class Box_NATO_Grenades_F: NATO_Box_Base { - class TransportItems { - MACRO_ADDITEM(ACE_HandFlare_White,12) - MACRO_ADDITEM(ACE_HandFlare_Green,12) - MACRO_ADDITEM(ACE_M84,12) + class Box_NATO_Grenades_F: NATO_Box_Base { + class TransportItems { + MACRO_ADDITEM(ACE_HandFlare_White,12) + MACRO_ADDITEM(ACE_HandFlare_Green,12) + MACRO_ADDITEM(ACE_M84,12) + }; }; - }; - class Box_East_Grenades_F: EAST_Box_Base { - class TransportItems { - MACRO_ADDITEM(ACE_HandFlare_Yellow,12) - MACRO_ADDITEM(ACE_HandFlare_Red,12) - MACRO_ADDITEM(ACE_M84,12) + class Box_East_Grenades_F: EAST_Box_Base { + class TransportItems { + MACRO_ADDITEM(ACE_HandFlare_Yellow,12) + MACRO_ADDITEM(ACE_HandFlare_Red,12) + MACRO_ADDITEM(ACE_M84,12) + }; }; - }; - class Box_IND_Grenades_F: IND_Box_Base { - class TransportItems { - MACRO_ADDITEM(ACE_HandFlare_Yellow,12) - MACRO_ADDITEM(ACE_HandFlare_Green,12) - MACRO_ADDITEM(ACE_M84,12) + class Box_IND_Grenades_F: IND_Box_Base { + class TransportItems { + MACRO_ADDITEM(ACE_HandFlare_Yellow,12) + MACRO_ADDITEM(ACE_HandFlare_Green,12) + MACRO_ADDITEM(ACE_M84,12) + }; }; - }; - class ACE_Box_Misc: Box_NATO_Support_F { - class TransportItems { - MACRO_ADDITEM(ACE_HandFlare_White,12) - MACRO_ADDITEM(ACE_HandFlare_Red,12) - MACRO_ADDITEM(ACE_HandFlare_Green,12) - MACRO_ADDITEM(ACE_HandFlare_Yellow,12) - MACRO_ADDITEM(ACE_M84,12) + class ACE_Box_Misc: Box_NATO_Support_F { + class TransportItems { + MACRO_ADDITEM(ACE_HandFlare_White,12) + MACRO_ADDITEM(ACE_HandFlare_Red,12) + MACRO_ADDITEM(ACE_HandFlare_Green,12) + MACRO_ADDITEM(ACE_HandFlare_Yellow,12) + MACRO_ADDITEM(ACE_M84,12) + }; }; - }; }; diff --git a/addons/grenades/CfgWeapons.hpp b/addons/grenades/CfgWeapons.hpp index fa28ca4ef0..4edc6e6d12 100644 --- a/addons/grenades/CfgWeapons.hpp +++ b/addons/grenades/CfgWeapons.hpp @@ -1,23 +1,23 @@ class CfgWeapons { - class GrenadeLauncher; + class GrenadeLauncher; - class Throw: GrenadeLauncher { - muzzles[] += {"ACE_HandFlare_WhiteMuzzle", "ACE_HandFlare_RedMuzzle", "ACE_HandFlare_GreenMuzzle", "ACE_HandFlare_YellowMuzzle", "ACE_M84Muzzle"}; - class ThrowMuzzle; - class ACE_HandFlare_WhiteMuzzle: ThrowMuzzle { - magazines[] = {"ACE_HandFlare_White"}; + class Throw: GrenadeLauncher { + muzzles[] += {"ACE_HandFlare_WhiteMuzzle", "ACE_HandFlare_RedMuzzle", "ACE_HandFlare_GreenMuzzle", "ACE_HandFlare_YellowMuzzle", "ACE_M84Muzzle"}; + class ThrowMuzzle; + class ACE_HandFlare_WhiteMuzzle: ThrowMuzzle { + magazines[] = {"ACE_HandFlare_White"}; + }; + class ACE_HandFlare_RedMuzzle: ThrowMuzzle { + magazines[] = {"ACE_HandFlare_Red"}; + }; + class ACE_HandFlare_GreenMuzzle: ThrowMuzzle { + magazines[] = {"ACE_HandFlare_Green"}; + }; + class ACE_HandFlare_YellowMuzzle: ThrowMuzzle { + magazines[] = {"ACE_HandFlare_Yellow"}; + }; + class ACE_M84Muzzle: ThrowMuzzle { + magazines[] = {"ACE_M84"}; + }; }; - class ACE_HandFlare_RedMuzzle: ThrowMuzzle { - magazines[] = {"ACE_HandFlare_Red"}; - }; - class ACE_HandFlare_GreenMuzzle: ThrowMuzzle { - magazines[] = {"ACE_HandFlare_Green"}; - }; - class ACE_HandFlare_YellowMuzzle: ThrowMuzzle { - magazines[] = {"ACE_HandFlare_Yellow"}; - }; - class ACE_M84Muzzle: ThrowMuzzle { - magazines[] = {"ACE_M84"}; - }; - }; }; diff --git a/addons/grenades/XEH_postInit.sqf b/addons/grenades/XEH_postInit.sqf new file mode 100644 index 0000000000..0b6bb16ffb --- /dev/null +++ b/addons/grenades/XEH_postInit.sqf @@ -0,0 +1,28 @@ +// by commy2 + +#include "script_component.hpp" + +["flashbangExplosion", {_this call FUNC(flashbangExplosionEH)}] call EFUNC(common,addEventHandler); + +if !(hasInterface) exitWith {}; + +GVAR(flashbangPPEffectCC) = ppEffectCreate ["ColorCorrections", 4265]; +GVAR(flashbangPPEffectCC) ppEffectForceInNVG true; + +// Add keybinds +["ACE3", + localize "STR_ACE_Grenades_SwitchGrenadeMode", + { + // Conditions: canInteract + _exceptions = [QEGVAR(captives,isNotEscorting)]; + if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; + // Conditions: specific + if (!([ACE_player] call EFUNC(common,canUseWeapon))) exitWith {false}; + + // Statement + [] call FUNC(nextMode); + }, + [9, [false, false, false]], //8 key + false, + "keydown" +] call cba_fnc_registerKeybind; diff --git a/addons/grenades/XEH_postInitClient.sqf b/addons/grenades/XEH_postInitClient.sqf deleted file mode 100644 index 5f5b569050..0000000000 --- a/addons/grenades/XEH_postInitClient.sqf +++ /dev/null @@ -1,13 +0,0 @@ -// by commy2 - -#include "script_component.hpp" - -GVAR(flashbangPPEffectCC) = ppEffectCreate ["ColorCorrections", 4265]; -GVAR(flashbangPPEffectCC) ppEffectForceInNVG true; - -["ACE3", -localize "STR_ACE_Grenades_SwitchGrenadeMode", -{_this call FUNC(nextMode)}, -[9, [false, false, false]], //8 key -false, -"keydown"] call cba_fnc_registerKeybind; diff --git a/addons/grenades/XEH_preInit.sqf b/addons/grenades/XEH_preInit.sqf index 569cbfa8f6..0df2e235fd 100644 --- a/addons/grenades/XEH_preInit.sqf +++ b/addons/grenades/XEH_preInit.sqf @@ -2,12 +2,9 @@ ADDON = false; -PREP(flashbangEffectStages); PREP(flashbangExplosionEH); PREP(flashbangThrownFuze); PREP(nextMode); PREP(throwGrenade); -["flashbangExplosion", { _this call DFUNC(flashbangExplosionEH) }] call EFUNC(common,addEventHandler); - ADDON = true; diff --git a/addons/grenades/config.cpp b/addons/grenades/config.cpp index 74d1038ecc..c2a899d66c 100644 --- a/addons/grenades/config.cpp +++ b/addons/grenades/config.cpp @@ -1,15 +1,15 @@ #include "script_component.hpp" class CfgPatches { - class ADDON { - units[] = {}; - weapons[] = {}; - requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ace_common"}; - author[] = {"commy2", "KoffeinFlummi"}; - authorUrl = "https://github.com/commy2/"; - VERSION_CONFIG; - }; + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common"}; + author[] = {"commy2", "KoffeinFlummi"}; + authorUrl = "https://github.com/commy2/"; + VERSION_CONFIG; + }; }; #include "CfgEventHandlers.hpp" diff --git a/addons/grenades/functions/fnc_flashbangEffectStages.sqf b/addons/grenades/functions/fnc_flashbangEffectStages.sqf deleted file mode 100644 index c2ee7a6841..0000000000 --- a/addons/grenades/functions/fnc_flashbangEffectStages.sqf +++ /dev/null @@ -1,57 +0,0 @@ -/* -* Author: KoffeinFlummi, Pabst Mirror -* -* Handles the different stages of the flash bang effect recovery -* -* Arguments: -* ARRAY[ -* 0-ARRAY - PARAMS: -* 0: NUMBER - Stage, controls a case statement -* 1: NUMBER - Time To Wait Until -* 2: VARIES - Stage's Variable -* 1-NUMBER perFrame handle -* Return Value: -* None -*/ - -#include "script_component.hpp" - -private ["_stage", "_waitUntilTime"]; - -_stage = (_this select 0) select 0; -_waitUntilTime = (_this select 0) select 1; - -if (_waitUntilTime > time) exitWith {}; - -//remove frameEH -[(_this select 1)] call cba_fnc_removePerFrameHandler; - -switch (_stage) do { - case(EFFECT_STAGE_RESETAI): { - private "_unit"; - _unit = (_this select 0) select 2; - _unit enableAI "MOVE"; - _unit enableAI "ANIM"; - _unit enableAI "AUTOTARGET"; - _unit enableAI "TARGET"; - _unit enableAI "FSM"; - _unit setSkill (skill _unit * 50); - }; - case(EFFECT_STAGE_DELETELIGHT): { - private "_light"; - _light = (_this select 0) select 2; - deleteVehicle _light; - }; - case(EFFECT_STAGE_PARTIALRECOVERY): { - private "_strength"; - _strength = (_this select 0) select 2; - GVAR(flashbangPPEffectCC) ppEffectAdjust [1,1,0,[1,1,1,0],[0,0,0,1],[0,0,0,0]]; - GVAR(flashbangPPEffectCC) ppEffectCommit (10 * _strength); - }; - case(EFFECT_STAGE_FULLRECOVERY): { - GVAR(flashbangPPEffectCC) ppEffectEnable false; - }; - default { - TRACE_1("EffectStage Bad Stage", _stage); - }; -}; diff --git a/addons/grenades/functions/fnc_flashbangExplosionEH.sqf b/addons/grenades/functions/fnc_flashbangExplosionEH.sqf index 1ef7ea1484..3868994bee 100644 --- a/addons/grenades/functions/fnc_flashbangExplosionEH.sqf +++ b/addons/grenades/functions/fnc_flashbangExplosionEH.sqf @@ -1,85 +1,109 @@ /* -* Author: KoffeinFlummi -* -* Creates the flashbang effect and knock out AI units. -* -* Arguments: -* 0: The grenade (Object) -* -* Return Value: -* None -*/ - + * Author: KoffeinFlummi + * Creates the flashbang effect and knock out AI units. + * + * Arguments: + * 0: The grenade + * + * Return Value: + * Nothing + * + * Example: + * [theGrenade] call ace_grenades_fnc_flashbangExplosionEH + * + * Public: No + */ #include "script_component.hpp" -private ["_grenade", "_affected", "_strength", "_posGrenade", "_posUnit", "_angleGrenade", "_angleView", "_angleDiff", "_light"]; +private ["_affected", "_strength", "_posGrenade", "_posUnit", "_angleGrenade", "_angleView", "_angleDiff", "_light"]; -_grenade = _this select 0; +PARAMS_1(_grenade); _affected = _grenade nearEntities ["CAManBase", 50]; { - if ((local _x) && {alive _x}) then { + if ((local _x) && {alive _x}) then { - _strength = 1 - ((_x distance _grenade) min 15) / 15; + _strength = 1 - ((_x distance _grenade) min 15) / 15; - if (_x != ACE_player) then { - //must be AI - _x disableAI "MOVE"; - _x disableAI "ANIM"; - _x disableAI "AUTOTARGET"; - _x disableAI "TARGET"; - _x disableAI "FSM"; - _x setSkill ((skill _x) / 50); + if (_x != ACE_player) then { + //must be AI + _x disableAI "MOVE"; + _x disableAI "ANIM"; + _x disableAI "AUTOTARGET"; + _x disableAI "TARGET"; + _x disableAI "FSM"; + _x setSkill ((skill _x) / 50); - [FUNC(flashbangEffectStages), 0, [EFFECT_STAGE_RESETAI, (time + (7 * _strength)), _x]] call CBA_fnc_addPerFrameHandler; - } else { - //Do effects for player - // is there line of sight to the grenade? - _posGrenade = getPosASL _grenade; - _posGrenade set [2, (_posGrenade select 2) + 0.2]; // compensate for grenade glitching into ground - if (lineIntersects [_posGrenade, getPosASL _x, _grenade, _x]) then { - _strength = _strength / 10; - }; + [{ + PARAMS_1(_unit); + _unit enableAI "MOVE"; + _unit enableAI "ANIM"; + _unit enableAI "AUTOTARGET"; + _unit enableAI "TARGET"; + _unit enableAI "FSM"; + _unit setSkill (skill _unit * 50); + }, [_x], (7 * _strength), 0.1] call EFUNC(common,waitAndExecute); //0.1 precision is fine for AI + } else { + //Do effects for player + // is there line of sight to the grenade? + _posGrenade = getPosASL _grenade; + _posGrenade set [2, (_posGrenade select 2) + 0.2]; // compensate for grenade glitching into ground + if (lineIntersects [_posGrenade, getPosASL _x, _grenade, _x]) then { + _strength = _strength / 10; + }; - // beeeeeeeeeeeeeeeeeeeeeeeeeeeeep - if (isClass (configFile >> "CfgPatches" >> "ACE_Hearing") and _strength > 0) then { - [_x, 0.5 + (_strength / 2)] call EFUNC(hearing,earRinging); - }; + // beeeeeeeeeeeeeeeeeeeeeeeeeeeeep + if (isClass (configFile >> "CfgPatches" >> "ACE_Hearing") and _strength > 0) then { + [_x, 0.5 + (_strength / 2)] call EFUNC(hearing,earRinging); + }; - // account for people looking away by slightly - // reducing the effect for visual effects. - _posUnit = getPos _x; - _posGrenade = getPos _grenade; - _angleGrenade = ((_posGrenade select 0) - (_posUnit select 0)) atan2 ((_posGrenade select 1) - (_posUnit select 1)); - _angleGrenade = (_angleGrenade + 360) % 360; + // account for people looking away by slightly + // reducing the effect for visual effects. + _posUnit = getPos _x; + _posGrenade = getPos _grenade; + _angleGrenade = ((_posGrenade select 0) - (_posUnit select 0)) atan2 ((_posGrenade select 1) - (_posUnit select 1)); + _angleGrenade = (_angleGrenade + 360) % 360; - _angleView = (eyeDirection player select 0) atan2 (eyeDirection player select 1); - _angleView = (_angleView + 360) % 360; + _angleView = (eyeDirection ACE_player select 0) atan2 (eyeDirection ACE_player select 1); + _angleView = (_angleView + 360) % 360; - _angleDiff = 180 - abs (abs (_angleGrenade - _angleView) - 180); - _angleDiff = ((_angleDiff - 45) max 0); + _angleDiff = 180 - abs (abs (_angleGrenade - _angleView) - 180); + _angleDiff = ((_angleDiff - 45) max 0); - _strength = _strength - _strength * (_angleDiff / 135); + _strength = _strength - _strength * (_angleDiff / 135); - // create flash to illuminate environment - _light = "#lightpoint" createVehicleLocal getPos _grenade; - _light setLightBrightness 200; - _light setLightAmbient [1,1,1]; - _light setLightColor [1,1,1]; - _light setLightDayLight true; + // create flash to illuminate environment + _light = "#lightpoint" createVehicleLocal (getPos _grenade); + _light setLightBrightness 200; + _light setLightAmbient [1,1,1]; + _light setLightColor [1,1,1]; + _light setLightDayLight true; - [FUNC(flashbangEffectStages), 0, [EFFECT_STAGE_DELETELIGHT, (time + (0.1)), _light]] call CBA_fnc_addPerFrameHandler; + //Delete the light after 0.1 seconds + [{ + PARAMS_1(_light); + deleteVehicle _light; + }, [_light], 0.1, 0] call EFUNC(common,waitAndExecute); - // blind player - if (_strength > 0.1) then { - GVAR(flashbangPPEffectCC) ppEffectEnable true; - GVAR(flashbangPPEffectCC) ppEffectAdjust [1,1,(0.8 + _strength) min 1,[1,1,1,0],[0,0,0,1],[0,0,0,0]]; - GVAR(flashbangPPEffectCC) ppEffectCommit 0.01; + // blind player + if (_strength > 0.1) then { + GVAR(flashbangPPEffectCC) ppEffectEnable true; + GVAR(flashbangPPEffectCC) ppEffectAdjust [1,1,(0.8 + _strength) min 1,[1,1,1,0],[0,0,0,1],[0,0,0,0]]; + GVAR(flashbangPPEffectCC) ppEffectCommit 0.01; - [FUNC(flashbangEffectStages), 0, [EFFECT_STAGE_PARTIALRECOVERY, (time + (7 * _strength)), _strength]] call CBA_fnc_addPerFrameHandler; - [FUNC(flashbangEffectStages), 0, [ EFFECT_STAGE_FULLRECOVERY, (time + (17 * _strength))]] call CBA_fnc_addPerFrameHandler; - }; + //PARTIALRECOVERY - start decreasing effect over time + [{ + PARAMS_1(_strength); + GVAR(flashbangPPEffectCC) ppEffectAdjust [1,1,0,[1,1,1,0],[0,0,0,1],[0,0,0,0]]; + GVAR(flashbangPPEffectCC) ppEffectCommit (10 * _strength); + }, [_strength], (7 * _strength), 0] call EFUNC(common,waitAndExecute); + + //FULLRECOVERY - end effect + [{ + GVAR(flashbangPPEffectCC) ppEffectEnable false; + }, [], (17 * _strength), 0] call EFUNC(common,waitAndExecute); + }; + }; }; - }; } forEach _affected; diff --git a/addons/grenades/functions/fnc_flashbangThrownFuze.sqf b/addons/grenades/functions/fnc_flashbangThrownFuze.sqf index aec10301ab..a83c81e660 100644 --- a/addons/grenades/functions/fnc_flashbangThrownFuze.sqf +++ b/addons/grenades/functions/fnc_flashbangThrownFuze.sqf @@ -1,18 +1,25 @@ -//Waits for the grenade fuze to trigger and 'explode' - +/* + * Author: commy2 + * Waits for the flashbang grenade fuze to trigger and 'explode' + * + * Arguments: + * 0: projectile - Flashbang Grenade + * + * Return Value: + * Nothing + * + * Example: + * [theFlashbang] call ace_grenades_fnc_flashbangThrownFuze + * + * Public: No + */ #include "script_component.hpp" -_projectile = (_this select 0) select 0; -_waitUntilTime = (_this select 0) select 1; - -if (_waitUntilTime > time) exitWith {}; - -//remove frameEH -[(_this select 1)] call cba_fnc_removePerFrameHandler; +PARAMS_1(_projectile); if (alive _projectile) then { - playSound3D ["A3\Sounds_F\weapons\Explosion\explosion_mine_1.wss", _projectile, false, getPosASL _projectile, 5, 1.2, 400]; - - _affected = _projectile nearEntities ["CAManBase", 50]; - ["flashbangExplosion", _affected, [_projectile]] call EFUNC(common,targetEvent); + playSound3D ["A3\Sounds_F\weapons\Explosion\explosion_mine_1.wss", _projectile, false, getPosASL _projectile, 5, 1.2, 400]; + + _affected = _projectile nearEntities ["CAManBase", 50]; + ["flashbangExplosion", _affected, [_projectile]] call EFUNC(common,targetEvent); }; diff --git a/addons/grenades/functions/fnc_nextMode.sqf b/addons/grenades/functions/fnc_nextMode.sqf index da8392b6ab..7663e790f6 100644 --- a/addons/grenades/functions/fnc_nextMode.sqf +++ b/addons/grenades/functions/fnc_nextMode.sqf @@ -1,40 +1,41 @@ /* * Author: commy2 - * * Select the next throwing mode and display message. - * - * Argument: - * Nothing - * - * Return value: + * + * Arguments: * Nothing + * + * Return Value: + * Handeled + * + * Example: + * [] call ace_grenades_fnc_nextMode + * + * Public: No */ - #include "script_component.hpp" - -private ["_mode", "_hint"]; -if (!([ACE_player] call EFUNC(common,canUseWeapon))) exitWith {false}; +private ["_mode", "_hint"]; _mode = missionNamespace getVariable [QGVAR(currentThrowMode), 0]; if (_mode == 4) then { - _mode = 0; + _mode = 0; } else { - _mode = _mode + 1; + _mode = _mode + 1; }; // ROLL GRENADE DOESN'T WORK RIGHT NOW if (_mode == 3) then { - _mode = 4; + _mode = 4; }; _hint = [ - localize "STR_ACE_Grenades_NormalThrow", - localize "STR_ACE_Grenades_HighThrow", - localize "STR_ACE_Grenades_PreciseThrow", - localize "STR_ACE_Grenades_RollGrenade", - localize "STR_ACE_Grenades_DropGrenade" +localize "STR_ACE_Grenades_NormalThrow", +localize "STR_ACE_Grenades_HighThrow", +localize "STR_ACE_Grenades_PreciseThrow", +localize "STR_ACE_Grenades_RollGrenade", +localize "STR_ACE_Grenades_DropGrenade" ] select _mode; [_hint] call EFUNC(common,displayTextStructured); diff --git a/addons/grenades/functions/fnc_throwGrenade.sqf b/addons/grenades/functions/fnc_throwGrenade.sqf index e725ebd426..c7bc09a261 100644 --- a/addons/grenades/functions/fnc_throwGrenade.sqf +++ b/addons/grenades/functions/fnc_throwGrenade.sqf @@ -1,15 +1,24 @@ /* -* Author: commy2 -* -* Adjust the grenades throwing direction and speed to the selected throwing mode. -* -* Argument: -* input from "Fired" eventhandler -* -* Return value: -* Nothing -*/ - + * Author: commy2 + * Adjust the grenades throwing direction and speed to the selected throwing mode. + * + * Arguments: + * 0: unit - Object the event handler is assigned to + * 1: weapon - Fired weapon + * 2: muzzle - Muzzle that was used + * 3: mode - Current mode of the fired weapon + * 4: ammo - Ammo used + * 5: magazine - magazine name which was used + * 6: projectile - Object of the projectile that was shot + * + * Return Value: + * Nothing + * + * Example: + * [clientFiredBIS-XEH] call ace_grenades_fnc_throwGrenade + * + * Public: No + */ #include "script_component.hpp" private ["_unit", "_weapon", "_projectile", "_mode", "_fuzeTime"]; @@ -24,38 +33,38 @@ if (_weapon != "Throw") exitWith {}; _mode = missionNamespace getVariable [QGVAR(currentThrowMode), 0]; if (_mode != 0) then { - private "_velocity"; + private "_velocity"; - _velocity = velocity _projectile; + _velocity = velocity _projectile; - switch (_mode) do { - //high throw - case 1 : { - _velocity = [ - 0.5 * (_velocity select 0), - 0.5 * (_velocity select 1), - [0, 0, 0] distance (_velocity vectorMultiply 0.5) - ]; + switch (_mode) do { + //high throw + case 1 : { + _velocity = [ + 0.5 * (_velocity select 0), + 0.5 * (_velocity select 1), + [0, 0, 0] distance (_velocity vectorMultiply 0.5) + ]; + }; + //precise throw + case 2 : { + _velocity = (_unit weaponDirection _weapon) vectorMultiply (vectorMagnitude _velocity); + }; + //roll grande + case 3 : { + //@todo + }; + //drop grenade + case 4 : { + _velocity = [0, 0, 0]; + }; }; - //precise throw - case 2 : { - _velocity = (_unit weaponDirection _weapon) vectorMultiply (vectorMagnitude _velocity); - }; - //roll grande - case 3 : { - //@todo - }; - //drop grenade - case 4 : { - _velocity = [0, 0, 0]; - }; - }; - _projectile setVelocity _velocity; + _projectile setVelocity _velocity; }; if (typeOf _projectile == "ACE_G_M84") then { - _fuzeTime = getNumber (configFile >> "CfgAmmo" >> typeOf _projectile >> "fuseDistance"); - // _fuzeTime = getNumber (configFile >> "CfgAmmo" >> typeOf _projectile >> "explosionTime"); //@toDo pretty sure this should be explosionTime not fuseDistance - [FUNC(flashbangThrownFuze), 0, [_projectile, (time + _fuzeTime)]] call CBA_fnc_addPerFrameHandler; + _fuzeTime = getNumber (configFile >> "CfgAmmo" >> typeOf _projectile >> "fuseDistance"); + // _fuzeTime = getNumber (configFile >> "CfgAmmo" >> typeOf _projectile >> "explosionTime"); //@toDo pretty sure this should be explosionTime not fuseDistance + [FUNC(flashbangThrownFuze), [_projectile], _fuzeTime, 0] call EFUNC(common,waitAndExecute); }; diff --git a/addons/hearing/config.cpp b/addons/hearing/config.cpp index 708146a89b..4499e647f6 100644 --- a/addons/hearing/config.cpp +++ b/addons/hearing/config.cpp @@ -22,9 +22,11 @@ class CfgPatches { #include "CfgAmmo.hpp" -class ACE_Options { - class GVAR(Hearing_DisableEarRinging) { - displayName = "$STR_ACE_Hearing_DisableEarRinging"; - default = 0; - }; +class ACE_Settings { + class GVAR(DisableEarRinging) { + default = 1; + typeName = "BOOL"; + isClientSetable = 1; + displayName = "$STR_ACE_Hearing_DisableEarRinging"; + }; }; \ No newline at end of file diff --git a/addons/hearing/functions/fnc_earRinging.sqf b/addons/hearing/functions/fnc_earRinging.sqf index 9279b6b954..4581a6fdd9 100644 --- a/addons/hearing/functions/fnc_earRinging.sqf +++ b/addons/hearing/functions/fnc_earRinging.sqf @@ -25,7 +25,7 @@ GVAR(newStrength) = GVAR(newStrength) max _strength; if (missionNamespace getVariable [QGVAR(isEarRingingPlaying), false]) exitWith {}; -if (profileNamespace getVariable [QGVAR(DisableEarRinging), false]) exitWith {}; +if (GVAR(DisableEarRinging)) exitWith {}; if (_strength > 0.75) exitWith { playSound "ACE_EarRinging_Heavy"; diff --git a/addons/interaction/XEH_clientInit.sqf b/addons/interaction/XEH_clientInit.sqf index bcc3f47def..047e528ad6 100644 --- a/addons/interaction/XEH_clientInit.sqf +++ b/addons/interaction/XEH_clientInit.sqf @@ -20,7 +20,7 @@ GVAR(isOpeningDoor) = false; localize "STR_ACE_Interaction_InteractionMenu", { // Conditions: canInteract - _exceptions = ["ACE_Drag_isNotDragging", "ACE_Medical_canTreat", "ACE_Interaction_isNotEscorting", "ACE_Interaction_isNotSwimming"]; + _exceptions = ["ACE_Drag_isNotDragging", "ACE_Medical_canTreat", QEGVAR(captives,isNotEscorting), "ACE_Interaction_isNotSwimming"]; if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; // Conditions: specific if !(isNull (findDisplay 1713999)) exitWith {false}; @@ -38,10 +38,10 @@ GVAR(isOpeningDoor) = false; localize "STR_ACE_Interaction_InteractionMenu", { // Conditions: canInteract - _exceptions = ["ACE_Drag_isNotDragging", "ACE_Medical_canTreat", "ACE_Interaction_isNotEscorting", "ACE_Interaction_isNotSwimming"]; + _exceptions = ["ACE_Drag_isNotDragging", "ACE_Medical_canTreat", QEGVAR(captives,isNotEscorting), "ACE_Interaction_isNotSwimming"]; if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; // Conditions: specific - if !(!isNull (findDisplay 1713999) && {profileNamespace getVariable [QGVAR(AutoCloseMenu), 0] > 0}) exitWith {false}; + if !(!isNull (findDisplay 1713999) && {QGVAR(AutoCloseMenu)}) exitWith {false}; // Statement if (GVAR(MenuType) mod 2 == 0) then {call FUNC(onButtonUp)}; @@ -56,7 +56,7 @@ GVAR(isOpeningDoor) = false; localize "STR_ACE_Interaction_InteractionMenuSelf", { // Conditions: canInteract - _exceptions = ["ACE_Drag_isNotDragging", "ACE_Medical_canTreat", "ACE_Interaction_isNotEscorting", "ACE_Interaction_isNotSwimming", "ACE_Common_notOnMap"]; + _exceptions = ["ACE_Drag_isNotDragging", "ACE_Medical_canTreat", QEGVAR(captives,isNotEscorting), QEGVAR(captives,isNotSurrendering), "ACE_Interaction_isNotSwimming", "ACE_Common_notOnMap"]; if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; // Conditions: specific if !(isNull (findDisplay 1713999)) exitWith {false}; @@ -74,10 +74,10 @@ GVAR(isOpeningDoor) = false; localize "STR_ACE_Interaction_InteractionMenuSelf", { // Conditions: canInteract - _exceptions = ["ACE_Drag_isNotDragging", "ACE_Medical_canTreat", "ACE_Interaction_isNotEscorting", "ACE_Interaction_isNotSwimming"]; + _exceptions = ["ACE_Drag_isNotDragging", "ACE_Medical_canTreat", QEGVAR(captives,isNotEscorting), QEGVAR(captives,isNotSurrendering), "ACE_Interaction_isNotSwimming"]; if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; // Conditions: specific - if !(!isNull (findDisplay 1713999) && {profileNamespace getVariable [QGVAR(AutoCloseMenu), 0] > 0}) exitWith {false}; + if !(!isNull (findDisplay 1713999) && {QGVAR(AutoCloseMenu)}) exitWith {false}; // Statement if (GVAR(MenuType) mod 2 == 1) then {call FUNC(onButtonUp)}; diff --git a/addons/interaction/config.cpp b/addons/interaction/config.cpp index acb41d362f..90db08e9e2 100644 --- a/addons/interaction/config.cpp +++ b/addons/interaction/config.cpp @@ -18,35 +18,32 @@ class CfgPatches { #include -class ACE_Options { - class Interaction_FlowMenu { +class ACE_Settings { + class GVAR(FlowMenu) { + value = 0; + typeName = "BOOL"; + isClientSetable = 1; displayName = "$STR_ACE_Interaction_FlowMenu"; - default = 0; }; - class Interaction_AutoCloseMenu { + class GVAR(AutoCloseMenu) { + value = 0; + typeName = "BOOL"; + isClientSetable = 1; displayName = "$STR_ACE_Interaction_AutoCloseMenu"; - default = 0; }; - class Interaction_AutoCenterCursor { + class GVAR(AutoCenterCursor) { + value = 1; + typeName = "BOOL"; + isClientSetable = 1; displayName = "$STR_ACE_Interaction_AutoCenterCursor"; - default = 1; }; -}; - -class ACE_Parameters_Boolean { - ACE_Interaction_EnableTeamManagement = 1; + class GVAR(EnableTeamManagement) { + value = 1; + typeName = "BOOL"; + }; }; class ACE_canInteractConditions { - class GVAR(isNotEscorting) { - condition = QUOTE( !(ACE_player getVariable [ARR_2('ACE_isEscorting', false)]) ); - }; - class GVAR(isNotCaptive) { - condition = QUOTE( !(ACE_player getVariable [ARR_2('ACE_isCaptive', false)]) ); - }; - class GVAR(isNotSurrendering) { - condition = QUOTE( !(ACE_player getVariable [ARR_2('ACE_isSurrender', false)]) ); - }; class GVAR(isNotSwimming) { condition = QUOTE( !underwater ACE_player ); }; diff --git a/addons/interaction/functions/fnc_getActions2.sqf b/addons/interaction/functions/fnc_getActions2.sqf index ab64d8d390..0de4f7a534 100644 --- a/addons/interaction/functions/fnc_getActions2.sqf +++ b/addons/interaction/functions/fnc_getActions2.sqf @@ -66,7 +66,7 @@ _cacheIndices = _cache select 2; _statement = getText (_action >> "statement"); _statement = compile _statement; - if (profileNamespace getVariable ["ACE_Interaction_FlowMenu", false]) then { + if (GVAR(FlowMenu)) then { _statement = if (getText (_action >> "statement") == "" && {count _subMenu > 1}) then { compile format [QUOTE( call FUNC(hideMenu);if(%2 == 1)then{['%1'] call FUNC(openSubMenuSelf);}else{['%1'] call FUNC(openSubMenu);}; ), _subMenu select 0, _subMenu select 1]; } else { diff --git a/addons/interaction/functions/fnc_initialiseInteraction.sqf b/addons/interaction/functions/fnc_initialiseInteraction.sqf index 2637d28bf9..4d88eb4ea1 100644 --- a/addons/interaction/functions/fnc_initialiseInteraction.sqf +++ b/addons/interaction/functions/fnc_initialiseInteraction.sqf @@ -67,7 +67,7 @@ if (_this select 2) then { disableSerialization; _dlgInteractionDialog = uiNamespace getVariable QGVAR(Dialog); _ctrlInteractionDialog = _dlgInteractionDialog displayCtrl 3; - if (profileNamespace getVariable [QGVAR(AutoCenterCursor), true]) then {setMousePosition [0.5, 0.5]}; + if (GVAR(AutoCenterCursor)) then {setMousePosition [0.5, 0.5]}; if !(_subMenu) then { _ctrlInteractionDialog ctrlSetText ([_target] call EFUNC(common,getName)); } else { diff --git a/addons/interaction/functions/fnc_moduleInteraction.sqf b/addons/interaction/functions/fnc_moduleInteraction.sqf index 78fd6e2acc..37b7bacba5 100644 --- a/addons/interaction/functions/fnc_moduleInteraction.sqf +++ b/addons/interaction/functions/fnc_moduleInteraction.sqf @@ -16,6 +16,6 @@ _activated = _this select 2; if !(_activated) exitWith {}; -[_logic, QGVAR(EnableTeamManagement), "EnableTeamManagement"] call EFUNC(common,readBooleanParameterFromModule); +[_logic, QGVAR(EnableTeamManagement), "EnableTeamManagement"] call EFUNC(common,readSettingFromModule); diag_log text "[ACE]: Interaction Module Initialized."; diff --git a/addons/laser_selfdesignate/CfgEventhandlers.hpp b/addons/laser_selfdesignate/CfgEventhandlers.hpp index 74deb4bcf6..ea33d05bcb 100644 --- a/addons/laser_selfdesignate/CfgEventhandlers.hpp +++ b/addons/laser_selfdesignate/CfgEventhandlers.hpp @@ -1,27 +1,27 @@ class Extended_PreInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_pre_init)); - }; + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_pre_init)); + }; }; class Extended_PostInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_post_init)); - }; + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_post_init)); + }; }; class Extended_GetIn_EventHandlers { - class B_Heli_Attack_01_F { - class ADDON { - getIn = QUOTE(call FUNC(onGetin)); - }; - }; + class B_Heli_Attack_01_F { + class ADDON { + getIn = QUOTE(call FUNC(onGetin)); + }; + }; }; class Extended_GetOut_EventHandlers { - class B_Heli_Attack_01_F { - class ADDON { - getOut = QUOTE(call FUNC(onGetout)); - }; - }; + class B_Heli_Attack_01_F { + class ADDON { + getOut = QUOTE(call FUNC(onGetout)); + }; + }; }; diff --git a/addons/laser_selfdesignate/CfgUI.hpp b/addons/laser_selfdesignate/CfgUI.hpp index 11fab908d7..e8823e04f8 100644 --- a/addons/laser_selfdesignate/CfgUI.hpp +++ b/addons/laser_selfdesignate/CfgUI.hpp @@ -4,29 +4,29 @@ class RscControlsGroupNoScrollbars; /* This disables air radar. We need to make this a seperate HUD addon class RscInGameUI { - class RscUnitInfo - { - class CA_Radar: RscControlsGroupNoScrollbars - { - class controls - { - class CA_RadarBackground: RscPicture { - colorText[] = {0,0,0,0}; - text = ""; - }; - class CA_RadarIcon: RscPicture { - colorText[] = {0,0,0,0}; - }; - class CA_Heading: RscText { - colorText[] = {0,0,0,0}; - }; - }; - }; - }; + class RscUnitInfo + { + class CA_Radar: RscControlsGroupNoScrollbars + { + class controls + { + class CA_RadarBackground: RscPicture { + colorText[] = {0,0,0,0}; + text = ""; + }; + class CA_RadarIcon: RscPicture { + colorText[] = {0,0,0,0}; + }; + class CA_Heading: RscText { + colorText[] = {0,0,0,0}; + }; + }; + }; + }; }; class CfgInGameUI { - + }; */ \ No newline at end of file diff --git a/addons/laser_selfdesignate/CfgVehicles.hpp b/addons/laser_selfdesignate/CfgVehicles.hpp index eed000544c..5b2fdd7d28 100644 --- a/addons/laser_selfdesignate/CfgVehicles.hpp +++ b/addons/laser_selfdesignate/CfgVehicles.hpp @@ -1,35 +1,30 @@ class CfgVehicles { - class AllVehicles; - - class Air: AllVehicles { - class Turrets; - }; - class Helicopter: Air - { - class Turrets: Turrets { - class MainTurret; - }; - // TODO: move these to a different HUD addon - // commanderCanSee = 2+32; - // gunnerCanSee = 2+32; - // driverCanSee = 2+32; + class AllVehicles; + class Air: AllVehicles { + class Turrets; + }; - }; - class Helicopter_Base_F: Helicopter { - class Turrets: Turrets { - class MainTurret: MainTurret {}; - }; - }; - class Heli_Attack_01_base_F: Helicopter_Base_F { - class Turrets: Turrets { - class MainTurret: MainTurret {}; - }; - }; - class B_Heli_Attack_01_F: Heli_Attack_01_base_F { - class Turrets: Turrets { - class MainTurret: MainTurret { - stabilizedInAxes = 4; // This stablizes the turret a bit more for laser designation - }; - }; - }; -}; \ No newline at end of file + class Helicopter: Air { + class Turrets { + class MainTurret; + }; + + // TODO: move these to a different HUD addon + // commanderCanSee = 2+32; + // gunnerCanSee = 2+32; + // driverCanSee = 2+32; + + }; + + class Helicopter_Base_F: Helicopter {}; + + class Heli_Attack_01_base_F: Helicopter_Base_F {}; + + class B_Heli_Attack_01_F: Heli_Attack_01_base_F { + class Turrets: Turrets { + class MainTurret: MainTurret { + stabilizedInAxes = 4; // This stablizes the turret a bit more for laser designation + }; + }; + }; +}; diff --git a/addons/laser_selfdesignate/CfgWeapons.hpp b/addons/laser_selfdesignate/CfgWeapons.hpp index a966144b10..a62974ce40 100644 --- a/addons/laser_selfdesignate/CfgWeapons.hpp +++ b/addons/laser_selfdesignate/CfgWeapons.hpp @@ -1,10 +1,11 @@ class CfgWeapons { - class LauncherCore; - - class RocketPods: LauncherCore { - canLock = 1; // Disable locking unless newb mode - }; - class missiles_DAGR: RocketPods { - canLock = 1; // Disable locking unless newb mode - }; -}; \ No newline at end of file + // Disable locking unless newb mode + class LauncherCore; + class RocketPods: LauncherCore { + canLock = 1; + }; + + class missiles_DAGR: RocketPods { + canLock = 1; + }; +}; diff --git a/addons/laser_selfdesignate/config.cpp b/addons/laser_selfdesignate/config.cpp index 5452ee4e22..e19e438da0 100644 --- a/addons/laser_selfdesignate/config.cpp +++ b/addons/laser_selfdesignate/config.cpp @@ -1,17 +1,17 @@ #include "script_component.hpp" class CfgPatches { - class ADDON { - units[] = {}; - weapons[] = {}; - requiredVersion = REQUIRED_VERSION; - requiredAddons[] = { "ace_main", "ace_laser" }; - version = VERSION; - }; + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_main", "ace_laser"}; + version = VERSION; + }; }; #include "CfgUI.hpp" #include "CfgEventhandlers.hpp" #include "CfgWeapons.hpp" -#include "CfgVehicles.hpp" \ No newline at end of file +#include "CfgVehicles.hpp" diff --git a/addons/logistics_uavbattery/CfgSounds.hpp b/addons/logistics_uavbattery/CfgSounds.hpp new file mode 100644 index 0000000000..530c5b86a9 --- /dev/null +++ b/addons/logistics_uavbattery/CfgSounds.hpp @@ -0,0 +1,7 @@ +class CfgSounds { + class ACE_replaceUAVBattery { + name = "ACE_replaceUAVBattery"; + sound[]={QUOTE(PATHTOF(sounds\exchange_battery.ogg)),1,1}; + titles[]={}; + }; +}; diff --git a/addons/logistics_uavbattery/config.cpp b/addons/logistics_uavbattery/config.cpp index 046a2665d0..32d8c49978 100644 --- a/addons/logistics_uavbattery/config.cpp +++ b/addons/logistics_uavbattery/config.cpp @@ -15,3 +15,4 @@ class CfgPatches { #include "CfgEventHandlers.hpp" #include "CfgVehicles.hpp" #include "CfgWeapons.hpp" +#include "CfgSounds.hpp" diff --git a/addons/logistics_uavbattery/functions/fnc_canRefuelUAV.sqf b/addons/logistics_uavbattery/functions/fnc_canRefuelUAV.sqf index 4256ddabf9..aaaac3077d 100644 --- a/addons/logistics_uavbattery/functions/fnc_canRefuelUAV.sqf +++ b/addons/logistics_uavbattery/functions/fnc_canRefuelUAV.sqf @@ -1,17 +1,19 @@ -/* fnc_refuel.sqf -* -* Author: marc_book (modified by PabstMirror) -* -* Tests if unit can refuel the target UAV -* -* Argument: -* 0: OBJECT - Player unit -* 1: OBJECT - UAV to test -* -* Return value: -* BOOL -*/ - +/* + * Author: marc_book + * Tests if unit can refuel the target UAV + * + * Arguments: + * 0: Player + * 1: UAV + * + * Return Value: + * Can the player rechange the UAV + * + * Example: + * [player, theUAV] call ace_logistics_uavbattery_fnc_canRefuelUAV + * + * Public: No + */ #include "script_component.hpp" PARAMS_2(_caller,_target); diff --git a/addons/logistics_uavbattery/functions/fnc_refuelUAV.sqf b/addons/logistics_uavbattery/functions/fnc_refuelUAV.sqf index 9384044f00..a23969aa9f 100644 --- a/addons/logistics_uavbattery/functions/fnc_refuelUAV.sqf +++ b/addons/logistics_uavbattery/functions/fnc_refuelUAV.sqf @@ -1,17 +1,19 @@ -/* fnc_refuel.sqf -* -* Author: marc_book (modified by PabstMirror) -* -* Starts refueling/recharging the 'Dartar' UAVs -* -* Argument: -* 0: OBJECT - Player unit -* 1: OBJECT - UAV -* -* Return value: -* NOTHING -*/ - +/* + * Author: marc_book + * Starts refueling/recharging the 'Dartar' UAVs + * + * Arguments: + * 0: Player + * 1: UAV + * + * Return Value: + * Nothing + * + * Example: + * [player, theUAV] call ace_logistics_uavbattery_fnc_refuelUAV + * + * Public: No + */ #include "script_component.hpp" PARAMS_2(_caller,_target); @@ -21,6 +23,7 @@ if (!(_this call FUNC(canRefuelUAV))) exitWith {}; _onFinish = { EXPLODE_2_PVT((_this select 0),_caller,_target); _caller removeItem "ACE_UAVBattery"; + playSound3D [QUOTE(PATHTO_R(sounds\exchange_battery.ogg)), objNull, false, getPosASL _caller, 1, 1, 10]; ["VehicleSetFuel", [_target], [_target, 1]] call EFUNC(common,targetEvent); //setFuel is local }; diff --git a/addons/logistics_uavbattery/sounds/exchange_battery.ogg b/addons/logistics_uavbattery/sounds/exchange_battery.ogg new file mode 100644 index 0000000000..5a40ddb47a Binary files /dev/null and b/addons/logistics_uavbattery/sounds/exchange_battery.ogg differ diff --git a/addons/logistics_wirecutter/CfgWeapons.hpp b/addons/logistics_wirecutter/CfgWeapons.hpp index f2d35337a2..76b1003f34 100644 --- a/addons/logistics_wirecutter/CfgWeapons.hpp +++ b/addons/logistics_wirecutter/CfgWeapons.hpp @@ -3,7 +3,7 @@ class CfgWeapons { class ACE_ItemCore; class ACE_wirecutter: ACE_ItemCore { - author = "$STR_ACE_Core_ACETeam"; + author = "$STR_ACE_Common_ACETeam"; displayName = "$STR_ACE_logistics_wirecutter_wirecutterName"; descriptionShort = "$STR_ACE_logistics_wirecutter_wirecutterDescription"; model = "\A3\weapons_F\ammo\mag_univ.p3d"; diff --git a/addons/magazinerepack/CfgEventHandlers.hpp b/addons/magazinerepack/CfgEventHandlers.hpp index f0a9f14d91..b928bc2de6 100644 --- a/addons/magazinerepack/CfgEventHandlers.hpp +++ b/addons/magazinerepack/CfgEventHandlers.hpp @@ -1,4 +1,3 @@ - class Extended_PreInit_EventHandlers { class ADDON { init = QUOTE(call COMPILE_FILE(XEH_preInit)); diff --git a/addons/magazinerepack/CfgSounds.hpp b/addons/magazinerepack/CfgSounds.hpp new file mode 100644 index 0000000000..1390397e5e --- /dev/null +++ b/addons/magazinerepack/CfgSounds.hpp @@ -0,0 +1,12 @@ +class CfgSounds { + class GVAR(soundMagazineFinished) { + name = QGVAR(soundMagazineFinished); + sound[]={QUOTE(PATHTOF(sounds\magrepack_finished.wav)),1,1}; + titles[]={}; + }; + class GVAR(soundRoundFinished) { + name = QGVAR(soundRoundFinished); + sound[] = {QUOTE(PATHTOF(sounds\magrepack_single.wav)),1,1}; + titles[] = {}; + }; +}; diff --git a/addons/magazinerepack/CfgVehicles.hpp b/addons/magazinerepack/CfgVehicles.hpp index ecb732f8fd..acd1c76c3d 100644 --- a/addons/magazinerepack/CfgVehicles.hpp +++ b/addons/magazinerepack/CfgVehicles.hpp @@ -1,18 +1,17 @@ - class CfgVehicles { - class Man; - class CAManBase: Man { - class ACE_SelfActions { - class ACE_RepackMagazines { - displayName = "$STR_ACE_MagazineRepack_RepackMagazines"; - condition = QUOTE(true); - statement = QUOTE([_player] call FUNC(magazineRepack)); - showDisabled = 0; - priority = -2; - icon = PATHTOF(UI\repack_ca.paa); - hotkey = "R"; - enableInside = 1; - }; + class Man; + class CAManBase: Man { + class ACE_SelfActions { + class ACE_RepackMagazines { + displayName = "$STR_ACE_MagazineRepack_RepackMagazines"; + condition = QUOTE(true); + statement = QUOTE([_player] call FUNC(openSelectMagazineUI)); + showDisabled = 0; + priority = -2; + icon = QUOTE(PATHTOF(UI\repack_ca.paa)); + hotkey = "R"; + enableInside = 1; + }; + }; }; - }; }; diff --git a/addons/magazinerepack/README.md b/addons/magazinerepack/README.md index 49a3c9d531..28b7c3115a 100644 --- a/addons/magazinerepack/README.md +++ b/addons/magazinerepack/README.md @@ -3,10 +3,10 @@ ace_magazinerepack Adds the ability to consolidate multiple half-empty magazines. - ## Maintainers The people responsible for merging changes to this component or answering potential questions. - [commy2](https://github.com/commy2) - [esteldunedain](https://github.com/esteldunedain) +- [PabstMirror](https://github.com/PabstMirror) diff --git a/addons/magazinerepack/XEH_preInit.sqf b/addons/magazinerepack/XEH_preInit.sqf index 5caba1ffac..7cd7107f54 100644 --- a/addons/magazinerepack/XEH_preInit.sqf +++ b/addons/magazinerepack/XEH_preInit.sqf @@ -2,8 +2,10 @@ ADDON = false; -PREP(magazineRepack); -PREP(magazineRepackCallback); +PREP(magazineRepackFinish); +PREP(magazineRepackProgress); PREP(openSelectMagazineUI); +PREP(simulateRepackEvents); +PREP(startRepackingMagazine); ADDON = true; diff --git a/addons/magazinerepack/config.cpp b/addons/magazinerepack/config.cpp index 5f2c6edc7d..514a74350a 100644 --- a/addons/magazinerepack/config.cpp +++ b/addons/magazinerepack/config.cpp @@ -5,7 +5,7 @@ class CfgPatches { units[] = {}; weapons[] = {}; requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ace_common","ace_interaction"}; + requiredAddons[] = {"ace_interaction"}; author[] = {"commy2","CAA-Picard"}; authorUrl = "https://github.com/commy2/"; VERSION_CONFIG; @@ -13,9 +13,16 @@ class CfgPatches { }; #include "CfgEventHandlers.hpp" +#include "CfgSounds.hpp" #include "CfgVehicles.hpp" -class ACE_Parameters_Numeric { - GVAR(TimePerAmmo) = 1.5; - GVAR(TimePerMagazine) = 2.0; +class ACE_Settings { + class GVAR(TimePerAmmo) { + value = 1.5; + typeName = "SCALAR"; + }; + class GVAR(TimePerMagazine) { + value = 2.0; + typeName = "SCALAR"; + }; }; diff --git a/addons/magazinerepack/functions/fnc_magazineRepack.sqf b/addons/magazinerepack/functions/fnc_magazineRepack.sqf deleted file mode 100644 index 472b80e2bd..0000000000 --- a/addons/magazinerepack/functions/fnc_magazineRepack.sqf +++ /dev/null @@ -1,77 +0,0 @@ -// by commy2, esteldunedain -#include "script_component.hpp" - -private ["_unit", "_magazines", "_ammos", "_repackTime", "_magazine", "_ammo", "_count", "_index", "_i", "_j", "_ammoToTransfer", "_ammoAvailable", "_ammoNeeded"]; - -_unit = _this select 0; - -_magazines = []; -_ammos = []; -_repackTime = []; - -// get all mags and ammo count -{ - _magazine = _x select 0; - _ammo = _x select 1; - - _count = getNumber (configfile >> "CfgMagazines" >> _magazine >> "count"); - - if (_ammo != _count && {_count > 1}) then { // additional checks here - if !(_magazine in _magazines) then { - _index = count _magazines; - _magazines set [_index, _magazine]; - _ammos set [_index, [_ammo]]; - } else { - _index = _magazines find _magazine; - _ammos set [_index, (_ammos select _index) + [_ammo]]; - }; - }; -} forEach magazinesAmmoFull _unit; - -// Remove invalid magazines -{ - if (count _x < 2) then { - _magazines set [_forEachIndex, -1]; - _ammos set [_forEachIndex, [-1]]; - }; -} forEach _ammos; -_magazines = _magazines - [-1]; -_ammos = _ammos - [[-1]]; - -{ - // Calculate actual ammo to transfer during repack - _count = getNumber (configfile >> "CfgMagazines" >> (_magazines select _forEachIndex) >> "count"); - - // Sort Ascending - _list = _x call BIS_fnc_sortNum; - - ["MagazineRepack", _list] call EFUNC(common,log); - - _i = 0; - _j = count _x - 1; - _ammoToTransfer = 0; - _ammoAvailable = 0; - while {_i < _j} do { - _ammoNeeded = _count - (_list select _j); - _exit = false; - while {_i < _j && {!_exit}} do { - _ammoAvailable = _list select _i; - if (_ammoAvailable >= _ammoNeeded) then { - _list set [_i, _ammoAvailable - _ammoNeeded]; - _ammoToTransfer = _ammoToTransfer + _ammoNeeded; - _exit = true; - } else { - _ammoNeeded = _ammoNeeded - _ammoAvailable; - _ammoToTransfer = _ammoToTransfer + _ammoAvailable; - _i = _i + 1; - }; - }; - _j = _j - 1; - }; - - _repackTime set [_forEachIndex, _ammoToTransfer * GVAR(TimePerAmmo) + (count _x) * GVAR(TimePerMagazine)]; -} forEach _ammos; - -["MagazineRepack", [_magazines, _repackTime]] call EFUNC(common,log); - -[_unit, _magazines, _repackTime] call FUNC(openSelectMagazineUI); diff --git a/addons/magazinerepack/functions/fnc_magazineRepackCallback.sqf b/addons/magazinerepack/functions/fnc_magazineRepackCallback.sqf deleted file mode 100644 index f209806f9c..0000000000 --- a/addons/magazinerepack/functions/fnc_magazineRepackCallback.sqf +++ /dev/null @@ -1,106 +0,0 @@ -// by commy2 -#include "script_component.hpp" - -private ["_unit", "_magazine", "_ammo", "_ammoCount", "_fullMagazinesCount", "_restAmmo", "_isLoaded", "_weapon", "_reloadAction", "_text", "_picture"]; - -_unit = ACE_player; //_this select 0; -_magazine = _this select 1; - -// exit if the last magazine of this type was taken out of the backpack -if !(_magazine in magazines _unit) exitWith {}; - -// get current ammo count -_ammo = 0; -{ - if (_x select 0 == _magazine) then { - _ammo = _ammo + (_x select 1); - }; -} forEach magazinesAmmoFull _unit; - -// how many rounds fit in one mag -_ammoCount = getNumber (configFile >> "CfgMagazines" >> _magazine >> "count"); - -// calculate new vaules -_fullMagazinesCount = floor (_ammo / _ammoCount); -_restAmmo = _ammo - _fullMagazinesCount * _ammoCount; - -// remove old magazines -_unit removeMagazines _magazine; - -_isLoaded = false; -// reload rifle -if (_magazine in primaryWeaponMagazine _unit) then { - _weapon = primaryWeapon _unit; - - if (_fullMagazinesCount > 0) then { - _unit setAmmo [_weapon, _ammoCount]; - _fullMagazinesCount = _fullMagazinesCount - 1; - } else { - _unit setAmmo [_weapon, _restAmmo]; - _restAmmo = 0; - }; - - if (_weapon == currentWeapon _unit) then { - _reloadAction = getText (configFile >> "CfgWeapons" >> _weapon >> "reloadAction"); - _unit playActionNow _reloadAction; - }; - - _isLoaded = true; -}; - -// reload pistol -if (_magazine in handgunMagazine _unit) then { - _weapon = handgunWeapon _unit; - - if (_fullMagazinesCount > 0) then { - _unit setAmmo [_weapon, _ammoCount]; - _fullMagazinesCount = _fullMagazinesCount - 1; - } else { - _unit setAmmo [_weapon, _restAmmo]; - _restAmmo = 0; - }; - - if (_weapon == currentWeapon _unit) then { - _reloadAction = getText (configFile >> "CfgWeapons" >> _weapon >> "reloadAction"); - _unit playActionNow _reloadAction; - }; - - _isLoaded = true; -}; - -// reload rocket launcher (just in case ...) -if (_magazine in secondaryWeaponMagazine _unit) then { - _weapon = secondaryWeapon _unit; - - if (_fullMagazinesCount > 0) then { - _unit setAmmo [_weapon, _ammoCount]; - _fullMagazinesCount = _fullMagazinesCount - 1; - } else { - _unit setAmmo [_weapon, _restAmmo]; - _restAmmo = 0; - }; - - if (_weapon == currentWeapon _unit) then { - _reloadAction = getText (configFile >> "CfgWeapons" >> _weapon >> "reloadAction"); - _unit playActionNow _reloadAction; - }; - - _isLoaded = true; -}; - -// add new magazines -for "_a" from 1 to _fullMagazinesCount do { - _unit addMagazine _magazine; -}; - -if (_restAmmo > 0) then { - _unit addMagazine [_magazine, _restAmmo]; -}; - -// display text if successful -_text = format [localize "STR_ACE_MagazineRepack_RepackedMagazinesDetail", [_fullMagazinesCount, _fullMagazinesCount + 1] select _isLoaded, _restAmmo]; -_picture = getText (configFile >> "CfgMagazines" >> _magazine >> "picture"); - -_text = parseText format ["
%2
%3", _picture, localize "STR_ACE_MagazineRepack_RepackedMagazines", _text]; - -[_text] call EFUNC(common,displayTextStructured); diff --git a/addons/magazinerepack/functions/fnc_magazineRepackFinish.sqf b/addons/magazinerepack/functions/fnc_magazineRepackFinish.sqf new file mode 100644 index 0000000000..038b7fb151 --- /dev/null +++ b/addons/magazinerepack/functions/fnc_magazineRepackFinish.sqf @@ -0,0 +1,52 @@ +/* + * Author: PabstMirror (based on repack from commy2, esteldunedain, Ruthberg) + * Simulates repacking a set of magazines. + * Returns the timing and magazines counts at every stage. + * + * Arguments: + * 0: Arguments [classname,lastAmmoStatus,events] + * 1: Elapsed Time + * 2: Total Time Repacking Will Take + * 3: Error Code + * + * Return Value: + * Nothing + * + * Example: + * (args from progressBar) call ace_magazinerepack_fnc_magazineRepackFinish + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_4(_args,_elapsedTime,_totalTime,_errorCode); +EXPLODE_2_PVT(_args,_magazineClassname,_lastAmmoCount); +_fullMagazineCount = getNumber (configfile >> "CfgMagazines" >> _magazineClassname >> "count"); + +_structuredOutputText = + +if (_errorCode == 0) then { + format ["%1
", (localize "STR_ACE_MagazineRepack_RepackComplete")]; +} else { + format ["%1
", (localize "STR_ACE_MagazineRepack_RepackInterrupted")]; +}; + +_picture = getText (configFile >> "CfgMagazines" >> _magazineClassname >> "picture"); +_structuredOutputText = _structuredOutputText + format ["
", _picture]; + +_fullMags = 0; +_partialMags = 0; +{ + EXPLODE_2_PVT(_x,_xClassname,_xCount); + if ((_xClassname == _magazineClassname) && {_xCount > 0}) then { + if (_xCount == _fullMagazineCount) then { + _fullMags = _fullMags + 1; + } else { + _partialMags = _partialMags + 1; + }; + }; +} forEach (magazinesAmmoFull ACE_player); + +_structuredOutputText = _structuredOutputText + format [("" + (localize "STR_ACE_MagazineRepack_RepackedMagazinesCount") + ""), _fullMags, _partialMags]; + +[parseText _structuredOutputText] call EFUNC(common,displayTextStructured); diff --git a/addons/magazinerepack/functions/fnc_magazineRepackProgress.sqf b/addons/magazinerepack/functions/fnc_magazineRepackProgress.sqf new file mode 100644 index 0000000000..64ce05d12d --- /dev/null +++ b/addons/magazinerepack/functions/fnc_magazineRepackProgress.sqf @@ -0,0 +1,78 @@ +/* + * Author: PabstMirror (based on repack from commy2, esteldunedain, Ruthberg) + * Handles each frame durring the repack progressBar. + * On each event (repacked bullet or move to new mag) it plays a sound and syncs up the new magazines to the player. + * + * Arguments: + * 0: Arguments [classname,lastAmmoStatus,events] + * 1: Elapsed Time + * 2: Total Time Repacking Will Take + * + * Return Value: + * Keep going (on missing mags return false) + * + * Example: + * (args from progressBar) call ace_magazinerepack_fnc_magazineRepackProgress + * + * Public: No + */ +#include "script_component.hpp" + +private ["_currentAmmoCount", "_addedMagazines", "_missingAmmo", "_index", "_updateMagazinesOnPlayerFnc"]; + +PARAMS_3(_args,_elapsedTime,_totalTime); +EXPLODE_3_PVT(_args,_magazineClassname,_lastAmmoCount,_simEvents); +if ((count _simEvents) == 0) exitWith {ERROR("No Event"); false}; +EXPLODE_3_PVT((_simEvents select 0),_nextEventTime,_nextEventIsBullet,_nextEventMags); + +if (_nextEventTime > _elapsedTime) exitWith {true};//waiting on next event + +//Verify we aren't missing any ammo +_currentAmmoCount = []; +{ + EXPLODE_2_PVT(_x,_xClassname,_xCount); + if (_xClassname == _magazineClassname) then { + _currentAmmoCount pushBack _xCount; + }; +} forEach (magazinesAmmo ACE_player); //only inventory mags + +//Go through mags we currently have and check off the ones we should have +_addedMagazines = +_currentAmmoCount; +_missingAmmo = false; +{ + if (_x > 0) then { + _index = _addedMagazines find _x; + if (_index != -1) then { + _addedMagazines deleteAt _index; + } else { + _missingAmmo = true; + }; + }; +} forEach _lastAmmoCount; + +if (_missingAmmo) exitWith {false}; //something removed ammo that was being repacked (could be other players or scripts) + +_updateMagazinesOnPlayerFnc = { + ACE_player removeMagazines _magazineClassname; //remove inventory magazines + { + if (_x > 0) then { + ACE_player addMagazine [_magazineClassname, _x]; + }; + } forEach (_addedMagazines + _nextEventMags); + _args set [1, _nextEventMags]; //store the new magazine +}; + +if (_nextEventIsBullet) then { + playSound QGVAR(soundRoundFinished); + if ((((count _simEvents) % 3) == 0) || {(count _simEvents) == 1}) then { + //For performance - only update mags every 3 bullets (or if it's the last event) + call _updateMagazinesOnPlayerFnc; + }; +} else { + playSound QGVAR(soundMagazineFinished); + call _updateMagazinesOnPlayerFnc; +}; + +_simEvents deleteAt 0; //pop off the event + +true; diff --git a/addons/magazinerepack/functions/fnc_openSelectMagazineUI.sqf b/addons/magazinerepack/functions/fnc_openSelectMagazineUI.sqf index b1a31c266c..e96e84e9a1 100644 --- a/addons/magazinerepack/functions/fnc_openSelectMagazineUI.sqf +++ b/addons/magazinerepack/functions/fnc_openSelectMagazineUI.sqf @@ -1,40 +1,59 @@ -// by commy2 +/* + * Author: PabstMirror (based on repack from commy2, esteldunedain, Ruthberg) + * Opens the selectMenu UI to chose which magazine to repack. + * Only shows classnames that have 2+ partial magazines + * + * Arguments: + * 0: Unit (player) + * + * Return Value: + * Nothing + * + * Example: + * [_player] call ace_magazinerepack_fnc_openSelectMagazineUI + * + * Public: No + */ #include "script_component.hpp" -private ["_unit", "_magazines", "_repackTime", "_listIDC", "_count", "_index", "_magazine", "_time", "_displayName", "_picture"]; +private ["_unitMagazines", "_unitMagCounts", "_xFullMagazineCount", "_index", "_actions", "_displayName", "_picture"]; -_unit = _this select 0; -_magazines = _this select 1; -_repackTime = _this select 2; +PARAMS_1(_unit); -_count = count _magazines; +_unitMagazines = []; +_unitMagCounts = []; + +// get all mags and ammo count +{ + EXPLODE_2_PVT(_x,_xClassname,_xCount); + _xFullMagazineCount = getNumber (configfile >> "CfgMagazines" >> _xClassname >> "count"); + + if ((_xCount != _xFullMagazineCount) && {_xCount > 0}) then {//for every partial magazine + _index = _unitMagazines find _xClassname; + if (_index == -1) then { + _unitMagazines pushBack _xClassname; + _unitMagCounts pushBack [_xCount]; + } else { + (_unitMagCounts select _index) pushBack _xCount; + }; + }; +} forEach (magazinesAmmoFull _unit); _actions = [localize "STR_ACE_MagazineRepack_SelectMagazineMenu", localize "STR_ACE_MagazineRepack_SelectMagazine"] call EFUNC(interaction,prepareSelectMenu); -for "_index" from 0 to (_count - 1) do { - _magazine = _magazines select _index; - _time = _repackTime select _index; - _displayName = getText (configFile >> "CfgMagazines" >> _magazine >> "displayName"); - _picture = getText (configFile >> "CfgMagazines" >> _magazine >> "picture"); - _actions = [ - _actions, - _displayName, - _picture, - [str _unit, _magazine, _time] - ] call EFUNC(interaction,addSelectableItem); -}; + +{ + if ((count (_unitMagCounts select _forEachIndex)) >= 2) then {// Ignore invalid magazines types (need 2+ partial mags to do anything) + _displayName = getText (configFile >> "CfgMagazines" >> _x >> "displayName"); + _picture = getText (configFile >> "CfgMagazines" >> _x >> "picture"); + _actions = [_actions, _displayName, _picture, _x] call EFUNC(interaction,addSelectableItem); + }; +} forEach _unitMagazines; [ - _actions, - { - _data = _this; - call EFUNC(interaction,hideMenu); - if (isNil "_data") exitWith {}; - _data set [2, [_data select 2] call EFUNC(common,toNumber)]; - [(_data select 2), _data, {(_this select 0) call FUNC(magazineRepackCallback)}, {}, (localize "STR_ACE_MagazineRepack_RepackingMagazine")] call EFUNC(common,progressBar); - [ACE_player] call EFUNC(common,goKneeling); - }, - { - call EFUNC(interaction,hideMenu); - if !(profileNamespace getVariable [QGVAR(AutoCloseMenu), false]) then {"Default" call EFUNC(interaction,openMenuSelf)}; - } +_actions, +{ [_this] call FUNC(startRepackingMagazine); }, +{ + call EFUNC(interaction,hideMenu); //ToDo: Self Interaction Integration + if !(profileNamespace getVariable [QGVAR(AutoCloseMenu), false]) then {"Default" call EFUNC(interaction,openMenuSelf)}; +} ] call EFUNC(interaction,openSelectMenu); diff --git a/addons/magazinerepack/functions/fnc_simulateRepackEvents.sqf b/addons/magazinerepack/functions/fnc_simulateRepackEvents.sqf new file mode 100644 index 0000000000..2b8b383a9a --- /dev/null +++ b/addons/magazinerepack/functions/fnc_simulateRepackEvents.sqf @@ -0,0 +1,67 @@ +/* + * Author: PabstMirror + * Simulates repacking a set of magazines. + * Returns the timing and magazines counts at every stage. + * + * Arguments: + * 0: How many rounds in a full magazine + * 1: Array of rounds in magazines + * + * Return Value: + * Array in format [time, isBullet, array of ammo counts] + * + * Example: + * [5, [1,2,3,8]] call ace_magazinerepack_fnc_simulateRepackEvents = + * [[1.5,true,[0,2,3,9]],[3.5,false,[0,2,3,9]],[5,true,[0,1,3,10]],[7,false,[0,1,3,10]],[8.5,true,[0,0,4,10]],[10.5,false,[0,0,4,10]]] + * + * Public: No + */ +#include "script_component.hpp" + +private ["_newMagFnc", "_time", "_events", "_swapAmmoFnc", "_ammoSwaped", "_lowIndex", "_highIndex", "_ammoToTransfer", "_ammoAvailable", "_ammoNeeded"]; + +PARAMS_2(_fullMagazineCount,_arrayOfAmmoCounts); + +// Sort Ascending - Don't modify original +_arrayOfAmmoCounts = (+_arrayOfAmmoCounts) call BIS_fnc_sortNum; + +_newMagFnc = { + _time = _time + GVAR(TimePerMagazine); + _events pushBack [_time, false, +_arrayOfAmmoCounts]; +}; +_swapAmmoFnc = { + for "_swapProgress" from 0 to (_ammoSwaped - 1) do { + _time = _time + GVAR(TimePerAmmo); + _arrayOfAmmoCounts set [_lowIndex, ((_arrayOfAmmoCounts select _lowIndex) - 1)]; + _arrayOfAmmoCounts set [_highIndex, ((_arrayOfAmmoCounts select _highIndex) + 1)]; + _events pushBack [_time, true, +_arrayOfAmmoCounts]; + }; +}; + +_lowIndex = 0; +_highIndex = (count _arrayOfAmmoCounts) - 1; +_ammoToTransfer = 0; +_ammoAvailable = 0; + +_time = 0; +_events = []; + +while {_lowIndex < _highIndex} do { + _ammoNeeded = _fullMagazineCount - (_arrayOfAmmoCounts select _highIndex); + _ammoAvailable = _arrayOfAmmoCounts select _lowIndex; + + if (_ammoAvailable == 0) then { + _lowIndex = _lowIndex + 1; + call _newMagFnc; + } else { + if (_ammoNeeded == 0) then { + _highIndex = _highIndex - 1; + call _newMagFnc; + } else { + _ammoSwaped = _ammoAvailable min _ammoNeeded; + call _swapAmmoFnc; + }; + }; +}; + +_events diff --git a/addons/magazinerepack/functions/fnc_startRepackingMagazine.sqf b/addons/magazinerepack/functions/fnc_startRepackingMagazine.sqf new file mode 100644 index 0000000000..06c0f0a137 --- /dev/null +++ b/addons/magazinerepack/functions/fnc_startRepackingMagazine.sqf @@ -0,0 +1,67 @@ +/* + * Author: PabstMirror (based on repack from commy2, esteldunedain, Ruthberg) + * Starts repacking a specific magazine classname. + * If room in inventory, unload magazine from weapon to be repacked. + * Precalcs all the event timings and starts the progressBar. + * + * Arguments: + * 0: Magazine Classname + * + * Return Value: + * Nothing + * + * Example: + * ["30Rnd_65x39_caseless_mag"] call ace_magazinerepack_fnc_startRepackingMagazine + * + * Public: No + */ +#include "script_component.hpp" + +private ["_unit", "_fullMagazineCount", "_startingAmmoCounts", "_simEvents", "_totalTime"]; + +PARAMS_1(_magazineClassname); +if (isNil "_magazineClassname" || {_magazineClassname == ""}) exitWith {ERROR("Bad Mag Classname");}; + +_unit = ACE_player; + +[ACE_player] call EFUNC(common,goKneeling); +call EFUNC(interaction,hideMenu);//ToDo: Self Interaction Integration + +// Calculate actual ammo to transfer during repack +_fullMagazineCount = getNumber (configfile >> "CfgMagazines" >> _magazineClassname >> "count"); + +_startingAmmoCounts = []; +{ + EXPLODE_4_PVT(_x,_xClassname,_xCount,_xLoaded,_xType); + if ((_xClassname == _magazineClassname) && {(_xCount != _fullMagazineCount) && {_xCount > 0}}) then { + if (_xLoaded) then { + //Try to Remove from weapon and add to inventory, otherwise ignore + if (_unit canAdd _magazineClassname) then { + switch (_xType) do { + case (1): {_unit removePrimaryWeaponItem _magazineClassname;}; + case (2): {_unit removeHandgunItem _magazineClassname;}; + case (4): {_unit removeSecondaryWeaponItem _magazineClassname;}; + default {ERROR("Loaded Location Invalid");}; + }; + _unit addMagazine [_magazineClassname, _xCount]; + _startingAmmoCounts pushBack _xCount; + }; + } else { + _startingAmmoCounts pushBack _xCount; + }; + }; +} forEach (magazinesAmmoFull _unit); + +if ((count _startingAmmoCounts) < 2) exitwith {ERROR("Not Enough Mags to Repack");}; + +_simEvents = [_fullMagazineCount, _startingAmmoCounts] call FUNC(simulateRepackEvents); +_totalTime = (_simEvents select ((count _simEvents) - 1) select 0); + +[ +_totalTime, +[_magazineClassname, _startingAmmoCounts, _simEvents], +{_this call FUNC(magazineRepackFinish)}, +{_this call FUNC(magazineRepackFinish)}, +(localize "STR_ACE_MagazineRepack_RepackingMagazine"), +{_this call FUNC(magazineRepackProgress)} +] call EFUNC(common,progressBar); diff --git a/addons/magazinerepack/sounds/magrepack_finished.wav b/addons/magazinerepack/sounds/magrepack_finished.wav new file mode 100644 index 0000000000..ab73615a55 Binary files /dev/null and b/addons/magazinerepack/sounds/magrepack_finished.wav differ diff --git a/addons/magazinerepack/sounds/magrepack_single.wav b/addons/magazinerepack/sounds/magrepack_single.wav new file mode 100644 index 0000000000..5d94e215fd Binary files /dev/null and b/addons/magazinerepack/sounds/magrepack_single.wav differ diff --git a/addons/magazinerepack/stringtable.xml b/addons/magazinerepack/stringtable.xml index 5ea62e3a18..937cfcbf9a 100644 --- a/addons/magazinerepack/stringtable.xml +++ b/addons/magazinerepack/stringtable.xml @@ -1,5 +1,5 @@  - + @@ -74,5 +74,20 @@ %1 tejles tár és %2 extra lőszer. %1 полных магазина(ов) и %2 патрона(ов) + + Repacking Finished + Wiederverpacken Fertig + Reembalaje Finalizado + + + Repacking Interrupted + Umpacken Unterbrochen + Reempaque Interrupted + + + %1 Full and %2 Partial + %1 Vollständigen und %2 Teilweisen + %1 Total y %2 Parcial + \ No newline at end of file diff --git a/addons/magazines/CfgVehicles.hpp b/addons/magazines/CfgVehicles.hpp index b78eb71abc..a7c2654d71 100644 --- a/addons/magazines/CfgVehicles.hpp +++ b/addons/magazines/CfgVehicles.hpp @@ -1,9 +1,4 @@ -#define MACRO_ADDMAGAZINE(MAGAZINE,COUNT) class _xx_##MAGAZINE { \ - magazine = #MAGAZINE; \ - count = COUNT; \ -} - class CfgVehicles { class NATO_Box_Base; class Box_NATO_Wps_F: NATO_Box_Base { diff --git a/addons/main/script_macros.hpp b/addons/main/script_macros.hpp index 3b59e8b373..cc589aac3e 100644 --- a/addons/main/script_macros.hpp +++ b/addons/main/script_macros.hpp @@ -199,6 +199,22 @@ #define GETEGVAR(var1,var2,var3) GETMVAR(EGVAR(var1,var2),var3) +#define MACRO_ADDWEAPON(WEAPON,COUNT) class _xx_##WEAPON { \ + weapon = #WEAPON; \ + count = COUNT; \ +} + +#define MACRO_ADDITEM(ITEM,COUNT) class _xx_##ITEM { \ + name = #ITEM; \ + count = COUNT; \ +} + +#define MACRO_ADDMAGAZINE(MAGAZINE,COUNT) class _xx_##MAGAZINE { \ + magazine = #MAGAZINE; \ + count = COUNT; \ +} + + #ifdef DISABLE_COMPILE_CACHE #define PREP(fncName) DFUNC(fncName) = compile preprocessFileLineNumbers QUOTE(PATHTOF(functions\DOUBLES(fnc,fncName).sqf)) #else diff --git a/addons/map/config.cpp b/addons/map/config.cpp index c9980458db..36a6f85168 100644 --- a/addons/map/config.cpp +++ b/addons/map/config.cpp @@ -23,13 +23,23 @@ class RscButtonMenuCancel; class RscButtonMenu; class RscEdit; -class ACE_Parameters_Numeric { - GVAR(BFT_Interval) = 1; -}; -class ACE_Parameters_Boolean { - GVAR(EveryoneCanDrawOnBriefing) = 1; - GVAR(BFT_Enabled) = 0; - GVAR(BFT_HideAiGroups) = 0; +class ACE_Settings { + class GVAR(BFT_Interval) { + value = 1.0; + typeName = "SCALAR"; + }; + class GVAR(EveryoneCanDrawOnBriefing) { + value = 1; + typeName = "BOOL"; + }; + class GVAR(BFT_Enabled) { + value = 0; + typeName = "BOOL"; + }; + class GVAR(BFT_HideAiGroups) { + value = 0; + typeName = "BOOL"; + }; }; #include "MapGpsUI.hpp" diff --git a/addons/map/functions/fnc_blueForceTrackingModule.sqf b/addons/map/functions/fnc_blueForceTrackingModule.sqf index 3951473026..cecfd348d2 100644 --- a/addons/map/functions/fnc_blueForceTrackingModule.sqf +++ b/addons/map/functions/fnc_blueForceTrackingModule.sqf @@ -21,8 +21,8 @@ _activated = _this select 2; if !(_activated) exitWith {}; GVAR(BFT_Enabled) = true; -[_logic, QGVAR(BFT_Interval), "Interval"] call EFUNC(common,readNumericParameterFromModule); -[_logic, QGVAR(BFT_HideAiGroups), "HideAiGroups"] call EFUNC(common,readBooleanParameterFromModule); +[_logic, QGVAR(BFT_Interval), "Interval"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(BFT_HideAiGroups), "HideAiGroups"] call EFUNC(common,readSettingFromModule); diag_log text "[ACE]: Blue Force Tracking Module initialized."; TRACE_2("[ACE]: Blue Force Tracking Module initialized.",GVAR(BFT_Interval), GVAR(BFT_HideAiGroups)); diff --git a/addons/medical/functions/fnc_moduleBasicRevive.sqf b/addons/medical/functions/fnc_moduleBasicRevive.sqf index 6d8bfa2e6c..b02d873313 100644 --- a/addons/medical/functions/fnc_moduleBasicRevive.sqf +++ b/addons/medical/functions/fnc_moduleBasicRevive.sqf @@ -15,9 +15,9 @@ _logic = _this select 0; GVAR(Module) = true; -[_logic, QGVAR(ENABLE_REVIVE_F), "enableFor" ] call EFUNC(common,readNumericParameterFromModule); -[_logic, QGVAR(REVIVE_TIMER_MAX_F), "timer" ] call EFUNC(common,readNumericParameterFromModule); -[_logic, QGVAR(REVIVE_NUMBER_MAX_F), "amountOf" ] call EFUNC(common,readNumericParameterFromModule); +[_logic, QGVAR(ENABLE_REVIVE_F), "enableFor" ] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(REVIVE_TIMER_MAX_F), "timer" ] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(REVIVE_NUMBER_MAX_F), "amountOf" ] call EFUNC(common,readSettingFromModule); [ {(((_this select 0) getvariable[QGVAR(ENABLE_REVIVE_SETDEAD_F),0]) > 0)} diff --git a/addons/movement/CfgMoves.hpp b/addons/movement/CfgMoves.hpp index 9d32d4e856..677ad3dc94 100644 --- a/addons/movement/CfgMoves.hpp +++ b/addons/movement/CfgMoves.hpp @@ -77,6 +77,15 @@ class CfgMovesMaleSdr: CfgMovesBasic { class AmovPercMwlkSlowWrflDr: AmovPercMwlkSlowWrflDf { leftHandIKCurve[] = {}; }; + class AmovPercMwlkSlowWrflDf_v1: AmovPercMwlkSlowWrflDf { + leftHandIKCurve[] = {}; + }; + class AidlPercMwlkSrasWrflDf: AmovPercMwlkSlowWrflDf { + leftHandIKCurve[] = {}; + }; + class AmovPercMtacSlowWrflDf: AmovPercMwlkSlowWrflDf { + leftHandIKCurve[] = {}; + }; // enable optics in prone left and right stance class AidlPpneMstpSrasWrflDnon_G0S; diff --git a/addons/movement/config.cpp b/addons/movement/config.cpp index e8661b748c..51ab97b80a 100644 --- a/addons/movement/config.cpp +++ b/addons/movement/config.cpp @@ -17,9 +17,11 @@ class CfgPatches { //#include "CfgInventoryGlobalVariable.hpp" #include "CfgMoves.hpp" -class ACE_Options { +class ACE_Settings { class GVAR(useImperial) { + value = 0; + typeName = "BOOL"; + isClientSetable = 1; displayName = "$STR_ACE_Movement_UseImperial"; - default = 0; }; }; diff --git a/addons/movement/functions/fnc_getWeight.sqf b/addons/movement/functions/fnc_getWeight.sqf index a52ed3cb12..254b706d56 100644 --- a/addons/movement/functions/fnc_getWeight.sqf +++ b/addons/movement/functions/fnc_getWeight.sqf @@ -7,7 +7,7 @@ _unit = _this select 0; _weight = loadAbs _unit * 0.1; -if (GETGVAR(useImperial, 0) == 1) then { +if (GVAR(useImperial)) then { _weight = format ["%1lb", (round (_weight * 100)) / 100]; } else { _weight = format ["%1kg", (round (_weight * FACTOR_POUND_TO_KILOGRAMM * 100)) / 100]; diff --git a/addons/nametags/CfgVehicles.hpp b/addons/nametags/CfgVehicles.hpp index 444622f0ed..e3c4227834 100644 --- a/addons/nametags/CfgVehicles.hpp +++ b/addons/nametags/CfgVehicles.hpp @@ -15,40 +15,44 @@ class CfgVehicles { typeName = "NUMBER"; defaultValue = 5; }; - class ShowNamesForAI { + class showNamesForAI { displayName = "Show name tags for AI?"; - description = "Show the name and rank tags for friendly AI units? Default: No"; - typeName = "BOOL"; - class values { - class Yes { - name = "Yes"; - value = 1; - }; - class No { - default = 1; - name = "No"; - value = 0; - }; - }; - }; - class Visibility { - displayName = "Visibility of crew info"; - description = "Forces visibility of vehicle crew info, or by default allows players to choose it on their own. Default: Do Not Force"; - typeName = "INT"; + description = "Show the name and rank tags for friendly AI units? Default: Do not force"; + typeName = "NUMBER"; class values { class DoNotForce { default = 1; name = "Do Not Force"; + value = -1; + }; + class ForceHide { + name = "Force Hide"; + value = 0; + }; + class ForceShow { + name = "Force show"; + value = 1; + }; + }; + }; + class showVehicleCrewInfo { + displayName = "Show crew info?"; + description = "Show vehicle crew info, or by default allows players to choose it on their own. Default: Do Not Force"; + typeName = "NUMBER"; + class values { + class DoNotForce { + default = 1; + name = "Do Not Force"; + value = -1; + }; + class ForceHide { + name = "Force Hide"; value = 0; }; class ForceShow { name = "Force Show"; value = 1; }; - class ForceHide { - name = "Force Hide"; - value = -1; - }; }; }; }; diff --git a/addons/nametags/config.cpp b/addons/nametags/config.cpp index 1846cd616e..aa55dd2aad 100644 --- a/addons/nametags/config.cpp +++ b/addons/nametags/config.cpp @@ -15,29 +15,43 @@ class CfgPatches { #include "CfgEventHandlers.hpp" #include "CfgVehicles.hpp" -class ACE_Options { +class ACE_Settings { class GVAR(showPlayerNames) { + value = 1; + typeName = "SCALAR"; + isClientSetable = 1; displayName = "$STR_ACE_NameTags_ShowPlayerNames"; values[] = {"Disabled", "Enabled", "Only Cursor", "Only On Keypress", "Only Cursor and KeyPress"}; - default = 1; }; class GVAR(showPlayerRanks) { + value = 1; + typeName = "BOOL"; + isClientSetable = 1; displayName = "$STR_ACE_NameTags_ShowPlayerRanks"; - default = 1; }; class GVAR(showVehicleCrewInfo) { - displayName = "$STR_ACE_CrewInfo_ShowVehicleCrewInfo"; - default = 1; + value = 1; + typeName = "BOOL"; + isClientSetable = 1; + displayName = "$STR_ACE_NameTags_ShowVehicleCrewInfo"; + }; + class GVAR(showNamesForAI) { + value = 0; + typeName = "BOOL"; + isClientSetable = 1; + displayName = "$STR_ACE_NameTags_ShowNamesForAI"; }; -}; -class ACE_Parameters_Numeric { - GVAR(PlayerNamesViewDistance) = 5; - GVAR(PlayerNamesMaxAlpha) = 0.8; - GVAR(CrewInfoVisibility) = 0; -}; -class ACE_Parameters_Boolean { - GVAR(ShowNamesForAI) = 0; + class GVAR(PlayerNamesViewDistance) { + value = 5; + typeName = "SCALAR"; + isClientSetable = 0; + }; + class GVAR(PlayerNamesMaxAlpha) { + value = 0.8; + typeName = "SCALAR"; + isClientSetable = 0; + }; }; #include diff --git a/addons/nametags/functions/fnc_canShow.sqf b/addons/nametags/functions/fnc_canShow.sqf index 8b61352def..0e187fee0f 100644 --- a/addons/nametags/functions/fnc_canShow.sqf +++ b/addons/nametags/functions/fnc_canShow.sqf @@ -1,12 +1,12 @@ /* Author: aeroson - + Description: Might be called several times a second - - Parameters: + + Parameters: None - + Returns: true if CrewInfo can be shown, false otherwise */ @@ -17,11 +17,6 @@ private["_player"]; _player = ACE_player; -// AGM_NameTags_ShowVehicleCrewInfo: -1 force NO, 0 doesnt care, 1 force YES - vehicle _player != _player && -{ - (GVAR(CrewInfoVisibility) == 1) || - (GVAR(CrewInfoVisibility) != -1 && GVAR(showVehicleCrewInfo)) -} && +{GVAR(ShowCrewInfo)} && {!(vehicle _player isKindOf "ParachuteBase")}; diff --git a/addons/nametags/functions/fnc_moduleNameTags.sqf b/addons/nametags/functions/fnc_moduleNameTags.sqf index b701a2db8c..24b30e5d6b 100644 --- a/addons/nametags/functions/fnc_moduleNameTags.sqf +++ b/addons/nametags/functions/fnc_moduleNameTags.sqf @@ -22,8 +22,8 @@ if !(_activated) exitWith {}; GVAR(Module) = true; -[_logic, QGVAR(PlayerNamesViewDistance), "PlayerNamesViewDistance" ] call EFUNC(common,readNumericParameterFromModule); -[_logic, QGVAR(ShowNamesForAI), "ShowNamesForAI" ] call EFUNC(common,readBooleanParameterFromModule); -[_logic, QGVAR(CrewInfoVisibility), "Visibility" ] call EFUNC(common,readNumericParameterFromModule); +[_logic, QGVAR(PlayerNamesViewDistance), "PlayerNamesViewDistance" ] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(ShowNamesForAI), "ShowNamesForAI" ] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(showVehicleCrewInfo), "showVehicleCrewInfo" ] call EFUNC(common,readSettingFromModule); diag_log text "[ACE]: NameTags Module Initialized."; diff --git a/addons/nametags/stringtable.xml b/addons/nametags/stringtable.xml index 7d085b9d44..9cd99adaef 100644 --- a/addons/nametags/stringtable.xml +++ b/addons/nametags/stringtable.xml @@ -58,9 +58,7 @@ Játékosok rendfokozatának mutatása (névcímke szükséges) Показать звания игроков (требует имен игроков) - - - + Show vehicle crew info Zeige Fahrzeugbesatzung Mostrar tripulantes @@ -68,5 +66,8 @@ Zobrazit info o posádce vozidla Показать экипаж + + Show name tags for AI units + diff --git a/addons/optionsmenu/CfgEventHandlers.hpp b/addons/optionsmenu/CfgEventHandlers.hpp index 88bfdf4e6b..b97829836e 100644 --- a/addons/optionsmenu/CfgEventHandlers.hpp +++ b/addons/optionsmenu/CfgEventHandlers.hpp @@ -3,9 +3,3 @@ class Extended_PreInit_EventHandlers { init = QUOTE(call COMPILE_FILE(XEH_preInit)); }; }; - -class Extended_PostInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_postInit)); - }; -}; diff --git a/addons/optionsmenu/XEH_postInit.sqf b/addons/optionsmenu/XEH_postInit.sqf deleted file mode 100644 index c0b61d87de..0000000000 --- a/addons/optionsmenu/XEH_postInit.sqf +++ /dev/null @@ -1,4 +0,0 @@ -#include "script_component.hpp" - -//Add Settings from configFile -[] call FUNC(addFromConfig); diff --git a/addons/optionsmenu/XEH_preInit.sqf b/addons/optionsmenu/XEH_preInit.sqf index 97df9410e6..83a50bce65 100644 --- a/addons/optionsmenu/XEH_preInit.sqf +++ b/addons/optionsmenu/XEH_preInit.sqf @@ -2,16 +2,11 @@ ADDON = false; -PREP(addClientSideColor); -PREP(addClientSideOptions); -PREP(addFromConfig); -PREP(loadFromProfile); PREP(onListBoxSettingsChanged); PREP(onListBoxShowSelectionChanged); PREP(onSettingsMenuOpen); PREP(onSliderPosChanged); PREP(resetSettings); -PREP(saveToProfile); PREP(settingsMenuUpdateKeyView); PREP(settingsMenuUpdateList); PREP(updateSetting); diff --git a/addons/optionsmenu/functions/fnc_addClientSideColor.sqf b/addons/optionsmenu/functions/fnc_addClientSideColor.sqf deleted file mode 100644 index ca0473cb89..0000000000 --- a/addons/optionsmenu/functions/fnc_addClientSideColor.sqf +++ /dev/null @@ -1,19 +0,0 @@ -/** - * fnc_addClientSideColor.sqf - * @Descr: N/A - * @Author: PabstMirror - * - * @Arguments: [] - * @Return: - * @PublicAPI: false - */ -#include "script_component.hpp" - -private ["_currentValue"]; -PARAMS_4(_name,_localizedName,_localizedDescription,_defaultValue); - -GVAR(clientSideColors) pushBack [_name, _localizedName, _localizedDescription, [], _defaultValue]; - -//Get the current setting from profile (or default) and set it: -_currentValue = [MENU_TAB_COLORS, _name, _defaultValue] call FUNC(loadFromProfile); -[MENU_TAB_COLORS, _name, _currentValue] call FUNC(updateSetting); diff --git a/addons/optionsmenu/functions/fnc_addClientSideOptions.sqf b/addons/optionsmenu/functions/fnc_addClientSideOptions.sqf deleted file mode 100644 index 4ad9584410..0000000000 --- a/addons/optionsmenu/functions/fnc_addClientSideOptions.sqf +++ /dev/null @@ -1,19 +0,0 @@ -/** - * fnc_addClientSideOptions.sqf - * @Descr: N/A - * @Author: Glowbal - * - * @Arguments: [] - * @Return: - * @PublicAPI: false - */ -#include "script_component.hpp" - -private ["_currentValue"]; -PARAMS_5(_name,_localizedName,_localizedDescription,_possibleValues,_defaultValue); - -GVAR(clientSideOptions) pushBack [_name, _localizedName, _localizedDescription, _possibleValues, -1, _defaultValue]; - -//Get the current setting from profile (or default) and set it: -_currentValue = [MENU_TAB_OPTIONS, _name, _defaultValue] call FUNC(loadFromProfile); -[MENU_TAB_OPTIONS, _name, _currentValue] call FUNC(updateSetting); diff --git a/addons/optionsmenu/functions/fnc_addFromConfig.sqf b/addons/optionsmenu/functions/fnc_addFromConfig.sqf deleted file mode 100644 index 226b5dee73..0000000000 --- a/addons/optionsmenu/functions/fnc_addFromConfig.sqf +++ /dev/null @@ -1,38 +0,0 @@ -/** -* fnc_addFromConfig.sqf -* @Descr: N/A -* @Author: PabstMirror -* -* @Arguments: [] -* @Return: -* @PublicAPI: false -*/ -#include "script_component.hpp" - -if (isClass (configFile >> "ACE_Options")) then { - _countOptions = count (configFile >> "ACE_Options"); - for "_index" from 0 to (_countOptions - 1) do { - _optionEntry = (configFile >> "ACE_Options") select _index; - _name = configName _optionEntry; - _displayName = getText (_optionEntry >> "displayName"); - _description = getText (_optionEntry >> "description"); - _default = getNumber (_optionEntry >> "default"); - _choices = getArray (_optionEntry >> "values"); - if ((count _choices) == 0) then { - _choices = [(localize "STR_ACE_OptionsMenu_Disabled"), (localize "STR_ACE_OptionsMenu_Enabled")]; - }; - [_name, _displayName, _description, _choices, _default] call FUNC(addClientSideOptions); - }; -}; - -if (isClass (configFile >> "ACE_Colors")) then { - _countOptions = count (configFile >> "ACE_Colors"); - for "_index" from 0 to (_countOptions - 1) do { - _optionEntry = (configFile >> "ACE_Colors") select _index; - _name = configName _optionEntry; - _displayName = getText (_optionEntry >> "displayName"); - _description = getText (_optionEntry >> "description"); - _default = getArray (_optionEntry >> "default"); - [_name, _displayName, _description, _default] call FUNC(addClientSideColor); - }; -}; diff --git a/addons/optionsmenu/functions/fnc_loadFromProfile.sqf b/addons/optionsmenu/functions/fnc_loadFromProfile.sqf deleted file mode 100644 index 21819f1add..0000000000 --- a/addons/optionsmenu/functions/fnc_loadFromProfile.sqf +++ /dev/null @@ -1,36 +0,0 @@ -/** -* fnc_loadFromProfile.sqf -* @Descr: N/A -* @Author: Glowbal -* -* @Arguments: [] -* @Return: -* @PublicAPI: false -*/ -#include "script_component.hpp" - -private ["_typeString", "_settingValue", "_badData"]; -PARAMS_3(_type,_name,_default); - -_typeString = ""; -switch (_type) do { -case (MENU_TAB_OPTIONS): {_typeString = "option";}; -case (MENU_TAB_COLORS): {_typeString = "color";}; -}; - -_settingValue = profileNamespace getvariable [(format ["ace_%1_%2", _typeString, _name]), _default]; - -_badData = isNil "_settingValue"; -if (!_badData) then { - switch (_type) do { - case (MENU_TAB_OPTIONS): {_badData = ((typeName _settingValue) != (typeName 0));}; - case (MENU_TAB_COLORS): {_badData = (((typeName _settingValue) != (typeName [])) || {(count _settingValue) != 4});}; - }; -}; -if (_badData) then { - _settingValue = _default; - systemChat format ["Bad Data in profile [ace_%1_%2] using default", _typeString, _name]; - ERROR("Bad Value in profile"); -}; - -_settingValue diff --git a/addons/optionsmenu/functions/fnc_onSettingsMenuOpen.sqf b/addons/optionsmenu/functions/fnc_onSettingsMenuOpen.sqf index 11f5a3ef64..e3137f8ca9 100644 --- a/addons/optionsmenu/functions/fnc_onSettingsMenuOpen.sqf +++ b/addons/optionsmenu/functions/fnc_onSettingsMenuOpen.sqf @@ -9,5 +9,26 @@ */ #include "script_component.hpp" +// Filter only user setable setting +GVAR(clientSideOptions) = []; +GVAR(clientSideColors) = []; +{ + // If the setting is user setable and not forced + if ((_x select 2) && !(_x select 6)) then { + // Append the current value to the setting metadata + _setting = + _x; + _setting pushBack (missionNamespace getVariable (_x select 0)); + + // Categorize the setting according to types + // @todo: allow the user to modify other types of parameters? + if ((_x select 1) == "SCALAR" || (_x select 1) == "BOOL") then { + GVAR(clientSideOptions) pushBack _setting; + }; + if ((_x select 1) == "COLOR") then { + GVAR(clientSideColors) pushBack _setting; + }; + }; +} forEach EGVAR(common,settings); + //Delay a frame [{ [MENU_TAB_OPTIONS] call FUNC(onListBoxShowSelectionChanged) }, []] call EFUNC(common,execNextFrame); diff --git a/addons/optionsmenu/functions/fnc_resetSettings.sqf b/addons/optionsmenu/functions/fnc_resetSettings.sqf index bdc5c7662a..dd4b951ef5 100644 --- a/addons/optionsmenu/functions/fnc_resetSettings.sqf +++ b/addons/optionsmenu/functions/fnc_resetSettings.sqf @@ -13,13 +13,13 @@ private ["_name", "_default", "_lastSelected"]; { _name = _x select 0; - _default = _x select 5; + _default = _x select 7; [MENU_TAB_OPTIONS, _name, _default] call FUNC(updateSetting); } forEach GVAR(clientSideOptions); { _name = _x select 0; - _default = _x select 4; + _default = _x select 7; [MENU_TAB_COLORS, _name, _default] call FUNC(updateSetting); } forEach GVAR(clientSideColors); diff --git a/addons/optionsmenu/functions/fnc_saveToProfile.sqf b/addons/optionsmenu/functions/fnc_saveToProfile.sqf deleted file mode 100644 index 30db652186..0000000000 --- a/addons/optionsmenu/functions/fnc_saveToProfile.sqf +++ /dev/null @@ -1,37 +0,0 @@ -/** -* fnc_saveToProfile.sqf -* @Descr: Save the clientside option to the profile. -* @Author: Glowbal -* -* @Arguments: [name STRING (Name of setting)] -* @Return: BOOL True if saved. -* @PublicAPI: false -*/ -#include "script_component.hpp" - -private ["_nameSelected", "_saved"]; -PARAMS_2(_type,_name); - -_saved = false; -switch (_type) do { -case (MENU_TAB_OPTIONS): { - { - _nameSelected = _x select 0; - if (_nameSelected == _name) exitwith { - profileNamespace setvariable [(format ["ace_option_%1", _name]), (_x select 4)]; - _saved = true; - }; - }foreach GVAR(clientSideOptions); - }; -case (MENU_TAB_COLORS): { - { - _nameSelected = _x select 0; - if (_nameSelected == _name) exitwith { - profileNamespace setvariable [(format ["ace_color_%1", _name]), (_x select 3)]; - _saved = true; - }; - }foreach GVAR(clientSideColors); - }; -}; - -_saved diff --git a/addons/optionsmenu/functions/fnc_settingsMenuUpdateKeyView.sqf b/addons/optionsmenu/functions/fnc_settingsMenuUpdateKeyView.sqf index 09242bcb8c..c271ecd176 100644 --- a/addons/optionsmenu/functions/fnc_settingsMenuUpdateKeyView.sqf +++ b/addons/optionsmenu/functions/fnc_settingsMenuUpdateKeyView.sqf @@ -33,8 +33,8 @@ if (count _collection > 0) then { _setting = _collection select _settingIndex; _entryName = _setting select 0; - _localizedName = _setting select 1; - _localizedDescription = _setting select 2; + _localizedName = _setting select 3; + _localizedDescription = _setting select 4; if (_localizedName == "") then {_localizedName = _entryName;}; (_settingsMenu displayCtrl 250) ctrlSetText _localizedName; @@ -43,15 +43,23 @@ if (count _collection > 0) then { switch (GVAR(optionMenu_openTab)) do { case (MENU_TAB_OPTIONS): { - _possibleValues = _setting select 3; - _settingsValue = _setting select 4; - lbClear 400; - { lbAdd [400, _x]; } foreach _possibleValues; + _possibleValues = _setting select 5; + _settingsValue = _setting select 8; + // Created disable/enable options for bools + if ((_setting select 1) == "BOOL") then { + lbClear 400; + lbAdd [400, (localize "STR_ACE_OptionsMenu_Disabled")]; + lbAdd [400, (localize "STR_ACE_OptionsMenu_Enabled")]; + _settingsValue = [0, 1] select _settingsValue; + } else { + lbClear 400; + { lbAdd [400, _x]; } foreach _possibleValues; + }; (_settingsMenu displayCtrl 400) lbSetCurSel _settingsValue; }; case (MENU_TAB_COLORS): { - _currentColor = _setting select 3; + _currentColor = _setting select 8; { sliderSetPosition [_x, (255 * (_currentColor select _forEachIndex))]; } forEach [410, 411, 412, 413]; diff --git a/addons/optionsmenu/functions/fnc_settingsMenuUpdateList.sqf b/addons/optionsmenu/functions/fnc_settingsMenuUpdateList.sqf index ff825a2141..73a6d3de3b 100644 --- a/addons/optionsmenu/functions/fnc_settingsMenuUpdateList.sqf +++ b/addons/optionsmenu/functions/fnc_settingsMenuUpdateList.sqf @@ -21,21 +21,30 @@ lbclear _ctrlList; switch (GVAR(optionMenu_openTab)) do { case (MENU_TAB_OPTIONS): { { - _settingsText = ((_x select 3) select (_x select 4)); - _ctrlList lbadd (_x select 1); + _ctrlList lbadd (_x select 3); + + _settingsValue = _x select 8; + + // Created disable/enable options for bools + _settingsText = if ((_x select 1) == "BOOL") then { + [(localize "STR_ACE_OptionsMenu_Disabled"), (localize "STR_ACE_OptionsMenu_Enabled")] select _settingsValue; + } else { + (_x select 5) select _settingsValue; + }; + _ctrlList lbadd (_settingsText); }foreach GVAR(clientSideOptions); }; case (MENU_TAB_COLORS): { { - _color = +(_x select 3); + _color = +(_x select 8); { _color set [_forEachIndex, ((round (_x * 100))/100)]; } forEach _color; _settingsColor = str _color; - _ctrlList lbadd (_x select 1); + _ctrlList lbadd (_x select 3); _ctrlList lbadd (_settingsColor); - _ctrlList lnbSetColor [[_forEachIndex, 1], (_x select 3)]; + _ctrlList lnbSetColor [[_forEachIndex, 1], (_x select 8)]; }foreach GVAR(clientSideColors); }; }; diff --git a/addons/optionsmenu/functions/fnc_updateSetting.sqf b/addons/optionsmenu/functions/fnc_updateSetting.sqf index 403a09cdb2..e4a9917f25 100644 --- a/addons/optionsmenu/functions/fnc_updateSetting.sqf +++ b/addons/optionsmenu/functions/fnc_updateSetting.sqf @@ -17,25 +17,31 @@ _changed = false; switch (_type) do { case (MENU_TAB_OPTIONS): { { - if (((_x select 0) == _name) && {!((_x select 4) isEqualTo _newValue)}) then { - _changed = true; - _x set [4, _newValue]; + if ((_x select 0) == _name) then { + + if ((_x select 1) == "BOOL") then { + _newValue = [false, true] select _newValue; + }; + + if !((_x select 8) isEqualTo _newValue) then { + _changed = true; + _x set [8, _newValue]; + } ; + }; } foreach GVAR(clientSideOptions); }; case (MENU_TAB_COLORS): { { - if (((_x select 0) == _name) && {!((_x select 3) isEqualTo _newValue)}) then { + if (((_x select 0) == _name) && {!((_x select 8) isEqualTo _newValue)}) then { _changed = true; - _x set [3, _newValue]; + _x set [8, _newValue]; }; } foreach GVAR(clientSideColors); }; }; if (_changed) then { - missionNameSpace setVariable [_name, _newValue]; - [_type, _name] call FUNC(saveToProfile); - ["SettingChanged", [_name, _newValue]] call EFUNC(common,localEvent); - TRACE_2("Variable Updated",_name,_newValue); + profileNamespace setVariable [_name, _newValue]; + [_name, _newValue] call EFUNC(common,setSetting); }; diff --git a/addons/overheating/CfgSounds.hpp b/addons/overheating/CfgSounds.hpp index fd3a5596bd..c32fc02abf 100644 --- a/addons/overheating/CfgSounds.hpp +++ b/addons/overheating/CfgSounds.hpp @@ -3,4 +3,24 @@ class CfgSounds { sound[] = {QUOTE(PATHTOF(sounds\barrelswap.ogg)),5,1,200}; titles[] = {}; }; + class GVAR(jamming_rifle) { + name=QGVAR(jamming_rifle); + sound[]={QUOTE(PATHTOF(sounds\jamming_rifle.wav)),1,1}; + titles[]={}; + }; + class GVAR(jamming_pistol) { + name=QGVAR(jamming_pistol); + sound[]={QUOTE(PATHTOF(sounds\jamming_pistol.wav)),1,1}; + titles[]={}; + }; + class GVAR(fixing_rifle) { + name=QGVAR(fixing_rifle); + sound[]={QUOTE(PATHTOF(sounds\fixing_rifle.wav)),1,1}; + titles[]={}; + }; + class GVAR(fixing_pistol) { + name= QGVAR(fixing_pistol); + sound[]={QUOTE(PATHTOF(sounds\fixing_pistol.wav)),1,1}; + titles[]={}; + }; }; diff --git a/addons/overheating/functions/fnc_checkTemperature.sqf b/addons/overheating/functions/fnc_checkTemperature.sqf index 92b6d1727e..02747b0129 100644 --- a/addons/overheating/functions/fnc_checkTemperature.sqf +++ b/addons/overheating/functions/fnc_checkTemperature.sqf @@ -1,15 +1,18 @@ /* * Author: Commy2 and CAA-Picard - * * Make the player check the temperature of his weapon * * Arguments: - * 0: _player - * 1: _weapon + * 0: Player + * 1: Weapon * - * Return Values: + * Return Value: * None * + * Example: + * None + * + * Public: No */ #include "\z\ace\addons\overheating\script_component.hpp" diff --git a/addons/overheating/functions/fnc_clearJam.sqf b/addons/overheating/functions/fnc_clearJam.sqf index 829ab34811..76941d75ac 100644 --- a/addons/overheating/functions/fnc_clearJam.sqf +++ b/addons/overheating/functions/fnc_clearJam.sqf @@ -1,15 +1,16 @@ /* * Author: Commy2 + * Make the unit clear the jam from a weapon * - * Clears the jam from a weapon + * Arguments: + * 0: Player + * 1: Weapon + * 2: Skip anim? * - * Argument: - * 0: Last temperature (number) - * 1: Barrel mass (number) - * 2: Time (number) + * Return Value: + * None * - * Return value: - * New temperature (number) + * Public: No */ #include "\z\ace\addons\overheating\script_component.hpp" @@ -42,6 +43,12 @@ if (_weapon in _jammedWeapons) then { _unit playActionNow _clearJamAction; }; - + if (_weapon == primaryWeapon _unit) then { + playSound QGVAR(fixing_rifle); + } else { + if (_weapon == secondaryWeapon _unit) then { + playSound QGVAR(fixing_pistol); + }; + }; [localize "STR_ACE_Overheating_WeaponUnjammed"] call EFUNC(common,displayTextStructured); }; diff --git a/addons/overheating/functions/fnc_cooldown.sqf b/addons/overheating/functions/fnc_cooldown.sqf index 13d53c7327..718c77474f 100644 --- a/addons/overheating/functions/fnc_cooldown.sqf +++ b/addons/overheating/functions/fnc_cooldown.sqf @@ -1,15 +1,16 @@ /* * Author: CAA-Picard - * * Calculate cooling down of the weapon. * * Argument: - * 0: Last temperature (number) - * 1: Barrel mass (number) - * 2: Time (number) + * 0: Last temperature + * 1: Barrel mass + * 2: Time * * Return value: - * New temperature (number) + * New temperature + * + * Public: No */ #include "\z\ace\addons\overheating\script_component.hpp" diff --git a/addons/overheating/functions/fnc_displayTemperature.sqf b/addons/overheating/functions/fnc_displayTemperature.sqf index 130eec5f39..9af817f8fd 100644 --- a/addons/overheating/functions/fnc_displayTemperature.sqf +++ b/addons/overheating/functions/fnc_displayTemperature.sqf @@ -1,15 +1,15 @@ /* * Author: Commy2 and CAA-Picard - * * Displays the weapon temperature * * Arguments: - * 0: _player - * 1: _weapon + * 0: Player + * 1: Weapon * * Return Values: * None * + * Public: No */ #include "\z\ace\addons\overheating\script_component.hpp" diff --git a/addons/overheating/functions/fnc_jamWeapon.sqf b/addons/overheating/functions/fnc_jamWeapon.sqf index beb3a1925b..f11b72688c 100644 --- a/addons/overheating/functions/fnc_jamWeapon.sqf +++ b/addons/overheating/functions/fnc_jamWeapon.sqf @@ -1,14 +1,15 @@ /* * Author: Commy2, based on KK_fnc_playerWeaponMulfunction from KillzoneKid - * * Jam the weapon * * Argument: - * 0: unit - * 1: weapon + * 0: Unit + * 1: Weapon * * Return value: * None + * + * Public: No */ #include "\z\ace\addons\overheating\script_component.hpp" diff --git a/addons/overheating/functions/fnc_overheat.sqf b/addons/overheating/functions/fnc_overheat.sqf index 05a286cfa2..9f26d51869 100644 --- a/addons/overheating/functions/fnc_overheat.sqf +++ b/addons/overheating/functions/fnc_overheat.sqf @@ -1,17 +1,19 @@ /* * Author: Commy2 and CAA-Picard - * - * Heat up the weapon + * Handle weapon fire, heat up the weapon * * Argument: - * 0: unit - * 1: weapon - * 2: ammo - * 3: projectile - * 4: velocity + * 0: Unit + * 1: Weapon + * 3: Muzzle + * 4: Ammo + * 5: Magazine + * 6: Projectile * * Return value: * None + * + * Public: No */ #include "\z\ace\addons\overheating\script_component.hpp" diff --git a/addons/overheating/functions/fnc_swapBarrel.sqf b/addons/overheating/functions/fnc_swapBarrel.sqf index 6bacbe5049..2384fb470e 100644 --- a/addons/overheating/functions/fnc_swapBarrel.sqf +++ b/addons/overheating/functions/fnc_swapBarrel.sqf @@ -1,14 +1,15 @@ /* * Author: Commy2 - * * Make a unit start swapping it's barrel * * Argument: - * 0: unit - * 1: weapon + * 0: Unit + * 1: Weapon * * Return value: * None + * + * Public: No */ #include "\z\ace\addons\overheating\script_component.hpp" diff --git a/addons/overheating/functions/fnc_swapBarrelCallback.sqf b/addons/overheating/functions/fnc_swapBarrelCallback.sqf index 88201dc9f4..e626bf2aea 100644 --- a/addons/overheating/functions/fnc_swapBarrelCallback.sqf +++ b/addons/overheating/functions/fnc_swapBarrelCallback.sqf @@ -1,14 +1,15 @@ /* * Author: Commy2 - * * Swap barrel callback * * Argument: - * 0: unit - * 1: weapon + * 0: Unit + * 1: Weapon * * Return value: * None + * + * Public: No */ #include "\z\ace\addons\overheating\script_component.hpp" diff --git a/TO_MERGE/cse/sys_weaponheat/sound/fixing_pistol.wav b/addons/overheating/sounds/fixing_pistol.wav similarity index 100% rename from TO_MERGE/cse/sys_weaponheat/sound/fixing_pistol.wav rename to addons/overheating/sounds/fixing_pistol.wav diff --git a/TO_MERGE/cse/sys_weaponheat/sound/fixing_rifle.wav b/addons/overheating/sounds/fixing_rifle.wav similarity index 100% rename from TO_MERGE/cse/sys_weaponheat/sound/fixing_rifle.wav rename to addons/overheating/sounds/fixing_rifle.wav diff --git a/TO_MERGE/cse/sys_weaponheat/sound/jamming_pistol.wav b/addons/overheating/sounds/jamming_pistol.wav similarity index 100% rename from TO_MERGE/cse/sys_weaponheat/sound/jamming_pistol.wav rename to addons/overheating/sounds/jamming_pistol.wav diff --git a/TO_MERGE/cse/sys_weaponheat/sound/jamming_rifle.wav b/addons/overheating/sounds/jamming_rifle.wav similarity index 100% rename from TO_MERGE/cse/sys_weaponheat/sound/jamming_rifle.wav rename to addons/overheating/sounds/jamming_rifle.wav diff --git a/addons/overpressure/$PBOPREFIX$ b/addons/overpressure/$PBOPREFIX$ new file mode 100644 index 0000000000..fc5a82e0f7 --- /dev/null +++ b/addons/overpressure/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\overpressure \ No newline at end of file diff --git a/addons/overpressure/CfgEventHandlers.hpp b/addons/overpressure/CfgEventHandlers.hpp new file mode 100644 index 0000000000..40c3b32a57 --- /dev/null +++ b/addons/overpressure/CfgEventHandlers.hpp @@ -0,0 +1,46 @@ + +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; + +class Extended_PostInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; + +class Extended_FiredBIS_EventHandlers { + class CAManBase { + class ADDON { + firedBIS = QUOTE(if (local (_this select 0) && {getNumber (configfile >> 'CfgWeapons' >> _this select 1 >> QUOTE(QGVAR(Damage))) > 0}) then {_this call DFUNC(fireLauncherBackblast)}); + }; + }; + + class Tank { + class ADDON { + firedBIS = QUOTE(if (local (_this select 0) && {getNumber (configfile >> 'CfgWeapons' >> _this select 1 >> QUOTE(QGVAR(Damage))) > 0}) then {_this call DFUNC(fireOverpressureZone)}); + }; + }; + class Car { + class ADDON { + firedBIS = QUOTE(if (local (_this select 0) && {getNumber (configfile >> 'CfgWeapons' >> _this select 1 >> QUOTE(QGVAR(Damage))) > 0}) then {_this call DFUNC(fireOverpressureZone)}); + }; + }; + class Helicopter { + class ADDON { + firedBIS = QUOTE(if (local (_this select 0) && {getNumber (configfile >> 'CfgWeapons' >> _this select 1 >> QUOTE(QGVAR(Damage))) > 0}) then {_this call DFUNC(fireOverpressureZone)}); + }; + }; + class Plane { + class ADDON { + firedBIS = QUOTE(if (local (_this select 0) && {getNumber (configfile >> 'CfgWeapons' >> _this select 1 >> QUOTE(QGVAR(Damage))) > 0}) then {_this call DFUNC(fireOverpressureZone)}); + }; + }; + class Ship_F { + class ADDON { + firedBIS = QUOTE(if (local (_this select 0) && {getNumber (configfile >> 'CfgWeapons' >> _this select 1 >> QUOTE(QGVAR(Damage))) > 0}) then {_this call DFUNC(fireOverpressureZone)}); + }; + }; +}; diff --git a/addons/overpressure/CfgWeapons.hpp b/addons/overpressure/CfgWeapons.hpp new file mode 100644 index 0000000000..5880795ee2 --- /dev/null +++ b/addons/overpressure/CfgWeapons.hpp @@ -0,0 +1,49 @@ + +class CfgWeapons { + + class LauncherCore; + class Launcher: LauncherCore { + GVAR(angle) = 60; + GVAR(range) = 10; + GVAR(damage) = 0.7; + }; + + class Launcher_Base_F: Launcher {}; + + class launch_Titan_base: Launcher_Base_F { + GVAR(angle) = 40; + GVAR(range) = 8; + GVAR(damage) = 0.5; + }; + + class launch_Titan_short_base: launch_Titan_base { + GVAR(angle) = 40; + GVAR(range) = 8; + GVAR(damage) = 0.5; + }; + + class launch_NLAW_F: Launcher_Base_F { + GVAR(angle) = 40; + GVAR(range) = 5; + GVAR(damage) = 0.6; + }; + + class launch_RPG32_F: Launcher_Base_F { + GVAR(angle) = 60; + GVAR(range) = 15; + GVAR(damage) = 0.7; + }; + + class CannonCore; + class cannon_120mm: CannonCore { + GVAR(angle) = 90; + GVAR(range) = 50; + GVAR(damage) = 0.85; + }; + + class mortar_155mm_AMOS: CannonCore { + GVAR(angle) = 90; + GVAR(range) = 60; + GVAR(damage) = 1; + }; +}; diff --git a/addons/backblast/README.md b/addons/overpressure/README.md similarity index 94% rename from addons/backblast/README.md rename to addons/overpressure/README.md index 857776693a..3d3f242e40 100644 --- a/addons/backblast/README.md +++ b/addons/overpressure/README.md @@ -1,4 +1,4 @@ -ace_backblast +ace_overpressure ============= Adds backblast to AT launchers and overpressure zones to tank cannons. diff --git a/addons/overpressure/XEH_postInit.sqf b/addons/overpressure/XEH_postInit.sqf new file mode 100644 index 0000000000..33c2e679c9 --- /dev/null +++ b/addons/overpressure/XEH_postInit.sqf @@ -0,0 +1,3 @@ +#include "script_component.hpp" + +["overpressure", FUNC(overpressureDamage)] call EFUNC(common,addEventHandler); diff --git a/addons/backblast/XEH_preInit.sqf b/addons/overpressure/XEH_preInit.sqf similarity index 50% rename from addons/backblast/XEH_preInit.sqf rename to addons/overpressure/XEH_preInit.sqf index ec4edb75bc..5eefc5eae4 100644 --- a/addons/backblast/XEH_preInit.sqf +++ b/addons/overpressure/XEH_preInit.sqf @@ -2,8 +2,9 @@ ADDON = false; +PREP(fireLauncherBackblast); +PREP(fireOverpressureZone); PREP(getDistance); -PREP(launcherBackblast); -PREP(tankDangerZone); +PREP(overpressureDamage); ADDON = true; diff --git a/addons/backblast/config.cpp b/addons/overpressure/config.cpp similarity index 85% rename from addons/backblast/config.cpp rename to addons/overpressure/config.cpp index 88de936cf9..4f866beedc 100644 --- a/addons/backblast/config.cpp +++ b/addons/overpressure/config.cpp @@ -6,12 +6,11 @@ class CfgPatches { weapons[] = {}; requiredVersion = REQUIRED_VERSION; requiredAddons[] = {"ace_common"}; - author[] = {"commy2", "KoffeinFlummi"}; + author[] = {"commy2","KoffeinFlummi","CAA-Picard"}; authorUrl = "https://github.com/commy2/"; VERSION_CONFIG; }; }; #include "CfgEventHandlers.hpp" - #include "CfgWeapons.hpp" diff --git a/addons/overpressure/functions/fnc_fireLauncherBackblast.sqf b/addons/overpressure/functions/fnc_fireLauncherBackblast.sqf new file mode 100644 index 0000000000..f42ffd23ed --- /dev/null +++ b/addons/overpressure/functions/fnc_fireLauncherBackblast.sqf @@ -0,0 +1,97 @@ +/* + * Author: commy2 and CAA-Picard + * + * Handle fire of local launchers + * + * Argument: + * 0: Unit that fired (Object) + * 1: Weapon fired (String) + * 2: Muzzle (String) + * 3: Mode (String) + * 4: Ammo (String) + * 5: Magazine (String) + * 6: Projectile (Object) + * + * Return value: + * None + */ +//#define DEBUG_MODE_FULL +#include "script_component.hpp" + +EXPLODE_7_PVT(_this,_firer,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); + +// Prevent AI from causing backblast damage +if !([_firer] call EFUNC(common,isPlayer)) exitWith {}; + +private ["_position", "_direction"]; + +_position = getPosASL _projectile; +_direction = [0, 0, 0] vectorDiff (vectorDir _projectile); + +private ["_backblastAngle", "_backblastRange", "_backblastDamage"]; + +_backblastAngle = getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(angle)) / 2; +_backblastRange = getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(range)); +_backblastDamage = getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(damage)); + +// Damage to others +private "_affected"; +_affected = getPos _projectile nearEntities ["CAManBase", _backblastRange]; + +// Let each client handle their own affected units +["overpressure", _affected, [_firer, _position, _direction, _weapon]] call EFUNC(common,targetEvent); + +// Damage to the firer +private "_distance"; +_distance = [_position, _direction, _backblastRange] call FUNC(getDistance); + +TRACE_1("Distance",_distance); + +if (_distance < _backblastRange) then { + private ["_alpha", "_beta", "_damage"]; + + _alpha = sqrt (1 - _distance / _backblastRange); + _beta = sqrt 0.5; + + _damage = 2 * _alpha * _beta * _backblastDamage; + [_damage * 100] call BIS_fnc_bloodEffect; + + // TODO: Sort this interaction with medical + if (isClass (configFile >> "CfgPatches" >> "ACE_Medical")) then { + [_firer, "HitBody", ([_firer, "", ((_firer getHitPointDamage "HitBody") + _damage), objNull, objNull] call EFUNC(medical,handleDamage))] call EFUNC(medical,setHitPointDamage); + } else { + _firer setDamage (damage _firer + _damage); + }; +}; + +// Draw debug lines +#ifdef DEBUG_MODE_FULL + [ _position, + _position vectorAdd (_direction vectorMultiply _backblastRange), + [1,1,0,1] + ] call EFUNC(common,addLineToDebugDraw); + + private "_ref"; + _ref = _direction call EFUNC(common,createOrthonormalReference); + [ _position, + _position vectorAdd (_direction vectorMultiply _backblastRange) vectorAdd ((_ref select 1) vectorMultiply _backblastRange * tan _backblastAngle), + [1,1,0,1] + ] call EFUNC(common,addLineToDebugDraw); + [ _position, + _position vectorAdd (_direction vectorMultiply _backblastRange) vectorDiff ((_ref select 1) vectorMultiply _backblastRange * tan _backblastAngle), + [1,1,0,1] + ] call EFUNC(common,addLineToDebugDraw); + [ _position, + _position vectorAdd (_direction vectorMultiply _backblastRange) vectorAdd ((_ref select 2) vectorMultiply _backblastRange * tan _backblastAngle), + [1,1,0,1] + ] call EFUNC(common,addLineToDebugDraw); + [ _position, + _position vectorAdd (_direction vectorMultiply _backblastRange) vectorDiff ((_ref select 2) vectorMultiply _backblastRange * tan _backblastAngle), + [1,1,0,1] + ] call EFUNC(common,addLineToDebugDraw); + + [ _position, + _position vectorAdd (_direction vectorMultiply (_distance min _backblastRange)), + [1,0,0,1] + ] call EFUNC(common,addLineToDebugDraw); +#endif diff --git a/addons/overpressure/functions/fnc_fireOverpressureZone.sqf b/addons/overpressure/functions/fnc_fireOverpressureZone.sqf new file mode 100644 index 0000000000..cc4918275d --- /dev/null +++ b/addons/overpressure/functions/fnc_fireOverpressureZone.sqf @@ -0,0 +1,70 @@ +/* + * Author: commy2 and CAA-Picard + * + * Handle fire of local vehicle weapons creating overpressure zones + * + * Argument: + * 0: Unit that fired (Object) + * 1: Weapon fired (String) + * 2: Muzzle (String) + * 3: Mode (String) + * 4: Ammo (String) + * 5: Magazine (String) + * 6: Projectile (Object) + * + * Return value: + * None + */ +//#define DEBUG_MODE_FULL +#include "script_component.hpp" + +EXPLODE_7_PVT(_this,_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? + +private ["_position", "_direction"]; + +_position = getPosASL _projectile; +_direction = vectorDir _projectile; + +private ["_dangerZoneAngle", "_dangerZoneRange", "_dangerZoneDamage"]; + +_dangerZoneAngle = getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(angle)) / 2; +_dangerZoneRange = getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(range)); +_dangerZoneDamage = getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(damage)); + +// Damage to others +private "_affected"; +_affected = getPos _projectile nearEntities ["CAManBase", _dangerZoneRange]; + +// Let each client handle their own affected units +["overpressure", _affected, [_firer, _position, _direction, _weapon]] call EFUNC(common,targetEvent); + +// Draw debug lines +#ifdef DEBUG_MODE_FULL + [ _position, + _position vectorAdd (_direction vectorMultiply _dangerZoneRange), + [1,0,0,1] + ] call EFUNC(common,addLineToDebugDraw); + + private "_ref"; + _ref = _direction call EFUNC(common,createOrthonormalReference); + [ _position, + _position vectorAdd (_direction vectorMultiply _dangerZoneRange) vectorAdd ((_ref select 1) vectorMultiply _dangerZoneRange * tan _dangerZoneAngle), + [1,1,0,1] + ] call EFUNC(common,addLineToDebugDraw); + [ _position, + _position vectorAdd (_direction vectorMultiply _dangerZoneRange) vectorDiff ((_ref select 1) vectorMultiply _dangerZoneRange * tan _dangerZoneAngle), + [1,1,0,1] + ] call EFUNC(common,addLineToDebugDraw); + [ _position, + _position vectorAdd (_direction vectorMultiply _dangerZoneRange) vectorAdd ((_ref select 2) vectorMultiply _dangerZoneRange * tan _dangerZoneAngle), + [1,1,0,1] + ] call EFUNC(common,addLineToDebugDraw); + [ _position, + _position vectorAdd (_direction vectorMultiply _dangerZoneRange) vectorDiff ((_ref select 2) vectorMultiply _dangerZoneRange * tan _dangerZoneAngle), + [1,1,0,1] + ] call EFUNC(common,addLineToDebugDraw); + +#endif diff --git a/addons/overpressure/functions/fnc_getDistance.sqf b/addons/overpressure/functions/fnc_getDistance.sqf new file mode 100644 index 0000000000..6ffa60f7af --- /dev/null +++ b/addons/overpressure/functions/fnc_getDistance.sqf @@ -0,0 +1,40 @@ +/* + * Author: commy2 and CAA-Picard + * + * Calculate the distance to the first intersection of a line + * + * Argument: + * 0: Pos ASL of origin (Array) + * 1: Direction (Array) + * 2: Max distance to search (Number) + * + * Return value: + * Distance to intersection (+- 0.1 m) + */ +#include "script_component.hpp" + +EXPLODE_3_PVT(_this,_posASL,_direction,_maxDistance); + +private ["_distance", "_interval", "_line", "_intersections"]; + +_distance = _maxDistance; +_interval = _distance; +_line = [_posASL, []]; + +while { + _interval > 0.1 +} do { + _interval = _interval / 2; + + _line set [1, _posASL vectorAdd (_direction vectorMultiply _distance)]; + + _intersections = { + _x isKindOf "Static" || {_x isKindOf "AllVehicles"} + } count (lineIntersectsWith _line); + + _distance = _distance + ([1, -1] select (_intersections > 0 || {terrainIntersectASL _line})) * _interval; + + if (_distance > _maxDistance) exitWith {_distance = 999}; +}; + +_distance diff --git a/addons/overpressure/functions/fnc_overpressureDamage.sqf b/addons/overpressure/functions/fnc_overpressureDamage.sqf new file mode 100644 index 0000000000..c19fed1c04 --- /dev/null +++ b/addons/overpressure/functions/fnc_overpressureDamage.sqf @@ -0,0 +1,70 @@ +/* + * Author: commy2 and CAA-Picard + * + * Calculate and apply backblast damage to potentially affected local units + * + * Argument: + * 0: Unit that fired (Object) + * 1: Pos ASL of the projectile (Array) + * 2: Direction of the projectile (Array) + * 3: Weapon fired (String) + * + * Return value: + * None + */ +#include "script_component.hpp" + +EXPLODE_4_PVT(_this,_firer,_posASL,_direction,_weapon); + +private ["_overpressureAngle", "_overpressureRange", "_overpressureDamage"]; + +_overpressureAngle = getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(angle)) / 2; +_overpressureRange = getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(range)); +_overpressureDamage = getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(damage)); + +TRACE_4("Parameters:",_overpressureAngle,_overpressureRange,_overpressureDamage,_weapon); + +private "_pos"; +_pos = _posASL; +if (!surfaceIsWater _pos) then { + _pos = ASLtoATL _pos; +}; + +{ + if (local _x && {_x != _firer} && {vehicle _x == _x}) then { + private ["_targetPositionASL", "_relativePosition", "_axisDistance", "_distance", "_angle", "_line", "_line2"]; + + _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]; + 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); + + _damage = 2 * _alpha * _beta * _overpressureDamage; + + // If the target is the ACE_player + if (_x == ACE_player) then {[_damage * 100] call BIS_fnc_bloodEffect}; + + // TODO: Sort this interaction with medical + if (isClass (configFile >> "CfgPatches" >> "ACE_Medical")) then { + [_x, "HitBody", ([_x, "", (_x getHitPointDamage "HitBody") + _damage, objNull, objNull] call EFUNC(medical,handleDamage))] call EFUNC(medical,setHitPointDamage); + _x spawn { + sleep 0.5; + [_this, "", 0, objNull, objNull] call EFUNC(medical,handleDamage); + }; + } else { + _x setDamage (damage _x + _damage); + }; + }; + }; +} forEach (_pos nearEntities ["CAManBase", _overpressureRange]); diff --git a/addons/overpressure/functions/script_component.hpp b/addons/overpressure/functions/script_component.hpp new file mode 100644 index 0000000000..d66ac7aec3 --- /dev/null +++ b/addons/overpressure/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\overpressure\script_component.hpp" \ No newline at end of file diff --git a/addons/overpressure/script_component.hpp b/addons/overpressure/script_component.hpp new file mode 100644 index 0000000000..8dac72cbbf --- /dev/null +++ b/addons/overpressure/script_component.hpp @@ -0,0 +1,12 @@ +#define COMPONENT overpressure +#include "\z\ace\Addons\main\script_mod.hpp" + +#ifdef DEBUG_ENABLED_OVERPRESSURE + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_ENABLED_OVERPRESSURE + #define DEBUG_SETTINGS DEBUG_ENABLED_OVERPRESSURE +#endif + +#include "\z\ace\Addons\main\script_macros.hpp" \ No newline at end of file diff --git a/addons/realisticnames/config.cpp b/addons/realisticnames/config.cpp index 347d0c1b2e..ea1318686b 100644 --- a/addons/realisticnames/config.cpp +++ b/addons/realisticnames/config.cpp @@ -292,8 +292,8 @@ class CfgVehicles { displayName = "$STR_ACE_RealisticNames_Heli_Attack_01_Name"; }; - class Heli_Light_01_base_F; - class B_Heli_Light_01_F: Heli_Light_01_base_F { + class Heli_Light_01_unarmed_base_F; + class B_Heli_Light_01_F: Heli_Light_01_unarmed_base_F { displayName = "$STR_ACE_RealisticNames_Heli_Light_01_Name"; }; @@ -302,7 +302,7 @@ class CfgVehicles { displayName = "$STR_ACE_RealisticNames_Heli_Light_01_armed_Name"; }; - class Heli_Light_01_civil_base_F: Heli_Light_01_base_F { + class Heli_Light_01_civil_base_F: Heli_Light_01_unarmed_base_F { displayName = "$STR_ACE_RealisticNames_Heli_Light_01_civil_Name"; }; diff --git a/addons/respawn/config.cpp b/addons/respawn/config.cpp index 0d914df949..19032df4f7 100644 --- a/addons/respawn/config.cpp +++ b/addons/respawn/config.cpp @@ -17,7 +17,13 @@ class CfgPatches { #include "CfgVehicleClasses.hpp" #include "CfgVehicles.hpp" -class ACE_Parameters_Boolean { - GVAR(SavePreDeathGear) = 0; - GVAR(RemoveDeadBodiesDisconnected) = 1; +class ACE_Settings { + class GVAR(SavePreDeathGear) { + value = 0; + typeName = "BOOL"; + }; + class GVAR(RemoveDeadBodiesDisconnected) { + value = 1; + typeName = "BOOL"; + }; }; diff --git a/addons/respawn/functions/fnc_module.sqf b/addons/respawn/functions/fnc_module.sqf index 0a996d0acc..5ba52fd40e 100644 --- a/addons/respawn/functions/fnc_module.sqf +++ b/addons/respawn/functions/fnc_module.sqf @@ -1,17 +1,17 @@ /* Name: ACE_Respawn_fnc_module - + Author(s): KoffeinFlummi, bux578, CAA-Picard, commy2 - + Description: initializes the respawn module - + Parameters: 0: OBJECT - logic 1: ARRAY - synced units 2: BOOLEAN - activated - + Returns: VOID */ @@ -27,8 +27,8 @@ if !(_activated) exitWith {}; GVAR(Module) = true; -[_logic, QGVAR(SavePreDeathGear), "SavePreDeathGear"] call EFUNC(common,readBooleanParameterFromModule); -[_logic, QGVAR(RemoveDeadBodiesDisconnected), "RemoveDeadBodiesDisconnected"] call EFUNC(common,readBooleanParameterFromModule); +[_logic, QGVAR(SavePreDeathGear), "SavePreDeathGear"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(RemoveDeadBodiesDisconnected), "RemoveDeadBodiesDisconnected"] call EFUNC(common,readSettingFromModule); if (isServer) then { if (GVAR(RemoveDeadBodiesDisconnected)) then { diff --git a/addons/resting/CfgSounds.hpp b/addons/resting/CfgSounds.hpp new file mode 100644 index 0000000000..b55d4d9ae8 --- /dev/null +++ b/addons/resting/CfgSounds.hpp @@ -0,0 +1,14 @@ +class CfgSounds { + class GVAR(rest) + { + name=QGVAR(rest); + sound[]={QUOTE(PATHTOF(sounds\weaponrest_rest.wav)),1,1}; + titles[]={}; + }; + class GVAR(unrest) + { + name=QGVAR(unrest); + sound[]={QUOTE(PATHTOF(sounds\weaponrest_unrest.wav)),1,1}; + titles[]={}; + }; +}; \ No newline at end of file diff --git a/addons/resting/config.cpp b/addons/resting/config.cpp index ac710c82a8..599c15d318 100644 --- a/addons/resting/config.cpp +++ b/addons/resting/config.cpp @@ -17,3 +17,5 @@ class CfgPatches { #include "CfgWeapons.hpp" #include "CfgMoves.hpp" + +#include "CfgSounds.hpp" \ No newline at end of file diff --git a/addons/resting/functions/fnc_restWeapon.sqf b/addons/resting/functions/fnc_restWeapon.sqf index e22a1309f3..52b1932f62 100644 --- a/addons/resting/functions/fnc_restWeapon.sqf +++ b/addons/resting/functions/fnc_restWeapon.sqf @@ -33,6 +33,7 @@ if (true in _intersects) then { // REST THE WEAPON addCamShake CAMSHAKE; + playSound QGVAR(rest); if ([_weapon] call FUNC(hasBipod) && {_intersects select 3}) then { _unit setVariable ["ACE_bipodDeployed", true]; diff --git a/addons/resting/functions/fnc_unRestWeapon.sqf b/addons/resting/functions/fnc_unRestWeapon.sqf index b182cd89e8..86caa31ac8 100644 --- a/addons/resting/functions/fnc_unRestWeapon.sqf +++ b/addons/resting/functions/fnc_unRestWeapon.sqf @@ -43,6 +43,7 @@ if (_unit getVariable ["ACE_bipodDeployed", false]) then { _picture = getText (configFile >> "CfgWeapons" >> _weapon >> "picture"); [localize "STR_ACE_Resting_WeaponLifted", _picture] call EFUNC(common,displayTextPicture); }; +playSound QGVAR(unrest); _unit setVariable ["ACE_weaponRested", false]; _unit setVariable ["ACE_bipodDeployed", false]; diff --git a/TO_MERGE/cse/sys_equipment/weaponresting/sound/weaponrest_rest.wav b/addons/resting/sounds/weaponrest_rest.wav similarity index 100% rename from TO_MERGE/cse/sys_equipment/weaponresting/sound/weaponrest_rest.wav rename to addons/resting/sounds/weaponrest_rest.wav diff --git a/TO_MERGE/cse/sys_equipment/weaponresting/sound/weaponrest_unrest.wav b/addons/resting/sounds/weaponrest_unrest.wav similarity index 100% rename from TO_MERGE/cse/sys_equipment/weaponresting/sound/weaponrest_unrest.wav rename to addons/resting/sounds/weaponrest_unrest.wav diff --git a/addons/scopes/CfgEventHandlers.hpp b/addons/scopes/CfgEventHandlers.hpp index 204f2e267e..b3d70a2861 100644 --- a/addons/scopes/CfgEventHandlers.hpp +++ b/addons/scopes/CfgEventHandlers.hpp @@ -13,39 +13,7 @@ class Extended_PostInit_EventHandlers { class Extended_Fired_EventHandlers { class CAManBase { class ADDON { - clientFired = QUOTE(if (_this select 0 == ACE_player) then { _this call FUNC(firedEH);};); - }; - }; -}; - -class Extended_Take_EventHandlers { - class CAManBase { - class ADDON { - clientTake = QUOTE(if (_this select 0 == ACE_player) then{ _this call FUNC(inventoryCheck);};); - }; - }; -}; - -class Extended_Put_EventHandlers { - class CAManBase { - class ADDON { - clientPut = QUOTE(if (_this select 0 == ACE_player) then {_this call FUNC(inventoryCheck);};); - }; - }; -}; - -class Extended_InitPost_EventHandlers { - class CAManBase { - class ADDON { - init = QUOTE(if (_this select 0 == call EFUNC(common,player)) then{ _this call FUNC(inventoryCheck);};); - }; - }; -}; - -class Extended_Respawn_EventHandlers { - class CAManBase { - class ADDON { - respawn = QUOTE(if (_this select 0 == call EFUNC(common,player)) then{ _this call FUNC(inventoryCheck);};); + fired = QUOTE(_this call FUNC(firedEH);); }; }; }; diff --git a/addons/scopes/RscTitles.hpp b/addons/scopes/RscTitles.hpp index 79de7e8214..a9c43aedaf 100644 --- a/addons/scopes/RscTitles.hpp +++ b/addons/scopes/RscTitles.hpp @@ -4,7 +4,7 @@ class RscTitles { movingEnable = 0; enableSimulation = 1; enableDisplay = 1; - onLoad = QUOTE(_this spawn compile preprocessFileLineNumbers QUOTE(QUOTE(PATHTOF(scripts\zeroingOnLoad.sqf))); uiNamespace setVariable [ARR_2('ACE_Scopes_Debug', _this)];); + onLoad = QUOTE(uiNamespace setVariable [ARR_2(QUOTE(QGVAR(ZeroingDisplay)),_this select 0)];); duration = 1e+011; fadein = 0; fadeout = 0; @@ -13,7 +13,7 @@ class RscTitles { class RscText; class controls { class ACE_Scopes_Zeroing_BG : RscPicture { - idc = 925001; + idc = 11; type = 0; text = PATHTOF(UI\scopes_bg.paa); style = 48 + 0x800; @@ -30,7 +30,7 @@ class RscTitles { h = 0.3 * safezoneH; }; class ACE_Scopes_Zeroing_Vertical : RscText { - idc = 925002; + idc = 12; type = 0; style = 2; sizeEx = 0.04; @@ -47,7 +47,7 @@ class RscTitles { h = 0.025 * safezoneH; }; class ACE_Scopes_Zeroing_Horizontal : RscText { - idc = 925003; + idc = 13; type = 0; style = 0; sizeEx = 0.04; diff --git a/addons/scopes/XEH_postInit.sqf b/addons/scopes/XEH_postInit.sqf index b7fd4bfc3a..8de7ff8af0 100644 --- a/addons/scopes/XEH_postInit.sqf +++ b/addons/scopes/XEH_postInit.sqf @@ -9,32 +9,27 @@ if !(hasInterface) exitWith {}; -// show overlay after changing weapon/optic -0 spawn { - _layer = [QGVAR(Zeroing)] call BIS_fnc_rscLayer; - while {True} do { - waitUntil {[ACE_player, 0,0] call FUNC(canAdjustScope)}; - _layer cutRsc [QGVAR(Zeroing), "PLAIN", 0, false]; - sleep 3; - _layer cutFadeOut 2; +// Check inventory when it changes +["playerInventoryChanged", { + [ACE_player] call FUNC(inventoryCheck); +}] call EFUNC(common,addEventhandler); - _weapon = currentWeapon ACE_player; - _optics = [ACE_player] call FUNC(getOptics); - waitUntil {sleep 0.05; !(_optics isEqualTo ([ACE_player] call FUNC(getOptics))) or (currentWeapon ACE_player != _weapon)}; - }; -}; -// instantly hide when scoping in -0 spawn { - _layer = [QGVAR(Zeroing)] call BIS_fnc_rscLayer; - while {True} do { - waitUntil {sleep 0.05; cameraView == "GUNNER"}; - if !(isNull GVAR(fadeScript)) then { - terminate GVAR(fadeScript); - }; +// Instantly hide knobs when scoping in +["cameraViewChanged", { + EXPLODE_2_PVT(_this,_player,_newCameraView); + if (_newCameraView == "GUNNER") then { + private "_layer"; + _layer = [QGVAR(Zeroing)] call BIS_fnc_rscLayer; _layer cutText ["", "PLAIN", 0]; + + + if !(isNil QGVAR(fadePFH)) then { + [GVAR(fadePFH)] call cba_fnc_removePerFrameHandler; + GVAR(fadePFH) = nil; + }; }; -}; +}] call EFUNC(common,addEventhandler); // Add keybinds diff --git a/addons/scopes/XEH_preInit.sqf b/addons/scopes/XEH_preInit.sqf index 9dc7450c94..e574cc72d4 100644 --- a/addons/scopes/XEH_preInit.sqf +++ b/addons/scopes/XEH_preInit.sqf @@ -6,8 +6,8 @@ PREP(adjustScope); PREP(canAdjustScope); PREP(firedEH); PREP(getOptics); -PREP(hideZeroing); PREP(inventoryCheck); +PREP(showZeroing); GVAR(fadeScript) = scriptNull; diff --git a/addons/scopes/config.cpp b/addons/scopes/config.cpp index 9d2ddbeacb..50ff6528d0 100644 --- a/addons/scopes/config.cpp +++ b/addons/scopes/config.cpp @@ -5,8 +5,8 @@ class CfgPatches { units[] = {}; weapons[] = {}; requiredVersion = REQUIRED_VERSION; - requiredAddons[] = { "ace_main", "ace_common" }; - author[] = {"KoffeinFlummi"}; + requiredAddons[] = { "ace_common" }; + author[] = {"KoffeinFlummi", "CAA-Picard"}; authorUrl = "https://github.com/KoffeinFlummi"; VERSION_CONFIG; }; diff --git a/addons/scopes/functions/fnc_adjustScope.sqf b/addons/scopes/functions/fnc_adjustScope.sqf index 7db640590a..6e71a391aa 100644 --- a/addons/scopes/functions/fnc_adjustScope.sqf +++ b/addons/scopes/functions/fnc_adjustScope.sqf @@ -1,42 +1,44 @@ /* * Author: KoffeinFlummi - * * Changes the adjustment for the current scope * - * Arguments: - * 0: Horizontal adjustment - * 1: Vertical adjustment + * Argument: + * 0: Unit + * 1: Horizontal adjustment + * 2: Vertical adjustment * - * Return Value: - * True + * Return value: + * True + * + * Public: No */ - #include "script_component.hpp" - + private ["_unit", "_weapons", "_zeroing", "_pitchbankyaw", "_pitch", "_bank", "_yaw", "_hint"]; _unit = _this select 0; -_weapons = [ - primaryWeapon _unit, - secondaryWeapon _unit, - handgunWeapon _unit -]; +_weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex); -if (isNil QGVAR(Adjustment)) then { - GVAR(Adjustment) = [[0,0], [0,0], [0,0]]; +_adjustment = _unit getVariable QGVAR(Adjustment); +if (isNil "_adjustment") then { + _adjustment = [[0,0], [0,0], [0,0]]; + _unit setVariable [QGVAR(Adjustment), _adjustment]; }; -_zeroing = GVAR(Adjustment) select (_weapons find (currentWeapon _unit)); +_zeroing = _adjustment select _weaponIndex; _zeroing set [0, (round (((_zeroing select 0) + (_this select 1)) * 10)) / 10]; _zeroing set [1, (round (((_zeroing select 1) + (_this select 2)) * 10)) / 10]; -GVAR(Adjustment) set [_weapons find (currentWeapon _unit), _zeroing]; +// Change the adjustment array +_adjustment set [_weaponIndex, _zeroing]; +[_unit, QGVAR(Adjustment), _adjustment, 0.5] call EFUNC(common,setVariablePublic); playSound (["ACE_Scopes_Click_1", "ACE_Scopes_Click_2", "ACE_Scopes_Click_3"] select floor random 3); // slightly rotate the player if looking through optic if (cameraView == "GUNNER") then { + _pitchbankyaw = [_unit] call EFUNC(common,getPitchBankYaw); // these are not exact mil-to-degree conversions, but instead chosen // to minimize the effect of rounding errors @@ -44,26 +46,11 @@ if (cameraView == "GUNNER") then { _bank = _pitchbankyaw select 1; _yaw = (_pitchbankyaw select 2) + ((_this select 1) * -0.04); [_unit, _pitch, _bank, _yaw] call EFUNC(common,setPitchBankYaw) -}; -_display = uiNamespace getVariable [QGVAR(ZeroingDisplay), displayNull]; -if !(isNull _display) then { - _vertical = _display displayCtrl 925002; - _horizontal = _display displayCtrl 925003; - _vertical ctrlSetText (str (_zeroing select 1)); - _horizontal ctrlSetText (str (_zeroing select 0)); -}; +} else { + + [] call FUNC(showZeroing); -if (!isNull (missionNamespace getVariable [QGVAR(fadeScript), scriptNull])) then { - terminate GVAR(fadeScript); -}; -if (cameraView != "GUNNER") then { - GVAR(fadeScript) = 0 spawn { - _layer = [QGVAR(Zeroing)] call BIS_fnc_rscLayer; - _layer cutRsc [QGVAR(Zeroing), "PLAIN", 0, false]; - sleep 3; - _layer cutFadeOut 2; - }; }; true diff --git a/addons/scopes/functions/fnc_canAdjustScope.sqf b/addons/scopes/functions/fnc_canAdjustScope.sqf index 8aea2ff9e4..eda08dc0ee 100644 --- a/addons/scopes/functions/fnc_canAdjustScope.sqf +++ b/addons/scopes/functions/fnc_canAdjustScope.sqf @@ -1,43 +1,40 @@ /* * Author: KoffeinFlummi - * * Checks if a player can adjust his optic in the given way. * - * Arguments: - * 0: Horizontal adjustment - * 1: Vertical adjustment + * Argument: + * 0: Unit + * 1: Horizontal adjustment + * 2: Vertical adjustment * - * Return Value: - * Can adjustment be done? (Bool) + * Return value: + * Can adjustment be done? + * + * Public: No */ - #include "script_component.hpp" -private ["_unit", "_weapons", "_zeroing", "_optic", "_maxHorizontal", "_maxVertical"]; +private ["_unit", "_weaponIndex", "_zeroing", "_optic", "_maxHorizontal", "_maxVertical"]; _unit = _this select 0; -_weapons = [ - primaryWeapon _unit, - secondaryWeapon _unit, - handgunWeapon _unit -]; +_weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex); +if (_weaponIndex < 0) exitWith {false}; -if !(currentWeapon _unit in _weapons) exitWith {false}; - -if (isNil QGVAR(Adjustment)) then { - GVAR(Adjustment) = [[0,0], [0,0], [0,0]]; +_adjustment = _unit getVariable QGVAR(Adjustment); +if (isNil "_adjustment") then { + _adjustment = [[0,0], [0,0], [0,0]]; }; if (isNil QGVAR(Optics)) then { GVAR(Optics) = ["", "", ""]; }; -_zeroing = GVAR(Adjustment) select (_weapons find (currentWeapon _unit)); +_zeroing = _adjustment select _weaponIndex; _zeroX = (_zeroing select 0) + (_this select 1); _zeroY = (_zeroing select 1) + (_this select 2); -_optic = GVAR(Optics) select (_weapons find (currentWeapon _unit)); +_optic = GVAR(Optics) select _weaponIndex; _maxHorizontal = getArray (configFile >> "CfgWeapons" >> _optic >> "ACE_ScopeAdjust_Horizontal"); _maxVertical = getArray (configFile >> "CfgWeapons" >> _optic >> "ACE_ScopeAdjust_Vertical"); if ((count _maxHorizontal < 2) or (count _maxVertical < 2)) exitWith {false}; diff --git a/addons/scopes/functions/fnc_firedEH.sqf b/addons/scopes/functions/fnc_firedEH.sqf index 4414f617d6..371d1e5f33 100644 --- a/addons/scopes/functions/fnc_firedEH.sqf +++ b/addons/scopes/functions/fnc_firedEH.sqf @@ -1,35 +1,42 @@ /* - * Author: KoffeinFlummi - * + * Author: KoffeinFlummi and CAA-Picard * Adjusts the flight path of the bullet according to the zeroing * - * Arguments: - * Fired EH + * Argument: + * 0: Unit + * 1: Weapon + * 3: Muzzle + * 4: Magazine + * 5: Ammo + * 6: Projectile * - * Return Value: + * Return value: * None + * + * Public: No */ - #include "script_component.hpp" -private ["_unit", "_weaponType", "_ammoType", "_magazineType", "_round", "_weapons", "_zeroing", "_direction", "_azimuth", "_altitude", "_velocity"]; +private ["_unit", "_adjustment", "_weapon", "_projectile", "_weaponIndex", "_zeroing", "_adjustment"]; _unit = _this select 0; -_weaponType = _this select 1; -_ammoType = _this select 4; -_round = _this select 5; -_magazineType = _this select 6; -_weapons = [ - primaryWeapon _unit, - secondaryWeapon _unit, - handgunWeapon _unit -]; -if !(_weaponType in _weapons) exitWith {}; +// Exit if the unit doesn't have any adjusment variable +_adjustment = _unit getVariable QGVAR(Adjustment); +if (isNil "_adjustment") exitWith {}; -_zeroing = GVAR(Adjustment) select (_weapons find _weaponType); +// Exit if the unit isn't a player +if !([_unit] call EFUNC(common,isPlayer)) exitWith {}; -// convert zeroing from mils to degrees +_weapon = _this select 1; +_projectile = _this select 5; + +_weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex); +if (_weaponIndex < 0) exitWith {}; + +_zeroing = _adjustment select _weaponIndex; + +// Convert zeroing from mils to degrees _zeroing = [_zeroing, {_this * 0.05625}] call EFUNC(common,map); -[_round, _zeroing select 0, _zeroing select 1, 0] call EFUNC(common,changeProjectileDirection); +[_projectile, _zeroing select 0, _zeroing select 1, 0] call EFUNC(common,changeProjectileDirection); diff --git a/addons/scopes/functions/fnc_getOptics.sqf b/addons/scopes/functions/fnc_getOptics.sqf index 7ff2c7ea1d..289ed5e7bd 100644 --- a/addons/scopes/functions/fnc_getOptics.sqf +++ b/addons/scopes/functions/fnc_getOptics.sqf @@ -1,21 +1,22 @@ /* * Author: commy2 - * * Gets the optic classnames of all currently equipped weapons. * * Arguments: - * 0: Unit (Object) + * 0: Unit * * Return Value: - * [optic of primary, optic of secondary, optic of handgun] (Array) + * 0: Optic of primary + * 1: Optic of secondary + * 2: Optic of handgun + * + * Public: No */ - #include "script_component.hpp" -private ["_unit", "_array"]; - -_unit = _this select 0; +EXPLODE_1_PVT(_this,_unit); +private ["_array"]; _array = ["", "", ""]; if !(_unit isKindOf "CAManBase") exitWith {_array}; diff --git a/addons/scopes/functions/fnc_hideZeroing.sqf b/addons/scopes/functions/fnc_hideZeroing.sqf deleted file mode 100644 index b41fd1dab6..0000000000 --- a/addons/scopes/functions/fnc_hideZeroing.sqf +++ /dev/null @@ -1,27 +0,0 @@ -// by commy2 - -#include "script_component.hpp" - -private ["_state", "_ctrl"]; - -_state = _this select 0; - -disableSerialization; -_ctrl = (uiNamespace getVariable ['ACE_dlgWeaponZeroing', displayNull]) displayCtrl 168; - -if (_state) then { - _ctrl ctrlSetPosition [0,0,0,0]; -} else { - private "_config"; - - _config = configFile >> "RscInGameUI" >> "RscWeaponZeroing" >> "CA_Zeroing"; - - _ctrl ctrlSetPosition [ - getNumber (_config >> "x"), - getNumber (_config >> "y"), - getNumber (_config >> "w"), - getNumber (_config >> "h") - ]; -}; - -_ctrl ctrlCommit 0; diff --git a/addons/scopes/functions/fnc_inventoryCheck.sqf b/addons/scopes/functions/fnc_inventoryCheck.sqf index 23971098d6..c83112c8a6 100644 --- a/addons/scopes/functions/fnc_inventoryCheck.sqf +++ b/addons/scopes/functions/fnc_inventoryCheck.sqf @@ -1,23 +1,42 @@ -// by KoffeinFlummi / commy2 - +/* + * Author: KoffeinFlummi and Commy2 + * Check if weapon optics changed and reset zeroing if needed + * + * Arguments: + * 0: Player + * + * Return Value: + * None + * + * Public: No + */ #include "script_component.hpp" -private "_new"; +EXPLODE_1_PVT(_this,_player); -_new = _this call FUNC(getOptics); +private ["_newOptics", "_adjustment"]; + +_adjustment = ACE_player getVariable QGVAR(Adjustment); +if (isNil "_adjustment") then { + _adjustment = [[0,0], [0,0], [0,0]]; + ACE_player setVariable [QGVAR(Adjustment), _adjustment]; + [ACE_player, QGVAR(Adjustment), _adjustment, 0.5] call EFUNC(common,setVariablePublic); +}; if (isNil QGVAR(Optics)) then { GVAR(Optics) = ["", "", ""]; }; - -if (isNil QGVAR(Adjustment)) then { - GVAR(Adjustment) = [[0,0], [0,0], [0,0]]; -}; +_newOptics = [_player] call FUNC(getOptics); { - if (_new select _forEachIndex != _x) then { - GVAR(Adjustment) set [_forEachIndex, [0,0]]; + if (_newOptics select _forEachIndex != _x) then { + // The optic for this weapon changed, set adjustment to zero + if !((_adjustment select _foreachindex) isEqualTo [0,0]) then { + _adjustment set [_forEachIndex, [0,0]]; + [ACE_player, QGVAR(Adjustment), _adjustment, 0.5] call EFUNC(common,setVariablePublic); + }; }; } forEach GVAR(Optics); -GVAR(Optics) = _new; +_adjustment = ACE_player getVariable QGVAR(Adjustment); +GVAR(Optics) = _newOptics; diff --git a/addons/scopes/functions/fnc_showZeroing.sqf b/addons/scopes/functions/fnc_showZeroing.sqf new file mode 100644 index 0000000000..836f69b2df --- /dev/null +++ b/addons/scopes/functions/fnc_showZeroing.sqf @@ -0,0 +1,59 @@ +/* + * Author: KoffeinFlummi and CAA-Picard + * Display the adjustment knobs, update their value and fade them out later + * + * Arguments: + * None + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" + +disableSerialization; + +private ["_weaponIndex","_adjustment","_layer","_display","_zeroing","_vertical","_horizontal"]; + +_weaponIndex = [ACE_player, currentWeapon ACE_player] call EFUNC(common,getWeaponIndex); +if (_weaponIndex < 0) exitWith {}; + +_adjustment = ACE_player getVariable QGVAR(Adjustment); +if (isNil "_adjustment") then { + _adjustment = [[0,0], [0,0], [0,0]]; +}; + +// Display the adjustment knobs +_layer = [QGVAR(Zeroing)] call BIS_fnc_rscLayer; +_layer cutRsc [QGVAR(Zeroing), "PLAIN", 0, false]; + +// Find the display +_display = uiNamespace getVariable [QGVAR(ZeroingDisplay), displayNull]; +if (isNull _display) exitWith {}; + +// Update values +_zeroing = _adjustment select _weaponIndex; +_vertical = _display displayCtrl 12; +_horizontal = _display displayCtrl 13; +_vertical ctrlSetText (str (_zeroing select 1)); +_horizontal ctrlSetText (str (_zeroing select 0)); + +// Set the time when to hide the knobs +GVAR(timeToHide) = diag_tickTime + 3.0; + +if !(isNil QGVAR(fadePFH)) exitWith {}; + +// Launch a PFH to wait and fade out the knobs +GVAR(fadePFH) = [{ + + if (diag_tickTime >= GVAR(timeToHide)) exitWith { + private "_layer"; + _layer = [QGVAR(Zeroing)] call BIS_fnc_rscLayer; + _layer cutFadeOut 2; + + GVAR(fadePFH) = nil; + [_this select 1] call cba_fnc_removePerFrameHandler; + }; + +}, 0.1, []] call CBA_fnc_addPerFrameHandler diff --git a/addons/scopes/scripts/script_component.hpp b/addons/scopes/scripts/script_component.hpp deleted file mode 100644 index acca51b4b5..0000000000 --- a/addons/scopes/scripts/script_component.hpp +++ /dev/null @@ -1 +0,0 @@ -#include "\z\ace\addons\scopes\script_component.hpp" diff --git a/addons/scopes/scripts/zeroingOnLoad.sqf b/addons/scopes/scripts/zeroingOnLoad.sqf deleted file mode 100644 index 591b5fc07b..0000000000 --- a/addons/scopes/scripts/zeroingOnLoad.sqf +++ /dev/null @@ -1,20 +0,0 @@ -#include "script_component.hpp" - -disableSerialization; - -_display = _this select 0; -uiNamespace setVariable [QGVAR(ZeroingDisplay, _display]; -_vertical = _display displayCtrl 925002; -_horizontal = _display displayCtrl 925003; - -_weapons = [ - primaryWeapon player, - secondaryWeapon player, - handgunWeapon player -]; - -if ((currentWeapon ACE_player) in _weapons) then { - _zeroing = GVAR(Adjustment) select (_weapons find (currentWeapon ACE_player)); - _horizontal ctrlSetText (str (_zeroing select 0)); - _vertical ctrlSetText (str (_zeroing select 1)); -}; diff --git a/addons/switchunits/CfgEventHandlers.hpp b/addons/switchunits/CfgEventHandlers.hpp index 47dcd984d1..38f9883743 100644 --- a/addons/switchunits/CfgEventHandlers.hpp +++ b/addons/switchunits/CfgEventHandlers.hpp @@ -5,7 +5,7 @@ class Extended_PreInit_EventHandlers { }; class Extended_PostInit_EventHandlers { - class ADDON { - postInit = QUOTE(call COMPILE_FILE(XEH_postInit) ); - }; + class ADDON { + clientInit = QUOTE( call COMPILE_FILE(XEH_clientInit) ); + }; }; diff --git a/addons/switchunits/XEH_clientInit.sqf b/addons/switchunits/XEH_clientInit.sqf new file mode 100644 index 0000000000..3075d67941 --- /dev/null +++ b/addons/switchunits/XEH_clientInit.sqf @@ -0,0 +1,39 @@ +/* + * Author: bux578 + * Initializes the SwitchUnits pbo. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * None + * + * Public: No + */ + +#include "script_component.hpp" + +DFUNC(pfhClientInit) = { + + if (GVAR(EnableSwitchUnits)) exitWith { + + private ["_sides"]; + _sides = []; + + if(GVAR(SwitchToWest)) then {_sides pushBack west;}; + if(GVAR(SwitchToEast)) then {_sides pushBack east;}; + if(GVAR(SwitchToIndependent)) then {_sides pushBack independent;}; + if(GVAR(SwitchToCivilian)) then {_sides pushBack civilian;}; + + if (player getVariable ["ACE_CanSwitchUnits", false]) then { + [player, _sides] call FUNC(initPlayer); + }; + + [(_this select 1)] call cba_fnc_removePerFrameHandler; + }; +}; + +[FUNC(pfhClientInit), 0.5, []] call cba_fnc_addPerFrameHandler; diff --git a/addons/switchunits/XEH_postInit.sqf b/addons/switchunits/XEH_postInit.sqf deleted file mode 100644 index 3ce84ef838..0000000000 --- a/addons/switchunits/XEH_postInit.sqf +++ /dev/null @@ -1,27 +0,0 @@ -/* - Author(s): - bux578 -*/ - -#include "script_component.hpp" - -//0 spawn { - -private ["_sides"]; - -//waitUntil {sleep 0.5; AGM_SwitchUnits_EnableSwitchUnits}; - -//_side = [west, east, independent, civilian] select AGM_SwitchUnits_SwitchUnitsAllowedForSide; - -_sides = []; - -if(GVAR(SwitchToWest)) then {_sides pushBack west}; -if(GVAR(SwitchToEast)) then {_sides pushBack east}; -if(GVAR(SwitchToIndependent)) then {_sides pushBack independent}; -if(GVAR(SwitchToCivilian)) then {_sides pushBack civilian}; - -if (player getVariable ["ACE_CanSwitchUnits", false]) then { -[player, _sides] call FUNC(initPlayer); -}; - -//}; diff --git a/addons/switchunits/config.cpp b/addons/switchunits/config.cpp index b89adb3a7a..09d3e05594 100644 --- a/addons/switchunits/config.cpp +++ b/addons/switchunits/config.cpp @@ -15,15 +15,33 @@ class CfgPatches { #include "CfgEventHandlers.hpp" #include "CfgVehicles.hpp" -class ACE_Parameters_Numeric { - GVAR(SafeZoneRadius) = 100; -}; - -class ACE_Parameters_Boolean { - GVAR(EnableSwitchUnits) = 0; - GVAR(SwitchToWest) = 0; - GVAR(SwitchToEast) = 0; - GVAR(SwitchToIndependent) = 0; - GVAR(SwitchToCivilian) = 0; - GVAR(EnableSafeZone) = 1; +class ACE_Settings { + class GVAR(SafeZoneRadius) { + value = 100; + typeName = "SCALAR"; + }; + class GVAR(EnableSwitchUnits) { + value = 0; + typeName = "BOOL"; + }; + class GVAR(SwitchToWest) { + value = 0; + typeName = "BOOL"; + }; + class GVAR(SwitchToEast) { + value = 0; + typeName = "BOOL"; + }; + class GVAR(SwitchToIndependent) { + value = 0; + typeName = "BOOL"; + }; + class GVAR(SwitchToCivilian) { + value = 0; + typeName = "BOOL"; + }; + class GVAR(EnableSafeZone) { + value = 1; + typeName = "BOOL"; + }; }; diff --git a/addons/switchunits/functions/fnc_addMapFunction.sqf b/addons/switchunits/functions/fnc_addMapFunction.sqf index 1c4e158d80..62a7c42a22 100644 --- a/addons/switchunits/functions/fnc_addMapFunction.sqf +++ b/addons/switchunits/functions/fnc_addMapFunction.sqf @@ -1,19 +1,19 @@ /* - Name: ACE_SwitchUnits_fnc_addMapFunction - - Author(s): - bux578 - - Description: - Adds a mapClick Eventhandler - - Parameters: - 0: OBJECT - unit - 1: ARRAY - sides - - Returns: - VOID -*/ + * Author: bux578 + * Adds a mapClick Eventhandler + * + * Arguments: + * 0: unit + * 1: sides > + * + * Return Value: + * None + * + * Example: + * [_unit, _sides] call FUNC(addMapFunction) + * + * Public: No + */ #include "script_component.hpp" diff --git a/addons/switchunits/functions/fnc_handleMapClick.sqf b/addons/switchunits/functions/fnc_handleMapClick.sqf index bce28963da..3033071984 100644 --- a/addons/switchunits/functions/fnc_handleMapClick.sqf +++ b/addons/switchunits/functions/fnc_handleMapClick.sqf @@ -1,45 +1,41 @@ /* - Name: ACE_SwitchUnits_fnc_handleMapClick - - Author(s): - bux578 - - Description: - Finds the clicked unit - - Parameters: - 0: OBJECT - MapClickEventHandlerArgs - 0: OBJECT - unit // useless - 1: ARRAY - sides - - Returns: - VOID -*/ + * Author: bux578 + * Switches to a unit close to a clicked map position + * + * Arguments: + * 0: unit + * 1: sides > + * + * Return Value: + * None + * + * Example: + * [_unit, _sides] call FUNC(handleMapClick) + * + * Public: No + */ #include "script_component.hpp" private ["_sides", "_pos", "_sideNearest"]; -// that's wrong -//_currentPlayerUnit = (_this select 0) select 0; - _sides = (_this select 0) select 1; _pos = _this select 1; _sideNearest = []; { - if ([_x] call FUNC(isValidAi) && (side group _x in _sides)) then { - _sideNearest pushBack _x; - }; + if ([_x] call FUNC(isValidAi) && (side group _x in _sides)) then { + _sideNearest pushBack _x; + }; } forEach (nearestObjects [_pos, ["Man"], 20]); if (count _sideNearest > 0) then { - private ["_switchUnit"]; - - _switchUnit = _sideNearest select 0; - [ACE_player, _switchUnit] call FUNC(switchUnit); - - openMap false; + private ["_switchUnit"]; + + _switchUnit = _sideNearest select 0; + [ACE_player, _switchUnit] call FUNC(switchUnit); + + openMap false; }; diff --git a/addons/switchunits/functions/fnc_initPlayer.sqf b/addons/switchunits/functions/fnc_initPlayer.sqf index 81e4fc259f..9c71f8cefc 100644 --- a/addons/switchunits/functions/fnc_initPlayer.sqf +++ b/addons/switchunits/functions/fnc_initPlayer.sqf @@ -1,19 +1,19 @@ /* - Name: ACE_SwitchUnits_fnc_initPlayer - - Author(s): - bux578 - - Description: - Initializes the player - - Parameters: - 0: OBJECT - player - 1: ARRAY - Array containing selected sides - - Returns: - VOID -*/ + * Author: bux578 + * Initializes the player + * + * Arguments: + * 0: player + * 1: sides > + * + * Return Value: + * None + * + * Example: + * [_player, _sides] call FUNC(initPlayer) + * + * Public: No + */ #include "script_component.hpp" @@ -24,27 +24,28 @@ _sides = _this select 1; if (vehicle _playerUnit == _playerUnit) then { - [_sides] call FUNC(markAiOnMap); + [_sides] call FUNC(markAiOnMap); - _playerUnit setVariable [QGVAR(IsPlayerUnit), true]; - _playerUnit allowDamage false; + _playerUnit setVariable [QGVAR(IsPlayerUnit), true]; + _playerUnit allowDamage false; - GVAR(OriginalUnit) = _playerUnit; - GVAR(OriginalName) = [_playerUnit] call EFUNC(common,getName); - GVAR(OriginalGroup) = group _playerUnit; + GVAR(OriginalUnit) = _playerUnit; + //GVAR(OriginalName) = [_playerUnit] call EFUNC(common,getName); + GVAR(OriginalName) = name _playerUnit; + GVAR(OriginalGroup) = group _playerUnit; - // remove all starting gear of a player - removeAllWeapons _playerUnit; - removeGoggles _playerUnit; - removeHeadgear _playerUnit; - removeVest _playerUnit; - removeAllAssignedItems _playerUnit; - clearAllItemsFromBackpack _playerUnit; - removeBackpack _playerUnit; - _playerUnit linkItem "ItemMap"; - removeUniform _playerUnit; + // remove all starting gear of a player + removeAllWeapons _playerUnit; + removeGoggles _playerUnit; + removeHeadgear _playerUnit; + removeVest _playerUnit; + removeAllAssignedItems _playerUnit; + clearAllItemsFromBackpack _playerUnit; + removeBackpack _playerUnit; + _playerUnit linkItem "ItemMap"; + removeUniform _playerUnit; - [_playerUnit, "ACE_SwitchUnits", true] call EFUNC(common,setForceWalkStatus); + [_playerUnit, "ACE_SwitchUnits", true] call EFUNC(common,setForceWalkStatus); - [_playerUnit, _sides] call FUNC(addMapFunction); + [_playerUnit, _sides] call FUNC(addMapFunction); }; diff --git a/addons/switchunits/functions/fnc_isValidAi.sqf b/addons/switchunits/functions/fnc_isValidAi.sqf index 5beb59d430..61c2401da9 100644 --- a/addons/switchunits/functions/fnc_isValidAi.sqf +++ b/addons/switchunits/functions/fnc_isValidAi.sqf @@ -1,22 +1,22 @@ /* - Name: ACE_SwitchUnits_fnc_isValidAi - - Author(s): - bux578 - - Description: - Checks if AI is a valid target for switching - - Parameters: - 0: OBJECT - unit - - Returns: - VOID -*/ + * Author: bux578 + * Checks if AI is a valid target for switching. + * + * Arguments: + * 0: unit + * + * Return Value: + * Boolean + * + * Example: + * [_unit] call FUNC(isValidAi) + * + * Public: Yes + */ #include "script_component.hpp" -private ["_unit"]; +private "_unit"; _unit = _this select 0; diff --git a/addons/switchunits/functions/fnc_markAiOnMap.sqf b/addons/switchunits/functions/fnc_markAiOnMap.sqf index e54673c1a5..ed94c31b0b 100644 --- a/addons/switchunits/functions/fnc_markAiOnMap.sqf +++ b/addons/switchunits/functions/fnc_markAiOnMap.sqf @@ -1,69 +1,71 @@ /* - Name: ACE_SwitchUnits_fnc_markAiOnMap - - Author(s): - bux578 - - Description: - Creates markers for AI units for given sides - Marks players in a different color - - Parameters: - 0: OBJECT - side - - Returns: - VOID -*/ + * Author: bux578 + * Creates markers for AI units for given sides. + * Marks players in a different colour. + * + * Arguments: + * 0: side + * + * Return Value: + * None + * + * Example: + * [[west, east]] call FUNC(markAiOnMap) + * + * Public: No + */ #include "script_component.hpp" -private ["_sidesToShow"]; +private "_sidesToShow"; _sidesToShow = _this select 0; -_sidesToShow spawn { +GVAR(AllMarkerNames) = []; - private ["_sides", "_allMarkerNames"]; - _sides = _this; - _allMarkerNames = []; +DFUNC(pfhMarkAiOnMap) = { + private ["_args", "_sides"]; + _args = _this select 0; + _sides = _args select 0; - while { true } do { - sleep 1.5; + + // delete markers + { + deleteMarkerLocal _x; + } forEach GVAR(AllMarkerNames); - // delete markers + if (alive ACE_player && {GVAR(OriginalUnit) getVariable ["ACE_CanSwitchUnits", false]}) then { + + // create markers { - deleteMarkerLocal _x; - } forEach _allMarkerNames; + if (([_x] call FUNC(isValidAi) && (side group _x in _sides)) || (_x getVariable [QGVAR(IsPlayerControlled), false])) then { + private ["_markerName", "_marker", "_markerColor"]; + + hint format ["marker. %1", time]; - if (alive ACE_player && {GVAR(OriginalUnit) getVariable ["ACE_CanSwitchUnits", false]}) then { + //_markerName = format ["%1", [_x] call EFUNC(common,getName)]; + _markerName = str _x; - // create markers - { - if (([_x] call FUNC(isValidAi) && (side group _x in _sides)) || (_x getVariable [QGVAR(IsPlayerControlled), false])) then { - private ["_markerName", "_marker", "_markerColor"]; + _marker = createMarkerLocal [_markerName, position _x]; + _markerName setMarkerTypeLocal "mil_triangle"; + _markerName setMarkerShapeLocal "ICON"; + _markerName setMarkerSizeLocal [0.5,0.7]; + _markerName setMarkerDirLocal getDir _x; - //_markerName = format ["%1", [_x] call EFUNC(common,getName)]; - _markerName = str _x; + // commy's one liner magic + _markerColor = format ["Color%1", side group _x]; - _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]; - - if ((_x getVariable [QGVAR(IsPlayerControlled), false])) then { - _markerName setMarkerColorLocal "ColorOrange"; - _markerName setMarkerTextLocal (_x getVariable [QGVAR(PlayerControlledName), ""]); - } else { - _markerName setMarkerColorLocal _markerColor; - _markerName setMarkerTextLocal (getText (configFile >> "CfgVehicles" >> typeOf _x >> "displayName")); - }; - - _allMarkerNames pushBack _markerName; + if ((_x getVariable [QGVAR(IsPlayerControlled), false])) then { + _markerName setMarkerColorLocal "ColorOrange"; + _markerName setMarkerTextLocal (_x getVariable [QGVAR(PlayerControlledName), ""]); + } else { + _markerName setMarkerColorLocal _markerColor; + _markerName setMarkerTextLocal (getText (configFile >> "CfgVehicles" >> typeOf _x >> "displayName")); }; - } forEach allUnits; - }; + + GVAR(AllMarkerNames) pushBack _markerName; + }; + } forEach allUnits; }; }; + +[FUNC(pfhMarkAiOnMap), 1.5, [_sidesToShow]] call CBA_fnc_addPerFrameHandler; diff --git a/addons/switchunits/functions/fnc_module.sqf b/addons/switchunits/functions/fnc_module.sqf index c4f5c378c2..e622a65338 100644 --- a/addons/switchunits/functions/fnc_module.sqf +++ b/addons/switchunits/functions/fnc_module.sqf @@ -1,20 +1,20 @@ /* - Name: ACE_SwitchUnits_fnc_module - - Author(s): - bux578 - - Description: - Initializes the SwitchUnits module - - Parameters: - 0: OBJECT - module logic - 1: ARRAY - list of affected units - 2: BOOLEAN - isActivated - - Returns: - BOOLEAN (Good practice to include one) -*/ + * Author: bux578 + * Initializes the SwitchUnits module + * + * Arguments: + * 0: module logic + * 1: list of affected units > + * 2: isActivated + * + * Return Value: + * None + * + * Example: + * None + * + * Public: No + */ #include "script_component.hpp" @@ -27,14 +27,14 @@ if !(_activated) exitWith {}; GVAR(Module) = true; -[QGVAR(EnableSwitchUnits), true] call EFUNC(common,setParameter); +[_logic, QGVAR(SwitchToWest), "SwitchToWest"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(SwitchToEast), "SwitchToEast"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(SwitchToIndependent), "SwitchToIndependent"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(SwitchToCivilian), "SwitchToCivilian"] call EFUNC(common,readSettingFromModule); -[_logic, QGVAR(SwitchToWest), "SwitchToWest"] call EFUNC(common,readBooleanParameterFromModule); -[_logic, QGVAR(SwitchToEast), "SwitchToEast"] call EFUNC(common,readBooleanParameterFromModule); -[_logic, QGVAR(SwitchToIndependent), "SwitchToIndependent"] call EFUNC(common,readBooleanParameterFromModule); -[_logic, QGVAR(SwitchToCivilian), "SwitchToCivilian"] call EFUNC(common,readBooleanParameterFromModule); - -[_logic, QGVAR(EnableSafeZone), "EnableSafeZone"] call EFUNC(common,readBooleanParameterFromModule); -[_logic, QGVAR(SafeZoneRadius), "SafeZoneRadius"] call EFUNC(common,readNumericParameterFromModule); +[_logic, QGVAR(EnableSafeZone), "EnableSafeZone"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(SafeZoneRadius), "SafeZoneRadius"] call EFUNC(common,readSettingFromModule); + +[QGVAR(EnableSwitchUnits), true, false, true] call EFUNC(common,setSetting); diag_log text "[ACE]: SwitchUnits Module Initialized."; diff --git a/addons/switchunits/functions/fnc_nearestPlayers.sqf b/addons/switchunits/functions/fnc_nearestPlayers.sqf index 217e1b90e4..b79c54054f 100644 --- a/addons/switchunits/functions/fnc_nearestPlayers.sqf +++ b/addons/switchunits/functions/fnc_nearestPlayers.sqf @@ -1,19 +1,19 @@ /* - Name: ACE_SwitchUnits_fnc_nearestPlayers - - Author(s): - bux578 - - Description: - Returns an array of alive players in a given radius around a given location - - Parameters: - 0: POSTION - Center position - 1: NUMBER - Radius - - Returns: - ARRAY - Player units -*/ + * Author: bux578 + * Returns an array of alive players in a given radius around a given location + * + * Arguments: + * 0: Center position + * 1: Radius + * + * Return Value: + * Player units > + * + * Example: + * [_pos, 100] call FUNC(nearestPlayers) + * + * Public: Yes + */ #include "script_component.hpp" diff --git a/addons/switchunits/functions/fnc_switchBack.sqf b/addons/switchunits/functions/fnc_switchBack.sqf index 6bdc2c8bac..d54713bbe4 100644 --- a/addons/switchunits/functions/fnc_switchBack.sqf +++ b/addons/switchunits/functions/fnc_switchBack.sqf @@ -1,31 +1,41 @@ /* - Name: ACE_SwitchUnits_fnc_switchBack - - Author(s): - bux578 - - Description: - Switches back to the original player unit - This method needs to be "spawn"ed - - Parameters: - 0: OBJECT - original player unit - 1: OBJECT - respawned unit - - Returns: - VOID -*/ + * Author: bux578 + * Switches back to the original player unit + * + * Arguments: + * 0: Original player unit + * 1: Respawned unit + * + * Return Value: + * None + * + * Example: + * [_origPlayer, _respPlayer] call FUNC(switchBack) + * + * Public: Yes + */ #include "script_component.hpp" -private ["_originalPlayerUnit", "_currentUnit"]; -_originalPlayerUnit = _this select 0; -_currentUnit = _this select 1; +private ["_origPlayerUnit"]; -[_originalPlayerUnit] joinSilent GVAR(OriginalGroup); +_origPlayerUnit = _this select 0; +[_origPlayerUnit] joinSilent GVAR(OriginalGroup); -waitUntil {local _originalPlayerUnit}; +DFUNC(pfhSwitchBack) = { + + private ["_args", "_originalPlayerUnit", "_currentUnit"]; + + _args = _this select 0; + + _originalPlayerUnit = _args select 0; + _currentUnit = _args select 1; -selectPlayer _originalPlayerUnit; + if (local _originalPlayerUnit) exitWith { + selectPlayer _originalPlayerUnit; + deleteVehicle _currentUnit; + [(_this select 1)] call cba_fnc_removePerFrameHandler; + }; +}; -deleteVehicle _currentUnit; +[FUNC(pfhSwitchBack), 0.2, _this] call CBA_fnc_addPerFrameHandler; diff --git a/addons/switchunits/functions/fnc_switchUnit.sqf b/addons/switchunits/functions/fnc_switchUnit.sqf index efe3cef901..abd053ffae 100644 --- a/addons/switchunits/functions/fnc_switchUnit.sqf +++ b/addons/switchunits/functions/fnc_switchUnit.sqf @@ -1,81 +1,98 @@ /* - Name: ACE_SwitchUnits_fnc_switchUnit - - Author(s): - bux578 - - Description: - Selects the new given player unit - - Parameters: - 0: OBJECT - the unit to switch to - - Returns: - VOID -*/ + * Author: bux578 + * Switches to the new given player unit + * + * Arguments: + * 0: current unit + * 1: the unit to switch to + * + * Return Value: + * None + * + * Example: + * [_unit] call FUNC(switchUnit) + * + * Public: Yes + */ + #include "script_component.hpp" -private ["_newUnit"]; +private ["_unit", "_allNearestPlayers", "_oldUnit", "_leave"]; -_newUnit = _this select 1; +_unit = _this select 1; // don't switch to original player units -if (!([_newUnit] call FUNC(isValidAi))) exitWith {}; +if (!([_unit] call FUNC(isValidAi))) exitWith {}; + +// exit var +_leave = false; + +if (GVAR(EnableSafeZone)) then { -_newUnit spawn { - private ["_unit", "_allNearestPlayers", "_oldUnit", "_respawnEhId", "_oldOwner", "_leave"]; - - _unit = _this; - - _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); if (count _nearestEnemyPlayers > 0) exitWith { - _leave = true; + _leave = true; }; - }; - - // exitWith doesn't exit past the "if(EnableSafeZone)" block - if (_leave) exitWith { - [localize "STR_ACE_SwitchUnits_TooCloseToEnemy"] call EFUNC(common,displayTextStructured); - }; - - // 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); - - _oldUnit = player; - waitUntil {sleep 0.2; local _unit}; - - _oldUnit setVariable [QGVAR(IsPlayerControlled), false, true]; - _oldUnit setVariable [QGVAR(PlayerControlledName), "", true]; - - _respawnEhId = _unit getVariable [QGVAR(RespawnEhId), -1]; - if (_respawnEhId != -1) then { - _oldUnit removeEventHandler ["Respawn", _respawnEhId]; - }; - - selectPlayer _unit; - - _unit setVariable [QGVAR(IsPlayerControlled), true, true]; - _unit setVariable [QGVAR(PlayerControlledName), GVAR(OriginalName), true]; - - _respawnEhId = _unit addEventHandler ["Respawn", { - [GVAR(OriginalUnit), _this select 0] spawn FUNC(switchBack); - }]; - _unit setVariable [QGVAR(RespawnEhId), _respawnEhId, true]; - - // set owner back to original owner - _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); - }; - - [localize "STR_ACE_SwitchUnits_SwitchedUnit"] call EFUNC(common,displayTextStructured); + }; + +// exitWith doesn't exit past the "if(EnableSafeZone)" block +if (_leave) exitWith { + [localize "STR_ACE_SwitchUnits_TooCloseToEnemy"] call EFUNC(common,displayTextStructured); +}; + +// 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); + +_oldUnit = player; + + +DFUNC(pfhSwitchUnit) = { + + private ["_args", "_unit", "_oldUnit", "_respawnEhId", "_oldOwner"]; + _args = _this select 0; + + _unit = _args select 0; + _oldUnit = _args select 1; + + + + if (local _unit) exitWith { + + _oldUnit setVariable [QGVAR(IsPlayerControlled), false, true]; + _oldUnit setVariable [QGVAR(PlayerControlledName), "", true]; + + _respawnEhId = _unit getVariable [QGVAR(RespawnEhId), -1]; + if (_respawnEhId != -1) then { + _oldUnit removeEventHandler ["Respawn", _respawnEhId]; + }; + + selectPlayer _unit; + + _unit setVariable [QGVAR(IsPlayerControlled), true, true]; + _unit setVariable [QGVAR(PlayerControlledName), GVAR(OriginalName), true]; + + _respawnEhId = _unit addEventHandler ["Respawn", { + [GVAR(OriginalUnit), _this select 0] call FUNC(switchBack); + }]; + _unit setVariable [QGVAR(RespawnEhId), _respawnEhId, true]; + + // set owner back to original owner + _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); + }; + + [localize "STR_ACE_SwitchUnits_SwitchedUnit"] call EFUNC(common,displayTextStructured); + + [(_this select 1)] call cba_fnc_removePerFrameHandler; + + }; +}; + +[FUNC(pfhSwitchUnit), 0.2, [_unit, _oldUnit]] call cba_fnc_addPerFrameHandler; diff --git a/addons/vector/XEH_postInit.sqf b/addons/vector/XEH_postInit.sqf index 0a8f031347..8bbf7d7aa6 100644 --- a/addons/vector/XEH_postInit.sqf +++ b/addons/vector/XEH_postInit.sqf @@ -1,78 +1,4 @@ // by commy2 #include "script_component.hpp" -["ACE3", - localize "STR_ACE_Vector_AzimuthKey", - { - // Conditions: canInteract - _exceptions = []; - if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; - // Conditions: specific - if !(currentWeapon ACE_player == "ACE_Vector" && {ACE_player == cameraOn} && {cameraView == "GUNNER"} && {!(GETGVAR(isDownStateKeyAzimuth,false))}) exitWith {false}; - - GVAR(isDownStateKeyAzimuth) = true; - - // Statement - ["azimuth"] call FUNC(onKeyDown); - true - }, - [15, [false, false, false]], - false, - "keydown" -] call CBA_fnc_registerKeybind; - -["ACE3", - localize "STR_ACE_Vector_AzimuthKey", - { - GVAR(isDownStateKeyAzimuth) = false; - - // Conditions: canInteract - _exceptions = []; - if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; - - // Statement - ["azimuth"] call FUNC(onKeyUp); - true - }, - [15, [false, false, false]], - false, - "keyup" -] call CBA_fnc_registerKeybind; - -["ACE3", - localize "STR_ACE_Vector_DistanceKey", - { - // Conditions: canInteract - _exceptions = []; - if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; - // Conditions: specific - if !(currentWeapon ACE_player == "ACE_Vector" && {ACE_player == cameraOn} && {cameraView == "GUNNER"} && {!(GETGVAR(isDownStateKeyDistance,false))}) exitWith {false}; - - GVAR(isDownStateKeyDistance) = true; - - // Statement - ["distance"] call FUNC(onKeyDown); - true - }, - [19, [false, false, false]], - false, - "keydown" -] call CBA_fnc_registerKeybind; - -["ACE3", - localize "STR_ACE_Vector_DistanceKey", - { - GVAR(isDownStateKeyDistance) = false; - - // Conditions: canInteract - _exceptions = []; - if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; - - // Statement - ["distance"] call FUNC(onKeyUp); - true - }, - [19, [false, false, false]], - false, - "keyup" -] call CBA_fnc_registerKeybind; +#include "initKeybinds.sqf" diff --git a/addons/vector/initKeybinds.sqf b/addons/vector/initKeybinds.sqf new file mode 100644 index 0000000000..f81c280905 --- /dev/null +++ b/addons/vector/initKeybinds.sqf @@ -0,0 +1,83 @@ +// by commy2 + +["ACE3", + localize "STR_ACE_Vector_AzimuthKey", + { + // Conditions: canInteract + _exceptions = []; + if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; + // Conditions: specific + if !(currentWeapon ACE_player == "ACE_Vector" && {ACE_player == cameraOn} && {cameraView == "GUNNER"}) exitWith {false}; + + // prevent holding down + if (GETGVAR(isDownStateKey1,false)) exitWith {false}; + GVAR(isDownStateKey1) = true; + + // Statement + ["azimuth"] call FUNC(onKeyDown); + true + }, + [15, [false, false, false]], + false, + "keydown" +] call CBA_fnc_registerKeybind; + +["ACE3", + localize "STR_ACE_Vector_AzimuthKey", + { + // prevent holding down + GVAR(isDownStateKey1) = false; + + // Conditions: canInteract + _exceptions = []; + if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; + + // Statement + ["azimuth"] call FUNC(onKeyUp); + true + }, + [15, [false, false, false]], + false, + "keyup" +] call CBA_fnc_registerKeybind; + +["ACE3", + localize "STR_ACE_Vector_DistanceKey", + { + // Conditions: canInteract + _exceptions = []; + if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; + // Conditions: specific + if !(currentWeapon ACE_player == "ACE_Vector" && {ACE_player == cameraOn} && {cameraView == "GUNNER"}) exitWith {false}; + + // prevent holding down + if (GETGVAR(isDownStateKey2,false)) exitWith {false}; + GVAR(isDownStateKey2) = true; + + // Statement + ["distance"] call FUNC(onKeyDown); + true + }, + [19, [false, false, false]], + false, + "keydown" +] call CBA_fnc_registerKeybind; + +["ACE3", + localize "STR_ACE_Vector_DistanceKey", + { + // prevent holding down + GVAR(isDownStateKey2) = false; + + // Conditions: canInteract + _exceptions = []; + if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; + + // Statement + ["distance"] call FUNC(onKeyUp); + true + }, + [19, [false, false, false]], + false, + "keyup" +] call CBA_fnc_registerKeybind; diff --git a/addons/vehiclelock/CfgWeapons.hpp b/addons/vehiclelock/CfgWeapons.hpp index c7df1116f8..157fb4bf60 100644 --- a/addons/vehiclelock/CfgWeapons.hpp +++ b/addons/vehiclelock/CfgWeapons.hpp @@ -3,7 +3,7 @@ class CfgWeapons { class ACE_ItemCore; class ACE_key_master: ACE_ItemCore { - author = "$STR_ACE_Core_ACETeam"; + author = "$STR_ACE_Common_ACETeam"; displayName = "Vehicle Key: Master"; descriptionShort = "$STR_ACE_Vehicle_Item_Master_Description"; model = "\A3\weapons_F\ammo\mag_univ.p3d"; diff --git a/addons/vehiclelock/config.cpp b/addons/vehiclelock/config.cpp index 83850a2bef..9031987315 100644 --- a/addons/vehiclelock/config.cpp +++ b/addons/vehiclelock/config.cpp @@ -12,8 +12,11 @@ class CfgPatches { }; }; -class ACE_Parameters_Numeric { - GVAR(DefaultLockpickStrength) = 10; +class ACE_Settings { + class GVAR(DefaultLockpickStrength) { + value = 10; + typeName = "SCALAR"; + }; }; #include "CfgEventHandlers.hpp" diff --git a/addons/vehiclelock/functions/fnc_moduleInit.sqf b/addons/vehiclelock/functions/fnc_moduleInit.sqf index b0ae230724..a344185ab0 100644 --- a/addons/vehiclelock/functions/fnc_moduleInit.sqf +++ b/addons/vehiclelock/functions/fnc_moduleInit.sqf @@ -29,7 +29,7 @@ _sideKeysAssignment = _logic getVariable["SideKeysAssignment", 0]; _setLockState = _logic getVariable["SetLockState", 0]; if (isServer) then { - [_logic, QGVAR(DefaultLockpickStrength), "LockpickStrength"] call EFUNC(common,readNumericParameterFromModule); + [_logic, QGVAR(DefaultLockpickStrength), "LockpickStrength"] call EFUNC(common,readSettingFromModule); }; //Run at mission start (anyone besides JIPs) diff --git a/addons/weather/config.cpp b/addons/weather/config.cpp index dc3faecf5f..f59267690f 100644 --- a/addons/weather/config.cpp +++ b/addons/weather/config.cpp @@ -14,11 +14,3 @@ class CfgPatches { #include "CfgEventhandlers.hpp" #include "CfgWorlds.hpp" - -/*class ACE_Parameters_Numeric { - GVAR(XXXX) = 100; -}; - -class ACE_Parameters_Boolean { - GVAR(XXXX) = 0; -};*/ diff --git a/addons/winddeflection/CfgEventHandlers.hpp b/addons/winddeflection/CfgEventHandlers.hpp index 6cf7856ba5..4961d7dbc7 100644 --- a/addons/winddeflection/CfgEventHandlers.hpp +++ b/addons/winddeflection/CfgEventHandlers.hpp @@ -4,12 +4,6 @@ class Extended_PreInit_EventHandlers { }; }; -class Extended_PostInit_EventHandlers { - class ADDON { - init = QUOTE( call compile preprocessFileLineNumbers PATHTOF(XEH_postInit.sqf) ); - }; -}; - class Extended_Fired_Eventhandlers { class CaManBase { fired = QUOTE( call FUNC(handleFired) ); diff --git a/addons/winddeflection/CfgVehicles.h b/addons/winddeflection/CfgVehicles.h index fe0e31bda5..e84727b94e 100644 --- a/addons/winddeflection/CfgVehicles.h +++ b/addons/winddeflection/CfgVehicles.h @@ -1,27 +1,20 @@ class CfgVehicles { - - // TODO Stringtable usage - class Logic; - class Module_F: Logic { - class ArgumentsBaseUnits { - }; - }; - class GVAR(Module): Module_F { - scope = 2; - displayName = "Wind Deflection [ACE]"; - icon = QUOTE(PATHTOF(data\module_icon.paa)); - category = "ACE"; - function = FUNC(enableModule); - functionPriority = 1; - isGlobal = 1; - isTriggerActivated = 0; - class Arguments { - class forAI { - displayName = "Enable for AI"; - description = "Should the module be enabled for AI"; - typeName = "BOOL"; - defaultValue = 0; - }; - }; - }; + class Module_F; + class GVAR(Module): Module_F { + author = "$STR_ACE_Common_ACETeam"; + category = "ACE"; + displayName = "Wind Deflection"; + function = FUNC(enableModule); + scope = 2; + isGlobal = 1; + icon = QUOTE(PATHTOF(data\module_icon.paa)); + class Arguments { + class EnableForAI { + displayName = "Enable for AI"; + description = "Should the module be enabled for AI"; + typeName = "BOOL"; + defaultValue = 0; + }; + }; + }; }; diff --git a/addons/winddeflection/XEH_postInit.sqf b/addons/winddeflection/XEH_postInit.sqf deleted file mode 100644 index 9c3a4bc41f..0000000000 --- a/addons/winddeflection/XEH_postInit.sqf +++ /dev/null @@ -1,15 +0,0 @@ -/** - * XEH_postInit.sqf - * @Descr: N/A - * @Author: Glowbal - * - * @Arguments: [] - * @Return: - * @PublicAPI: false - */ - -#include "script_component.hpp" - -if (isnil QGVAR(EnableForAI)) then { - GVAR(EnableForAI) = false; -}; diff --git a/addons/winddeflection/config.cpp b/addons/winddeflection/config.cpp index 6e1bdbc379..0e721846ad 100644 --- a/addons/winddeflection/config.cpp +++ b/addons/winddeflection/config.cpp @@ -1,16 +1,16 @@ #include "script_component.hpp" class CfgPatches { - class ADDON { - units[] = {}; - weapons[] = {}; - requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ACE_common", "ACE_weather"}; - versionDesc = "ACE Wind Deflection"; - version = VERSION; - author[] = {$STR_ACE_Core_ACETeam, "Glowbal", "Ruthberg"}; - authorUrl = "http://csemod.com"; - }; + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ACE_common", "ACE_weather"}; + versionDesc = "ACE Wind Deflection"; + version = VERSION; + author[] = {$STR_ACE_Common_ACETeam, "Glowbal", "Ruthberg"}; + authorUrl = "http://csemod.com"; + }; }; class CfgAddons { @@ -21,4 +21,11 @@ class CfgAddons { }; }; +class ACE_Settings { + class GVAR(EnableForAI) { + value = 0; + typeName = "BOOL"; + isClientSetable = 0; + }; +}; #include "CfgVehicles.h" \ No newline at end of file diff --git a/addons/winddeflection/functions/fnc_initalizeModule.sqf b/addons/winddeflection/functions/fnc_initalizeModule.sqf index d0b9937a58..2833ecc54c 100644 --- a/addons/winddeflection/functions/fnc_initalizeModule.sqf +++ b/addons/winddeflection/functions/fnc_initalizeModule.sqf @@ -15,5 +15,5 @@ if (!hasInterface) exitwith {}; // No need for this module on HC or dedicated se private ["_logic"]; _logic = [_this,0,objNull,[objNull]] call BIS_fnc_param; if (!isNull _logic) then { - [_logic, QGVAR(EnableForAI), "forAI" ] call EFUNC(common,readBooleanParameterFromModule); + [_logic, QGVAR(EnableForAI), "EnableForAI" ] call EFUNC(common,readSettingFromModule); }; \ No newline at end of file