diff --git a/addons/cargo/CfgVehicles.hpp b/addons/cargo/CfgVehicles.hpp index 0dd59720dc..9d4c34182f 100644 --- a/addons/cargo/CfgVehicles.hpp +++ b/addons/cargo/CfgVehicles.hpp @@ -265,6 +265,16 @@ class CfgVehicles { GVAR(hasCargo) = 0; }; + class VTOL_Base_F; + class VTOL_01_base_F: VTOL_Base_F { + GVAR(space) = 4; + GVAR(hasCargo) = 1; + }; + class VTOL_02_base_F: VTOL_Base_F { + GVAR(space) = 4; + GVAR(hasCargo) = 1; + }; + // autonomus class UAV_01_base_F: Helicopter_Base_F { GVAR(space) = 0; diff --git a/addons/interaction/CfgVehicles.hpp b/addons/interaction/CfgVehicles.hpp index 0aa65cd762..5ee893e101 100644 --- a/addons/interaction/CfgVehicles.hpp +++ b/addons/interaction/CfgVehicles.hpp @@ -385,10 +385,11 @@ class CfgVehicles { class Air; class Helicopter: Air { + GVAR(bodyWidth) = 3; class ACE_Actions { class ACE_MainActions { displayName = CSTRING(MainAction); - position = QUOTE(call DFUNC(getVehiclePos)); + position = QUOTE([ARR_2(_target, EGVAR(interact_menu,cameraPosASL))] call DFUNC(getVehiclePosComplex)); selection = ""; distance = 4; condition = "true"; @@ -415,6 +416,7 @@ class CfgVehicles { class ACE_Actions { class ACE_MainActions { displayName = CSTRING(MainAction); + position = QUOTE([ARR_2(_target, EGVAR(interact_menu,cameraPosASL))] call DFUNC(getVehiclePosComplex)); selection = ""; distance = 4; condition = "true"; @@ -437,6 +439,16 @@ class CfgVehicles { }; }; + class VTOL_Base_F; + class VTOL_01_base_F: VTOL_Base_F { + GVAR(bodyWidth) = 4; + GVAR(bodyLength) = 10; + }; + class VTOL_02_base_F: VTOL_Base_F { + GVAR(bodyWidth) = 3; + GVAR(bodyLength) = 7; + }; + class Ship; class Ship_F: Ship { class ACE_Actions { diff --git a/addons/interaction/XEH_PREP.hpp b/addons/interaction/XEH_PREP.hpp index db6b1d3298..c8ceb66e8f 100644 --- a/addons/interaction/XEH_PREP.hpp +++ b/addons/interaction/XEH_PREP.hpp @@ -3,6 +3,7 @@ PREP(addPassengerActions); PREP(addPassengersActions); PREP(getVehiclePos); +PREP(getVehiclePosComplex); PREP(getWeaponPos); PREP(moduleInteraction); diff --git a/addons/interaction/functions/fnc_getVehiclePos.sqf b/addons/interaction/functions/fnc_getVehiclePos.sqf index 1b8ebc69f6..1544aea939 100644 --- a/addons/interaction/functions/fnc_getVehiclePos.sqf +++ b/addons/interaction/functions/fnc_getVehiclePos.sqf @@ -19,9 +19,6 @@ private _bb = boundingBoxReal _target; (_bb select 0) params ["_bbX", "_bbY", "_bbZ"]; -//Helicopter's rotors distort the bounding box, assume a max of 3 meters width for the body -if (_target isKindOf "Helicopter") then {_bbX = (_bbx min 3) max -3;}; - private _relPos = _target worldToModelVisual ASLToAGL EGVAR(interact_menu,cameraPosASL); #ifdef DEBUG_MODE_FULL _relPos = _target worldToModelVisual ASLToAGL eyePos ACE_player; diff --git a/addons/interaction/functions/fnc_getVehiclePosComplex.sqf b/addons/interaction/functions/fnc_getVehiclePosComplex.sqf new file mode 100644 index 0000000000..886f7052c4 --- /dev/null +++ b/addons/interaction/functions/fnc_getVehiclePosComplex.sqf @@ -0,0 +1,59 @@ +/* + * Author: esteldunedain, PabstMirror + * Return a suitable position for the action point for the given target vehicle + * + * Arguments: + * 0: Target + * 1: Player's Position ASL + * + * Return value: + * Interaction point in model cords + * + * Example: + * [cursorTarget, eyePos player] call ace_interaction_fnc_getVehiclePosComplex + * + * Public: No + */ +#include "script_component.hpp" + +params ["_target", "_cameraPosASL"]; +TRACE_2("params",_target,_cameraPosASL); + +private _bb = boundingBoxReal _target; +(_bb select 0) params ["_bbX", "_bbY", "_bbZ"]; + +private _config = configFile >> "CfgVehicles" >> (typeOf _target); +if (isNumber (_config >> QGVAR(bodyWidth))) then {_bbX = getNumber (_config >> QGVAR(bodyWidth));}; +if (isNumber (_config >> QGVAR(bodyLength))) then {_bbY = getNumber (_config >> QGVAR(bodyLength));}; + +private _relPos = _target worldToModelVisual ASLToAGL _cameraPosASL; +_relPos params ["_dx", "_dy", "_dz"]; + +private _ndx = (abs _dx) / ((abs (_bbx)) - 1); +private _ndy = (abs _dy) / ((abs (_bbY)) - 1); +private _ndz = (abs _dz) / ((abs (_bbZ)) - 1); + + +private "_pos"; +if (_ndx > _ndy) then { + if (_ndx > _ndz) then { + // _ndx is greater, will colide with x plane first + _pos = _relPos vectorMultiply ((1 / _ndx) min 0.8); + } else { + // _ndz is greater, will colide with z plane first + _pos = _relPos vectorMultiply ((1 / _ndz) min 0.8); + }; +} else { + if (_ndy > _ndz) then { + // _ndy is greater, will colide with y plane first + _pos = _relPos vectorMultiply ((1 / _ndy) min 0.8); + } else { + // _ndz is greater, will colide with z plane first + _pos = _relPos vectorMultiply ((1 / _ndz) min 0.8); + }; +}; + +//Set max height at player's eye level (prevent very high interactin point on choppers) +_pos set [2, (_pos select 2) min _dz]; + +_pos