mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
31 lines
698 B
Plaintext
31 lines
698 B
Plaintext
#include "script_component.hpp"
|
|
/*
|
|
* Author: bux578
|
|
* Switches to a unit close to a clicked map position
|
|
*
|
|
* Arguments:
|
|
* 0: Faction <ARRAY>
|
|
* 0: unit <OBJECT>
|
|
* 1: sides <ARRAY>
|
|
* 1: Map Position <ARRAY>
|
|
*
|
|
* Return Value:
|
|
* None
|
|
*
|
|
* Example:
|
|
* [[unit, _sides], [20, 30]] call ace_switchunits_fnc_handleMapClick
|
|
*
|
|
* Public: No
|
|
*/
|
|
|
|
params ["_sides", "_pos"];
|
|
|
|
private _nearestObjects = nearestObjects [_pos, ["Man"], 15];
|
|
|
|
private _nearestValidUnitIndex = _nearestObjects findIf {(side group _x in _sides) && {[_x] call FUNC(isValidAi)}};
|
|
|
|
if (_nearestValidUnitIndex != -1) then {
|
|
[_nearestObjects select _nearestValidUnitIndex] call FUNC(switchUnit);
|
|
openMap false;
|
|
};
|