From 70261e8c54953f5f170525a227dab63ab2a10dab Mon Sep 17 00:00:00 2001 From: William Riley Date: Wed, 2 Nov 2022 00:07:27 -0500 Subject: [PATCH 1/2] add range check so far away units are not searched. Fixes #12 --- .../functions/AI/NPC/fn_initNATOCheckpoint.sqf | 4 +++- .../functions/inventory/fn_getSearchStock.sqf | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/addons/overthrow_main/functions/AI/NPC/fn_initNATOCheckpoint.sqf b/addons/overthrow_main/functions/AI/NPC/fn_initNATOCheckpoint.sqf index 5fe6cb15..751441f9 100644 --- a/addons/overthrow_main/functions/AI/NPC/fn_initNATOCheckpoint.sqf +++ b/addons/overthrow_main/functions/AI/NPC/fn_initNATOCheckpoint.sqf @@ -88,7 +88,9 @@ while {!(isNil "_group") && count (units _group) > 0} do {\ _v = vehicle _x; _v setVelocity [0,0,0]; { - [_x,_v,true] call OT_fnc_dumpStuff; + if ((player distance _x) < 10) then { + [_x,_v,true] call OT_fnc_dumpStuff; + } }foreach(units _v); }; }; diff --git a/addons/overthrow_main/functions/inventory/fn_getSearchStock.sqf b/addons/overthrow_main/functions/inventory/fn_getSearchStock.sqf index 7ab6c76e..f1c670b5 100644 --- a/addons/overthrow_main/functions/inventory/fn_getSearchStock.sqf +++ b/addons/overthrow_main/functions/inventory/fn_getSearchStock.sqf @@ -10,8 +10,10 @@ if(_this isKindOf "Man") then { }else{ _myitems = (itemCargo _this) + (weaponCargo _this) + (magazineCargo _this) + (backpackCargo _this); { - _myitems = [_myitems,(items _this) + (magazines _this)] call BIS_fnc_arrayPushStack; - }foreach(units _this); + if ((player distance _x) < 10) then { + _myitems = [_myitems,(items _x) + (magazines _x)] call BIS_fnc_arrayPushStack; + } + }foreach(units _this); }; if !(isNil "_myitems") then { { From a18896c981a5aae04a6e694c4cf6e2cd37ebb178 Mon Sep 17 00:00:00 2001 From: William Riley Date: Wed, 2 Nov 2022 10:35:54 -0500 Subject: [PATCH 2/2] better distance check --- .../overthrow_main/functions/AI/NPC/fn_initNATOCheckpoint.sqf | 4 +++- .../overthrow_main/functions/inventory/fn_getSearchStock.sqf | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/overthrow_main/functions/AI/NPC/fn_initNATOCheckpoint.sqf b/addons/overthrow_main/functions/AI/NPC/fn_initNATOCheckpoint.sqf index 751441f9..f4bea0d6 100644 --- a/addons/overthrow_main/functions/AI/NPC/fn_initNATOCheckpoint.sqf +++ b/addons/overthrow_main/functions/AI/NPC/fn_initNATOCheckpoint.sqf @@ -87,8 +87,10 @@ while {!(isNil "_group") && count (units _group) > 0} do {\ if(vehicle _x != _x) then { _v = vehicle _x; _v setVelocity [0,0,0]; + private _playerpos = getpos ((units _v) select 0); { - if ((player distance _x) < 10) then { + private _dist = _playerpos distance _x; + if (_dist < 10) then { [_x,_v,true] call OT_fnc_dumpStuff; } }foreach(units _v); diff --git a/addons/overthrow_main/functions/inventory/fn_getSearchStock.sqf b/addons/overthrow_main/functions/inventory/fn_getSearchStock.sqf index f1c670b5..25760265 100644 --- a/addons/overthrow_main/functions/inventory/fn_getSearchStock.sqf +++ b/addons/overthrow_main/functions/inventory/fn_getSearchStock.sqf @@ -10,7 +10,9 @@ if(_this isKindOf "Man") then { }else{ _myitems = (itemCargo _this) + (weaponCargo _this) + (magazineCargo _this) + (backpackCargo _this); { - if ((player distance _x) < 10) then { + private _playerpos = getpos ((units _v) select 0); + private _dist = _playerpos distance _x; + if (_dist < 10) then { _myitems = [_myitems,(items _x) + (magazines _x)] call BIS_fnc_arrayPushStack; } }foreach(units _this);