From a4c710bd28c5822912f46088e0bd92ce9620408d Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Fri, 8 May 2015 13:36:24 -0500 Subject: [PATCH] Switch scopes to use firedBIS --- addons/scopes/CfgEventHandlers.hpp | 4 ++-- addons/scopes/functions/fnc_firedEH.sqf | 27 ++++++++++++++----------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/addons/scopes/CfgEventHandlers.hpp b/addons/scopes/CfgEventHandlers.hpp index b3d70a2861..5c23e0c462 100644 --- a/addons/scopes/CfgEventHandlers.hpp +++ b/addons/scopes/CfgEventHandlers.hpp @@ -10,10 +10,10 @@ class Extended_PostInit_EventHandlers { }; }; -class Extended_Fired_EventHandlers { +class Extended_FiredBIS_EventHandlers { class CAManBase { class ADDON { - fired = QUOTE(_this call FUNC(firedEH);); + firedBIS = QUOTE(_this call FUNC(firedEH);); }; }; }; diff --git a/addons/scopes/functions/fnc_firedEH.sqf b/addons/scopes/functions/fnc_firedEH.sqf index 8753019931..1b692e340a 100644 --- a/addons/scopes/functions/fnc_firedEH.sqf +++ b/addons/scopes/functions/fnc_firedEH.sqf @@ -3,12 +3,13 @@ * Adjusts the flight path of the bullet according to the zeroing * * Argument: - * 0: Unit - * 1: Weapon - * 3: Muzzle - * 4: Magazine - * 5: Ammo - * 6: Projectile + * 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: * None @@ -20,23 +21,25 @@ private ["_unit", "_adjustment", "_weapon", "_projectile", "_weaponIndex", "_zeroing", "_adjustment"]; _unit = _this select 0; +_weapon = _this select 1; +_projectile = _this select 6; // Exit if the unit doesn't have any adjusment variable -_adjustment = _unit getVariable QGVAR(Adjustment); -if (isNil "_adjustment") exitWith {}; +_adjustment = _unit getVariable [QGVAR(Adjustment), []]; +if (_adjustment isEqualTo []) exitWith {}; // Exit if the unit isn't a player if !([_unit] call EFUNC(common,isPlayer)) exitWith {}; -_weapon = _this select 1; -_projectile = _this select 5; - _weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex); if (_weaponIndex < 0) exitWith {}; _zeroing = _adjustment select _weaponIndex; +//Exit if adjusment is zero: +if (_zeroing isEqualTo [0,0,0]) exitWith {}; + // Convert zeroing from mils to degrees -_zeroing = [_zeroing, {_this * 0.05625}] call EFUNC(common,map); +_zeroing = _zeroing vectorMultiply 0.05625; [_projectile, (_zeroing select 1), (_zeroing select 0) + (_zeroing select 2), 0] call EFUNC(common,changeProjectileDirection);