ACE3/addons/fcs/functions/fnc_vehicleInit.sqf

37 lines
1.5 KiB
Plaintext
Raw Normal View History

/*
* Author: KoffeinFlummi
*
* Checks if a vehicle is equipped with an FCS and if so, adds the fired event handler
*
* Arguments:
* 0: Vehicle
*
* Return Value:
* none
*/
2015-01-13 21:51:02 +00:00
#include "script_component.hpp"
private ["_gunBeg", "_gunnerView", "_gunBegPos", "_gunnerViewPos", "_viewDiff"];
if (getNumber (configFile >> "CfgVehicles" >> (typeOf (_this select 0)) >> QGVAR(Enabled)) == 1) then {
2015-01-14 20:07:41 +00:00
(_this select 0) addEventHandler ["Fired", {_this call FUNC(firedEH)}];
2015-01-14 20:07:41 +00:00
(_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];
2015-01-14 20:07:41 +00:00
// 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];
};
};