diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 90a774ddfe..94a0a490bf 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -49,6 +49,7 @@ PREP(getConfigGunner); PREP(getDefaultAnim); PREP(getDoorTurrets); PREP(getForceWalkStatus); +PREP(getGunner); PREP(getHitPoints); PREP(getHitPointsWithSelections); PREP(getInPosition); diff --git a/addons/common/functions/fnc_getGunner.sqf b/addons/common/functions/fnc_getGunner.sqf new file mode 100644 index 0000000000..2510c2ddc4 --- /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 weapons. + * + * 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/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/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..1e8e309b55 --- /dev/null +++ b/addons/fcs/CfgVehicles.hpp @@ -0,0 +1,516 @@ + +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 FUNC(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 FUNC(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 B_Heli_Light_01_F: Heli_Light_01_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..918548e71e 100644 --- a/addons/fcs/XEH_clientInit.sqf +++ b/addons/fcs/XEH_clientInit.sqf @@ -4,76 +4,4 @@ GVAR(enabled) = True; 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/config.cpp b/addons/fcs/config.cpp index e1e8ac8901..3c7303d68b 100644 --- a/addons/fcs/config.cpp +++ b/addons/fcs/config.cpp @@ -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..81876b301b 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), [vehicle 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..854dcf5cec 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, [_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..a0b10795cf 100644 --- a/addons/fcs/functions/fnc_firedEH.sqf +++ b/addons/fcs/functions/fnc_firedEH.sqf @@ -12,38 +12,46 @@ #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); + +if (ACE_player != _gunner) 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 { +if (getNumber (configFile >> "CfgAmmo" >> _ammo >> "ACE_Airburst") == 1) then { _this spawn { _vehicle = _this select 0; _projectile = _this select 6; - _distance = _vehicle getVariable [QGVAR(Distance), currentZeroing _vehicle]; + _distance = _vehicle getVariable [format ["%1_%2", QGVAR(Distance), _turret], currentZeroing _vehicle]; if (_distance < 50) exitWith {}; if (_distance > 1500) exitWith {}; diff --git a/addons/fcs/functions/fnc_keyDown.sqf b/addons/fcs/functions/fnc_keyDown.sqf index 086a11c03c..4cfcf7c57a 100644 --- a/addons/fcs/functions/fnc_keyDown.sqf +++ b/addons/fcs/functions/fnc_keyDown.sqf @@ -12,9 +12,11 @@ #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 {}; @@ -26,7 +28,7 @@ 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); 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..78a622331f 100644 --- a/addons/fcs/functions/fnc_keyUp.sqf +++ b/addons/fcs/functions/fnc_keyUp.sqf @@ -12,21 +12,27 @@ #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; 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 }; +private ["_weaponDirection", "_angleTarget"]; + _weaponDirection = _vehicle weaponDirection currentWeapon _vehicle; _angleTarget = asin (_weaponDirection select 2); @@ -38,6 +44,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 +61,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 +72,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 +89,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 +112,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 +127,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 +146,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 setVariable [format ["%1_%2", QGVAR(Distance), _turret], _distance, true]; +_vehicle setVariable [format ["%1_%2", QGVAR(Magazines), _turret], _FCSMagazines, true]; +_vehicle setVariable [format ["%1_%2", QGVAR(Elevation), _turret], _FCSElevation, true]; +_vehicle setVariable [format ["%1_%2", QGVAR(Azimuth), _turret], _FCSAzimuth, true]; [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..9001a31c48 100644 --- a/addons/fcs/functions/fnc_reset.sqf +++ b/addons/fcs/functions/fnc_reset.sqf @@ -12,7 +12,7 @@ #include "script_component.hpp" -private ["_vehicle"]; +private "_vehicle"; _vehicle = _this select 0; diff --git a/addons/fcs/functions/fnc_vehicleInit.sqf b/addons/fcs/functions/fnc_vehicleInit.sqf index 5872b1757f..29de520f5d 100644 --- a/addons/fcs/functions/fnc_vehicleInit.sqf +++ b/addons/fcs/functions/fnc_vehicleInit.sqf @@ -12,25 +12,35 @@ #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]; +{ + if (getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(Enabled)) == 1) then { // @todo for all turrets + _vehicle addEventHandler ["Fired", {_this call FUNC(firedEH)}]; - // 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]; + _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 ["_turretConfig", "_gunBeg", "_gunnerView", "_gunBegPos", "_gunnerViewPos", "_viewDiff"]; + + _turretConfig = [configFile >> "CfgVehicles" >> typeOf _vehicle, _x] call EFUNC(common,getTurretConfigPath); + + _gunBeg = getText (_turretConfig >> "gunBeg"); // @todo player turret path + _gunnerView = getText (_turretConfig >> "memoryPointGunnerOptics"); // @todo player turret path + + _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..444891903b --- /dev/null +++ b/addons/fcs/initKeybinds.sqf @@ -0,0 +1,73 @@ + +["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, [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", + { + // 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/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_clearJam.sqf b/addons/overheating/functions/fnc_clearJam.sqf index 829ab34811..2340c6c890 100644 --- a/addons/overheating/functions/fnc_clearJam.sqf +++ b/addons/overheating/functions/fnc_clearJam.sqf @@ -42,6 +42,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/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/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