Advertisement
secondcoming

DMS Static Occupation Mission

Mar 13th, 2016
1,947
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 9.14 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.         _pos = [11685,2666,0];
  65.         _missionName = "Lijnhaven Occupation";
  66.         _msgStart = ['#FFFF00',"Lijnhaven is under martial law! There are reports they have a large weapon cache..."];
  67.         _msgWIN = ['#0080FF',"Convicts have successfully assaulted the town of Lijnhaven and secured the cache!"];
  68.         _msgLOSE = ['#FF0000',"The troops have left Lijnhaven, taking the cache with them..."];
  69.     }; 
  70.    
  71.    
  72.    
  73.     default
  74.     {
  75.         diag_log format["DMS ERROR :: Attempting to run occupation with unsupported map: %1",worldName];
  76.     };
  77. };
  78.  
  79. if (isNil "_pos") exitWith {};
  80.  
  81. if ([_pos,DMS_StaticMinPlayerDistance] call DMS_fnc_IsPlayerNearby) exitWith {"delay"};
  82.  
  83. diag_log text "[DMS]: Town Occupation Mission Started";
  84.  
  85.  
  86. // Set general mission difficulty
  87. _difficulty = "hardcore";
  88.  
  89.  
  90. // Create AI
  91. _AICount        = 27;
  92. _group1Count    = ceil(_AICount/3);
  93. _group2Count    = ceil(_AICount/3);
  94. _group3Count    = ceil(_AICount/3);
  95.  
  96. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  97. // Get AI to defend the position
  98. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  99. _group = [_pos, _group1Count, _difficulty, "random", _side] call DMS_fnc_SpawnAIGroup;
  100. [ _group,_pos,_difficulty,"AWARE" ] call DMS_fnc_SetGroupBehavior;
  101.  
  102. _buildings = _pos nearObjects ["building", 75];
  103. {
  104.     _buildingPositions = [_x, 10] call BIS_fnc_buildingPositions;
  105.     if(count _buildingPositions > 0) then
  106.     {
  107.         _y = _x;
  108.         // Find Highest Point
  109.         _highest = [0,0,0];
  110.         {
  111.             if(_x select 2 > _highest select 2) then
  112.             {
  113.                 _highest = _x;
  114.             };
  115.  
  116.         } foreach _buildingPositions;
  117.         _spawnPosition = _highest;
  118.  
  119.         _i = _buildingPositions find _spawnPosition;
  120.         _wp = _group addWaypoint [_spawnPosition,0] ;
  121.         _wp setWaypointFormation "Column";
  122.         _wp setWaypointBehaviour "AWARE";
  123.         _wp setWaypointCombatMode "RED";
  124.         _wp setWaypointCompletionRadius 1;
  125.         _wp waypointAttachObject _y;
  126.         _wp setwaypointHousePosition _i;
  127.         _wp setWaypointType "MOVE";
  128.  
  129.     };
  130.  
  131. } foreach _buildings;
  132. if(count _buildings > 0 ) then
  133. {
  134.     _wp setWaypointType "CYCLE";
  135. };
  136.  
  137.  
  138. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  139. _group2 = [ _pos, _group2Count, _difficulty, "random", _side] call DMS_fnc_SpawnAIGroup;
  140. [ _group2,_pos,_difficulty,"AWARE" ] call DMS_fnc_SetGroupBehavior;
  141.  
  142. _buildings = _pos nearObjects ["building", 150];
  143. {
  144.     _buildingPositions = [_x, 10] call BIS_fnc_buildingPositions;
  145.     if(count _buildingPositions > 0) then
  146.     {
  147.         _y = _x;
  148.         // Find Highest Point
  149.         _highest = [0,0,0];
  150.         {
  151.             if(_x select 2 > _highest select 2) then
  152.             {
  153.                 _highest = _x;
  154.             };
  155.  
  156.         } foreach _buildingPositions;
  157.         _spawnPosition = _highest;
  158.  
  159.         _i = _buildingPositions find _spawnPosition;
  160.         _wp2 = _group2 addWaypoint [_spawnPosition,0] ;
  161.         _wp2 setWaypointFormation "Column";
  162.         _wp2 setWaypointBehaviour "AWARE";
  163.         _wp2 setWaypointCombatMode "RED";
  164.         _wp2 setWaypointCompletionRadius 1;
  165.         _wp2 waypointAttachObject _y;
  166.         _wp2 setwaypointHousePosition _i;
  167.         _wp2 setWaypointType "MOVE";
  168.     };
  169.  
  170. } foreach _buildings;
  171. if(count _buildings > 0 ) then
  172. {
  173.     _wp2 setWaypointType "CYCLE";
  174. };
  175.  
  176. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  177. _group3 = [_pos, _group3Count, _difficulty, "random", _side] call DMS_fnc_SpawnAIGroup;
  178. [ _group3,_pos,_difficulty,"AWARE" ] call DMS_fnc_SetGroupBehavior;
  179.  
  180. _buildings = _pos nearObjects ["building", 300];
  181. {
  182.     _buildingPositions = [_x, 10] call BIS_fnc_buildingPositions;
  183.     if(count _buildingPositions > 0) then
  184.     {
  185.         _y = _x;
  186.         // Find Highest Point
  187.         _highest = [0,0,0];
  188.         {
  189.             if(_x select 2 > _highest select 2) then
  190.             {
  191.                 _highest = _x;
  192.             };
  193.  
  194.         } foreach _buildingPositions;
  195.         _spawnPosition = _highest;
  196.  
  197.         _i = _buildingPositions find _spawnPosition;
  198.         _wp3 = _group2 addWaypoint [_spawnPosition,0] ;
  199.         _wp3 setWaypointFormation "Column";
  200.         _wp3 setWaypointBehaviour "AWARE";
  201.         _wp3 setWaypointCombatMode "RED";
  202.         _wp3 setWaypointCompletionRadius 1;
  203.         _wp3 waypointAttachObject _y;
  204.         _wp3 setwaypointHousePosition _i;
  205.         _wp3 setWaypointType "MOVE";
  206.  
  207.     };
  208.  
  209. } foreach _buildings;
  210. if(count _buildings > 0 ) then
  211. {
  212.     _wp3 setWaypointType "CYCLE";
  213. };
  214.  
  215. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  216.  
  217. // Get the AI to shut the fuck up :)
  218. enableSentences false;
  219. enableRadio false;
  220.  
  221. // Create Crate
  222. _crate = ["I_CargoNet_01_ammo_F",_pos] call DMS_fnc_SpawnCrate;
  223.  
  224.  
  225. // Define mission-spawned AI Units
  226. _missionAIUnits =
  227. [
  228.     [_group,_group2,_group3]
  229. ];
  230.  
  231. // Define the group reinforcements
  232. _groupReinforcementsInfo = [];
  233.  
  234. // Define mission-spawned objects and loot values
  235. _missionObjs =
  236. [
  237.     [_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.
  238.     [],
  239.     [[_crate,[30 + (random 20),100 + (random 40),15 + (random 5)]]]         // weapons,items,backpacks
  240. ];
  241.  
  242. // Create Markers
  243. _markers =
  244. [
  245.     _pos,
  246.     _missionName,
  247.     _difficulty
  248. ] call DMS_fnc_CreateMarker;
  249.  
  250. (_markers select 1) setMarkerSize [500,500];
  251.  
  252. // Record time here (for logging purposes, otherwise you could just put "diag_tickTime" into the "DMS_AddMissionToMonitor" parameters directly)
  253. _time = diag_tickTime;
  254.  
  255. // Parse and add mission info to missions monitor
  256. _added =
  257. [
  258.     _pos,
  259.     [
  260.         [
  261.             "kill",
  262.             [_group,_group2,_group3]
  263.         ],
  264.         [
  265.             "playerNear",
  266.             [_pos,100]
  267.         ]
  268.     ],
  269.     _groupReinforcementsInfo,
  270.     [
  271.         _time,
  272.         DMS_StaticMissionTimeOut call DMS_fnc_SelectRandomVal
  273.     ],
  274.     _missionAIUnits,
  275.     _missionObjs,
  276.     [_missionName,_msgWIN,_msgLOSE],
  277.     _markers,
  278.     _side,
  279.     _difficulty,
  280.     [[],[]]
  281. ] call DMS_fnc_AddMissionToMonitor_Static;
  282.  
  283. // Check to see if it was added correctly, otherwise delete the stuff
  284. if !(_added) exitWith
  285. {
  286.     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];
  287.  
  288.     _cleanup = [];
  289.     {
  290.         _cleanup pushBack _x;
  291.     } forEach _missionAIUnits;
  292.  
  293.     _cleanup pushBack ((_missionObjs select 0)+(_missionObjs select 1));
  294.  
  295.     {
  296.         _cleanup pushBack (_x select 0);
  297.     } foreach (_missionObjs select 2);
  298.  
  299.     _cleanup call DMS_fnc_CleanUp;
  300.  
  301.  
  302.     // Delete the markers directly
  303.     {deleteMarker _x;} forEach _markers;
  304.  
  305.  
  306.     // Reset the mission count
  307.     DMS_MissionCount = DMS_MissionCount - 1;
  308. };
  309.  
  310.  
  311. // Notify players
  312. [_missionName,_msgStart] call DMS_fnc_BroadcastMissionStatus;
  313.  
  314. if (DMS_DEBUG) then
  315. {
  316.     (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;
  317. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement