secondcoming

occupation.sqf

Aug 8th, 2016
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 9.68 KB | None | 0 0
  1. /*
  2.     "Occupation" static mission for Altis, Chernarus, Namalsk and Taviana
  3.     Created by second_coming
  4. */
  5.  
  6. private["_wp","_wp2","_wp3","_pos","_missionName","_msgStart","_msgWIN","_msgLOSE"];
  7.  
  8. // For logging purposes
  9. private _num = DMS_MissionCount;
  10.  
  11.  
  12. // Set mission side (only "bandit" is supported for now)
  13. _side = "bandit";
  14.  
  15. switch (toLower worldName) do
  16. {
  17.     case "chernarus":
  18.     {
  19.         _pos = [3810,8887,0];
  20.         _missionName = "Vybor Occupation";
  21.         _msgStart = ['#FFFF00',"Vybor is under martial law! There are reports they have a large weapon cache..."];
  22.         _msgWIN = ['#0080FF',"Convicts have successfully assaulted the town of Vybor and secured the cache!"];
  23.         _msgLOSE = ['#FF0000',"The troops have left Vybor, taking the cache with them..."];
  24.     };
  25.  
  26.     case "altis":
  27.     {
  28.         _pos = [12571,14337,0];
  29.         _missionName = "Neochori Occupation";
  30.         _msgStart = ['#FFFF00',"Neochori is under martial law! There are reports they have a large weapon cache..."];
  31.         _msgWIN = ['#0080FF',"Convicts have successfully assaulted the town of Neochori and secured the cache!"];
  32.         _msgLOSE = ['#FF0000',"The troops have left Neochori, taking the cache with them..."];
  33.     };
  34.  
  35.     case "taviana":
  36.     {
  37.         _pos = [14000,12220,0];
  38.         _missionName = "Solibor Occupation";
  39.         _msgStart = ['#FFFF00',"Solibor is under martial law! There are reports they have a large weapon cache..."];
  40.         _msgWIN = ['#0080FF',"Convicts have successfully assaulted the town of Solibor and secured the cache!"];
  41.         _msgLOSE = ['#FF0000',"The troops have left Solibor, taking the cache with them..."];
  42.     };
  43.  
  44.     case "namalsk":
  45.     {
  46.         _pos = [3926,7523,0];
  47.         _missionName = "Norinsk Occupation";
  48.         _msgStart = ['#FFFF00',"Norinsk is under martial law! There are reports they have a large weapon cache..."];
  49.         _msgWIN = ['#0080FF',"Convicts have successfully assaulted the town of Norinsk and secured the cache!"];
  50.         _msgLOSE = ['#FF0000',"The troops have left Norinsk, taking the cache with them..."];
  51.     };
  52.  
  53.     case "napf":
  54.     {
  55.         _pos = [3926,7523,0];
  56.         _missionName = "Lenzburg Occupation";
  57.         _msgStart = ['#FFFF00',"Lenzburg is under martial law! There are reports they have a large weapon cache..."];
  58.         _msgWIN = ['#0080FF',"Convicts have successfully assaulted the town of Lenzburg and secured the cache!"];
  59.         _msgLOSE = ['#FF0000',"The troops have left Lenzburg, taking the cache with them..."];
  60.     };
  61.    
  62.     case "tanoa":
  63.     {
  64.         _chance = random 100;
  65.         if(_chance < 40) then
  66.         {
  67.             _pos = [11621,2648.86,0];
  68.             _missionName = "Lijnhaven Occupation";
  69.             _msgStart = ['#FFFF00',"Lijnhaven is under martial law! There are reports they have a large weapon cache..."];
  70.             _msgWIN = ['#0080FF',"Convicts have successfully assaulted the town of Lijnhaven and secured the cache!"];
  71.             _msgLOSE = ['#FF0000',"The troops have left Lijnhaven, taking the cache with them..."];
  72.         }
  73.         else
  74.         {
  75.             _pos = [5850.64,10216.4,0];
  76.             _missionName = "Georgetown Occupation";
  77.             _msgStart = ['#FFFF00',"Georgetown is under martial law! There are reports they have a large weapon cache..."];
  78.             _msgWIN = ['#0080FF',"Convicts have successfully assaulted the town of Georgetown and secured the cache!"];
  79.             _msgLOSE = ['#FF0000',"The troops have left Georgetown, taking the cache with them..."];
  80.         };
  81.     }; 
  82.    
  83.    
  84.    
  85.     default
  86.     {
  87.         diag_log format["DMS ERROR :: Attempting to run occupation with unsupported map: %1",worldName];
  88.     };
  89. };
  90.  
  91. if (isNil "_pos") exitWith {};
  92.  
  93. if ([_pos,DMS_StaticMinPlayerDistance] call DMS_fnc_IsPlayerNearby) exitWith {"delay"};
  94.  
  95. diag_log format["[DMS]: Town Occupation Mission Started (%1)",_missionName];
  96.  
  97.  
  98. // Set general mission difficulty
  99. _difficulty = "hardcore";
  100.  
  101.  
  102. // Create AI
  103. _AICount        = 27;
  104. _group1Count    = ceil(_AICount/3);
  105. _group2Count    = ceil(_AICount/3);
  106. _group3Count    = ceil(_AICount/3);
  107.  
  108. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  109. // Get AI to defend the position
  110. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  111. _group = [_pos, _group1Count, _difficulty, "random", _side] call DMS_fnc_SpawnAIGroup;
  112. [ _group,_pos,_difficulty,"AWARE" ] call DMS_fnc_SetGroupBehavior;
  113.  
  114. _buildings = _pos nearObjects ["building", 75];
  115. {
  116.     _isEnterable = [_x] call BIS_fnc_isBuildingEnterable;
  117.  
  118.     if(_isEnterable) then
  119.     {
  120.         _buildingPositions = [_x, 10] call BIS_fnc_buildingPositions;
  121.         _y = _x;
  122.        
  123.         // Find Highest Point
  124.         _highest = [0,0,0];
  125.         {
  126.             if(_x select 2 > _highest select 2) then
  127.             {
  128.                 _highest = _x;
  129.             };
  130.  
  131.         } foreach _buildingPositions;      
  132.         _wpPosition = _highest;
  133.        
  134.         _i = _buildingPositions find _wpPosition;
  135.         _wp = _group addWaypoint [_wpPosition, 0] ;
  136.         _wp setWaypointBehaviour "AWARE";
  137.         _wp setWaypointCombatMode "RED";
  138.         _wp setWaypointCompletionRadius 1;
  139.         _wp waypointAttachObject _y;
  140.         _wp setwaypointHousePosition _i;
  141.         _wp setWaypointType "SAD";
  142.  
  143.     };
  144. } foreach _buildings;
  145. if(count _buildings > 0 && !isNil "_wp") then
  146. {
  147.     _wp setWaypointType "CYCLE";
  148. };
  149.  
  150.  
  151. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  152. _group2 = [ _pos, _group2Count, _difficulty, "random", _side] call DMS_fnc_SpawnAIGroup;
  153. [ _group2,_pos,_difficulty,"AWARE" ] call DMS_fnc_SetGroupBehavior;
  154.  
  155. _buildings = _pos nearObjects ["building", 150];
  156. {
  157.     _isEnterable = [_x] call BIS_fnc_isBuildingEnterable;
  158.  
  159.     if(_isEnterable) then
  160.     {
  161.         _buildingPositions = [_x, 10] call BIS_fnc_buildingPositions;
  162.         _y = _x;
  163.        
  164.         // Find Highest Point
  165.         _highest = [0,0,0];
  166.         {
  167.             if(_x select 2 > _highest select 2) then
  168.             {
  169.                 _highest = _x;
  170.             };
  171.  
  172.         } foreach _buildingPositions;      
  173.         _wpPosition = _highest;
  174.        
  175.         _i = _buildingPositions find _wpPosition;
  176.         _wp2 = _group2 addWaypoint [_wpPosition, 0] ;
  177.         _wp2 setWaypointBehaviour "AWARE";
  178.         _wp2 setWaypointCombatMode "RED";
  179.         _wp2 setWaypointCompletionRadius 1;
  180.         _wp2 waypointAttachObject _y;
  181.         _wp2 setwaypointHousePosition _i;
  182.         _wp2 setWaypointType "SAD";
  183.  
  184.     };
  185. } foreach _buildings;
  186. if(count _buildings > 0 && !isNil "_wp2") then
  187. {
  188.     _wp2 setWaypointType "CYCLE";
  189. };
  190.  
  191. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  192. _group3 = [_pos, _group3Count, _difficulty, "random", _side] call DMS_fnc_SpawnAIGroup;
  193. [ _group3,_pos,_difficulty,"AWARE" ] call DMS_fnc_SetGroupBehavior;
  194.  
  195. _buildings = _pos nearObjects ["building", 300];
  196. {
  197.     _isEnterable = [_x] call BIS_fnc_isBuildingEnterable;
  198.  
  199.     if(_isEnterable) then
  200.     {
  201.         _buildingPositions = [_x, 10] call BIS_fnc_buildingPositions;
  202.         _y = _x;
  203.        
  204.         // Find Highest Point
  205.         _highest = [0,0,0];
  206.         {
  207.             if(_x select 2 > _highest select 2) then
  208.             {
  209.                 _highest = _x;
  210.             };
  211.  
  212.         } foreach _buildingPositions;      
  213.         _wpPosition = _highest;
  214.        
  215.         _i = _buildingPositions find _wpPosition;
  216.         _wp3 = _group3 addWaypoint [_wpPosition, 0] ;
  217.         _wp3 setWaypointBehaviour "AWARE";
  218.         _wp3 setWaypointCombatMode "RED";
  219.         _wp3 setWaypointCompletionRadius 1;
  220.         _wp3 waypointAttachObject _y;
  221.         _wp3 setwaypointHousePosition _i;
  222.         _wp3 setWaypointType "SAD";
  223.  
  224.     };
  225. } foreach _buildings;
  226. if(count _buildings > 0 && !isNil "_wp2") then
  227. {
  228.     _wp3 setWaypointType "CYCLE";
  229. };
  230.  
  231. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  232.  
  233. // Get the AI to shut the fuck up :)
  234. enableSentences false;
  235. enableRadio false;
  236.  
  237. // Create Crate
  238. _crate = ["I_CargoNet_01_ammo_F",_pos] call DMS_fnc_SpawnCrate;
  239.  
  240.  
  241. // Define mission-spawned AI Units
  242. _missionAIUnits =
  243. [
  244.     [_group,_group2,_group3]
  245. ];
  246.  
  247. // Define the group reinforcements
  248. _groupReinforcementsInfo = [];
  249.  
  250. // Define mission-spawned objects and loot values
  251. _missionObjs =
  252. [
  253.     [_missionAIUnits],          // armed AI vehicle and static gun(s). Note, we don't add the base itself because we don't want to delete it and respawn it if the mission respawns.
  254.     [],
  255.     [[_crate,[30 + (random 20),100 + (random 40),15 + (random 5)]]]         // weapons,items,backpacks
  256. ];
  257.  
  258. // Create Markers
  259. _markers =
  260. [
  261.     _pos,
  262.     _missionName,
  263.     _difficulty
  264. ] call DMS_fnc_CreateMarker;
  265.  
  266. (_markers select 1) setMarkerSize [500,500];
  267.  
  268. // Record time here (for logging purposes, otherwise you could just put "diag_tickTime" into the "DMS_AddMissionToMonitor" parameters directly)
  269. _time = diag_tickTime;
  270.  
  271. // Parse and add mission info to missions monitor
  272. _added =
  273. [
  274.     _pos,
  275.     [
  276.         [
  277.             "kill",
  278.             [_group,_group2,_group3]
  279.         ],
  280.         [
  281.             "playerNear",
  282.             [_pos,100]
  283.         ]
  284.     ],
  285.     _groupReinforcementsInfo,
  286.     [
  287.         _time,
  288.         DMS_StaticMissionTimeOut call DMS_fnc_SelectRandomVal
  289.     ],
  290.     _missionAIUnits,
  291.     _missionObjs,
  292.     [_missionName,_msgWIN,_msgLOSE],
  293.     _markers,
  294.     _side,
  295.     _difficulty,
  296.     [[],[]]
  297. ] call DMS_fnc_AddMissionToMonitor_Static;
  298.  
  299. // Check to see if it was added correctly, otherwise delete the stuff
  300. if !(_added) exitWith
  301. {
  302.     diag_log format ["DMS ERROR :: Attempt to set up mission %1 with invalid parameters for DMS_fnc_AddMissionToMonitor_Static! Deleting mission objects and resetting DMS_MissionCount.",_missionName];
  303.  
  304.     _cleanup = [];
  305.     {
  306.         _cleanup pushBack _x;
  307.     } forEach _missionAIUnits;
  308.  
  309.     _cleanup pushBack ((_missionObjs select 0)+(_missionObjs select 1));
  310.  
  311.     {
  312.         _cleanup pushBack (_x select 0);
  313.     } foreach (_missionObjs select 2);
  314.  
  315.     _cleanup call DMS_fnc_CleanUp;
  316.  
  317.  
  318.     // Delete the markers directly
  319.     {deleteMarker _x;} forEach _markers;
  320.  
  321.  
  322.     // Reset the mission count
  323.     DMS_MissionCount = DMS_MissionCount - 1;
  324. };
  325.  
  326.  
  327. // Notify players
  328. [_missionName,_msgStart] call DMS_fnc_BroadcastMissionStatus;
  329.  
  330. if (DMS_DEBUG) then
  331. {
  332.     (format ["MISSION: (%1) :: Mission #%2 started at %3 with %4 AI units and %5 difficulty at time %6",_missionName,_num,_pos,_AICount,_difficulty,_time]) call DMS_fnc_DebugLog;
  333. };
Add Comment
Please, Sign In to add comment