Advertisement
Guest User

Untitled

a guest
Mar 17th, 2015
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.70 KB | None | 0 0
  1. if (isServer) then {
  2.  
  3.  
  4. private["_mission","_vehname","_vehclass","_vehicle","_position","_unitGroup","_waypoint_data","_num_waypoints","_leader","_count_wp","_waypoints","_waypoint_prev","_msg","_wp"];
  5.  
  6.  
  7. _mission = count wai_mission_data -1;
  8.  
  9. //Armed Land Vehicle
  10. _vehclass = armed_vehicle call BIS_fnc_selectRandom;
  11. _vehname = getText (configFile >> "CfgVehicles" >> _vehclass >> "displayName");
  12. _position = [40] call find_position;
  13.  
  14. [_mission,_position,"Medium",format["Disabled %1",_vehname],"MainHero",true] call mission_init;
  15. //Troops
  16. _num = 4 + round (random 3);
  17. [[_position select 0,_position select 1,0],_num,"hard","Random",4,"Random","Bandit","Random","Bandit",_mission] call spawn_group;
  18.  
  19. _waypoint_data = 10; //some
  20. _num_waypoints = 5; //how many waypoints?
  21. _leader = leader _unitGroup;
  22. _count_wp = count _waypoint_data;
  23. _waypoint_prev = "";
  24.  
  25. _vehicle setvehiclelock "UNLOCKED";
  26.  
  27. _unitGroup setBehaviour "COMBAT";
  28. _unitGroup setCombatMode "YELLOW";
  29.  
  30. {
  31.  
  32. if(_leader == _x) then {
  33. _x assignAsDriver _vehicle;
  34. _x action["getInDriver",_vehicle];
  35. diag_log format["WAI: %1 assigned as driver",_x];
  36. } else {
  37.  
  38. if((_vehicle emptyPositions "GUNNER") > 0) then {
  39. _x assignAsGunner _vehicle;
  40. _x moveInGunner _vehicle;
  41.  
  42. diag_log format["WAI: %1 assigned as gunner",_x];
  43. } else {
  44. _x moveInCargo _vehicle;
  45. diag_log format["WAI: %1 assigned as cargo",_x];
  46. };
  47.  
  48. };
  49.  
  50. } forEach units _unitGroup;
  51.  
  52. waitUntil {(_vehicle emptyPositions "DRIVER" == 0)}; // Wait until driver gets inside vehicle
  53.  
  54. diag_log format["WAI: Driver is inside vehicle, continue.."];
  55.  
  56. [_vehicle,_unitGroup] spawn {
  57.  
  58. private["_vehicle","_unitGroup","_runmonitor"];
  59.  
  60. _vehicle = _this select 0;
  61. _unitGroup = _this select 1;
  62. _runmonitor = true;
  63.  
  64. while {(canMove _vehicle && _runmonitor)} do {
  65. if (fuel _vehicle < 0.2) then { _vehicle setfuel 1; };
  66. if (!(alive leader _unitGroup)) then {
  67. diag_log "WAI: Driver was killed, ejecting AI and removing waypoints.";
  68. _runmonitor = false;
  69. };
  70. sleep .5;
  71. };
  72.  
  73. if(_runmonitor) then {
  74. diag_log "WAI: Vehicle became undriveable, ejecting crew.";
  75. };
  76.  
  77. deleteWaypoint [_unitGroup, all];
  78.  
  79. waitUntil { (speed _vehicle < 10) }; // Wait until vehicle slows down before ejecting crew
  80.  
  81. {
  82. _x action ["eject",vehicle _x];
  83. } forEach crew _vehicle;
  84.  
  85. _wp = _unitGroup addWaypoint [(getPos _vehicle),0];
  86. _wp setWaypointType "GUARD";
  87. _wp setWaypointBehaviour "COMBAT";
  88.  
  89. };
  90.  
  91. for "_i" from 1 to _num_waypoints do {
  92.  
  93. _rand_nr = ceil(random((_count_wp - _i)));
  94. _waypoint = (_waypoint_data select _rand_nr);
  95. _waypoint_data set[_rand_nr,-1];
  96. _waypoint_data = _waypoint_data - [-1];
  97.  
  98. _wp = _unitGroup addWaypoint [(_waypoint select 1),0];
  99.  
  100. if(_i == _num_waypoints) then {
  101. _wp setWaypointType "GUARD";
  102. } else {
  103. _wp setWaypointType "MOVE";
  104. };
  105.  
  106. _wp setWaypointBehaviour "CARELESS";
  107. _wp setWaypointCombatMode "YELLOW";
  108.  
  109. if(_waypoint_prev != "") then {
  110. _msg = format["[RADIO] The patrol arrived at %1, heading towards %2",_waypoint_prev,(_waypoint select 0)];
  111. } else {
  112. _msg = format["[RADIO] The patrol is seen moving towards %1",(_waypoint select 0)];
  113. };
  114.  
  115. sleep random(10);
  116.  
  117. if (wai_radio_announce) then {
  118. RemoteMessage = ["radio",_msg];
  119. publicVariable "RemoteMessage";
  120. } else {
  121. [nil,nil,rTitleText,_msg,"PLAIN",10] call RE;
  122. };
  123.  
  124. waitUntil{sleep 1; (_vehicle distance (_waypoint select 1) < 30)};
  125.  
  126. _waypoint_prev = (_waypoint select 0);
  127. };
  128.  
  129. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement