Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 12.85 KB | None | 0 0
  1. /*
  2.     "The Fortess" static IMS Mission for Chernarus and Chernarusredux
  3.     Created by Steve aka Salutesh
  4.     Last Update: 09.10.2017
  5. */
  6.  
  7. private["_pos","_posStart","_posEnd","_missionName","_msgStart","_msgWIN","_msgLOSE","_questgiver","_difficulty","_AICount","_group1Count","_group2Count","_group3Count","_group4Count","_group5Count","_group1Pos","_group2Pos","_group3Pos","_group4Pos","_group5Pos","_group","_group2","_group3","_group4","_group5","_missionAIUnits","_groupReinforcementsInfo","_missionObjs","_questMarkers","_missionMarkers","_missionSuccessParams","_missionSuccessCode","_added","_scriptObjects","_vehicle","_objectName","_scriptName","_missionObjects","_missionFailParams","_missionFailCode","_onMonitorStart","_onMonitorEnds"];
  8.  
  9. // For logging purposes
  10. private _num = DMS_MissionCount;
  11.  
  12. // Set mission side
  13. _side = "bandit";
  14.  
  15. switch (toLower worldName) do
  16. {
  17.     case "chernarus":
  18.     {
  19.         _pos = [6892.32,11437.6,0];
  20.         _posStart = [7816.74, 11556, 0];
  21.         _posEnd = [7816.74, 11556, 0];
  22.         _missionName = "[Quest] The Fortress";
  23.         _msgStart = ['#FFFF00',"PLACEHOLDER"];
  24.         _msgWIN = ['#0080FF',"The fortress was cleaned by tough survivors!"];
  25.         _msgLOSE = ['#FF0000',"All players died within the mission...sad story.."];
  26.         _questgiver = [] remoteExec ["IMSClient_create_Fortress_Questgiver", 0, true];
  27.     };
  28.     case "chernarusredux":
  29.     {
  30.         _pos = [6892.32,11437.6,0];
  31.         _posStart = [7816.74, 11556, 0];
  32.         _posEnd = [7816.74, 11556, 0];
  33.         _missionName = "[Quest] The Fortress";
  34.         _msgStart = ['#FFFF00',"PLACEHOLDER"];
  35.         _msgWIN = ['#0080FF',"The fortress was cleaned by tough survivors!"];
  36.         _msgLOSE = ['#FF0000',"All players died within the mission...sad story.."];
  37.         _questgiver = [] remoteExec ["IMSClient_create_Fortress_Questgiver", 0, true];
  38.     };
  39.     default
  40.     {
  41.         diag_log format["DMS ERROR :: Attempting to run The Fortress mission with unsupported map: %1",worldName];
  42.     };
  43. };
  44.  
  45. if (isNil "_pos") exitWith {};
  46.  
  47. if ([_pos,DMS_StaticMinPlayerDistance] call DMS_fnc_IsPlayerNearby) exitWith {"delay"};
  48.  
  49. diag_log text "[DMS]: Fortress Mission Started";
  50.  
  51. // Create the script objects
  52. _scriptObjects =
  53. [
  54.     ["Land_Document_01_F", [6908.93, 11429.2, 425.664], [-0.938909, -0.344166, 0], [0, 0, 1], false, "FortressDokuments"],
  55.     ["Exile_Construction_WoodGate_Reinforced_Static", [6928.17, 11355.3, 392.586], [0.825535, -0.564351, 0], [0, 0, 1], true, "FortressMaingate"],
  56.     ["Exile_Construction_WoodGate_Reinforced_Static", [6863.72, 11443.9, 393.951], [0.995577, 0.0939534, 0], [0, 0, 1], true, "FortressCentergate"],
  57.     ["Land_PCSet_01_screen_F", [6852.49, 11396.7, 408.166], [-0.918132, -0.396275, 0], [0, 0, 1], false, "FortressPC"],
  58.     ["Loudspeakers_EP1", [6921.82, 11381.5, 397.512], [-0.847145, 0.531361, 0], [0, 0, 1], true, "FortressSpeaker1"],
  59.     ["Loudspeakers_EP1", [6882.55, 11427.5, 397.272], [0.409335, -0.912384, 0], [0, 0, 1], true, "FortressSpeaker2"],
  60.     ["Loudspeakers_EP1", [6881.16, 11515.7, 395.162], [-0.926281, 0.37587, -0.02693], [-0.0205213, 0.0210444, 0.999568], true, "FortressSpeaker3"],
  61.     ["Exile_Construction_WoodDoor_Reinforced_Static", [6912.84, 11435.4, 405.241], [0.0576511, -0.998337, -0.000576364], [-0.0192847, -0.00169085, 0.999813], true, "FortressTowergate"]
  62. ];
  63.  
  64. {
  65.     _vehicle = (_x select 0) createVehicle (_x select 1);
  66.     _vehicle allowDamage false;
  67.     _vehicle setPosWorld (_x select 1);
  68.     _vehicle setVectorDirAndUp [_x select 2, _x select 3];
  69.     _vehicle enableSimulationGlobal (_x select 4);
  70.     _vehicle setVariable ["ExileIsLocked", -1, true];
  71.     _objectName = _x select 5;
  72.     _scriptName = format ["IMS_ScriptObject_%1",_objectName];
  73.     missionNamespace setVariable [_scriptName, _vehicle, true];
  74. } forEach _scriptObjects;
  75.  
  76. // Set general mission difficulty
  77. _difficulty = "hardcore";
  78.  
  79. // Create AI
  80. _AICount        = 15;
  81. _group1Count    = ceil(_AICount/3);
  82. _group2Count    = ceil(_AICount/3);
  83. _group3Count    = ceil(_AICount/3);
  84. _group4Count    = ceil(_AICount/3);
  85. _group5Count    = ceil(_AICount/3);
  86.  
  87. _group1Pos      = [6910.27,11369.2,0];
  88. _group2Pos      = [6887.8,11496.9,0];
  89. _group3Pos      = [6867.67,11403.4,0];
  90. _group4Pos      = [6891.44,11447.7,0];
  91. _group5Pos      = [6937.96,11348.1,0];
  92.  
  93. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  94. // Get AI to defend the position
  95. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  96. _group = [_group1Pos, _group1Count, _difficulty, "ims", _side] call DMS_fnc_SpawnAIGroup;
  97. [_group, _group1Pos, _difficulty, "SAFE"] call DMS_fnc_SetGroupBehavior;
  98. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  99. _group2 = [_group2Pos, _group2Count, _difficulty, "ims", _side] call DMS_fnc_SpawnAIGroup;
  100. [_group2, _group2Pos, _difficulty, "SAFE"] call DMS_fnc_SetGroupBehavior;
  101. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  102. _group3 = [_group3Pos, _group3Count, _difficulty, "ims", _side] call DMS_fnc_SpawnAIGroup;
  103. [_group3, _group3Pos, _difficulty, "SAFE"] call DMS_fnc_SetGroupBehavior;
  104. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  105. _group4 = [_group4Pos, _group4Count, _difficulty, "ims", _side] call DMS_fnc_SpawnAIGroup;
  106. [_group4, _group4Pos, _difficulty, "SAFE"] call DMS_fnc_SetGroupBehavior;
  107. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  108. _group5 = [_group5Pos, _group5Count, _difficulty, "ims", _side] call DMS_fnc_SpawnAIGroup;
  109. [_group5, _group5Pos, _difficulty, "SAFE"] call DMS_fnc_SetGroupBehavior;
  110. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  111.  
  112. // Get the AI to shut the fuck up :)
  113. enableSentences false;
  114. enableRadio false;
  115.  
  116. // Define mission-spawned AI Units
  117. _missionAIUnits =
  118. [
  119.     [_group,_group2,_group3,_group4,_group5]
  120. ];
  121.  
  122. // Define the group reinforcements
  123. _groupReinforcementsInfo = [];
  124.  
  125. // Define mission-spawned objects and ai units
  126. // Note: We don't add the base itself because we don't want to delete it and respawn it if the mission respawns.
  127. // We just do that for scripted objects, they must be deleted and re-placed to restore their functionality within the mission.
  128. _missionObjs =
  129. [
  130.     [_missionAIUnits],                  // Ai Units and script objects
  131.     [],                                 // No DMS vehicles, we spawn the mission reward with IMS.
  132.     []                                  // No DMS mission create, we spawn the mission reward with IMS.
  133. ];
  134.  
  135. // Create IMS Quest Marker
  136. _questMarkers =
  137. [
  138.     _posStart,                          // ARRAY (positionATL or position2d): Where the marker will be spawned (strict)
  139.     "ExileExpansionQuestIcon",          // STRING: Icon type of the marker. Example: "ExileHeart"
  140.     "Quest",                            // NUMBER: Label to spawn for the marker.
  141.     "The Stranger",                     // STRING: Name to spawn for the marker.
  142.     "Mission_1_1",                      // STRING: Script Name for the Marker.
  143.     false
  144. ] call ExileExpansionClient_gui_createMapMarker;
  145.  
  146. // Create DMS Mission Marker
  147. _missionMarkers =
  148. [
  149.     _pos,
  150.     _missionName,
  151.     _difficulty
  152. ] call DMS_fnc_CreateMarker;
  153.  
  154. (_missionMarkers select 1) setMarkerSize [500,500];
  155.  
  156. ExileExpansionClient_gui_MapMarker_Mission_1_2 = (_missionMarkers select 0);
  157. publicVariable "ExileExpansionClient_gui_MapMarker_Mission_1_2";
  158. // Hide the mission marker
  159. ExileExpansionClient_gui_MapMarker_Mission_1_2 setMarkerAlpha 0;
  160.  
  161. // Record time here (for logging purposes, otherwise you could just put "diag_tickTime" into the "DMS_AddMissionToMonitor" parameters directly)
  162. _time = diag_tickTime;
  163.  
  164. // Mission Success Events
  165. _missionSuccessParams = _posEnd;
  166. _missionSuccessCode =
  167. {
  168.     _eventpos = _x select 0;
  169.     _questUnits = (_eventpos nearEntities ["Exile_Unit_Player", 30]);
  170.     [] remoteExec ["IMS_AE_Toast_4", _questUnits, true];
  171.     [_eventpos] remoteExec ["IMS_Fortress_Completion_ActionScript", 0, true];
  172.    
  173.     // Delete the ims script objects
  174.     _missionObjects = [ExileExpansion_object_interactionUnit_FortressQuestgiver, IMS_ScriptObject_FortressMaingate, IMS_ScriptObject_FortressCentergate, IMS_ScriptObject_FortressDokuments];
  175.     {deleteVehicle _x} forEach _missionObjects;
  176. };
  177.  
  178. // Mission Fail Events
  179. _missionFailParams = [];
  180. _missionFailCode =
  181. {
  182.     // Mission failed so set all mission tasks also to failed..
  183.     _missionTasks =
  184.     [
  185.         ["ExileTask_Chernaurus_Fortress_1", "Failed"],
  186.         ["ExileTask_Chernaurus_Fortress_2", "Failed"],
  187.         ["ExileTask_Chernaurus_Fortress_3", "Failed"],
  188.         ["ExileTask_Chernaurus_Fortress_4", "Failed"],
  189.         ["ExileTask_Chernaurus_Fortress_5", "Failed"]
  190.     ];
  191.     {
  192.         _questName = _x select 0;
  193.         _questState = _x select 1;
  194.         [_questName, _questState] remoteExec ["FHQ_fnc_ttSetTaskState", 0, true];
  195.     } forEach _missionTasks;
  196.    
  197.     // Delete the ims script objects
  198.     _missionObjects = [ExileExpansion_object_interactionUnit_FortressQuestgiver, IMS_ScriptObject_FortressMaingate, IMS_ScriptObject_FortressCentergate, IMS_ScriptObject_FortressDokuments];
  199.     {deleteVehicle _x} forEach _missionObjects;
  200. };
  201.  
  202. // Mission Fail condition
  203. _onMonitorStart =
  204. {
  205.     // Only include the stuff below if you also use the "_onMonitorEnd" parameter for this.
  206.     // and if your parameters are different.
  207.     DMS_ResetMissionTimeoutOnKill_original = DMS_ResetMissionTimeoutOnKill;
  208.     DMS_MissionTimeoutResetFrequency_original = DMS_MissionTimeoutResetFrequency;
  209.     DMS_ResetMissionTimeoutOnKill = false;
  210.     DMS_MissionTimeoutResetFrequency = 0;
  211.    
  212.     // Triger only if the mission has players in -> ExileExpansionClient_MissionUnits_Fortress
  213.     if !(isNil "ExileExpansionClient_MissionUnits_Fortress") then
  214.     {
  215.         // Trigers
  216.         // If all mission players die within the mission execute mission failure - (Trigger)
  217.         if (({(alive _x) and (side _x == independent)}count ExileExpansionClient_MissionUnits_Fortress) < 1) then
  218.         {
  219.             _failTime = 0;
  220.             _completionInfo = [["external", false, true]]; // This ensures that the mission doesn't attain the "success" state.
  221.         };
  222.     };
  223. };
  224.  
  225. _onMonitorEnds =
  226. {
  227.     DMS_ResetMissionTimeoutOnKill = DMS_ResetMissionTimeoutOnKill_original;
  228.     DMS_MissionTimeoutResetFrequency = DMS_MissionTimeoutResetFrequency_original;
  229. };
  230.  
  231. // Parse and add mission info to missions monitor
  232. _added =
  233. [
  234.     _pos,
  235.     [
  236.         [
  237.             "kill",
  238.             [_group, _group2, _group3, _group4, _group5]
  239.         ],
  240.         [
  241.             "playerNear",
  242.             [_posEnd, DMS_playerNearRadius]
  243.         ],
  244.         [
  245.             "external",
  246.             false
  247.         ]
  248.     ],
  249.     _groupReinforcementsInfo,
  250.     [
  251.         _time,
  252.         DMS_StaticMissionTimeOut call DMS_fnc_SelectRandomVal
  253.     ],
  254.     _missionAIUnits,
  255.     _missionObjs,
  256.     [_missionName, _msgWIN, _msgLOSE],
  257.     _missionMarkers,
  258.     _side,
  259.     _difficulty,
  260.     [],
  261.     [
  262.         [
  263.             [                                           // _onSuccessScripts (OPTIONAL): Array of code or string to be executed on mission completion (in addition to regular code). Each element should be an array in the form [_params, _code].
  264.                 _missionSuccessParams,
  265.                 _missionSuccessCode
  266.             ]
  267.         ],
  268.         [
  269.             [
  270.                 _missionFailParams,                     // _onFailScripts (OPTIONAL): Array of code or string to be executed on mission failure (in addition to regular code). Each element should be an array in the form [_params, _code].
  271.                 _missionFailCode
  272.             ]
  273.         ],
  274.         _onMonitorStart,                                // _onMonitorStart (OPTIONAL): Code to run when the monitor starts to check the mission status. The passed parameter (_this) is the mission data array itself.
  275.         _onMonitorEnds                                  // _onMonitorEnd (OPTIONAL): Code to run when the monitor is done with checking the mission status. The passed parameter (_this) is the mission data array itself.
  276.     ]
  277. ] call DMS_fnc_AddMissionToMonitor_Static;
  278.  
  279. // Set puplic var for quest activity tracking
  280. IM_Fortress_QuestActive = false;
  281. publicVariable "IM_Fortress_QuestActive";
  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.     // Add IMS script objects to the cleanup
  294.     _cleanup pushBack (_missionObjs select 1);
  295.  
  296.     _cleanup call DMS_fnc_CleanUp;
  297.  
  298.     // Delete the markers directly
  299.     {deleteMarker _x;} forEach _missionMarkers;
  300.     {deleteMarker _x;} forEach _questMarkers;
  301.    
  302.     // Delete the ims script objects
  303.     _missionObjects = [ExileExpansion_object_interactionUnit_FortressQuestgiver, IMS_ScriptObject_FortressMaingate, IMS_ScriptObject_FortressCentergate, IMS_ScriptObject_FortressDokuments];
  304.     {deleteVehicle _x} forEach _missionObjects;
  305.    
  306.     // Reset the mission count
  307.     DMS_MissionCount = DMS_MissionCount - 1;
  308. };
  309.  
  310. // Notify players
  311. [_missionName, _msgStart] call DMS_fnc_BroadcastMissionStatus;
  312.  
  313. if (DMS_DEBUG) then
  314. {
  315.     (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;
  316. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement