summaryrefslogtreecommitdiffstats
path: root/Server/AI/AI_TLWPHandler.sqs
blob: c94a6a8a633b2d7c1020138bee79ba7699528831 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Private ["_group","_i","_timeSince","_unit","_units","_waitForMembers","_wpPos"]
_group = _this select 0
_wpPos = _this select 1

_timeSince = 0

if (vehicle (leader _group) isKindOf "Air") then {Goto "Exit";}

#Main
	~5
	
	_timeSince = _timeSince + 5
	
	;Check for the group's status.
	_units = ((units _group) Call GetLiveUnits) - [leader _group]

	;Exit if the leader is the only member.
	if (count _units < 2) then {Goto "Exit";}
	
	_i = 0
	_waitForMembers = false
	
	;Iterate through all members.
	#Loop
		_unit = _units select _i
		
		if (_unit distance (leader _group) > 150 && !(_unit isKindOf 'Air')) then {_waitForMembers = true; if (_timeSince > 240) then {[vehicle _unit,getPos (leader _group),75] Call PlaceSafe;};}
		
		_i = _i + 1
	
		if (_i == count _units) then {if (_waitForMembers) then {Goto "Main";} else {Goto "Exit";}};
	
		Goto "Loop"
	
	Goto "Main"
	
#Exit

	Exit