ACE3/addons/switchunits/functions/fnc_handleMapClick.sqf

31 lines
701 B
Plaintext
Raw Normal View History

#include "..\script_component.hpp"
/*
2015-02-02 22:28:27 +00:00
* Author: bux578
* Switches to a unit close to a clicked map position
*
* Arguments:
* 0: Faction <ARRAY>
2015-08-07 07:18:42 +00:00
* 0: unit <OBJECT>
* 1: sides <ARRAY>
* 1: Map Position <ARRAY>
2015-02-02 22:28:27 +00:00
*
* Return Value:
* None
*
* Example:
2015-08-07 07:18:42 +00:00
* [[unit, _sides], [20, 30]] call ace_switchunits_fnc_handleMapClick
2015-02-02 22:28:27 +00:00
*
* Public: No
*/
2015-01-12 14:47:22 +00:00
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);
2015-02-02 22:28:27 +00:00
openMap false;
};