From d8b461db913a3ef596f5ce22a07374a0a766da8b Mon Sep 17 00:00:00 2001 From: ulteq Date: Sat, 18 Apr 2015 21:17:37 +0200 Subject: [PATCH] Enabled wind deflection for grenades and vehicle gunners: *Added a new module option to disable WD for vehicle gunners *Fixed enabled setting not being initialized --- addons/winddeflection/ACE_Settings.hpp | 6 ++++++ addons/winddeflection/CfgEventHandlers.hpp | 2 +- addons/winddeflection/CfgVehicles.hpp | 6 ++++++ addons/winddeflection/functions/fnc_handleFired.sqf | 7 ++++--- addons/winddeflection/functions/fnc_initModuleSettings.sqf | 2 ++ .../winddeflection/functions/fnc_updateTrajectoryPFH.sqf | 2 +- 6 files changed, 20 insertions(+), 5 deletions(-) diff --git a/addons/winddeflection/ACE_Settings.hpp b/addons/winddeflection/ACE_Settings.hpp index f84bdeace3..b10b78db0c 100644 --- a/addons/winddeflection/ACE_Settings.hpp +++ b/addons/winddeflection/ACE_Settings.hpp @@ -5,6 +5,12 @@ class ACE_Settings { typeName = "BOOL"; value = 1; }; + class GVAR(vehicleEnabled) { + displayName = "Vehicle Enabled"; + description = "Enables wind deflection for static/vehicle gunners"; + typeName = "BOOL"; + value = 1; + }; class GVAR(simulationInterval) { displayName = "Simulation Interval"; description = "Defines the interval between every calculation step"; diff --git a/addons/winddeflection/CfgEventHandlers.hpp b/addons/winddeflection/CfgEventHandlers.hpp index 4f54a73c84..d856993322 100644 --- a/addons/winddeflection/CfgEventHandlers.hpp +++ b/addons/winddeflection/CfgEventHandlers.hpp @@ -5,7 +5,7 @@ class Extended_PreInit_EventHandlers { }; class Extended_FiredBIS_EventHandlers { - class CAManBase { + class AllVehicles { class ADDON { firedBIS = QUOTE(_this call FUNC(handleFired)); }; diff --git a/addons/winddeflection/CfgVehicles.hpp b/addons/winddeflection/CfgVehicles.hpp index 09dc1b69be..76ac0c13d3 100644 --- a/addons/winddeflection/CfgVehicles.hpp +++ b/addons/winddeflection/CfgVehicles.hpp @@ -17,6 +17,12 @@ class CfgVehicles { typeName = "BOOL"; defaultValue = 1; }; + class vehicleEnabled { + displayName = "Vehicle Enabled"; + description = "Enables wind deflection for static/vehicle gunners"; + typeName = "BOOL"; + defaultValue = 1; + }; class simulationInterval { displayName = "Simulation Interval"; description = "Defines the interval between every calculation step"; diff --git a/addons/winddeflection/functions/fnc_handleFired.sqf b/addons/winddeflection/functions/fnc_handleFired.sqf index 241fbcf839..f7090cfc2a 100644 --- a/addons/winddeflection/functions/fnc_handleFired.sqf +++ b/addons/winddeflection/functions/fnc_handleFired.sqf @@ -21,15 +21,16 @@ */ #include "script_component.hpp" -if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) exitWith {false}; - private ["_unit", "_bullet"]; _unit = _this select 0; _bullet = _this select 6; +if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false] && (_bullet isKindOf "BulletBase") && (_unit isKindOf "Man")) exitWith {false}; + if (!hasInterface) exitWith {false}; if (!(GVAR(enabled))) exitWith {false}; -if (!(_bullet isKindOf "BulletBase")) exitWith {false}; +if (!(GVAR(vehicleEnabled)) && !(_unit isKindOf "Man")) exitWith {false}; +if (!((_bullet isKindOf "BulletBase") || (_bullet isKindOf "GrenadeBase"))) exitWith {false}; if (_unit distance ACE_player > GVAR(simulationRadius)) exitWith {false}; if (!([_unit] call EFUNC(common,isPlayer))) exitWith {false}; diff --git a/addons/winddeflection/functions/fnc_initModuleSettings.sqf b/addons/winddeflection/functions/fnc_initModuleSettings.sqf index 4cf75c885a..40be14a2b2 100644 --- a/addons/winddeflection/functions/fnc_initModuleSettings.sqf +++ b/addons/winddeflection/functions/fnc_initModuleSettings.sqf @@ -22,6 +22,8 @@ _activated = _this select 2; if !(_activated) exitWith {}; +[_logic, QGVAR(enabled), "enabled"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(vehicleEnabled), "vehicleEnabled"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(simulationInterval), "simulationInterval"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(simulationRadius), "simulationRadius"] call EFUNC(common,readSettingFromModule); diff --git a/addons/winddeflection/functions/fnc_updateTrajectoryPFH.sqf b/addons/winddeflection/functions/fnc_updateTrajectoryPFH.sqf index f5f1d3861e..4c2859f9b6 100644 --- a/addons/winddeflection/functions/fnc_updateTrajectoryPFH.sqf +++ b/addons/winddeflection/functions/fnc_updateTrajectoryPFH.sqf @@ -26,7 +26,7 @@ _bulletVelocity = velocity _bullet; _bulletSpeed = vectorMagnitude _bulletVelocity; - if (!alive _bullet || _bulletSpeed < 100) exitwith { + if (!alive _bullet || ((_bullet isKindOf "BulletBase") && _bulletSpeed < 100)) exitwith { [_this select 1] call cba_fnc_removePerFrameHandler; };