diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 6dacdf316b..05322924e0 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -92,6 +92,7 @@ PREP(getTurretIndex); PREP(getTurrets); PREP(getTurretsFFV); PREP(getTurretsOther); +PREP(getTurretDirection); PREP(getUavControlPosition); PREP(getVehicleCargo); PREP(getVehicleCodriver); diff --git a/addons/common/functions/fnc_getTurretDirection.sqf b/addons/common/functions/fnc_getTurretDirection.sqf new file mode 100644 index 0000000000..9022670af5 --- /dev/null +++ b/addons/common/functions/fnc_getTurretDirection.sqf @@ -0,0 +1,37 @@ +/* + * Author: jaynus + * + * Get the absolute turret direction for FOV/PIP turret. + * + * Argument: + * 0: Vehicle (Object) + * 1: Turret Position + * + * Return value: + * [position, direction] + */ +#include "script_component.hpp" + +EXPLODE_2_PVT(_this,_vehicle,_position); +private ["_turrets", "_turret", "_config", "_turret", "_povPos", "_povDir", "_gunBeginPos", "_gunEndPos", "_pov"]; + +_turret = [_vehicle, _position] call CBA_fnc_getTurret; +_pov = getText (_turret >> "memoryPointGunnerOptics"); +_gunBeg = getText (_turret >> "gunBeg"); +_gunEnd = getText (_turret >> "gunEnd"); +TRACE_3("", _pov, _gunBeg, _gunEnd); + +// Pull the PIP pov or barrel direction, depending on how the model is set up +_povPos = ATLtoASL ( _vehicle modelToWorld (_vehicle selectionPosition _pov ) ); +_povDir = [0,0,0]; + +if(_pov == "pip0_pos") then { + _pipDir = ATLtoASL ( _vehicle modelToWorld (_vehicle selectionPosition "pip0_dir" ) ); + _povDir = [_povPos, _pipDir] call BIS_fnc_vectorDiff; +} else { + _gunBeginPos = ATLtoASL ( _vehicle modelToWorld (_vehicle selectionPosition _gunBeg ) ); + _gunEndPos = ATLtoASL ( _vehicle modelToWorld (_vehicle selectionPosition _gunEnd ) ); + _povDir = [_gunEndPos, _gunBeginPos] call BIS_fnc_vectorDiff; +}; + +[_povPos, _povDir] \ No newline at end of file diff --git a/addons/laser_selfdesignate/CfgEventhandlers.hpp b/addons/laser_selfdesignate/CfgEventhandlers.hpp index 953687bb2b..e75b3b674b 100644 --- a/addons/laser_selfdesignate/CfgEventhandlers.hpp +++ b/addons/laser_selfdesignate/CfgEventhandlers.hpp @@ -13,7 +13,7 @@ class Extended_PostInit_EventHandlers { class Extended_GetIn_EventHandlers { class B_Heli_Attack_01_F { class ADDON { - getIn = QUOTE(_this call FUNC(onGetin)); + clientGetIn = QUOTE(_this call FUNC(onGetIn)); }; }; }; @@ -21,7 +21,7 @@ class Extended_GetIn_EventHandlers { class Extended_GetOut_EventHandlers { class B_Heli_Attack_01_F { class ADDON { - getOut = QUOTE(_this call FUNC(onGetout)); + clientGetOut = QUOTE(_this call FUNC(onGetOut)); }; }; }; diff --git a/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOn.sqf b/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOn.sqf index a58284ee34..a2f3c5f871 100644 --- a/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOn.sqf +++ b/addons/laser_selfdesignate/functions/fnc_laserHudDesignateOn.sqf @@ -33,26 +33,9 @@ FUNC(laserHudDesignatePFH) = { // Retrieve the gunner and turret memory point information _gunnerInfo = [_vehicle, _weapon] call CBA_fnc_getFirer; - - _turret = [_vehicle, _gunnerInfo select 1] call CBA_fnc_getTurret; - _pov = getText (_turret >> "memoryPointGunnerOptics"); - _gunBeg = getText (_turret >> "gunBeg"); - _gunEnd = getText (_turret >> "gunEnd"); - TRACE_3("", _pov, _gunBeg, _gunEnd); - - // Pull the PIP pov or barrel direction, depending on how the model is set up - _povPos = ATLtoASL ( _vehicle modelToWorld (_vehicle selectionPosition _pov ) ); - _povDir = [0,0,0]; - if(_pov == "pip0_pos") then { - _pipDir = ATLtoASL ( _vehicle modelToWorld (_vehicle selectionPosition "pip0_dir" ) ); - _povDir = [_povPos, _pipDir] call BIS_fnc_vectorDiff; - } else { - _gunBeginPos = ATLtoASL ( _vehicle modelToWorld (_vehicle selectionPosition _gunBeg ) ); - _gunEndPos = ATLtoASL ( _vehicle modelToWorld (_vehicle selectionPosition _gunEnd ) ); - _povDir = [_gunEndPos, _gunBeginPos] call BIS_fnc_vectorDiff; - }; - - TRACE_4("", _povDir, _povPos, _gunBeginPos, _gunEndPos); + _turretInfo = [_vehicle, _gunnerInfo select 1] call EFUNC(common,getTurretDirection); + _povPos = _turretInfo select 0; + _povDir = _turretInfo select 1; _result = [_povPos, _povDir] call EFUNC(laser,shootCone); diff --git a/addons/laser_selfdesignate/functions/fnc_onGetin.sqf b/addons/laser_selfdesignate/functions/fnc_onGetin.sqf index d6f555c02f..dc62f72e95 100644 --- a/addons/laser_selfdesignate/functions/fnc_onGetin.sqf +++ b/addons/laser_selfdesignate/functions/fnc_onGetin.sqf @@ -1,4 +1,4 @@ -#define DEBUG_MODE_FULL +//#define DEBUG_MODE_FULL #include "script_component.hpp" // TODO: we should do this differently eventually private["_onActionId", "_offActionId"];