2015-01-11 16:42:31 +00:00
|
|
|
/*
|
2015-02-02 22:28:27 +00:00
|
|
|
* Author: bux578
|
|
|
|
* Switches to a unit close to a clicked map position
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: unit <OBJECT>
|
|
|
|
* 1: sides <ARRAY<OBJECT>>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [_unit, _sides] call FUNC(handleMapClick)
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-01-12 14:47:22 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-01-27 08:01:57 +00:00
|
|
|
private ["_sides", "_pos", "_sideNearest"];
|
|
|
|
|
2015-01-11 16:42:31 +00:00
|
|
|
_sides = (_this select 0) select 1;
|
|
|
|
_pos = _this select 1;
|
|
|
|
|
|
|
|
_sideNearest = [];
|
|
|
|
|
|
|
|
{
|
2015-02-02 22:28:27 +00:00
|
|
|
if ([_x] call FUNC(isValidAi) && (side group _x in _sides)) then {
|
|
|
|
_sideNearest pushBack _x;
|
|
|
|
};
|
2015-01-11 16:42:31 +00:00
|
|
|
} forEach (nearestObjects [_pos, ["Man"], 20]);
|
|
|
|
|
|
|
|
|
|
|
|
if (count _sideNearest > 0) then {
|
2015-02-02 22:28:27 +00:00
|
|
|
private ["_switchUnit"];
|
|
|
|
|
|
|
|
_switchUnit = _sideNearest select 0;
|
|
|
|
[ACE_player, _switchUnit] call FUNC(switchUnit);
|
|
|
|
|
|
|
|
openMap false;
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|