Advertisement
jka249

swoku_tut.sqf

Jun 19th, 2019
658
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 8.81 KB | None | 0 0
  1. /*
  2.     Medical Mission Mission with new difficulty selection system
  3.     Hardcore now gives persistent vehicle
  4.     easy/mod/difficult/hardcore - reworked by [CiC]red_ned http://cic-gaming.co.uk
  5.     based on work by Defent and eraser1
  6. */
  7.  
  8. private ["_num", "_side", "_pos", "_OK", "_difficulty", "_AICount", "_group", "_type", "_launcher", "_staticGuns", "_crate1", "_vehicle", "_pinCode", "_class", "_veh", "_crate_loot_values1", "_missionAIUnits", "_missionObjs", "_msgStart", "_msgWIN", "_msgLOSE", "_missionName", "_markers", "_time", "_added", "_cleanup", "_baseObjs", "_crate_weapons", "_crate_weapon_list", "_crate_items", "_crate_item_list", "_crate_backpacks", "_PossibleDifficulty"];
  9.  
  10. // For logging purposes
  11. _num = DMS_MissionCount;
  12.  
  13.  
  14. // Set mission side (only "bandit" is supported for now)
  15. _side = "bandit";
  16.  
  17.  
  18. // This part is unnecessary, but exists just as an example to format the parameters for "DMS_fnc_MissionParams" if you want to explicitly define the calling parameters for DMS_fnc_FindSafePos.
  19. // It also allows anybody to modify the default calling parameters easily.
  20. if ((isNil "_this") || {_this isEqualTo [] || {!(_this isEqualType [])}}) then
  21. {
  22.     _this =
  23.     [
  24.         [10,DMS_WaterNearBlacklist,DMS_MinSurfaceNormal,DMS_SpawnZoneNearBlacklist,DMS_TraderZoneNearBlacklist,DMS_MissionNearBlacklist,DMS_PlayerNearBlacklist,DMS_TerritoryNearBlacklist,DMS_ThrottleBlacklists],
  25.         [
  26.             []
  27.         ],
  28.         _this
  29.     ];
  30. };
  31.  
  32. // Check calling parameters for manually defined mission position.
  33. // You can define "_extraParams" to specify the vehicle classname to spawn, either as _vehClass or [_vehClass]
  34. _OK = (_this call DMS_fnc_MissionParams) params
  35. [
  36.     ["_pos",[],[[]],[3],[],[],[]],
  37.     ["_extraParams",[]]
  38. ];
  39.  
  40. if !(_OK) exitWith
  41. {
  42.     diag_log format ["DMS ERROR :: Called MISSION paul_cargo_tower.sqf with invalid parameters: %1",_this];
  43. };
  44.  
  45.  
  46. //create possible difficulty add more of one difficulty to weight it towards that
  47. _PossibleDifficulty     =   [
  48.                                 "difficult",
  49.                                 "difficult",
  50.                                 "hardcore"  //1 in 3 chance of being HC (pincoded)
  51.                             ];
  52. //choose difficulty and set value
  53. _difficulty = selectRandom _PossibleDifficulty;
  54.  
  55. switch (_difficulty) do
  56. {
  57.     case "easy":
  58.     {
  59.         _AICount = (8 + (round (random 2)));
  60.         _crate_weapons      = (3 + (round (random 0)));
  61.         _crate_items        = (5 + (round (random 3)));
  62.         _crate_backpacks    = (1 + (round (random 1)));
  63.     };
  64.  
  65.     case "moderate":
  66.     {
  67.         _AICount = (8 + (round (random 2)));
  68.         _crate_weapons      = (10 + (round (random 0)));
  69.         _crate_items        = (10 + (round (random 3)));
  70.         _crate_backpacks    = (3 + (round (random 1)));
  71.     };
  72.  
  73.     case "difficult":
  74.     {
  75.         _AICount = (12 + (round (random 2)));
  76.         _crate_weapons      = (20 + (round (random 5)));
  77.         _crate_items        = (15 + (round (random 0)));
  78.         _crate_backpacks    = (4 + (round (random 1)));
  79.     };
  80.  
  81.     //case "hardcore":
  82.     default
  83.     {
  84.         _AICount = (15 + (round (random 5)));
  85.         _crate_weapons      = (20 + (round (random 5)));
  86.         _crate_items        = (15 + (round (random 5)));
  87.         _crate_backpacks    = (6 + (round (random 1)));
  88.     };
  89. };
  90.  
  91. //_msgStart = ['#FFFF00',format["A field hospital is under attack! Go kill the %1 attackers",_difficulty]];
  92. _msgStart = ['#FFFF00',"Some AI have stolen a tigris go reclaim it!(changeme)"];
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99. _group =
  100.     [
  101.         _pos,                   // Position AI in tent
  102.         _AICount,               // Number of AI
  103.         _difficulty,            // "random","hardcore","difficult","moderate", or "easy"
  104.         "random",               // "random","assault","MG","sniper" or "unarmed" OR [_type,_launcher]
  105.         "bandit"                    // "bandit","hero", etc.
  106. ] call DMS_fnc_SpawnAIGroup;
  107.  
  108. // add static guns
  109. /*_staticGuns =
  110. [
  111.     [
  112.         [(_pos select 0) -3.4916,(_pos select 1) +3.68517,0],
  113.         [(_pos select 0) +3.58349,(_pos select 1) +3.00053,0],
  114.         [(_pos select 0) +11.6072,(_pos select 1) -6.67776,0],
  115.         [(_pos select 0) -9.20683,(_pos select 1) -8.44086,0]
  116.     ],
  117.     _group,
  118.     "assault",
  119.     "static",
  120.     "bandit"
  121. ] call DMS_fnc_SpawnAIStaticMG;
  122. */
  123.  
  124.  
  125. // Create Buildings - use seperate file as found in the mercbase mission
  126. _baseObjs =
  127. [
  128.     "MissionNameChangeMe",
  129.     _pos
  130. ] call DMS_fnc_ImportFromM3E;
  131.  
  132.  
  133. // If hardcore give pincoded vehicle, if not give non persistent
  134. if (_difficulty isEqualTo "hardcore") then {  
  135.                                                 //changeme (hardcore vehicle reward(with pin)
  136.                                                 _pinCode = (1000 +(round (random 8999)));
  137.                                                 _vehicle = ["O_APC_Tracked_02_AA_F",[(_pos select 0) +14.3441,(_pos select 1) +10.8109,0],_pinCode] call DMS_fnc_SpawnPersistentVehicle;
  138.                                                 _msgWIN = ['#0080ff',format ["You have succesfully completed the misson pin code is %1...",_pinCode]];
  139.                                             } else
  140.                                             {
  141.                                                 //changeme (non HC diffculty missions no pin)
  142.                                                 _vehicle = ["O_APC_Tracked_02_AA_F",[(_pos select 0) +14.3441,(_pos select 1) +10.8109,0], "CAN_COLLIDE"] call DMS_fnc_SpawnNonPersistentVehicle;
  143.                                                 _msgWIN = ['#0080ff',"You have succesfully completed the misson!"];
  144.                                             };
  145.  
  146. // Create Crate type
  147. _crate1 = ["Box_NATO_Wps_F",_pos] call DMS_fnc_SpawnCrate;
  148.  
  149.  
  150. // setup crate with items
  151. _crate_loot_values =
  152. [  
  153.     0,  //weapons (disabled) to enable do same as other two
  154.     [1, ChangeME],      // Items Crates (1 = amount / change me = which crate
  155.     [1, ChangeME]       // Same as above but for backpacks
  156. ];
  157.  
  158.  
  159. // Define mission-spawned AI Units
  160. _missionAIUnits =
  161. [
  162.     _group      // We only spawned the single group for this mission
  163. ];
  164.  
  165. // Define mission-spawned objects and loot values
  166. _missionObjs =
  167. [
  168.     _baseObjs,      // armed AI vehicle, base objects, and static guns
  169.     [_vehicle],                         //this is prize vehicle
  170.     [[_crate1,_crate_loot_values]]      //this is prize crate
  171. ];
  172.  
  173. // define start messages in difficulty choice
  174.  
  175. // Define Mission Win message defined in persistent choice
  176.  
  177.  
  178. // Define Mission Lose message
  179. _msgLOSE = ['#FF0000',"Mission failed we will get them next time.(changeme)"];
  180.  
  181. // Define mission name (for map marker and logging)
  182. _missionName = "Stolen Tigris(changeme)";
  183.  
  184. // Create Markers - same for all levels
  185. _markers =
  186. [
  187.     _pos,
  188.     _missionName,
  189.     _difficulty
  190. ] call DMS_fnc_CreateMarker;
  191.  
  192. // Record time here (for logging purposes, otherwise you could just put "diag_tickTime" into the "DMS_AddMissionToMonitor" parameters directly)
  193. _time = diag_tickTime;
  194.  
  195. // Parse and add mission info to missions monitor
  196. _added =
  197. [
  198.     _pos,
  199.     [
  200.         [
  201.             "kill",
  202.             _group
  203.         ],
  204.         [
  205.             "playerNear",
  206.             [_pos,DMS_playerNearRadius]
  207.         ]
  208.     ],
  209.     [
  210.         _time,
  211.         (DMS_MissionTimeOut select 0) + random((DMS_MissionTimeOut select 1) - (DMS_MissionTimeOut select 0))
  212.     ],
  213.     _missionAIUnits,
  214.     _missionObjs,
  215.     [_missionName,_msgWIN,_msgLOSE],
  216.     _markers,
  217.     _side,
  218.     _difficulty,
  219.     []
  220. ] call DMS_fnc_AddMissionToMonitor;
  221.  
  222. // Check to see if it was added correctly, otherwise delete the stuff
  223. if !(_added) exitWith
  224. {
  225.     diag_log format ["DMS ERROR :: Attempt to set up mission %1 with invalid parameters for DMS_AddMissionToMonitor! Deleting mission objects and resetting DMS_MissionCount.",_missionName];
  226.  
  227.     // Delete AI units and the crate. I could do it in one line but I just made a little function that should work for every mission (provided you defined everything correctly)
  228.     _cleanup = [];
  229.     {
  230.         _cleanup pushBack _x;
  231.     } forEach _missionAIUnits;
  232.  
  233.     _cleanup pushBack ((_missionObjs select 0)+(_missionObjs select 1));
  234.  
  235.     {
  236.         _cleanup pushBack (_x select 0);
  237.     } foreach (_missionObjs select 2);
  238.  
  239.     _cleanup call DMS_fnc_CleanUp;
  240.  
  241.  
  242.     // Delete the markers directly
  243.     {deleteMarker _x;} forEach _markers;
  244.  
  245.  
  246.     // Reset the mission count
  247.     DMS_MissionCount = DMS_MissionCount - 1;
  248. };
  249.  
  250.  
  251. // Notify players
  252. [_missionName,_msgStart] call DMS_fnc_BroadcastMissionStatus;
  253.  
  254.  
  255.  
  256. if (DMS_DEBUG) then
  257. {
  258.     (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;
  259. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement