Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (isServer) then {
- private["_mission","_vehname","_vehclass","_vehicle","_position","_unitGroup","_waypoint_data","_num_waypoints","_leader","_count_wp","_waypoints","_waypoint_prev","_msg","_wp"];
- _mission = count wai_mission_data -1;
- //Armed Land Vehicle
- _vehclass = armed_vehicle call BIS_fnc_selectRandom;
- _vehname = getText (configFile >> "CfgVehicles" >> _vehclass >> "displayName");
- _position = [40] call find_position;
- [_mission,_position,"Medium",format["Disabled %1",_vehname],"MainHero",true] call mission_init;
- //Troops
- _num = 4 + round (random 3);
- [[_position select 0,_position select 1,0],_num,"hard","Random",4,"Random","Bandit","Random","Bandit",_mission] call spawn_group;
- _waypoint_data = 10; //some
- _num_waypoints = 5; //how many waypoints?
- _leader = leader _unitGroup;
- _count_wp = count _waypoint_data;
- _waypoint_prev = "";
- _vehicle setvehiclelock "UNLOCKED";
- _unitGroup setBehaviour "COMBAT";
- _unitGroup setCombatMode "YELLOW";
- {
- if(_leader == _x) then {
- _x assignAsDriver _vehicle;
- _x action["getInDriver",_vehicle];
- diag_log format["WAI: %1 assigned as driver",_x];
- } else {
- if((_vehicle emptyPositions "GUNNER") > 0) then {
- _x assignAsGunner _vehicle;
- _x moveInGunner _vehicle;
- diag_log format["WAI: %1 assigned as gunner",_x];
- } else {
- _x moveInCargo _vehicle;
- diag_log format["WAI: %1 assigned as cargo",_x];
- };
- };
- } forEach units _unitGroup;
- waitUntil {(_vehicle emptyPositions "DRIVER" == 0)}; // Wait until driver gets inside vehicle
- diag_log format["WAI: Driver is inside vehicle, continue.."];
- [_vehicle,_unitGroup] spawn {
- private["_vehicle","_unitGroup","_runmonitor"];
- _vehicle = _this select 0;
- _unitGroup = _this select 1;
- _runmonitor = true;
- while {(canMove _vehicle && _runmonitor)} do {
- if (fuel _vehicle < 0.2) then { _vehicle setfuel 1; };
- if (!(alive leader _unitGroup)) then {
- diag_log "WAI: Driver was killed, ejecting AI and removing waypoints.";
- _runmonitor = false;
- };
- sleep .5;
- };
- if(_runmonitor) then {
- diag_log "WAI: Vehicle became undriveable, ejecting crew.";
- };
- deleteWaypoint [_unitGroup, all];
- waitUntil { (speed _vehicle < 10) }; // Wait until vehicle slows down before ejecting crew
- {
- _x action ["eject",vehicle _x];
- } forEach crew _vehicle;
- _wp = _unitGroup addWaypoint [(getPos _vehicle),0];
- _wp setWaypointType "GUARD";
- _wp setWaypointBehaviour "COMBAT";
- };
- for "_i" from 1 to _num_waypoints do {
- _rand_nr = ceil(random((_count_wp - _i)));
- _waypoint = (_waypoint_data select _rand_nr);
- _waypoint_data set[_rand_nr,-1];
- _waypoint_data = _waypoint_data - [-1];
- _wp = _unitGroup addWaypoint [(_waypoint select 1),0];
- if(_i == _num_waypoints) then {
- _wp setWaypointType "GUARD";
- } else {
- _wp setWaypointType "MOVE";
- };
- _wp setWaypointBehaviour "CARELESS";
- _wp setWaypointCombatMode "YELLOW";
- if(_waypoint_prev != "") then {
- _msg = format["[RADIO] The patrol arrived at %1, heading towards %2",_waypoint_prev,(_waypoint select 0)];
- } else {
- _msg = format["[RADIO] The patrol is seen moving towards %1",(_waypoint select 0)];
- };
- sleep random(10);
- if (wai_radio_announce) then {
- RemoteMessage = ["radio",_msg];
- publicVariable "RemoteMessage";
- } else {
- [nil,nil,rTitleText,_msg,"PLAIN",10] call RE;
- };
- waitUntil{sleep 1; (_vehicle distance (_waypoint select 1) < 30)};
- _waypoint_prev = (_waypoint select 0);
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement