; ; This is a part of the Group Link II script. ; ; /KeyCat ; ; Get current group _helpgroup = _this select 0 _NotInVehicle = [] _TempArray = [] _Spot = ParkingSpot ; ---------------------------------------------------------------------------- ; Get current vehicle leader is in, if not in any vehicle the leader is returned _tmp = vehicle (leader _helpgroup) ; Check if leader is on foot? ? _tmp == (leader _helpgroup) : goto "AI_on_Foot" ; Check if leader is in a APC ? ((typeOf(_tmp) in KEY_EastAPCTypes)) : goto "AI_in_APC" ; Check if leader is in a chopper ? ((typeOf(_tmp) in KEY_EastHeliTypes)) : goto "AI_in_Chopper" ; Check if leader is in a plane - FEATURE NOT IMPLEMENTED YET! ;? ((typeOf(_tmp) in KEY_EastPlaneTypes)) : goto "AI_in_Plane" ; Check if leader is in a boat - FEATURE NOT IMPLEMENTED YET! ;? ((typeOf(_tmp) in KEY_EastBoatTypes)) : goto "AI_in_Boat" ; None of the above, exit script exit ; ---------------------------------------------------------------------------- #AI_in_Chopper ; ########### DEBUG ########### ;hint "DEBUG: Land helicopter" ; ############################# ; Land helicopter _tmp land "get in" ; Pause ~1 ; Assign all (living) infantry soldiers as cargo and order them to get in "if !((typeof _x in KEY_CrewMembers) && (alive _x)) then {_x assignAsCargo _tmp; units _helpgroup orderGetIn True}" forEach units _helpgroup ; ########### DEBUG ########### ;hint "DEBUG: All boarded the helicopter" ; ############################# ; Return to helipad at their base named EastBase _helpgroup move (getPos EastBase) ; Wait until pilot is ready @ (unitReady (leader _helpgroup)) ; Land helicopter _tmp land "land" ; Exit script exit ; ---------------------------------------------------------------------------- #AI_in_APC ; ########### DEBUG ########### ;hint "DEBUG: Board BMP" ; ############################# ; Assign all infantry soldiers as cargo and order them to get in "if !((typeof _x in KEY_CrewMembers) && (alive _x)) then {_x assignAsCargo _tmp; units _helpgroup orderGetIn True}" forEach units _helpgroup ; ########### DEBUG ########### ;hint "DEBUG: All boarded the BMP" ; ############################# ; Exit script exit ; ---------------------------------------------------------------------------- #AI_on_Foot ; No parkingspots has been allocated ? (count KEY_ParkingSpots == 0) : goto "nocars" ; Random delay in case of more than one group looking for their cars ~random 20 ; ########### DEBUG ########### ;hint "DEBUG: Get back to parkingspot" ; ############################# ; Select one of available parking spots from array KEY_ParkingSpots. Remove it when done ? (0 in KEY_ParkingSpots) : KEY_ParkingSpots = KEY_ParkingSpots - [0]; _Spot = ParkingSpot ? (1 in KEY_ParkingSpots) : KEY_ParkingSpots = KEY_ParkingSpots - [1]; _Spot = ParkingSpot1 ? (2 in KEY_ParkingSpots) : KEY_ParkingSpots = KEY_ParkingSpots - [2]; _Spot = ParkingSpot2 ? (3 in KEY_ParkingSpots) : KEY_ParkingSpots = KEY_ParkingSpots - [3]; _Spot = ParkingSpot3 ; Order group to get back to selected parkingspot _helpgroup move (getPos _Spot) ; If leader is close to the parkingspot look for cars directly ? ((leader _helpgroup) distance _Spot) < 15 : goto "look_for_1st_car" ; Otherwise wait until leader is within 15 m range else nearestobject won't work @ ((leader _helpgroup) distance _Spot) <= 15 #look_for_1st_car ; Clear variable _Tries = 0 ; Save first parkingspots location _OrgParkingSpot = (getpos _Spot) ; ########### DEBUG ########### ;hint "DEBUG: Looking for 1 st car" ;~2 ; ############################# ; Clear variable _i = 0 ; Count vehicle array _TotalVehicles = count KEY_EastVehicleTypes #LoopVehicles_1 ; ########### DEBUG ########### ;hint format["DEBUG: Vehicle loop %1",_i] ;~2 ; ############################# ; See if there is a car close to ParkingSpot _tmp = nearestobject [(getpos _Spot), KEY_EastVehicleTypes select _i] ; ########### DEBUG ########### ;hint format["DEBUG: Looked for %1",(KEY_EastVehicleTypes select _i)] ;~2 ; ############################# ; Increase variable _i = _i + 1 ; Check if the vehicle is functional and empty, if not check next in array if ((isNull _tmp) || !(canMove _tmp) || (count (crew _tmp) != 0)) then {goto "LoopVehicles_1"} ; Didn't found any vehicles at all near the parkingspot if (_i == _TotalVehicles) then {goto "nocars"} ; ########### DEBUG ########### ;hint format["Found car object:\n%1",_tmp] ;~4 ; ############################# ; Select leader assign him as driver (leader _helpgroup) assignAsDriver _tmp ; Order leader to getin the truck [(leader _helpgroup)] orderGetIn True ; Assign rest soldiers in group as cargo "if (_x != leader _helpgroup) then {_x assignAsCargo _tmp}" forEach units _helpgroup ; Order them to get in units _helpgroup orderGetIn True ; Wait until they had time to get in the car ~50 ; Check if all got room in the first vehicle, if not add them to the _NotinVehicle array "if !(_x in _tmp) then {_NotInVehicle = _NotInVehicle + [_x]}" forEach units _helpgroup ; Count array to see if anyone still not in a car ? (count _NotinVehicle == 0) : goto "nocars" ; Save the first car used to a variable _Car1 = _tmp #look_for_more_cars ; Clear variable _ParkMoves = 0 ; ########### DEBUG ########### ;hint "DEBUG: Looking for more cars" ;~2 ; ############################# ; ########### DEBUG ########### ;hint format["Found car object:\n%1",_tmp] ;~4 ; ############################# ; Increment variable _Tries = _Tries + 1 #look_again ; Increment variable _ParkMoves = _ParkMoves + 1 ; If we moved the "parkingspot" 50 times and did not find anything goto nocars ? (_ParkMoves > 50) : goto "nocars" ; Get original parking spots location _px = _OrgParkingSpot select 0 _py = _OrgParkingSpot select 1 ; Randomly move parking spot location +/- 100 m _Spot SetPos [((_px) + ((random 100) - (random 100))),((_py) + ((random 100) - (random 100))),0] ; Pause ~0.1 ; Clear variable _i = 0 #LoopVehicles_2 ; ########### DEBUG ########### ;hint format["DEBUG: _i=%1, _TotalVehicles=%2",_i,_TotalVehicles] ;~2 ; ############################# ; See if there is a car close to ParkingSpot _tmp = nearestobject [(getpos _Spot), KEY_EastVehicleTypes select _i] ; Increase variable _i = _i + 1 ; If no functional and empty vehicle is found, search thru whole array for all possible types if ((isNull _tmp) || (_tmp == _Car1) || !(canMove _tmp) || (count (crew _tmp) != 0)) then {goto "Continue_Array"} else {goto "Continue_Else"} #Continue_Array ; Make sure whole array is checked if (_i < _TotalVehicles) then {goto "LoopVehicles_2"} ; ---------------------------------------------------------------------------- #Continue_Else ; ########### DEBUG ########### ;hint "DEBUG: Looking for another car" ;~2 ; ############################# ; If nothing is found or damaged or already taken no functional cars is nearby ? (isNull _tmp) || (_tmp == _Car1) || !(canMove _tmp) || (count (crew _tmp) != 0) : goto "look_again" ; ########### DEBUG ########### ;hint format["Object:\n%1",_tmp] ;~2 ; ############################# ; Select first soldier in the array and assign him as driver (_NotinVehicle select 0) assignAsDriver _tmp ; Order him to get in [(_NotinVehicle select 0)] orderGetIn True ; Remove him from the array _NotinVehicle = _NotinVehicle - [(_NotinVehicle select 0)] ; Assign rest soldiers in array as cargo and remove him from array "_x assignAsCargo _tmp" forEach _NotinVehicle ; Order them to get in _NotinVehicle orderGetIn True ; Wait enough time until they had time to get in the car ~50 ; Copy to a temp array _TempArray = _NotInVehicle ; Clear array _NotinVehicle = [] ; Check if all got room in the other vehicle, if not add them to the _NotinVehicle array "if !(_x in _tmp) then {_NotInVehicle = _NotInVehicle + [_x]}" forEach _TempArray ; ########### DEBUG ########### ;hint format["_NotinVehicle array:\n%1",_NotinVehicle] ;~2 ; ############################# ; Count array to see if anyone still not in a car ? ((count _NotinVehicle == 0) || (_Tries == 3)) : goto "nocars" goto "look_for_more_cars" ; ---------------------------------------------------------------------------- #nocars ; ########### DEBUG ########### ;hint "DEBUG: No cars or all in" ;~2 ; ############################# ; Exit script exit ; ----------------------------------------------------------------------------