Advertisement
KRDucky

ConvoyMission

Mar 14th, 2017
598
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 4.87 KB | None | 0 0
  1. // ******************************************************************************************
  2. // * This project is licensed under the GNU Affero GPL v3. Copyright © 2014 A3Wasteland.com *
  3. // ******************************************************************************************
  4. //  @file Version: 2.1
  5. //  @file Name: mission_Convoy.sqf
  6. //  @file Author: JoSchaap / routes by Del1te - (original idea by Sanjo), AgentRev
  7. //  @file Created: 31/08/2013 18:19
  8.  
  9. if (!isServer) exitwith {};
  10. #include "mainMissionDefines.sqf";
  11.  
  12. private ["_convoyVeh", "_veh1", "_veh2", "_veh3", "_createVehicle", "_vehicles", "_leader", "_speedMode", "_waypoint", "_vehicleName", "_numWaypoints", "_box1", "_box2"];
  13.  
  14. _setupVars =
  15. {
  16.     _missionType = "Armed Convoy";
  17.     _locationsArray = LandConvoyPaths;
  18. };
  19.  
  20. _setupObjects =
  21. {
  22.     private ["_starts", "_startDirs", "_waypoints"];
  23.     call compile preprocessFileLineNumbers format ["mapConfig\convoys\%1.sqf", _missionLocation];
  24.  
  25.     // pick the vehicles for the convoy
  26.     _convoyVeh =
  27.     [
  28.         ["B_MRAP_01_hmg_F", "B_Truck_01_covered_F", "B_MRAP_01_hmg_F"],
  29.         ["O_MRAP_02_hmg_F", "O_Truck_03_covered_F", "O_MRAP_02_hmg_F"],
  30.         ["I_MRAP_03_hmg_F", "I_Truck_02_covered_F", "I_MRAP_03_hmg_F"]
  31.     ] call BIS_fnc_selectRandom;
  32.  
  33.     _veh1 = _convoyVeh select 0;
  34.     _veh2 = _convoyVeh select 1;
  35.     _veh3 = _convoyVeh select 2;
  36.  
  37.     _createVehicle =
  38.     {
  39.         private ["_type", "_position", "_direction", "_vehicle", "_soldier"];
  40.  
  41.         _type = _this select 0;
  42.         _position = _this select 1;
  43.         _direction = _this select 2;
  44.  
  45.         _vehicle = createVehicle [_type, _position, [], 0, "None"];
  46.         _vehicle setVariable ["R3F_LOG_disabled", true, true];
  47.         _vehicle setVariable ["A3W_skipAutoSave", true, true];
  48.         [_vehicle] call vehicleSetup;
  49.  
  50.         _vehicle setDir _direction;
  51.         _aiGroup addVehicle _vehicle;
  52.  
  53.         _soldier = [_aiGroup, _position] call createRandomSoldier;
  54.         _soldier moveInDriver _vehicle;
  55.  
  56.         _soldier = [_aiGroup, _position] call createRandomSoldier;
  57.         _soldier moveInCargo [_vehicle, 0];
  58.  
  59.         if !(_type isKindOf "Truck_F") then
  60.         {
  61.             _soldier = [_aiGroup, _position] call createRandomSoldier;
  62.             _soldier moveInGunner _vehicle;
  63.  
  64.             _soldier = [_aiGroup, _position] call createRandomSoldier;
  65.  
  66.             if (_vehicle emptyPositions "commander" > 0) then
  67.             {
  68.                 _soldier moveInCommander _vehicle;
  69.             }
  70.             else
  71.             {
  72.                 _soldier moveInCargo [_vehicle, 1];
  73.             };
  74.         };
  75.  
  76.         [_vehicle, _aiGroup] spawn checkMissionVehicleLock;
  77.  
  78.         _vehicle
  79.     };
  80.  
  81.     _aiGroup = createGroup CIVILIAN;
  82.  
  83.     _vehicles =
  84.     [
  85.         [_veh1, _starts select 0, _startDirs select 0] call _createVehicle,
  86.         [_veh2, _starts select 1, _startDirs select 1] call _createVehicle,
  87.         [_veh3, _starts select 2, _startDirs select 2] call _createVehicle
  88.     ];
  89.  
  90.     _leader = effectiveCommander (_vehicles select 0);
  91.     _aiGroup selectLeader _leader;
  92.  
  93.     _aiGroup setCombatMode "GREEN"; // units will defend themselves
  94.     _aiGroup setBehaviour "SAFE"; // units feel safe until they spot an enemy or get into contact
  95.     _aiGroup setFormation "STAG COLUMN";
  96.  
  97.     _speedMode = if (missionDifficultyHard) then { "NORMAL" } else { "LIMITED" };
  98.  
  99.     _aiGroup setSpeedMode _speedMode;
  100.  
  101.     {
  102.         _waypoint = _aiGroup addWaypoint [_x, 0];
  103.         _waypoint setWaypointType "MOVE";
  104.         _waypoint setWaypointCompletionRadius 25;
  105.         _waypoint setWaypointCombatMode "GREEN";
  106.         _waypoint setWaypointBehaviour "SAFE"; // safe is the best behaviour to make AI follow roads, as soon as they spot an enemy or go into combat they WILL leave the road for cover though!
  107.         _waypoint setWaypointFormation "STAG COLUMN";
  108.         _waypoint setWaypointSpeed _speedMode;
  109.     } forEach _waypoints;
  110.  
  111.     _missionPos = getPosATL leader _aiGroup;
  112.  
  113.     _missionPicture = getText (configFile >> "CfgVehicles" >> _veh2 >> "picture");
  114.     _vehicleName = getText (configFile >> "CfgVehicles" >> _veh2 >> "displayName");
  115.  
  116.     _missionHintText = format ["A <t color='%2'>%1</t> transporting 2 weapon crates is being escorted by armed vehicles. Stop them!", _vehicleName, mainMissionColor];
  117.  
  118.     _numWaypoints = count waypoints _aiGroup;
  119. };
  120.  
  121. _waitUntilMarkerPos = {getPosATL _leader};
  122. _waitUntilExec = nil;
  123. _waitUntilCondition = {currentWaypoint _aiGroup >= _numWaypoints};
  124.  
  125. _failedExec = nil;
  126.  
  127. // _vehicles are automatically deleted or unlocked in missionProcessor depending on the outcome
  128.  
  129. _successExec =
  130. {
  131.     // Mission completed
  132.  
  133.     _box1 = createVehicle ["Box_NATO_Wps_F", _lastPos, [], 2, "None"];
  134.     _box1 setDir random 360;
  135.     //[_box1, "mission_USSpecial"] call fn_refillbox;
  136.     _box1 call randomCrateLoadOut; // new randomCrateLoadOut function call
  137.  
  138.     _box2 = createVehicle ["Box_East_WpsSpecial_F", _lastPos, [], 2, "None"];
  139.     _box2 setDir random 360;
  140.     //[_box2, "mission_USLaunchers"] call fn_refillbox;
  141.   _box2 call randomCrateLoadOut; // new randomCrateLoadOut function call
  142.  
  143.     _successHintMessage = "The convoy has been stopped, the weapon crates and vehicles are now yours to take.";
  144. };
  145.  
  146. _this call mainMissionProcessor;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement