Advertisement
Guest User

swoku_tut.sqf

a guest
Jun 19th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 7.63 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.     [1, ChangeME],      // amout of objects + which pool to choose from
  154.     [1, ChangeME]       //
  155. ];
  156.  
  157.  
  158. // Define mission-spawned AI Units
  159. _missionAIUnits =
  160. [
  161.     _group      // We only spawned the single group for this mission
  162. ];
  163.  
  164. // Define mission-spawned objects and loot values
  165. _missionObjs =
  166. [
  167.     _baseObjs,      // armed AI vehicle, base objects, and static guns
  168.     [_vehicle],                         //this is prize vehicle
  169.     [[_crate1,_crate_loot_values]]      //this is prize crate
  170. ];
  171.  
  172. // define start messages in difficulty choice
  173.  
  174. // Define Mission Win message defined in persistent choice
  175.  
  176.  
  177. // Define Mission Lose message
  178. _msgLOSE = ['#FF0000',"Mission failed we will get them next time.(changeme)"];
  179.  
  180. // Define mission name (for map marker and logging)
  181. _missionName = "Stolen Tigris(changeme)";
  182.  
  183. // Create Markers - same for all levels
  184. _markers =
  185. [
  186.     _pos,
  187.     _missionName,
  188.     _difficulty
  189. ] call DMS_fnc_CreateMarker;
  190.  
  191. // Record time here (for logging purposes, otherwise you could just put "diag_tickTime" into the "DMS_AddMissionToMonitor" parameters directly)
  192. _time = diag_tickTime;
  193.  
  194. // Parse and add mission info to missions monitor
  195. _added =
  196. [
  197.     _pos,
  198.     [
  199.         [
  200.             "kill",
  201.             _group
  202.         ],
  203.         [
  204.             "playerNear",
  205.             [_pos,DMS_playerNearRadius]
  206.         ]
  207.     ],
  208.     [
  209.         _time,
  210.         (DMS_MissionTimeOut select 0) + random((DMS_MissionTimeOut select 1) - (DMS_MissionTimeOut select 0))
  211.     ],
  212.     _missionAIUnits,
  213.     _missionObjs,
  214.     [_missionName,_msgWIN,_msgLOSE],
  215.     _markers,
  216.     _side,
  217.     _difficulty,
  218.     []
  219. ] call DMS_fnc_AddMissionToMonitor;
  220.  
  221. // Check to see if it was added correctly, otherwise delete the stuff
  222. if !(_added) exitWith
  223. {
  224.     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];
  225.  
  226.     // 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)
  227.     _cleanup = [];
  228.     {
  229.         _cleanup pushBack _x;
  230.     } forEach _missionAIUnits;
  231.  
  232.     _cleanup pushBack ((_missionObjs select 0)+(_missionObjs select 1));
  233.  
  234.     {
  235.         _cleanup pushBack (_x select 0);
  236.     } foreach (_missionObjs select 2);
  237.  
  238.     _cleanup call DMS_fnc_CleanUp;
  239.  
  240.  
  241.     // Delete the markers directly
  242.     {deleteMarker _x;} forEach _markers;
  243.  
  244.  
  245.     // Reset the mission count
  246.     DMS_MissionCount = DMS_MissionCount - 1;
  247. };
  248.  
  249.  
  250. // Notify players
  251. [_missionName,_msgStart] call DMS_fnc_BroadcastMissionStatus;
  252.  
  253.  
  254.  
  255. if (DMS_DEBUG) then
  256. {
  257.     (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;
  258. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement