cargo - use getInteractionDistance to get better distance (#5697)

This commit is contained in:
PabstMirror 2017-11-10 08:28:12 -06:00 committed by jonpas
parent 28706c4dab
commit 70c25aacaf
8 changed files with 12 additions and 8 deletions

View File

@ -22,10 +22,11 @@ private _statement = {
[_player, _target, _vehicle] call FUNC(startLoadIn); [_player, _target, _vehicle] call FUNC(startLoadIn);
}; };
private _vehicles = (nearestObjects [_target, GVAR(cargoHolderTypes), MAX_LOAD_DISTANCE]) select { private _vehicles = (nearestObjects [_target, GVAR(cargoHolderTypes), (MAX_LOAD_DISTANCE + 10)]) select {
private _hasCargoConfig = 1 == getNumber (configFile >> "CfgVehicles" >> typeOf _x >> QGVAR(hasCargo)); private _hasCargoConfig = 1 == getNumber (configFile >> "CfgVehicles" >> typeOf _x >> QGVAR(hasCargo));
private _hasCargoPublic = _x getVariable [QGVAR(hasCargo), false]; private _hasCargoPublic = _x getVariable [QGVAR(hasCargo), false];
(_hasCargoConfig || {_hasCargoPublic}) && {_x != _target} (_hasCargoConfig || {_hasCargoPublic}) && {_x != _target} &&
{([_target, _x] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE}
}; };
[_vehicles, _statement, _target] call EFUNC(interact_menu,createVehiclesActions) [_vehicles, _statement, _target] call EFUNC(interact_menu,createVehiclesActions)

View File

@ -34,7 +34,7 @@ if (_item isEqualType "") then {
} else { } else {
_validItem = _validItem =
(alive _item) && (alive _item) &&
{(_item distance _vehicle) <= MAX_LOAD_DISTANCE}; {([_item, _vehicle] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE};
}; };
_validItem && _validItem &&

View File

@ -58,8 +58,9 @@ private _condition = {
private _type = typeOf _x; private _type = typeOf _x;
private _hasCargoPublic = _x getVariable [QGVAR(hasCargo), false]; private _hasCargoPublic = _x getVariable [QGVAR(hasCargo), false];
private _hasCargoConfig = getNumber (configFile >> "CfgVehicles" >> _type >> QGVAR(hasCargo)) == 1; private _hasCargoConfig = getNumber (configFile >> "CfgVehicles" >> _type >> QGVAR(hasCargo)) == 1;
(_hasCargoPublic || _hasCargoConfig) && {_x != _target} (_hasCargoPublic || _hasCargoConfig) && {_x != _target} &&
} count (nearestObjects [_player, GVAR(cargoHolderTypes), MAX_LOAD_DISTANCE])} {([_target, _x] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE}
} count (nearestObjects [_player, GVAR(cargoHolderTypes), (MAX_LOAD_DISTANCE + 10)])}
}; };
private _statement = { private _statement = {
params ["_target", "_player"]; params ["_target", "_player"];

View File

@ -71,6 +71,7 @@ private _condition = {
GVAR(enable) && GVAR(enable) &&
{(_target getVariable [QGVAR(hasCargo), getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(hasCargo)) == 1])} && {(_target getVariable [QGVAR(hasCargo), getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(hasCargo)) == 1])} &&
{locked _target < 2} && {locked _target < 2} &&
{([_player, _target] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE} &&
{alive _target} && {alive _target} &&
{[_player, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)} {[_player, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)}
}; };

View File

@ -32,7 +32,7 @@ if (GVAR(interactionParadrop)) then {
[_this select 1] call CBA_fnc_removePerFrameHandler; [_this select 1] call CBA_fnc_removePerFrameHandler;
}; };
if (isNull GVAR(interactionVehicle) || {(ACE_player distance GVAR(interactionVehicle) >= 10) && {(vehicle ACE_player) != GVAR(interactionVehicle)}}) exitWith { if (isNull GVAR(interactionVehicle) || {(([ACE_player, GVAR(interactionVehicle)] call EFUNC(interaction,getInteractionDistance)) >= MAX_LOAD_DISTANCE) && {(vehicle ACE_player) != GVAR(interactionVehicle)}}) exitWith {
closeDialog 0; closeDialog 0;
[_this select 1] call CBA_fnc_removePerFrameHandler; [_this select 1] call CBA_fnc_removePerFrameHandler;
}; };

View File

@ -24,7 +24,7 @@ private _vehicle = _cargoVehicle;
if (isNull _vehicle) then { if (isNull _vehicle) then {
{ {
if ([_object, _x] call FUNC(canLoadItemIn)) exitWith {_vehicle = _x}; if ([_object, _x] call FUNC(canLoadItemIn)) exitWith {_vehicle = _x};
} forEach (nearestObjects [_player, GVAR(cargoHolderTypes), MAX_LOAD_DISTANCE]); } forEach (nearestObjects [_player, GVAR(cargoHolderTypes), (MAX_LOAD_DISTANCE + 10)]);
}; };
if (isNull _vehicle) exitWith { if (isNull _vehicle) exitWith {

View File

@ -16,7 +16,7 @@
#include "\z\ace\addons\main\script_macros.hpp" #include "\z\ace\addons\main\script_macros.hpp"
#define MAX_LOAD_DISTANCE 10 #define MAX_LOAD_DISTANCE 5
#define GET_NUMBER(config,default) (if (isNumber (config)) then {getNumber (config)} else {default}) #define GET_NUMBER(config,default) (if (isNumber (config)) then {getNumber (config)} else {default})

View File

@ -174,6 +174,7 @@ class CfgVehicles {
}; };
class rhsusf_CH53E_USMC: Helicopter_Base_H { class rhsusf_CH53E_USMC: Helicopter_Base_H {
EGVAR(interaction,bodyWidth) = 3.5;
EGVAR(map,vehicleLightColor)[] = {1,0,0,0.1}; EGVAR(map,vehicleLightColor)[] = {1,0,0,0.1};
EGVAR(fastroping,enabled) = 1; EGVAR(fastroping,enabled) = 1;
EGVAR(fastroping,ropeOrigins)[] = {{0,-9.5,2.6}}; EGVAR(fastroping,ropeOrigins)[] = {{0,-9.5,2.6}};