mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Repair - Use object with lowest damage for changing wheels/tracks (#9648)
sort claimObject by damage
This commit is contained in:
parent
ac9044f2d6
commit
99ccf31807
@ -7,6 +7,7 @@
|
||||
* 0: Unit that does the repairing <OBJECT>
|
||||
* 1: Max range to seach from unit (meters) <NUMBER>
|
||||
* 2: Array of arrays of classnames <ARRAY>
|
||||
* 3: Sort objects by damage <BOOL> (default: false)
|
||||
*
|
||||
* Return Value:
|
||||
* Array of objects, or [] if not all available <ARRAY>
|
||||
@ -17,8 +18,8 @@
|
||||
* Public: Yes
|
||||
*/
|
||||
|
||||
params ["_unit", "_maxRange", "_objectsToClaim"];
|
||||
TRACE_3("params",_unit,_maxRange,_objectsToClaim);
|
||||
params ["_unit", "_maxRange", "_objectsToClaim", ["_sortByDamage", false]];
|
||||
TRACE_4("params",_unit,_maxRange,_objectsToClaim,_sortByDamage);
|
||||
|
||||
private _return = [];
|
||||
|
||||
@ -27,6 +28,11 @@ private _return = [];
|
||||
private _ableToAquire = []; //will be array of objects
|
||||
{
|
||||
private _nearObjects = _unit nearEntities [_x, _maxRange];
|
||||
if (_sortByDamage && {count _nearObjects > 1}) then {
|
||||
_nearObjects = _nearObjects apply {[damage _x, _x]};
|
||||
_nearObjects sort true;
|
||||
_nearObjects = _nearObjects apply {_x select 1};
|
||||
};
|
||||
{
|
||||
if (!(_x in _ableToAquire) && {(_x getVariable [QEGVAR(common,owner), objNull]) in [objNull, _unit]}) exitWith { // skip claimed objects
|
||||
_ableToAquire pushBack _x
|
||||
|
@ -95,7 +95,7 @@ if (!("All" in _repairLocations)) then {
|
||||
private _requiredObjects = getArray (_config >> "claimObjects");
|
||||
private _claimObjectsAvailable = [];
|
||||
if (_requiredObjects isNotEqualTo []) then {
|
||||
_claimObjectsAvailable = [_caller, 5, _requiredObjects] call FUNC(getClaimObjects);
|
||||
_claimObjectsAvailable = [_caller, 5, _requiredObjects, true] call FUNC(getClaimObjects);
|
||||
if (_claimObjectsAvailable isEqualTo []) then {
|
||||
TRACE_2("Missing Required Objects",_requiredObjects,_claimObjectsAvailable);
|
||||
_return = false
|
||||
|
Loading…
Reference in New Issue
Block a user