Add getInteractionDistance and fix VTOL refuel/arm (#4882)

This commit is contained in:
PabstMirror 2017-02-10 12:34:51 -06:00 committed by GitHub
parent d2ee1e987a
commit 3ce0865913
7 changed files with 39 additions and 5 deletions

View File

@ -2,6 +2,7 @@
// interaction menu // interaction menu
PREP(addPassengerActions); PREP(addPassengerActions);
PREP(addPassengersActions); PREP(addPassengersActions);
PREP(getInteractionDistance);
PREP(getVehiclePos); PREP(getVehiclePos);
PREP(getVehiclePosComplex); PREP(getVehiclePosComplex);
PREP(getWeaponPos); PREP(getWeaponPos);

View File

@ -0,0 +1,33 @@
/*
* Author: PabstMirror
* Gets effective interaction distance (handles very large vehicles)
*
* Arguments:
* 0: Player <OBJECT>
* 0: Target Vehicle <OBJECT>
*
* Return value:
* Distance to interaction point <NUMBER>
*
* Example:
* [player, cursorObject] call ace_interaction_fnc_getInteractionDistance
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit", "_target"];
TRACE_3("getInteractionDistance",_unit,_target,typeOf _target);
// Handle Man, Crate
if (!((_target isKindOf "Car") || {_target isKindOf "Tank"} || {_target isKindOf "Helicopter"} || {_target isKindOf "Plane"} || {_target isKindOf "Ship_F"})) exitWith {
_unit distance _target
};
private _unitEyeASL = eyePos _unit;
private _targetModelPos = [_target, _unitEyeASL] call FUNC(getVehiclePosComplex);
private _distance = _unitEyeASL distance (AGLtoASL (_target modelToWorld _targetModelPos));
TRACE_2("",_targetModelPos,_distance);
_distance

View File

@ -19,7 +19,7 @@
private ["_dummy","_magazineClass"]; private ["_dummy","_magazineClass"];
params [["_target", objNull, [objNull]], ["_unit", objNull, [objNull]]]; params [["_target", objNull, [objNull]], ["_unit", objNull, [objNull]]];
if (GVAR(level) == 0 || {isNull _unit} || {!(_unit isKindOf "CAManBase")} || {!local _unit} || {_target distance _unit > REARM_ACTION_DISTANCE} || {_target getVariable [QGVAR(disabled), false]}) exitWith {false}; if (GVAR(level) == 0 || {isNull _unit} || {!(_unit isKindOf "CAManBase")} || {!local _unit} || {([_unit, _target] call EFUNC(interaction,getInteractionDistance)) > REARM_ACTION_DISTANCE} || {_target getVariable [QGVAR(disabled), false]}) exitWith {false};
_dummy = _unit getVariable [QGVAR(dummy), objNull]; _dummy = _unit getVariable [QGVAR(dummy), objNull];
if (isNull _dummy) exitwith {false}; if (isNull _dummy) exitwith {false};

View File

@ -22,5 +22,5 @@ params [["_unit", objNull, [objNull]], ["_target", objNull, [objNull]]];
{!(_unit isKindOf "CAManBase")} || {!(_unit isKindOf "CAManBase")} ||
{!local _unit} || {!local _unit} ||
{!alive _target} || {!alive _target} ||
{(_target distance _unit) > REFUEL_ACTION_DISTANCE} || {([_unit, _target] call EFUNC(interaction,getInteractionDistance)) > REFUEL_ACTION_DISTANCE} ||
{(_target call FUNC(getFuel) == REFUEL_INFINITE_FUEL)}) {(_target call FUNC(getFuel) == REFUEL_INFINITE_FUEL)})

View File

@ -27,5 +27,5 @@ if (_target isKindOf "AllVehicles") then {
!(isNull _nozzle || !(isNull _nozzle ||
{_engine} || {_engine} ||
{(_target distance _unit) > REFUEL_ACTION_DISTANCE} || {([_unit, _target] call EFUNC(interaction,getInteractionDistance)) > REFUEL_ACTION_DISTANCE} ||
{!isNull (_target getVariable [QGVAR(nozzle), objNull])}) {!isNull (_target getVariable [QGVAR(nozzle), objNull])})

View File

@ -21,5 +21,5 @@ params [["_unit", objNull, [objNull]], ["_target", objNull, [objNull]]];
private _nozzle = _unit getVariable [QGVAR(nozzle), objNull]; private _nozzle = _unit getVariable [QGVAR(nozzle), objNull];
(!isNull _nozzle) && (!isNull _nozzle) &&
{_target distance _unit < REFUEL_ACTION_DISTANCE} && {([_unit, _target] call EFUNC(interaction,getInteractionDistance)) < REFUEL_ACTION_DISTANCE} &&
{_target == (_nozzle getVariable [QGVAR(source), objNull])} {_target == (_nozzle getVariable [QGVAR(source), objNull])}

View File

@ -23,6 +23,6 @@ if (isNull _unit ||
{!local _unit} || {!local _unit} ||
{!alive _target} || {!alive _target} ||
{!isNull (_unit getVariable [QGVAR(nozzle), objNull])} || {!isNull (_unit getVariable [QGVAR(nozzle), objNull])} ||
{(_target distance _unit) > REFUEL_ACTION_DISTANCE}) exitWith {false}; {([_unit, _target] call EFUNC(interaction,getInteractionDistance)) > REFUEL_ACTION_DISTANCE}) exitWith {false};
!(_target getVariable [QGVAR(isConnected), false]) && {!(_unit getVariable [QGVAR(isRefueling), false])} !(_target getVariable [QGVAR(isConnected), false]) && {!(_unit getVariable [QGVAR(isRefueling), false])}