diff --git a/@GMS/addons/custom_server/Compiles/Functions/GMS_fnc_findSafePosn-128.sqf b/@GMS/addons/custom_server/Compiles/Functions/GMS_fnc_findSafePosn-128.sqf new file mode 100644 index 0000000..10fad2c --- /dev/null +++ b/@GMS/addons/custom_server/Compiles/Functions/GMS_fnc_findSafePosn-128.sqf @@ -0,0 +1,210 @@ +/* + + By Ghostrider [GRG] + Copyright 2016 + + -------------------------- + License + -------------------------- + All the code and information provided here is provided under an Attribution Non-Commercial ShareAlike 4.0 Commons License. + + http://creativecommons.org/licenses/by-nc-sa/4.0/ +*/ +#include "\q\addons\custom_server\Configs\blck_defines.hpp"; +/* + Tasks + 1. avoid water (weight 100%, min distance 50 meters). + 2. avoid sites of active heli, UMS or land dynamic missions. (weight sliding down to 50%, min distance 1000 meters). + 3. avoid players and player bases (weight 100%, 1000 meters min distance). + 4. avoid cites and towns (weight 20%, min distance according to settings). + +*/ +private["_findNew","_tries","_coords","_dist","_xpos","_ypos","_newPos","_townPos","_pole","_oldPos","_ignore"]; + +_fnc_getNewPosition = { + //[_centerForSearch,_minDistFromCenter,_maxDistanceFromCenter,_minDistanceFromNearestObj,_waterMode,_maxTerainGradient,_shoreMode] call BIS_fnc_findSafePos + // https://community.bistudio.com/wiki/BIS_fnc_findSafePos + _coords = [blck_mapCenter,0,blck_mapRange,30,0,5,0] call BIS_fnc_findSafePos; + //diag_log format["<<--->> _coords = %1",_coords]; + _coords +}; + +_fnc_excludeBlacklistedLocations = { + private _coords = _this select 0; + private _findNew = false; + { + if ( ((_x select 0) distance2D _coords) < (_x select 1)) exitWith + { + _findNew = true; + }; + } forEach blck_locationBlackList; + _findNew +}; + +_fnc_excludeNearbyMissions = { + private _coords = _this select 0; + private _findNew = false; + { + if ((_x distance2D _coords) < blck_MinDistanceFromMission) then { + _findNew = true; + }; + }forEach DBD_HeliCrashSites; + //diag_log format["#- findSafePosn -# blck_ActiveMissionCoords isEqualTo %1", blck_ActiveMissionCoords]; + { + //diag_log format["#- findSafePosn -# blck_ActiveMissionCoords active mission item is %1", _x]; + if ( (_x distance2D _coords) < blck_MinDistanceFromMission) exitWith + { + _FindNew = true; + }; + } forEach blck_ActiveMissionCoords; + _findNew +}; + +_fnc_excludeRecentMissionCoords = { + private _coords = _this select 0; + private _findNew = false; + { + _ignore = false; + //diag_log format["-# findSafePosn.sqf -# Old Mission element is %1", _x]; + if (diag_tickTime > ((_x select 1) + 1200)) then // if the prior mission was completed more than 20 min ago then delete it from the list and ignore the check for this location. + { + _ignore = true; + blck_recentMissionCoords= blck_recentMissionCoords - _x; + //diag_log format["-# findSafePosn.sqf -# Removing Old Mission element: %1", _x]; + }; + if !(_ignore) then + { + //diag_log format["-# findSafePosn.sqf -# testing _coords against Old Mission coords is %1", _x select 0]; + if ( ((_x select 0) distance2D _coords) < blck_MinDistanceFromMission) then + { + _findNew = true; + //diag_log format["-# findSafePosn.sqf -# Too Close to Old Mission element: %1", _x]; + }; + }; + } forEach blck_recentMissionCoords; + _findNew +}; + +_fnc_excludeSitesAtShore = { + private _coords = _this select 0; + private _findNew = false; + // test for water nearby + _dist = 50; + for [{_i=0}, {_i<360}, {_i=_i+20}] do + { + _xpos = (_coords select 0) + sin (_i) * _dist; + _ypos = (_coords select 1) + cos (_i) * _dist; + _newPos = [_xpos,_ypos,0]; + if (surfaceIsWater _newPos) then + { + _findNew = true; + _i = 361; + }; + }; + _findNew +}; + +_fnc_excludeCitiesAndTowns = { + private _coords = _this select 0; + private _findNew = false; + // check that missions spawn at least 1 kkm from towns + { + _townPos = [((locationPosition _x) select 0), ((locationPosition _x) select 1), 0]; + if (_townPos distance2D _coords < blck_minDistanceFromTowns) exitWith { + _findNew = true; + }; + } forEach blck_townLocations; + _findNew +}; + +_fnc_excludeSpawnsNearPlayers = { + private _coords = _this select 0; + private _findNew = false; + // check to be sure we do not spawn a mission on top of a player. + { + if (isPlayer _x && (_x distance2D _coords) < blck_minDistanceToPlayer) then + { + _findNew = true; + }; + }forEach playableUnits; + _findNew +}; + +_fnc_mapSpecificExclusions = { + private _coords = _this select 0; + private _findNew = false; + if (toLower(worldName) in ["taviana","napf"]) then + { + _tavTest = createVehicle ["SmokeShell",_coords,[], 0, "CAN_COLLIDE"]; + _tavHeight = (getPosASL _tavTest) select 2; + deleteVehicle _tavTest; + if (_tavHeight > 100) then {_FindNew = true;}; + }; + _findNew +}; + +_fnc_excludeSitesNearBases = { + private _coords = _this select 0; + private _findNew = false; + // check for nearby plot pole/freq jammer within 800 meters + _mod = call blck_fnc_getModType; + _pole = ""; + if (_mod isEqualTo "Epoch") then {_pole = "PlotPole_EPOCH"}; + if (_mod isEqualTo "Exile") then {_pole = "Exile_Construction_Flag_Static"}; + //diag_log format["_fnc_findSafePosn:: -- >> _mod = %1 and _pole = %2",_mod,_pole]; + { + if ((_x distance2D _coords) < blck_minDistanceToBases) then + { + _findNew = true; + }; + }forEach nearestObjects[blck_mapCenter, [_pole], blck_minDistanceToBases]; + _findNew +}; + +private _findNew = true; +private _tries = 0; +while {_findNew} do { + _findNew = false; + _coords = call _fnc_getNewPosition; + + _findNew = [_coords] call _fnc_mapSpecificExclusions; + + if !(_findNew) then + { + _findNew [_coords] call _fnc_excludeSitesAtShore; + }; + if !(_findNew) then + { + _findNew = [_coords] call _fnc_excludeBlacklistedLocations; + }; + if !(_findNew) then + { + _findNew = [_coords] call _fnc_excludeNearbyMissions; + }; + if !(_findNew) then + { + _findNew = [_coords] call _fnc_excludeSpawnsNearPlayers; + }; + if !(_findNew) then + { + _findNew = [_coords] call _fnc_excludeSitesNearBases; + }; + if !(_findNew) then + { + + }; + if !(_findNew) then + { + + }; + + _tries = _tries + 1; +}; + +if ((count _coords) > 2) then +{ + private["_temp"]; + _temp = [_coords select 0, _coords select 1]; + _coords = _temp; +}; +_coords; diff --git a/@GMS/addons/custom_server/Compiles/Groups/GMS_fnc_create_AI_Group.sqf b/@GMS/addons/custom_server/Compiles/Groups/GMS_fnc_create_AI_Group.sqf index c5fd62a..64b3d83 100644 --- a/@GMS/addons/custom_server/Compiles/Groups/GMS_fnc_create_AI_Group.sqf +++ b/@GMS/addons/custom_server/Compiles/Groups/GMS_fnc_create_AI_Group.sqf @@ -26,5 +26,8 @@ _groupSpawned setspeedmode "FULL"; _groupSpawned setFormation blck_groupFormation; _groupSpawned setVariable ["blck_group",true,true]; +#ifdef blck_debugMode diag_log format["_fnc_create_AI_Group: _groupSpawned = %1",_groupSpawned]; +#endif + _groupSpawned \ No newline at end of file diff --git a/@GMS/addons/custom_server/Compiles/Groups/GMS_fnc_spawnGroup.sqf b/@GMS/addons/custom_server/Compiles/Groups/GMS_fnc_spawnGroup.sqf index 22538ce..68a34c1 100644 --- a/@GMS/addons/custom_server/Compiles/Groups/GMS_fnc_spawnGroup.sqf +++ b/@GMS/addons/custom_server/Compiles/Groups/GMS_fnc_spawnGroup.sqf @@ -52,7 +52,7 @@ if (blck_debugLevel >= 1) then if !(isNull _groupSpawned) then { - diag_log format["spawnGroup:: group is %1",_groupSpawned]; + //diag_log format["spawnGroup:: group is %1",_groupSpawned]; _useLauncher = blck_useLaunchers; if (_weaponList isEqualTo []) then { diff --git a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_endMission - Copy.sqf b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_endMission - Copy.sqf new file mode 100644 index 0000000..469db4e --- /dev/null +++ b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_endMission - Copy.sqf @@ -0,0 +1,137 @@ +/* + schedules deletion of all remaining alive AI and mission objects. + Updates the mission que. + Updates mission markers. + By Ghostrider GRG + + -------------------------- + License + -------------------------- + All the code and information provided here is provided under an Attribution Non-Commercial ShareAlike 4.0 Commons License. + + http://creativecommons.org/licenses/by-nc-sa/4.0/ +*/ +#include "\q\addons\custom_server\Configs\blck_defines.hpp" +private["_cleanupAliveAITimer","_cleanupCompositionTimer","_isScubaMission"]; + +_fn_missionCleanup = { + params["_mines","_objects","_blck_AllMissionAI","_mission","_cleanupAliveAITimer","_cleanupCompositionTimer",["_isScubaMission",false]]; + [_mines] spawn blck_fnc_clearMines; + //diag_log format["_fnc_endMission: (103) _objects = %1",_objects]; + [_objects, _cleanupCompositionTimer] spawn blck_fnc_addObjToQue; + //diag_log format["_fnc_endMission:: (106) _blck_AllMissionAI = %1",_blck_AllMissionAI]; + [_blck_AllMissionAI, (_cleanupAliveAITimer)] spawn blck_fnc_addLiveAItoQue; + blck_missionsRunning = blck_missionsRunning - 1; + blck_ActiveMissionCoords = blck_ActiveMissionCoords - [ _coords]; + if !(_isScubaMission) then + { + blck_recentMissionCoords pushback [_coords,diag_tickTime]; + [_mission,"inactive",[0,0,0]] call blck_fnc_updateMissionQue; + //diag_log format["_fnc_endMission:: (109) _mission = %1",_mission]; + }; + if (_isScubaMission) then + { + blck_priorDynamicUMS_Missions pushback [_coords,diag_tickTime]; + blck_UMS_ActiveDynamicMissions = blck_UMS_ActiveDynamicMissions - [_coords]; + blck_dynamicUMS_MissionsRuning = blck_dynamicUMS_MissionsRuning - 1; + }; +}; + +/////////////////////////////////////////////////////////////////////// +// MAIN FUNCTION STARTS HERE +////////////////////////////////////////////////////////////////////// + #ifdef blck_debugMode + diag_log format["_fnc_endMission: _this = %1",_this]; + #endif + params["_mines","_objects","_crates","_blck_AllMissionAI","_endMsg","_blck_localMissionMarker","_coords","_mission",["_aborted",false],["_vehicles",[]],["_isScubaMission",false]]; + + #ifdef blck_debugMode + if (blck_debugLevel > 0) then + { + diag_log format["_fnc_endMission: _blck_localMissionMarker %1 | _coords %2 | _mission %3 | _aborted %4",_blck_localMissionMarker,_coords,_mission,_aborted]; + diag_log format["_fnc_endMission: _aborted = %1",_aborted]; + diag_log format["_fnc_endMission: _isScubaMission = %1",_isScubaMission]; + diag_log format["_fnc_endMission: prior to running mission end functions -> blck_missionsRunning = %1 | blck_dynamicUMS_MissionsRuning = %2",blck_missionsRunning,blck_dynamicUMS_MissionsRuning]; + }; + #endif + + if (_aborted > 0) exitWith + { + #ifdef blck_debugMode + if (blck_debugLevel > 0) then { + diag_log format["_fnc_endMission: Mission Aborted, setting all timers to 0"]; + }; + #endif + if (_aborted == 2) then + { + [["abort",_endMsg,_blck_localMissionMarker select 2]] call blck_fnc_messageplayers; + }; + [_blck_localMissionMarker select 0] call blck_fnc_deleteMarker; + _cleanupCompositionTimer = 0; + _cleanupAliveAITimer = 0; + // params["_mines","_objects","_blck_AllMissionAI","_mission","_cleanupAliveAITimer","_cleanupCompositionTimer",["_isScubaMission",false]]; + [_mines,_objects,_blck_AllMissionAI,_mission,_cleanupAliveAITimer,_cleanupCompositionTimer,_isScubaMission] call _fn_missionCleanup; + { + deleteVehicle _x; + }forEach _crates; + { + deleteVehicle _x; + }forEach _vehicles; + }; + if (_aborted == 0) then + { + private["_cleanupAliveAITimer","_cleanupCompositionTimer"]; + if (blck_useSignalEnd) then + { + [_crates select 0] spawn blck_fnc_signalEnd; + { + _x enableRopeAttach true; + }forEach _crates; + #ifdef blck_debugMode + if (blck_debugLevel > 0) then + { + diag_log format["[blckeagls] _fnc_endMission:: (18) SignalEnd called: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; + }; + #endif + }; + #ifdef blck_debugMode + if (blck_debugLevel > 0) then { + diag_log format["_fnc_endMission: Mission Completed without errors, setting all timers to default values"]; + }; + #endif + + _cleanupCompositionTimer = blck_cleanupCompositionTimer; + _cleanupAliveAITimer = blck_AliveAICleanUpTimer; + [["end",_endMsg,_blck_localMissionMarker select 2]] call blck_fnc_messageplayers; + [_blck_localMissionMarker select 0] call blck_fnc_deleteMarker; + [_blck_localMissionMarker select 1, _markerClass] spawn blck_fnc_missionCompleteMarker; + // Using a variable attached to the crate rather than the global setting to be sure we do not fill a crate twice. + // the "lootLoaded" loaded should be set to true by the crate filler script so we can use that for our check. + { + //diag_log format["_fnc_endMission (82): for crate %1 lootLoaded = %2",_x,_x getVariable["lootLoaded",false]]; + if !(_x getVariable["lootLoaded",false]) then + { + // _crateLoot,_lootCounts are defined above and carry the loot table to be used and the number of items of each category to load + [_x,_crateLoot,_lootCounts] call blck_fnc_fillBoxes; + }; + }forEach _crates; + { + private ["_v","_posnVeh"]; + _posnVeh = blck_monitoredVehicles find _x; // returns -1 if the vehicle is not in the array else returns 0-(count blck_monitoredVehicles -1) + if (_posnVeh >= 0) then + { + #ifdef blck_debugMode + diag_log format["_fnc_endMission: setting missionCompleted for vehicle %1 to %2",_x,diag_tickTime]; + #endif + (blck_monitoredVehicles select _posnVeh) setVariable ["missionCompleted", diag_tickTime]; + } else { + _x setVariable ["missionCompleted", diag_tickTime]; + blck_monitoredVehicles pushback _x; + }; + } forEach _vehicles; + [_mines,_objects,_blck_AllMissionAI,_mission,_cleanupAliveAITimer,_cleanupCompositionTimer,_isScubaMission] call _fn_missionCleanup; + }; + #ifdef blck_debugMode + diag_log format["_fnc_endMission: after to running mission end functions -> blck_missionsRunning = %1 | blck_dynamicUMS_MissionsRuning = %2",blck_missionsRunning,blck_dynamicUMS_MissionsRuning]; + #endif + _aborted \ No newline at end of file diff --git a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_fillBoxes.sqf b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_fillBoxes.sqf index 8e714c4..ca62a52 100644 --- a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_fillBoxes.sqf +++ b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_fillBoxes.sqf @@ -23,12 +23,14 @@ #endif _itemCnts params["_wepCnt","_magCnt","_opticsCnt","_materialsCnt","_itemCnt","_bkcPckCnt"]; _tries = [_wepCnt] call blck_fnc_getNumberFromRange; + //diag_log format["_fnc_fillBoxes (26): loading %1 weapons",_wepCnt]; if (_tries > 0) then { _a1 = _boxLoot select 0; // choose the subarray of weapons and corresponding magazines // Add some randomly selected weapons and corresponding magazines for "_i" from 1 to _tries do { _item = selectRandom _a1; + //diag_log format["_fnc_fillBoxes: _item = %1",_item]; if (typeName _item isEqualTo "ARRAY") then // Check whether weapon name is part of an array that might also specify an ammo to use { _crate addWeaponCargoGlobal [_item select 0,1]; // if yes then assume the first element in the array is the weapon name @@ -47,57 +49,102 @@ }; }; _tries = [_magCnt] call blck_fnc_getNumberFromRange; + //diag_log format["_fnc_fillBoxes (26): loading %1 magazines",_magCnt]; if (_tries > 0) then { // Add Magazines, grenades, and 40mm GL shells _a1 = _boxLoot select 1; for "_i" from 1 to _tries do { _item = selectRandom _a1; - _diff = (_item select 2) - (_item select 1); // Take difference between max and min number of items to load and randomize based on this value - _crate addMagazineCargoGlobal [_item select 0, (_item select 1) + round(random(_diff))]; + //diag_log format["_fnc_fillBoxes: _item = %1",_item]; + if (typeName _item isEqualTo "ARRAY") then + { + _diff = (_item select 2) - (_item select 1); // Take difference between max and min number of items to load and randomize based on this value + _crate addMagazineCargoGlobal [_item select 0, (_item select 1) + round(random(_diff))]; + }; + if (typeName _item isEqualTo "STRING") then + { + _crate addMagazineCargoGlobal [_item, 1]; + }; }; }; _tries = [_opticsCnt] call blck_fnc_getNumberFromRange; + //diag_log format["_fnc_fillBoxes (72): loading %1 weapons",_wepCnt]; if (_tries > 0) then { // Add Optics _a1 = _boxLoot select 2; for "_i" from 1 to _tries do { _item = selectRandom _a1; - _diff = (_item select 2) - (_item select 1); - _crate additemCargoGlobal [_item select 0, (_item select 1) + round(random(_diff))]; + //diag_log format["_fnc_fillBoxes: _item = %1",_item]; + if (typeName _item isEqualTo "ARRAY") then + { + _diff = (_item select 2) - (_item select 1); + _crate additemCargoGlobal [_item select 0, (_item select 1) + round(random(_diff))]; + }; + if (typeName _item isEqualTo "STRING") then + { + _crate addItemCargoGlobal [_item,1]; + }; }; }; _tries = [_materialsCnt] call blck_fnc_getNumberFromRange; + //diag_log format["_fnc_fillBoxes (92): loading %1 materials",_materialsCnt]; if (_tries > 0) then { // Add materials (cindar, mortar, electrical parts etc) _a1 = _boxLoot select 3; for "_i" from 1 to _tries do { _item = selectRandom _a1; - _diff = (_item select 2) - (_item select 1); - _crate additemCargoGlobal [_item select 0, (_item select 1) + round(random(_diff))]; + //diag_log format["_fnc_fillBoxes: _item = %1",_item]; + if (typeName _item isEqualTo "ARRAY") then + { + _diff = (_item select 2) - (_item select 1); + _crate additemCargoGlobal [_item select 0, (_item select 1) + round(random(_diff))]; + }; + if (typeName _item isEqualTo "STRING") then + { + _crate addItemCargoGlobal [_item, 1]; + }; }; }; _tries = [_itemCnt] call blck_fnc_getNumberFromRange; + //diag_log format["_fnc_fillBoxes (112): loading %1 items",_itemCnt]; if (_tries > 0) then { // Add Items (first aid kits, multitool bits, vehicle repair kits, food and drinks) _a1 = _boxLoot select 4; for "_i" from 1 to _tries do { _item = selectRandom _a1; - _diff = (_item select 2) - (_item select 1); - _crate additemCargoGlobal [_item select 0, (_item select 1) + round(random(_diff))]; + //diag_log format["_fnc_fillBoxes: _item = %1",_item]; + if (typeName _item isEqualTo "ARRAY") then + { + _diff = (_item select 2) - (_item select 1); + _crate additemCargoGlobal [_item select 0, (_item select 1) + round(random(_diff))]; + }; + if (typeName _item isEqualTo "STRING") then + { + _crate addItemCargoGlobal [_item, 1]; + }; }; }; _tries = [_bkcPckCnt] call blck_fnc_getNumberFromRange; + //diag_log format["_fnc_fillBoxes (132): loading %1 backpacs",_bkcPckCnt]; if (_tries > 0) then { _a1 = _boxLoot select 5; for "_i" from 1 to _tries do { _item = selectRandom _a1; - _diff = (_item select 2) - (_item select 1); - _crate addbackpackcargoGlobal [_item select 0, (_item select 1) + round(random(_diff))]; + diag_log format["_fnc_fillBoxes: _item = %1",_item]; + if (typeName _item isEqualTo "ARRAY") then + { + _diff = (_item select 2) - (_item select 1); + _crate addbackpackcargoGlobal [_item select 0, (_item select 1) + round(random(_diff))]; + }; + if (typeName _item isEqualTo "STRING") then + { + _crate addbackpackcargoGlobal [_item, 1]; + }; }; }; diff --git a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_loadMissionCrate.sqf b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_loadMissionCrate.sqf index 9aa8954..4855358 100644 --- a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_loadMissionCrate.sqf +++ b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_loadMissionCrate.sqf @@ -2,9 +2,9 @@ private _crate = _this select 0; #ifdef blck_debugMode diag_log format["_fnc_loadMisionLootcrate: _this = %1",_this]; -diag_log format["_fnc_loadMisionLootcrate: difficulty = %1", _crate getVariable "lootArray"]; +diag_log format["_fnc_loadMisionLootcrate: difficulty = %1", _crate getVariable "difficulty"]; diag_log format["_fnc_loadMisionLootcrate: lootCounts = %1", _crate getVariable "lootCounts"]; -diag_log format["_fnc_loadMisionLootcrate: lootArray = %1",_crate getVariable "difficulty"]; +diag_log format["_fnc_loadMisionLootcrate: lootArray = %1",_crate getVariable "lootArray"]; #endif [_crate,(_crate getVariable "lootArray"),(_crate getVariable "lootCounts")] call blck_fnc_fillBoxes; [_crate, _crate getVariable "difficulty"] call blck_fnc_addMoneyToObject; diff --git a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_missionSpawner - Copy (4).sqf b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_missionSpawner - Copy (4).sqf new file mode 100644 index 0000000..a8c3e49 --- /dev/null +++ b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_missionSpawner - Copy (4).sqf @@ -0,0 +1,586 @@ +/* + Dynamic Mission Spawner (over-ground missions) + By Ghostrider GRG + Copyright 2016 + + -------------------------- + License + -------------------------- + All the code and information provided here is provided under an Attribution Non-Commercial ShareAlike 4.0 Commons License. + + http://creativecommons.org/licenses/by-nc-sa/4.0/ +*/ +#include "\q\addons\custom_server\Configs\blck_defines.hpp"; +#define delayTime 1 +private ["_abort","_crates","_aiGroup","_objects","_groupPatrolRadius","_missionLandscape","_mines","_blck_AllMissionAI","_blck_localMissionMarker","_assetKilledMsg","_enemyLeaderConfig", + "_AI_Vehicles","_timeOut","_aiDifficultyLevel","_missionPatrolVehicles","_missionGroups","_loadCratesTiming","_spawnCratesTiming","_assetSpawned","_hostageConfig", + "_chanceHeliPatrol","_noPara","_reinforcementLootCounts","_chanceLoot","_heliCrew","_loadCratesTiming","_useMines","_blck_AllMissionAI","_delayTime","_groupPatrolRadius", + "_wait","_missionStartTime","_playerInRange","_missionTimedOut","_temp","_patrolVehicles","_vehToSpawn","_noChoppers","_chancePara","_marker"]; + +params["_coords","_markerClass","_aiDifficultyLevel"]; + +//////// +// set all variables needed for the missions +// data is pulled either from the mission description or from the _mission variable passsed as a parameter +// Deal with situations where some of these variables might not be defined as well. +//////// + +// _mission params["OrangeMarker","orange",blck_TMin_Orange,blck_TMax_Orange]; +//_markerClass = _mission select 0; +// _aiDifficultyLevel = _mission select 1; + +[_markerClass, "active",_coords] call blck_fnc_updateMissionQue; +blck_ActiveMissionCoords pushback _coords; +diag_log format["[blckeagls] missionSpawner (17):: Initializing mission: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; + +if (isNil "_assetKilledMsg") then {_assetKilledMsg = ""}; +if (isNil "_markerColor") then {_markerColor = "ColorBlack"}; +if (isNil "_markerType") then {_markerType = ["mil_box",[]]}; +//if (isNil "_timeOut") then {_timeOut = -1;}; +if (isNil "_spawnCratesTiming") then {_spawnCratesTiming = blck_spawnCratesTiming}; // Choices: "atMissionSpawnGround","atMissionStartAir","atMissionEndGround","atMissionEndAir". +if (isNil "_loadCratesTiming") then {_loadCratesTiming = blck_loadCratesTiming}; // valid choices are "atMissionCompletion" and "atMissionSpawn"; +if (isNil "_missionPatrolVehicles") then {_missionPatrolVehicles = []}; +if (isNil "_missionGroups") then {_missionGroups = []}; +if (isNil "_hostageConfig") then {_hostageConfig = []}; +if (isNil "_enemyLeaderConfig") then {_enemyLeaderConfig = []}; +if (isNil "_useMines") then {_useMines = blck_useMines;}; + +_objects = []; +_mines = []; +_crates = []; +_aiGroup = []; +_missionAIVehicles = []; +_blck_AllMissionAI = []; +_AI_Vehicles = []; +_blck_localMissionMarker = [_markerClass,_coords,"","",_markerColor,_markerType]; +_delayTime = 1; +_groupPatrolRadius = 50; + +if (blck_labelMapMarkers select 0) then +{ + //diag_log "labeling map markers *****"; + _blck_localMissionMarker set [2, _markerMissionName]; +}; +if !(blck_preciseMapMarkers) then +{ + //diag_log "Map marker will be OFFSET from the mission position"; + _blck_localMissionMarker set [1,[_coords,75] call blck_fnc_randomPosition]; +}; +_blck_localMissionMarker set [3,blck_labelMapMarkers select 1]; // Use an arrow labeled with the mission name? +[["start",_startMsg,_markerMissionName]] call blck_fnc_messageplayers; +_marker = [_blck_localMissionMarker] call blck_fnc_spawnMarker; + +#ifdef blck_debugMode +if (blck_debugLevel > 0) then {diag_log "missionSpawner:: (77) message players and spawn a mission marker";}; +if (blck_debugLevel > 0) then {diag_log format["missionSpawner:: (77) _marker = %1",_marker];}; +if (blck_debugLevel > 0) then {diag_log "missionSpawner:: (77) waiting for player to trigger the mission";}; +#endif +//////// +// All parameters are defined, lets wait until a player is nearby or the mission has timed out +//////// + +_missionStartTime = diag_tickTime; +_playerInRange = false; +_missionTimedOut = false; +_wait = true; + +#ifdef blck_debugMode +if (blck_debugLevel > 0) then {diag_log "missionSpawner:: (90) starting mission trigger loop"}; +#endif + +while {_wait} do +{ + #ifdef blck_debugMode + //diag_log "missionSpawner:: top of mission trigger loop"; + if (blck_debugLevel > 2) exitWith {_playerInRange = true;}; + #endif + + if ([_coords, blck_TriggerDistance, false] call blck_fnc_playerInRange) exitWith {_playerInRange = true;}; + if ([_missionStartTime] call blck_fnc_timedOut) exitWith {_missionTimedOut = true;}; + uiSleep 5; + + #ifdef blck_debugMode + if (blck_debugLevel > 2) then + { + diag_log format["missionSpawner:: Trigger Loop - blck_debugLevel = %1 and _coords = %2",blck_debugLevel, _coords]; + diag_log format["missionSpawner:: Trigger Loop - players in range = %1",{isPlayer _x && _x distance2D _coords < blck_TriggerDistance} count allPlayers]; + diag_log format["missionSpawner:: Trigger Loop - timeout = %1", [_missionStartTime] call blck_fnc_timedOut]; + }; + #endif +}; + +if (_missionTimedOut) exitWith +{ + // Deal with the case in which the mission timed out. + blck_recentMissionCoords pushback [_coords,diag_tickTime]; + blck_ActiveMissionCoords = blck_ActiveMissionCoords - [ _coords]; + [_markerClass, "inactive",[0,0,0]] call blck_fnc_updateMissionQue; + blck_missionsRunning = blck_missionsRunning - 1; + [_blck_localMissionMarker select 0] call blck_fnc_deleteMarker; + [_objects, 0.1] spawn blck_fnc_cleanupObjects; + + #ifdef blck_debugMode + if (blck_debugLevel > 0) then + { + diag_log format["[blckeagls] missionSpawner:: (133) Mission Timed Out: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; + }; + #endif +}; + +//////// +// Spawn the mission objects, loot chest, and AI +//////// +#ifdef blck_debugMode +if (blck_debugLevel > 0) then +{ + diag_log format["[blckeagls] missionSpawner:: (142) -- >> Mission tripped: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; +}; +#endif + +if (blck_SmokeAtMissions select 0) then // spawn a fire and smoke near the crate +{ + _temp = [_coords,blck_SmokeAtMissions select 1] call blck_fnc_smokeAtCrates; + if (typeName _temp isEqualTo "ARRAY") then + { + _objects append _temp; + }; +}; + +uiSleep _delayTime; +if (_useMines) then +{ + _mines = [_coords] call blck_fnc_spawnMines; + +}; +uiSleep _delayTime; +_temp = []; + +if (_missionLandscapeMode isEqualTo "random") then +{ + _temp = [_coords,_missionLandscape, 3, 15, 2] call blck_fnc_spawnRandomLandscape; +} else { + params["_center","_objects"]; + _temp = [_coords, _missionLandscape] call blck_fnc_spawnCompositionObjects; +}; +if (typeName _temp isEqualTo "ARRAY") then +{ + _objects append _temp; +}; + +#ifdef blck_debugMode +if (blck_debugLevel > 0) then +{ + diag_log format["[blckeagls] missionSpawner:: (190) Landscape spawned: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; +}; +#endif + +uiSleep _delayTime;; + +_temp = [_coords,_missionLootVehicles] call blck_fnc_spawnMissionLootVehicles; +//uisleep 1; +_crates append _temp; + +uiSleep _delayTime; + +_abort = false; +_temp = [[],[],false]; +_temp = [_coords, _minNoAI,_maxNoAI,_aiDifficultyLevel,_uniforms,_headGear,_missionGroups] call blck_fnc_spawnMissionAI; + +#ifdef blck_debugMode +if (blck_debugLevel > 2) then { + diag_log format["missionSpawner :: (209) blck_fnc_spawnMissionAI returned a value of _temp = %1",_temp]; uiSleep 1; +}; + +_abort = _temp select 1; +if (blck_debugLevel > 2) then { + diag_log format["missionSpawner :: (214) blck_fnc_spawnMissionAI returned a value of _abort = %1",_abort]; uiSleep 1; +}; +#endif + +if (_abort) exitWith +{ + if (blck_debugLevel > 1) then { + diag_log "missionSpawner:: (220) grpNull returned, mission termination criteria met, calling blck_fnc_endMission" + }; + [_mines,_objects,_crates, _blck_AllMissionAI,_endMsg,_blck_localMissionMarker,_coords,_markerClass, 1] call blck_fnc_endMission; +}; +if !(_abort) then +{ + _blck_AllMissionAI append (_temp select 0); +}; + +#ifdef blck_debugMode +if (blck_debugLevel > 0) then +{ + diag_log format["[blckeagls] missionSpawner:: (235) AI Patrols Spawned: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; +}; +#endif + +_assetSpawned = objNull; +if !(_hostageConfig isEqualTo []) then +{ + _assetSpawned = [_coords,_hostageConfig] call blck_fnc_spawnHostage; + //diag_log format["_fnc_missionSpawner: _assetSpawned = %1",_assetSpawned]; + _blck_AllMissionAI pushBack _assetSpawned; +}; + +if !(_enemyLeaderConfig isEqualTo []) then +{ + _assetSpawned = [_coords,_enemyLeaderConfig] call blck_fnc_spawnLeader; + //diag_log format["_fnc_missionSpawner: _assetSpawned = %1",_assetSpawned]; + _blck_AllMissionAI pushBack _assetSpawned; +}; + +uiSleep _delayTime; +_temp = [[],[],false]; +_abort = false; + +_vehToSpawn = [_noVehiclePatrols] call blck_fnc_getNumberFromRange; +if (blck_useVehiclePatrols && ((_vehToSpawn > 0) || count _missionPatrolVehicles > 0)) then +{ + _temp = [_coords,_vehToSpawn,_aiDifficultyLevel,_uniforms,_headGear,_missionPatrolVehicles] call blck_fnc_spawnMissionVehiclePatrols; + + #ifdef blck_debugMode + if (blck_debugLevel > 1) then { + diag_log format["missionSpawner :: (251) blck_fnc_spawnMissionVehiclePatrols returned _temp = %1",_temp]; + }; + #endif + + if (typeName _temp isEqualTo "ARRAY") then + { + _abort = _temp select 2; + }; + if !(_abort) then + { + _patrolVehicles = _temp select 0; + _blck_AllMissionAI append (_temp select 1); + + #ifdef blck_debugMode + if (blck_debugLevel > 0) then + { + diag_log format["[blckeagls] missionSpawner:: (267) Vehicle Patrols Spawned: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; + }; + #endif + + }; +}; + +if (_abort) exitWith +{ + #ifdef blck_debugMode + if (blck_debugLevel > 0) then { + diag_log "missionSpawner:: (279) grpNull returned, mission termination criteria met, calling blck_endMission"; + }; + #endif + + [_mines,_objects,_crates, _blck_AllMissionAI,_endMsg,_blck_localMissionMarker,_coords,_markerClass, 1] call blck_fnc_endMission; +}; + +uiSleep _delayTime; +_temp = [[],[],false]; +_abort = false; + +// Deal with helicopter patrols +_weaponList = [_aiDifficultyLevel] call blck_fnc_selectAILoadout; +_temp = []; + +#ifdef blck_debugMode +if (blck_debugLevel > 1) then +{ + diag_log format["[blckeagls] missionSpawner:: (298) calling in reinforcements: Current mission: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; +}; +#endif + +switch (toLower _aiDifficultyLevel) do +{ + case "blue":{ + _noChoppers = [blck_noPatrolHelisBlue] call blck_fnc_getNumberFromRange; + _chancePara = [blck_chanceParaBlue] call blck_fnc_getNumberFromRange; + }; + case "red":{ + _noChoppers = [blck_noPatrolHelisRed] call blck_fnc_getNumberFromRange; + _chancePara = [blck_chanceParaRed] call blck_fnc_getNumberFromRange; + }; + case "green":{ + _noChoppers = [blck_noPatrolHelisGreen] call blck_fnc_getNumberFromRange; + _chancePara = [blck_chanceParaGreen] call blck_fnc_getNumberFromRange; + }; + case "orange":{ + _noChoppers = [blck_noPatrolHelisOrange] call blck_fnc_getNumberFromRange; + _chancePara = [blck_chanceParaOrange] call blck_fnc_getNumberFromRange; + }; + default { + _chancePara = 0.5; + _noChoppers = 0; + }; +}; +#ifdef blck_debugMode +diag_log format["_missionSpawner(322):: _noChoppers = %1 && _chancePara = %2",_noChoppers,_chancePara]; +#endif +for "_i" from 1 to (_noChoppers) do +{ + _temp = [_coords,_aiDifficultyLevel,_weaponList,_uniforms,_headGear,_chancePara] call blck_fnc_spawnMissionReinforcements; + + #ifdef blck_debugMode + if (blck_debugLevel >= 2) then + { + diag_log format["missionSpawner(334):: blck_fnc_spawnMissionReinforcements call for chopper # %1 out of a total of %2 choppers",_i, _noChoppers]; + diag_log format["missionSpawner(335):: _temp = %1",_temp]; + }; + #endif + + if (typeName _temp isEqualTo "ARRAY") then + { + _abort = _temp select 2; + blck_monitoredVehicles pushBack (_temp select 0); + _blck_AllMissionAI append (_temp select 1); + }; + if (_abort) then + { + #ifdef blck_debugMode + if (blck_debugLevel > 2) then {diag_log "missionSpawner:: (349) grpNul or ERROR in blck_fnc_spawnMissionReinforcements, mission termination criteria met, calling blck_endMission"}; + #endif + _objects pushback (_temp select 0); + [_mines,_objects,_crates, _blck_AllMissionAI,_endMsg,_blck_localMissionMarker,_coords,_markerClass, 1] call blck_fnc_endMission; + }; +}; + +////////////////////////// +// Spawn Crates and Emplaced Weapons Last to try to force them to correct positions relative to spawned buildinga or other objects. +#ifdef blck_debugMode +if (blck_debugLevel > 0) then {diag_log format["missionSpawner:: (361) preparing to spawn emplaced weapons for _coords %4 | _markerClass %3 | blck_useStatic = %1 | _noEmplacedWeapons = %2",blck_useStatic,_noEmplacedWeapons,_markerClass,_coords];}; +#endif +uiSleep 15; +private["_noEmplacedToSpawn"]; +_noEmplacedToSpawn = [_noEmplacedWeapons] call blck_fnc_getNumberFromRange; +if (blck_useStatic && (_noEmplacedToSpawn > 0)) then +{ + _temp = [_missionEmplacedWeapons,_noEmplacedToSpawn,_aiDifficultyLevel,_coords,_uniforms,_headGear] call blck_fnc_spawnEmplacedWeaponArray; + + #ifdef blck_debugMode + if (blck_debugLevel > 2) then {diag_log format ["missionSpawner:: (375) blck_fnc_spawnEmplacedWeaponArray returned _temp = %1",_temp]}; + #endif + + if (typeName _temp isEqualTo "ARRAY") then + { + _abort = _temp select 2; + }; + + #ifdef blck_debugMode + if (blck_debugLevel > 2) then {diag_log format ["missionSpawner:: (387) _abort = %1",_abort]}; + #endif + + if !(_abort) then + { + _objects append (_temp select 0); + _blck_AllMissionAI append (_temp select 1); + + #ifdef blck_debugMode + if (blck_debugLevel > 0) then {diag_log format["[blckeagls] missionSpawner:: (400) Static Weapons Spawned: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]}; + #endif + }; +}; +if (_abort) exitWith +{ + #ifdef blck_debugMode + if (blck_debugLevel > 2) then {diag_log "missionSpawner:: (410) grpNull ERROR in blck_fnc_spawnEmplacedWeaponArray, mission termination criteria met, calling blck_endMission"}; + #endif + [_mines,_objects,_crates, _blck_AllMissionAI,_endMsg,_blck_localMissionMarker,_coords,_markerClass, 1] call blck_fnc_endMission; +}; +#ifdef blck_debugMode +if (blck_debugLevel > 2) then {diag_log format["_fnc_missionSpawner: _spawnCratesTiming = %1", _spawnCratesTiming]}; +#endif +uiSleep _delayTime; +if (_spawnCratesTiming isEqualTo "atMissionSpawnGround") then +{ + if (count _missionLootBoxes > 0) then + { + _crates = [_coords,_missionLootBoxes,_loadCratesTiming, _spawnCratesTiming, "start", _aiDifficultyLevel] call blck_fnc_spawnMissionCrates; + } + else + { + _crates = [_coords,[[selectRandom blck_crateTypes,[0,0,0],_crateLoot,_lootCounts]], _loadCratesTiming, _spawnCratesTiming, "start", _aiDifficultyLevel] call blck_fnc_spawnMissionCrates; + + }; + + if (blck_cleanUpLootChests) then + { + _objects append _crates; + }; + + #ifdef blck_debugMode + if (blck_debugLevel > 0) then + { + diag_log format["[blckeagls] missionSpawner:: (428) Crates Spawned: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; + }; + #endif +}; +// Trigger for mission end + +private["_missionComplete","_endIfPlayerNear","_endIfAIKilled","_secureAsset","_crateStolen","_locations"]; +_missionComplete = -1; +_startTime = diag_tickTime; + +switch (_endCondition) do +{ + case "playerNear": {_secureAsset = false; _endIfPlayerNear = true;_endIfAIKilled = false;}; + case "allUnitsKilled": {_secureAsset = false; _endIfPlayerNear = false;_endIfAIKilled = true;}; + case "allKilledOrPlayerNear": {_secureAsset = false; _endIfPlayerNear = true;_endIfAIKilled = true;}; + case "assetSecured": {_secureAsset = true; _endIfPlayerNear = false; _endIfAIKilled = false;}; +}; + +#ifdef blck_debugMode +if (blck_debugLevel >2) then {diag_log format["_missionSpawner (464): _endCondition = %1",_endCondition]}; +diag_log format["missionSpawner :: (449) _endIfPlayerNear = %1 _endIfAIKilled= %2",_endIfPlayerNear,_endIfAIKilled]; +#endif + +if (blck_showCountAliveAI) then +{ + if !(_marker isEqualTo "") then + { + [_marker,_markerMissionName,_blck_AllMissionAI] call blck_fnc_updateMarkerAliveCount; + blck_missionMarkers pushBack [_marker,_markerMissionName,_blck_AllMissionAI]; + }; +}; + +_crateStolen = false; +_locations = [_coords]; + +{ + _locations pushback (getPos _x); + _x setVariable["crateSpawnPos", (getPos _x)]; +} forEach _crates; + +#ifdef blck_debugMode +diag_log format["missionSpawner (458):: _coords = %1 | _crates = %2 | _locations = %3",_coords,_crates,_locations]; +diag_log format["missionSpawner(462):: Waiting for player to satisfy mission end criteria of _endIfPlayerNear %1 with _endIfAIKilled %2",_endIfPlayerNear,_endIfAIKilled]; +diag_log format["_fnc_missionSpawner(495) starting mission completion loop with _assetSpawned = %1",_assetSpawned]; +#endif + +while {_missionComplete isEqualTo -1} do +{ + //if (blck_debugLevel isEqualTo 3) exitWith {uiSleep 180}; + if (_endIfPlayerNear) then + { + if ([_locations,10,true] call blck_fnc_playerInRangeArray) then {_missionComplete = 1}; + }; + if (_endIfAIKilled) then + { + if (({alive _x} count _blck_AllMissionAI) < 1) then {_missionComplete = 1}; + }; + if (_spawnCratesTiming isEqualTo "atMissionSpawn") then + { + { + if ({[_x] call blck_fnc_crateMoved} count _crates > 0) exitWith + { + _missionComplete = 1; + _crateStolen = true; + }; + }forEach _crates; + }; + if (_secureAsset) then + { + if !(alive _assetSpawned) then + { + _missionComplete = 1 + } else { + if (_assetSpawned getVariable["blck_AIState",0] > 0 && (({alive _x} count _blck_AllMissionAI) isEqualTo 1)) then {_missionComplete = 1}; + }; + }; + uiSleep 2; +}; + +if (_crateStolen) exitWith +{ + diag_log format["missionSpawner:: (491) Crate Stolen Callening _fnc_endMission - > players near = %1 and ai alive = %2 and crates stolen = %3",[_locations,10,true] call blck_fnc_playerInRangeArray, {alive _x} count _blck_AllMissionAI, _crateStolen]; + [_mines,_objects,_crates, _blck_AllMissionAI,"Crate Removed from Mission Site Before Mission Completion: Mission Aborted",_blck_localMissionMarker,_coords,_markerClass, 2] call blck_fnc_endMission; +}; + +if ((_secureAsset) && !(alive _assetSpawned)) exitWith +{ + [_mines,_objects,_crates, _blck_AllMissionAI,_assetKilledMsg,_blck_localMissionMarker,_coords,_markerClass, 2] call blck_fnc_endMission; +}; + +if (_spawnCratesTiming in ["atMissionEndGround","atMissionEndAir"]) then +{ + if (count _missionLootBoxes > 0) then + { + _crates = [_coords,_missionLootBoxes,_loadCratesTiming,_spawnCratesTiming, "end", _aiDifficultyLevel] call blck_fnc_spawnMissionCrates; + } + else + { + _crates = [_coords,[[selectRandom blck_crateTypes,[0,0,0],_crateLoot,_lootCounts]], _loadCratesTiming,_spawnCratesTiming, "end", _aiDifficultyLevel] call blck_fnc_spawnMissionCrates; + }; + + #ifdef blck_debugMode + if (blck_debugLevel > 0) then {diag_log format["_fnc_missionSpawner (531): _crates = %1", _crates]}; + #endif + + if (blck_cleanUpLootChests) then + { + _objects append _crates; + }; + + #ifdef blck_debugMode + if (blck_debugLevel > 0) then {diag_log format["[blckeagls] missionSpawner:: (428) Crates Spawned: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]}; + #endif +}; + +if (_spawnCratesTiming isEqualTo "atMissionSpawnGround" && _loadCratesTiming isEqualTo "atMissionCompletion") then +{ + { + [_x] call blck_fnc_loadMissionCrate; + } forEach _crates; +}; + +#ifdef blck_debugMode +if (blck_debugLevel > 0) then +{ + diag_log format["[blckeagls] missionSpawner:: (496) Mission completion criteria fulfilled: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; + diag_log format["missionSpawner :: (497) _endIfPlayerNear = %1 _endIfAIKilled= %2",_endIfPlayerNear,_endIfAIKilled]; + diag_log format["[blckeagls] missionSpawner:: (498) calling endMission: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; +}; +#endif + +private["_result"]; +// Force passing the mission name for informational purposes. +_blck_localMissionMarker set [2, _markerMissionName]; +if (blck_showCountAliveAI) then +{ + _marker setMarkerText format["%1: All AI Dead",_markerMissionName]; + { + if ((_x select 1) isEqualTo _markerMissionName) exitWith{blck_missionMarkers deleteAt _forEachIndex}; + }forEach blck_missionMarkers; +}; + +diag_log format["_fnc_missionSpawner (557) Build 123: _secureAsset = %1 | {alive _assetSpawned} = %2 | assetType = %3",_secureAsset,alive _assetSpawned, _assetSpawned getVariable["assetType",-1]]; + +if (_assetSpawned getVariable["assetType",0] isEqualTo 1) then +{ + diag_log "Processing Mission End for Hostage Rescue"; + _assetSpawned setCaptive false; + _assetSpawned setVariable["GMSAnimations",{""],true]; + [_assetSpawned,""] remoteExec["switchMove",-2];; + uiSleep 0.1; + _assetSpawned enableAI "ALL"; + private _newPos = (getPos _assetSpawned) getPos [1000, random(360)]; + diag_log format["processing domove for hostage with current pos = %1 and new pos = %2",getPos _assetSpawned, _newPos]; + (group _assetSpawned) setCurrentWaypoint [group _assetSpawned, 0]; + [group _assetSpawned,0] setWaypointPosition [_newPos,0]; + [group _assetSpawned,0] setWaypointType "MOVE"; +}; +if (_assetSpawned getVariable["assetType",0] isEqualTo 2) then +{ + diag_log format["Processing Mission End for Arrest of Leader %1 with endAnimation %2",_assetSpawned,_assetSpawned getVariable["endAnimation",""]]; + [_assetSpawned,""] remoteExec["switchMove",-2]; + _assetSpawned setVariable["GMSAnimations",_assetSpawned getVariable["endAnimation","AidlPercMstpSnonWnonDnon_AI"],true]; + [_assetSpawned,selectRandom(_assetSpawned getVariable["endAnimation","AidlPercMstpSnonWnonDnon_AI"])] remoteExec["switchMove",-2]; +}; + +diag_log format["_fnc_missionSpawner (579) Build 123: _secureAsset = %1 | {alive _assetSpawned} = %2 | assetType = %3",_secureAsset,alive _assetSpawned, _assetSpawned getVariable["assetType",-1]]; + +_result = [_mines,_objects,_crates,_blck_AllMissionAI,_endMsg,_blck_localMissionMarker,_coords,_markerClass, 0] call blck_fnc_endMission; + +#ifdef blck_debugMode +if (blck_debugLevel > 2) then {diag_log format["[blckeagls] missionSpawner:: (507)end of mission: blck_fnc_endMission has returned control to _fnc_missionSpawner"]}; +#endif diff --git a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_missionSpawner - Copy (5).sqf b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_missionSpawner - Copy (5).sqf new file mode 100644 index 0000000..2bc71b1 --- /dev/null +++ b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_missionSpawner - Copy (5).sqf @@ -0,0 +1,633 @@ +/* + Dynamic Mission Spawner (over-ground missions) + By Ghostrider GRG + Copyright 2016 + + -------------------------- + License + -------------------------- + All the code and information provided here is provided under an Attribution Non-Commercial ShareAlike 4.0 Commons License. + + http://creativecommons.org/licenses/by-nc-sa/4.0/ +*/ +#include "\q\addons\custom_server\Configs\blck_defines.hpp"; +#define delayTime 1 +private ["_abort","_crates","_aiGroup","_objects","_groupPatrolRadius","_missionLandscape","_mines","_blck_AllMissionAI","_blck_localMissionMarker","_assetKilledMsg","_enemyLeaderConfig", + "_AI_Vehicles","_timeOut","_aiDifficultyLevel","_missionPatrolVehicles","_missionGroups","_loadCratesTiming","_spawnCratesTiming","_assetSpawned","_hostageConfig", + "_chanceHeliPatrol","_noPara","_chanceLoot","_heliCrew","_loadCratesTiming","_useMines","_blck_AllMissionAI","_delayTime","_groupPatrolRadius", + "_wait","_missionStartTime","_playerInRange","_missionTimedOut","_temp","_patrolVehicles","_vehToSpawn","_noChoppers","_chancePara","_marker"]; + +params["_coords","_markerClass","_aiDifficultyLevel"]; + +//////// +// set all variables needed for the missions +// data is pulled either from the mission description or from the _mission variable passsed as a parameter +// Deal with situations where some of these variables might not be defined as well. +//////// + +// _mission params["OrangeMarker","orange",blck_TMin_Orange,blck_TMax_Orange]; +//_markerClass = _mission select 0; +// _aiDifficultyLevel = _mission select 1; + +[_markerClass, "active",_coords] call blck_fnc_updateMissionQue; +blck_ActiveMissionCoords pushback _coords; +diag_log format["[blckeagls] missionSpawner (17):: Initializing mission: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; + +if (isNil "_assetKilledMsg") then {_assetKilledMsg = ""}; +if (isNil "_markerColor") then {_markerColor = "ColorBlack"}; +if (isNil "_markerType") then {_markerType = ["mil_box",[]]}; +//if (isNil "_timeOut") then {_timeOut = -1;}; +if (isNil "_spawnCratesTiming") then {_spawnCratesTiming = blck_spawnCratesTiming}; // Choices: "atMissionSpawnGround","atMissionStartAir","atMissionEndGround","atMissionEndAir". +if (isNil "_loadCratesTiming") then {_loadCratesTiming = blck_loadCratesTiming}; // valid choices are "atMissionCompletion" and "atMissionSpawn"; +if (isNil "_missionPatrolVehicles") then {_missionPatrolVehicles = []}; +if (isNil "_missionGroups") then {_missionGroups = []}; +if (isNil "_hostageConfig") then {_hostageConfig = []}; +if (isNil "_enemyLeaderConfig") then {_enemyLeaderConfig = []}; +if (isNil "_useMines") then {_useMines = blck_useMines;}; +if (isNil "_weaponList") then {_weaponList = [_aiDifficultyLevel] call blck_fnc_selectAILoadout}; +if (isNil "_sideArms") then {_sideArms = blck_Pistols}; +if (isNil "_vests") then {_vests = blck_vests}; +if (isNil "_backpacks") then {_backpacks = blck_backpacks}; +diag_log format["_fnc_missionSpawner: -> blck_backpacks = %1", blck_backpacks]; +diag_log format["_fnc_missionSpawner: -> _backpacks = %1",_backpacks]; +if (isNil "_uniforms") then {_uniforms = blck_SkinList}; +if (isNil "_headGear") then {_headgear = blck_headgear}; + +if (isNil "_chanceHeliPatrol") then +{ + switch (toLower(_aiDifficultyLevel)) do + { + case "blue": {_chanceHeliPatrol = blck_chanceHeliPatrolBlue}; + case "red": {_chanceHeliPatrol = blck_noPatblck_chanceHeliPatrolRed}; + case "green": {_chanceHeliPatrol = blck_noPatblck_chanceHeliPatrolGreen}; + case "orange": {_chanceHeliPatrol = blck_chanceHeliPatrolOrange}; + default {_chanceHeliPatrol = 0}; + }; +}; +if (isNil "_noChoppers") then +{ + switch (toLower(_aiDifficultyLevel)) do + { + case "blue": {_noChoppers = blck_noPatrolHelisBlue}; + case "red": {_noChoppers = blck_noPatrolHelisRed}; + case "green": {_noChoppers = blck_noPatrolHelisGreen}; + case "orange": {_noChoppers = blck_noPatrolHelisOrange}; + default {_noChoppers = 0}; + }; +}; +if (isNil "_chancePara") then +{ + switch (toLower (_aiDifficultyLevel)) do + { + case "blue": {_chancePara = blck_chanceParaBlue}; + case "red": {_chancePara = blck_chanceParaRed}}; + case "green": {_chancePara = blck_chanceParaGreen}; + case "orange": {_chancePara = blck_chanceParaOrange; + default {_chancePara = 0}; + }; +}; +if (isNil "_missionHelis") then +{ + switch (toLower (_aiDifficultyLevel)) do + { + case "blue": {_missionHelis = blck_patrolHelisBlue}; + case "red": {_missionHelis = blck_patrolHelisRed}; + case "green": {_missionHelis = blck_patrolHelisGreen}; + case "orange": {_missionHelis = blck_patrolHelisOrange}; + default {_missionHelis = blck_patrolHelisBlue}; + }; +}; +if (isNil "_noPara") then +{ + switch (toLower (_aiDifficultyLevel)) do + { + case "blue": {_noPara = blck_noParaBlue}; + case "red": {_noPara = blck_noParaRed}; + case "green": {_noPara = blck_noParaGreen}; + case "orange": {_noPara = blck_noParaOrange}; + default {_noPara = 0}; + }; +}; +if (isNil "_chanceLoot") then {_chanceLoot = 0}; +if (isNil "_paraTriggerDistance") then {_paraTriggerDistance = 400;}; +if (isNil "_paraLoot") then {_paraLoot = blck_BoxLoot_Blue}; +if (isNil "_paraLootCounts") then {_paraLootCounts = blck_lootCountsRed}; + +_objects = []; +_mines = []; +_crates = []; +_aiGroup = []; +_missionAIVehicles = []; +_blck_AllMissionAI = []; +_AI_Vehicles = []; +_blck_localMissionMarker = [_markerClass,_coords,"","",_markerColor,_markerType]; +_delayTime = 1; +_groupPatrolRadius = 50; + +diag_log "_missionSpawner: All variables initialized"; + +if (blck_labelMapMarkers select 0) then +{ + //diag_log "labeling map markers *****"; + _blck_localMissionMarker set [2, _markerMissionName]; +}; +if !(blck_preciseMapMarkers) then +{ + //diag_log "Map marker will be OFFSET from the mission position"; + _blck_localMissionMarker set [1,[_coords,75] call blck_fnc_randomPosition]; +}; +_blck_localMissionMarker set [3,blck_labelMapMarkers select 1]; // Use an arrow labeled with the mission name? +[["start",_startMsg,_markerMissionName]] call blck_fnc_messageplayers; +_marker = [_blck_localMissionMarker] call blck_fnc_spawnMarker; + +#ifdef blck_debugMode +if (blck_debugLevel > 0) then {diag_log "missionSpawner:: (77) message players and spawn a mission marker";}; +if (blck_debugLevel > 0) then {diag_log format["missionSpawner:: (77) _marker = %1",_marker];}; +if (blck_debugLevel > 0) then {diag_log "missionSpawner:: (77) waiting for player to trigger the mission";}; +#endif +//////// +// All parameters are defined, lets wait until a player is nearby or the mission has timed out +//////// + +_missionStartTime = diag_tickTime; +_playerInRange = false; +_missionTimedOut = false; +_wait = true; + +#ifdef blck_debugMode +if (blck_debugLevel > 0) then {diag_log "missionSpawner:: (90) starting mission trigger loop"}; +#endif + +while {_wait} do +{ + #ifdef blck_debugMode + //diag_log "missionSpawner:: top of mission trigger loop"; + if (blck_debugLevel > 2) exitWith {_playerInRange = true;}; + #endif + + if ([_coords, blck_TriggerDistance, false] call blck_fnc_playerInRange) exitWith {_playerInRange = true;}; + if ([_missionStartTime] call blck_fnc_timedOut) exitWith {_missionTimedOut = true;}; + uiSleep 5; + + #ifdef blck_debugMode + if (blck_debugLevel > 2) then + { + diag_log format["missionSpawner:: Trigger Loop - blck_debugLevel = %1 and _coords = %2",blck_debugLevel, _coords]; + diag_log format["missionSpawner:: Trigger Loop - players in range = %1",{isPlayer _x && _x distance2D _coords < blck_TriggerDistance} count allPlayers]; + diag_log format["missionSpawner:: Trigger Loop - timeout = %1", [_missionStartTime] call blck_fnc_timedOut]; + }; + #endif +}; + +if (_missionTimedOut) exitWith +{ + // Deal with the case in which the mission timed out. + blck_recentMissionCoords pushback [_coords,diag_tickTime]; + blck_ActiveMissionCoords = blck_ActiveMissionCoords - [ _coords]; + [_markerClass, "inactive",[0,0,0]] call blck_fnc_updateMissionQue; + blck_missionsRunning = blck_missionsRunning - 1; + [_blck_localMissionMarker select 0] call blck_fnc_deleteMarker; + [_objects, 0.1] spawn blck_fnc_cleanupObjects; +}; + +//////// +// Spawn the mission objects, loot chest, and AI +//////// +#ifdef blck_debugMode +if (blck_debugLevel > 0) then +{ + diag_log format["[blckeagls] missionSpawner:: (142) -- >> Mission tripped: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; +}; +#endif + +if (blck_SmokeAtMissions select 0) then // spawn a fire and smoke near the crate +{ + _temp = [_coords,blck_SmokeAtMissions select 1] call blck_fnc_smokeAtCrates; + if (typeName _temp isEqualTo "ARRAY") then + { + _objects append _temp; + }; +}; + +uiSleep _delayTime; +if (_useMines) then +{ + _mines = [_coords] call blck_fnc_spawnMines; + +}; +uiSleep _delayTime; +_temp = []; + +if (_missionLandscapeMode isEqualTo "random") then +{ + _temp = [_coords,_missionLandscape, 3, 15, 2] call blck_fnc_spawnRandomLandscape; +} else { + params["_center","_objects"]; + _temp = [_coords, _missionLandscape] call blck_fnc_spawnCompositionObjects; +}; +if (typeName _temp isEqualTo "ARRAY") then +{ + _objects append _temp; +}; + +#ifdef blck_debugMode +if (blck_debugLevel > 0) then +{ + diag_log format["[blckeagls] missionSpawner:: (190) Landscape spawned: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; +}; +#endif + +uiSleep _delayTime;; + +_temp = [_coords,_missionLootVehicles] call blck_fnc_spawnMissionLootVehicles; +//uisleep 1; +_crates append _temp; + +uiSleep _delayTime; + +_abort = false; +_temp = [[],[],false]; + +// params["_coords",_minNoAI,_maxNoAI,_missionGroups,_aiDifficultyLevel,_uniforms,_headGear,_vests",_backpacks,_weapons,sideArms,_isScubaGroup]; +#ifdef blck_debugMode +private _params = [_coords,_minNoAI,_maxNoAI,_missionGroups,_aiDifficultyLevel,_uniforms,_headGear,_vests,_backpacks,_weaponList,_sideArms]; +{ + diag_log format["_fnc_missionSpawner: _param %1 label %2 = %3",_forEachIndex, _x, _params select _forEachIndex]; +}forEach ["_coords","_minNoAI","_maxNoAI","_missionGroups","_aiDifficultyLevel","_uniforms","_headgear","_vests","_backpacks","_weaponList","_sideArms"]; +#endif + +_temp = [_coords, _minNoAI,_maxNoAI,_missionGroups,_aiDifficultyLevel,_uniforms,_headGear,_vests,_backpacks,_weaponList,_sideArms] call blck_fnc_spawnMissionAI; + +#ifdef blck_debugMode +if (blck_debugLevel > 2) then { + diag_log format["missionSpawner :: (209) blck_fnc_spawnMissionAI returned a value of _temp = %1",_temp]; uiSleep 1; +}; + +_abort = _temp select 1; +if (blck_debugLevel > 2) then { + diag_log format["missionSpawner :: (214) blck_fnc_spawnMissionAI returned a value of _abort = %1",_abort]; uiSleep 1; +}; +#endif + +if (_abort) exitWith +{ + if (blck_debugLevel > 1) then { + diag_log "missionSpawner:: (220) grpNull returned, mission termination criteria met, calling blck_fnc_endMission" + }; + [_mines,_objects,_crates, _blck_AllMissionAI,_endMsg,_blck_localMissionMarker,_coords,_markerClass, 1] call blck_fnc_endMission; +}; +if !(_abort) then +{ + _blck_AllMissionAI append (_temp select 0); +}; + +#ifdef blck_debugMode +if (blck_debugLevel > 0) then +{ + diag_log format["[blckeagls] missionSpawner:: (235) AI Patrols Spawned: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; +}; +#endif + +_assetSpawned = objNull; +if !(_hostageConfig isEqualTo []) then +{ + _assetSpawned = [_coords,_hostageConfig] call blck_fnc_spawnHostage; + //diag_log format["_fnc_missionSpawner: _assetSpawned = %1",_assetSpawned]; + _blck_AllMissionAI pushBack _assetSpawned; +}; + +if !(_enemyLeaderConfig isEqualTo []) then +{ + _assetSpawned = [_coords,_enemyLeaderConfig] call blck_fnc_spawnLeader; + //diag_log format["_fnc_missionSpawner: _assetSpawned = %1",_assetSpawned]; + _blck_AllMissionAI pushBack _assetSpawned; +}; + +#ifdef blck_debugMode + if (blck_debugLevel >= 1) then { + diag_log format["_fnc_missionSpawner: _assetSpawned = %1",_assetSpawned]; + }; +#endif + +uiSleep _delayTime; +_temp = [[],[],false]; +_abort = false; + +_vehToSpawn = [_noVehiclePatrols] call blck_fnc_getNumberFromRange; +if (blck_useVehiclePatrols && ((_vehToSpawn > 0) || count _missionPatrolVehicles > 0)) then +{ + #define useRelativePos true + //params[_coords,_noVehiclePatrols,_aiDifficultyLevel,_missionPatrolVehicles,_useRelativePos,_uniforms,_headGear,_vests,_backpacks,_weaponList,_sideArms, _isScubaGroup]; + //_temp = [_coords,_vehToSpawn,_aiDifficultyLevel,_uniforms,_headGear,_missionPatrolVehicles] call blck_fnc_spawnMissionVehiclePatrols; + _temp = [_coords,_vehToSpawn,_aiDifficultyLevel,_missionPatrolVehicles,useRelativePos,_uniforms,_headGear,_vests,_backpacks,_weaponList,_sideArms] call blck_fnc_spawnMissionVehiclePatrols; + + if (typeName _temp isEqualTo "ARRAY") then + { + _abort = _temp select 2; + }; + if !(_abort) then + { + _patrolVehicles = _temp select 0; + _blck_AllMissionAI append (_temp select 1); + }; +}; + +if (_abort) exitWith +{ + [_mines,_objects,_crates, _blck_AllMissionAI,_endMsg,_blck_localMissionMarker,_coords,_markerClass, 1] call blck_fnc_endMission; +}; + +uiSleep _delayTime; +_temp = [[],[],false]; +_abort = false; + +// Deal with helicopter patrols +_temp = []; + +#ifdef blck_debugMode +if (blck_debugLevel > 1) then +{ + diag_log format["[blckeagls] missionSpawner:: (298) calling in heli patrol: Current mission: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; +}; +#endif + +_noChoppers = [_noChoppers] call blck_fnc_getNumberFromRange; +//_noPara = [_noPara] call blck_fnc_getNumberFromRange; + +#ifdef blck_debugMode +if (blck_debugLevel > 1) then {diag_log format["_missionSpawner(322):: _noChoppers = %1 && _chancePara = %2",_noChoppers,_chancePara]}; +#endif +if (_noChoppers > 0) then +{ + for "_i" from 1 to (_noChoppers) do + { + if (random(1) < _chanceHeliPatrol) then + { + //_temp = [_coords,_missionHelis,spawnHeli,_aiDifficultyLevel,_chancePara,_noPara,_uniforms,_headGear,_vests,_backpacks,_weaponList,_sideArms] call blck_fnc_spawnMissionReinforcements; + _temp = [_coords,_aiDifficultyLevel,_missionHelis,_uniforms,_headGear,_vests,_backpacks,"none",_weaponList, _sideArms] call blck_fnc_spawnMissionHeli; + + if (typeName _temp isEqualTo "ARRAY") then + { + _abort = _temp select 2; + blck_monitoredVehicles pushBack (_temp select 0); + _blck_AllMissionAI append (_temp select 1); + }; + if (_abort) then + { + _objects pushback (_temp select 0); + [_mines,_objects,_crates, _blck_AllMissionAI,_endMsg,_blck_localMissionMarker,_coords,_markerClass, 1] call blck_fnc_endMission; + }; + }; + }; +}; + + +////////////////////////// +// Spawn Crates and Emplaced Weapons Last to try to force them to correct positions relative to spawned buildinga or other objects. +#ifdef blck_debugMode +if (blck_debugLevel > 0) then {diag_log format["missionSpawner:: (361) preparing to spawn emplaced weapons for _coords %4 | _markerClass %3 | blck_useStatic = %1 | _noEmplacedWeapons = %2",blck_useStatic,_noEmplacedWeapons,_markerClass,_coords];}; +#endif +uiSleep 15; +private["_noEmplacedToSpawn"]; +_noEmplacedToSpawn = [_noEmplacedWeapons] call blck_fnc_getNumberFromRange; +diag_log format["_fnc_missionSpawner: -> _noEmplacedToSpawn = %1 | blck_useStatic = %2",_noEmplacedToSpawn,blck_useStatic]; +if (blck_useStatic && (_noEmplacedToSpawn > 0)) then +{ + // _params = ["_coords","_missionEmplacedWeapons","_useRelativePos","_noEmplacedWeapons","_aiDifficultyLevel","_uniforms","_headGear","_vests","_backpacks","_weaponList","_sideArms"]; + // _temp = [_missionEmplacedWeapons,_noEmplacedToSpawn,_aiDifficultyLevel,_coords,_uniforms,_headGear] call blck_fnc_spawnEmplacedWeaponArray; + _temp = [_coords,_missionEmplacedWeapons,useRelativePos,_noEmplacedToSpawn,_aiDifficultyLevel,_uniforms,_headGear,_vests,_backpacks,_weaponList,_sideArms] call blck_fnc_spawnEmplacedWeaponArray; + + if (typeName _temp isEqualTo "ARRAY") then + { + _abort = _temp select 2; + }; + + if !(_abort) then + { + _objects append (_temp select 0); + _blck_AllMissionAI append (_temp select 1); + }; +}; +if (_abort) exitWith +{ + [_mines,_objects,_crates, _blck_AllMissionAI,_endMsg,_blck_localMissionMarker,_coords,_markerClass, 1] call blck_fnc_endMission; +}; +uiSleep _delayTime; +if (_spawnCratesTiming isEqualTo "atMissionSpawnGround") then +{ + if (count _missionLootBoxes > 0) then + { + _crates = [_coords,_missionLootBoxes,_loadCratesTiming, _spawnCratesTiming, "start", _aiDifficultyLevel] call blck_fnc_spawnMissionCrates; + } + else + { + _crates = [_coords,[[selectRandom blck_crateTypes,[0,0,0],_crateLoot,_lootCounts]], _loadCratesTiming, _spawnCratesTiming, "start", _aiDifficultyLevel] call blck_fnc_spawnMissionCrates; + + }; + + if (blck_cleanUpLootChests) then + { + _objects append _crates; + }; +}; +if (_noPara > 0 && (random(1) < _chancePara) && _paraTriggerDistance == 0) then +{ + diag_log format["_fnc_missionSpawner (435): spawning %1 paraunits at mission spawn",_noPara]; + private _paratroops = [_coords,_noPara,_aiDifficultyLevel,_uniforms,_headGear,_vests,_backpacks,_weaponList,_sideArms] call blck_fnc_spawnParaUnits; + if !(isNull _paratroops) then + { + _blck_AllMissionAI append (units _paratroops); + }; + if (random(1) < _chanceLoot) then + { + private _extraCrates = [_coords,[[selectRandom blck_crateTypes,[0,0,0],_paraLoot,_paraLootCounts]], "atMissionSpawn","atMissionStartAir", "start", _aiDifficultyLevel] call blck_fnc_spawnMissionCrates; + if (blck_cleanUpLootChests) then + { + _objects append _extraCrates; + }; + }; +}; + +// Define Triggers for mission end +private["_missionComplete","_endIfPlayerNear","_endIfAIKilled","_secureAsset","_crateStolen","_locations"]; +_missionComplete = -1; +_startTime = diag_tickTime; + +switch (_endCondition) do +{ + case "playerNear": {_secureAsset = false; _endIfPlayerNear = true;_endIfAIKilled = false;}; + case "allUnitsKilled": {_secureAsset = false; _endIfPlayerNear = false;_endIfAIKilled = true;}; + case "allKilledOrPlayerNear": {_secureAsset = false; _endIfPlayerNear = true;_endIfAIKilled = true;}; + case "assetSecured": {_secureAsset = true; _endIfPlayerNear = false; _endIfAIKilled = false;}; +}; + +if (blck_showCountAliveAI) then +{ + if !(_marker isEqualTo "") then + { + [_marker,_markerMissionName,_blck_AllMissionAI] call blck_fnc_updateMarkerAliveCount; + blck_missionMarkers pushBack [_marker,_markerMissionName,_blck_AllMissionAI]; + }; +}; + +_crateStolen = false; +_locations = [_coords]; +private _spawnPara = if (random(1) < _chancePara) then {true} else {false}; +diag_log format["_fnc_missionSpawner (476): _spawnPara = %1 | _chancePara = %2",_spawnPara,_chancePara]; +{ + _locations pushback (getPos _x); + _x setVariable["crateSpawnPos", (getPos _x)]; +} forEach _crates; + +while {_missionComplete isEqualTo -1} do +{ + if (blck_debugLevel isEqualTo 3) exitWith {uiSleep 180}; + if (_endIfPlayerNear) then + { + if ([_locations,10,true] call blck_fnc_playerInRangeArray) then {_missionComplete = 1}; + }; + if (_endIfAIKilled) then + { + if (({alive _x} count _blck_AllMissionAI) < 1) then {_missionComplete = 1}; + }; + if (_spawnCratesTiming isEqualTo "atMissionSpawn") then + { + { + if ({[_x] call blck_fnc_crateMoved} count _crates > 0) exitWith + { + _missionComplete = 1; + _crateStolen = true; + }; + }forEach _crates; + }; + if (_secureAsset) then + { + if !(alive _assetSpawned) then + { + _missionComplete = 1 + } else { + if (_assetSpawned getVariable["blck_AIState",0] > 0 && (({alive _x} count _blck_AllMissionAI) isEqualTo 1)) then {_missionComplete = 1}; + }; + }; + if (_spawnPara) then + { + + if ([_coords,_paraTriggerDistance,true] call blck_fnc_playerInRange) then + { + _spawnPara = false; // The player gets one try to spawn these. + if (random(1) < _chancePara) then // + { + private _paratroops = [_coords,_noPara,_aiDifficultyLevel,_uniforms,_headGear,_vests,_backpacks,_weaponList,_sideArms] call blck_fnc_spawnParaUnits; + if !(isNull _paratroops) then + { + _blck_AllMissionAI append (units _paratroops); + }; + if (random(1) < _chanceLoot) then + { + private _extraCrates = [_coords,[[selectRandom blck_crateTypes,[0,0,0],_paraLoot,_paraLootCounts]], "atMissionSpawn","atMissionStartAir", "start", _aiDifficultyLevel] call blck_fnc_spawnMissionCrates; + if (blck_cleanUpLootChests) then + { + _objects append _extraCrates; + }; + }; + }; + }; + }; + uiSleep 2; +}; + +if (_crateStolen) exitWith +{ + diag_log format["missionSpawner:: (491) Crate Stolen Callening _fnc_endMission - > players near = %1 and ai alive = %2 and crates stolen = %3",[_locations,10,true] call blck_fnc_playerInRangeArray, {alive _x} count _blck_AllMissionAI, _crateStolen]; + [_mines,_objects,_crates, _blck_AllMissionAI,"Crate Removed from Mission Site Before Mission Completion: Mission Aborted",_blck_localMissionMarker,_coords,_markerClass, 2] call blck_fnc_endMission; +}; + +if ((_secureAsset) && !(alive _assetSpawned)) exitWith +{ + [_mines,_objects,_crates, _blck_AllMissionAI,_assetKilledMsg,_blck_localMissionMarker,_coords,_markerClass, 2] call blck_fnc_endMission; +}; + +if (_spawnCratesTiming in ["atMissionEndGround","atMissionEndAir"]) then +{ + if (count _missionLootBoxes > 0) then + { + _crates = [_coords,_missionLootBoxes,_loadCratesTiming,_spawnCratesTiming, "end", _aiDifficultyLevel] call blck_fnc_spawnMissionCrates; + } + else + { + _crates = [_coords,[[selectRandom blck_crateTypes,[0,0,0],_crateLoot,_lootCounts]], _loadCratesTiming,_spawnCratesTiming, "end", _aiDifficultyLevel] call blck_fnc_spawnMissionCrates; + }; + + #ifdef blck_debugMode + if (blck_debugLevel > 0) then {diag_log format["_fnc_missionSpawner (531): _crates = %1", _crates]}; + #endif + + if (blck_cleanUpLootChests) then + { + _objects append _crates; + }; + + #ifdef blck_debugMode + if (blck_debugLevel > 0) then {diag_log format["[blckeagls] missionSpawner:: (428) Crates Spawned: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]}; + #endif +}; + +if (_spawnCratesTiming isEqualTo "atMissionSpawnGround" && _loadCratesTiming isEqualTo "atMissionCompletion") then +{ + { + [_x] call blck_fnc_loadMissionCrate; + } forEach _crates; +}; + +#ifdef blck_debugMode +if (blck_debugLevel > 0) then +{ + diag_log format["[blckeagls] missionSpawner:: (496) Mission completion criteria fulfilled: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; + diag_log format["missionSpawner :: (497) _endIfPlayerNear = %1 _endIfAIKilled= %2",_endIfPlayerNear,_endIfAIKilled]; + diag_log format["[blckeagls] missionSpawner:: (498) calling endMission: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; +}; +#endif + +private["_result"]; +// Force passing the mission name for informational purposes. +_blck_localMissionMarker set [2, _markerMissionName]; +if (blck_showCountAliveAI) then +{ + _marker setMarkerText format["%1: All AI Dead",_markerMissionName]; + { + if ((_x select 1) isEqualTo _markerMissionName) exitWith{blck_missionMarkers deleteAt _forEachIndex}; + }forEach blck_missionMarkers; +}; + +diag_log format["_fnc_missionSpawner (557) Build 123: _secureAsset = %1 | {alive _assetSpawned} = %2 | assetType = %3",_secureAsset,alive _assetSpawned, _assetSpawned getVariable["assetType",-1]]; + +if (_assetSpawned getVariable["assetType",0] isEqualTo 1) then +{ + diag_log "Processing Mission End for Hostage Rescue"; + _assetSpawned setCaptive false; + _assetSpawned setVariable["GMSAnimations",[""],true]; + [_assetSpawned,""] remoteExec["switchMove",-2];; + uiSleep 0.1; + _assetSpawned enableAI "ALL"; + private _newPos = (getPos _assetSpawned) getPos [1000, random(360)]; + diag_log format["processing domove for hostage with current pos = %1 and new pos = %2",getPos _assetSpawned, _newPos]; + (group _assetSpawned) setCurrentWaypoint [group _assetSpawned, 0]; + [group _assetSpawned,0] setWaypointPosition [_newPos,0]; + [group _assetSpawned,0] setWaypointType "MOVE"; +}; + +if (_assetSpawned getVariable["assetType",0] isEqualTo 2) then +{ + diag_log format["Processing Mission End for Arrest of Leader %1 with endAnimation %2",_assetSpawned,_assetSpawned getVariable["endAnimation",""]]; + [_assetSpawned,""] remoteExec["switchMove",-2]; + _assetSpawned setVariable["GMSAnimations",_assetSpawned getVariable["endAnimation",["AidlPercMstpSnonWnonDnon_AI"]],true]; + [_assetSpawned,selectRandom(_assetSpawned getVariable["endAnimation",["AidlPercMstpSnonWnonDnon_AI"]])] remoteExec["switchMove",-2]; +}; + +diag_log format["_fnc_missionSpawner (579) Build 123: _secureAsset = %1 | {alive _assetSpawned} = %2 | assetType = %3",_secureAsset,alive _assetSpawned, _assetSpawned getVariable["assetType",-1]]; + +_result = [_mines,_objects,_crates,_blck_AllMissionAI,_endMsg,_blck_localMissionMarker,_coords,_markerClass, 0] call blck_fnc_endMission; + +#ifdef blck_debugMode +if (blck_debugLevel > 2) then {diag_log format["[blckeagls] missionSpawner:: (507)end of mission: blck_fnc_endMission has returned control to _fnc_missionSpawner"]}; +#endif diff --git a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_missionSpawner - Copy (6).sqf b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_missionSpawner - Copy (6).sqf new file mode 100644 index 0000000..3be764d --- /dev/null +++ b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_missionSpawner - Copy (6).sqf @@ -0,0 +1,637 @@ +/* + Dynamic Mission Spawner (over-ground missions) + By Ghostrider GRG + Copyright 2016 + + -------------------------- + License + -------------------------- + All the code and information provided here is provided under an Attribution Non-Commercial ShareAlike 4.0 Commons License. + + http://creativecommons.org/licenses/by-nc-sa/4.0/ +*/ +#include "\q\addons\custom_server\Configs\blck_defines.hpp"; +#define delayTime 1 +private ["_abort","_crates","_aiGroup","_objects","_groupPatrolRadius","_missionLandscape","_mines","_blck_AllMissionAI","_blck_localMissionMarker","_assetKilledMsg","_enemyLeaderConfig", + "_AI_Vehicles","_timeOut","_aiDifficultyLevel","_missionPatrolVehicles","_missionGroups","_loadCratesTiming","_spawnCratesTiming","_assetSpawned","_hostageConfig", + "_chanceHeliPatrol","_noPara","_chanceLoot","_heliCrew","_loadCratesTiming","_useMines","_blck_AllMissionAI","_delayTime","_groupPatrolRadius", + "_wait","_missionStartTime","_playerInRange","_missionTimedOut","_temp","_patrolVehicles","_vehToSpawn","_noChoppers","_chancePara","_marker"]; + +params["_coords","_markerClass","_aiDifficultyLevel"]; + +//////// +// set all variables needed for the missions +// data is pulled either from the mission description or from the _mission variable passsed as a parameter +// Deal with situations where some of these variables might not be defined as well. +//////// + +// _mission params["OrangeMarker","orange",blck_TMin_Orange,blck_TMax_Orange]; +//_markerClass = _mission select 0; +// _aiDifficultyLevel = _mission select 1; + +[_markerClass, "active",_coords] call blck_fnc_updateMissionQue; +blck_ActiveMissionCoords pushback _coords; +diag_log format["[blckeagls] missionSpawner (17):: Initializing mission: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; + +if (isNil "_assetKilledMsg") then {_assetKilledMsg = ""}; +if (isNil "_markerColor") then {_markerColor = "ColorBlack"}; +if (isNil "_markerType") then {_markerType = ["mil_box",[]]}; +//if (isNil "_timeOut") then {_timeOut = -1;}; +if (isNil "_endCondition") then {_endCondition = blck_missionEndCondition}; // Options are "allUnitsKilled", "playerNear", "allKilledOrPlayerNear"}; +if (isNil "_spawnCratesTiming") then {_spawnCratesTiming = blck_spawnCratesTiming}; // Choices: "atMissionSpawnGround","atMissionStartAir","atMissionEndGround","atMissionEndAir". +if (isNil "_loadCratesTiming") then {_loadCratesTiming = blck_loadCratesTiming}; // valid choices are "atMissionCompletion" and "atMissionSpawn"; +if (isNil "_missionPatrolVehicles") then {_missionPatrolVehicles = []}; +if (isNil "_missionGroups") then {_missionGroups = []}; +if (isNil "_hostageConfig") then {_hostageConfig = []}; +if (isNil "_enemyLeaderConfig") then {_enemyLeaderConfig = []}; +if (isNil "_useMines") then {_useMines = blck_useMines;}; +if (isNil "_weaponList") then {_weaponList = [_aiDifficultyLevel] call blck_fnc_selectAILoadout}; +if (isNil "_sideArms") then {_sideArms = blck_Pistols}; +if (isNil "_vests") then {_vests = blck_vests}; +if (isNil "_backpacks") then {_backpacks = blck_backpacks}; +//diag_log format["_fnc_missionSpawner: -> blck_backpacks = %1", blck_backpacks]; +//diag_log format["_fnc_missionSpawner: -> _backpacks = %1",_backpacks]; +if (isNil "_uniforms") then {_uniforms = blck_SkinList}; +if (isNil "_headGear") then {_headgear = blck_headgear}; + +if (isNil "_chanceHeliPatrol") then +{ + switch (toLower(_aiDifficultyLevel)) do + { + case "blue": {_chanceHeliPatrol = blck_chanceHeliPatrolBlue}; + case "red": {_chanceHeliPatrol = blck_chanceHeliPatrolRed}; + case "green": {_chanceHeliPatrol = blck_chanceHeliPatrolGreen}; + case "orange": {_chanceHeliPatrol = blck_chanceHeliPatrolOrange}; + default {_chanceHeliPatrol = 0}; + }; +}; +if (isNil "_noChoppers") then +{ + switch (toLower(_aiDifficultyLevel)) do + { + case "blue": {_noChoppers = blck_noPatrolHelisBlue}; + case "red": {_noChoppers = blck_noPatrolHelisRed}; + case "green": {_noChoppers = blck_noPatrolHelisGreen}; + case "orange": {_noChoppers = blck_noPatrolHelisOrange}; + default {_noChoppers = 0}; + }; +}; +if (isNil "_chancePara") then +{ + switch (toLower (_aiDifficultyLevel)) do + { + case "blue": {_chancePara = blck_chanceParaBlue}; + case "red": {_chancePara = blck_chanceParaRed}; + case "green": {_chancePara = blck_chanceParaGreen}; + case "orange": {_chancePara = blck_chanceParaOrange}; + default {_chancePara = 0}; + }; +}; +if (isNil "_missionHelis") then +{ + switch (toLower (_aiDifficultyLevel)) do + { + case "blue": {_missionHelis = blck_patrolHelisBlue}; + case "red": {_missionHelis = blck_patrolHelisRed}; + case "green": {_missionHelis = blck_patrolHelisGreen}; + case "orange": {_missionHelis = blck_patrolHelisOrange}; + default {_missionHelis = blck_patrolHelisBlue}; + }; +}; +if (isNil "_noPara") then +{ + switch (toLower (_aiDifficultyLevel)) do + { + case "blue": {_noPara = blck_noParaBlue}; + case "red": {_noPara = blck_noParaRed}; + case "green": {_noPara = blck_noParaGreen}; + case "orange": {_noPara = blck_noParaOrange}; + default {_noPara = 0}; + }; +}; +if (isNil "_chanceLoot") then {_chanceLoot = 0.5}; +if (isNil "_paraTriggerDistance") then {_paraTriggerDistance = 400;}; +if (isNil "_paraLoot") then {_paraLoot = blck_BoxLoot_Red}; +if (isNil "_paraLootCounts") then {_paraLootCounts = blck_lootCountsRed}; + +_objects = []; +_mines = []; +_crates = []; +_aiGroup = []; +_missionAIVehicles = []; +_blck_AllMissionAI = []; +_AI_Vehicles = []; +_blck_localMissionMarker = [_markerClass,_coords,"","",_markerColor,_markerType]; +#define delayTime 1 +//_groupPatrolRadius = 50; + +#ifdef blck_debugMode +diag_log "_missionSpawner: All variables initialized"; +#endif + +if (blck_labelMapMarkers select 0) then +{ + //diag_log "labeling map markers *****"; + _blck_localMissionMarker set [2, _markerMissionName]; +}; +if !(blck_preciseMapMarkers) then +{ + //diag_log "Map marker will be OFFSET from the mission position"; + _blck_localMissionMarker set [1,[_coords,75] call blck_fnc_randomPosition]; +}; +_blck_localMissionMarker set [3,blck_labelMapMarkers select 1]; // Use an arrow labeled with the mission name? +[["start",_startMsg,_markerMissionName]] call blck_fnc_messageplayers; +_marker = [_blck_localMissionMarker] call blck_fnc_spawnMarker; + +#ifdef blck_debugMode +if (blck_debugLevel > 0) then {diag_log "missionSpawner:: (145) message players and spawn a mission marker";}; +if (blck_debugLevel > 0) then {diag_log format["missionSpawner:: (146) _marker = %1",_marker];}; +if (blck_debugLevel > 0) then {diag_log "missionSpawner:: (147) waiting for player to trigger the mission";}; +#endif +//////// +// All parameters are defined, lets wait until a player is nearby or the mission has timed out +//////// + +_missionStartTime = diag_tickTime; +_playerInRange = false; +_missionTimedOut = false; +_wait = true; + +#ifdef blck_debugMode +if (blck_debugLevel > 0) then {diag_log "missionSpawner:: (90) starting mission trigger loop"}; +#endif + +while {_wait} do +{ + #ifdef blck_debugMode + //diag_log "missionSpawner:: top of mission trigger loop"; + if (blck_debugLevel > 2) exitWith {_playerInRange = true;}; + #endif + + if ([_coords, blck_TriggerDistance, false] call blck_fnc_playerInRange) exitWith {_playerInRange = true;}; + if ([_missionStartTime] call blck_fnc_timedOut) exitWith {_missionTimedOut = true;}; + uiSleep 5; + + #ifdef blck_debugMode + if (blck_debugLevel > 2) then + { + diag_log format["missionSpawner:: Trigger Loop - blck_debugLevel = %1 and _coords = %2",blck_debugLevel, _coords]; + diag_log format["missionSpawner:: Trigger Loop - players in range = %1",{isPlayer _x && _x distance2D _coords < blck_TriggerDistance} count allPlayers]; + diag_log format["missionSpawner:: Trigger Loop - timeout = %1", [_missionStartTime] call blck_fnc_timedOut]; + }; + #endif +}; + +if (_missionTimedOut) exitWith +{ + // Deal with the case in which the mission timed out. + blck_recentMissionCoords pushback [_coords,diag_tickTime]; + blck_ActiveMissionCoords = blck_ActiveMissionCoords - [ _coords]; + [_markerClass, "inactive",[0,0,0]] call blck_fnc_updateMissionQue; + blck_missionsRunning = blck_missionsRunning - 1; + [_blck_localMissionMarker select 0] call blck_fnc_deleteMarker; + [_objects, 0.1] spawn blck_fnc_cleanupObjects; +}; + +//////// +// Spawn the mission objects, loot chest, and AI +//////// +#ifdef blck_debugMode +if (blck_debugLevel > 0) then +{ + diag_log format["[blckeagls] missionSpawner:: (200) -- >> Mission tripped: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; +}; +#endif + +if (blck_SmokeAtMissions select 0) then // spawn a fire and smoke near the crate +{ + _temp = [_coords,blck_SmokeAtMissions select 1] call blck_fnc_smokeAtCrates; + if (typeName _temp isEqualTo "ARRAY") then + { + _objects append _temp; + }; +}; + +uiSleep delayTime; +if (_useMines) then +{ + _mines = [_coords] call blck_fnc_spawnMines; + +}; +uiSleep delayTime; +_temp = []; + +if (_missionLandscapeMode isEqualTo "random") then +{ + _temp = [_coords,_missionLandscape, 3, 15, 2] call blck_fnc_spawnRandomLandscape; +} else { + params["_center","_objects"]; + _temp = [_coords, _missionLandscape] call blck_fnc_spawnCompositionObjects; +}; +if (typeName _temp isEqualTo "ARRAY") then +{ + _objects append _temp; +}; + +#ifdef blck_debugMode +if (blck_debugLevel > 0) then +{ + diag_log format["[blckeagls] missionSpawner:: (237) Landscape spawned: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; +}; +#endif + +uiSleep delayTime;; + +_temp = [_coords,_missionLootVehicles] call blck_fnc_spawnMissionLootVehicles; +//uisleep 1; +_crates append _temp; + +uiSleep delayTime; + +_abort = false; +_temp = [[],[],false]; + +// params["_coords",_minNoAI,_maxNoAI,_missionGroups,_aiDifficultyLevel,_uniforms,_headGear,_vests",_backpacks,_weapons,sideArms,_isScubaGroup]; +#ifdef blck_debugMode +private _params = [_coords,_minNoAI,_maxNoAI,_missionGroups,_aiDifficultyLevel,_uniforms,_headGear,_vests,_backpacks,_weaponList,_sideArms]; +{ + diag_log format["_fnc_missionSpawner: _param %1 label %2 = %3",_forEachIndex, _x, _params select _forEachIndex]; +}forEach ["_coords","_minNoAI","_maxNoAI","_missionGroups","_aiDifficultyLevel","_uniforms","_headgear","_vests","_backpacks","_weaponList","_sideArms"]; +#endif + +_temp = [_coords, _minNoAI,_maxNoAI,_missionGroups,_aiDifficultyLevel,_uniforms,_headGear,_vests,_backpacks,_weaponList,_sideArms] call blck_fnc_spawnMissionAI; + +#ifdef blck_debugMode +if (blck_debugLevel > 2) then { + diag_log format["missionSpawner :: (264) blck_fnc_spawnMissionAI returned a value of _temp = %1",_temp]; uiSleep 1; +}; + +_abort = _temp select 1; +if (blck_debugLevel > 2) then { + diag_log format["missionSpawner :: (269) blck_fnc_spawnMissionAI returned a value of _abort = %1",_abort]; uiSleep 1; +}; +#endif + +if (_abort) exitWith +{ + if (blck_debugLevel > 1) then { + diag_log "missionSpawner:: (277) grpNull returned, mission termination criteria met, calling blck_fnc_endMission" + }; + [_mines,_objects,_crates, _blck_AllMissionAI,_endMsg,_blck_localMissionMarker,_coords,_markerClass, 1] call blck_fnc_endMission; +}; +if !(_abort) then +{ + _blck_AllMissionAI append (_temp select 0); +}; + +#ifdef blck_debugMode +if (blck_debugLevel > 0) then +{ + diag_log format["[blckeagls] missionSpawner:: (288) AI Patrols Spawned: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; +}; +#endif + +_assetSpawned = objNull; +if !(_hostageConfig isEqualTo []) then +{ + _assetSpawned = [_coords,_hostageConfig] call blck_fnc_spawnHostage; + //diag_log format["_fnc_missionSpawner: _assetSpawned = %1",_assetSpawned]; + _blck_AllMissionAI pushBack _assetSpawned; +}; + +if !(_enemyLeaderConfig isEqualTo []) then +{ + _assetSpawned = [_coords,_enemyLeaderConfig] call blck_fnc_spawnLeader; + //diag_log format["_fnc_missionSpawner: _assetSpawned = %1",_assetSpawned]; + _blck_AllMissionAI pushBack _assetSpawned; +}; + +#ifdef blck_debugMode + if (blck_debugLevel >= 1) then { + diag_log format["_fnc_missionSpawner: _assetSpawned = %1",_assetSpawned]; + }; +#endif + +uiSleep delayTime; +_temp = [[],[],false]; +_abort = false; + +_vehToSpawn = [_noVehiclePatrols] call blck_fnc_getNumberFromRange; +if (blck_useVehiclePatrols && ((_vehToSpawn > 0) || count _missionPatrolVehicles > 0)) then +{ + #define useRelativePos true + //params[_coords,_noVehiclePatrols,_aiDifficultyLevel,_missionPatrolVehicles,_useRelativePos,_uniforms,_headGear,_vests,_backpacks,_weaponList,_sideArms, _isScubaGroup]; + //_temp = [_coords,_vehToSpawn,_aiDifficultyLevel,_uniforms,_headGear,_missionPatrolVehicles] call blck_fnc_spawnMissionVehiclePatrols; + _temp = [_coords,_vehToSpawn,_aiDifficultyLevel,_missionPatrolVehicles,useRelativePos,_uniforms,_headGear,_vests,_backpacks,_weaponList,_sideArms] call blck_fnc_spawnMissionVehiclePatrols; + + if (typeName _temp isEqualTo "ARRAY") then + { + _abort = _temp select 2; + }; + if !(_abort) then + { + _patrolVehicles = _temp select 0; + _blck_AllMissionAI append (_temp select 1); + }; +}; + +if (_abort) exitWith +{ + [_mines,_objects,_crates, _blck_AllMissionAI,_endMsg,_blck_localMissionMarker,_coords,_markerClass, 1] call blck_fnc_endMission; +}; + +uiSleep delayTime; +_temp = [[],[],false]; +_abort = false; + +// Deal with helicopter patrols +_temp = []; + +#ifdef blck_debugMode +if (blck_debugLevel > 1) then +{ + diag_log format["[blckeagls] missionSpawner:: (351) calling in heli patrol: Current mission: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; +}; +#endif + +_noChoppers = [_noChoppers] call blck_fnc_getNumberFromRange; +//_noPara = [_noPara] call blck_fnc_getNumberFromRange; + +#ifdef blck_debugMode +if (blck_debugLevel > 1) then {diag_log format["_missionSpawner(322):: _noChoppers = %1 && _chancePara = %2",_noChoppers,_chancePara]}; +#endif +if (_noChoppers > 0) then +{ + for "_i" from 1 to (_noChoppers) do + { + if (random(1) < _chanceHeliPatrol) then + { + //_temp = [_coords,_missionHelis,spawnHeli,_aiDifficultyLevel,_chancePara,_noPara,_uniforms,_headGear,_vests,_backpacks,_weaponList,_sideArms] call blck_fnc_spawnMissionReinforcements; + _temp = [_coords,_aiDifficultyLevel,_missionHelis,_uniforms,_headGear,_vests,_backpacks,"none",_weaponList, _sideArms] call blck_fnc_spawnMissionHeli; + + if (typeName _temp isEqualTo "ARRAY") then + { + _abort = _temp select 2; + blck_monitoredVehicles pushBack (_temp select 0); + _blck_AllMissionAI append (_temp select 1); + }; + if (_abort) then + { + _objects pushback (_temp select 0); + [_mines,_objects,_crates, _blck_AllMissionAI,_endMsg,_blck_localMissionMarker,_coords,_markerClass, 1] call blck_fnc_endMission; + }; + }; + }; +}; + + +////////////////////////// +// Spawn Crates and Emplaced Weapons Last to try to force them to correct positions relative to spawned buildinga or other objects. +#ifdef blck_debugMode +if (blck_debugLevel > 0) then {diag_log format["missionSpawner:: (389) preparing to spawn emplaced weapons for _coords %4 | _markerClass %3 | blck_useStatic = %1 | _noEmplacedWeapons = %2",blck_useStatic,_noEmplacedWeapons,_markerClass,_coords];}; +#endif +uiSleep 15; +private["_noEmplacedToSpawn"]; +_noEmplacedToSpawn = [_noEmplacedWeapons] call blck_fnc_getNumberFromRange; +diag_log format["_fnc_missionSpawner: -> _noEmplacedToSpawn = %1 | blck_useStatic = %2",_noEmplacedToSpawn,blck_useStatic]; +if (blck_useStatic && (_noEmplacedToSpawn > 0)) then +{ + // _params = ["_coords","_missionEmplacedWeapons","_useRelativePos","_noEmplacedWeapons","_aiDifficultyLevel","_uniforms","_headGear","_vests","_backpacks","_weaponList","_sideArms"]; + // _temp = [_missionEmplacedWeapons,_noEmplacedToSpawn,_aiDifficultyLevel,_coords,_uniforms,_headGear] call blck_fnc_spawnEmplacedWeaponArray; + _temp = [_coords,_missionEmplacedWeapons,useRelativePos,_noEmplacedToSpawn,_aiDifficultyLevel,_uniforms,_headGear,_vests,_backpacks,_weaponList,_sideArms] call blck_fnc_spawnEmplacedWeaponArray; + + if (typeName _temp isEqualTo "ARRAY") then + { + _abort = _temp select 2; + }; + + if !(_abort) then + { + _objects append (_temp select 0); + _blck_AllMissionAI append (_temp select 1); + }; +}; +if (_abort) exitWith +{ + [_mines,_objects,_crates, _blck_AllMissionAI,_endMsg,_blck_localMissionMarker,_coords,_markerClass, 1] call blck_fnc_endMission; +}; +uiSleep delayTime; +if (_spawnCratesTiming isEqualTo "atMissionSpawnGround") then +{ + if (count _missionLootBoxes > 0) then + { + _crates = [_coords,_missionLootBoxes,_loadCratesTiming, _spawnCratesTiming, "start", _aiDifficultyLevel] call blck_fnc_spawnMissionCrates; + } + else + { + _crates = [_coords,[[selectRandom blck_crateTypes,[0,0,0],_crateLoot,_lootCounts]], _loadCratesTiming, _spawnCratesTiming, "start", _aiDifficultyLevel] call blck_fnc_spawnMissionCrates; + + }; + + if (blck_cleanUpLootChests) then + { + _objects append _crates; + }; +}; +if (_noPara > 0 && (random(1) < _chancePara) && _paraTriggerDistance == 0) then +{ + diag_log format["_fnc_missionSpawner (436): spawning %1 paraunits at mission spawn",_noPara]; + private _paratroops = [_coords,_noPara,_aiDifficultyLevel,_uniforms,_headGear,_vests,_backpacks,_weaponList,_sideArms] call blck_fnc_spawnParaUnits; + if !(isNull _paratroops) then + { + _blck_AllMissionAI append (units _paratroops); + }; + if (random(1) < _chanceLoot) then + { + private _extraCrates = [_coords,[[selectRandom blck_crateTypes,[0,0,0],_paraLoot,_paraLootCounts]], "atMissionSpawn","atMissionStartAir", "start", _aiDifficultyLevel] call blck_fnc_spawnMissionCrates; + if (blck_cleanUpLootChests) then + { + _objects append _extraCrates; + }; + }; +}; + +// Define Triggers for mission end +private["_missionComplete","_endIfPlayerNear","_endIfAIKilled","_secureAsset","_crateStolen","_locations"]; +_missionComplete = -1; +_startTime = diag_tickTime; + +switch (_endCondition) do +{ + case "playerNear": {_secureAsset = false; _endIfPlayerNear = true;_endIfAIKilled = false;}; + case "allUnitsKilled": {_secureAsset = false; _endIfPlayerNear = false;_endIfAIKilled = true;}; + case "allKilledOrPlayerNear": {_secureAsset = false; _endIfPlayerNear = true;_endIfAIKilled = true;}; + case "assetSecured": {_secureAsset = true; _endIfPlayerNear = false; _endIfAIKilled = false;}; +}; + +if (blck_showCountAliveAI) then +{ + if !(_marker isEqualTo "") then + { + [_marker,_markerMissionName,_blck_AllMissionAI] call blck_fnc_updateMarkerAliveCount; + blck_missionMarkers pushBack [_marker,_markerMissionName,_blck_AllMissionAI]; + }; +}; + +_crateStolen = false; +_locations = [_coords]; +private _spawnPara = if (random(1) < _chancePara) then {true} else {false}; +diag_log format["_fnc_missionSpawner (477): _spawnPara = %1 | _chancePara = %2",_spawnPara,_chancePara]; +{ + _locations pushback (getPos _x); + _x setVariable["crateSpawnPos", (getPos _x)]; +} forEach _crates; + +while {_missionComplete isEqualTo -1} do +{ + if (blck_debugLevel isEqualTo 3) exitWith {uiSleep 180}; + if (_endIfPlayerNear) then + { + if ([_locations,10,true] call blck_fnc_playerInRangeArray) then {_missionComplete = 1}; + }; + if (_endIfAIKilled) then + { + if (({alive _x} count _blck_AllMissionAI) < 1) then {_missionComplete = 1}; + }; + if (_spawnCratesTiming isEqualTo "atMissionSpawn") then + { + { + if ({[_x] call blck_fnc_crateMoved} count _crates > 0) exitWith + { + _missionComplete = 1; + _crateStolen = true; + }; + }forEach _crates; + }; + if (_secureAsset) then + { + if !(alive _assetSpawned) then + { + _missionComplete = 1 + } else { + if (_assetSpawned getVariable["blck_AIState",0] > 0 && (({alive _x} count _blck_AllMissionAI) isEqualTo 1)) then {_missionComplete = 1}; + }; + }; + if (_spawnPara) then + { + + if ([_coords,_paraTriggerDistance,true] call blck_fnc_playerInRange) then + { + _spawnPara = false; // The player gets one try to spawn these. + if (random(1) < _chancePara) then // + { + private _paratroops = [_coords,_noPara,_aiDifficultyLevel,_uniforms,_headGear,_vests,_backpacks,_weaponList,_sideArms] call blck_fnc_spawnParaUnits; + if !(isNull _paratroops) then + { + _blck_AllMissionAI append (units _paratroops); + }; + if (random(1) < _chanceLoot) then + { + private _extraCrates = [_coords,[[selectRandom blck_crateTypes,[0,0,0],_paraLoot,_paraLootCounts]], "atMissionSpawn","atMissionStartAir", "start", _aiDifficultyLevel] call blck_fnc_spawnMissionCrates; + if (blck_cleanUpLootChests) then + { + _objects append _extraCrates; + }; + }; + }; + }; + }; + uiSleep 2; +}; + +if (_crateStolen) exitWith +{ + diag_log format["missionSpawner:: (542) Crate Stolen Callening _fnc_endMission - > players near = %1 and ai alive = %2 and crates stolen = %3",[_locations,10,true] call blck_fnc_playerInRangeArray, {alive _x} count _blck_AllMissionAI, _crateStolen]; + [_mines,_objects,_crates, _blck_AllMissionAI,"Crate Removed from Mission Site Before Mission Completion: Mission Aborted",_blck_localMissionMarker,_coords,_markerClass, 2] call blck_fnc_endMission; +}; + +if ((_secureAsset) && !(alive _assetSpawned)) exitWith +{ + [_mines,_objects,_crates, _blck_AllMissionAI,_assetKilledMsg,_blck_localMissionMarker,_coords,_markerClass, 2] call blck_fnc_endMission; +}; + +if (_spawnCratesTiming in ["atMissionEndGround","atMissionEndAir"]) then +{ + if (count _missionLootBoxes > 0) then + { + _crates = [_coords,_missionLootBoxes,_loadCratesTiming,_spawnCratesTiming, "end", _aiDifficultyLevel] call blck_fnc_spawnMissionCrates; + } + else + { + _crates = [_coords,[[selectRandom blck_crateTypes,[0,0,0],_crateLoot,_lootCounts]], _loadCratesTiming,_spawnCratesTiming, "end", _aiDifficultyLevel] call blck_fnc_spawnMissionCrates; + }; + + #ifdef blck_debugMode + if (blck_debugLevel > 0) then {diag_log format["_fnc_missionSpawner (531): _crates = %1", _crates]}; + #endif + + if (blck_cleanUpLootChests) then + { + _objects append _crates; + }; + + #ifdef blck_debugMode + if (blck_debugLevel > 0) then {diag_log format["[blckeagls] missionSpawner:: (428) Crates Spawned: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]}; + #endif +}; + +if (_spawnCratesTiming isEqualTo "atMissionSpawnGround" && _loadCratesTiming isEqualTo "atMissionCompletion") then +{ + { + [_x] call blck_fnc_loadMissionCrate; + } forEach _crates; +}; + +#ifdef blck_debugMode +if (blck_debugLevel > 0) then +{ + diag_log format["[blckeagls] missionSpawner:: (586) Mission completion criteria fulfilled: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; + diag_log format["missionSpawner :: (587) _endIfPlayerNear = %1 _endIfAIKilled= %2",_endIfPlayerNear,_endIfAIKilled]; + diag_log format["[blckeagls] missionSpawner:: (588) calling endMission: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; +}; +#endif + +private["_result"]; +// Force passing the mission name for informational purposes. +_blck_localMissionMarker set [2, _markerMissionName]; +if (blck_showCountAliveAI) then +{ + _marker setMarkerText format["%1: All AI Dead",_markerMissionName]; + { + if ((_x select 1) isEqualTo _markerMissionName) exitWith{blck_missionMarkers deleteAt _forEachIndex}; + }forEach blck_missionMarkers; +}; + +diag_log format["_fnc_missionSpawner (557) Build 123: _secureAsset = %1 | {alive _assetSpawned} = %2 | assetType = %3",_secureAsset,alive _assetSpawned, _assetSpawned getVariable["assetType",-1]]; + +if (_assetSpawned getVariable["assetType",0] isEqualTo 1) then +{ + diag_log "Processing Mission End for Hostage Rescue"; + _assetSpawned setCaptive false; + _assetSpawned setVariable["GMSAnimations",[""],true]; + [_assetSpawned,""] remoteExec["switchMove",-2];; + uiSleep 0.1; + _assetSpawned enableAI "ALL"; + private _newPos = (getPos _assetSpawned) getPos [1000, random(360)]; + diag_log format["processing domove for hostage with current pos = %1 and new pos = %2",getPos _assetSpawned, _newPos]; + (group _assetSpawned) setCurrentWaypoint [group _assetSpawned, 0]; + [group _assetSpawned,0] setWaypointPosition [_newPos,0]; + [group _assetSpawned,0] setWaypointType "MOVE"; +}; + +if (_assetSpawned getVariable["assetType",0] isEqualTo 2) then +{ + diag_log format["Processing Mission End for Arrest of Leader %1 with endAnimation %2",_assetSpawned,_assetSpawned getVariable["endAnimation",""]]; + [_assetSpawned,""] remoteExec["switchMove",-2]; + _assetSpawned setVariable["GMSAnimations",_assetSpawned getVariable["endAnimation",["AidlPercMstpSnonWnonDnon_AI"]],true]; + [_assetSpawned,selectRandom(_assetSpawned getVariable["endAnimation",["AidlPercMstpSnonWnonDnon_AI"]])] remoteExec["switchMove",-2]; +}; + +diag_log format["_fnc_missionSpawner (579) Build 123: _secureAsset = %1 | {alive _assetSpawned} = %2 | assetType = %3",_secureAsset,alive _assetSpawned, _assetSpawned getVariable["assetType",-1]]; + +_result = [_mines,_objects,_crates,_blck_AllMissionAI,_endMsg,_blck_localMissionMarker,_coords,_markerClass, 0] call blck_fnc_endMission; + +#ifdef blck_debugMode +if (blck_debugLevel > 2) then {diag_log format["[blckeagls] missionSpawner:: (507)end of mission: blck_fnc_endMission has returned control to _fnc_missionSpawner"]}; +#endif +diag_log format["_fnc_missionSpawner (637) Mission Completed | _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; \ No newline at end of file diff --git a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_missionSpawner - Copy.sqf b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_missionSpawner - Copy.sqf new file mode 100644 index 0000000..fe8a8d3 --- /dev/null +++ b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_missionSpawner - Copy.sqf @@ -0,0 +1,633 @@ +/* + Dynamic Mission Spawner (over-ground missions) + By Ghostrider GRG + Copyright 2016 + + -------------------------- + License + -------------------------- + All the code and information provided here is provided under an Attribution Non-Commercial ShareAlike 4.0 Commons License. + + http://creativecommons.org/licenses/by-nc-sa/4.0/ +*/ +#include "\q\addons\custom_server\Configs\blck_defines.hpp"; +#define delayTime 1 +private ["_abort","_crates","_aiGroup","_objects","_groupPatrolRadius","_missionLandscape","_mines","_blck_AllMissionAI","_blck_localMissionMarker","_assetKilledMsg","_enemyLeaderConfig", + "_AI_Vehicles","_timeOut","_aiDifficultyLevel","_missionPatrolVehicles","_missionGroups","_loadCratesTiming","_spawnCratesTiming","_assetSpawned","_hostageConfig", + "_chanceHeliPatrol","_noPara","_chanceLoot","_heliCrew","_loadCratesTiming","_useMines","_blck_AllMissionAI","_delayTime","_groupPatrolRadius", + "_wait","_missionStartTime","_playerInRange","_missionTimedOut","_temp","_patrolVehicles","_vehToSpawn","_noChoppers","_chancePara","_marker"]; + +params["_coords","_markerClass","_aiDifficultyLevel"]; + +//////// +// set all variables needed for the missions +// data is pulled either from the mission description or from the _mission variable passsed as a parameter +// Deal with situations where some of these variables might not be defined as well. +//////// + +// _mission params["OrangeMarker","orange",blck_TMin_Orange,blck_TMax_Orange]; +//_markerClass = _mission select 0; +// _aiDifficultyLevel = _mission select 1; + +[_markerClass, "active",_coords] call blck_fnc_updateMissionQue; +blck_ActiveMissionCoords pushback _coords; +diag_log format["[blckeagls] missionSpawner (17):: Initializing mission: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; + +if (isNil "_assetKilledMsg") then {_assetKilledMsg = ""}; +if (isNil "_markerColor") then {_markerColor = "ColorBlack"}; +if (isNil "_markerType") then {_markerType = ["mil_box",[]]}; +//if (isNil "_timeOut") then {_timeOut = -1;}; +if (isNil "_spawnCratesTiming") then {_spawnCratesTiming = blck_spawnCratesTiming}; // Choices: "atMissionSpawnGround","atMissionStartAir","atMissionEndGround","atMissionEndAir". +if (isNil "_loadCratesTiming") then {_loadCratesTiming = blck_loadCratesTiming}; // valid choices are "atMissionCompletion" and "atMissionSpawn"; +if (isNil "_missionPatrolVehicles") then {_missionPatrolVehicles = []}; +if (isNil "_missionGroups") then {_missionGroups = []}; +if (isNil "_hostageConfig") then {_hostageConfig = []}; +if (isNil "_enemyLeaderConfig") then {_enemyLeaderConfig = []}; +if (isNil "_useMines") then {_useMines = blck_useMines;}; +if (isNil "_weaponList") then {_weaponList = [_aiDifficultyLevel] call blck_fnc_selectAILoadout}; +if (isNil "_sideArms") then {_sideArms = blck_Pistols}; +if (isNil "_vests") then {_vests = blck_vests}; +if (isNil "_backpacks") then {_backpacks = blck_backpacks}; +//diag_log format["_fnc_missionSpawner: -> blck_backpacks = %1", blck_backpacks]; +//diag_log format["_fnc_missionSpawner: -> _backpacks = %1",_backpacks]; +if (isNil "_uniforms") then {_uniforms = blck_SkinList}; +if (isNil "_headGear") then {_headgear = blck_headgear}; + +if (isNil "_chanceHeliPatrol") then +{ + switch (toLower(_aiDifficultyLevel)) do + { + case "blue": {_chanceHeliPatrol = blck_chanceHeliPatrolBlue}; + case "red": {_chanceHeliPatrol = blck_noPatblck_chanceHeliPatrolRed}; + case "green": {_chanceHeliPatrol = blck_noPatblck_chanceHeliPatrolGreen}; + case "orange": {_chanceHeliPatrol = blck_chanceHeliPatrolOrange}; + default {_chanceHeliPatrol = 0}; + }; +}; +if (isNil "_noChoppers") then +{ + switch (toLower(_aiDifficultyLevel)) do + { + case "blue": {_noChoppers = blck_noPatrolHelisBlue}; + case "red": {_noChoppers = blck_noPatrolHelisRed}; + case "green": {_noChoppers = blck_noPatrolHelisGreen}; + case "orange": {_noChoppers = blck_noPatrolHelisOrange}; + default {_noChoppers = 0}; + }; +}; +if (isNil "_chancePara") then +{ + switch (toLower (_aiDifficultyLevel)) do + { + case "blue": {_chancePara = blck_chanceParaBlue}; + case "red": {_chancePara = blck_chanceParaRed}}; + case "green": {_chancePara = blck_chanceParaGreen}; + case "orange": {_chancePara = blck_chanceParaOrange; + default {_chancePara = 0}; + }; +}; +if (isNil "_missionHelis") then +{ + switch (toLower (_aiDifficultyLevel)) do + { + case "blue": {_missionHelis = blck_patrolHelisBlue}; + case "red": {_missionHelis = blck_patrolHelisRed}; + case "green": {_missionHelis = blck_patrolHelisGreen}; + case "orange": {_missionHelis = blck_patrolHelisOrange}; + default {_missionHelis = blck_patrolHelisBlue}; + }; +}; +if (isNil "_noPara") then +{ + switch (toLower (_aiDifficultyLevel)) do + { + case "blue": {_noPara = blck_noParaBlue}; + case "red": {_noPara = blck_noParaRed}; + case "green": {_noPara = blck_noParaGreen}; + case "orange": {_noPara = blck_noParaOrange}; + default {_noPara = 0}; + }; +}; +if (isNil "_chanceLoot") then {_chanceLoot = 0}; +if (isNil "_paraTriggerDistance") then {_paraTriggerDistance = 400;}; +if (isNil "_paraLoot") then {_paraLoot = blck_BoxLoot_Blue}; +if (isNil "_paraLootCounts") then {_paraLootCounts = blck_lootCountsRed}; + +_objects = []; +_mines = []; +_crates = []; +_aiGroup = []; +_missionAIVehicles = []; +_blck_AllMissionAI = []; +_AI_Vehicles = []; +_blck_localMissionMarker = [_markerClass,_coords,"","",_markerColor,_markerType]; +_delayTime = 1; +_groupPatrolRadius = 50; + +diag_log "_missionSpawner: All variables initialized"; + +if (blck_labelMapMarkers select 0) then +{ + //diag_log "labeling map markers *****"; + _blck_localMissionMarker set [2, _markerMissionName]; +}; +if !(blck_preciseMapMarkers) then +{ + //diag_log "Map marker will be OFFSET from the mission position"; + _blck_localMissionMarker set [1,[_coords,75] call blck_fnc_randomPosition]; +}; +_blck_localMissionMarker set [3,blck_labelMapMarkers select 1]; // Use an arrow labeled with the mission name? +[["start",_startMsg,_markerMissionName]] call blck_fnc_messageplayers; +_marker = [_blck_localMissionMarker] call blck_fnc_spawnMarker; + +#ifdef blck_debugMode +if (blck_debugLevel > 0) then {diag_log "missionSpawner:: (77) message players and spawn a mission marker";}; +if (blck_debugLevel > 0) then {diag_log format["missionSpawner:: (77) _marker = %1",_marker];}; +if (blck_debugLevel > 0) then {diag_log "missionSpawner:: (77) waiting for player to trigger the mission";}; +#endif +//////// +// All parameters are defined, lets wait until a player is nearby or the mission has timed out +//////// + +_missionStartTime = diag_tickTime; +_playerInRange = false; +_missionTimedOut = false; +_wait = true; + +#ifdef blck_debugMode +if (blck_debugLevel > 0) then {diag_log "missionSpawner:: (90) starting mission trigger loop"}; +#endif + +while {_wait} do +{ + #ifdef blck_debugMode + //diag_log "missionSpawner:: top of mission trigger loop"; + if (blck_debugLevel > 2) exitWith {_playerInRange = true;}; + #endif + + if ([_coords, blck_TriggerDistance, false] call blck_fnc_playerInRange) exitWith {_playerInRange = true;}; + if ([_missionStartTime] call blck_fnc_timedOut) exitWith {_missionTimedOut = true;}; + uiSleep 5; + + #ifdef blck_debugMode + if (blck_debugLevel > 2) then + { + diag_log format["missionSpawner:: Trigger Loop - blck_debugLevel = %1 and _coords = %2",blck_debugLevel, _coords]; + diag_log format["missionSpawner:: Trigger Loop - players in range = %1",{isPlayer _x && _x distance2D _coords < blck_TriggerDistance} count allPlayers]; + diag_log format["missionSpawner:: Trigger Loop - timeout = %1", [_missionStartTime] call blck_fnc_timedOut]; + }; + #endif +}; + +if (_missionTimedOut) exitWith +{ + // Deal with the case in which the mission timed out. + blck_recentMissionCoords pushback [_coords,diag_tickTime]; + blck_ActiveMissionCoords = blck_ActiveMissionCoords - [ _coords]; + [_markerClass, "inactive",[0,0,0]] call blck_fnc_updateMissionQue; + blck_missionsRunning = blck_missionsRunning - 1; + [_blck_localMissionMarker select 0] call blck_fnc_deleteMarker; + [_objects, 0.1] spawn blck_fnc_cleanupObjects; +}; + +//////// +// Spawn the mission objects, loot chest, and AI +//////// +#ifdef blck_debugMode +if (blck_debugLevel > 0) then +{ + diag_log format["[blckeagls] missionSpawner:: (142) -- >> Mission tripped: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; +}; +#endif + +if (blck_SmokeAtMissions select 0) then // spawn a fire and smoke near the crate +{ + _temp = [_coords,blck_SmokeAtMissions select 1] call blck_fnc_smokeAtCrates; + if (typeName _temp isEqualTo "ARRAY") then + { + _objects append _temp; + }; +}; + +uiSleep _delayTime; +if (_useMines) then +{ + _mines = [_coords] call blck_fnc_spawnMines; + +}; +uiSleep _delayTime; +_temp = []; + +if (_missionLandscapeMode isEqualTo "random") then +{ + _temp = [_coords,_missionLandscape, 3, 15, 2] call blck_fnc_spawnRandomLandscape; +} else { + params["_center","_objects"]; + _temp = [_coords, _missionLandscape] call blck_fnc_spawnCompositionObjects; +}; +if (typeName _temp isEqualTo "ARRAY") then +{ + _objects append _temp; +}; + +#ifdef blck_debugMode +if (blck_debugLevel > 0) then +{ + diag_log format["[blckeagls] missionSpawner:: (190) Landscape spawned: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; +}; +#endif + +uiSleep _delayTime;; + +_temp = [_coords,_missionLootVehicles] call blck_fnc_spawnMissionLootVehicles; +//uisleep 1; +_crates append _temp; + +uiSleep _delayTime; + +_abort = false; +_temp = [[],[],false]; + +// params["_coords",_minNoAI,_maxNoAI,_missionGroups,_aiDifficultyLevel,_uniforms,_headGear,_vests",_backpacks,_weapons,sideArms,_isScubaGroup]; +#ifdef blck_debugMode +private _params = [_coords,_minNoAI,_maxNoAI,_missionGroups,_aiDifficultyLevel,_uniforms,_headGear,_vests,_backpacks,_weaponList,_sideArms]; +{ + diag_log format["_fnc_missionSpawner: _param %1 label %2 = %3",_forEachIndex, _x, _params select _forEachIndex]; +}forEach ["_coords","_minNoAI","_maxNoAI","_missionGroups","_aiDifficultyLevel","_uniforms","_headgear","_vests","_backpacks","_weaponList","_sideArms"]; +#endif + +_temp = [_coords, _minNoAI,_maxNoAI,_missionGroups,_aiDifficultyLevel,_uniforms,_headGear,_vests,_backpacks,_weaponList,_sideArms] call blck_fnc_spawnMissionAI; + +#ifdef blck_debugMode +if (blck_debugLevel > 2) then { + diag_log format["missionSpawner :: (209) blck_fnc_spawnMissionAI returned a value of _temp = %1",_temp]; uiSleep 1; +}; + +_abort = _temp select 1; +if (blck_debugLevel > 2) then { + diag_log format["missionSpawner :: (214) blck_fnc_spawnMissionAI returned a value of _abort = %1",_abort]; uiSleep 1; +}; +#endif + +if (_abort) exitWith +{ + if (blck_debugLevel > 1) then { + diag_log "missionSpawner:: (220) grpNull returned, mission termination criteria met, calling blck_fnc_endMission" + }; + [_mines,_objects,_crates, _blck_AllMissionAI,_endMsg,_blck_localMissionMarker,_coords,_markerClass, 1] call blck_fnc_endMission; +}; +if !(_abort) then +{ + _blck_AllMissionAI append (_temp select 0); +}; + +#ifdef blck_debugMode +if (blck_debugLevel > 0) then +{ + diag_log format["[blckeagls] missionSpawner:: (235) AI Patrols Spawned: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; +}; +#endif + +_assetSpawned = objNull; +if !(_hostageConfig isEqualTo []) then +{ + _assetSpawned = [_coords,_hostageConfig] call blck_fnc_spawnHostage; + //diag_log format["_fnc_missionSpawner: _assetSpawned = %1",_assetSpawned]; + _blck_AllMissionAI pushBack _assetSpawned; +}; + +if !(_enemyLeaderConfig isEqualTo []) then +{ + _assetSpawned = [_coords,_enemyLeaderConfig] call blck_fnc_spawnLeader; + //diag_log format["_fnc_missionSpawner: _assetSpawned = %1",_assetSpawned]; + _blck_AllMissionAI pushBack _assetSpawned; +}; + +#ifdef blck_debugMode + if (blck_debugLevel >= 1) then { + diag_log format["_fnc_missionSpawner: _assetSpawned = %1",_assetSpawned]; + }; +#endif + +uiSleep _delayTime; +_temp = [[],[],false]; +_abort = false; + +_vehToSpawn = [_noVehiclePatrols] call blck_fnc_getNumberFromRange; +if (blck_useVehiclePatrols && ((_vehToSpawn > 0) || count _missionPatrolVehicles > 0)) then +{ + #define useRelativePos true + //params[_coords,_noVehiclePatrols,_aiDifficultyLevel,_missionPatrolVehicles,_useRelativePos,_uniforms,_headGear,_vests,_backpacks,_weaponList,_sideArms, _isScubaGroup]; + //_temp = [_coords,_vehToSpawn,_aiDifficultyLevel,_uniforms,_headGear,_missionPatrolVehicles] call blck_fnc_spawnMissionVehiclePatrols; + _temp = [_coords,_vehToSpawn,_aiDifficultyLevel,_missionPatrolVehicles,useRelativePos,_uniforms,_headGear,_vests,_backpacks,_weaponList,_sideArms] call blck_fnc_spawnMissionVehiclePatrols; + + if (typeName _temp isEqualTo "ARRAY") then + { + _abort = _temp select 2; + }; + if !(_abort) then + { + _patrolVehicles = _temp select 0; + _blck_AllMissionAI append (_temp select 1); + }; +}; + +if (_abort) exitWith +{ + [_mines,_objects,_crates, _blck_AllMissionAI,_endMsg,_blck_localMissionMarker,_coords,_markerClass, 1] call blck_fnc_endMission; +}; + +uiSleep _delayTime; +_temp = [[],[],false]; +_abort = false; + +// Deal with helicopter patrols +_temp = []; + +#ifdef blck_debugMode +if (blck_debugLevel > 1) then +{ + diag_log format["[blckeagls] missionSpawner:: (298) calling in heli patrol: Current mission: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; +}; +#endif + +_noChoppers = [_noChoppers] call blck_fnc_getNumberFromRange; +_noPara = [_noPara] call blck_fnc_getNumberFromRange; + +#ifdef blck_debugMode +if (blck_debugLevel > 1) then {diag_log format["_missionSpawner(322):: _noChoppers = %1 && _chancePara = %2",_noChoppers,_chancePara]}; +#endif +if (_noChoppers > 0) then +{ + for "_i" from 1 to (_noChoppers) do + { + if (random(1) < _chanceHeliPatrol) then + { + //_temp = [_coords,_missionHelis,spawnHeli,_aiDifficultyLevel,_chancePara,_noPara,_uniforms,_headGear,_vests,_backpacks,_weaponList,_sideArms] call blck_fnc_spawnMissionReinforcements; + _temp = [_coords,_aiDifficultyLevel,_missionHelis,_uniforms,_headGear,_vests,_backpacks,"none",_weaponList, _sideArms] call blck_fnc_spawnMissionHeli; + + if (typeName _temp isEqualTo "ARRAY") then + { + _abort = _temp select 2; + blck_monitoredVehicles pushBack (_temp select 0); + _blck_AllMissionAI append (_temp select 1); + }; + if (_abort) then + { + _objects pushback (_temp select 0); + [_mines,_objects,_crates, _blck_AllMissionAI,_endMsg,_blck_localMissionMarker,_coords,_markerClass, 1] call blck_fnc_endMission; + }; + }; + }; +}; + + +////////////////////////// +// Spawn Crates and Emplaced Weapons Last to try to force them to correct positions relative to spawned buildinga or other objects. +#ifdef blck_debugMode +if (blck_debugLevel > 0) then {diag_log format["missionSpawner:: (361) preparing to spawn emplaced weapons for _coords %4 | _markerClass %3 | blck_useStatic = %1 | _noEmplacedWeapons = %2",blck_useStatic,_noEmplacedWeapons,_markerClass,_coords];}; +#endif +uiSleep 15; +private["_noEmplacedToSpawn"]; +_noEmplacedToSpawn = [_noEmplacedWeapons] call blck_fnc_getNumberFromRange; +diag_log format["_fnc_missionSpawner: -> _noEmplacedToSpawn = %1 | blck_useStatic = %2",_noEmplacedToSpawn,blck_useStatic]; +if (blck_useStatic && (_noEmplacedToSpawn > 0)) then +{ + // _params = ["_coords","_missionEmplacedWeapons","_useRelativePos","_noEmplacedWeapons","_aiDifficultyLevel","_uniforms","_headGear","_vests","_backpacks","_weaponList","_sideArms"]; + // _temp = [_missionEmplacedWeapons,_noEmplacedToSpawn,_aiDifficultyLevel,_coords,_uniforms,_headGear] call blck_fnc_spawnEmplacedWeaponArray; + _temp = [_coords,_missionEmplacedWeapons,useRelativePos,_noEmplacedToSpawn,_aiDifficultyLevel,_uniforms,_headGear,_vests,_backpacks,_weaponList,_sideArms] call blck_fnc_spawnEmplacedWeaponArray; + + if (typeName _temp isEqualTo "ARRAY") then + { + _abort = _temp select 2; + }; + + if !(_abort) then + { + _objects append (_temp select 0); + _blck_AllMissionAI append (_temp select 1); + }; +}; +if (_abort) exitWith +{ + [_mines,_objects,_crates, _blck_AllMissionAI,_endMsg,_blck_localMissionMarker,_coords,_markerClass, 1] call blck_fnc_endMission; +}; +uiSleep _delayTime; +if (_spawnCratesTiming isEqualTo "atMissionSpawnGround") then +{ + if (count _missionLootBoxes > 0) then + { + _crates = [_coords,_missionLootBoxes,_loadCratesTiming, _spawnCratesTiming, "start", _aiDifficultyLevel] call blck_fnc_spawnMissionCrates; + } + else + { + _crates = [_coords,[[selectRandom blck_crateTypes,[0,0,0],_crateLoot,_lootCounts]], _loadCratesTiming, _spawnCratesTiming, "start", _aiDifficultyLevel] call blck_fnc_spawnMissionCrates; + + }; + + if (blck_cleanUpLootChests) then + { + _objects append _crates; + }; +}; +if (_noPara > 0 && (random(1) < _chancePara) && _paraTriggerDistance == 0) then +{ + diag_log format["_fnc_missionSpawner (435): spawning %1 paraunits at mission spawn",_noPara]; + private _paratroops = [_coords,_noPara,_aiDifficultyLevel,_uniforms,_headGear,_vests,_backpacks,_weaponList,_sideArms] call blck_fnc_spawnParaUnits; + if !(isNull _paratroops) then + { + _blck_AllMissionAI append (units _paratroops); + }; + if (random(1) < _chanceLoot) then + { + private _extraCrates = [_coords,[[selectRandom blck_crateTypes,[0,0,0],_paraLoot,_paraLootCounts]], "atMissionSpawn","atMissionStartAir", "start", _aiDifficultyLevel] call blck_fnc_spawnMissionCrates; + if (blck_cleanUpLootChests) then + { + _objects append _extraCrates; + }; + }; +}; + +// Define Triggers for mission end +private["_missionComplete","_endIfPlayerNear","_endIfAIKilled","_secureAsset","_crateStolen","_locations"]; +_missionComplete = -1; +_startTime = diag_tickTime; + +switch (_endCondition) do +{ + case "playerNear": {_secureAsset = false; _endIfPlayerNear = true;_endIfAIKilled = false;}; + case "allUnitsKilled": {_secureAsset = false; _endIfPlayerNear = false;_endIfAIKilled = true;}; + case "allKilledOrPlayerNear": {_secureAsset = false; _endIfPlayerNear = true;_endIfAIKilled = true;}; + case "assetSecured": {_secureAsset = true; _endIfPlayerNear = false; _endIfAIKilled = false;}; +}; + +if (blck_showCountAliveAI) then +{ + if !(_marker isEqualTo "") then + { + [_marker,_markerMissionName,_blck_AllMissionAI] call blck_fnc_updateMarkerAliveCount; + blck_missionMarkers pushBack [_marker,_markerMissionName,_blck_AllMissionAI]; + }; +}; + +_crateStolen = false; +_locations = [_coords]; +private _spawnPara = if (random(1) < _chancePara) then {true} else {false}; +diag_log format["_fnc_missionSpawner (476): _spawnPara = %1 | _chancePara = %2",_spawnPara,_chancePara]; +{ + _locations pushback (getPos _x); + _x setVariable["crateSpawnPos", (getPos _x)]; +} forEach _crates; + +while {_missionComplete isEqualTo -1} do +{ + if (blck_debugLevel isEqualTo 3) exitWith {uiSleep 180}; + if (_endIfPlayerNear) then + { + if ([_locations,10,true] call blck_fnc_playerInRangeArray) then {_missionComplete = 1}; + }; + if (_endIfAIKilled) then + { + if (({alive _x} count _blck_AllMissionAI) < 1) then {_missionComplete = 1}; + }; + if (_spawnCratesTiming isEqualTo "atMissionSpawn") then + { + { + if ({[_x] call blck_fnc_crateMoved} count _crates > 0) exitWith + { + _missionComplete = 1; + _crateStolen = true; + }; + }forEach _crates; + }; + if (_secureAsset) then + { + if !(alive _assetSpawned) then + { + _missionComplete = 1 + } else { + if (_assetSpawned getVariable["blck_AIState",0] > 0 && (({alive _x} count _blck_AllMissionAI) isEqualTo 1)) then {_missionComplete = 1}; + }; + }; + if (_spawnPara) then + { + + if ([_coords,_paraTriggerDistance,true] call blck_fnc_playerInRange) then + { + _spawnPara = false; // The player gets one try to spawn these. + if (random(1) < _chancePara) then // + { + private _paratroops = [_coords,_noPara,_aiDifficultyLevel,_uniforms,_headGear,_vests,_backpacks,_weaponList,_sideArms] call blck_fnc_spawnParaUnits; + if !(isNull _paratroops) then + { + _blck_AllMissionAI append (units _paratroops); + }; + if (random(1) < _chanceLoot) then + { + private _extraCrates = [_coords,[[selectRandom blck_crateTypes,[0,0,0],_paraLoot,_paraLootCounts]], "atMissionSpawn","atMissionStartAir", "start", _aiDifficultyLevel] call blck_fnc_spawnMissionCrates; + if (blck_cleanUpLootChests) then + { + _objects append _extraCrates; + }; + }; + }; + }; + }; + uiSleep 2; +}; + +if (_crateStolen) exitWith +{ + diag_log format["missionSpawner:: (491) Crate Stolen Callening _fnc_endMission - > players near = %1 and ai alive = %2 and crates stolen = %3",[_locations,10,true] call blck_fnc_playerInRangeArray, {alive _x} count _blck_AllMissionAI, _crateStolen]; + [_mines,_objects,_crates, _blck_AllMissionAI,"Crate Removed from Mission Site Before Mission Completion: Mission Aborted",_blck_localMissionMarker,_coords,_markerClass, 2] call blck_fnc_endMission; +}; + +if ((_secureAsset) && !(alive _assetSpawned)) exitWith +{ + [_mines,_objects,_crates, _blck_AllMissionAI,_assetKilledMsg,_blck_localMissionMarker,_coords,_markerClass, 2] call blck_fnc_endMission; +}; + +if (_spawnCratesTiming in ["atMissionEndGround","atMissionEndAir"]) then +{ + if (count _missionLootBoxes > 0) then + { + _crates = [_coords,_missionLootBoxes,_loadCratesTiming,_spawnCratesTiming, "end", _aiDifficultyLevel] call blck_fnc_spawnMissionCrates; + } + else + { + _crates = [_coords,[[selectRandom blck_crateTypes,[0,0,0],_crateLoot,_lootCounts]], _loadCratesTiming,_spawnCratesTiming, "end", _aiDifficultyLevel] call blck_fnc_spawnMissionCrates; + }; + + #ifdef blck_debugMode + if (blck_debugLevel > 0) then {diag_log format["_fnc_missionSpawner (531): _crates = %1", _crates]}; + #endif + + if (blck_cleanUpLootChests) then + { + _objects append _crates; + }; + + #ifdef blck_debugMode + if (blck_debugLevel > 0) then {diag_log format["[blckeagls] missionSpawner:: (428) Crates Spawned: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]}; + #endif +}; + +if (_spawnCratesTiming isEqualTo "atMissionSpawnGround" && _loadCratesTiming isEqualTo "atMissionCompletion") then +{ + { + [_x] call blck_fnc_loadMissionCrate; + } forEach _crates; +}; + +#ifdef blck_debugMode +if (blck_debugLevel > 0) then +{ + diag_log format["[blckeagls] missionSpawner:: (496) Mission completion criteria fulfilled: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; + diag_log format["missionSpawner :: (497) _endIfPlayerNear = %1 _endIfAIKilled= %2",_endIfPlayerNear,_endIfAIKilled]; + diag_log format["[blckeagls] missionSpawner:: (498) calling endMission: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; +}; +#endif + +private["_result"]; +// Force passing the mission name for informational purposes. +_blck_localMissionMarker set [2, _markerMissionName]; +if (blck_showCountAliveAI) then +{ + //_marker setMarkerText format["%1: All AI Dead",_markerMissionName]; + { + if ((_x select 1) isEqualTo _markerMissionName) exitWith{blck_missionMarkers deleteAt _forEachIndex}; + }forEach blck_missionMarkers; +}; + +diag_log format["_fnc_missionSpawner (557) Build 123: _secureAsset = %1 | {alive _assetSpawned} = %2 | assetType = %3",_secureAsset,alive _assetSpawned, _assetSpawned getVariable["assetType",-1]]; + +if (_assetSpawned getVariable["assetType",0] isEqualTo 1) then +{ + diag_log "Processing Mission End for Hostage Rescue"; + _assetSpawned setCaptive false; + _assetSpawned setVariable["GMSAnimations",[""],true]; + [_assetSpawned,""] remoteExec["switchMove",-2];; + uiSleep 0.1; + _assetSpawned enableAI "ALL"; + private _newPos = (getPos _assetSpawned) getPos [1000, random(360)]; + diag_log format["processing domove for hostage with current pos = %1 and new pos = %2",getPos _assetSpawned, _newPos]; + (group _assetSpawned) setCurrentWaypoint [group _assetSpawned, 0]; + [group _assetSpawned,0] setWaypointPosition [_newPos,0]; + [group _assetSpawned,0] setWaypointType "MOVE"; +}; + +if (_assetSpawned getVariable["assetType",0] isEqualTo 2) then +{ + diag_log format["Processing Mission End for Arrest of Leader %1 with endAnimation %2",_assetSpawned,_assetSpawned getVariable["endAnimation",""]]; + [_assetSpawned,""] remoteExec["switchMove",-2]; + _assetSpawned setVariable["GMSAnimations",_assetSpawned getVariable["endAnimation",["AidlPercMstpSnonWnonDnon_AI"]],true]; + [_assetSpawned,selectRandom(_assetSpawned getVariable["endAnimation",["AidlPercMstpSnonWnonDnon_AI"]])] remoteExec["switchMove",-2]; +}; + +diag_log format["_fnc_missionSpawner (579) Build 123: _secureAsset = %1 | {alive _assetSpawned} = %2 | assetType = %3",_secureAsset,alive _assetSpawned, _assetSpawned getVariable["assetType",-1]]; + +_result = [_mines,_objects,_crates,_blck_AllMissionAI,_endMsg,_blck_localMissionMarker,_coords,_markerClass, 0] call blck_fnc_endMission; + +#ifdef blck_debugMode +if (blck_debugLevel >= 2) then {diag_log format["[blckeagls] missionSpawner:: (507)end of mission: blck_fnc_endMission has returned control to _fnc_missionSpawner"]}; +#endif diff --git a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_missionSpawner.sqf b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_missionSpawner.sqf index c0abe12..1bac892 100644 --- a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_missionSpawner.sqf +++ b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_missionSpawner.sqf @@ -109,7 +109,7 @@ if (isNil "_noPara") then default {_noPara = 0}; }; }; -if (isNil "_chanceLoot") then {_chanceLoot = 0.5}; +if (isNil "_chanceLoot") then {_chanceLoot = 1.0}; //0.5}; if (isNil "_paraTriggerDistance") then {_paraTriggerDistance = 400;}; if (isNil "_paraLoot") then {_paraLoot = blck_BoxLoot_Red}; if (isNil "_paraLootCounts") then {_paraLootCounts = blck_lootCountsRed}; @@ -125,7 +125,9 @@ _blck_localMissionMarker = [_markerClass,_coords,"","",_markerColor,_markerType] #define delayTime 1 //_groupPatrolRadius = 50; +#ifdef blck_debugMode diag_log "_missionSpawner: All variables initialized"; +#endif if (blck_labelMapMarkers select 0) then { @@ -441,6 +443,7 @@ if (_noPara > 0 && (random(1) < _chancePara) && _paraTriggerDistance == 0) then }; if (random(1) < _chanceLoot) then { + diag_log format["_fnc_missionSpawner (446): spawning supplemental loot with _chanceLoot = %1",_chanceLoot]; private _extraCrates = [_coords,[[selectRandom blck_crateTypes,[0,0,0],_paraLoot,_paraLootCounts]], "atMissionSpawn","atMissionStartAir", "start", _aiDifficultyLevel] call blck_fnc_spawnMissionCrates; if (blck_cleanUpLootChests) then { @@ -632,3 +635,4 @@ _result = [_mines,_objects,_crates,_blck_AllMissionAI,_endMsg,_blck_localMission #ifdef blck_debugMode if (blck_debugLevel > 2) then {diag_log format["[blckeagls] missionSpawner:: (507)end of mission: blck_fnc_endMission has returned control to _fnc_missionSpawner"]}; #endif +diag_log format["_fnc_missionSpawner (637) Mission Completed | _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName]; \ No newline at end of file diff --git a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_spawnCrate - Copy.sqf b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_spawnCrate - Copy.sqf new file mode 100644 index 0000000..8232b18 --- /dev/null +++ b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_spawnCrate - Copy.sqf @@ -0,0 +1,47 @@ +/* + spawn a crate at a specific location + returns the object (crate) that was created. + for ghostridergaming + By Ghostrider [GRG] + Copyright 2016 + Last updated 12-5-17 + + -------------------------- + License + -------------------------- + All the code and information provided here is provided under an Attribution Non-Commercial ShareAlike 4.0 Commons License. + + http://creativecommons.org/licenses/by-nc-sa/4.0/ +*/ +#include "\q\addons\custom_server\Configs\blck_defines.hpp"; + +private ["_crate"]; +params["_coords",["_crateType","Box_NATO_Wps_F"]]; + +_crate = createVehicle [_crateType,_coords,[], 0, "CAN_COLLIDE"]; +_crate setVariable ["LAST_CHECK", 100000]; +_crate allowDamage false; +_crate enableRopeAttach false; +[_crate] call blck_fnc_emptyObject; +_crate setPosATL _coords; +_crate setVectorUp [0,0,0]; +if ((_coords select 2) < 0 || surfaceIsWater (_coords)) then +{ + + private["_lantern","_bbr","_p1","_p2","_maxHeight"]; + //_lantern = createVehicle ["PortableHelipadLight_01_red_F", [0,0,0],[],0,"CAN_COLLIDE"];// Land_Camping_Light_F + //_lantern enableSimulationGlobal true; + //_lantern switchLight "on"; + _light = "#lightpoint" createVehicle (getPos _crate); + _light setLightDayLight true; + _light setLightBrightness 1.0; + _light setLightAmbient [0.0, 1.0, 0.0]; + _light setLightColor [0.0, 1.0, 0.0]; + _bbr = boundingBoxReal _crate; + _p1 = _bbr select 0; + _p2 = _bbr select 1; + _maxHeight = abs ((_p2 select 2) - (_p1 select 2)); + //diag_log format["_fnc_spawnCrate: _bbr = %1 | _maxHeight = %2",_bbr,_maxHeight]; + _light attachTo [_crate, [0,0,(_maxHeight + 0.5)]]; +}; +_crate; diff --git a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_spawnMissionCrates.sqf b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_spawnMissionCrates.sqf index 9fe82b6..9cacf21 100644 --- a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_spawnMissionCrates.sqf +++ b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_spawnMissionCrates.sqf @@ -17,8 +17,9 @@ params[ ["_coords", [0,0,0]], ["_cratesToSpawn",[]], ["_loadCrateTiming","atMiss #ifdef blck_debugMode if (blck_debugLevel >= 2) then { + private _params = ["_coords","_cratesToSpawn","_loadCrateTiming","_spawnCrateTiming","_missionState","_difficulty"]; { - diag_log format["_fnc_spawnMissionCrates: _this select %1 = %2",_foreachindex, _this select _foreachindex]; + diag_log format["_fnc_spawnMissionCrates: %1 = %2 with _foreachindex = %3",_params select _foreachindex, _this select _foreachindex, _foreachindex]; }forEach _this; }; #endif @@ -33,7 +34,11 @@ _cratesSpawned = []; { _x params["_crateType","_crateOffset","_lootArray","_lootCounts"]; //_pos = [(_coords select 0)+(_crateOffset select 0),(_coords select 1) + (_crateOffset select 1),(_coords select 2)+(_crateOffset select 2)]; // calculate the world coordinates - + private _xParams = ["_crateType","_crateOffset","_lootArray","_lootCounts"]; + { + private _item = _x; + //diag_log format["_fnc_spawnMissionCrates: _cratesToSpawn Loop| %1 = %2",_foreachindex, _item select _foreachindex]; + }forEach _x; _pos = _coords vectorAdd _crateOffset; _crate = [_pos,_crateType] call blck_fnc_spawnCrate; _crate setVariable["lootArray",_lootArray]; diff --git a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_spawnPendingMissions.sqf b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_spawnPendingMissions.sqf index 8229773..5ab4264 100644 --- a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_spawnPendingMissions.sqf +++ b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_spawnPendingMissions.sqf @@ -55,7 +55,10 @@ if (count _readyToSpawnQue > 0) then #ifdef blck_debugMode { - if (_foreachindex > 0) then {diag_log format["_fnc_spawnPendingMissions: _missionToSpawn %1 = %2",_foreachindex, _missionToSpawn select _foreachindex]}; + if (blck_debugLevel > 2) then + { + if (_foreachindex > 0) then {diag_log format["_fnc_spawnPendingMissions: _missionToSpawn %1 = %2",_foreachindex, _missionToSpawn select _foreachindex]}; + }; }forEach _missionToSpawn; #endif diff --git a/@GMS/addons/custom_server/Compiles/Units/GMS_fnc_spawnCharacter.sqf b/@GMS/addons/custom_server/Compiles/Units/GMS_fnc_spawnCharacter.sqf index eec398f..a1a6d02 100644 --- a/@GMS/addons/custom_server/Compiles/Units/GMS_fnc_spawnCharacter.sqf +++ b/@GMS/addons/custom_server/Compiles/Units/GMS_fnc_spawnCharacter.sqf @@ -12,11 +12,15 @@ params["_coords","_charConfigs"]; private["_char","_charGroup"]; _charConfigs params["_classname","_posn","_dir","_simDamg","_animations","_headgear","_uniforms"]; + +#ifdef blck_debugMode { diag_log format["_fnc_spawnchar: _forEachIndex = %1 | _x = %2",_forEachIndex,_x]; }forEach _charConfigs; diag_log format["_fnc_spawnchar: _this = %1",_this]; diag_log format["_fnc_spawnchar _classname = %1 | _posn = %2 | _dir = %3 | _animations = %4",_classname,_posn,_dir,_animations]; +#endif + _charGroup = createGroup [blck_AI_Side, true]; _char = _charGroup createUnit [_classname,[0,0,0], [], 0, "NONE"]; _char setCaptive true; @@ -30,7 +34,11 @@ if (count _uniforms > 0) then }; _posn = (_coords vectorAdd _posn); _char setPos [_posn select 0, _posn select 1, 0]; + +#ifdef blck_debugMode diag_log format["_fnc_spawnchar _char = %1 at Position = %2 | _coords = %3",_char, getPos _char,_coords]; +#endif + if (blck_modType isEqualTo "Epoch") then {_char setVariable ["LAST_CHECK",28800,true]}; _char setPos (_posn); _char setDir (_dir); diff --git a/@GMS/addons/custom_server/Compiles/Units/GMS_fnc_spawnParaUnits.sqf b/@GMS/addons/custom_server/Compiles/Units/GMS_fnc_spawnParaUnits.sqf index b866814..5eafb0e 100644 --- a/@GMS/addons/custom_server/Compiles/Units/GMS_fnc_spawnParaUnits.sqf +++ b/@GMS/addons/custom_server/Compiles/Units/GMS_fnc_spawnParaUnits.sqf @@ -25,7 +25,7 @@ private _params = ["_pos","_numAI","_skillAI"]; diag_log format["_fnc_spawnParaUnits: %1 = %2",_x, _this select _forEachIndex]; }forEach _params; _paraGroup = call blck_fnc_create_AI_Group; -diag_log format["_fnc_spawnParaUnits: _paraGroup = %1",_paraGroup]; +//diag_log format["_fnc_spawnParaUnits: _paraGroup = %1",_paraGroup]; // [_pos,_minDist,_maxDist,_groupSpawned,"random","SAD"] spawn blck_fnc_setupWaypoints; [_pos,20,30,_paraGroup,"random","SAD","paraUnits"] call blck_fnc_setupWaypoints; @@ -41,7 +41,11 @@ for "_i" from 1 to _numAI do [_chute] call blck_fnc_protectVehicle; // ["_pos","_aiGroup",["_skillLevel","red"],["_uniforms", blck_SkinList],["_headGear",blck_headgear],["_vests",blck_vests],["_backpacks",blck_backpacks],["_Launcher","none"],["_weaponList",[]],["_sideArms",[]],["_scuba",false]]; _unit = [getPos _chute,_paraGroup,_skillAI,_uniforms,_headGear,_vests,_backpacks,launcherType,_weapons] call blck_fnc_spawnUnit; + + #ifdef blck_debugMode diag_log format["_fnc_spawnParaUnits: unit %1 = %2 dropping in chute %3",_i,_unit,_chute]; + #endif + //_chute setPos [_spawnPos select 0, _spawnPos select 1, 125]; //(_offset select 2) - 10]; _unit assignAsDriver _chute; _unit moveInDriver _chute; diff --git a/@GMS/addons/custom_server/Missions/Green/default.sqf b/@GMS/addons/custom_server/Missions/Green/default.sqf index dbb39e1..a6b5cf3 100644 --- a/@GMS/addons/custom_server/Missions/Green/default.sqf +++ b/@GMS/addons/custom_server/Missions/Green/default.sqf @@ -37,7 +37,12 @@ _noVehiclePatrols = blck_SpawnVeh_Green; _noEmplacedWeapons = blck_SpawnEmplaced_Green; _uniforms = blck_SkinList; _headgear = blck_headgear; - +_chanceLoot = 0.6; +private _lootIndex = selectRandom[1,2,3,4]; +private _paralootChoices = [blck_contructionLoot,blck_contructionLoot,blck_highPoweredLoot,blck_supportLoot]; +private _paralootCountsChoices = [[0,0,0,8,8,0],[0,0,0,8,8,0],[8,8,0,0,0,0],[0,0,0,0,12,0]]; +_paraLoot = _paralootChoices select _lootIndex; +_paraLootCounts = _paralootCountsChoices select _lootIndex; // Throw in something more exotic than found at a normal blue mission. //_endCondition = "playerNear"; // Options are "allUnitsKilled", "playerNear", "allKilledOrPlayerNear" //_timeOut = -1; #include "\q\addons\custom_server\Compiles\Missions\GMS_fnc_missionSpawner.sqf"; diff --git a/@GMS/addons/custom_server/Missions/Green/medicalCamp.sqf b/@GMS/addons/custom_server/Missions/Green/medicalCamp.sqf index 20ea72c..d66a53b 100644 --- a/@GMS/addons/custom_server/Missions/Green/medicalCamp.sqf +++ b/@GMS/addons/custom_server/Missions/Green/medicalCamp.sqf @@ -56,7 +56,12 @@ _noVehiclePatrols = blck_SpawnVeh_Green; _noEmplacedWeapons = blck_SpawnEmplaced_Green; _uniforms = blck_SkinList; _headgear = blck_headgear; - +_chanceLoot = 1; //0.6; +private _lootIndex = selectRandom[1,2,3,4]; +private _paralootChoices = [blck_contructionLoot,blck_contructionLoot,blck_highPoweredLoot,blck_supportLoot]; +private _paralootCountsChoices = [[0,0,0,8,8,0],[0,0,0,8,8,0],[8,8,0,0,0,0],[0,0,0,0,12,0]]; +_paraLoot = _paralootChoices select _lootIndex; +_paraLootCounts = _paralootCountsChoices select _lootIndex; // Throw in something more exotic than found at a normal blue mission. //_endCondition = "playerNear"; // Options are "allUnitsKilled", "playerNear", "allKilledOrPlayerNear" //_timeOut = -1; #include "\q\addons\custom_server\Compiles\Missions\GMS_fnc_missionSpawner.sqf"; diff --git a/@GMS/addons/custom_server/Missions/Green/redCamp.sqf b/@GMS/addons/custom_server/Missions/Green/redCamp.sqf index d14547a..c85a57d 100644 --- a/@GMS/addons/custom_server/Missions/Green/redCamp.sqf +++ b/@GMS/addons/custom_server/Missions/Green/redCamp.sqf @@ -80,7 +80,12 @@ _noVehiclePatrols = blck_SpawnVeh_Green; _noEmplacedWeapons = blck_SpawnEmplaced_Green; _uniforms = blck_SkinList; _headgear = blck_headgear; - +_chanceLoot = 1; //0.6; +private _lootIndex = selectRandom[1,2,3,4]; +private _paralootChoices = [blck_contructionLoot,blck_contructionLoot,blck_highPoweredLoot,blck_supportLoot]; +private _paralootCountsChoices = [[0,0,0,8,8,0],[0,0,0,8,8,0],[8,8,0,0,0,0],[0,0,0,0,12,0]]; +_paraLoot = _paralootChoices select _lootIndex; +_paraLootCounts = _paralootCountsChoices select _lootIndex; // Throw in something more exotic than found at a normal blue mission. //_endCondition = "playerNear"; // Options are "allUnitsKilled", "playerNear", "allKilledOrPlayerNear" //_timeOut = -1; #include "\q\addons\custom_server\Compiles\Missions\GMS_fnc_missionSpawner.sqf"; diff --git a/@GMS/addons/custom_server/Missions/Green/resupplyCamp.sqf b/@GMS/addons/custom_server/Missions/Green/resupplyCamp.sqf index 52d609e..aa282b3 100644 --- a/@GMS/addons/custom_server/Missions/Green/resupplyCamp.sqf +++ b/@GMS/addons/custom_server/Missions/Green/resupplyCamp.sqf @@ -46,7 +46,12 @@ _noVehiclePatrols = blck_SpawnVeh_Green; _noEmplacedWeapons = blck_SpawnEmplaced_Green; _uniforms = blck_SkinList; _headgear = blck_headgear; - +_chanceLoot = 1; //0.6; +private _lootIndex = selectRandom[1,2,3,4]; +private _paralootChoices = [blck_contructionLoot,blck_contructionLoot,blck_highPoweredLoot,blck_supportLoot]; +private _paralootCountsChoices = [[0,0,0,8,8,0],[0,0,0,8,8,0],[8,8,0,0,0,0],[0,0,0,0,12,0]]; +_paraLoot = _paralootChoices select _lootIndex; +_paraLootCounts = _paralootCountsChoices select _lootIndex; // Throw in something more exotic than found at a normal blue mission. //_endCondition = "playerNear"; // Options are "allUnitsKilled", "playerNear", "allKilledOrPlayerNear" //_timeOut = -1; #include "\q\addons\custom_server\Compiles\Missions\GMS_fnc_missionSpawner.sqf"; diff --git a/@GMS/addons/custom_server/Missions/Orange/default.sqf b/@GMS/addons/custom_server/Missions/Orange/default.sqf index bcd4884..ad418e5 100644 --- a/@GMS/addons/custom_server/Missions/Orange/default.sqf +++ b/@GMS/addons/custom_server/Missions/Orange/default.sqf @@ -41,7 +41,7 @@ _headgear = blck_headgear; _chancePara = 0.5; // Setting this in the mission file overrides the defaults _noPara = 5; // Setting this in the mission file overrides the defaults _paraTriggerDistance = 400; // Distance from mission at which a player triggers these reinforcements and any supplemental loot. // To have paras spawn at the time the mission spawns with/without accompanying loot set this to 0. -_paraSkill = "orangered"; // Choose any skill you like; bump up skill or add AI to justify more valuable loot. +_paraSkill = "orange"; // Choose any skill you like; bump up skill or add AI to justify more valuable loot. _chanceLoot = 0.5; _paraLoot = blck_BoxLoot_Orange; diff --git a/@GMS/addons/custom_server/Missions/Orange/medicalCamp.sqf b/@GMS/addons/custom_server/Missions/Orange/medicalCamp.sqf index 595f4d2..08589b3 100644 --- a/@GMS/addons/custom_server/Missions/Orange/medicalCamp.sqf +++ b/@GMS/addons/custom_server/Missions/Orange/medicalCamp.sqf @@ -57,14 +57,17 @@ _useMines = blck_useMines; _uniforms = blck_SkinList; _headgear = blck_headgear; -_chancePara = 0.5; // Setting this in the mission file overrides the defaults +_chancePara = 0.75; // Setting this in the mission file overrides the defaults _noPara = 5; // Setting this in the mission file overrides the defaults _paraTriggerDistance = 400; // Distance from mission at which a player triggers these reinforcements and any supplemental loot. // To have paras spawn at the time the mission spawns with/without accompanying loot set this to 0. -_paraSkill = "orangered"; // Choose any skill you like; bump up skill or add AI to justify more valuable loot. +_paraSkill = "orange"; // Choose any skill you like; bump up skill or add AI to justify more valuable loot. -_chanceLoot = 0.5; -_paraLoot = blck_BoxLoot_Orange; -_paraLootCounts = blck_lootCountsOrange; // Throw in something more exotic than found at a normal blue mission. +_chanceLoot = 0.7; +private _lootIndex = selectRandom[1,2,3,4]; +private _paralootChoices = [blck_contructionLoot,blck_contructionLoot,blck_highPoweredLoot,blck_supportLoot]; +private _paralootCountsChoices = [[0,0,0,10,10,0],[0,0,0,10,10,0],[10,10,0,0,0,0],[0,0,0,0,15,0]]; +_paraLoot = _paralootChoices select _lootIndex; +_paraLootCounts = _paralootCountsChoices select _lootIndex; // Throw in something more exotic than found at a normal blue mission. //_endCondition = "playerNear"; // Options are "allUnitsKilled", "playerNear", "allKilledOrPlayerNear" ////_timeOut = -1; diff --git a/@GMS/addons/custom_server/Missions/Orange/redCamp.sqf b/@GMS/addons/custom_server/Missions/Orange/redCamp.sqf index f1a01e3..a45cdee 100644 --- a/@GMS/addons/custom_server/Missions/Orange/redCamp.sqf +++ b/@GMS/addons/custom_server/Missions/Orange/redCamp.sqf @@ -81,14 +81,17 @@ _noEmplacedWeapons = blck_SpawnEmplaced_Orange; _uniforms = blck_SkinList; _headgear = blck_headgear; -_chancePara = 0.5; // Setting this in the mission file overrides the defaults +_chancePara = 0.75; // Setting this in the mission file overrides the defaults _noPara = 5; // Setting this in the mission file overrides the defaults _paraTriggerDistance = 400; // Distance from mission at which a player triggers these reinforcements and any supplemental loot. // To have paras spawn at the time the mission spawns with/without accompanying loot set this to 0. -_paraSkill = "orangered"; // Choose any skill you like; bump up skill or add AI to justify more valuable loot. +_paraSkill = "orange"; // Choose any skill you like; bump up skill or add AI to justify more valuable loot. -_chanceLoot = 0.5; -_paraLoot = blck_BoxLoot_Orange; -_paraLootCounts = blck_lootCountsOrange; // Throw in something more exotic than found at a normal blue mission. +_chanceLoot = 1; //0.7; +private _lootIndex = selectRandom[1,2,3,4]; +private _paralootChoices = [blck_contructionLoot,blck_contructionLoot,blck_highPoweredLoot,blck_supportLoot]; +private _paralootCountsChoices = [[0,0,0,10,10,0],[0,0,0,10,10,0],[10,10,0,0,0,0],[0,0,0,0,15,0]]; +_paraLoot = _paralootChoices select _lootIndex; +_paraLootCounts = _paralootCountsChoices select _lootIndex; // Throw in something more exotic than found at a normal blue mission. //_endCondition = "playerNear"; // Options are "allUnitsKilled", "playerNear", "allKilledOrPlayerNear" ////_timeOut = -1; diff --git a/@GMS/addons/custom_server/Missions/Orange/resupplyCamp.sqf b/@GMS/addons/custom_server/Missions/Orange/resupplyCamp.sqf index 28c96aa..5158a3b 100644 --- a/@GMS/addons/custom_server/Missions/Orange/resupplyCamp.sqf +++ b/@GMS/addons/custom_server/Missions/Orange/resupplyCamp.sqf @@ -48,14 +48,17 @@ _noEmplacedWeapons = blck_SpawnEmplaced_Orange; _uniforms = blck_SkinList; _headgear = blck_headgear; -_chancePara = 0.5; // Setting this in the mission file overrides the defaults +_chancePara = 0.75; // Setting this in the mission file overrides the defaults _noPara = 5; // Setting this in the mission file overrides the defaults _paraTriggerDistance = 400; // Distance from mission at which a player triggers these reinforcements and any supplemental loot. // To have paras spawn at the time the mission spawns with/without accompanying loot set this to 0. -_paraSkill = "orangered"; // Choose any skill you like; bump up skill or add AI to justify more valuable loot. +_paraSkill = "orange"; // Choose any skill you like; bump up skill or add AI to justify more valuable loot. -_chanceLoot = 0.5; -_paraLoot = blck_BoxLoot_Orange; -_paraLootCounts = blck_lootCountsOrange; // Throw in something more exotic than found at a normal blue mission. +_chanceLoot = 0.7; +private _lootIndex = selectRandom[1,2,3,4]; +private _paralootChoices = [blck_contructionLoot,blck_contructionLoot,blck_highPoweredLoot,blck_supportLoot]; +private _paralootCountsChoices = [[0,0,0,10,10,0],[0,0,0,10,10,0],[10,10,0,0,0,0],[0,0,0,0,15,0]]; +_paraLoot = _paralootChoices select _lootIndex; +_paraLootCounts = _paralootCountsChoices select _lootIndex; // Throw in something more exotic than found at a normal blue mission. _endCondition = "playerNear"; // Options are "allUnitsKilled", "playerNear", "allKilledOrPlayerNear" //_timeOut = -1; diff --git a/@GMS/addons/custom_server/Missions/Red/redCamp.sqf b/@GMS/addons/custom_server/Missions/Red/redCamp.sqf index e2e096d..be7a502 100644 --- a/@GMS/addons/custom_server/Missions/Red/redCamp.sqf +++ b/@GMS/addons/custom_server/Missions/Red/redCamp.sqf @@ -26,6 +26,7 @@ _markerColor = "ColorRed"; _markerMissionName = "Bandit Camp"; _missionLandscapeMode = "precise"; // acceptable values are "none","random","precise" _missionLandscape = [ + ["Flag_AAF_F",[-1,-1,0],0,[false,false]], ["Land_CampingChair_V1_F",[1.32227,2.07813,8.2016e-005],108.293,[false,false]], ["Land_CampingChair_V1_F",[-2.01465,2.91992,3.05176e-005],236.049,[false,false]], ["FirePlace_burning_F",[0.0302734,4.26563,2.47955e-005],359.997,[false,false]], diff --git a/changeLog.sqf b/changeLog.sqf index d6e4471..3c3bbb2 100644 --- a/changeLog.sqf +++ b/changeLog.sqf @@ -8,7 +8,7 @@ Ideas or code from that by Vampire and KiloSwiss have been used for certain func Significant Changes: ===================== -Version 1.81 Build 127 (EXPERIMENTAL). +Version 1.81 Build 126 (EXPERIMENTAL). Added: Support for hostage rescue missions. The hostage can be spawned at any location relative to the mission center. The mission aborts if the hostage is killed; all loot is deleted. @@ -77,6 +77,9 @@ Changed: Code for Heli Patrols redone. Changed: Methods for detecting NULL Groups (rarely a problem with arma these days) simplified. GMS_fnc_missionSpawner redone using a single test for the _abort flag to save repeated calls for debugging and endMission. This could be done with try/catch as well. + +Changed: Methods for defining mission crate loot were relaxed. + You can define each item either with the old method ["Item Name", minimun number, maximum number] or just "Item name". Fixed: disabled some logging that is not required except when debugging. Fixed: AI Counts were not being shown at dynamic UMS.