diff --git a/@GMS/addons/GMS/Compiles/Functions/fn_createMissionMarkers.sqf b/@GMS/addons/GMS/Compiles/Functions/fn_createMissionMarkers.sqf index 1f9113f..048829b 100644 --- a/@GMS/addons/GMS/Compiles/Functions/fn_createMissionMarkers.sqf +++ b/@GMS/addons/GMS/Compiles/Functions/fn_createMissionMarkers.sqf @@ -12,14 +12,15 @@ private "_markers"; params[ - "_markerName", // the name used when creating the marker. Must be unique. - "_markerPos", - "_markerLabel", // Text used to label the marker - "_markerColor", - "_markerType", // Use either the name of the icon or "ELLIPSE" or "RECTANGLE" where non-icon markers are used + ["_markerName","NoNameGiven"], // the name used when creating the marker. Must be unique. + ["_markerPos",[0,0]], + ["_markerLabel","NoLabelGiven"], // Text used to label the marker + ["_markerColor","NoColorGiven"], + ["_markerType","NoTypeGiven"], // Use either the name of the icon or "ELLIPSE" or "RECTANGLE" where non-icon markers are used ["_markerSize",[0,0]], - ["_markerBrush","GRID"], - ["_showMarkers",true] + ["_markerBrush","NoBrushGiven"], + ["_showMarkers",true], + ["_missionFile","NoFilenameProvided"] ]; if (GMS_debugLevel > 3) then @@ -35,37 +36,58 @@ if (GMS_debugLevel > 3) then ]; for "_i" from 0 to ((count _this) - 1) do { - diag_log format["_fnc_createMarker: parameter %1 = %2",_pList select _i,_this select _i]; + diag_log format["_fnc_createMarker: _missionFile %1 | parameter %2 = %3",_missionFile,_pList select _i,_this select _i]; }; }; -if (toUpper(_markerType) in ["ELLIPSE","RECTANGLE"]) then // not an Icon .... +private _markerError = false; +if !(toLowerANSI (_markerType) in ["ellipse","rectangle"] || {isClass(configFile >> "CfgMarkers" >> _markerType)} ) then { - private _m = createMarker [GMS_missionMarkerRootName + _markerName,_markerPos]; - If (_showMarkers) then { - _m setMarkerShape _markerType; - _m setMarkerColor _markerColor; - _m setMarkerBrush _markerBrush; - _m setMarkerSize _markerSize; - }; - private _m2 = createMarker [GMS_missionMarkerRootName + _markerName + "label", _markerPos]; - if (_showMarkers) then { - _m2 setMarkerType "loc_destroy"; - _m2 setMarkerColor "ColorWhite"; - _m2 setMarkerText _markerLabel; - }; - _markers = [_m,_m2]; - //diag_log format["_fnc_createMarkers: case of ELLIPSE/RECTANGLE: _markers = %1",_markers]; -} else { - private _m = ""; - private _m2 = createMarker [GMS_missionMarkerRootName + _markerName + "label", _markerPos]; - if (_showMarkers) then { - _m2 setMarkerType _markerType; - _m2 setMarkerColor _markerColor; - _m2 setMarkerText _markerLabel; - }; - _markers = [_m,_m2]; - //diag_log format["_fnc_createMarkers: case of ICON: _markers = %1",_markers]; + [format["_markerType set to 'ELLIPSE': Illegal marker type %1 used for mission %2 of difficulty %3",_markerType,_markerMissionName,_difficulty],"warning"] call GMS_fnc_log; + _markerType = "ELLIPSE"; + _markerSize = [200,200]; + _markerBrush = "GRID"; + _markerError = true; }; +if !(isClass(configFile >> "CfgMarkerColors" >> _markerColor)) then +{ + [format["_markerColor set to 'default': Illegal color %1 used for mission %2 of difficulty %3",_markerColor,_markerMissionName,_difficulty],"warning"] call GMS_fnc_log; + _markerColor = "DEFAULT"; + _markerError = true; +}; + +private _markers = [];; +if (_showMarkers) then { + if (toUpper(_markerType) in ["ELLIPSE","RECTANGLE"]) then // not an Icon .... + { + private _m = createMarker [GMS_missionMarkerRootName + _markerName,_markerPos]; + If (_showMarkers) then { + _m setMarkerShape _markerType; + _m setMarkerColor _markerColor; + _m setMarkerBrush _markerBrush; + _m setMarkerSize _markerSize; + }; + + private _m2 = createMarker [GMS_missionMarkerRootName + _markerName + "label", _markerPos]; + if (_showMarkers) then { + _m2 setMarkerType "loc_destroy"; + _m2 setMarkerColor "ColorWhite"; + _m2 setMarkerText _markerLabel; + }; + _markers = [_m,_m2]; + } else { + private _m = ""; + private _m2 = createMarker [GMS_missionMarkerRootName + _markerName + "label", _markerPos]; + if (_showMarkers) then { + _m2 setMarkerType _markerType; + _m2 setMarkerColor _markerColor; + _m2 setMarkerText _markerLabel; + }; + _markers = [_m,_m2]; + + }; +} else { + _markers = ["",""]; +}; _markers \ No newline at end of file diff --git a/@GMS/addons/GMS/Compiles/Missions/GMS_fnc_missionSpawner.sqf b/@GMS/addons/GMS/Compiles/Missions/GMS_fnc_missionSpawner.sqf index 9909333..4909860 100644 --- a/@GMS/addons/GMS/Compiles/Missions/GMS_fnc_missionSpawner.sqf +++ b/@GMS/addons/GMS/Compiles/Missions/GMS_fnc_missionSpawner.sqf @@ -96,7 +96,7 @@ if !(isNil "_difficulty") then {_aiDifficultyLevel = _difficulty}; if (isNil "_timeoutMsg") then {_timeoutMsg = ""}; if (isNil "_showMarker") then {_showMarker = true}; -_markerType params["_markerType",["_markersize",[250,250]],["_markerBrush","GRID"]]; +_markerType params["_markerShape",["_markersize",[250,250]],["_markerBrush","GRID"]]; private _paraSkill = _aiDifficultyLevel; @@ -119,7 +119,7 @@ if !(_endCondition in GMS_validEndStates) then private _markerConfigs = [ _markerLabel, _markerMissionName, // Name used for setMarkerText and also for the root name for all markers - _markerType, + _markerShape, _markerColor, _markerSize, _markerBrush, diff --git a/@GMS/addons/GMS/Compiles/Missions/fn_addMIssionToQue.sqf b/@GMS/addons/GMS/Compiles/Missions/fn_addMIssionToQue.sqf index c206a95..583f25c 100644 --- a/@GMS/addons/GMS/Compiles/Missions/fn_addMIssionToQue.sqf +++ b/@GMS/addons/GMS/Compiles/Missions/fn_addMIssionToQue.sqf @@ -24,11 +24,12 @@ if (_isStatic) then { //diag_log format["_addMissionToQue: _waitTime = %1",_waitTime]; +private "_missionFile"; private _missionsData = []; // Parameters definine each of the missions for this difficulty are stored as arrays here. { - private _missionFile = format["\GMS\Missions\%1\%2.sqf",_path,_x]; - //diag_log format["_addMissionToQue: _missionFile = %1",_missionFile]; + _missionFile = format["\GMS\Missions\%1\%2.sqf",_path,_x]; + if (GMS_debugLevel > 0) then {[format["_addMissionToQue: adding %1 mission with fileName %2",_difficulty,_missionFile]] call GMS_fnc_log}; private _missionCode = compileFinal preprocessFileLinenumbers _missionFile;//return all of the values that define how the mission is spawned as an array of values if !(isNil "_missionCode") then { @@ -54,7 +55,8 @@ private _missions = [ _tMax, // as above _waitTime, // time at which a mission should be spawned _missionsData, // Array of data about individual missions that could be spawned. The data table for each mission is defined in _missionSpawner - _isStatic + _isStatic, + _missionFile ]; //diag_log format["_addMissionToQue (55): _missions = %1",_missions]; GMS_missionData pushBack _missions; diff --git a/@GMS/addons/GMS/Compiles/Missions/fn_initializeMission.sqf b/@GMS/addons/GMS/Compiles/Missions/fn_initializeMission.sqf index 65d1b7b..e298896 100644 --- a/@GMS/addons/GMS/Compiles/Missions/fn_initializeMission.sqf +++ b/@GMS/addons/GMS/Compiles/Missions/fn_initializeMission.sqf @@ -2,14 +2,7 @@ GMS_fnc_initializeMission Perform all functions necessary to initialize a mission. - A marker is created and mission info is added to GMS_initializedMissionsList - - [_mrkr,_difficulty,_m] call GMS_fnc_initializeMission; - Returns one of the following values: - 0 - this is a static mission that has been spawned and has not been completed - 1 - the mission was successfully initialized at _coords != [0,0,0] - 2 - the mission has been run the maximum allowed times. */ #include "\GMS\Compiles\Init\GMS_defines.hpp" @@ -19,7 +12,8 @@ params[ "_key", // This key can be used to seach the list of available mission types to update that list when a mission is completed or times out "_missionConfigs", // Selfevident but this is an array with all configs for the mission "_missionCount", // The number of missions run thus far which is used to unsure each marker has a unique name - "_isStatic" + "_isStatic", + "_missionFile" ]; // _missionConfigs is configured as: @@ -59,176 +53,224 @@ params[ "_spawnedAt" // index 13 ]; -// do not initialize if the odds of spawning are not favorable. -if (random(1) > _chanceMissionSpawned) exitWith { - diag_log format["_initializeMission (27): returning value of -1"]; - -1 -}; -// If the mission has already been spawned the max number of times, pass back a code indicating that. -if (!(_maxMissionRespawns == -1) && (_timesSpawned > _maxMissionRespawns)) exitWith { - diag_log format["_initializeMission (32): returning value of -2"]; - -2 -}; -// If the mission has not been spawned, but is a static mission and could be spawned if it met the test for chance of a spawn, pass back a code indicating that. -if (random(1) > _chanceMissionSpawned && (_isStatic) && (_timesSpawned == 0)) exitWith { - diag_log format["_initializeMission (37): returning value of 2"]; - 2 -}; -// If the mission is a static mission and it has been spawned but not cleared then pass back a code indicating that -if (_isStatic && _isSpawned) exitWith { - diag_log format["_initializeMission (42): returning value of 3"]; - 3 -}; - #define timesSpawnedIndex 11 +private _initialized = 0; -_markerConfigs params[ - "_markerName", // The unique text identifier for the marker - "_markerMissionName", // Name used for setMarkerText - does not need to be unique - "_markerType", - "_markerColor", - "_markerSize", - "_markerBrush", - "_showMarkers" +private _markers = []; +/* +private _markerConfigs = [ + _markerLabel, + _markerMissionName, // Name used for setMarkerText and also for the root name for all markers + _markerShape, + _markerColor, + _markerSize, + _markerBrush, + _showMarker +]; +*/ +_markerConfigs params [ + ["_markerLabel","NoLabelGiven"], // Text used to label the marker + ["_markerMissionName","NoNameGiven"], // the name used when creating the marker. Must be unique. + ["_markerShape","NoTypeGiven"], // Use either the name of the icon or "ELLIPSE" or "RECTANGLE" where non-icon markers are used + ["_markerColor","NoColorGiven"], + ["_markerSize",[0,0]], + ["_markerBrush","NoBrushGiven"], + ["_showMarkers",true] ]; -//[format["_initializeMission (39): _markerName %1 | _key %2 | _missionCount %3 | _maxMissionRespawns %4 | _timesSpawned %5",_markerName,_key,_missionCount,_maxMissionRespawns,_timesSpawned]] call GMS_fnc_log; +try { + if (GMS_debugLevel > 0) then {[format["_initializeMission (82): _timesSpawned %1 | _maxMissionRespawns %2",_timesSpawned,_maxMissionRespawns]] call GMS_fnc_log}; + if (_timesSpawned >= _maxMissionRespawns && !(_maxMissionRespawns == -1)) throw -2; -private _initialized = 0; -/* + // If the mission is a static mission and it has been spawned but not cleared then pass back a code indicating that + if (_isStatic && _isSpawned) throw 3; // We do not want to respawn this static mission till it has been cleared. + + // If the mission has not been spawned, but is a static mission and could be spawned if it met the test for chance of a spawn, pass back a code indicating that. + if (random(1) > _chanceMissionSpawned && (_isStatic) && (_timesSpawned == 0)) throw 2; -*/ -_coordsArray = []; -if !(_defaultMissionLocations isEqualTo []) then -{ - _coords = selectRandom _defaultMissionLocations; -} else { - if (_isScubaMission) then + // do not initialize if the odds of spawning are not favorable. + if (random(1) > _chanceMissionSpawned) throw 0; + + /* + private _labels = ["_markerLabel","_markerMissionName","_markerShape","_markerColor","_markerSize","_markerBrush","_showMarkers"]; { - _coords = [] call GMS_fnc_findShoreLocation; + [format["_initializeMission (95): _markerConfigs index %1 | name %2 = %3",_forEachIndex, _labels select _forEachIndex, _x]] call GMS_fnc_log; + } forEach _markerConfigs; + */ + // [format["initializeMission (100): _markerShape = %1",_markerShape]] call GMS_fnc_log; + if (_markerMissionName isEqualTo "NoNameGiven") throw -1; // This is a FATAL ERROR + + if !(toLowerANSI (_markerShape) in ["ellipse","rectangle"] || {isClass(configFile >> "CfgMarkers" >> _markerShape)} ) then + { + [format["_markerShape set to 'ELLIPSE': Illegal marker type %1 used for _missionFile %2",_markerShape,_missionFile,_difficulty],"warning"] call GMS_fnc_log; + _markerShape = GMS_defaultMarkerType; + _markerSize = GMS_defaultMarkerSize; + _markerBrush = GMS_defaultMarkerBrush; + }; + + if !(isClass(configFile >> "CfgMarkerColors" >> _markerColor)) then + { + [format["_markerColor set to 'default': Illegal color %1 used for mission %2 of difficulty %3",_markerColor,_missionFile,_difficulty],"warning"] call GMS_fnc_log; + _markerColor = "NoColorGiven"; + }; + + if (_markerLabel isEqualTo "NoLabelGiven") then { + [format["No Marker Text (_markerLabel) defined for mission %1",_missionFile],'warning'] call GMS_fnc_log; + // Probably not a fatal error but it will look funny on the server + }; + if (_markerColor isEqualTo "NoColorGiven") then { + [format["No Marker Color (_markerColor) defined for mission %1 SO GMS_defaultMarkerColor used instead",_missionFile],'warning'] call GMS_fnc_log; + // Probably not FATAL but will apply a Default Color anyhow + _markerColor = GMS_defaultMarkerColor; + }; + if (_markerShape isEqualTo "NoTypeGiven") then { + [format["No Marker Type (triangle, mil_dot) or Shape ('Elipse', 'Rectangle') defined for mission %1 SO default setting GMS_defaultMarkerType used",_missionFile],'warning'] call GMS_fnc_log; + // Apply a default setting here + _markerShape = GMS_defaultMarkerType; + }; + if !(_markerSize isEqualTypeArray [0,0]) then { + [format["_markerSize = %1 BUT must be given as an array of [xsize, ysize] SO defaults of GMS_defaultMarkerSize were used for mission file %1",_markerSize,_missionFile],'warning'] call GMS_fnc_log; + _markerSize = GMS_defaultMarkerSize; + // Just alert the server scripter of the problem and apply a default. + }; + + if (toUpper(_markerShape) in ["ELLIPSE","RECTANGLE"] && (_markerBrush isEqualTo "NoBrushGiven" || !(isClass(configFile >> "CfgMarkerBrushes" >> _markerBrush)))) then { + [format["_markerBrush not defined for shaped marker in mission %1 SO default of GMS_defaultMarkerBrush used"],'warning'] call GMS_fnc_log; + _markerBrush = GMS_defaultMarkerBrush; + }; + + _coordsArray = []; + if !(_defaultMissionLocations isEqualTo []) then + { + _coords = selectRandom _defaultMissionLocations; } else { - _coords = [] call GMS_fnc_findSafePosn; - _coords = [_coords select 0, _coords select 1, 0]; + if (_isScubaMission) then + { + _coords = [] call GMS_fnc_findShoreLocation; + } else { + _coords = [] call GMS_fnc_findSafePosn; + _coords = [_coords select 0, _coords select 1, 0]; + }; + }; + + _missionConfigs set[timesSpawnedIndex, _timesSpawned + 1]; + _missionConfigs set[isSpawned, true]; + _missionConfigs set[spawnedAt, diag_tickTime]; + + if (_coords isEqualTo [] || {_coords isEqualTo [0,0,0]}) throw -2; + + if (GMS_debugLevel > 0) then {[format["Initializing mission: _coords = %1 | _markerMissionName %2 | _missionFile = %3",_coords,_markerMissionName,_missionFile]] call GMS_fnc_log}; + + GMS_ActiveMissionCoords pushback _coords; + GMS_missionsRunning = GMS_missionsRunning + 1; + + private _markers = []; + + /* + Handle map markers + */ + + private "_markerPos"; + if (GMS_labelMapMarkers select 0) then + { + _markerPos = _coords; + }; + if !(GMS_preciseMapMarkers) then + { + _markerPos = [_coords,75] call GMS_fnc_randomPosition; + }; + + // _markers holds the two markers generated for the mission. + // The first can be "" if the marker type used is an icon such as a triangle. + // The second is always an icon which may have a label. + _markers = [ + format["%1:%2",_markerMissionName,_missionCount], + _markerPos, + _markerMissionName, + _markerColor, + _markerShape, + _markerSize, + _markerBrush, + _showMarkers, + _missionFile + ] call GMS_fnc_createMissionMarkers; + + if (_markers isEqualTo []) throw -1; // Something happened when creating markers so alert the server scripter. + /* + Send a message to players. + */ + _missionMessages params [ + "_assetKilledMsg", + "_endMsg", + "_timeoutMsg", + "_startMsg" + ]; + + [["start",_startMsg,_markerMissionName]] call GMS_fnc_messageplayers; + + #define missionTimeoutAt (diag_tickTime + GMS_MissionTimeout) + #define triggered 0 + #define objects [] + #define hiddenObjects [] + #define mines [] + #define crates [] + #define missionVehicles [] + #define missionAI [] + #define lootVehicles [] + #define assetSpawned objNull + + private _missionData = [ + _coords, // index 0 + mines, // index 1 + objects, // index 2 + hiddenObjects, // index 3 + crates, // index 4 + missionAI, // index 5 + assetSpawned, /// Used for missions for which a hostage or target is spawned. + missionVehicles, // index 7 + lootVehicles, // index 8 + _markers // index 9 + ]; + + #define spawnPara -1 + GMS_initializedMissionsList pushBack [_key, missionTimeoutAt, triggered, _missionData, _missionConfigs, spawnPara,_isStatic,_missionFile]; + + // Repair any damage done by prior activities. + {_x setDamage 0} forEach ( nearestObjects [_coords, ["Building"], 500]); + throw 1; // Normal script termination +} + +catch { + switch (_exception) do { + + case -3: { + [format["No Safe Mission Spawn Position Found to spawn Mission %1",_missionFile],'warning'] call GMS_fnc_log; + _initialized = -3; + }; + + case -2: { // The mission was spawned the maximum number of times. + [format["Mission %1 has been spawn the maximum allowable number of times",_missionFile]] call GMS_fnc_log; + _initialized = -2; + }; + + case -1: { // A fatal error in marker configs was found or GMS_fnc_createMissionMarkers did not create any for some reason. + _initialized = -1; + }; + + case 0: { // The mission failed the test for chance it would be spawned. + _initialized = 0; + }; + + case 1: { // The marker was configured in a legal way and a safe position was found to spawn it. + _initialized = 1; + }; + case 2: { // This static mission failed the test for chance that it would be spawned. + _initialized = 2; + }; + case 3: { // Case of a static mission that has already been spawned. + _initialized = 3; + }; }; }; -_missionConfigs set[timesSpawnedIndex, _timesSpawned + 1]; -_missionConfigs set[isSpawned, true]; -_missionConfigs set[spawnedAt, diag_tickTime]; - -if (_coords isEqualTo [] || {_coords isEqualTo [0,0,0]}) exitWith -{ - [format["No Safe Mission Spawn Position Found to spawn Mission %1",_markerMissionName],'warning'] call GMS_fnc_log; - // _initialized should be == 0 here - _initialized -}; - -GMS_ActiveMissionCoords pushback _coords; -GMS_missionsRunning = GMS_missionsRunning + 1; -//[format["_initializeMission (118): _coords = %1 | GMS_missionsRunning = %2",_coords,GMS_missionsRunning]] call GMS_fnc_log; - -private _markers = []; - -/* - Handle map markers -*/ - -private "_markerPos"; -if (GMS_labelMapMarkers select 0) then -{ - _markerPos = _coords; -}; -if !(GMS_preciseMapMarkers) then -{ - _markerPos = [_coords,75] call GMS_fnc_randomPosition; -}; - -/* -{ - diag_log format["_initializeMission (95) %1 = %2",_x,_markerConfigs select _forEachIndex]; -} forEach [ - "_markerType", - "_markerColor", - "_markerSize", - "_markerBrush" -]; -*/ - -private _markerError = false; -if !(toLowerANSI (_markerType) in ["ellipse","rectangle"] || {isClass(configFile >> "CfgMarkers" >> _markerType)} ) then -{ - [format["_markerType set to 'ELLIPSE': Illegal marker type %1 used for mission %2 of difficulty %3",_markerType,_markerMissionName,_difficulty],"warning"] call GMS_fnc_log; - _markerType = "ELLIPSE"; - _markerSize = [200,200]; - _markerBrush = "GRID"; - _markerError = true; -}; - -if !(isClass(configFile >> "CfgMarkerColors" >> _markerColor)) then -{ - [format["_markerColor set to 'default': Illegal color %1 used for mission %2 of difficulty %3",_markerColor,_markerMissionName,_difficulty],"warning"] call GMS_fnc_log; - _markerColor = "DEFAULT"; - _markerError = true; -}; - -// _markers holds the two markers generated for the mission. -// The first can be "" if the marker type used is an icon such as a triangle. -// The second is always an icon which may have a label. -private _markers = [ - format["%1:%2",_markerName,_missionCount], - _markerPos, - _markerMissionName, - _markerColor, - _markerType, - _markerSize, - _markerBrush, - _showMarkers -] call GMS_fnc_createMissionMarkers; - -//if (GMS_debugLevel >= 0) then {[format["_initializeMission (130): _marker = %1 | _markerMissionName = %2 | _difficulty = %3",_markers,_markerMissionName,_difficulty]] call GMS_fnc_log}; - -/* - Send a message to players. -*/ -_missionMessages params [ - "_assetKilledMsg", - "_endMsg", - "_timeoutMsg", - "_startMsg" -]; - -[["start",_startMsg,_markerMissionName]] call GMS_fnc_messageplayers; - -#define missionTimeoutAt (diag_tickTime + GMS_MissionTimeout) -#define triggered 0 -#define objects [] -#define hiddenObjects [] -#define mines [] -#define crates [] -#define missionVehicles [] -#define missionAI [] -#define lootVehicles [] -#define assetSpawned objNull - -private _missionData = [ - _coords, // index 0 - mines, // index 1 - objects, // index 2 - hiddenObjects, // index 3 - crates, // index 4 - missionAI, // index 5 - assetSpawned, /// Used for missions for which a hostage or target is spawned. - missionVehicles, // index 7 - lootVehicles, // index 8 - _markers // index 9 -]; - -#define spawnPara -1 -GMS_initializedMissionsList pushBack [_key, missionTimeoutAt, triggered, _missionData, _missionConfigs, spawnPara,_isStatic]; - -// Repair any damage done by prior activities. -{_x setDamage 0} forEach ( nearestObjects [_coords, ["Building"], 500]); - -//[format["_initializeMission (163): count GMS_initializedMissionsList = %1",count GMS_initializedMissionsList]] call GMS_fnc_log; -_initialized = 1; _initialized \ No newline at end of file diff --git a/@GMS/addons/GMS/Compiles/Missions/fn_monitorInitializedMissions.sqf b/@GMS/addons/GMS/Compiles/Missions/fn_monitorInitializedMissions.sqf index ce7efb9..ca565aa 100644 --- a/@GMS/addons/GMS/Compiles/Missions/fn_monitorInitializedMissions.sqf +++ b/@GMS/addons/GMS/Compiles/Missions/fn_monitorInitializedMissions.sqf @@ -35,30 +35,33 @@ for "_i" from 1 to (count _missionsList) do "_missionData", // 4 // variable containing information specific to this instance of the mission such as location and objects "_missionConfigs", // 5 // Variables regarding the configuration of the dynamic mission "_spawnPara", // - "_isStatic" // 7 // A flag as to whether the mission is a static or dynamically spawned mission. + "_isStatic", // 7 // A flag as to whether the mission is a static or dynamically spawned mission. + "_missionFile" ]; #define triggered 2 - #define missionCoords (_missionData select 0) + private _missionCoords = (_missionData select 0); #define delayTime 1 if !(_triggered == 0) then { _missionsList pushBack _el; } else { - private _playerInRange = if ({(_x distance2d missionCoords) < GMS_TriggerDistance /*&& ((vehicle _x == _x) || (getPosATL _x) select 2 < 5)*/} count allPlayers > 0) then {true} else {false}; + try { + if (!(_missionCoords isEqualTypeArray [0,0,0]) || _missionCoords isEqualTo [0,0,0]) throw -3; + private _playerInRange = if ({(_x distance2d _missionCoords) < GMS_TriggerDistance /*&& ((vehicle _x == _x) || (getPosATL _x) select 2 < 5)*/} count allPlayers > 0) then {true} else {false}; switch (true) do { case ((_missionTimeoutAt > 0) && {diag_tickTime > _missionTimeoutAt && !(_isStatic)}): { - diag_log format["_monitorInitializedMissions (37) Mission Timeout Criteria Met at %1",diag_tickTime]; + if (GMS_debugLevel > 0) then {diag_log format["_monitorInitializedMissions (37) Mission Timeout Criteria Met at %1 for mission %2",diag_tickTime,_missionFile]}; throw -1; }; case (_playerInRange): { - diag_log format["_monitorInitializedMissions (52) Player in range criteria met at %1 for _key %2",diag_tickTime,_key]; + if (GMS_debugLevel > 0) then {diag_log format["_monitorInitializedMissions (52) Player in range criteria met at %1 for _missionFile %2",diag_tickTime,_missionFile]}; throw 0; }; case (GMS_debugLevel >= 3): { - [format["_monitorInitializedMissions (54): mission triggered for GMS_debugLevel = %1",GMS_debugLevel]] call GMS_fnc_log; + [format["_monitorInitializedMissions (54): mission triggered for GMS_debugLevel = %1 for _missionFile %2",GMS_debugLevel,_missionFile]] call GMS_fnc_log; throw 0; }; // simulate the mission being tripped by a player default { @@ -72,6 +75,9 @@ for "_i" from 1 to (count _missionsList) do //[format["_monitorInitializeMissions (69): diag_tickTime %1 | _missionTimeoutAt %2 | _exception %3",diag_tickTime,_missionTimeoutAt,_exception]] call GMS_fnc_log; switch (_exception) do { + case -3: { + [format["Unable to initialize Mission in _monitorInitializedMissions because an illeagal value was passed for _missionCoords of %1 for _missionFile %2",_missionCoords,_missionFile],'warning'] call GMS_fnc_log; + }; // Nothing needs to be done case -2 : { _missionsList pushBack _el; diff --git a/@GMS/addons/GMS/Compiles/Missions/fn_monitorSpawnedMissions.sqf b/@GMS/addons/GMS/Compiles/Missions/fn_monitorSpawnedMissions.sqf index 5baa881..967bdc4 100644 --- a/@GMS/addons/GMS/Compiles/Missions/fn_monitorSpawnedMissions.sqf +++ b/@GMS/addons/GMS/Compiles/Missions/fn_monitorSpawnedMissions.sqf @@ -31,7 +31,8 @@ for "_i" from 1 to (count _missionsList) do "_missionData", // 4 // variable containing information specific to this instance of the mission such as location and objects "_missionConfigs", // 5 // Variables regarding the configuration of the dynamic mission "_spawnPara", - "_isStatic" + "_isStatic", + "_missionFile" ]; #define triggered 2 #define spawnPara 5 diff --git a/@GMS/addons/GMS/Compiles/Missions/fn_spawnMissionAssets.sqf b/@GMS/addons/GMS/Compiles/Missions/fn_spawnMissionAssets.sqf index 4ebd093..5c1118f 100644 --- a/@GMS/addons/GMS/Compiles/Missions/fn_spawnMissionAssets.sqf +++ b/@GMS/addons/GMS/Compiles/Missions/fn_spawnMissionAssets.sqf @@ -211,7 +211,6 @@ if !(_garrisonedBuildings_BuildingPosnSystem isEqualTo []) then ["_sideArms",[]]]; */ private _userelativepos = true; -//private _numberEmplacedWeaponsThisMission = [_noEmplacedWeapons] call GMSCore_fnc_getNumberFromRange; if (GMS_useStatic && !(_missionEmplacedWeapons isEqualTo [])) then { @@ -221,6 +220,8 @@ if (GMS_useStatic && !(_missionEmplacedWeapons isEqualTo [])) then _missionInfantry append _units; uisleep delayTime; } else { + + // GMSCore_fnc_getNumberFromRange returns -1 if there was an issue. if (([_noEmplacedWeapons] call GMSCore_fnc_getNumberFromRange) > 0) then { private _wepPositions = [_coords,_noEmplacedWeapons,35,50] call GMS_fnc_findPositionsAlongARadius; private _emplacedWeaponsRandom = []; @@ -258,7 +259,6 @@ if !(_missionLootVehicles isEqualTo []) then ["_crewCount",4] ]; */ -private _noPatrols = [_noVehiclePatrols] call GMSCore_fnc_getNumberFromRange; if (GMS_useVehiclePatrols && {!(_missionPatrolVehicles isEqualTo [])}) then { @@ -268,6 +268,8 @@ if (GMS_useVehiclePatrols && {!(_missionPatrolVehicles isEqualTo [])}) then _missionInfantry append _units; uiSleep delayTime; } else { + // GMSCore_fnc_getNumberFromRange returns -1 if there was an issue. + private _noPatrols = [_noVehiclePatrols] call GMSCore_fnc_getNumberFromRange; if (GMS_useVehiclePatrols && {(_noPatrols > 0)}) then { private _spawnLocations = [_coords,_noVehiclePatrols,60,100] call GMS_fnc_findPositionsAlongARadius; @@ -309,7 +311,7 @@ if (GMS_useVehiclePatrols && {((_submarinePatrols > 0) || {!(_submarinePatrolPar ["_sideArms",[]] ]; */ -private _noChoppers = [_noChoppers] call GMSCore_fnc_getNumberFromRange; + if !(_airPatrols isEqualTo [] && {random(1) < _chanceHeliPatrol}) then // Spawn any choppers defined in the array { _temp = [_coords, _airPatrols,_difficulty,_uniforms,_headgear,_vests,_backpacks,_weaponList,_sidearms] call GMS_fnc_spawnMissionHelis; @@ -320,6 +322,8 @@ if !(_airPatrols isEqualTo [] && {random(1) < _chanceHeliPatrol}) then // Spawn _missionInfantry append _unitsSpawned; uisleep delayTime; } else { + // GMSCore_fnc_getNumberFromRange returns -1 if there was an issue. + private _noPatrols = [_noVehiclePatrols] call GMSCore_fnc_getNumberFromRange; if ((_noChoppers > 0) && {random(1) < _chanceHeliPatrol}) then { // GMS_fnc_findPositionsAlongARadius: params["_center","_num","_minDistance","_maxDistance"]; diff --git a/@GMS/addons/GMS/Compiles/Missions/fn_spawnNewMissions.sqf b/@GMS/addons/GMS/Compiles/Missions/fn_spawnNewMissions.sqf index 8b1899a..bde5590 100644 --- a/@GMS/addons/GMS/Compiles/Missions/fn_spawnNewMissions.sqf +++ b/@GMS/addons/GMS/Compiles/Missions/fn_spawnNewMissions.sqf @@ -17,7 +17,7 @@ // TODO: Need to debug for GMS if (GMS_missionsRunning >= GMS_maxSpawnedMissions) exitWith { - [format["_spawnNewMissions (18): GMS_maxSpawnedMissions of %1 Reached",GMS_maxSpawnedMissions]] call GMS_fnc_log; + if (GMS_debugLevel > 0) then {[format["_spawnNewMissions (18): GMS_maxSpawnedMissions of %1 Reached",GMS_maxSpawnedMissions]] call GMS_fnc_log}; }; for "_i" from 1 to (count GMS_missionData) do @@ -36,11 +36,12 @@ for "_i" from 1 to (count GMS_missionData) do _tMax, // as above _waitTime, // time at which a mission should be spawned _missionsData, // Array of data about individual missions that could be spawned. The data table for each mission is defined in _missionSpawner - _isStatic + _isStatic, + _missionFile ]; */ - _missionDescriptors params["_key","_difficulty","_maxMissions","_activeMissions","_tMin","_tMax","_waitTime","_missionsData","_isStatic"]; + _missionDescriptors params["_key","_difficulty","_maxMissions","_activeMissions","_tMin","_tMax","_waitTime","_missionsData","_isStatic","_missionFile"]; // Just in case there are no missions to choose from for some reason. // But this could happen if all of the available missions had reached their maximal number of respawns. @@ -74,12 +75,20 @@ for "_i" from 1 to (count GMS_missionData) do _spawnedAt // index 14 ]; */ - private _missionInitialized = [_key,_missionSelected,GMS_MissionsSpawned,_isStatic] call GMS_fnc_initializeMission; - //[format["_spawnNewMissions (78) GMS_fnc_initializeMission returned %1",_missionInitialized]] call GMS_fnc_log; + private _missionInitialized = [_key,_missionSelected,GMS_MissionsSpawned,_isStatic,_missionFile] call GMS_fnc_initializeMission; + switch (_missionInitialized) do { + case -3: { // No safe spot found for the mission for whatever reason. + // Try to respawn it in a while + #define waitTime 6 + private _wt = diag_tickTime + _tmin + (random(_tMax - _tMin)); + _missionDescriptors set[waitTime, _wt]; + }; + case -2: { // Handle the case in which a mission has been spawned _maxmissionRespawns + // Or a mission threw a FATAL ERROR [format["_spawnNewMission (82): count _missionsData before deletion = %1", count _missionsData]] call GMS_fnc_log; private _posn = _missionsData findIf {(_x select 0) isEqualTo _key}; _missionsData deleteAt _posn; @@ -87,12 +96,23 @@ for "_i" from 1 to (count GMS_missionData) do #define missionsData 7 _missionDescriptors set [missionsData, _missionsData]; }; - case -1: { + + case -1: { // Fatal Error in Marker Configs or markers were not created for some reason. + // Remove this mission from the list. + private _posn = _missionsData findIf {(_x select 0) isEqualTo _key}; + _missionsData deleteAt _posn; + [format["Removed %1 from list of missions because of a FATAL ERROR", _missionFile],'warning'] call GMS_fnc_log; + #define missionsData 7 + _missionDescriptors set [missionsData, _missionsData]; + }; + + case 0: { // The mission failed the test for chance it would be spawned. #define waitTime 6 private _wt = diag_tickTime + _tmin + (random(_tMax - _tMin)); _missionDescriptors set[waitTime, _wt]; }; - case 1: { + + case 1: { // The mission was initialized without any errors GMS_MissionsSpawned = GMS_MissionsSpawned + 1; #define waitTime 6 #define noActive 3 @@ -100,13 +120,15 @@ for "_i" from 1 to (count GMS_missionData) do _missionDescriptors set[waitTime, _wt]; _missionDescriptors set[noActive, _activeMissions + 1]; }; + case 2: { // A special case for static missions that have never been spawned that did not pass the test for chance of a spawn. Here we set waitTime to 60 sec. #define waitTime 6 private _wt = diag_tickTime + 60; _missionDescriptors set[waitTime, _wt]; }; - case 3: { - // Nothing to do here at this time. + + case 3: { // Case of a static mission that was already spawned. + // Nothing to do here at this time. }; }; }; @@ -114,5 +136,4 @@ for "_i" from 1 to (count GMS_missionData) do }; }; -private _exitcode = 1; -_exitCode; + diff --git a/@GMS/addons/GMS/config.cpp b/@GMS/addons/GMS/config.cpp index a02cca2..9666554 100644 --- a/@GMS/addons/GMS/config.cpp +++ b/@GMS/addons/GMS/config.cpp @@ -12,9 +12,9 @@ */ class GMSBuild { - Version = "7.18"; - Build = "273"; - Date = "10-20-2023"; + Version = "7.21"; + Build = "275"; + Date = "10-25-2023"; }; class CfgPatches {